if (ipv6Request.getNextHeader() != IPv6.PROTOCOL_ICMP6) { return null; IPv6 ipv6Reply = new IPv6(); byte[] destAddress = ipv6Request.getDestinationAddress(); ipv6Reply.setDestinationAddress(ipv6Request.getSourceAddress()); ipv6Reply.setSourceAddress(destAddress); ipv6Reply.setHopLimit((byte) 64); ipv6Reply.setTrafficClass(ipv6Request.getTrafficClass()); ipv6Reply.setNextHeader(IPv6.PROTOCOL_ICMP6); icmpv6Reply.setPayload(ipv6Request.getPayload().getPayload()); icmpv6Reply.setIcmpType(ICMP6.ECHO_REPLY); icmpv6Reply.setIcmpCode((byte) 0); ipv6Reply.setPayload(icmpv6Reply);
bbChecksum.put(ipv6Parent.getSourceAddress()); bbChecksum.put(ipv6Parent.getDestinationAddress()); } else { ((IPv6) this.parent).setNextHeader(IPv6.PROTOCOL_ICMP6); } else if (this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(IPv6.PROTOCOL_ICMP6);
+ 4; // length final ByteBuffer bbChecksum = ByteBuffer.allocate(bbLength); bbChecksum.put(ipv6.getSourceAddress()); bbChecksum.put(ipv6.getDestinationAddress()); bbChecksum.put((byte) 0); // padding bbChecksum.put(ipv6.getNextHeader()); bbChecksum.putInt(length); bbChecksum.rewind();
checkArgument(ipv6Request.getNextHeader() == IPv6.PROTOCOL_ICMP6, "Protocol must be ICMP6"); final ICMP6 icmpv6 = (ICMP6) ipv6Request.getPayload(); eth.setVlanID(request.getVlanID()); IPv6 ipv6 = new IPv6(); ipv6.setSourceAddress(srcIp.toOctets()); ipv6.setDestinationAddress(ipv6Request.getSourceAddress()); ipv6.setHopLimit(NDP_HOP_LIMIT); ipv6.setNextHeader(IPv6.PROTOCOL_ICMP6); ipv6.setPayload(icmp6); eth.setPayload(ipv6); return eth;
ethernet.setVlanID(vlan.id()); IPv6 ipv6 = new IPv6(); ipv6.setSourceAddress(sourceIp); ipv6.setDestinationAddress(destinationIp); ipv6.setHopLimit((byte) 255); ipv6.setPayload(icmp6); ethernet.setPayload(ipv6);
if (ipv6.getNextHeader() != IPv6.PROTOCOL_ICMP6) { return null; ICMP6 icmpv6 = (ICMP6) ipv6.getPayload(); IpAddress sender = Ip6Address.valueOf(ipv6.getSourceAddress()); IpAddress target; target = Ip6Address.valueOf(ipv6.getDestinationAddress()); } else { return null;
@Override public void process(PacketContext context) { // Stop processing if the packet has been handled, since we // can't do any more to it. if (context.isHandled()) { return; } InboundPacket pkt = context.inPacket(); Ethernet ethPkt = pkt.parsed(); if (ethPkt == null) { return; } if (ethPkt.getEtherType() == TYPE_ARP) { // handle ARP packets handlePacket(context); } else if (ethPkt.getEtherType() == TYPE_IPV6) { IPv6 ipv6 = (IPv6) ethPkt.getPayload(); if (ipv6.getNextHeader() == IPv6.PROTOCOL_ICMP6) { ICMP6 icmp6 = (ICMP6) ipv6.getPayload(); if (icmp6.getIcmpType() == NEIGHBOR_SOLICITATION || icmp6.getIcmpType() == NEIGHBOR_ADVERTISEMENT) { // handle ICMPv6 solicitations and advertisements (NDP) handlePacket(context); } } } } }
checkInput(data, offset, length, FIXED_HEADER_LENGTH); IPv6 ipv6 = new IPv6();
if (ipv6Request.getNextHeader() != IPv6.PROTOCOL_ICMP6) { return null; ICMP6 icmpv6 = (ICMP6) ipv6Request.getPayload(); eth.setVlanID(request.getVlanID()); IPv6 ipv6 = new IPv6(); ipv6.setSourceAddress(srcIp); ipv6.setDestinationAddress(ipv6Request.getSourceAddress()); ipv6.setHopLimit((byte) 255); ipv6.setPayload(icmp6); eth.setPayload(ipv6); return eth;
ethernet.setVlanID(vlan.id()); IPv6 ipv6 = new IPv6(); ipv6.setSourceAddress(sourceIp.toOctets()); ipv6.setDestinationAddress(destinationIp.toOctets()); ipv6.setHopLimit(NDP_HOP_LIMIT); ipv6.setPayload(icmp6); ethernet.setPayload(ipv6);
+ 4; // length final ByteBuffer bbChecksum = ByteBuffer.allocate(bbLength); bbChecksum.put(ipv6.getSourceAddress()); bbChecksum.put(ipv6.getDestinationAddress()); bbChecksum.put((byte) 0); // padding bbChecksum.put(ipv6.getNextHeader()); bbChecksum.putInt(length); bbChecksum.rewind();
} else if (ipv6NeighborDiscovery && ethPkt.getEtherType() == TYPE_IPV6) { IPv6 ipv6Pkt = (IPv6) ethPkt.getPayload(); if (ipv6Pkt.getNextHeader() == IPv6.PROTOCOL_ICMP6) { ICMP6 icmp6Pkt = (ICMP6) ipv6Pkt.getPayload(); if (icmp6Pkt.getIcmpType() == NEIGHBOR_SOLICITATION || icmp6Pkt.getIcmpType() == NEIGHBOR_ADVERTISEMENT) {
IPv6 ipv6 = new IPv6(); ipv6.setSourceAddress(srcIp.toOctets()); ipv6.setDestinationAddress(requestIp.getSourceAddress()); ipv6.setHopLimit((byte) 255); ipv6.setPayload(icmp6); eth.setPayload(ipv6); return eth;
final IPv6 ipv6 = (IPv6) pkt; sb.append("\nipv6_src: "); sb.append(Ip6Address.valueOf(ipv6.getSourceAddress()).toString()); sb.append("\nipv6_dst: "); sb.append(Ip6Address.valueOf(ipv6.getDestinationAddress()).toString()); sb.append("\nipv6_proto: "); sb.append(ipv6.getNextHeader());