/**
  * Generates a new IP address base on a given IP address plus a number to increase.
  *
  * @param ipAddress the IP address to increase
  * @param num the number for ipAddress to add
  * @return the new IP address after increase
  */
 private IpAddress increaseIpAddress(IpAddress ipAddress, int num) {
   if (ipAddress.isIp6()) {
     log.info("vBNG currently does not handle IPv6");
     return null;
   }
   return IpAddress.valueOf(ipAddress.getIp4Address().toInt() + num);
 }
Beispiel #2
0
  private Ethernet buildArpRequest(
      IpAddress targetIp, IpAddress sourceIp, MacAddress sourceMac, VlanId vlan) {

    ARP arp = new ARP();
    arp.setHardwareType(ARP.HW_TYPE_ETHERNET)
        .setHardwareAddressLength((byte) Ethernet.DATALAYER_ADDRESS_LENGTH)
        .setProtocolType(ARP.PROTO_TYPE_IP)
        .setProtocolAddressLength((byte) IpAddress.INET_BYTE_LENGTH)
        .setOpCode(ARP.OP_REQUEST);

    arp.setSenderHardwareAddress(sourceMac.toBytes())
        .setSenderProtocolAddress(sourceIp.toOctets())
        .setTargetHardwareAddress(ZERO_MAC_ADDRESS)
        .setTargetProtocolAddress(targetIp.toOctets());

    Ethernet ethernet = new Ethernet();
    ethernet
        .setEtherType(Ethernet.TYPE_ARP)
        .setDestinationMACAddress(MacAddress.BROADCAST)
        .setSourceMACAddress(sourceMac)
        .setPayload(arp);

    if (!vlan.equals(VlanId.NONE)) {
      ethernet.setVlanID(vlan.toShort());
    }

    ethernet.setPad(true);

    return ethernet;
  }
  /** Tests methods defined on the Builder. */
  @Test
  public void testBuilderMethods() {
    final Instruction instruction1 = new ModLambdaInstruction(L0SubType.LAMBDA, (short) 4);

    final TrafficTreatment.Builder builder1 =
        DefaultTrafficTreatment.builder()
            .add(instruction1)
            .setEthDst(MacAddress.BROADCAST)
            .setEthSrc(MacAddress.BROADCAST)
            .setIpDst(IpAddress.valueOf("1.1.1.1"))
            .setIpSrc(IpAddress.valueOf("2.2.2.2"))
            .setLambda((short) 4)
            .setOutput(PortNumber.portNumber(2))
            .setVlanId(VlanId.vlanId((short) 4))
            .setVlanPcp((byte) 3);

    final TrafficTreatment treatment1 = builder1.build();

    final List<Instruction> instructions1 = treatment1.instructions();
    assertThat(instructions1, hasSize(9));

    builder1.drop();
    builder1.add(instruction1);

    final List<Instruction> instructions2 = builder1.build().instructions();
    assertThat(instructions2, hasSize(8));
  }
  /**
   * Sets up BGP speakers.
   *
   * @return configured BGP speakers as a map from speaker name to speaker
   */
  private Set<BgpConfig.BgpSpeakerConfig> setUpBgpSpeakers() {

    BgpConfig.BgpSpeakerConfig speaker1 =
        new BgpConfig.BgpSpeakerConfig(
            Optional.empty(),
            NO_VLAN,
            s1Eth100,
            Collections.singleton(IpAddress.valueOf("192.168.10.1")));

    BgpConfig.BgpSpeakerConfig speaker2 =
        new BgpConfig.BgpSpeakerConfig(
            Optional.empty(),
            NO_VLAN,
            s1Eth100,
            Sets.newHashSet(IpAddress.valueOf("192.168.20.1"), IpAddress.valueOf("192.168.30.1")));

    BgpConfig.BgpSpeakerConfig speaker3 =
        new BgpConfig.BgpSpeakerConfig(
            Optional.empty(),
            VLAN30,
            s3Eth100,
            Sets.newHashSet(IpAddress.valueOf("192.168.40.1"), IpAddress.valueOf("192.168.50.1")));

    Set<BgpConfig.BgpSpeakerConfig> bgpSpeakers = Sets.newHashSet();
    bgpSpeakers.add(speaker1);
    bgpSpeakers.add(speaker2);
    bgpSpeakers.add(speaker3);

    return bgpSpeakers;
  }
  @Before
  public void setup() {

    address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
    sameAsAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
    address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
  }
