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
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.
Hi,
Couldn't get your code to compile
, 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
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.
Here a link to javadoc of updates Ip4Type table:
http://jnetpcap.com/docs/javadoc/latest/org/jnetpcap/protocol/network/Ip...