Home | History | Annotate | Download | only in util

Lines Matching defs:packet

58     //   out = "        ByteBuffer packet = ByteBuffer.wrap(new byte[] {\n            "
69 // packet = (scapy.IPv6(src="2001:db8::1", dst="2001:db8::2") /
72 // print JavaPacketDefinition(str(packet))
76 // packet = (scapy.IPv6(src="2001:db8::1", dst="2001:db8::2", tc=0x80) /
81 ByteBuffer packet = ByteBuffer.wrap(new byte[] {
102 // Check that a valid packet has checksum 0.
103 int transportLen = packet.limit() - IPV6_HEADER_LENGTH;
104 assertEquals(0, IpUtils.tcpChecksum(packet, 0, IPV6_HEADER_LENGTH, transportLen));
108 int sum = getUnsignedByte(packet, sumOffset) * 256 + getUnsignedByte(packet, sumOffset + 1);
111 packet.put(sumOffset, (byte) 0);
112 packet.put(sumOffset + 1, (byte) 0);
113 assertChecksumEquals(sum, IpUtils.tcpChecksum(packet, 0, IPV6_HEADER_LENGTH, transportLen));
115 // Check that writing the checksum back into the packet results in a valid packet.
116 packet.putShort(
118 IpUtils.tcpChecksum(packet, 0, IPV6_HEADER_LENGTH, transportLen));
119 assertEquals(0, IpUtils.tcpChecksum(packet, 0, IPV6_HEADER_LENGTH, transportLen));
124 // packet = (scapy.IP(src="192.0.2.1", dst="192.0.2.2", tos=0x40) /
127 ByteBuffer packet = ByteBuffer.wrap(new byte[] {
138 // Check that a valid packet has IP checksum 0 and UDP checksum 0xffff (0 is not a valid
140 assertEquals(0, IpUtils.ipChecksum(packet, 0));
141 assertEquals((short) 0xffff, IpUtils.udpChecksum(packet, 0, IPV4_HEADER_LENGTH));
145 final int ipSum = getChecksum(packet, ipSumOffset);
148 packet.put(ipSumOffset, (byte) 0);
149 packet.put(ipSumOffset + 1, (byte) 0);
150 assertChecksumEquals(ipSum, IpUtils.ipChecksum(packet, 0));
153 final int udpSum = getChecksum(packet, udpSumOffset);
156 packet.put(udpSumOffset, (byte) 0);
157 packet.put(udpSumOffset + 1, (byte) 0);
158 assertChecksumEquals(udpSum, IpUtils.udpChecksum(packet, 0, IPV4_HEADER_LENGTH));
160 // Check that writing the checksums back into the packet results in a valid packet.
161 packet.putShort(ipSumOffset, IpUtils.ipChecksum(packet, 0));
162 packet.putShort(udpSumOffset, IpUtils.udpChecksum(packet, 0, IPV4_HEADER_LENGTH));
163 assertEquals(0, IpUtils.ipChecksum(packet, 0));
164 assertEquals((short) 0xffff, IpUtils.udpChecksum(packet, 0, IPV4_HEADER_LENGTH));