summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp.go
diff options
context:
space:
mode:
Diffstat (limited to 'packet/bgp.go')
-rw-r--r--packet/bgp.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/packet/bgp.go b/packet/bgp.go
index 6369269e..9928ecce 100644
--- a/packet/bgp.go
+++ b/packet/bgp.go
@@ -1567,12 +1567,36 @@ func (p *PathAttributeCommunities) Serialize() ([]byte, error) {
}
func (p *PathAttributeCommunities) MarshalJSON() ([]byte, error) {
+ wellKnown := map[uint32]string{
+ 0xffff0000: "planned-shut",
+ 0xffff0001: "accept-own",
+ 0xffff0002: "ROUTE_FILTER_TRANSLATED_v4",
+ 0xffff0003: "ROUTE_FILTER_v4",
+ 0xffff0004: "ROUTE_FILTER_TRANSLATED_v6",
+ 0xffff0005: "ROUTE_FILTER_v6",
+ 0xffff0006: "LLGR_STALE",
+ 0xffff0007: "NO_LLGR",
+ 0xFFFFFF01: "NO_EXPORT",
+ 0xFFFFFF02: "NO_ADVERTISE",
+ 0xFFFFFF03: "NO_EXPORT_SUBCONFED",
+ 0xFFFFFF04: "NOPEER"}
+
+ l := make([]string, len(p.Value))
+ for i, v := range p.Value {
+ s, found := wellKnown[v]
+ if found {
+ l[i] = s
+ } else {
+ l[i] = fmt.Sprintf("%x:%x", (v&0xffff0000)>>16, v&0xffff)
+ }
+ }
+
return json.Marshal(struct {
Type string
- Value []uint32
+ Value []string
}{
Type: p.Type.String(),
- Value: p.Value,
+ Value: l,
})
}