xorp

ASSegment Class Reference

Parent class for ASPath elements, which can be either ASSet or ASSequence. More...

#include <aspath.hh>

Inheritance diagram for ASSegment:
AS4Segment

List of all members.

Public Types

typedef list< AsNumASLIST
typedef ASLIST::iterator iterator
typedef ASLIST::const_iterator const_iterator
typedef
ASLIST::const_reverse_iterator 
const_reverse_iterator

Public Member Functions

 ASSegment (ASPathSegType t=AS_NONE)
 Constructor of an empty ASSegment.
 ASSegment (const uint8_t *d) throw (CorruptMessage)
 constructor from external representation will just decode the chunk of data received, and convert to internal representation.
 ASSegment (const ASSegment &a)
 Copy constructor.
 ~ASSegment ()
 The destructor has nothing to do, the underlying container will take care of the thing.
void clear ()
 reset whatever is currently contained in the object.
size_t path_length () const
size_t as_size () const
void add_as (const AsNum &n)
 Add AsNum at the end of the segment (order is irrelevant for AS_SET but important for AS_SEQUENCE) This is used when initializing from a string.
void prepend_as (const AsNum &n)
 Add AsNum at the beginning of the segment (order is irrelevant for AS_SET but important for AS_SEQUENCE).
bool contains (const AsNum &as_num) const
 Check if a given AsNum is contained in the segment.
const AsNumfirst_asnum () const
const AsNumas_num (int n) const
 find the n'th AS number in the segment
void decode (const uint8_t *d) throw (CorruptMessage)
 Convert the external representation into the internal one.
const uint8_t * encode (size_t &len, uint8_t *buf) const
 Convert from internal to external representation.
size_t wire_size () const
string str () const
 prints ASSegments as
string short_str () const
 prints ASSegments as
bool operator== (const ASSegment &him) const
 compares internal representations for equality.
bool operator< (const ASSegment &him) const
 Compares internal representations for <.
ASPathSegType type () const
void set_type (ASPathSegType t)
size_t encode_for_mib (uint8_t *buf, size_t buf_size) const
bool two_byte_compatible () const
 returns true if the AS segment does not lose information when represented entirely as two-byte AS numbers

Protected Attributes

ASPathSegType _type
ASLIST _aslist

Detailed Description

Parent class for ASPath elements, which can be either ASSet or ASSequence.


Constructor & Destructor Documentation

ASSegment::ASSegment ( const uint8_t *  d) throw (CorruptMessage) [inline]

constructor from external representation will just decode the chunk of data received, and convert to internal representation.

In fact, the external representation is quite simple and effective.

_type is d[0], l is d[1], entries follow.


Member Function Documentation

void ASSegment::decode ( const uint8_t *  d) throw (CorruptMessage)

Convert the external representation into the internal one.

_type is d[0], _entries is d[1], entries follow.

Reimplemented in AS4Segment.

const uint8_t * ASSegment::encode ( size_t &  len,
uint8_t *  buf 
) const

Convert from internal to external representation.

If we do not pass a buffer (buf = 0), then the routine will allocate a new one; otherwise, len indicates the size of the input buffer, which must be large enough to store the encoding.

Returns:
the pointer to the buffer, len is the actual size.

Reimplemented in AS4Segment.

size_t ASSegment::path_length ( ) const [inline]
Returns:
the path length, which is 1 for an AS_SET, and the length of the sequence for an AS_SEQUENCE
void ASSegment::prepend_as ( const AsNum n) [inline]

Add AsNum at the beginning of the segment (order is irrelevant for AS_SET but important for AS_SEQUENCE).

This is used e.g. when a node is adding its AsNum to the sequence.

string ASSegment::short_str ( ) const

prints ASSegments as

Returns:
compact string representation of the segment

AS_SEQUENCE: comma-separated-asn-list AS_SET: {comma-separated-asn-list} AS_CONFED_SEQUENCE: (comma-separated-asn-list) AS_CONFED_SET: <comma-separated-asn-list>

string ASSegment::str ( ) const

prints ASSegments as

Returns:
fancy string representation of the segment

AS_SEQUENCE: [comma-separated-asn-list] AS_SET: {comma-separated-asn-list} AS_CONFED_SEQUENCE: (comma-separated-asn-list) AS_CONFED_SET: <comma-separated-asn-list>

size_t ASSegment::wire_size ( ) const [inline]
Returns:
the size of the list on the wire.

Reimplemented in AS4Segment.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations