|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jnetpcap.winpcap.WinPcapSendQueue
public class WinPcapSendQueue
Class peered with native pcap_send_queue
structure. A queue
of raw packets that will be sent to the network with
WinPcap.sendqueueTransmit()
. The class peers with native C
pcap_send_queue structure and allows direct control. The structure can be
allocated using WinPcap.sendQueueAlloc method or can be directly instantiated
using one o the public constructors.
Field Summary | |
---|---|
static int |
DEFAULT_QUEUE_SIZE
Constant used to determine the default queue size which is 64Kb (1024 * 64). |
Constructor Summary | |
---|---|
WinPcapSendQueue()
Allocates default size buffer for use as a send queue. |
|
WinPcapSendQueue(byte[] data)
Creates a sendqueue by allocating a buffer to hold the supplied data. |
|
WinPcapSendQueue(java.nio.ByteBuffer buffer)
The queue uses the supplied byte buffer which holds the buffers contents. |
|
WinPcapSendQueue(int size)
Allocates specific queue size |
Method Summary | |
---|---|
java.nio.ByteBuffer |
getBuffer()
Gets the buffer containing the packets to be sent. |
int |
getLen()
Gets the current size of the queue, in bytes. |
int |
getMaxLen()
Gets the maximum size of the the queue, in bytes. |
int |
queue(PcapPktHdr hdr,
byte[] data)
Add a packet to a send queue. |
int |
queue(PcapPktHdr hdr,
java.nio.ByteBuffer data)
Add a packet to a send queue. |
void |
setLen(int len)
Sets the peered pcap_send_queue.len field which specifies
the urrent size of the queue, in bytes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_QUEUE_SIZE
Constructor Detail |
---|
public WinPcapSendQueue()
public WinPcapSendQueue(int size)
size
size
- size of the queue in bytespublic WinPcapSendQueue(java.nio.ByteBuffer buffer)
The queue uses the supplied byte buffer which holds the buffers contents. The buffer must a direct buffer, array based buffers will be rejected and an exception thrown. The properties of the buffer are used as follows. The start of the buffer is always with index 0, and end of queue content at current buffer's limit property (comparible to pcap_send_queue.len). The capacity property (comparible to pcap_send_queue.maxlen) determines maximum amount of data that can be further stored in the buffer.
Note that changing properties of the buffer after creating this queue object, will have immediate effect up on the queue. You do not have to use the queue's provided methods to change the limit property. This should allow of external addition of the
buffer
- a direct buffer containing the data to be sendpublic WinPcapSendQueue(byte[] data)
data
- data to be copied into the queueMethod Detail |
---|
public void setLen(int len)
pcap_send_queue.len
field which specifies
the urrent size of the queue, in bytes.
len
- current size of the queue, in bytespublic int getLen()
public int getMaxLen()
public java.nio.ByteBuffer getBuffer()
public int queue(PcapPktHdr hdr, java.nio.ByteBuffer data)
hdr
points to a
PcapPktHdr structure with the timestamp and the length of the packet, data
points to a buffer with the data of the packet. The PcapPktHdr structure is
the same used by WinPcap and libpcap to store the packets in a file,
therefore sending a capture file is straightforward. 'Raw packet' means
that the sending application will have to include the protocol headers,
since every packet is sent to the network 'as is'. The CRC of the packets
needs not to be calculated, because it will be transparently added by the
network interface.
hdr
- all fields need to be initialized as they are all useddata
- Buffer containing packet data. The buffer's position and limit
properties determine the area of the buffer to be copied into the
queue. The length of the data must much what is in the header.
Also the queue has to be large enough to hold all of the data, or
an exception will be thrown.
java.lang.IllegalArgumentException
- if amount of data in the buffer (limit - position) does match the
hdr.getCaplen() value
java.nio.BufferUnderflowException
- if the queues buffer capacity is too small to hold all of the
datapublic int queue(PcapPktHdr hdr, byte[] data)
hdr
points to a
PcapPktHdr structure with the timestamp and the length of the packet, data
points to a buffer with the data of the packet. The PcapPktHdr structure is
the same used by WinPcap and libpcap to store the packets in a file,
therefore sending a capture file is straightforward. 'Raw packet' means
that the sending application will have to include the protocol headers,
since every packet is sent to the network 'as is'. The CRC of the packets
needs not to be calculated, because it will be transparently added by the
network interface.
hdr
- all fields need to be initialized as they are all useddata
- Buffer containing packet data. The length of the data must much
what is in the header. Also the queue has to be large enough to
hold all of the data, or an exception will be thrown.
java.lang.IllegalArgumentException
- if amount of data does match the hdr.getCaplen() value
java.nio.BufferUnderflowException
- if the queues buffer capacity is too small to hold all of the
data
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |