|
xorp
|
A class for storing an AS number used by protocols such as BGP. More...
#include <asnum.hh>
Public Member Functions | |
| AsNum (const uint32_t value) | |
| Constructor. | |
| AsNum (const uint16_t value) | |
| AsNum (int value) | |
| AsNum (const uint8_t *d) | |
| construct from a 2-byte buffer in memory | |
| AsNum (const uint8_t *d, bool fourbyte) | |
| construct from a 2-byte buffer in memory or a 4 byte buffer (in net byte order). | |
| AsNum (const string &as_str) throw (InvalidString) | |
| 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 () const |
| Get the non-extended AS number value. | |
| uint32_t | as4 () const |
| Get the extended AS number value. | |
| void | copy_out (uint8_t *d) const |
| copy the 16-bit value into a 2-byte memory buffer | |
| void | copy_out4 (uint8_t *d) const |
| copy the 32-bit value into a 4-byte network byte order memory buffer | |
| bool | extended () const |
| Test if this is an extended AS number. | |
| bool | operator== (const AsNum &x) const |
| Equality Operator. | |
| bool | operator< (const AsNum &x) const |
| Less-Than Operator. | |
| string | str () const |
| Convert this AS number from binary form to presentation format. | |
| string | short_str () const |
| string | fourbyte_str () const |
Static Public Attributes | |
| static const uint16_t | AS_INVALID = 0 |
| static const uint16_t | AS_TRAN = 23456 |
Private Attributes | |
| uint32_t | _as |
A class for storing an AS number used by protocols such as BGP.
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.
| AsNum::AsNum | ( | const uint32_t | value | ) | [inline, explicit] |
Constructor.
| value | the value to assign to this AS number. |
| AsNum::AsNum | ( | const uint8_t * | d, |
| bool | fourbyte | ||
| ) | [inline, explicit] |
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.
| uint16_t AsNum::as | ( | ) | const [inline] |
| uint32_t AsNum::as4 | ( | ) | const [inline] |
| bool AsNum::extended | ( | ) | const [inline] |
Test if this is an extended AS number.
| bool AsNum::operator< | ( | const AsNum & | x | ) | const [inline] |
| bool AsNum::operator== | ( | const AsNum & | x | ) | const [inline] |
| string AsNum::str | ( | ) | const [inline] |