SSF.OS.BGP4
Class RIBElement

java.lang.Object
  |
  +--SSF.OS.BGP4.Util.RadixTree
        |
        +--SSF.OS.BGP4.RIBElement
Direct Known Subclasses:
AdjRIBIn, AdjRIBOut, LocRIB

public abstract class RIBElement
extends RadixTree

An element of a RIB. A single RIBElement is either Loc-RIB, or part of Adj-RIBs-In or Adj-RIBs-Out. An array of RIBElements make up Adj-RIBs-In, and the same is true for Adj-RIBs-Out (since they each have one element per peer).


Field Summary
protected  BGPSession bgp
          A reference to the local BGP protocol session.
protected  java.util.HashMap rtes
          A table mapping NLRI to routes.
protected  int version
          The version number of the table.
 
Method Summary
 RouteInfo add(RouteInfo info)
          Adds route information.
 int approxBytes(boolean usenhi)
          Determines the approximate number of bytes that would be required when converting this RIB element to a series of bytes with toBytes.
static int bytes2str(java.lang.StringBuffer ribstr, byte[] bytes, int bindex, java.lang.String ind, boolean usenhi)
          Converts a series of bytes into a string represention of a RIB element.
 RouteInfo find(IPaddress ipa)
          Attempts to find information for a given destination.
 java.util.ArrayList get_all_routes()
          Constructs and returns a list of all route information in the RIB element.
 java.util.Iterator get_dests()
          Returns an iterator for enumerating the destinations (IP addresses) of all contained routes.
 java.util.ArrayList get_less_specifics(IPaddress ipa)
          Finds any routes with overlapping but less specific NLRI than the given IP address prefix.
 java.util.ArrayList get_more_specifics(IPaddress ipa)
          Finds any routes with overlapping but more specific NLRI than the given IP address prefix.
 java.util.Iterator get_routes()
          Returns an iterator for enumerating all contained routes.
protected  java.lang.String hdr2str(java.lang.String ind, boolean usenhi)
          Composes into a string of the header/title text used when printing out a RIB element.
 boolean is_less_specific(IPaddress ipa)
          Determines if there are any routes with more specific NLRI than the given IP address prefix.
 java.util.ArrayList remove_all()
          Removes all route information in the RIB element and returns it as a list.
 RouteInfo remove(IPaddress ipa)
          Removes the route information corresponding to the given route destination.
 RouteInfo replace(RouteInfo info)
          Adds route information, replacing any pre-existing information with the same NLRI.
 int toBytes(byte[] bytes, int bindex, boolean usenhi)
          Converts this RIB element into a series of bytes and inserts them into a given byte array.
 java.lang.String toString()
          Returns this RIB element as a string.
 java.lang.String toString(java.lang.String ind, boolean usenhi)
          Returns this RIB element as a string, indenting each line with the given prefix string.
 
Methods inherited from class SSF.OS.BGP4.Util.RadixTree
add, find, get_ancestors, get_descendants, has_descendants, oldest_ancestor, print, prune, remove, replace, root, youngest_ancestor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bgp

protected BGPSession bgp
A reference to the local BGP protocol session.


rtes

protected java.util.HashMap rtes
A table mapping NLRI to routes. It adds no more functionality than the radix tree already had, but can save time during look-ups.


version

protected int version
The version number of the table. Inspired by Cisco table version numbering.

Method Detail

find

public RouteInfo find(IPaddress ipa)
Attempts to find information for a given destination.

Parameters:
ipa - The destination IP address prefix to search for info about.
Returns:
the route information if the prefix is found, null if not

add

public RouteInfo add(RouteInfo info)
Adds route information. If route information with the same NLRI already exists, then the add fails and the pre-existing information is returned.

Parameters:
info - The route information to add.
Returns:
null if the add was successful, the pre-existing route information otherwise

replace

public RouteInfo replace(RouteInfo info)
Adds route information, replacing any pre-existing information with the same NLRI.

