|
SourceForge Jpcap | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jpcap.net.PacketFactory
public class PacketFactory
This factory constructs high-level packet objects from
captured data streams.
The createUnknownPacket(int, java.nio.ByteBuffer, net.sourceforge.jpcap.util.Timeval)
method can be overridden to allow applications
to provide custom Packet classes for protocols of local interest.
In addition, the PacketFactories.properties
file can be over-ridden to add additional
PacketFactory implementations for new protocols.
See the PacketFactories.properties
file provided for details.
This file is loaded from whichever of jpcap.jar or jpcap-core.jar you are using, but:
Field Summary | |
---|---|
protected static Map<String,Constructor<? extends Packet>> |
classes
|
static String |
ETHERNET8023_PREFIX
|
static String |
ETHERNETII_PREFIX
.properties file key prefixes. |
protected static Map<String,Method> |
factories
|
static String |
FACTORY_METHOD_NAME
|
static String |
PACKET_FACTORY_PROPERTIES
Name of the .properties file. |
protected static Properties |
properties
|
Constructor Summary | |
---|---|
PacketFactory()
|
Method Summary | |
---|---|
protected Packet |
createPacket(int linkType,
ByteBuffer bb,
Timeval tv)
Returns a Packet object for the specified linkType and data. |
protected static Packet |
createPacket(String key,
int lLen,
ByteBuffer bb,
Timeval tv)
Create a packet given a properties-file key. |
protected Packet |
createUnknownPacket(int lLen,
ByteBuffer bb,
Timeval tv)
Return a Packet object for an unknown packet format. |
static Packet |
dataToPacket(int linkType,
byte[] bytes)
Convert captured packet data into an object. |
static Packet |
dataToPacket(int linkType,
byte[] bytes,
Timeval tv)
Convert captured packet data into an object. |
static Packet |
dataToPacket(int linkType,
ByteBuffer bb,
Timeval tv)
Convert captured packet data into an object. |
static PacketFactory |
getInstance()
Get the installed PacketFactory instance. |
static void |
setDefault(PacketFactory defaultFactory)
Set the default packet factory. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PACKET_FACTORY_PROPERTIES
public static final String ETHERNETII_PREFIX
public static final String ETHERNET8023_PREFIX
public static final String FACTORY_METHOD_NAME
protected static Properties properties
protected static Map<String,Method> factories
protected static Map<String,Constructor<? extends Packet>> classes
Constructor Detail |
---|
public PacketFactory()
Method Detail |
---|
public static void setDefault(PacketFactory defaultFactory)
defaultFactory
- PacketFactory object for unrecognized packetspublic static Packet dataToPacket(int linkType, byte[] bytes)
linkType
- Link typebytes
- Packet data
public static Packet dataToPacket(int linkType, byte[] bytes, Timeval tv)
linkType
- Link typebytes
- Packet datatv
- Timeval
public static Packet dataToPacket(int linkType, ByteBuffer bb, Timeval tv)
linkType
- Link typebb
- Packet data in a ByteBuffertv
- Timeval
public static PacketFactory getInstance()
protected final Packet createPacket(int linkType, ByteBuffer bb, Timeval tv)
createUnknownPacket(int, java.nio.ByteBuffer, net.sourceforge.jpcap.util.Timeval)
for a packet which isn't recognized by this method;
if that returns null, returns an EthernetPacket
.
Supported packet types include:
linkType
- Link typebb
- ByteBuffertv
- Timeval, or null
protected Packet createUnknownPacket(int lLen, ByteBuffer bb, Timeval tv)
lLen
- Length of link-layer header data to ignorebb
- Packet data in a ByteBuffertv
- Timeval, or null
protected static Packet createPacket(String key, int lLen, ByteBuffer bb, Timeval tv)
key
- Properties-file key, e.g. Ethernet802.3Protocol.dsapssap.0xaaaa.org.0x000c.protocol.0x2000lLen
- Link-layer l=header lengthbb
- Packet data in a ByteBuffertv
- Timeval of packet
|
Copyright © Patrick Charles & Jonas Lehmann, 2001; Esmond Pitt, 2008. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |