Class DeviceConfiguration

  • All Implemented Interfaces:
    org.onosproject.segmentrouting.config.DeviceProperties

    public class DeviceConfiguration
    extends Object
    implements org.onosproject.segmentrouting.config.DeviceProperties
    Segment Routing configuration component that reads the segment routing related configuration from Network Configuration Manager component and organizes in more accessible formats.
    • Constructor Summary

      Constructors 
      Constructor Description
      DeviceConfiguration​(SegmentRoutingManager srManager)
      Constructs device configuration for all Segment Router devices, organizing the data into various maps for easier access.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addSubnet​(org.onosproject.net.ConnectPoint cp, org.onlab.packet.IpPrefix ipPrefix)
      Add subnet to specific connect point.
      List<Integer> getAllDeviceSegmentIds()  
      List<Set<org.onlab.packet.IpPrefix>> getBatchedSubnets​(org.onosproject.net.DeviceId deviceId)
      Returns batches of all subnets reachable on the given device.
      List<Set<org.onlab.packet.IpPrefix>> getBatchedSubnets​(org.onosproject.net.HostId hostId)
      Returns batches of all subnets reachable via given next hop
      Set<org.onlab.packet.IpPrefix> getConfiguredSubnets​(org.onosproject.net.DeviceId deviceId)
      Returns configured subnets for a segment router.
      Set<org.onosproject.net.ConnectPoint> getConnectPointsForASubnetHost​(org.onlab.packet.IpAddress destIpAddress)
      Returns all the connect points of the segment routers that have the specified ip address in their subnets.
      org.onosproject.net.DeviceId getDeviceId​(int sid)
      Returns the device identifier or data plane identifier (dpid) of a segment router given its segment id.
      org.onosproject.net.DeviceId getDeviceId​(org.onlab.packet.Ip4Address ipAddress)
      Returns the device identifier or data plane identifier (dpid) of a segment router given its router ip address.
      org.onosproject.net.DeviceId getDeviceId​(org.onlab.packet.Ip6Address ipAddress)
      Returns the device identifier or data plane identifier (dpid) of a segment router given its router ipv6 address.
      org.onlab.packet.MacAddress getDeviceMac​(org.onosproject.net.DeviceId deviceId)  
      List<org.onosproject.net.DeviceId> getEdgeDeviceIds()  
      List<org.onosproject.net.DeviceId> getInfraDeviceIds()  
      int getIPv4SegmentId​(org.onlab.packet.Ip4Address routerAddress)
      Returns the IPv4 Node segment id of a segment router given its Router ip address.
      int getIPv4SegmentId​(org.onlab.packet.MacAddress routerMac)
      Returns the IPv4 Node segment id of a segment router given its Router mac address.
      int getIPv4SegmentId​(org.onosproject.net.DeviceId deviceId)  
      int getIPv6SegmentId​(org.onlab.packet.Ip6Address routerAddress)
      Returns the IPv6 Node segment id of a segment router given its Router ip address.
      int getIPv6SegmentId​(org.onlab.packet.MacAddress routerMac)
      Returns the IPv6 Node segment id of a segment router given its Router mac address.
      int getIPv6SegmentId​(org.onosproject.net.DeviceId deviceId)  
      org.onosproject.net.DeviceId getPairDeviceId​(org.onosproject.net.DeviceId deviceId)  
      org.onosproject.net.PortNumber getPairLocalPort​(org.onosproject.net.DeviceId deviceId)  
      Set<org.onosproject.net.ConnectPoint> getPortByIps​(Set<org.onlab.packet.IpAddress> ips)
      Returns all ports that has a subnet that contains any of the given IP addresses.
      Set<org.onlab.packet.IpAddress> getPortIPs​(org.onosproject.net.DeviceId deviceId)
      Returns the configured port ip addresses for a segment router.
      Set<Integer> getPortsForAdjacencySid​(org.onosproject.net.DeviceId deviceId, int sid)
      Returns the ports corresponding to the adjacency Sid given.
      Set<org.onlab.packet.IpPrefix> getPortSubnets​(org.onosproject.net.DeviceId deviceId, org.onosproject.net.PortNumber port)
      Returns the subnet configuration of given device and port.
      int getPWRoutingLabel​(org.onosproject.net.DeviceId deviceId)  
      org.onlab.packet.IpAddress getRouterIpAddress​(org.onlab.packet.IpAddress destIpAddress, org.onosproject.net.DeviceId routerDeviceId)
      Gets router ip address based on the destination ip address.
      org.onlab.packet.Ip4Address getRouterIpAddressForASubnetHost​(org.onlab.packet.Ip4Address destIpAddress)
      Returns the router ip address of segment router that has the specified ip address in its subnets.
      org.onlab.packet.Ip6Address getRouterIpAddressForASubnetHost​(org.onlab.packet.Ip6Address destIpAddress)
      Returns the router ipv6 address of segment router that has the specified ip address in its subnets.
      org.onlab.packet.Ip4Address getRouterIpv4​(org.onosproject.net.DeviceId deviceId)  
      org.onlab.packet.Ip6Address getRouterIpv6​(org.onosproject.net.DeviceId deviceId)  
      org.onlab.packet.MacAddress getRouterMacForAGatewayIp​(org.onlab.packet.IpAddress gatewayIpAddress)
      Returns the router mac address of segment router that has the specified ip address as one of its subnet gateway ip address.
      Collection<org.onosproject.net.DeviceId> getRouters()  
      Map<org.onlab.packet.IpPrefix,​List<org.onosproject.net.PortNumber>> getSubnetPortsMap​(org.onosproject.net.DeviceId deviceId)  
      Set<org.onlab.packet.IpPrefix> getSubnets​(org.onosproject.net.DeviceId deviceId)
      Deprecated.
      use getBatchedSubnets(DeviceId deviceId) instead
      boolean inSameSubnet​(org.onosproject.net.ConnectPoint connectPoint, org.onlab.packet.IpAddress ip)
      Checks if the IP is in the subnet defined on given connect point.
      boolean inSameSubnet​(org.onosproject.net.DeviceId deviceId, org.onlab.packet.IpAddress hostIp)
      Checks if the host IP is in any of the subnet defined in the router with the device ID given.
      boolean isAdjacencySid​(org.onosproject.net.DeviceId deviceId, int sid)
      Check if the Sid given is whether adjacency Sid of the router device or not.
      boolean isConfigured​(org.onosproject.net.DeviceId deviceId)  
      boolean isEdgeDevice​(org.onosproject.net.DeviceId deviceId)  
      boolean isPairedEdge​(org.onosproject.net.DeviceId deviceId)  
      boolean isPairLocalPort​(org.onosproject.net.DeviceId devId, org.onosproject.net.PortNumber pnum)  
      void removeSubnet​(org.onosproject.net.ConnectPoint cp, org.onlab.packet.IpPrefix ipPrefix)
      Remove subnet from specific connect point.
      void updateConfig()  
    • Constructor Detail

      • DeviceConfiguration

        public DeviceConfiguration​(SegmentRoutingManager srManager)
        Constructs device configuration for all Segment Router devices, organizing the data into various maps for easier access.
        Parameters:
        srManager - Segment Routing Manager
    • Method Detail

      • updateConfig

        public void updateConfig()
      • getRouters

        public Collection<org.onosproject.net.DeviceId> getRouters()
      • isConfigured

        public boolean isConfigured​(org.onosproject.net.DeviceId deviceId)
        Specified by:
        isConfigured in interface org.onosproject.segmentrouting.config.DeviceProperties
      • getIPv4SegmentId

        public int getIPv4SegmentId​(org.onosproject.net.DeviceId deviceId)
                             throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
        Specified by:
        getIPv4SegmentId in interface org.onosproject.segmentrouting.config.DeviceProperties
        Throws:
        org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
      • getIPv6SegmentId

        public int getIPv6SegmentId​(org.onosproject.net.DeviceId deviceId)
                             throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
        Specified by:
        getIPv6SegmentId in interface org.onosproject.segmentrouting.config.DeviceProperties
        Throws:
        org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
      • getPWRoutingLabel

        public int getPWRoutingLabel​(org.onosproject.net.DeviceId deviceId)
                              throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
        Specified by:
        getPWRoutingLabel in interface org.onosproject.segmentrouting.config.DeviceProperties
        Throws:
        org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
      • getIPv4SegmentId

        public int getIPv4SegmentId​(org.onlab.packet.MacAddress routerMac)
        Returns the IPv4 Node segment id of a segment router given its Router mac address.
        Parameters:
        routerMac - router mac address
        Returns:
        node segment id, or -1 if not found in config
      • getIPv6SegmentId

        public int getIPv6SegmentId​(org.onlab.packet.MacAddress routerMac)
        Returns the IPv6 Node segment id of a segment router given its Router mac address.
        Parameters:
        routerMac - router mac address
        Returns:
        node segment id, or -1 if not found in config
      • getIPv4SegmentId

        public int getIPv4SegmentId​(org.onlab.packet.Ip4Address routerAddress)
        Returns the IPv4 Node segment id of a segment router given its Router ip address.
        Parameters:
        routerAddress - router ip address
        Returns:
        node segment id, or -1 if not found in config
      • getIPv6SegmentId

        public int getIPv6SegmentId​(org.onlab.packet.Ip6Address routerAddress)
        Returns the IPv6 Node segment id of a segment router given its Router ip address.
        Parameters:
        routerAddress - router ip address
        Returns:
        node segment id, or -1 if not found in config
      • getDeviceMac

        public org.onlab.packet.MacAddress getDeviceMac​(org.onosproject.net.DeviceId deviceId)
                                                 throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
        Specified by:
        getDeviceMac in interface org.onosproject.segmentrouting.config.DeviceProperties
        Throws:
        org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
      • getRouterIpv4

        public org.onlab.packet.Ip4Address getRouterIpv4​(org.onosproject.net.DeviceId deviceId)
                                                  throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
        Specified by:
        getRouterIpv4 in interface org.onosproject.segmentrouting.config.DeviceProperties
        Throws:
        org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
      • getRouterIpv6

        public org.onlab.packet.Ip6Address getRouterIpv6​(org.onosproject.net.DeviceId deviceId)
                                                  throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
        Specified by:
        getRouterIpv6 in interface org.onosproject.segmentrouting.config.DeviceProperties
        Throws:
        org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
      • getRouterIpAddress

        public org.onlab.packet.IpAddress getRouterIpAddress​(org.onlab.packet.IpAddress destIpAddress,
                                                             org.onosproject.net.DeviceId routerDeviceId)
        Gets router ip address based on the destination ip address.
        Parameters:
        destIpAddress - the destination ip address
        routerDeviceId - the device id
        Returns:
        the ip address of the routes
      • isEdgeDevice

        public boolean isEdgeDevice​(org.onosproject.net.DeviceId deviceId)
                             throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
        Specified by:
        isEdgeDevice in interface org.onosproject.segmentrouting.config.DeviceProperties
        Throws:
        org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
      • getEdgeDeviceIds

        public List<org.onosproject.net.DeviceId> getEdgeDeviceIds()
        Specified by:
        getEdgeDeviceIds in interface org.onosproject.segmentrouting.config.DeviceProperties
      • getInfraDeviceIds

        public List<org.onosproject.net.DeviceId> getInfraDeviceIds()
        Specified by:
        getInfraDeviceIds in interface org.onosproject.segmentrouting.config.DeviceProperties
      • getAllDeviceSegmentIds

        public List<Integer> getAllDeviceSegmentIds()
        Specified by:
        getAllDeviceSegmentIds in interface org.onosproject.segmentrouting.config.DeviceProperties
      • getSubnetPortsMap

        public Map<org.onlab.packet.IpPrefix,​List<org.onosproject.net.PortNumber>> getSubnetPortsMap​(org.onosproject.net.DeviceId deviceId)
                                                                                                    throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
        Specified by:
        getSubnetPortsMap in interface org.onosproject.segmentrouting.config.DeviceProperties
        Throws:
        org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
      • getDeviceId

        public org.onosproject.net.DeviceId getDeviceId​(int sid)
        Returns the device identifier or data plane identifier (dpid) of a segment router given its segment id.
        Parameters:
        sid - segment id
        Returns:
        deviceId device identifier
      • getDeviceId

        public org.onosproject.net.DeviceId getDeviceId​(org.onlab.packet.Ip4Address ipAddress)
        Returns the device identifier or data plane identifier (dpid) of a segment router given its router ip address.
        Parameters:
        ipAddress - router ip address
        Returns:
        deviceId device identifier
      • getDeviceId

        public org.onosproject.net.DeviceId getDeviceId​(org.onlab.packet.Ip6Address ipAddress)
        Returns the device identifier or data plane identifier (dpid) of a segment router given its router ipv6 address.
        Parameters:
        ipAddress - router ipv6 address
        Returns:
        deviceId device identifier
      • getPortIPs

        public Set<org.onlab.packet.IpAddress> getPortIPs​(org.onosproject.net.DeviceId deviceId)
        Returns the configured port ip addresses for a segment router. These addresses serve as gateway IP addresses for the subnets configured on those ports.
        Parameters:
        deviceId - device identifier
        Returns:
        immutable set of ip addresses configured on the ports or null if not found
      • getConfiguredSubnets

        public Set<org.onlab.packet.IpPrefix> getConfiguredSubnets​(org.onosproject.net.DeviceId deviceId)
        Returns configured subnets for a segment router.
        Parameters:
        deviceId - device identifier
        Returns:
        list of ip prefixes or null if not found
      • getSubnets

        @Deprecated
        public Set<org.onlab.packet.IpPrefix> getSubnets​(org.onosproject.net.DeviceId deviceId)
        Deprecated.
        use getBatchedSubnets(DeviceId deviceId) instead
        Returns all subnets for a segment router, including subnets learnt from route service.
        Parameters:
        deviceId - device identifier
        Returns:
        set of ip prefixes or null if not found
      • getBatchedSubnets

        public List<Set<org.onlab.packet.IpPrefix>> getBatchedSubnets​(org.onosproject.net.HostId hostId)
        Returns batches of all subnets reachable via given next hop

        First batch includes FPM and STATIC routes Second batch includes all other type of routes obtained from routeService, including DHCP routes.

        Parameters:
        hostId - next hop host id
        Returns:
        list of subnet batches, each batch includes a set of prefixes.
      • getBatchedSubnets

        public List<Set<org.onlab.packet.IpPrefix>> getBatchedSubnets​(org.onosproject.net.DeviceId deviceId)
        Returns batches of all subnets reachable on the given device.

        First batch includes configured subnets, FPM and STATIC routes Second batch includes all other type of routes obtained from routeService, including DHCP routes.

        Parameters:
        deviceId - device identifier
        Returns:
        list of subnet batches, each batch includes a set of prefixes.
      • getPortSubnets

        public Set<org.onlab.packet.IpPrefix> getPortSubnets​(org.onosproject.net.DeviceId deviceId,
                                                             org.onosproject.net.PortNumber port)
        Returns the subnet configuration of given device and port.
        Parameters:
        deviceId - Device ID
        port - Port number
        Returns:
        The subnets configured on given port or empty set if the port is unconfigured or suppressed.
      • getPortByIps

        public Set<org.onosproject.net.ConnectPoint> getPortByIps​(Set<org.onlab.packet.IpAddress> ips)
        Returns all ports that has a subnet that contains any of the given IP addresses.
        Parameters:
        ips - a set of IP addresses
        Returns:
        a set of connect point that has a subnet that contains any of the given IP addresses
      • getConnectPointsForASubnetHost

        public Set<org.onosproject.net.ConnectPoint> getConnectPointsForASubnetHost​(org.onlab.packet.IpAddress destIpAddress)
        Returns all the connect points of the segment routers that have the specified ip address in their subnets.
        Parameters:
        destIpAddress - target ip address
        Returns:
        connect points of the segment routers
      • getRouterIpAddressForASubnetHost

        public org.onlab.packet.Ip4Address getRouterIpAddressForASubnetHost​(org.onlab.packet.Ip4Address destIpAddress)
        Returns the router ip address of segment router that has the specified ip address in its subnets.
        Parameters:
        destIpAddress - target ip address
        Returns:
        router ip address
      • getRouterIpAddressForASubnetHost

        public org.onlab.packet.Ip6Address getRouterIpAddressForASubnetHost​(org.onlab.packet.Ip6Address destIpAddress)
        Returns the router ipv6 address of segment router that has the specified ip address in its subnets.
        Parameters:
        destIpAddress - target ip address
        Returns:
        router ip address
      • getRouterMacForAGatewayIp

        public org.onlab.packet.MacAddress getRouterMacForAGatewayIp​(org.onlab.packet.IpAddress gatewayIpAddress)
        Returns the router mac address of segment router that has the specified ip address as one of its subnet gateway ip address.
        Parameters:
        gatewayIpAddress - router gateway ip address
        Returns:
        router mac address or null if not found
      • inSameSubnet

        public boolean inSameSubnet​(org.onosproject.net.DeviceId deviceId,
                                    org.onlab.packet.IpAddress hostIp)
        Checks if the host IP is in any of the subnet defined in the router with the device ID given.
        Parameters:
        deviceId - device identification of the router
        hostIp - host IP address to check
        Returns:
        true if the given IP is within any of the subnet defined in the router, false if no subnet is defined in the router or if the host is not within any subnet defined in the router
      • inSameSubnet

        public boolean inSameSubnet​(org.onosproject.net.ConnectPoint connectPoint,
                                    org.onlab.packet.IpAddress ip)
        Checks if the IP is in the subnet defined on given connect point.
        Parameters:
        connectPoint - Connect point
        ip - The IP address to check
        Returns:
        True if the IP belongs to the subnet. False if the IP does not belong to the subnet, or there is no subnet configuration on given connect point.
      • getPortsForAdjacencySid

        public Set<Integer> getPortsForAdjacencySid​(org.onosproject.net.DeviceId deviceId,
                                                    int sid)
        Returns the ports corresponding to the adjacency Sid given.
        Parameters:
        deviceId - device identification of the router
        sid - adjacency Sid
        Returns:
        set of port numbers
      • isAdjacencySid

        public boolean isAdjacencySid​(org.onosproject.net.DeviceId deviceId,
                                      int sid)
        Check if the Sid given is whether adjacency Sid of the router device or not.
        Parameters:
        deviceId - device identification of the router
        sid - Sid to check
        Returns:
        true if the Sid given is the adjacency Sid of the device, otherwise false
      • addSubnet

        public void addSubnet​(org.onosproject.net.ConnectPoint cp,
                              org.onlab.packet.IpPrefix ipPrefix)
        Add subnet to specific connect point.
        Parameters:
        cp - connect point
        ipPrefix - subnet being added to the device
      • removeSubnet

        public void removeSubnet​(org.onosproject.net.ConnectPoint cp,
                                 org.onlab.packet.IpPrefix ipPrefix)
        Remove subnet from specific connect point.
        Parameters:
        cp - connect point
        ipPrefix - subnet being removed to the device
      • isPairedEdge

        public boolean isPairedEdge​(org.onosproject.net.DeviceId deviceId)
                             throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
        Throws:
        org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
      • getPairDeviceId

        public org.onosproject.net.DeviceId getPairDeviceId​(org.onosproject.net.DeviceId deviceId)
                                                     throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
        Throws:
        org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
      • getPairLocalPort

        public org.onosproject.net.PortNumber getPairLocalPort​(org.onosproject.net.DeviceId deviceId)
                                                        throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
        Throws:
        org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
      • isPairLocalPort

        public boolean isPairLocalPort​(org.onosproject.net.DeviceId devId,
                                       org.onosproject.net.PortNumber pnum)