Parameters:
info - The route information to add.
Returns:
the pre-existing route information, or null if there was none

remove

public RouteInfo remove(IPaddress ipa)
Removes the route information corresponding to the given route destination.

Parameters:
ipa - The destination of the route information to remove.
Returns:
the removed route information

remove_all

public java.util.ArrayList remove_all()
Removes all route information in the RIB element and returns it as a list.

Returns:
a list of removed route information

get_all_routes

public java.util.ArrayList get_all_routes()
Constructs and returns a list of all route information in the RIB element.

Returns:
a list of all route information in the RIB element

get_less_specifics

public java.util.ArrayList get_less_specifics(IPaddress ipa)
Finds any routes with overlapping but less specific NLRI than the given IP address prefix.

Parameters:
ipa - An IP address prefix to find less specific NLRI than.
Returns:
a list of routes with overlapping but less specific NLRI

get_more_specifics

public java.util.ArrayList get_more_specifics(IPaddress ipa)
Finds any routes with overlapping but more specific NLRI than the given IP address prefix.

Parameters:
ipa - An IP address prefix to find more specific NLRI than.
Returns:
a list of routes with overlapping but more specific NLRI

is_less_specific

public boolean is_less_specific(IPaddress ipa)
Determines if there are any routes with more specific NLRI than the given IP address prefix.

Parameters:
ipa - An IP address prefix to find more specific NLRI than.
Returns:
true only if there is at least one route with more specific NLRI

get_dests

public java.util.Iterator get_dests()
Returns an iterator for enumerating the destinations (IP addresses) of all contained routes.

Returns:
an enumeration of the destinations (IP addresses) of all contained routes

get_routes

public java.util.Iterator get_routes()
Returns an iterator for enumerating all contained routes.

Returns:
an enumeration of all contained routes

approxBytes

public int approxBytes(boolean usenhi)
Determines the approximate number of bytes that would be required when converting this RIB element to a series of bytes with toBytes. It is more likely than not to be an overestimate. Using NHI addressing makes a difference, so it is included as a parameter.

Parameters:
usenhi - Whether or not to use NHI addressing.
Returns:
the approximate number of bytes that would result from conversion of this RIB element to a series of bytes with toBytes

toBytes

public int toBytes(byte[] bytes,
                   int bindex,
                   boolean usenhi)
Converts this RIB element into a series of bytes and inserts them into a given byte array.

Parameters:
bytes - A byte array in which to place the results.
bindex - The index into the given byte array at which to begin placing the results.
usenhi - Whether or not to use NHI addressing.
Returns:
the total number of bytes produced by the conversion

bytes2str

public static int bytes2str(java.lang.StringBuffer ribstr,
                            byte[] bytes,
                            int bindex,
                            java.lang.String ind,
                            boolean usenhi)
Converts a series of bytes into a string represention of a RIB element.

Parameters:
ribstr - A StringBuffer into which the results will be placed. It must be initialized to the empty string.
bytes - The byte array to convert to a RIB element.
bindex - The index into the given byte array from which to begin converting.
ind - The string with which to indent each line.
usenhi - Whether or not to use NHI addressing.
Returns:
the total number of bytes used in the conversion

hdr2str

protected java.lang.String hdr2str(java.lang.String ind,
                                   boolean usenhi)
Composes into a string of the header/title text used when printing out a RIB element.

Parameters:
ind - The string with which to indent each line.
usenhi - Whether or not NHI addressing is being used.
Returns:
RIBElement output header text as a string

toString

public java.lang.String toString(java.lang.String ind,
                                 boolean usenhi)
Returns this RIB element as a string, indenting each line with the given prefix string.

Parameters:
ind - The string with which to indent each line.
usenhi - Whether or not to use NHI addressing.
Returns:
this RIB element as a string

toString

public java.lang.String toString()
Returns this RIB element as a string.

Overrides:
toString in class java.lang.Object
Returns:
this RIB element as a string