Beispiel #6
0
  @Override
  public McastRoute decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
      return null;
    }

    IpAddress source = IpAddress.valueOf(json.path(SOURCE).asText());
    IpAddress group = IpAddress.valueOf(json.path(GROUP).asText());

    McastRoute route = new McastRoute(source, group, McastRoute.Type.STATIC);

    return route;
  }
  /** Tests a corner case, when there are no interfaces in the configuration. */
  @Test
  public void testNullInterfaces() {
    reset(interfaceService);
    interfaceService.addListener(anyObject(InterfaceListener.class));
    expectLastCall().anyTimes();

    expect(interfaceService.getInterfaces()).andReturn(Sets.newHashSet()).anyTimes();
    expect(interfaceService.getInterfacesByPort(s2Eth1))
        .andReturn(Collections.emptySet())
        .anyTimes();
    expect(interfaceService.getInterfacesByPort(s1Eth1))
        .andReturn(Collections.emptySet())
        .anyTimes();
    expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.10.101")))
        .andReturn(Collections.emptySet())
        .anyTimes();
    expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.10.1")))
        .andReturn(null)
        .anyTimes();
    expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.20.101")))
        .andReturn(Collections.emptySet())
        .anyTimes();
    expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.20.1")))
        .andReturn(null)
        .anyTimes();
    expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.30.101")))
        .andReturn(Collections.emptySet())
        .anyTimes();
    expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.30.1")))
        .andReturn(null)
        .anyTimes();
    expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.40.101")))
        .andReturn(Collections.emptySet())
        .anyTimes();
    expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.40.1")))
        .andReturn(null)
        .anyTimes();
    expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.50.101")))
        .andReturn(Collections.emptySet())
        .anyTimes();
    expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.50.1")))
        .andReturn(null)
        .anyTimes();

    replay(interfaceService);

    reset(intentSynchronizer);
    replay(intentSynchronizer);
    peerConnectivityManager.start();
    verify(intentSynchronizer);
  }
 @Override
 public final void setChannel(Channel channel) {
   this.channel = channel;
   final SocketAddress address = channel.getRemoteAddress();
   if (address instanceof InetSocketAddress) {
     final InetSocketAddress inetAddress = (InetSocketAddress) address;
     final IpAddress ipAddress = IpAddress.valueOf(inetAddress.getAddress());
     if (ipAddress.isIp4()) {
       channelId = ipAddress.toString() + ':' + inetAddress.getPort();
     } else {
       channelId = '[' + ipAddress.toString() + "]:" + inetAddress.getPort();
     }
   }
 }
Beispiel #9
0
  private void sendArpNdpProbe(
      ConnectPoint connectPoint,
      IpAddress targetIp,
      IpAddress sourceIp,
      MacAddress sourceMac,
      VlanId vlan) {
    Ethernet probePacket = null;

    if (targetIp.isIp4()) {
      // IPv4: Use ARP
      probePacket = buildArpRequest(targetIp, sourceIp, sourceMac, vlan);
    } else {
      // IPv6: Use Neighbor Discovery
      probePacket = buildNdpRequest(targetIp, sourceIp, sourceMac, vlan);
    }

    List<Instruction> instructions = new ArrayList<>();
    instructions.add(Instructions.createOutput(connectPoint.port()));

    TrafficTreatment treatment =
        DefaultTrafficTreatment.builder().setOutput(connectPoint.port()).build();

    OutboundPacket outboundPacket =
        new DefaultOutboundPacket(
            connectPoint.deviceId(), treatment, ByteBuffer.wrap(probePacket.serialize()));

    packetService.emit(outboundPacket);
  }
Beispiel #10
0
  /**
   * Sends an APR request for the target IP address to all ports except in-port.
   *
   * @param deviceId Switch device ID
   * @param targetAddress target IP address for ARP
   * @param inPort in-port
   */
  public void sendArpRequest(DeviceId deviceId, IpAddress targetAddress, ConnectPoint inPort) {
    byte[] senderMacAddress;
    byte[] senderIpAddress;

    try {
      senderMacAddress = config.getDeviceMac(deviceId).toBytes();
      senderIpAddress = config.getRouterIp(deviceId).toOctets();
    } catch (DeviceConfigNotFoundException e) {
      log.warn(e.getMessage() + " Aborting sendArpRequest.");
      return;
    }

    ARP arpRequest = new ARP();
    arpRequest
        .setHardwareType(ARP.HW_TYPE_ETHERNET)
        .setProtocolType(ARP.PROTO_TYPE_IP)
        .setHardwareAddressLength((byte) Ethernet.DATALAYER_ADDRESS_LENGTH)
        .setProtocolAddressLength((byte) Ip4Address.BYTE_LENGTH)
        .setOpCode(ARP.OP_REQUEST)
        .setSenderHardwareAddress(senderMacAddress)
        .setTargetHardwareAddress(MacAddress.ZERO.toBytes())
        .setSenderProtocolAddress(senderIpAddress)
        .setTargetProtocolAddress(targetAddress.toOctets());

    Ethernet eth = new Ethernet();
    eth.setDestinationMACAddress(MacAddress.BROADCAST.toBytes())
        .setSourceMACAddress(senderMacAddress)
        .setEtherType(Ethernet.TYPE_ARP)
        .setPayload(arpRequest);

    removeVlanAndFlood(eth, inPort);
  }
Beispiel #11
0
 @Override
 protected void execute() {
   SubnetService service = get(SubnetService.class);
   if (id == null || networkId == null || tenantId == null) {
     print(null, "id,networkId,tenantId can not be null");
     return;
   }
   Subnet subnet =
       new DefaultSubnet(
           SubnetId.subnetId(id),
           subnetName,
           TenantNetworkId.networkId(networkId),
           TenantId.tenantId(tenantId),
           ipVersion,
           cidr == null ? null : IpPrefix.valueOf(cidr),
           gatewayIp == null ? null : IpAddress.valueOf(gatewayIp),
           dhcpEnabled,
           shared,
           hostRoutes,
           ipV6AddressMode == null ? null : Mode.valueOf(ipV6AddressMode),
           ipV6RaMode == null ? null : Mode.valueOf(ipV6RaMode),
           allocationPools);
   Set<Subnet> subnetsSet = Sets.newHashSet();
   subnetsSet.add(subnet);
   service.updateSubnets(subnetsSet);
 }
