当前位置: 首页>>代码示例>>Java>>正文


Java PcapPktHdr.getCaplen方法代码示例

本文整理汇总了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;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:45,代码来源:WinPcapSendQueue.java


注:本文中的org.jnetpcap.PcapPktHdr.getCaplen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。