本文整理汇总了Java中org.jnetpcap.util.checksum.Checksum.inChecksum方法的典型用法代码示例。如果您正苦于以下问题:Java Checksum.inChecksum方法的具体用法?Java Checksum.inChecksum怎么用?Java Checksum.inChecksum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jnetpcap.util.checksum.Checksum
的用法示例。
在下文中一共展示了Checksum.inChecksum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateChecksum
import org.jnetpcap.util.checksum.Checksum; //导入方法依赖的package包/类
/**
* Calculate checksum.
*
* @return the int
* @see org.jnetpcap.packet.JHeaderChecksum#calculateChecksum()
*/
@Override
public int calculateChecksum() {
final JPacket packet = getPacket();
return Checksum.inChecksum(packet, getHeaderOffset(), size()
- getHeaderOffset());
}
示例2: testIp4CRC16Pkt1
import org.jnetpcap.util.checksum.Checksum; //导入方法依赖的package包/类
/**
* Test ip4 cr c16 pkt1.
*/
public void testIp4CRC16Pkt1() {
JPacket packet = super.getPcapPacket(TestUtils.L2TP, 0);
Ip4 ip = packet.getHeader(new Ip4());
int computed = Checksum.inChecksum(ip, 0, ip.size());
System.out.printf("1chunk=%x\n", computed);
System.out.printf("shoudbe=%x checksum=%x\n",
Checksum.inChecksumShouldBe(ip.checksum(), computed),
ip.checksum());
assertTrue(ip.isChecksumValid());
}
示例3: isChecksumValid
import org.jnetpcap.util.checksum.Checksum; //导入方法依赖的package包/类
/**
* Checks if the checksum is valid, even for fragmented packets.
*
* @return true if checksum checks out, otherwise if the computed checksum
* does not match the stored checksum false is returned
*/
public boolean isChecksumValid() {
return Checksum.inChecksum(this, 0, this.size()) == 0;
}