Beispiel #12
0
 /**
  * Produces device URI from the given DPID long.
  *
  * @param ipAddress device ip address
  * @return device URI
  */
 public static URI uri(IpAddress ipAddress) {
   try {
     return new URI(SCHEME, ipAddress.toString(), null);
   } catch (URISyntaxException e) {
     return null;
   }
 }
Beispiel #13
0
 /**
  * Creates an InterfaceAddress object.
  *
  * @param dpid the DPID of the interface as a String
  * @param port the port of the interface
  * @param ipAddress the IP address of a {@link BgpSpeaker} configured on the interface
  */
 public InterfaceAddress(
     @JsonProperty("interfaceDpid") String dpid,
     @JsonProperty("interfacePort") int port,
     @JsonProperty("ipAddress") String ipAddress) {
   this.connectPoint =
       new ConnectPoint(DeviceId.deviceId(NetTools.dpidToUri(dpid)), PortNumber.portNumber(port));
   this.ipAddress = IpAddress.valueOf(ipAddress);
 }
Beispiel #14
0
 // OvsdbNodeId(IP:port) is used in the adaptor while DeviceId(ovsdb:IP:port)
 // is used in the core. So DeviceId need be changed to OvsdbNodeId.
 private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) {
   int lastColon = deviceId.toString().lastIndexOf(":");
   int fistColon = deviceId.toString().indexOf(":");
   String ip = deviceId.toString().substring(fistColon + 1, lastColon - 1);
   String port = deviceId.toString().substring(lastColon + 1);
   IpAddress ipAddress = IpAddress.valueOf(ip);
   long portL = Long.valueOf(port).longValue();
   return new OvsdbNodeId(ipAddress, portL);
 }
 @Override
 public NetconfDevice getNetconfDevice(IpAddress ip, int port) {
   for (DeviceId info : netconfDeviceMap.keySet()) {
     if (info.uri().getSchemeSpecificPart().equals(ip.toString() + ":" + port)) {
       return netconfDeviceMap.get(info);
     }
   }
   return null;
 }
Beispiel #16
0
 @Override
 public RestSBDevice getDevice(IpAddress ip, int port) {
   for (DeviceId info : deviceMap.keySet()) {
     if (IpAddress.valueOf(info.uri().getHost()).equals(ip) && info.uri().getPort() == port) {
       return deviceMap.get(info);
     }
   }
   return null;
 }
 @Override
 protected void execute() {
   FloatingIpService service = get(FloatingIpService.class);
   try {
     FloatingIp floatingIpObj =
         new DefaultFloatingIp(
             FloatingIpId.of(id),
             TenantId.tenantId(tenantId),
             TenantNetworkId.networkId(networkId),
             VirtualPortId.portId(portId),
             RouterId.valueOf(routerId),
             floatingIp == null ? null : IpAddress.valueOf(floatingIp),
             fixedIp == null ? null : IpAddress.valueOf(fixedIp),
             status == null ? Status.ACTIVE : Status.valueOf(status));
     Set<FloatingIp> floatingIpSet = Sets.newHashSet(floatingIpObj);
     service.createFloatingIps(floatingIpSet);
   } catch (Exception e) {
     print(null, e.getMessage());
   }
 }
Beispiel #18
0
  public static SessionMappingKey Of(IpAddress publicIp, byte protocol, int publicTpPort) {
    String keyString =
        new StringBuilder()
            .append(publicIp.toString())
            .append("-")
            .append(protocol)
            .append("-")
            .append(publicTpPort)
            .toString();

    return new SessionMappingKey(keyString, publicIp, protocol, publicTpPort);
  }
Beispiel #19
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;
  }
  @Override
  public byte[] getBytes() throws HeaderException {
    try {
      byte[] data = new byte[LENGTH];

      System.arraycopy(exporterIPv4Address.toOctets(), 0, data, 0, 4);
      System.arraycopy(exporterIPv6Address.toOctets(), 0, data, 4, 16);
      System.arraycopy(Longs.toByteArray(flowStartMilliseconds), 0, data, 20, 8);
      System.arraycopy(Longs.toByteArray(flowEndMilliseconds), 0, data, 28, 8);
      System.arraycopy(Longs.toByteArray(octetDeltaCount), 0, data, 36, 8);
      System.arraycopy(Longs.toByteArray(packetDeltaCount), 0, data, 44, 8);
      System.arraycopy(Ints.toByteArray(ingressInterface), 0, data, 52, 4);
      System.arraycopy(Ints.toByteArray(egressInterface), 0, data, 56, 4);
      System.arraycopy(sourceMacAddress.toBytes(), 0, data, 60, 6);
      System.arraycopy(destinationMacAddress.toBytes(), 0, data, 66, 6);
      System.arraycopy(Shorts.toByteArray(ethernetType), 0, data, 72, 2);
      System.arraycopy(Shorts.toByteArray(vlanId), 0, data, 74, 2);

      return data;
    } catch (Exception e) {
      throw new HeaderException("Error while generating the bytes: " + e.getMessage());
    }
  }
