Search in sources :

Example 1 with Ip6Address

use of org.onlab.packet.Ip6Address in project onos by opennetworkinglab.

the class RouteEntryTest method testInvalidConstructorNullIpv6NextHop.

/**
 * Tests invalid class constructor for null IPv6 next-hop.
 */
@Test(expected = NullPointerException.class)
public void testInvalidConstructorNullIpv6NextHop() {
    Ip6Prefix prefix = Ip6Prefix.valueOf("1000::/64");
    Ip6Address nextHop = null;
    new RouteEntry(prefix, nextHop);
}
Also used : Ip6Prefix(org.onlab.packet.Ip6Prefix) Ip6Address(org.onlab.packet.Ip6Address) Test(org.junit.Test)

Example 2 with Ip6Address

use of org.onlab.packet.Ip6Address in project onos by opennetworkinglab.

the class RouteEntryTest method testNonEquality.

/**
 * Tests non-equality of {@link RouteEntry}.
 */
@Test
public void testNonEquality() {
    Ip4Prefix prefix1 = Ip4Prefix.valueOf("1.2.3.0/24");
    Ip4Address nextHop1 = Ip4Address.valueOf("5.6.7.8");
    RouteEntry routeEntry1 = new RouteEntry(prefix1, nextHop1);
    // Different
    Ip4Prefix prefix2 = Ip4Prefix.valueOf("1.2.3.0/25");
    Ip4Address nextHop2 = Ip4Address.valueOf("5.6.7.8");
    RouteEntry routeEntry2 = new RouteEntry(prefix2, nextHop2);
    Ip4Prefix prefix3 = Ip4Prefix.valueOf("1.2.3.0/24");
    // Different
    Ip4Address nextHop3 = Ip4Address.valueOf("5.6.7.9");
    RouteEntry routeEntry3 = new RouteEntry(prefix3, nextHop3);
    assertThat(routeEntry1, Matchers.is(Matchers.not(routeEntry2)));
    assertThat(routeEntry1, Matchers.is(Matchers.not(routeEntry3)));
    Ip6Prefix prefix4 = Ip6Prefix.valueOf("1000::/64");
    Ip6Address nextHop4 = Ip6Address.valueOf("2000::1");
    RouteEntry routeEntry4 = new RouteEntry(prefix4, nextHop4);
    Ip6Prefix prefix5 = Ip6Prefix.valueOf("1000::/65");
    Ip6Address nextHop5 = Ip6Address.valueOf("2000::1");
    RouteEntry routeEntry5 = new RouteEntry(prefix5, nextHop5);
    Ip6Prefix prefix6 = Ip6Prefix.valueOf("1000::/64");
    Ip6Address nextHop6 = Ip6Address.valueOf("2000::2");
    RouteEntry routeEntry6 = new RouteEntry(prefix6, nextHop6);
    assertThat(routeEntry4, Matchers.is(Matchers.not(routeEntry5)));
    assertThat(routeEntry4, Matchers.is(Matchers.not(routeEntry6)));
}
Also used : Ip6Prefix(org.onlab.packet.Ip6Prefix) Ip6Address(org.onlab.packet.Ip6Address) Ip4Address(org.onlab.packet.Ip4Address) Ip4Prefix(org.onlab.packet.Ip4Prefix) Test(org.junit.Test)

Example 3 with Ip6Address

use of org.onlab.packet.Ip6Address in project onos by opennetworkinglab.

the class RouteEntryTest method testEquality.

/**
 * Tests equality of {@link RouteEntry}.
 */
