Search in sources :

Example 16 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class InterfaceManagerTest method testGetInterfacesByPort.

@Test
public void testGetInterfacesByPort() throws Exception {
    ConnectPoint cp = ConnectPoint.deviceConnectPoint("of:0000000000000001/1");
    Set<Interface> byPort = Collections.singleton(createInterface(1));
    assertEquals(byPort, interfaceManager.getInterfacesByPort(cp));
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test)

Example 17 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class InterfaceManagerTest method testUpdateInterface.

@Test
public void testUpdateInterface() throws Exception {
    ConnectPoint cp = createConnectPoint(1);
    // Create an interface that is the same as the existing one, but adds a
    // new IP address
    Interface intf = createInterface(1);
    List<InterfaceIpAddress> addresses = Lists.newArrayList(intf.ipAddressesList());
    addresses.add(InterfaceIpAddress.valueOf("192.168.100.1/24"));
    intf = new Interface(Interface.NO_INTERFACE_NAME, intf.connectPoint(), addresses, intf.mac(), intf.vlan());
    // Create a new interface on the same connect point as the existing one
    InterfaceIpAddress newAddr = InterfaceIpAddress.valueOf("192.168.101.1/24");
    Interface newIntf = new Interface(Interface.NO_INTERFACE_NAME, cp, Collections.singletonList(newAddr), MacAddress.valueOf(101), VlanId.vlanId((short) 101));
    Set<Interface> interfaces = Sets.newHashSet(intf, newIntf);
    // New interface config updates the existing interface and adds a new
    // interface to the same connect point
    InterfaceConfig oldIc = new TestInterfaceConfig(cp, Sets.newHashSet(intf));
    InterfaceConfig ic = new TestInterfaceConfig(cp, interfaces);
    configs.put(cp, ic);
    NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_UPDATED, cp, ic, oldIc, CONFIG_CLASS);
    // Send in the event signalling the interfaces for this connect point
    // have been updated
    listener.event(event);
    assertEquals(NUM_INTERFACES + 1, interfaceManager.getInterfaces().size());
    assertEquals(interfaces, interfaceManager.getInterfacesByPort(cp));
}
Also used : InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) ConnectPoint(org.onosproject.net.ConnectPoint) Interface(org.onosproject.net.intf.Interface) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Test(org.junit.Test)

Example 18 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class InterfaceManagerTest method testGetInterfacesByIp.

@Test
public void testGetInterfacesByIp() throws Exception {
    IpAddress ip = Ip4Address.valueOf("192.168.2.1");
    Set<Interface> byIp = Collections.singleton(createInterface(2));
    assertEquals(byIp, interfaceManager.getInterfacesByIp(ip));
}
Also used : InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) IpAddress(org.onlab.packet.IpAddress) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test)

Example 19 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class InterfaceManagerTest method testAddInterface.

@Test
public void testAddInterface() throws Exception {
    // Create a new InterfaceConfig which will get added
    VlanId vlanId = VlanId.vlanId((short) 1);
    ConnectPoint cp = ConnectPoint.deviceConnectPoint("of:0000000000000001/2");
    Interface newIntf = new Interface(Interface.NO_INTERFACE_NAME, cp, Collections.emptyList(), MacAddress.valueOf(100), vlanId);
    InterfaceConfig ic = new TestInterfaceConfig(cp, Collections.singleton(newIntf));
    subjects.add(cp);
    configs.put(cp, ic);
    interfaces.add(newIntf);
    NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_ADDED, cp, ic, null, CONFIG_CLASS);
    assertEquals(NUM_INTERFACES, interfaceManager.getInterfaces().size());
    // Send in a config event containing a new interface config
    listener.event(event);
    // Check the new interface exists in the InterfaceManager's inventory
    assertEquals(interfaces, interfaceManager.getInterfaces());
    assertEquals(NUM_INTERFACES + 1, interfaceManager.getInterfaces().size());
    // There are now two interfaces with vlan ID 1
    Set<Interface> byVlan = Sets.newHashSet(createInterface(1), newIntf);
    assertEquals(byVlan, interfaceManager.getInterfacesByVlan(vlanId));
}
Also used : InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) ConnectPoint(org.onosproject.net.ConnectPoint) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test)

Example 20 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class ReactiveRoutingConfiguration method setUpConfiguration.

/**
 * Set up reactive routing information from configuration.
 */