Beispiel #21
0
  @Override
  protected void execute() {
    StaticRoutingService routingService = get(StaticRoutingService.class);

    if (fibEntryString.length < 3) {
      return;
    }

    IpPrefix prefix = IpPrefix.valueOf(fibEntryString[0]);
    IpAddress nextHopIp = IpAddress.valueOf(fibEntryString[1]);
    MacAddress nextHopMac = MacAddress.valueOf(fibEntryString[2]);
    FibEntry fibEntry = new FibEntry(prefix, nextHopIp, nextHopMac);
    FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.DELETE, fibEntry);

    FibListener fibListener = routingService.getFibListener();
    fibListener.update(Collections.emptyList(), Arrays.asList(fibUpdate));
  }
  /** Tests a corner case, when there is no Interface configured for one BGP peer. */
  @Test
  public void testNoPeerInterface() {
    IpAddress ip = IpAddress.valueOf("1.1.1.1");
    bgpSpeakers.clear();
    bgpSpeakers.add(
        new BgpConfig.BgpSpeakerConfig(
            Optional.of("foo"), VlanId.NONE, s1Eth100, Collections.singleton(ip)));
    reset(interfaceService);
    interfaceService.addListener(anyObject(InterfaceListener.class));
    expect(interfaceService.getMatchingInterface(ip)).andReturn(null).anyTimes();
    replay(interfaceService);

    // We don't expect any intents in this case
    reset(intentSynchronizer);
    replay(intentSynchronizer);
    peerConnectivityManager.start();
    verify(intentSynchronizer);
  }
Beispiel #23
0
  // Parses the given node with host data and supplies the host.
  private void parseHost(JsonNode node) {
    MacAddress mac = MacAddress.valueOf(get(node, "mac"));
    VlanId vlanId = VlanId.vlanId((short) node.get("vlan").asInt(VlanId.UNTAGGED));
    HostId hostId = HostId.hostId(mac, vlanId);
    SparseAnnotations annotations = annotations(node.get("annotations"));
    HostLocation location = new HostLocation(connectPoint(get(node, "location")), 0);

    String[] ipStrings = get(node, "ip", "").split(",");
    Set<IpAddress> ips = new HashSet<>();
    for (String ip : ipStrings) {
      ips.add(IpAddress.valueOf(ip.trim()));
    }

    DefaultHostDescription desc =
        new DefaultHostDescription(mac, vlanId, location, ips, annotations);
    hostProviderService.hostDetected(hostId, desc);

    connectPoints.add(location);
  }
Beispiel #24
0
  /**
   * Sets the Controller.
   *
   * @param bridgeUuid bridge uuid
   */
  private void setController(String bridgeUuid) {
    String controllerUuid = null;
    String iPAddress =
        IpAddress.valueOf(
                ((InetSocketAddress) channel.localAddress()).getAddress().getHostAddress())
            .toString();

    String target = "tcp:" + iPAddress + ":" + OvsdbConstant.OFPORT;
    log.debug("controller IP {}: port {}", iPAddress, OvsdbConstant.OFPORT);

    DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
    Controller controller =
        (Controller) TableGenerator.createTable(dbSchema, OvsdbTable.CONTROLLER);

    if (controller != null) {
      controller.setTarget(target);
      controllerUuid = getControllerUuid(OvsdbConstant.CONTROLLER, target);
      if (controllerUuid == null) {

        insertConfig(
            OvsdbConstant.CONTROLLER,
            "_uuid",
            OvsdbConstant.BRIDGE,
            "controller",
            bridgeUuid,
            controller.getRow());

      } else {

        Bridge bridge = (Bridge) TableGenerator.createTable(dbSchema, OvsdbTable.BRIDGE);
        Set<UUID> controllerUuids = new HashSet<>();
        controllerUuids.add(UUID.uuid(controllerUuid));
        bridge.setController(controllerUuids);
        updateConfig(OvsdbConstant.CONTROLLER, "_uuid", bridgeUuid, bridge.getRow());
      }
    }
  }
public class HostLocationProviderTest {
  private static final Integer INPORT = 10;
  private static final String DEV1 = "of:1";
  private static final String DEV2 = "of:2";
  private static final String DEV3 = "of:3";
  private static final String DEV4 = "of:4";
  private static final String DEV5 = "of:5";
  private static final String DEV6 = "of:6";

  private static final VlanId VLAN = vlanId();

  // IPv4 Host
  private static final MacAddress MAC = MacAddress.valueOf("00:00:11:00:00:01");
  private static final MacAddress BCMAC = MacAddress.valueOf("ff:ff:ff:ff:ff:ff");
  private static final byte[] IP = new byte[] {10, 0, 0, 1};
  private static final IpAddress IP_ADDRESS = IpAddress.valueOf(IpAddress.Version.INET, IP);
  private static final HostLocation LOCATION =
      new HostLocation(deviceId(DEV1), portNumber(INPORT), 0L);
  private static final DefaultHost HOST =
      new DefaultHost(
          ProviderId.NONE,
          hostId(MAC),
          MAC,
          vlanId(VlanId.UNTAGGED),
          LOCATION,
          ImmutableSet.of(IP_ADDRESS));

