|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Header
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. |
Header |
getHeader(int index)
Returns the indexed header from the packet. |
Header |
getHeader(java.lang.String name)
Returns the named header from the packet. |
int |
getHeaderCount()
Returns the number of headers in this packet. |
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. |
boolean |
hasHeader(java.lang.String name)
Checks to if the specified header exists in the packet. |
| Methods inherited from interface com.voytechs.jnetstream.codec.Identity |
|---|
getName, getProperty |
| Field Detail |
|---|
static final java.lang.String NAME
static final java.lang.String SUMMARY
static final java.lang.String COMMON
static final java.lang.String RFC
static final java.lang.String STD
static final java.lang.String IEEE
static final java.lang.String IMTC
static final java.lang.String ITU
static final java.lang.String OMG
static final java.lang.String W3C
static final java.lang.String IETF
static final java.lang.String ANSI
static final java.lang.String DOC
static final java.lang.String OSILAYER
static final java.lang.String DESCRIPTION
static final java.lang.String SHORTHEADER
static final java.lang.String COMPANY
static final java.lang.String ORGANIZATION
static final java.lang.String COPYRIGHT
static final java.lang.String TRADEMARK
static final java.lang.String SHORTDESCRIPTION
static final java.lang.String ABREVIATION
static final java.lang.String HTTP
static final java.lang.String AUTHOR
static final java.lang.String CREATOR
static final java.lang.String ADMINISTRATOR
static final java.lang.String CREATIONDATE
static final java.lang.String ACL
static final java.lang.String HIDEHEADERLINE
| Method Detail |
|---|
Field getField(java.lang.String name)
Field getField(int index)
int getFieldCount()
java.lang.Object getValue(java.lang.String name)
name - Field or property name to retrieve the value from.
java.lang.Object getValue(int index)
index - Index of the field within the header to retrieve the value
from.
int getHeaderLength()
int getHeaderCount()
boolean hasHeader(java.lang.String name)
name - name of the header to check for.
Header getHeader(java.lang.String name)
Returns the named header from the packet. If the header with the given
name is not found, null is returned.
Packet is made up of a number of headers that the decoder was able to
decode from the capture file or stream. To find out how many headers
use the getHeaderCount() method call.
Header getHeader(int index)
Returns the indexed header from the packet. If index is out of range
then null is returned.
Packet is made up of a number of headers that the decoder was able to
decode from the capture file or stream. To find out how many headers
use the getHeaderCount() method call.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||