class AsNum

A class for storing an AS number used by protocols such as BGP. More...

 
LOGO
 Annotated List  Files  Globals  Hierarchy  Index  Top

Public Methods

Public Members


Detailed Description

This class can be used to store an AS number that can be either 16 or 32 bits. Originally, the AS numbers were defined as 16-bit unsigned numbers. Later the "extended" AS numbers were introduced, which are unsigned 32-bit numbers. Conventional terminology refers to the 32-bit version as 4-byte AS numbers rather than 32-bit AS numbers, so we'll try and stick with that where it makes sense.

2-byte numbers are expanded to 32-bits by extending them with 0's in front. 4-byte numbers are represented in a 2-byte AS path, by a special 16-bit value, AS_TRAN, which will be allocated by IANA. Together with any AsPath containing AS_TRAN, we will always see a AS4_PATH attribute which contains the full 32-bit representation of the path. So there is no loss of information.

IANA refers to NEW_AS_PATH, but the latest internet drafts refer to AS4_PATH. They're the same thing, but I the latter is preferred so we'll use that.

The internal representation of an AsNum is 32-bit in host order.

The canonical string form of a 4-byte AS number is <high>.<low>, so decimal 65536 ends up being printed as "1.0".

An AsNum must always be initialized, so the default constructor is never called.

static const uint16_t AS_INVALID

AS_INVALID

static const uint16_t AS_TRAN

AS_TRAN

explicit  AsNum (const uint32_t value)

AsNum

Constructor.

Parameters:

valuethe value to assign to this AS number.
explicit  AsNum (const uint16_t value)

AsNum

explicit  AsNum (int value)

AsNum

explicit  AsNum (const uint8_t *d)

AsNum

construct from a 2-byte buffer in memory

explicit  AsNum (const uint8_t *d, bool fourbyte)

AsNum

construct from a 2-byte buffer in memory or a 4 byte buffer (in net byte order).

The 4byte parameter is mostly to distinguish this from the 2-byte constructor above.

explicit  AsNum (const string& as_str)
throw(InvalidString)

AsNum

construct from a string, either as a decimal number in the range 1-65535, or as two decimal numbers x.y, where x and y are in the range 0-65535

uint16_t  as ()

as

[const]

Get the non-extended AS number value.

Returns: the non-extended AS number value.

uint32_t  as4 ()

as4

[const]

Get the extended AS number value.

Returns: the extended AS number value.

void  copy_out (uint8_t *d)

copy_out

[const]

copy the 16-bit value into a 2-byte memory buffer

void  copy_out4 (uint8_t *d)

copy_out4

[const]

copy the 32-bit value into a 4-byte network byte order memory buffer

bool  extended ()

extended

[const]

Test if this is an extended AS number.

Returns: true if this is an extended AS number.

bool  operator== (const AsNum& x)

operator==

[const]

Equality Operator

Parameters:

otherthe right-hand operand to compare against.

Returns: true if the left-hand operand is numerically same as the right-hand operand.

bool  operator< (const AsNum& x)

operator<

[const]

Less-Than Operator

Returns: true if the left-hand operand is numerically smaller than the right-hand operand.

string  str ()

str

[const]

Convert this AS number from binary form to presentation format.

Returns: C++ string with the human-readable ASCII representation of the AS number.

string  short_str ()

short_str

[const]

string  fourbyte_str ()

fourbyte_str

[const]


Generated by: bms on anglepoise.lon.incunabulum.net on Wed Jul 23 10:05:24 2008, using kdoc 2.0a54+XORP.