  // IPv6 Host
  private static final MacAddress MAC2 = MacAddress.valueOf("00:00:22:00:00:02");
  private static final MacAddress BCMAC2 = MacAddress.valueOf("33:33:00:00:00:01");
  private static final byte[] IP2 = Ip6Address.valueOf("1000::1").toOctets();
  private static final IpAddress IP_ADDRESS2 = IpAddress.valueOf(IpAddress.Version.INET6, IP2);
  private static final HostLocation LOCATION2 =
      new HostLocation(deviceId(DEV4), portNumber(INPORT), 0L);
  private static final DefaultHost HOST2 =
      new DefaultHost(
          ProviderId.NONE,
          hostId(MAC2),
          MAC2,
          vlanId(VlanId.UNTAGGED),
          LOCATION2,
          ImmutableSet.of(IP_ADDRESS2));

  private static final ComponentContextAdapter CTX_FOR_REMOVE =
      new ComponentContextAdapter() {
        @Override
        public Dictionary getProperties() {
          Hashtable<String, String> props = new Hashtable<>();
          props.put("hostRemovalEnabled", "true");
          return props;
        }
      };

  public static final ComponentContextAdapter CTX_FOR_NO_REMOVE =
      new ComponentContextAdapter() {
        @Override
        public Dictionary getProperties() {
          return new Hashtable();
        }
      };

  private final HostLocationProvider provider = new HostLocationProvider();
  private final TestHostRegistry hostRegistry = new TestHostRegistry();
  private final TestTopologyService topoService = new TestTopologyService();
  private final TestDeviceService deviceService = new TestDeviceService();
  private final TestHostService hostService = new TestHostService();
  private final TestPacketService packetService = new TestPacketService();

  private PacketProcessor testProcessor;
  private CoreService coreService;
  private TestHostProviderService providerService;

  private ApplicationId appId = new DefaultApplicationId(100, "org.onosproject.provider.host");

  @Before
  public void setUp() {

    coreService = createMock(CoreService.class);
    expect(coreService.registerApplication(appId.name())).andReturn(appId).anyTimes();
    replay(coreService);

    provider.cfgService = new ComponentConfigAdapter();
    provider.coreService = coreService;

    provider.providerRegistry = hostRegistry;
    provider.topologyService = topoService;
    provider.packetService = packetService;
    provider.deviceService = deviceService;
    provider.hostService = hostService;

    provider.activate(CTX_FOR_NO_REMOVE);
  }

  @Test
  public void basics() {
    assertNotNull("registration expected", providerService);
    assertEquals("incorrect provider", provider, providerService.provider());
  }

  @Test
  public void events() {
    // new host
    testProcessor.process(new TestArpPacketContext(DEV1));
    assertNotNull("new host expected", providerService.added);
    assertNull("host motion unexpected", providerService.moved);

    // the host moved to new switch
    testProcessor.process(new TestArpPacketContext(DEV2));
    assertNotNull("host motion expected", providerService.moved);

    // the host was misheard on a spine
    testProcessor.process(new TestArpPacketContext(DEV3));
    assertNull("host misheard on spine switch", providerService.spine);

    providerService.clear();

    // new host
    testProcessor.process(new TestNaPacketContext(DEV4));
    assertNotNull("new host expected", providerService.added);
    assertNull("host motion unexpected", providerService.moved);

    // the host moved to new switch
    testProcessor.process(new TestNaPacketContext(DEV5));
    assertNotNull("host motion expected", providerService.moved);

    // the host was misheard on a spine
    testProcessor.process(new TestNaPacketContext(DEV6));
    assertNull("host misheard on spine switch", providerService.spine);
  }

  @Test
  public void removeHostByDeviceRemove() {
    provider.modified(CTX_FOR_REMOVE);
    testProcessor.process(new TestArpPacketContext(DEV1));
    testProcessor.process(new TestNaPacketContext(DEV4));

    Device device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(DEVICE_REMOVED, device));
    assertEquals("incorrect remove count", 1, providerService.removeCount);

