@Override protected Packet getWholePacket() throws UnknownHostException { IcmpV4CommonPacket.Builder icmpV4b = new IcmpV4CommonPacket.Builder(); icmpV4b .type(IcmpV4Type.PARAMETER_PROBLEM) .code(IcmpV4Code.POINTER_INDICATES_ERROR) .payloadBuilder(new SimpleBuilder(packet)) .correctChecksumAtBuild(true); IpV4Packet.Builder ipv4b = new IpV4Packet.Builder(); ipv4b .version(IpVersion.IPV4) .tos(IpV4Rfc1349Tos.newInstance((byte) 0)) .identification((short) 100) .ttl((byte) 100) .protocol(IpNumber.ICMPV4) .srcAddr( (Inet4Address) InetAddress.getByAddress(new byte[] {(byte) 192, (byte) 0, (byte) 2, (byte) 1})) .dstAddr( (Inet4Address) InetAddress.getByAddress(new byte[] {(byte) 192, (byte) 0, (byte) 2, (byte) 2})) .payloadBuilder(icmpV4b) .correctChecksumAtBuild(true) .correctLengthAtBuild(true); EthernetPacket.Builder eb = new EthernetPacket.Builder(); eb.dstAddr(MacAddress.getByName("fe:00:00:00:00:02")) .srcAddr(MacAddress.getByName("fe:00:00:00:00:01")) .type(EtherType.IPV4) .payloadBuilder(ipv4b) .paddingAtBuild(true); return eb.build(); }
public IcmpV4ParameterProblemPacketTest() { this.pointer = (byte) 123; this.unused = 321; IcmpV4EchoPacket.Builder echob = new IcmpV4EchoPacket.Builder(); echob .identifier((short) 100) .sequenceNumber((short) 10) .payloadBuilder( new UnknownPacket.Builder().rawData((new byte[] {(byte) 0, (byte) 1, (byte) 2}))); IcmpV4CommonPacket.Builder icmpV4b = new IcmpV4CommonPacket.Builder(); icmpV4b .type(IcmpV4Type.ECHO) .code(IcmpV4Code.NO_CODE) .payloadBuilder(echob) .correctChecksumAtBuild(true); IpV4Packet.Builder ipv4b = new IpV4Packet.Builder(); try { ipv4b .version(IpVersion.IPV4) .tos(IpV4Rfc1349Tos.newInstance((byte) 0)) .identification((short) 100) .ttl((byte) 100) .protocol(IpNumber.ICMPV4) .srcAddr( (Inet4Address) InetAddress.getByAddress(new byte[] {(byte) 192, (byte) 0, (byte) 2, (byte) 2})) .dstAddr( (Inet4Address) InetAddress.getByAddress(new byte[] {(byte) 192, (byte) 0, (byte) 2, (byte) 1})) .payloadBuilder(icmpV4b) .correctChecksumAtBuild(true) .correctLengthAtBuild(true); } catch (UnknownHostException e) { throw new AssertionError(); } IcmpV4ParameterProblemPacket.Builder b = new IcmpV4ParameterProblemPacket.Builder(); b.pointer(pointer) .unused(unused) .payload(IcmpV4Helper.makePacketForInvokingPacketField(ipv4b.build())); this.packet = b.build(); }