@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); } } } } }
"Protocol must be ICMP6"); final ICMP6 icmpv6 = (ICMP6) ipv6Request.getPayload();
return null; ICMP6 icmpv6 = (ICMP6) ipv6.getPayload();
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) {
ICMP6 icmpv6 = (ICMP6) ipv6Request.getPayload();
icmpv6Reply.setPayload(ipv6Request.getPayload().getPayload()); icmpv6Reply.setIcmpType(ICMP6.ECHO_REPLY); icmpv6Reply.setIcmpCode((byte) 0);