    device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(DEVICE_REMOVED, device));
    assertEquals("incorrect remove count", 2, providerService.removeCount);
  }

  @Test
  public void removeHostByDeviceOffline() {
    provider.modified(CTX_FOR_REMOVE);
    testProcessor.process(new TestArpPacketContext(DEV1));
    testProcessor.process(new TestArpPacketContext(DEV4));

    Device device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device));
    assertEquals("incorrect remove count", 1, providerService.removeCount);

    device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device));
    assertEquals("incorrect remove count", 2, providerService.removeCount);
  }

  @Test
  public void removeHostByDevicePortDown() {
    provider.modified(CTX_FOR_REMOVE);
    testProcessor.process(new TestArpPacketContext(DEV1));
    testProcessor.process(new TestArpPacketContext(DEV4));

    Device device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(
        new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
    assertEquals("incorrect remove count", 1, providerService.removeCount);

    device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(
        new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
    assertEquals("incorrect remove count", 2, providerService.removeCount);
  }

  /** When receiving ARP, updates location and IP. */
  @Test
  public void testReceiveArp() {
    testProcessor.process(new TestArpPacketContext(DEV1));
    HostDescription descr = providerService.added;
    assertThat(descr.location(), is(LOCATION));
    assertThat(descr.hwAddress(), is(MAC));
    assertThat(descr.ipAddress().toArray()[0], is(IP_ADDRESS));
    assertThat(descr.vlan(), is(VLAN));
  }

  /** When receiving IPv4, updates location only. */
  @Test
  public void testReceiveIpv4() {
    testProcessor.process(new TestIpv4PacketContext(DEV1));
    HostDescription descr = providerService.added;
    assertThat(descr.location(), is(LOCATION));
    assertThat(descr.hwAddress(), is(MAC));
    assertThat(descr.ipAddress().size(), is(0));
    assertThat(descr.vlan(), is(VLAN));
  }

  /** When receiving NeighborAdvertisement, updates location and IP. */
  @Test
  public void testReceiveNa() {
    testProcessor.process(new TestNaPacketContext(DEV4));
    assertNotNull(providerService.added);
    HostDescription descr = providerService.added;
    assertThat(descr.location(), is(LOCATION2));
    assertThat(descr.hwAddress(), is(MAC2));
    assertThat(descr.ipAddress().toArray()[0], is(IP_ADDRESS2));
    assertThat(descr.vlan(), is(VLAN));
  }

  /** When receiving NeighborSolicitation, updates location and IP. */
  @Test
  public void testReceiveNs() {
    testProcessor.process(new TestNsPacketContext(DEV4));
    HostDescription descr = providerService.added;
    assertThat(descr.location(), is(LOCATION2));
    assertThat(descr.hwAddress(), is(MAC2));
    assertThat(descr.ipAddress().toArray()[0], is(IP_ADDRESS2));
    assertThat(descr.vlan(), is(VLAN));
  }

  /** When receiving RouterAdvertisement, ignores it. */
  @Test
  public void testReceivesRa() {
    testProcessor.process(new TestRAPacketContext(DEV4));
    assertNull(providerService.added);
  }

  /** When receiving RouterSolicitation, ignores it. */
  @Test
  public void testReceiveRs() {
    testProcessor.process(new TestRSPacketContext(DEV4));
    assertNull(providerService.added);
  }

  /** When receiving Duplicate Address Detection (DAD), ignores it. */
  @Test
  public void testReceiveDad() {
    testProcessor.process(new TestDadPacketContext(DEV4));
    assertNull(providerService.added);
  }

  /** When receiving IPv6 multicast packet, ignores it. */
  @Test
  public void testReceiveIpv6Multicast() {
    testProcessor.process(new TestIpv6McastPacketContext(DEV4));
    assertNull(providerService.added);
  }

  /** When receiving IPv6 unicast packet, updates location only. */
  @Test
  public void testReceiveIpv6Unicast() {
    testProcessor.process(new TestIpv6PacketContext(DEV4));
    assertNotNull(providerService.added);
    HostDescription descr = providerService.added;
    assertThat(descr.location(), is(LOCATION2));
    assertThat(descr.hwAddress(), is(MAC2));
    assertThat(descr.ipAddress().size(), is(0));
    assertThat(descr.vlan(), is(VLAN));
  }

  @After
  public void tearDown() {
    provider.deactivate();
    provider.coreService = null;
    provider.providerRegistry = null;
  }

  private class TestHostRegistry implements HostProviderRegistry {

    @Override
    public HostProviderService register(HostProvider provider) {
      providerService = new TestHostProviderService(provider);
      return providerService;
    }

    @Override
    public void unregister(HostProvider provider) {}

    @Override
    public Set<ProviderId> getProviders() {
      return null;
    }
  }

  private class TestHostProviderService extends AbstractProviderService<HostProvider>
      implements HostProviderService {

    HostDescription added = null;
    HostDescription moved = null;
    HostDescription spine = null;
    public int removeCount;

    public void clear() {
      added = null;
      moved = null;
      spine = null;
      removeCount = 0;
    }

    protected TestHostProviderService(HostProvider provider) {
      super(provider);
    }

    @Override
    public void hostDetected(HostId hostId, HostDescription hostDescription, boolean replaceIps) {
      if (added == null) {
        added = hostDescription;
      } else if ((moved == null) && hostDescription != added) {
        moved = hostDescription;
      } else {
        spine = hostDescription;
      }
    }

    @Override
    public void hostVanished(HostId hostId) {
      removeCount++;
    }

    @Override
    public void removeIpFromHost(HostId hostId, IpAddress ipAddress) {}
  }

  private class TestPacketService extends PacketServiceAdapter {
    @Override
    public void addProcessor(PacketProcessor processor, int priority) {
      testProcessor = processor;
    }
  }

  private class TestTopologyService extends TopologyServiceAdapter {
    @Override
    public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) {
      // simulate DPID3 as an infrastructure switch
      if ((connectPoint.deviceId()).equals(deviceId(DEV3))
          || connectPoint.deviceId().equals(deviceId(DEV6))) {
        return true;
      }
      return false;
    }
  }

  /** Generates ARP packet. */
  private class TestArpPacketContext implements PacketContext {
    private final String deviceId;

    public TestArpPacketContext(String deviceId) {
      this.deviceId = deviceId;
    }

    @Override
    public long time() {
      return 0;
    }

    @Override
    public InboundPacket inPacket() {
      ARP arp = new ARP();
      arp.setSenderProtocolAddress(IP)
          .setSenderHardwareAddress(MAC.toBytes())
          .setTargetHardwareAddress(BCMAC.toBytes())
          .setTargetProtocolAddress(IP);

      Ethernet eth = new Ethernet();
      eth.setEtherType(Ethernet.TYPE_ARP)
          .setVlanID(VLAN.toShort())
          .setSourceMACAddress(MAC.toBytes())
          .setDestinationMACAddress(BCMAC)
          .setPayload(arp);
      ConnectPoint receivedFrom = new ConnectPoint(deviceId(deviceId), portNumber(INPORT));
      return new DefaultInboundPacket(receivedFrom, eth, ByteBuffer.wrap(eth.serialize()));
    }

    @Override
    public OutboundPacket outPacket() {
      return null;
    }

    @Override
    public TrafficTreatment.Builder treatmentBuilder() {
      return null;
    }

    @Override
    public void send() {}

    @Override
    public boolean block() {
      return false;
    }

    @Override
    public boolean isHandled() {
      return false;
    }
  }

  /** Generates IPv6 Unicast packet. */
  private class TestIpv4PacketContext implements PacketContext {
    private final String deviceId;

    public TestIpv4PacketContext(String deviceId) {
      this.deviceId = deviceId;
    }

    @Override
    public long time() {
      return 0;
    }

    @Override
    public InboundPacket inPacket() {
      IPv4 ipv4 = new IPv4();
      ipv4.setDestinationAddress("10.0.0.1");
      ipv4.setSourceAddress(IP_ADDRESS.toString());
      Ethernet eth = new Ethernet();
      eth.setEtherType(Ethernet.TYPE_IPV4)
          .setVlanID(VLAN.toShort())
          .setSourceMACAddress(MAC)
          .setDestinationMACAddress(MacAddress.valueOf("00:00:00:00:00:01"))
          .setPayload(ipv4);
      ConnectPoint receivedFrom = new ConnectPoint(deviceId(deviceId), portNumber(INPORT));
      return new DefaultInboundPacket(receivedFrom, eth, ByteBuffer.wrap(eth.serialize()));
    }

    @Override
    public OutboundPacket outPacket() {
      return null;
    }

    @Override
    public TrafficTreatment.Builder treatmentBuilder() {
      return null;
    }

    @Override
    public void send() {}

    @Override
    public boolean block() {
      return false;
    }

    @Override
    public boolean isHandled() {
      return false;
    }
  }

  /** Generates NeighborAdvertisement packet. */
  private class TestNaPacketContext implements PacketContext {
    private final String deviceId;

    public TestNaPacketContext(String deviceId) {
      this.deviceId = deviceId;
    }

    @Override
    public long time() {
      return 0;
    }

    @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()));
    }

    @Override
    public OutboundPacket outPacket() {
      return null;
    }

    @Override
    public TrafficTreatment.Builder treatmentBuilder() {
      return null;
    }

    @Override
    public void send() {}

    @Override
    public boolean block() {
      return false;
    }

    @Override
    public boolean isHandled() {
      return false;
    }
  }

  /** Generates NeighborSolicitation packet. */
  private class TestNsPacketContext implements PacketContext {
    private final String deviceId;

    public TestNsPacketContext(String deviceId) {
      this.deviceId = deviceId;
    }

    @Override
    public long time() {
      return 0;
    }

    @Override
    public InboundPacket inPacket() {
      NeighborSolicitation ns = new NeighborSolicitation();
      ICMP6 icmp6 = new ICMP6();
      icmp6.setPayload(ns);
      IPv6 ipv6 = new IPv6();
      ipv6.setPayload(icmp6);
      ipv6.setDestinationAddress(Ip6Address.valueOf("ff02::1:ff00:0000").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()));
    }

    @Override
    public OutboundPacket outPacket() {
      return null;
    }

    @Override
    public TrafficTreatment.Builder treatmentBuilder() {
      return null;
    }

    @Override
    public void send() {}

    @Override
    public boolean block() {
      return false;
    }

    @Override
    public boolean isHandled() {
      return false;
    }
  }

  /** Generates Duplicate Address Detection packet. */
  private class TestDadPacketContext implements PacketContext {
    private final String deviceId;

    public TestDadPacketContext(String deviceId) {
      this.deviceId = deviceId;
    }

    @Override
    public long time() {
      return 0;
    }

    @Override
    public InboundPacket inPacket() {
      NeighborSolicitation ns = new NeighborSolicitation();
      ICMP6 icmp6 = new ICMP6();
      icmp6.setPayload(ns);
      IPv6 ipv6 = new IPv6();
      ipv6.setPayload(icmp6);
      ipv6.setDestinationAddress(Ip6Address.valueOf("ff02::1").toOctets());
      ipv6.setSourceAddress(Ip6Address.valueOf("::").toOctets());
      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()));
    }

    @Override
    public OutboundPacket outPacket() {
      return null;
    }

    @Override
    public TrafficTreatment.Builder treatmentBuilder() {
      return null;
    }

    @Override
    public void send() {}

    @Override
    public boolean block() {
      return false;
    }

    @Override
    public boolean isHandled() {
      return false;
    }
  }

  /** Generates Router Solicitation packet. */
  private class TestRSPacketContext implements PacketContext {
    private final String deviceId;

    public TestRSPacketContext(String deviceId) {
      this.deviceId = deviceId;
    }

    @Override
    public long time() {
      return 0;
    }

    @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 OutboundPacket outPacket() {
      return null;
    }

    @Override
    public TrafficTreatment.Builder treatmentBuilder() {
      return null;
    }

    @Override
    public void send() {}

    @Override
    public boolean block() {
      return false;
    }

    @Override
    public boolean isHandled() {
      return false;
    }
  }

  /** Generates Router Advertisement packet. */
  private class TestRAPacketContext implements PacketContext {
    private final String deviceId;

    public TestRAPacketContext(String deviceId) {
      this.deviceId = deviceId;
    }

    @Override
    public long time() {
      return 0;
    }

    @Override
    public InboundPacket inPacket() {
      RouterAdvertisement ns = new RouterAdvertisement();
      ICMP6 icmp6 = new ICMP6();
      icmp6.setPayload(ns);
      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(MacAddress.valueOf("33:33: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 OutboundPacket outPacket() {
      return null;
    }

    @Override
    public TrafficTreatment.Builder treatmentBuilder() {
      return null;
    }

    @Override
    public void send() {}

    @Override
    public boolean block() {
      return false;
    }

    @Override
    public boolean isHandled() {
      return false;
    }
  }

  /** Generates IPv6 Multicast packet. */
  private class TestIpv6McastPacketContext implements PacketContext {
    private final String deviceId;

    public TestIpv6McastPacketContext(String deviceId) {
      this.deviceId = deviceId;
    }

    @Override
    public long time() {
      return 0;
    }

    @Override
    public InboundPacket inPacket() {
      IPv6 ipv6 = new IPv6();
      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(MacAddress.valueOf("33:33: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 OutboundPacket outPacket() {
      return null;
    }

    @Override
    public TrafficTreatment.Builder treatmentBuilder() {
      return null;
    }

    @Override
    public void send() {}

    @Override
    public boolean block() {
      return false;
    }

    @Override
    public boolean isHandled() {
      return false;
    }
  }

  /** Generates IPv6 Unicast packet. */
  private class TestIpv6PacketContext implements PacketContext {
    private final String deviceId;

    public TestIpv6PacketContext(String deviceId) {
      this.deviceId = deviceId;
    }

    @Override
    public long time() {
      return 0;
    }

    @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 OutboundPacket outPacket() {
      return null;
    }

    @Override
    public TrafficTreatment.Builder treatmentBuilder() {
      return null;
    }

    @Override
    public void send() {}

    @Override
    public boolean block() {
      return false;
    }

    @Override
    public boolean isHandled() {
      return false;
    }
  }

  private class TestDeviceService extends DeviceServiceAdapter {
    private DeviceListener listener;

    @Override
    public void addListener(DeviceListener listener) {
      this.listener = listener;
    }

    @Override
    public Iterable<Device> getDevices() {
      return Collections.emptyList();
    }
  }

  private class TestHostService extends HostServiceAdapter {
    @Override
    public Set<Host> getConnectedHosts(ConnectPoint connectPoint) {
      ConnectPoint cp1 = new ConnectPoint(deviceId(DEV1), portNumber(INPORT));
      ConnectPoint cp2 = new ConnectPoint(deviceId(DEV4), portNumber(INPORT));
      if (connectPoint.equals(cp1)) {
        return ImmutableSet.of(HOST);
      } else if (connectPoint.equals(cp2)) {
        return ImmutableSet.of(HOST2);
      } else {
        return ImmutableSet.of();
      }
    }

    @Override
    public Set<Host> getConnectedHosts(DeviceId deviceId) {
      if (deviceId.equals(deviceId(DEV1))) {
        return ImmutableSet.of(HOST);
      } else if (deviceId.equals(deviceId(DEV4))) {
        return ImmutableSet.of(HOST2);
      } else {
        return ImmutableSet.of();
      }
    }
  }
}
 @Test
 public void testRouterIp() throws Exception {
   assertThat(config.routerIp(), is(IpAddress.valueOf("10.0.1.254")));
 }
Beispiel #27
0
 /**
  * Returns IP address for tunneling for a given host.
  *
  * @param host host
  * @return ip address
  */
 private IpAddress getTunnelIp(Host host) {
   return IpAddress.valueOf(host.annotations().value(LOCATION_IP));
 }
Beispiel #28
0
 /**
  * Returns BGPId created from the given device URI.
  *
  * @param uri device URI
  * @return object of BGPId
  */
 public static BgpId bgpId(URI uri) {
   checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme");
   return new BgpId(IpAddress.valueOf(uri.getSchemeSpecificPart()));
 }
Beispiel #29
0
 /**
  * Convert the BGPId value to a ':' separated hexadecimal string.
  *
  * @return the BGPId value as a ':' separated hexadecimal string.
  */
 @Override
 public String toString() {
   return ipAddress.toString();
 }
Beispiel #30
0
 @Test
 public void testConstruction() {
   LispIpv4Address ipv4Address = address1;
   assertThat(ipv4Address.getAddress(), is(IpAddress.valueOf("192.168.1.1")));
 }