com.voytechs.jnetstream.codec
Interface Header

All Superinterfaces:
Identity
All Known Implementing Classes:
HeaderImpl

public interface Header
extends Identity

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) {
       }
     }
 }
 

Author:
Mark Bednarczyk

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

NAME

public static final java.lang.String NAME
Property contains the name of this header. This is a PERMENENT String property. Returns the name assigned to the header.

See Also:
Constant Field Values

SUMMARY

public static final java.lang.String SUMMARY
Property contains single line summary of most important header fields. This is a LOCAL String property. Header definition creates the SUMMARY property using what are the most import fields of the header.

See Also:
Constant Field Values

COMMON

public static final java.lang.String COMMON
Property contains common name for the header. This is a PERMANENT String property. Common name given to the protocol. Normally overrides what is output to the user, if the NAME property is too akward.

See Also:
Constant Field Values

RFC

public static final java.lang.String RFC
Property contains RFC number. This is a PERMANENT Integer property.

See Also:
Constant Field Values

STD

public static final java.lang.String STD
Property contains RFC's STD number. This is a PERMANENT Integer property.

See Also:
Constant Field Values

IEEE

public static final java.lang.String IEEE
Property contains IEEE number. This is a PERMANENT String property.

See Also:
Constant Field Values

IMTC

public static final java.lang.String IMTC
Property contains IMTC number. This is a PERMANENT String property.

See Also:
Constant Field Values

ITU

public static final java.lang.String ITU
Property contains ITU number. This is a PERMANENT String property.

See Also:
Constant Field Values

OMG

public static final java.lang.String OMG
Property contains OMG number. This is a PERMANENT String property.

See Also:
Constant Field Values

W3C

public static final java.lang.String W3C
Property contains W3C number. This is a PERMANENT String property.

See Also:
Constant Field Values

IETF

public static final java.lang.String IETF
Property contains IETF number. This is a PERMANENT String property.

See Also:
Constant Field Values

ANSI

public static final java.lang.String ANSI
Property contains ANSI number. This is a PERMANENT String property.

See Also:
Constant Field Values

DOC

public static final java.lang.String DOC
Property contains DOC number. This is a PERMANENT String property.

See Also:
Constant Field Values

OSILAYER

public static final java.lang.String OSILAYER
Property contains OSI layer number. This is a PERMANENT Integer property. OSI layer determines the header type according to OSI layer table:
  1. Physical
  2. Data Link
  3. Network
  4. Transport
  5. Session
  6. Representation
  7. Application

See Also:
Constant Field Values

DESCRIPTION

public static final java.lang.String DESCRIPTION
Property contains full description of the header. This is a PERMANENT String property. This description is used by applications to display help information about the header.

See Also:
Constant Field Values

SHORTHEADER

public static final java.lang.String SHORTHEADER
Property contains a summary line of the header. This is a LOCAL String property. Short header is slightly different from SUMMARY property in that it is used to display at top of header titles.

See Also:
Constant Field Values

COMPANY

public static final java.lang.String COMPANY
Property contains the name of the company who owns the rights to the protocol and its headers. This is a PERMANENT String property.

See Also:
Constant Field Values

ORGANIZATION

public static final 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. This is a PERMANENT String property.

See Also:
Constant Field Values

COPYRIGHT

public static final java.lang.String COPYRIGHT
Property contains copyright for the header defined. Copyright notice will always be displayed to the user when the header is encountered. This is a PERMANENT String property.

See Also:
Constant Field Values

TRADEMARK

public static final java.lang.String TRADEMARK
Property contains trademark information for the header. This is a PERMANENT String property.

See Also:
Constant Field Values

SHORTDESCRIPTION

public static final java.lang.String SHORTDESCRIPTION
Property contains short single linde description for the header. This property is PERMANENT String property. Just like DESCRIPTION Property but shorter.

See Also:
Constant Field Values

ABREVIATION

public static final java.lang.String ABREVIATION
Property contains abbreviation string for the header. This property is PERMANENT String property.

See Also:
Constant Field Values

HTTP

public static final java.lang.String HTTP
Property contains URL HTTP address which contains more information about the header and the protocol. This is a PERMANENT String property.

See Also:
Constant Field Values

AUTHOR

public static final java.lang.String AUTHOR
Property contains the name of the author of the header. This property is PERMANENT String property. Author is different from the creator of the definition for the protocol.

See Also:
Constant Field Values

CREATOR

public static final java.lang.String CREATOR
Property contains the name of the person who wrote the header definition and donated it to OpenSource. This property is PERMANENT String property.

See Also:
Constant Field Values

ADMINISTRATOR

public static final java.lang.String ADMINISTRATOR
Property contains the username of the NetRepository administrator who maintains this header. This is a PERMANENT String property. NetRepository is an online database of protocols which are user accessible. This property contains the username of the protocol who maintains the definition of this header.

See Also:
Constant Field Values

CREATIONDATE

public static final java.lang.String CREATIONDATE
Property contains the timestamp date of when the header definition was written. This is a PERMANENT String property.

See Also:
Constant Field Values

ACL

public static final java.lang.String ACL
Property contains defaul ACL for the header definition. This is a PERMANENT String property. ACL is used to determine how the header definition may be used or not used.

See Also:
Constant Field Values

HIDEHEADERLINE

public static final java.lang.String HIDEHEADERLINE
Property is a flag which indicates if the header output should be displayed or hidden. This is a LOCAL or PERMANENT Integer property.

See Also:
Constant Field Values
Method Detail

getField

public Field getField(java.lang.String name)
Returns the requested field by name. If the field with requested name is not found, null is returned.

Returns:
The requested field or null if not found.

getField

public Field getField(int index)
Returns the requested field by index. If the index is out of range then null is returned.

Returns:
The requested field or null if index out of range.

getFieldCount

public int getFieldCount()
Returns the number of fields within this header. The count does not count any subfields of fields, only its direct children fields.

Returns:
Number of direct children contained within this field.

getValue

public java.lang.Object getValue(java.lang.String name)
Conveniece method to retrieve a value of a field or propert directly.

Parameters:
name - Field or property name to retrieve the value from.
Returns:
Opaque value of the field or property.
Since:
JNetStream 0.2.2

getValue

public java.lang.Object getValue(int index)
Conveniece method to retrieve a value of a field directly.

Parameters:
index - Index of the field within the header to retrieve the value from.
Returns:
Opaque value of the field.
Since:
JNetStream 0.2.2

getHeaderLength

public int getHeaderLength()
Get the length of the header in bytes.

Returns:
length of the header in bytes.