@Test
public void testEquality() {
    Ip4Prefix prefix1 = Ip4Prefix.valueOf("1.2.3.0/24");
    Ip4Address nextHop1 = Ip4Address.valueOf("5.6.7.8");
    RouteEntry routeEntry1 = new RouteEntry(prefix1, nextHop1);
    Ip4Prefix prefix2 = Ip4Prefix.valueOf("1.2.3.0/24");
    Ip4Address nextHop2 = Ip4Address.valueOf("5.6.7.8");
    RouteEntry routeEntry2 = new RouteEntry(prefix2, nextHop2);
    assertThat(routeEntry1, is(routeEntry2));
    Ip6Prefix prefix3 = Ip6Prefix.valueOf("1000::/64");
    Ip6Address nextHop3 = Ip6Address.valueOf("2000::2");
    RouteEntry routeEntry3 = new RouteEntry(prefix3, nextHop3);
    Ip6Prefix prefix4 = Ip6Prefix.valueOf("1000::/64");
    Ip6Address nextHop4 = Ip6Address.valueOf("2000::2");
    RouteEntry routeEntry4 = new RouteEntry(prefix4, nextHop4);
    assertThat(routeEntry3, is(routeEntry4));
}
Also used : Ip6Prefix(org.onlab.packet.Ip6Prefix) Ip6Address(org.onlab.packet.Ip6Address) Ip4Address(org.onlab.packet.Ip4Address) Ip4Prefix(org.onlab.packet.Ip4Prefix) Test(org.junit.Test)

Example 4 with Ip6Address

use of org.onlab.packet.Ip6Address in project onos by opennetworkinglab.

the class RouteEntryTest method testGetFields.

/**
 * Tests getting the fields of a route entry.
 */
@Test
public void testGetFields() {
    Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
    Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
    RouteEntry routeEntry = new RouteEntry(prefix, nextHop);
    assertThat(routeEntry.prefix(), is(prefix));
    assertThat(routeEntry.nextHop(), is(nextHop));
    Ip6Prefix prefix6 = Ip6Prefix.valueOf("1000::/64");
    Ip6Address nextHop6 = Ip6Address.valueOf("2000::1");
    RouteEntry routeEntry6 = new RouteEntry(prefix6, nextHop6);
    assertThat(routeEntry6.prefix(), is(prefix6));
    assertThat(routeEntry6.nextHop(), is(nextHop6));
}
Also used : Ip6Prefix(org.onlab.packet.Ip6Prefix) Ip6Address(org.onlab.packet.Ip6Address) Ip4Address(org.onlab.packet.Ip4Address) Ip4Prefix(org.onlab.packet.Ip4Prefix) Test(org.junit.Test)

Example 5 with Ip6Address

use of org.onlab.packet.Ip6Address in project onos by opennetworkinglab.

the class Dhcp6HandlerImpl method setDhcpServerConfigs.

