本文整理汇总了Java中org.jnetpcap.PcapPktHdr.getCaplen方法的典型用法代码示例。如果您正苦于以下问题:Java PcapPktHdr.getCaplen方法的具体用法?Java PcapPktHdr.getCaplen怎么用?Java PcapPktHdr.getCaplen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jnetpcap.PcapPktHdr
的用法示例。
在下文中一共展示了PcapPktHdr.getCaplen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queue
import org.jnetpcap.PcapPktHdr; //导入方法依赖的package包/类
/**
* Add a packet to a send queue. This method adds a packet at the end of the
* send queue pointed by the queue parameter. <code>hdr</code> 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.
*
* @param hdr
* all fields need to be initialized as they are all used
* @param data
* 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.
* @return 0 on success; exception thrown on failure
* @deprecated replaced with new versions of the same method
*/
@Deprecated
public int queue(PcapPktHdr hdr, byte[] data) {
if (data.length != hdr.getCaplen()) {
throw new IllegalArgumentException("Buffer length "
+ "does not equal length in packet header");
}
int p = getLen();
/*
* Write the packet header first
*/
buffer.setInt(p, (int) hdr.getSeconds());
buffer.setInt(p + 4, hdr.getUseconds());
buffer.setInt(p + 8, hdr.getCaplen());
buffer.setInt(p + 12, hdr.getLen());
buffer.setByteArray(p + 16, data);
incLen(16 + data.length);
return 0;
}