|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--SSF.Net.Util.cidrBlock
Tree of CIDR blocks, constructed from a Net configuration using the optional "cidr" attributes provided for Net and link attributes. Each CIDR block in this tree represents one of three things: a Net, a link (ptp or LAN), or a placeholder block that doesn't correspond to any DML attribute, containing multiple link sub-blocks.
The block tree does the bookkeeping to maintain three distinct address maps. The NHI map addresses each network, host, and interface as N1:N2:N3:{...}Nn:H(I). The CIDR map addresses each network and link by its CIDR string, L1/L2/L3../Ln. The IP map addresses each network and link by the IP prefix associated with its CIDR block, and each interface of each host by an IP address offset from the prefix assigned to the link in which it appears as an attached interface.
To construct the three maps together, it suffices to construct a single CIDR block, passing the root network's dmlConfig and an IP prefix within which addresses are to be assigned. The code will make one pass over the DML to create the CIDR block tree and NHI map, another to compute the required address blocksizes for the IP map, and a third to assign IP prefixes and addresses.
The cidrBlock tree then serves as a translation table for all three maps, using utility functions {nhi,ip,cidr}_to_{nhi_ip_cidr}, each of which takes a String as an argument and returns another String.
If "cidr" attributes are partially or totally missing, the code will attempt to automatically supply numbers starting from CIDR_BASE. This is not foolproof, because of the amount of checking that would be involved (for example, the need for an additional pass to create a "reserved CIDR block map"). It's better to either uniformly supply CIDR addresses, or uniformly omit them.
| Nested Class Summary | |
(package private) class |
cidrBlock.blockList
|
| Field Summary | |
protected cidrBlock |
ancestorBlock
CIDR block where defined |
protected com.renesys.raceway.DML.Configuration |
blockConfig
Cached configuration of the Net or link for which this is the address block descriptor. |
static int |
CIDR_AUTOMATIC
|
static int |
CIDR_BASE
CIDR number from which we number default sub-blocks: e.g., 0 or 1 |
static int |
CIDR_IN_USE
Three-way flag for CIDR addressing. |
static int |
CIDR_INDETERMINATE
|
int |
cidr_number
CIDR block number for this address block descriptor. |
java.lang.String |
cidr_prefix
Global CIDR block address for this descriptor. |
static java.lang.String |
CIDR_SEPARATOR
Separator string for CIDR addresses |
static int |
CIDR_status
|
static int |
CIDR_WIDTH
Number of address bits that make up the entire address space |
protected java.util.Hashtable |
interfaces
Table of interfaces for hosts that appear in this subnet. |
static int |
IP_AUTOMATIC
|
static int |
IP_IN_USE
Three-way flag for IP addressing. |
static int |
IP_INDETERMINATE
|
int |
ip_prefix
IP address prefix assigned to this block. |
int |
ip_prefix_length
Number of prefix bits in the local block of reserved addresses. |
static int |
IP_status
|
protected int |
nextCidr
Next CIDR block number to be auto-assigned within this address block. |
int |
nhi_number
NHI Network Address final component |
java.lang.String |
nhi_prefix
NHI Network Address |
static java.lang.String |
NHI_SEPARATOR
Separator string for NHI addresses |
protected cidrBlock |
parentBlock
CIDR block one level up from this one. |
int |
required
Number of addresses required by this block, including the reserved net and broadcast addresses. |
static boolean |
strict
Set 'strict' to false to disable many CIDR/IP rules. |
protected java.util.Hashtable |
subblocks
Table of CIDR sub-blocks. |
protected java.util.Hashtable |
subnets
Table of sub-Nets. |
| Constructor Summary | |
private |
cidrBlock()
Default constructor for an uninitialized CIDR block. |
private |
cidrBlock(com.renesys.raceway.DML.Configuration cfg,
int use_netid,
cidrBlock ancestor)
Internal constructor for an internal CIDR block, given a DML configuration, a network ID number to use, and a reference to the cidrBlock representing the Net in which this Net or Link was defined. |
|
cidrBlock(com.renesys.raceway.DML.Configuration cfg,
java.lang.String use_IP)
Constructor for a top-level CIDR block, given a DML configuration describing one outermost Net, which may not have an ID or a CIDR block number. |
| Method Summary | |
private void |
addLinks(java.util.Enumeration linkset)
Create CIDR blocks for all links defined within a Net, and establish their CIDR addresses. |
private void |
addLoopbacks(java.util.Enumeration ifs)
Create CIDR blocks for virtual loopback links, defined implicitly by the existence of virtual interfaces within a Net, and establish their CIDR addresses. |
private void |
addSubnets(java.util.Enumeration netset)
Create CIDR blocks for all contained Nets, establish their CIDR addresses, and recurse to allow them to do the same. |
private void |
assignPrefix(int baseaddr)
Perform IP prefix assignment over the tree of block descriptors. |
java.util.Enumeration |
cidr_children()
Return the CIDR blocks in the CIDR level underneath this one. |
static java.lang.String |
cidr_concat(java.lang.String pre,
int post)
Concatenate the given CIDR addresses. |
cidrBlock |
cidr_parent()
Return the CIDR block which is one CIDR level up from this one. |
private void |
computePrefix()
Compute the IP prefix for each CIDR block in the tree. |
java.lang.String |
configCIDR(com.renesys.raceway.DML.Configuration cfg,
int offset)
Configure the CIDR adresses of the given link or subnet. |
java.lang.String |
configIP(com.renesys.raceway.DML.Configuration cfg,
int offset)
Configure the IP adresses of the given link or subnet. |
boolean |
contains(int addr)
Check if the address is inside the CIDR block. |
boolean |
contains(int addr,
int preflen)
Check if the address is inside the CIDR block. |
java.lang.String |
defined_in_net()
Return the NHI address of the network in which this CIDR block (Net or Link) was defined. |
void |
dump_by_cidr()
|
private void |
dump_by_cidr(boolean root)
|
void |
dump_by_subnet()
|
private void |
dump_by_subnet(boolean root)
|
private void |
format(java.lang.String s1,
int w1)
|
private void |
formatln(java.lang.String s1,
int w1)
|
java.lang.Object |
getUDA(java.lang.String key)
Retreive the value of a user-defined attribute from this CIDR block descriptor. |
java.lang.Object |
getUDA(java.lang.String key,
java.lang.String kval,
boolean flowdown,
boolean override,
java.lang.String concatString)
Retreive the value of a user-defined attribute from this CIDR block descriptor. |
private void |
insertBlock(java.lang.String cidrspec,
cidrBlock newblock)
Insert a CIDR block into the CIDR tree of which this CIDR block is the root. |
java.lang.String |
ip_to_nhi(int ipaddr,
int ipprefix)
IP address to NHI address. |
java.lang.String |
ip()
|
static void |
main(java.lang.String[] argv)
|
private void |
manual_IP_assignment()
Take the modeler at their word; assign IP addresses to interfaces according to the IP block addresses provided in the 'Net' and 'link' attributes |
private static void |
merge_hashtables(java.util.Hashtable dst,
java.util.Hashtable src)
Merge two Hashtables. |
com.renesys.raceway.DML.Configuration |
networkConfiguration()
|
java.util.Enumeration |
nhi_children()
Return the CIDR blocks corresponding to subnets within this one. |
static java.lang.String |
nhi_concat(java.lang.String pre,
int post)
Concatenate the given NHI addresses. |
static java.lang.String |
nhi_concat(java.lang.String pre,
java.lang.String post)
Concatenate the given NHI addresses. |
static java.lang.String |
nhi_host_interface(java.lang.String naddr)
Return 'host(interface)' part of an NHI address: "N1:N2:N3:H(I)" --> "H(I)" |
static java.lang.String |
nhi_host(java.lang.String naddr)
Return 'host' part of an NHI address: "N1:N2:N3:H(I)" --> "H" |
static java.lang.String |
nhi_interface(java.lang.String naddr)
Return 'interface' part of an NHI address: "N1:N2:N3:H(I)" --> "I" |
static java.lang.String |
nhi_net_host(java.lang.String naddr)
Return 'network:host' part of an NHI address: "N1:N2:N3:H(I)" --> "N1:N2:N3:H" |
static java.lang.String |
nhi_net(java.lang.String naddr)
Return 'network' part of an NHI address: "N1:N2:N3:H(I)" --> "N1:N2:N3" |
cidrBlock |
nhi_parent()
Return the CIDR block corresponding to the Net in which this block was defined: not necessarily the parent when multilevel CIDR strings are in use. |
java.lang.String |
nhi_to_cidr(java.lang.String nhi_address)
NHI address to CIDR address |
java.lang.String |
nhi_to_ip(java.lang.String nhi_address)
NHI address to IP address. |
cidrBlock |
nhi(java.lang.String naddr)
NHI address to CIDR block. |
int |
reserved()
Utility function to compute number of addresses reserved in block. |
private void |
setCIDR(cidrBlock newBlock,
java.lang.Integer blocknum)
Insert a CIDR block in the current block. |
java.lang.String |
toString()
|
void |
updateCidrBlock(com.renesys.raceway.DML.Configuration cfg)
Update the IP adresses of all interface Called after a modification in the tree. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int CIDR_BASE
public static final int CIDR_WIDTH
public static final java.lang.String NHI_SEPARATOR
public static final java.lang.String CIDR_SEPARATOR
public int cidr_number
public java.lang.String cidr_prefix
public int nhi_number
public java.lang.String nhi_prefix
public int ip_prefix
public int ip_prefix_length
public static boolean strict
public static final int CIDR_IN_USE
public static final int CIDR_AUTOMATIC
public static final int CIDR_INDETERMINATE
public static int CIDR_status
public static final int IP_IN_USE
public static final int IP_AUTOMATIC
public static final int IP_INDETERMINATE
public static int IP_status
protected com.renesys.raceway.DML.Configuration blockConfig
protected java.util.Hashtable subnets
protected java.util.Hashtable interfaces
protected cidrBlock ancestorBlock
protected cidrBlock parentBlock
protected java.util.Hashtable subblocks
protected int nextCidr
public int required
| Constructor Detail |
public cidrBlock(com.renesys.raceway.DML.Configuration cfg,
java.lang.String use_IP)
throws com.renesys.raceway.DML.configException
cfg - The Net configurationuse_IP - The IP adress to use for this Net.
com.renesys.raceway.DML.configException - if a DML configuration error occurs.
private cidrBlock(com.renesys.raceway.DML.Configuration cfg,
int use_netid,
cidrBlock ancestor)
throws com.renesys.raceway.DML.configException
cfg - The subNet configurationuse_netid - The id of this subnet.ancestor - The CIDR block that is at the top level.
com.renesys.raceway.DML.configException - if a DML configuration error occurs.private cidrBlock()
| Method Detail |
public java.lang.String ip()
public java.lang.String ip_to_nhi(int ipaddr,
int ipprefix)
ipaddr - The IP address to translateipprefix - The IP prefix
public cidrBlock nhi(java.lang.String naddr)
naddr - The NHI adress of a link or a subnet.
public java.lang.String nhi_to_cidr(java.lang.String nhi_address)
nhi_address - The NHI address to translate
public java.lang.String nhi_to_ip(java.lang.String nhi_address)
nhi_address - The NHI address to translate
public java.lang.String defined_in_net()
public static java.lang.String nhi_concat(java.lang.String pre,
java.lang.String post)
pre - The prefix of the NHI addresspost - The end of the NHI address
public static java.lang.String nhi_concat(java.lang.String pre,
int post)
pre - The prefix of the NHI addresspost - The end of the NHI address
public static java.lang.String cidr_concat(java.lang.String pre,
int post)
pre - The prefix of the CIDR addresspost - The end of the CIDR address
public static java.lang.String nhi_net(java.lang.String naddr)
naddr - The NHI address
public static java.lang.String nhi_net_host(java.lang.String naddr)
naddr - The NHI address
public static java.lang.String nhi_host_interface(java.lang.String naddr)
naddr - The NHI address
public static java.lang.String nhi_interface(java.lang.String naddr)
naddr - The NHI address
public static java.lang.String nhi_host(java.lang.String naddr)
naddr - The NHI address
public cidrBlock cidr_parent()
public cidrBlock nhi_parent()
public java.util.Enumeration cidr_children()
public java.util.Enumeration nhi_children()
public com.renesys.raceway.DML.Configuration networkConfiguration()
public final int reserved()
public boolean contains(int addr,
int preflen)
addr - The address to checkpreflen - The prefix length of the address
public boolean contains(int addr)
addr - The address to check
public java.lang.String toString()
toString in class java.lang.Object
private void addSubnets(java.util.Enumeration netset)
throws com.renesys.raceway.DML.configException
netset - The set of subnets.
com.renesys.raceway.DML.configException - if a DML configuration error occurs.
private void addLinks(java.util.Enumeration linkset)
throws com.renesys.raceway.DML.configException
linkset - The enumeration of links.
com.renesys.raceway.DML.configException - if a DML configuration error occurs.
private void addLoopbacks(java.util.Enumeration ifs)
throws com.renesys.raceway.DML.configException
ifs - The enumeration of virtual loopback links.
com.renesys.raceway.DML.configException - if a DML configuration error occurs.
private static void merge_hashtables(java.util.Hashtable dst,
java.util.Hashtable src)
dst - The first Hashtablesrc - The second Hashtable
private void setCIDR(cidrBlock newBlock,
java.lang.Integer blocknum)
newBlock - The CIDRBlock to insert.
private void insertBlock(java.lang.String cidrspec,
cidrBlock newblock)
throws com.renesys.raceway.DML.configException
cidrspec - The CIDR adress of the new block.
com.renesys.raceway.DML.configException - if a DML configuration error occurs.
private void manual_IP_assignment()
throws com.renesys.raceway.DML.configException
com.renesys.raceway.DML.configException - if a DML configuration error occurs.
private void computePrefix()
throws com.renesys.raceway.DML.configException
com.renesys.raceway.DML.configException
private void assignPrefix(int baseaddr)
throws com.renesys.raceway.DML.configException
baseaddr - The base adress for IP adresses.
com.renesys.raceway.DML.configException - if a DML configuration error occurs.
private void formatln(java.lang.String s1,
int w1)
private void format(java.lang.String s1,
int w1)
public void dump_by_subnet()
private void dump_by_subnet(boolean root)
public void dump_by_cidr()
private void dump_by_cidr(boolean root)
public java.lang.String configIP(com.renesys.raceway.DML.Configuration cfg,
int offset)
throws com.renesys.raceway.DML.configException
cfg - The configuration of the link or the subnetoffset - The offset for IP adresses
com.renesys.raceway.DML.configException - if a DML configuration error occurs.
public java.lang.String configCIDR(com.renesys.raceway.DML.Configuration cfg,
int offset)
throws com.renesys.raceway.DML.configException
cfg - The configuration of the link or the subnetoffset - The offset for CIDR adresses
com.renesys.raceway.DML.configException - if a DML configuration error occurs.
public java.lang.Object getUDA(java.lang.String key)
throws com.renesys.raceway.DML.configException
com.renesys.raceway.DML.configException
public java.lang.Object getUDA(java.lang.String key,
java.lang.String kval,
boolean flowdown,
boolean override,
java.lang.String concatString)
throws com.renesys.raceway.DML.configException
key - Attribute name to search for.kval - Attribute value that must appear (null if any value okay)flowdown - If true, allow parent network values to flow down as defaults
for subnets that fail to specify the attribute.override - If true, allow specified values to override any default value
that flows down from a parent network; otherwise raise an
error if both parent and child specify the attribute.concatString - if non-null, return the parent value, plus the given
concatenation string, plus the local value.
com.renesys.raceway.DML.configExceptionpublic static void main(java.lang.String[] argv)
public void updateCidrBlock(com.renesys.raceway.DML.Configuration cfg)
throws com.renesys.raceway.DML.configException
cfg - The configuration that contains the links.
com.renesys.raceway.DML.configException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||