public void setDhcpServerConfigs(Collection<DhcpServerConfig> configs, List<DhcpServerInfo> serverInfoList) {
    log.debug("config size {}.", configs.size());
    if (configs.size() == 0) {
        // no config to update
        return;
    }
    // TODO: currently we pick up first DHCP server config.
    // Will use other server configs in the future for HA.
    Boolean isConfigValid = false;
    for (DhcpServerConfig serverConfig : configs) {
        if (serverConfig.getDhcpServerIp6().isPresent()) {
            isConfigValid = true;
            break;
        }
    }
    if (!isConfigValid) {
        log.warn("No IP V6 server address found.");
        // No IP V6 address found
        return;
    }
    for (DhcpServerInfo oldServerInfo : serverInfoList) {
        // stop monitoring gateway or server
        oldServerInfo.getDhcpGatewayIp6().ifPresent(gatewayIp -> {
            hostService.stopMonitoringIp(gatewayIp);
        });
        oldServerInfo.getDhcpServerIp6().ifPresent(serverIp -> {
            hostService.stopMonitoringIp(serverIp);
            cancelDhcpPacket(serverIp);
        });
    }
    serverInfoList.clear();
    for (DhcpServerConfig serverConfig : configs) {
        // Create new server info according to the config
        DhcpServerInfo newServerInfo = new DhcpServerInfo(serverConfig, DhcpServerInfo.Version.DHCP_V6);
        checkState(newServerInfo.getDhcpServerConnectPoint().isPresent(), "Connect point not exists");
        checkState(newServerInfo.getDhcpServerIp6().isPresent(), "IP of DHCP server not exists");
        log.debug("DHCP server connect point: {}", newServerInfo.getDhcpServerConnectPoint().orElse(null));
        log.debug("DHCP server IP: {}", newServerInfo.getDhcpServerIp6().orElse(null));
        Ip6Address serverIp = newServerInfo.getDhcpServerIp6().get();
        Ip6Address ipToProbe;
        if (newServerInfo.getDhcpGatewayIp6().isPresent()) {
            ipToProbe = newServerInfo.getDhcpGatewayIp6().get();
        } else {
            ipToProbe = newServerInfo.getDhcpServerIp6().orElse(null);
        }
        String hostToProbe = newServerInfo.getDhcpGatewayIp6().map(ip -> "gateway").orElse("server");
        log.warn("Probing to resolve {} IP {}", hostToProbe, ipToProbe);
        hostService.startMonitoringIp(ipToProbe);
        Set<Host> hosts = hostService.getHostsByIp(ipToProbe);
        if (!hosts.isEmpty()) {
            Host host = hosts.iterator().next();
            newServerInfo.setDhcpConnectVlan(host.vlan());
            newServerInfo.setDhcpConnectMac(host.mac());
            log.warn("Host found host {}", host);
        } else {
            log.warn("No host found host ip {}", ipToProbe);
        }
        // Add new server info
        synchronized (this) {
            serverInfoList.add(newServerInfo);
        }
        if (!hosts.isEmpty()) {
            requestDhcpPacket(serverIp);
        }
    }
}
Also used : Dhcp6IaPdOption(org.onlab.packet.dhcp.Dhcp6IaPdOption) DeviceService(org.onosproject.net.device.DeviceService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) IgnoreDhcpConfig(org.onosproject.dhcprelay.config.IgnoreDhcpConfig) ApplicationId(org.onosproject.core.ApplicationId) Dhcp6IaNaOption(org.onlab.packet.dhcp.Dhcp6IaNaOption) Dhcp6IaTaOption(org.onlab.packet.dhcp.Dhcp6IaTaOption) Ip6Address(org.onlab.packet.Ip6Address) DhcpRelayStore(org.onosproject.dhcprelay.store.DhcpRelayStore) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) MsgType(org.onlab.packet.DHCP6.MsgType) PacketService(org.onosproject.net.packet.PacketService) DeviceId(org.onosproject.net.DeviceId) DhcpServerConfig(org.onosproject.dhcprelay.config.DhcpServerConfig) LEARN_ROUTE_FROM_LEASE_QUERY_DEFAULT(org.onosproject.dhcprelay.OsgiPropertyConstants.LEARN_ROUTE_FROM_LEASE_QUERY_DEFAULT) Dictionary(java.util.Dictionary) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Pipeliner(org.onosproject.net.behaviour.Pipeliner) REMOVE(org.onosproject.net.flowobjective.Objective.Operation.REMOVE) DhcpFpmPrefixStore(org.onosproject.dhcprelay.store.DhcpFpmPrefixStore) HostProviderRegistry(org.onosproject.net.host.HostProviderRegistry) Tools(org.onlab.util.Tools) RouteStore(org.onosproject.routeservice.RouteStore) Host(org.onosproject.net.Host) ComponentContext(org.osgi.service.component.ComponentContext) LEARN_ROUTE_FROM_LEASE_QUERY(org.onosproject.dhcprelay.OsgiPropertyConstants.LEARN_ROUTE_FROM_LEASE_QUERY) HostListener(org.onosproject.net.host.HostListener) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) Multimaps(com.google.common.collect.Multimaps) ArrayList(java.util.ArrayList) Dhcp6InterfaceIdOption(org.onlab.packet.dhcp.Dhcp6InterfaceIdOption) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) FpmRecord(org.onosproject.routing.fpm.api.FpmRecord) Dhcp6LeaseQueryOption(org.onlab.packet.dhcp.Dhcp6LeaseQueryOption) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) TpPort(org.onlab.packet.TpPort) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) BasePacket(org.onlab.packet.BasePacket) Executor(java.util.concurrent.Executor) HostProvider(org.onosproject.net.host.HostProvider) VlanId(org.onlab.packet.VlanId) ProviderId(org.onosproject.net.provider.ProviderId) Dhcp6IaAddressOption(org.onlab.packet.dhcp.Dhcp6IaAddressOption) IPv6(org.onlab.packet.IPv6) DHCP6(org.onlab.packet.DHCP6) HexString(org.onlab.util.HexString) DhcpRecord(org.onosproject.dhcprelay.store.DhcpRecord) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) Dhcp6Duid(org.onlab.packet.dhcp.Dhcp6Duid) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) Route(org.onosproject.routeservice.Route) HostLocation(org.onosproject.net.HostLocation) Interface(org.onosproject.net.intf.Interface) CoreService(org.onosproject.core.CoreService) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) Dhcp6ClientIdOption(org.onlab.packet.dhcp.Dhcp6ClientIdOption) ByteBuffer(java.nio.ByteBuffer) Ethernet(org.onlab.packet.Ethernet) HostProviderService(org.onosproject.net.host.HostProviderService) HashMultimap(com.google.common.collect.HashMultimap) Dhcp6IaPrefixOption(org.onlab.packet.dhcp.Dhcp6IaPrefixOption) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DhcpServerInfo(org.onosproject.dhcprelay.api.DhcpServerInfo) ImmutableSet(com.google.common.collect.ImmutableSet) Device(org.onosproject.net.Device) Collection(java.util.Collection) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) PacketContext(org.onosproject.net.packet.PacketContext) Optional(java.util.Optional) HostDescription(org.onosproject.net.host.HostDescription) IpPrefix(org.onlab.packet.IpPrefix) Dhcp6ClientDataOption(org.onlab.packet.dhcp.Dhcp6ClientDataOption) ADD(org.onosproject.net.flowobjective.Objective.Operation.ADD) Multimap(com.google.common.collect.Multimap) Dhcp6RelayOption(org.onlab.packet.dhcp.Dhcp6RelayOption) DhcpRelayCountersStore(org.onosproject.dhcprelay.store.DhcpRelayCountersStore) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) OutboundPacket(org.onosproject.net.packet.OutboundPacket) Activate(org.osgi.service.component.annotations.Activate) HostEvent(org.onosproject.net.host.HostEvent) HostId(org.onosproject.net.HostId) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Logger(org.slf4j.Logger) Semaphore(java.util.concurrent.Semaphore) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Dhcp6Option(org.onlab.packet.dhcp.Dhcp6Option) UDP(org.onlab.packet.UDP) DhcpHandler(org.onosproject.dhcprelay.api.DhcpHandler) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Modified(org.osgi.service.component.annotations.Modified) PacketPriority(org.onosproject.net.packet.PacketPriority) Reference(org.osgi.service.component.annotations.Reference) Ip6Address(org.onlab.packet.Ip6Address) DhcpServerConfig(org.onosproject.dhcprelay.config.DhcpServerConfig) Host(org.onosproject.net.Host) HexString(org.onlab.util.HexString) DhcpServerInfo(org.onosproject.dhcprelay.api.DhcpServerInfo)

Aggregations

Ip6Address (org.onlab.packet.Ip6Address)31 MacAddress (org.onlab.packet.MacAddress)12 Ip4Address (org.onlab.packet.Ip4Address)11 ArrayList (java.util.ArrayList)9 DHCP6 (org.onlab.packet.DHCP6)9 Ethernet (org.onlab.packet.Ethernet)9 IPv6 (org.onlab.packet.IPv6)9 IpAddress (org.onlab.packet.IpAddress)9 UDP (org.onlab.packet.UDP)9 VlanId (org.onlab.packet.VlanId)9 ConnectPoint (org.onosproject.net.ConnectPoint)9 DhcpServerInfo (org.onosproject.dhcprelay.api.DhcpServerInfo)8 Interface (org.onosproject.net.intf.Interface)8 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)7 List (java.util.List)7 Set (java.util.Set)7 Test (org.junit.Test)7 BasePacket (org.onlab.packet.BasePacket)7 MsgType (org.onlab.packet.DHCP6.MsgType)7 Dhcp6ClientIdOption (org.onlab.packet.dhcp.Dhcp6ClientIdOption)7