private void setUpConfiguration() {
    ReactiveRoutingConfig config = configService.getConfig(coreService.registerApplication(ReactiveRoutingConfigurationService.REACTIVE_ROUTING_APP_ID), ReactiveRoutingConfigurationService.CONFIG_CLASS);
    if (config == null) {
        log.warn("No reactive routing config available!");
        return;
    }
    for (LocalIpPrefixEntry entry : config.localIp4PrefixEntries()) {
        localPrefixTable4.put(createBinaryString(entry.ipPrefix()), entry);
        gatewayIpAddresses.add(entry.getGatewayIpAddress());
        log.info("adding local IPv4 entry: {} {}", entry.ipPrefix(), entry.getGatewayIpAddress());
    }
    for (LocalIpPrefixEntry entry : config.localIp6PrefixEntries()) {
        localPrefixTable6.put(createBinaryString(entry.ipPrefix()), entry);
        gatewayIpAddresses.add(entry.getGatewayIpAddress());
        log.info("adding local IPv6 entry: {} {}", entry.ipPrefix(), entry.getGatewayIpAddress());
    }
    virtualGatewayMacAddress = config.virtualGatewayMacAddress();
    log.info("virtual gateway MAC: {}", virtualGatewayMacAddress);
    // Setup BGP peer connect points
    ApplicationId routerAppId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
    if (routerAppId == null) {
        log.info("Router application ID is null!");
        return;
    }
    BgpConfig bgpConfig = configService.getConfig(routerAppId, BgpConfig.class);
    if (bgpConfig == null) {
        log.info("BGP config is null!");
        return;
    } else {
        bgpPeerConnectPoints = bgpConfig.bgpSpeakers().stream().flatMap(speaker -> speaker.peers().stream()).map(peer -> interfaceService.getMatchingInterface(peer)).filter(Objects::nonNull).map(Interface::connectPoint).collect(Collectors.toSet());
    }
}
Also used : NetworkConfigService(org.onosproject.net.config.NetworkConfigService) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) Interface(org.onosproject.net.intf.Interface) RouteTools.createBinaryString(org.onosproject.routeservice.RouteTools.createBinaryString) DefaultByteArrayNodeFactory(com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory) CoreService(org.onosproject.core.CoreService) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) LoggerFactory(org.slf4j.LoggerFactory) InterfaceService(org.onosproject.net.intf.InterfaceService) ConnectPoint(org.onosproject.net.ConnectPoint) HashSet(java.util.HashSet) Component(org.osgi.service.component.annotations.Component) SubjectFactories(org.onosproject.net.config.basics.SubjectFactories) ApplicationId(org.onosproject.core.ApplicationId) Activate(org.osgi.service.component.annotations.Activate) IpAddress(org.onlab.packet.IpAddress) RoutingService(org.onosproject.routing.RoutingService) Ip6Address(org.onlab.packet.Ip6Address) ImmutableSet(com.google.common.collect.ImmutableSet) Ip4Address(org.onlab.packet.Ip4Address) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) BgpConfig(org.onosproject.routing.config.BgpConfig) Collectors(java.util.stream.Collectors) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) ConfigFactory(org.onosproject.net.config.ConfigFactory) InvertedRadixTree(com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree) ConcurrentInvertedRadixTree(com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) IpPrefix(org.onlab.packet.IpPrefix) BgpConfig(org.onosproject.routing.config.BgpConfig) ApplicationId(org.onosproject.core.ApplicationId) Interface(org.onosproject.net.intf.Interface)

Aggregations

Interface (org.onosproject.net.intf.Interface)92 ConnectPoint (org.onosproject.net.ConnectPoint)51 MacAddress (org.onlab.packet.MacAddress)35 VlanId (org.onlab.packet.VlanId)34 InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)32 Ethernet (org.onlab.packet.Ethernet)28 IpAddress (org.onlab.packet.IpAddress)28 ArrayList (java.util.ArrayList)26 DeviceId (org.onosproject.net.DeviceId)26 Host (org.onosproject.net.Host)25 InterfaceService (org.onosproject.net.intf.InterfaceService)25 Logger (org.slf4j.Logger)25 Set (java.util.Set)23 TrafficSelector (org.onosproject.net.flow.TrafficSelector)23 LoggerFactory (org.slf4j.LoggerFactory)23 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)22 Test (org.junit.Test)21 ApplicationId (org.onosproject.core.ApplicationId)21 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)20 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)20