Package org.onosproject.segmentrouting
Class DeviceConfiguration
- java.lang.Object
-
- org.onosproject.segmentrouting.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 voidaddSubnet(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 hopSet<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.DeviceIdgetDeviceId(int sid)Returns the device identifier or data plane identifier (dpid) of a segment router given its segment id.org.onosproject.net.DeviceIdgetDeviceId(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.DeviceIdgetDeviceId(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.MacAddressgetDeviceMac(org.onosproject.net.DeviceId deviceId)List<org.onosproject.net.DeviceId>getEdgeDeviceIds()List<org.onosproject.net.DeviceId>getInfraDeviceIds()intgetIPv4SegmentId(org.onlab.packet.Ip4Address routerAddress)Returns the IPv4 Node segment id of a segment router given its Router ip address.intgetIPv4SegmentId(org.onlab.packet.MacAddress routerMac)Returns the IPv4 Node segment id of a segment router given its Router mac address.intgetIPv4SegmentId(org.onosproject.net.DeviceId deviceId)intgetIPv6SegmentId(org.onlab.packet.Ip6Address routerAddress)Returns the IPv6 Node segment id of a segment router given its Router ip address.intgetIPv6SegmentId(org.onlab.packet.MacAddress routerMac)Returns the IPv6 Node segment id of a segment router given its Router mac address.intgetIPv6SegmentId(org.onosproject.net.DeviceId deviceId)org.onosproject.net.DeviceIdgetPairDeviceId(org.onosproject.net.DeviceId deviceId)org.onosproject.net.PortNumbergetPairLocalPort(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.intgetPWRoutingLabel(org.onosproject.net.DeviceId deviceId)org.onlab.packet.IpAddressgetRouterIpAddress(org.onlab.packet.IpAddress destIpAddress, org.onosproject.net.DeviceId routerDeviceId)Gets router ip address based on the destination ip address.org.onlab.packet.Ip4AddressgetRouterIpAddressForASubnetHost(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.Ip6AddressgetRouterIpAddressForASubnetHost(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.Ip4AddressgetRouterIpv4(org.onosproject.net.DeviceId deviceId)org.onlab.packet.Ip6AddressgetRouterIpv6(org.onosproject.net.DeviceId deviceId)org.onlab.packet.MacAddressgetRouterMacForAGatewayIp(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) insteadbooleaninSameSubnet(org.onosproject.net.ConnectPoint connectPoint, org.onlab.packet.IpAddress ip)Checks if the IP is in the subnet defined on given connect point.booleaninSameSubnet(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.booleanisAdjacencySid(org.onosproject.net.DeviceId deviceId, int sid)Check if the Sid given is whether adjacency Sid of the router device or not.booleanisConfigured(org.onosproject.net.DeviceId deviceId)booleanisEdgeDevice(org.onosproject.net.DeviceId deviceId)booleanisPairedEdge(org.onosproject.net.DeviceId deviceId)booleanisPairLocalPort(org.onosproject.net.DeviceId devId, org.onosproject.net.PortNumber pnum)voidremoveSubnet(org.onosproject.net.ConnectPoint cp, org.onlab.packet.IpPrefix ipPrefix)Remove subnet from specific connect point.voidupdateConfig()
-
-
-
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:
isConfiguredin interfaceorg.onosproject.segmentrouting.config.DeviceProperties
-
getIPv4SegmentId
public int getIPv4SegmentId(org.onosproject.net.DeviceId deviceId) throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException- Specified by:
getIPv4SegmentIdin interfaceorg.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:
getIPv6SegmentIdin interfaceorg.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:
getPWRoutingLabelin interfaceorg.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:
getDeviceMacin interfaceorg.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:
getRouterIpv4in interfaceorg.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:
getRouterIpv6in interfaceorg.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 addressrouterDeviceId- 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:
isEdgeDevicein interfaceorg.onosproject.segmentrouting.config.DeviceProperties- Throws:
org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
-
getEdgeDeviceIds
public List<org.onosproject.net.DeviceId> getEdgeDeviceIds()
- Specified by:
getEdgeDeviceIdsin interfaceorg.onosproject.segmentrouting.config.DeviceProperties
-
getInfraDeviceIds
public List<org.onosproject.net.DeviceId> getInfraDeviceIds()
- Specified by:
getInfraDeviceIdsin interfaceorg.onosproject.segmentrouting.config.DeviceProperties
-
getAllDeviceSegmentIds
public List<Integer> getAllDeviceSegmentIds()
- Specified by:
getAllDeviceSegmentIdsin interfaceorg.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:
getSubnetPortsMapin interfaceorg.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) insteadReturns 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 hopFirst 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 IDport- 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 routerhostIp- 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 pointip- 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 routersid- 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 routersid- 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 pointipPrefix- 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 pointipPrefix- 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)
-
-