|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Field
Field contains data read from the capture file or stream. Fields are defined within NPL protocol definitions and are added to Header objects according to the definition in the order they were defined and encountered.
So combination of headers and their fields break down the structure of protocols and their headers within packets.
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(0);
if (header.getName().equals("Ethernet") == true) {
field = header.getField("proto");
} else {
field = header.getField(1);
}
System.out.println(field.toString());
}
} catch (StreamFormatException t) {
} catch (IOException ie) {
} catch (SyntaxError se) {
}
}
}
| Field Summary | |
|---|---|
static java.lang.String |
COMMON
Property contains common name for the field. |
static java.lang.String |
DESCRIPTION
Property contains full description of the field. |
static java.lang.String |
FORMAT
Property specifies primitive type specific format string which is used to reformat the output of the field. |
static java.lang.String |
HIDENAME
Property is a flag indicating the name of the field should not be displayed to the user. |
static java.lang.String |
HIDEVALUE
Property is a flag indicating the value of the field should not be displayed to the user. |
static java.lang.String |
HTTP
Property contains URL HTTP address which contains more information about the field and the header.. |
static java.lang.String |
MAX
Property specifies the maximum value this field can have. |
static java.lang.String |
MIN
Property specifies the minimum value this field can have. |
static java.lang.String |
MODIFIED
Property specifies the last time the definition to the field has been modified. |
static java.lang.String |
UNITS
Property specifies the units name for the field value. |
static java.lang.String |
UNITVALUE
Property specifies new value for the field. |
static java.lang.String |
VALUE_NAME
Property is automatically assigned to the ENUM name of the value, if one is found. |
| Fields inherited from interface com.voytechs.jnetstream.codec.Identity |
|---|
SHORT_NAME |
| Method Summary | |
|---|---|
Field |
getField(int index)
Return the requested sub-field by index from the field. |
Field |
getField(java.lang.String name)
Return the requested sub-field by name from the parent field. |
int |
getFieldCount()
Returns the number of sub-fields within this field. |
Primitive |
getPrimitive()
Accessor method that returns the value object of this field. |
int |
getSize()
Returns the size in bit of the field. |
java.lang.Object |
getValue()
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 property directly. |
boolean |
hasFields()
Returns a flag indicating if this field is broken up into additional structure of subfields. |
| Methods inherited from interface com.voytechs.jnetstream.codec.Identity |
|---|
getName, getProperty |
| Field Detail |
|---|
static final java.lang.String COMMON
static final java.lang.String HIDENAME
static final java.lang.String HIDEVALUE
static final java.lang.String DESCRIPTION
static final java.lang.String HTTP
static final java.lang.String MODIFIED
static final java.lang.String MIN
static final java.lang.String MAX
static final java.lang.String FORMAT
static final java.lang.String UNITS
static final java.lang.String UNITVALUE
static final java.lang.String VALUE_NAME
| Method Detail |
|---|
Primitive getPrimitive()
Accessor method that returns the value object of this field. The reason for the value being an Object is that certain header fields are not nice primitives such as ints and Strings. There are numerous others such as "FLAGS", 32bit and 128bit IP addresses and so forth.
All of this is encapsulated in under the ProtocolPrimitive interface.
If there are subfields present for this field, the "value" is the primitive representation of the field value at this level. Subfields can be queried for additial substructure of this field.
i.e. FlagsBigEndian allows to define a standard set of subfield values for each of the bits in the in a protocol "flag" field of a header.
int getSize()
boolean hasFields()
Returns a flag indicating if this field is broken up into additional structure of subfields. If yes, you can use the getSufieldsMethod to get an array of subfields.
Field getField(java.lang.String name)
Field getField(int index)
int getFieldCount()
java.lang.Object getValue()
java.lang.Object getValue(java.lang.String name)
name - property name to retrieve the value from.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||