Methods Summary |
---|
public java.lang.String | getAS()
return( as==null?"":as );
|
public java.lang.String | getASName()
return( asn==null?"":asn );
|
public java.net.InetAddress | getBGPEndAddress()
if ( bgp_prefix == null ){
return( null );
}
try{
return( getCIDREndAddress());
}catch( NetworkAdminException e ){
Debug.out(e);
return( null );
}
|
public java.lang.String | getBGPPrefix()
return( bgp_prefix==null?"":bgp_prefix );
|
public java.net.InetAddress | getBGPStartAddress()
if ( bgp_prefix == null ){
return( null );
}
try{
return( getCIDRStartAddress());
}catch( NetworkAdminException e ){
Debug.out(e);
return( null );
}
|
protected java.net.InetAddress | getCIDREndAddress()
int pos = bgp_prefix.indexOf('/");
try{
InetAddress start = InetAddress.getByName( bgp_prefix.substring(0,pos));
int cidr_mask = Integer.parseInt( bgp_prefix.substring( pos+1 ));
int rev_mask = 0;
for (int i=0;i<32-cidr_mask;i++){
rev_mask = ( rev_mask << 1 ) | 1;
}
byte[] bytes = start.getAddress();
bytes[0] |= (rev_mask>>24)&0xff;
bytes[1] |= (rev_mask>>16)&0xff;
bytes[2] |= (rev_mask>>8)&0xff;
bytes[3] |= (rev_mask)&0xff;
return( InetAddress.getByAddress( bytes ));
}catch( Throwable e ){
throw( new NetworkAdminException( "Parse failure for '" + bgp_prefix + "'", e ));
}
|
protected java.net.InetAddress | getCIDRStartAddress()
int pos = bgp_prefix.indexOf('/");
try{
return( InetAddress.getByName( bgp_prefix.substring(0,pos)));
}catch( Throwable e ){
throw( new NetworkAdminException( "Parse failure for '" + bgp_prefix + "'", e ));
}
|
public java.lang.String | getString()
return( "as=" + getAS() + ",asn=" + getASName() + ", bgp_prefx=" + getBGPPrefix() + "[" +getBGPStartAddress() + "-" + getBGPEndAddress() + "]" );
|
public boolean | matchesCIDR(java.net.InetAddress address)
if ( bgp_prefix == null || bgp_prefix.length() == 0 ){
return( false );
}
try{
InetAddress start = getCIDRStartAddress();
InetAddress end = getCIDREndAddress();
long l_start = PRHelpers.addressToLong( start );
long l_end = PRHelpers.addressToLong( end );
long test = PRHelpers.addressToLong( address );
return( test >= l_start && test <= l_end );
}catch( Throwable e ){
Debug.printStackTrace(e);
return( false );
}
|
public boolean | sameAs(com.aelitis.azureus.core.networkmanager.admin.NetworkAdminASN other)
return( getAS().equals( other.getAS()));
|
protected void | setASName(java.lang.String s)
asn = s;
|