What are possible values returned by Ip4.typeDescription()

4 replies [Last post]
ohaya
Offline
Joined: 07/13/2009

Hi,

Per the subject... What are the possible values returned from the typeDescription() call?

What I've seen thus far, I think, per the Javadocs, are:

tcp
next: udp
icmp

Are there any others, i.e., what if it's not one of those 3?

Thanks,
Jim

Mark Bednarczyk
Mark Bednarczyk's picture
Offline
Joined: 03/22/2008
String next =


String next = Ip4Type.toString(type());
return (offset() == 0) ? "next: " + next : "ip fragment"
+ (next == null ? "" : " of " + next + " PDU");

So its the names of the constants in Ip4Type enum table. When there is no match it converts the numerical value to a string. I believe currently there are only a few constants defined, but its super easy to add all the remaining registered names in there.

Sly Technologies, Inc.
R&D

ohaya
Offline
Joined: 07/13/2009
Hi, Couldn't get your code

Hi,

Couldn't get your code to compile Smile, so I tried this:

import org.jnetpcap.protocol.network.Ip4;


public class ListIP4Types {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Ip4.Ip4Type [] tableOfIp4Types = Ip4.Ip4Type.values();
		int numIp4Types = tableOfIp4Types.length;
		System.out.println("Table of jNetPcap Ip4.Ip4Type:");
		for (int i = 0; i < numIp4Types; i++) {
			System.out.println("Ip4Type[" + i + "] = [" + tableOfIp4Types[i] + "][" + tableOfIp4Types[i].getDescription() + "]");
		}
		
/*
		String next = Ip4.Ip4Type.toString(type());
		return (offset() == 0) ? "next: " + next : "ip fragment"
		    + (next == null ? "" : " of " + next + " PDU");
*/
		
	}

}

which yielded:


Table of jNetPcap Ip4.Ip4Type:
Ip4Type[0] = [ICMP][icmp]
Ip4Type[1] = [TCP][tcp]
Ip4Type[2] = [UDP][udp]

Does that look right?

Jim

Mark Bednarczyk
Mark Bednarczyk's picture
Offline
Joined: 03/22/2008
Yes. I added a bunch of new

Yes. I added a bunch of new constants to that table from IANA registry. The list will be longer. Remember that the CONSTANT is what you want to use in your code as conditional operations, not rely on description for programatic things. Descriptions may change and are there only as a convenience for human readable consumption.

Sly Technologies, Inc.
R&D

Mark Bednarczyk
Mark Bednarczyk's picture
Offline
Joined: 03/22/2008
Here a link to javadoc of

Here a link to javadoc of updates Ip4Type table:
http://jnetpcap.com/docs/javadoc/latest/org/jnetpcap/protocol/network/Ip...

Sly Technologies, Inc.
R&D

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.