• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Ip6类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jnetpcap.protocol.network.Ip6的典型用法代码示例。如果您正苦于以下问题:Java Ip6类的具体用法?Java Ip6怎么用?Java Ip6使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Ip6类属于org.jnetpcap.protocol.network包,在下文中一共展示了Ip6类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: modifyPacket

import org.jnetpcap.protocol.network.Ip6; //导入依赖的package包/类
/**
 * In this function the packet is pseudonymization and checksums are recalculated as configured.
 *
 * @param packet the captured packet
 */
public void modifyPacket(JPacket packet) {
    if ((!DNS_ONLY) || isDns(packet)) {
        // If the original ip4 checksum is not valid, the checksum should not be modified.
        boolean originalChecksumValid = true;

        if (_pseudonymizerMap.containsKey(JProtocol.IP4) && packet.hasHeader(Ip4.ID)) {
            Ip4 ip4 = packet.getHeader(new Ip4());
            originalChecksumValid = ip4.isChecksumValid();
            pseudonymizeIP4(_pseudonymizerMap.get(JProtocol.IP4), ip4);
        } else if (_pseudonymizerMap.containsKey(JProtocol.IP6) && packet.hasHeader(Ip6.ID)) {
            Ip6 ip6 = packet.getHeader(new Ip6());
            pseudonymizeIP6(_pseudonymizerMap.get(JProtocol.IP6), ip6);
        }
        // Checksum updates.
        recalculateChecksums(packet, originalChecksumValid);
    }
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:23,代码来源:JNetPcapPacketModifier.java


示例2: recalulateUdpChecksum

import org.jnetpcap.protocol.network.Ip6; //导入依赖的package包/类
/**
 * Within JNetPcap the UDP checksum recalculation does not work.
 * It is reimplemented here.
 *
 * @param packet packet to recalculate the udp checksum over.
 */
private void recalulateUdpChecksum(final JPacket packet) {
    final Udp udp = packet.getHeader(new Udp());
    udp.checksum(0); // The checksum is left out of the calculation but reset for correctness.
    final byte[] mergedBytes;
    if (packet.hasHeader(Ip4.ID)) {
        Ip4 ip4 = packet.getHeader(new Ip4());
        mergedBytes = constructIp4UdpChecksumByteArray(ip4, udp);
    } else {
        Ip6 ip6 = packet.getHeader(new Ip6());
        mergedBytes = constructIp6UdpChecksumByteArray(ip6, udp);
    }
    udp.checksum(ByteBuffer.wrap(calculateInternetChecksum(mergedBytes)).order(ByteOrder.BIG_ENDIAN).getShort());
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:20,代码来源:JNetPcapPacketModifier.java


示例3: constructIp6UdpChecksumByteArray

import org.jnetpcap.protocol.network.Ip6; //导入依赖的package包/类
/**
 * Constructs the byte array over which the Ipv4 UDP checksum is calculated.
 * Ip6 Pseudo header + data
 *
 * @param ip6 the Ipv6 header
 * @param udp the udp header
 * @return byte array
 */
private byte[] constructIp6UdpChecksumByteArray(final Ip6 ip6, final Udp udp) {
    return (Util.concatBytes(ip6.source(), ip6.destination(),
            Util.unsignedShortToByteArray(udp.length(), ByteOrder.BIG_ENDIAN),
            new byte[3], new byte[]{(byte) 0x11},
            Util.unsignedShortToByteArray(udp.source(), ByteOrder.BIG_ENDIAN),
            Util.unsignedShortToByteArray(udp.destination(), ByteOrder.BIG_ENDIAN),
            Util.unsignedShortToByteArray(udp.length(), ByteOrder.BIG_ENDIAN),
            udp.getPayload()));
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:18,代码来源:JNetPcapPacketModifier.java


示例4: testCoreProtocolRegistrationByName

import org.jnetpcap.protocol.network.Ip6; //导入依赖的package包/类
/**
 * Test core protocol registration by name.
 * 
 * @throws UnregisteredHeaderException
 *             the unregistered header exception
 */
public void testCoreProtocolRegistrationByName()
		throws UnregisteredHeaderException {

	assertEquals(JProtocol.ETHERNET.toString(), Ethernet.ID,
			JRegistry.lookupId(Ethernet.class));
	assertEquals(JProtocol.IP4.toString(), JProtocol.IP4_ID,
			JRegistry.lookupId(Ip4.class));
	assertEquals(JProtocol.IP6.toString(), Ip6.ID,
			JRegistry.lookupId(Ip6.class));
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:17,代码来源:TestJRegistry.java


示例5: testTcpIp6CRC16UsingHandler

import org.jnetpcap.protocol.network.Ip6; //导入依赖的package包/类
/**
 * Test tcp ip6 cr c16 using handler.
 */
public void testTcpIp6CRC16UsingHandler() {
	StringBuilder errbuf = new StringBuilder();
	Pcap pcap = Pcap.openOffline(HTTP_IP6, errbuf);

	assertNotNull(errbuf.toString(), pcap);

	pcap.loop(Pcap.LOOP_INFINATE, new PcapPacketHandler<String>() {
		Ip6 ip = new Ip6();

		Tcp tcp = new Tcp();

		public void nextPacket(PcapPacket packet, String user) {

			if (packet.hasHeader(tcp) == false) {
				return;
			}

			// PcapPacket packet = new PcapPacket(header, buffer);

			long f = packet.getFrameNumber();
			assertTrue("#" + f, packet.hasHeader(ip));

			assertTrue("Frame #" + f, tcp.isChecksumValid());
		}

	}, null);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:31,代码来源:TestTcpIp.java


示例6: testUdpIp6CRC16UsingHandler

import org.jnetpcap.protocol.network.Ip6; //导入依赖的package包/类
/**
 * Test udp ip6 cr c16 using handler.
 */
public void testUdpIp6CRC16UsingHandler() {
	StringBuilder errbuf = new StringBuilder();
	Pcap pcap = Pcap.openOffline(HTTP_IP6, errbuf);

	assertNotNull(errbuf.toString(), pcap);

	pcap.loop(Pcap.LOOP_INFINATE, new PcapPacketHandler<String>() {
		Ip6 ip = new Ip6();

		Udp udp = new Udp();

		public void nextPacket(PcapPacket packet, String user) {

			if (packet.hasHeader(udp) == false) {
				return;
			}

			// PcapPacket packet = new PcapPacket(header, buffer);

			long f = packet.getFrameNumber();
			assertTrue("#" + f, packet.hasHeader(ip));

			assertTrue("Frame #" + f, udp.isChecksumValid());
		}

	}, null);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:31,代码来源:TestTcpIp.java


示例7: pseudonymizeIP6

import org.jnetpcap.protocol.network.Ip6; //导入依赖的package包/类
/**
 * Pseudonymizes the Ipv6 source and destination.
 *
 * @param pseudonymizer pseudonymizer containing the algorithm used for pseudonymization.
 * @param ip6 the Ipv6 header.
 */
private void pseudonymizeIP6(final IPPseudonymizer pseudonymizer, final Ip6 ip6) {
    // Transfer the bytes from a bytebuffer to the correct offset inside the header.
    ip6.transferFrom(ByteBuffer.wrap(pseudonymizer.pseudonymize(ip6.source())), 8);
    ip6.transferFrom(ByteBuffer.wrap(pseudonymizer.pseudonymize(ip6.destination())), 24);
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:12,代码来源:JNetPcapPacketModifier.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Requirement类代码示例发布时间:2022-05-23
下一篇:
Java WSDLPatcher类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap