@Override
 public InboundPacket inPacket() {
   IPv6 ipv6 = new IPv6();
   ipv6.setDestinationAddress(Ip6Address.valueOf("1000::1").toOctets());
   ipv6.setSourceAddress(IP2);
   Ethernet eth = new Ethernet();
   eth.setEtherType(Ethernet.TYPE_IPV6)
       .setVlanID(VLAN.toShort())
       .setSourceMACAddress(MAC2)
       .setDestinationMACAddress(MacAddress.valueOf("00:00:00:00:00:01"))
       .setPayload(ipv6);
   ConnectPoint receivedFrom = new ConnectPoint(deviceId(deviceId), portNumber(INPORT));
   return new DefaultInboundPacket(receivedFrom, eth, ByteBuffer.wrap(eth.serialize()));
 }
 @Override
 public InboundPacket inPacket() {
   RouterSolicitation ns = new RouterSolicitation();
   ICMP6 icmp6 = new ICMP6();
   icmp6.setPayload(ns);
   IPv6 ipv6 = new IPv6();
   ipv6.setPayload(icmp6);
   ipv6.setDestinationAddress(Ip6Address.valueOf("ff02::2").toOctets());
   ipv6.setSourceAddress(Ip6Address.valueOf("::").toOctets());
   Ethernet eth = new Ethernet();
   eth.setEtherType(Ethernet.TYPE_IPV6)
       .setVlanID(VLAN.toShort())
       .setSourceMACAddress(MAC2.toBytes())
       .setDestinationMACAddress(MacAddress.valueOf("33:33:00:00:00:02"))
       .setPayload(ipv6);
   ConnectPoint receivedFrom = new ConnectPoint(deviceId(deviceId), portNumber(INPORT));
   return new DefaultInboundPacket(receivedFrom, eth, ByteBuffer.wrap(eth.serialize()));
 }
 @Override
 public InboundPacket inPacket() {
   NeighborAdvertisement na = new NeighborAdvertisement();
   ICMP6 icmp6 = new ICMP6();
   icmp6.setPayload(na);
   IPv6 ipv6 = new IPv6();
   ipv6.setPayload(icmp6);
   ipv6.setDestinationAddress(Ip6Address.valueOf("ff02::1").toOctets());
   ipv6.setSourceAddress(IP2);
   Ethernet eth = new Ethernet();
   eth.setEtherType(Ethernet.TYPE_IPV6)
       .setVlanID(VLAN.toShort())
       .setSourceMACAddress(MAC2.toBytes())
       .setDestinationMACAddress(BCMAC2)
       .setPayload(ipv6);
   ConnectPoint receivedFrom = new ConnectPoint(deviceId(deviceId), portNumber(INPORT));
   return new DefaultInboundPacket(receivedFrom, eth, ByteBuffer.wrap(eth.serialize()));
 }
Example #4
0
  private Ethernet buildNdpRequest(
      IpAddress targetIp, IpAddress sourceIp, MacAddress sourceMac, VlanId vlan) {

    // Create the Ethernet packet
    Ethernet ethernet = new Ethernet();
    ethernet
        .setEtherType(Ethernet.TYPE_IPV6)
        .setDestinationMACAddress(MacAddress.BROADCAST)
        .setSourceMACAddress(sourceMac);
    if (!vlan.equals(VlanId.NONE)) {
      ethernet.setVlanID(vlan.toShort());
    }

    //
    // Create the IPv6 packet
    //
    // TODO: The destination IP address should be the
    // solicited-node multicast address
    IPv6 ipv6 = new IPv6();
    ipv6.setSourceAddress(sourceIp.toOctets());
    ipv6.setDestinationAddress(targetIp.toOctets());
    ipv6.setHopLimit((byte) 255);

    // Create the ICMPv6 packet
    ICMP6 icmp6 = new ICMP6();
    icmp6.setIcmpType(ICMP6.NEIGHBOR_SOLICITATION);
    icmp6.setIcmpCode((byte) 0);

    // Create the Neighbor Solication packet
    NeighborSolicitation ns = new NeighborSolicitation();
    ns.setTargetAddress(targetIp.toOctets());
    ns.addOption(NeighborDiscoveryOptions.TYPE_SOURCE_LL_ADDRESS, sourceMac.toBytes());

    icmp6.setPayload(ns);
    ipv6.setPayload(icmp6);
    ethernet.setPayload(ipv6);

    return ethernet;
  }