fn parse_as_path(fmt: &mut fmt::Formatter, buffer: &Vec<u8>) {
    let mut i = 0;
    while i < buffer.len() {
        match buffer[i] {
            1 => {
                write!(fmt, "AS_SET");
                i += 1;
                let asn_count = buffer[i];
                write!(fmt, "[");
                i += 1;
                let mut j = 0;
                while j < asn_count {
                    if j != 0 {
                        write!(fmt, " ");
                    }
                    write!(
                        fmt,
                        "{:02x}{:02x}{:02x}{:02x}",
                        buffer[i],
                        buffer[i + 1],
                        buffer[i + 2],
                        buffer[i + 3]
                    );
                    j += 1;
                    i += 4;
                }
                write!(fmt, "]");
            }
            2 => {
                write!(fmt, "AS_SEQ:");
                i += 1;
                let asn_count = buffer[i];
                i += 1;
                let mut j = 0;
                let mut aspath = String::with_capacity((asn_count * 4 + (asn_count - 1)) as usize);
                while j < asn_count {
                    if j != 0 {
                        write!(fmt, " ");
                    }
                    write!(
                        fmt,
                        "{:02x}{:02x}{:02x}{:02x}",
                        buffer[i],
                        buffer[i + 1],
                        buffer[i + 2],
                        buffer[i + 3]
                    );
                    j += 1;
                    i += 4;
                }
            }
            _ => {
                write!(fmt, "AS_UNKNOWN");
                i += 1;
            }
        }
    }
}
// Each AS path segment is
// represented by a triple <path segment type, path segment
// length, path segment value>.
//
// The path segment type is a 1-octet length field with the
// following values defined:
//
//    Value      Segment Type
//
//    1         AS_SET: unordered set of ASes a route in the
//                 UPDATE message has traversed
//
//    2         AS_SEQUENCE: ordered set of ASes a route in
//                 the UPDATE message has traversed
//
// The path segment length is a 1-octet length field,
// containing the number of ASes (not the number of octets) in
// the path segment value field.
//
// The path segment value field contains one or more AS
// numbers, each encoded as a 2-octet length field.
// Usage of this attribute is defined in 5.1.2.
//
//
//50 BGP_PATH_ATTR_ASPATH [2, 5, 0, 0, 164, 125, 0, 0, 163, 237, 0, 0, 163, 149, 0, 0, 81, 35, 0, 0, 13, 28]
// == 2, (AS Sequence)
//    5, (AS hops)
//    0, 0, 164, 125,
//    0, 0, 163, 237,
//    0, 0, 163, 149,
//    0, 0, 81, 35,
//    0, 0, 13, 28
Each AS path segment is
represented by a triple .

The path segment type is a 1-octet length field with the
following values defined.

Value      Segment Type

1         AS_SET: unordered set of ASes a route in the
UPDATE message has traversed

2         AS_SEQUENCE: ordered set of ASes a route in
the UPDATE message has traversed

The path segment length is a 1-octet length field,
containing the number of ASes (not the number of octets) in
the path segment value field.

The path segment value field contains one or more AS
numbers, each encoded as a 2-octet length field.
Usage of this attribute is defined in 5.1.2.


Each AS path segment is represented by a triple . The path segment type is a 1 - octet length field with the following values defined . Value Segment Type 1 AS_SET : unordered set of ASes a route in the UPDATE message has traversed 2 AS_SEQUENCE : ordered set of ASes a route in the UPDATE message has traversed The path segment length is a 1 - octet length field containing the number of ASes ( not the number of octets ) in the path segment value field . The path segment value field contains one or more AS numbers each encoded as a 2 - octet length field . Usage of this attribute is defined in 5 . 1 . 2 .
fn parse_as_path(fmt: &mut fmt::Formatter, buffer: &Vec<u8>) {
    let mut i = 0;
    while i < buffer.len() {
        match buffer[i] {
            1 => {
                write!(fmt, "AS_SET");
                i += 1;
                let asn_count = buffer[i];
                write!(fmt, "[");
                i += 1;
                let mut j = 0;
                while j < asn_count {
                    if j != 0 {
                        write!(fmt, " ");
                    }
                    write!(
                        fmt,
                        "{:02x}{:02x}{:02x}{:02x}",
                        buffer[i],
                        buffer[i + 1],
                        buffer[i + 2],
                        buffer[i + 3]
                    );
                    j += 1;
                    i += 4;
                }
                write!(fmt, "]");
            }
            2 => {
                write!(fmt, "AS_SEQ:");
                i += 1;
                let asn_count = buffer[i];
                i += 1;
                let mut j = 0;
                let mut aspath = String::with_capacity((asn_count * 4 + (asn_count - 1)) as usize);
                while j < asn_count {
                    if j != 0 {
                        write!(fmt, " ");
                    }
                    write!(
                        fmt,
                        "{:02x}{:02x}{:02x}{:02x}",
                        buffer[i],
                        buffer[i + 1],
                        buffer[i + 2],
                        buffer[i + 3]
                    );
                    j += 1;
                    i += 4;
                }
            }
            _ => {
                write!(fmt, "AS_UNKNOWN");
                i += 1;
            }
        }
    }
}
fn parse_as_path ( fmt : & mut fmt :: Formatter , buffer : & Vec < u8 > ) { let mut i = 0 ; while i < buffer . len ( ) { match buffer [ i ] { 1 => { write ! ( fmt " " ) ; i += 1 ; let asn_count = buffer [ i ] ; write ! ( fmt " " ) ; i += 1 ; let mut j = 0 ; while j < asn_count { if j != 0 { write ! ( fmt " " ) ; } write ! ( fmt " " buffer [ i ] buffer [ i 1 ] buffer [ i 2 ] buffer [ i 3 ] ) ; j += 1 ; i += 4 ; } write ! ( fmt " " ) ; } 2 => { write ! ( fmt " " ) ; i += 1 ; let asn_count = buffer [ i ] ; i += 1 ; let mut j = 0 ; let mut aspath = String :: with_capacity ( ( asn_count * 4 + ( asn_count - 1 ) ) as usize ) ; while j < asn_count { if j != 0 { write ! ( fmt " " ) ; } write ! ( fmt " " buffer [ i ] buffer [ i 1 ] buffer [ i 2 ] buffer [ i 3 ] ) ; j += 1 ; i += 4 ; } } _ => { write ! ( fmt " " ) ; i += 1 ; } } } }
Each AS path segment is
represented by a triple <path segment type, path segment
length, path segment value>.
Each AS path segment is represented by a triple <path segment type path segment length path segment value > .
fmt
&mut fmt::Formatter
buffer
&Vec<u8>