Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package packet
import "fmt"
type ASPath []ASPathSegment
type ASPathSegment struct {
Type uint8
Count uint8
ASNs []uint32
}
func (pa ASPath) String() (ret string) {
for _, p := range pa {
if p.Type == ASSet {
ret += " ("
}
n := len(p.ASNs)
for i, asn := range p.ASNs {
if i < n-1 {
ret += fmt.Sprintf("%d ", asn)
continue
}
ret += fmt.Sprintf("%d", asn)
}
if p.Type == ASSet {
ret += ")"
}
}
return
}
func (pa ASPath) Length() (ret uint16) {
for _, p := range pa {
if p.Type == ASSet {
ret++
continue
}
ret += uint16(len(p.ASNs))
}
return
}