|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A header class that was decoded from a captured packet. Each packet contains a number of headers which in tern contain a number of fields.
The header does not contain any data from the capture file or stream. All data is contained within fields. You can query how many fields this header has using the getFieldCount() method and retrieve using the getField(int) or getField(String) method calls.
The header also contains a number of properties. Some properties are LOCAL and others are PERMANENT. Local properties are unrelated instances of some property and PERMANENT proporties are shared as a single instance between headers of the same type. That is a IPv4 headers will share a single instance of all PERMANENT properties defined for IPv4. They will each have a unique instance of LOCAL property though. Properties are stored as jnetstream.primitive.Primitive objects. To get actual data from the primitive object use method call chain form getProperty(String).getValue()
Headers do not contain other headers, only fields can contain other fields. Use the toString() method to printout very verbose output for the header. Each field is printed on separate line. This may produce large amount of output for a large header. I.e. X11 headers commonly produce more than 64Kbytes of text output this way.
To get less verbose output retrive the SUMMARY property for the header. The summary property contains a 1 line summary of the entire header. Below is an example of how to retrieve such a property.
.... skipped try statement .... Decoder decoder = new Decoder("captureFile.pcap"); Packet packet = decoder.nextPacket(); Header header = packet.getHeader("IPv4"); String summary = header.getProperty(Header.SUMMARY).getValue(); .... skipped catch statements ....Example:
import com.voytechs.jnetstream.codec.Packet;
import com.voytechs.jnetstream.codec.Header;
import com.voytechs.jnetstream.codec.Field;
import com.voytechs.jnetstream.codec.Decoder;
import com.voytechs.jnetstream.io.StreamFormatException;
import com.voytechs.jnetstream.npl.SyntaxError;
import java.io.IOException;
public class Tutorial1 {
public static void main(String[] args) {
try {
Decoder decoder = new Decoder("myCaptureFile.pcap");
Packet packet = null;
Header header = null;
Field field = null;
while ( (packet = decoder.nextPacket()) != null) {
header = packet.getHeader("IPv4");
if (header != null) {
field = header.getField("hlen");
System.out.println("hlen=" + field.toString());
} else {
System.out.println(packet.getProperty(Packet.SUMMARY));
}
}
} catch (StreamFormatException t) {
} catch (IOException ie) {
} catch (SyntaxError se) {
}
}
}
Field Summary | |
static java.lang.String |
ABREVIATION
Property contains abbreviation string for the header. |
static java.lang.String |
ACL
Property contains defaul ACL for the header definition. |
static java.lang.String |
ADMINISTRATOR
Property contains the username of the NetRepository administrator who maintains this header. |
static java.lang.String |
ANSI
Property contains ANSI number. |
static java.lang.String |
AUTHOR
Property contains the name of the author of the header. |
static java.lang.String |
COMMON
Property contains common name for the header. |
static java.lang.String |
COMPANY
Property contains the name of the company who owns the rights to the protocol and its headers. |
static java.lang.String |
COPYRIGHT
Property contains copyright for the header defined. |
static java.lang.String |
CREATIONDATE
Property contains the timestamp date of when the header definition was written. |
static java.lang.String |
CREATOR
Property contains the name of the person who wrote the header definition and donated it to OpenSource. |
static java.lang.String |
DESCRIPTION
Property contains full description of the header. |
static java.lang.String |
DOC
Property contains DOC number. |
static java.lang.String |
HIDEHEADERLINE
Property is a flag which indicates if the header output should be displayed or hidden. |
static java.lang.String |
HTTP
Property contains URL HTTP address which contains more information about the header and the protocol. |
static java.lang.String |
IEEE
Property contains IEEE number. |
static java.lang.String |
IETF
Property contains IETF number. |
static java.lang.String |
IMTC
Property contains IMTC number. |
static java.lang.String |
ITU
Property contains ITU number. |
static java.lang.String |
NAME
Property contains the name of this header. |
static java.lang.String |
OMG
Property contains OMG number. |
static java.lang.String |
ORGANIZATION
Property contains the name of the organization who owns the rights to the protocol and its headers if COMPANY is not appropriate. |
static java.lang.String |
OSILAYER
Property contains OSI layer number. |
static java.lang.String |
RFC
Property contains RFC number. |
static java.lang.String |
SHORTDESCRIPTION
Property contains short single linde description for the header. |
static java.lang.String |
SHORTHEADER
Property contains a summary line of the header. |
static java.lang.String |
STD
Property contains RFC's STD number. |
static java.lang.String |
SUMMARY
Property contains single line summary of most important header fields. |
static java.lang.String |
TRADEMARK
Property contains trademark information for the header. |
static java.lang.String |
W3C
Property contains W3C number. |
Fields inherited from interface com.voytechs.jnetstream.codec.Identity |
SHORT_NAME |
Method Summary | |
Field |
getField(int index)
Returns the requested field by index. |
Field |
getField(java.lang.String name)
Returns the requested field by name. |
int |
getFieldCount()
Returns the number of fields within this header. |
int |
getHeaderLength()
Get the length of the header in bytes. |
java.lang.Object |
getValue(int index)
Conveniece method to retrieve a value of a field directly. |
java.lang.Object |
getValue(java.lang.String name)
Conveniece method to retrieve a value of a field or propert directly. |
Methods inherited from interface com.voytechs.jnetstream.codec.Identity |
getName, getProperty |
Field Detail |
public static final java.lang.String NAME
public static final java.lang.String SUMMARY
public static final java.lang.String COMMON
public static final java.lang.String RFC
public static final java.lang.String STD
public static final java.lang.String IEEE
public static final java.lang.String IMTC
public static final java.lang.String ITU
public static final java.lang.String OMG
public static final java.lang.String W3C
public static final java.lang.String IETF
public static final java.lang.String ANSI
public static final java.lang.String DOC
public static final java.lang.String OSILAYER
public static final java.lang.String DESCRIPTION
public static final java.lang.String SHORTHEADER
public static final java.lang.String COMPANY
public static final java.lang.String ORGANIZATION
public static final java.lang.String COPYRIGHT
public static final java.lang.String TRADEMARK
public static final java.lang.String SHORTDESCRIPTION
public static final java.lang.String ABREVIATION
public static final java.lang.String HTTP
public static final java.lang.String AUTHOR
public static final java.lang.String CREATOR
public static final java.lang.String ADMINISTRATOR
public static final java.lang.String CREATIONDATE
public static final java.lang.String ACL
public static final java.lang.String HIDEHEADERLINE
Method Detail |
public Field getField(java.lang.String name)
public Field getField(int index)
public int getFieldCount()
public java.lang.Object getValue(java.lang.String name)
name
- Field or property name to retrieve the value from.
public java.lang.Object getValue(int index)
index
- Index of the field within the header to retrieve the value
from.
public int getHeaderLength()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |