|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
com.voytechs.jnetstream.io.ProtocolDataInputStream
com.voytechs.jnetstream.io.PacketInputStream
com.voytechs.jnetstream.io.QueuePacketInputStream
public class QueuePacketInputStream
Allows packet data to be passed in as byte[] directly into the inputstream. No capture files are decoded, only user supplied packet data is decoded from the supplied user buffers. Here is an example:
import java.io.*;
import java.sql.*;
import com.voytechs.jnetstream.io.*;
import com.voytechs.jnetstream.codec.*;
public class InMemoryTest
{
public static void main(String[] args)
{
byte[] buffer = {
(byte)0x00, (byte)0x03, (byte)0x42, (byte)0x57,
(byte)0x80, (byte)0x02, (byte)0x00, (byte)0x60,
(byte)0x0f, (byte)0xec, (byte)0x78, (byte)0xee,
(byte)0x88, (byte)0x64, (byte)0x11, (byte)0x00,
(byte)0xbf, (byte)0x91, (byte)0x00, (byte)0x44,
(byte)0x00, (byte)0x21, (byte)0x45, (byte)0x00,
(byte)0x00, (byte)0x42, (byte)0x08, (byte)0x93,
(byte)0x00, (byte)0x00, (byte)0x40, (byte)0x11,
(byte)0x24, (byte)0x65, (byte)0x41, (byte)0x06,
(byte)0xae, (byte)0xfd, (byte)0xcd, (byte)0x98,
(byte)0x90, (byte)0x17, (byte)0xc4, (byte)0x01,
(byte)0x00, (byte)0x35, (byte)0x00, (byte)0x2e,
(byte)0xa9, (byte)0x88, (byte)0x15, (byte)0xb8,
(byte)0x01, (byte)0x00, (byte)0x00, (byte)0x01,
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x00, (byte)0x00, (byte)0x04, (byte)0x77,
(byte)0x70, (byte)0x61, (byte)0x64, (byte)0x0b,
(byte)0x6c, (byte)0x61, (byte)0x75, (byte)0x6e,
(byte)0x63, (byte)0x68, (byte)0x6d, (byte)0x6f,
(byte)0x64, (byte)0x65, (byte)0x6d, (byte)0x03,
(byte)0x63, (byte)0x6f, (byte)0x6d, (byte)0x00,
(byte)0x00, (byte)0x01, (byte)0x00, (byte)0x01
};
String firstHeader = "Ethernet2";
Timestamp timestamp = new Timestamp (System.currentTimeMillis());
try {
QueuePacketInputStream in = new QueuePacketInputStream();
Decoder decoder = new Decoder(in);
in.addBuffer(buffer, firstHeader, timestamp);
Packet pkt = decoder.nextPacket();
System.out.println(pkt);
}
catch (Exception ex) {
System.out.println("ERROR in jnetstream. Exception: " + ex);
}
}
}
This produces the following output:
Ether: ---- Ethernet2 OSI=2 Frame #1 Captured on 2005-05-23 18:15:42.803 ----
Ether:
Ether: dst = 0:3:42:57:80:2
Ether: src = 0:60:f:ec:78:ee
Ether: proto = 0x8864 "(PPPOE) PPP Over Ethernet"
Ether: crc = (Frame check supressed)
Ether:
PPPOE: ---- PPPOE RFC=2516 OSI=2 ----
PPPOE:
PPPOE: ver = 1 "Version 1"
PPPOE: type = 1 "Type 1"
PPPOE: code = 0 "PPP session packet"
PPPOE: session_id = 49041
PPPOE: length = 68 (octets)
PPPOE:
PPP: ---- PPP RFC=1661,1662 OSI=2 ----
PPP:
PPP: protocol = 0x21 "Internet Protocol Version 4 (IPv4)"
PPP:
IPv4: ---- IPv4 RFC=791 OSI=3 ----
IPv4:
IPv4: ver = 4 "Internet Protocol version 4"
IPv4: hlen = 5 (20 bytes) "No IP options present"
IPv4: tos = 00000000 0x0
IPv4: 000..... 0x0 = [precedence] "Routine"
IPv4: ...0.... 0x0 = [delay] "Normal delay"
IPv4: ....0... 0x0 = [throughtput] "Normal throughput"
IPv4: .....0.. 0x0 = [reliability] "Normal reliability"
IPv4: ......00 0x0 = [reserved]
IPv4: len = 66 (46 bytes of data)
IPv4: id = 0x893
IPv4: flags = 000 0x0 (bit fields)
IPv4: 0.. 0x0 = [reserved]
IPv4: .0. 0x0 = [df] "fragmentation OK"
IPv4: ..0 0x0 = [mf] "no more fragments"
IPv4: offset = 0 (bytes)
IPv4: ttl = 64 (hops)
IPv4: proto = 17 "(UDP) User Datagram Protocol (RFC768)"
IPv4: checksum = 0x2465
IPv4: saddr = 65.6.174.253
IPv4: daddr = 205.152.144.23
IPv4:
UDP: ---- UDP RFC=768 OSI=4 ----
UDP:
UDP: sport = 50177
UDP: dport = 53
UDP: len = 46 (38 bytes of data)
UDP: crc = 0xa988
UDP:
DNS: ---- DNS RFC=1035 OSI=7 ----
DNS:
DNS: transactionid = 0x15b8
DNS: flags = 0000000100000000 0x100
DNS: 0............... 0 = [qr] "Query"
DNS: .0000........... 0 = [op] "Standard query"
DNS: .....0.......... 0 = [aa] "Server isn't authority for domain"
DNS: ......0......... 0 = [tc] "Message is not truncated"
DNS: .......1........ 1 = [rd] "Do query recursively"
DNS: ........0....... 0 = [ra] "Server can't do recursive queries"
DNS: .........000.... 0 = [z] "Answer/authority portion was not authenticated by the server"
DNS: ............0000 0 = [rcode] "No error condition"
DNS: Questions = 1
DNS: Answer = 0 (RRs)
DNS: Authority = 0 (RRs)
DNS: Additional = 0 (RRs)
DNS:
DNS: DNS.QuestionSection[0]
DNS: name = "wpad.launchmodem.com."
DNS: Type = 1
DNS: Class = 1 "Internet Address"
| Nested Class Summary | |
|---|---|
class |
QueuePacketInputStream.BufferEntry
A little utility class to hold extra information along with the buffer. |
| Nested classes/interfaces inherited from class com.voytechs.jnetstream.io.PacketInputStream |
|---|
PacketInputStream.BufferedHeader |
| Field Summary | |
|---|---|
static java.lang.String |
MODULE
|
| Fields inherited from class com.voytechs.jnetstream.io.PacketInputStream |
|---|
captureDeviceArch, captureDeviceFilename, captureDeviceIp, captureDeviceOS, captureLive, debugHeaders, fileHeader, linkType, packetCaptureTimestamp, packetEnd, packetLength, packetSnaplen, packetStart, recordEnd, recordHeader, recordLength, recordStart, stackIn |
| Fields inherited from class com.voytechs.jnetstream.io.ProtocolDataInputStream |
|---|
bitsLeft, in |
| Constructor Summary | |
|---|---|
QueuePacketInputStream()
Sets up an empty ByteArray input stream. |
|
QueuePacketInputStream(ExpandableByteArrayInputStream ein)
Sets up an empty ByteArray input stream. |
|
| Method Summary | |
|---|---|
void |
addBuffer(byte[] buf,
java.lang.String firstHeader,
java.sql.Timestamp captureTimestamp)
Adds a new buffer to the FIFO list of buffers to process. |
java.lang.String |
getCaptureFormatName()
Not supported |
java.util.Enumeration |
getMetaEnumeration()
Not supported. |
protected void |
initRecordHeader()
Retrieve next packet from our FIFO queue and prep the inputstream for packet reading and boundary checking.. |
boolean |
isMetaDataSupported()
Meta information is not supported with this particular class. |
static void |
main(java.lang.String[] args)
Example method of how to use QueuePacketInputStream. |
| Methods inherited from class com.voytechs.jnetstream.io.ProtocolDataInputStream |
|---|
readBits, readBitsLong, readBoolean, readByte, readerUnsignedLongLittleEndian, readFromPacket, readFromPacket, readInt, readIntLittleEndian, readLong, readLongLittleEndian, readShort, readShortLittleEndian, readUnsignedByte, readUnsignedInt, readUnsignedIntLittleEndian, readUnsignedLong, readUnsignedShort, readUnsignedShortLittleEndian, reThrow |
| Methods inherited from class java.io.InputStream |
|---|
available, close, mark, markSupported, read, read, reset |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String MODULE
| Constructor Detail |
|---|
public QueuePacketInputStream()
throws java.io.IOException,
EOPacketStream,
StreamFormatException
java.io.IOException
EOPacketStream
StreamFormatException
public QueuePacketInputStream(ExpandableByteArrayInputStream ein)
throws java.io.IOException,
EOPacketStream,
StreamFormatException
java.io.IOException
EOPacketStream
StreamFormatException| Method Detail |
|---|
public void addBuffer(byte[] buf,
java.lang.String firstHeader,
java.sql.Timestamp captureTimestamp)
buf - Buffer to add to the FIFO queue.firstHeader - Name of the first header to use to process the
packet buffer. The name has to be defined in NPL protocol definitions
of the current version of this software.captureTimestamp - amount of milli seconds since 1970 greenwitch
time specifying the time at which this packet was created.
protected void initRecordHeader()
throws java.io.IOException,
EOPacketStream,
StreamFormatException
initRecordHeader in class PacketInputStreamjava.io.IOException
EOPacketStream
StreamFormatExceptionpublic java.lang.String getCaptureFormatName()
getCaptureFormatName in interface CaptureMetaFormatpublic java.util.Enumeration getMetaEnumeration()
getMetaEnumeration in interface CaptureMetaFormatpublic boolean isMetaDataSupported()
isMetaDataSupported in interface CaptureMetaFormatpublic static void main(java.lang.String[] args)
args - Expects a single argument, filename of a capture file.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||