|
1 | 1 | package arango
|
2 | 2 |
|
| 3 | +import ( |
| 4 | + "encoding/json" |
| 5 | + |
| 6 | + "github.com/sbezverk/gobmp/pkg/message" |
| 7 | +) |
| 8 | + |
3 | 9 | // Information on Collections is taken from here:
|
4 |
| -// https://github.com/sbezverk/gobmp/blob/master/pkg/message/types.go |
5 |
| -type LSNode struct { |
6 |
| - ID string `json:"_id,omitempty"` |
7 |
| - Key string `json:"_key,omitempty"` |
8 |
| - RouterHash string `json:"router_hash,omitempty"` |
9 |
| - DomainID int64 `json:"domain_id,omitempty"` |
10 |
| - RouterIP string `json:"router_ip,omitempty"` |
11 |
| - PeerHash string `json:"peer_hash,omitempty"` |
12 |
| - PeerIP string `json:"peer_ip,omitempty"` |
13 |
| - PeerASN int32 `json:"peer_asn,omitempty"` |
14 |
| - Timestamp string `json:"timestamp,omitempty"` |
15 |
| - IGPRouterID string `json:"igp_router_id,omitempty"` |
16 |
| - ASN uint32 `json:"asn,omitempty"` |
17 |
| - MTID []*MultiTopologyIdentifier `json:"mt_id_tlv,omitempty"` |
18 |
| - AreaID string `json:"area_id,omitempty"` |
19 |
| - Protocol string `json:"protocol,omitempty"` |
20 |
| - ProtocolID uint8 `json:"protocol_id,omitempty"` |
21 |
| - Name string `json:"name,omitempty"` |
22 |
| - IsPrepolicy bool `json:"is_prepolicy,omitempty"` |
23 |
| - IsAdjRIBIn bool `json:"is_adj_rib_in,omitempty"` |
| 10 | +// // https://github.com/sbezverk/gobmp/blob/master/pkg/message/types.go |
| 11 | +type LsNode struct { |
| 12 | + message.LSNode |
| 13 | +} |
| 14 | + |
| 15 | +func (node LsNode) MarshalBinary() ([]byte, error) { |
| 16 | + return json.Marshal(node) |
| 17 | +} |
| 18 | + |
| 19 | +type LsLink struct { |
| 20 | + message.LSLink |
| 21 | + UnidirPacketLossPercentage float64 `json:"undir_packet_loss_percentage,omitempty"` |
| 22 | + NormalizedUnidirLinkDelay float64 `json:"normalized_unidir_link_delay,omitempty"` |
| 23 | + NormalizedUnidirDelayVariation float64 `json:"normalized_unidir_delay_variation,omitempty"` |
| 24 | + NormalizedUnidirPacketLoss float64 `json:"normalized_unidir_packet_loss,omitempty"` |
| 25 | +} |
| 26 | + |
| 27 | +func (link LsLink) MarshalBinary() ([]byte, error) { |
| 28 | + return json.Marshal(link) |
| 29 | +} |
| 30 | + |
| 31 | +type LsPrefix struct { |
| 32 | + message.LSPrefix |
24 | 33 | }
|
25 | 34 |
|
26 |
| -type LSLink struct { |
27 |
| - ID string `json:"_id,omitempty"` |
28 |
| - Key string `json:"_key,omitempty"` |
29 |
| - RouterHash string `json:"router_hash,omitempty"` |
30 |
| - RouterIP string `json:"router_ip,omitempty"` |
31 |
| - DomainID int64 `json:"domain_id,omitempty"` |
32 |
| - PeerHash string `json:"peer_hash,omitempty"` |
33 |
| - PeerIP string `json:"peer_ip,omitempty"` |
34 |
| - PeerASN int32 `json:"peer_asn,omitempty"` |
35 |
| - Timestamp string `json:"timestamp,omitempty"` |
36 |
| - IGPRouterID string `json:"igp_router_id,omitempty"` |
37 |
| - Protocol string `json:"protocol,omitempty"` |
38 |
| - AreaID string `json:"area_id,omitempty"` |
39 |
| - Nexthop string `json:"nexthop,omitempty"` |
40 |
| - MTID *MultiTopologyIdentifier `json:"mt_id_tlv,omitempty"` |
41 |
| - LocalLinkIP string `json:"local_link_ip,omitempty"` |
42 |
| - RemoteLinkIP string `json:"remote_link_ip,omitempty"` |
43 |
| - IGPMetric uint32 `json:"igp_metric,omitempty"` |
44 |
| - RemoteNodeHash string `json:"remote_node_hash,omitempty"` |
45 |
| - LocalNodeHash string `json:"local_node_hash,omitempty"` |
46 |
| - RemoteIGPRouterID string `json:"remote_igp_router_id,omitempty"` |
47 |
| - UnidirLinkDelay uint32 `json:"unidir_link_delay,omitempty"` |
48 |
| - UnidirLinkDelayMinMax []uint32 `json:"unidir_link_delay_min_max,omitempty"` |
49 |
| - MaxLinkBwKbps uint64 `json:"max_link_bw_kbps,omitempty"` |
50 |
| - UnidirDelayVariation uint32 `json:"unidir_delay_variation,omitempty"` |
51 |
| - UnidirPacketLoss float32 `json:"unidir_packet_loss,omitempty"` |
52 |
| - UnidirResidualBw uint32 `json:"unidir_residual_bw,omitempty"` |
53 |
| - UnidirAvailableBw uint32 `json:"unidir_available_bw,omitempty"` |
54 |
| - UnidirBwUtilization uint32 `json:"unidir_bw_utilization,omitempty"` |
55 |
| - NormalizedUnidirLinkDelay float64 `json:"normalized_unidir_link_delay,omitempty"` |
56 |
| - NormalizedUnidirDelayVariation float64 `json:"normalized_unidir_delay_variation,omitempty"` |
57 |
| - NormalizedUnidirPacketLoss float64 `json:"normalized_unidir_packet_loss,omitempty"` |
| 35 | +func (prefix LsPrefix) MarshalBinary() ([]byte, error) { |
| 36 | + return json.Marshal(prefix) |
58 | 37 | }
|
59 | 38 |
|
60 |
| -type LSPrefix struct { |
61 |
| - Key string `json:"_key,omitempty"` |
62 |
| - ID string `json:"_id,omitempty"` |
63 |
| - RouterHash string `json:"router_hash,omitempty"` |
64 |
| - RouterIP string `json:"router_ip,omitempty"` |
65 |
| - DomainID int64 `json:"domain_id,omitempty"` |
66 |
| - PeerHash string `json:"peer_hash,omitempty"` |
67 |
| - PeerIP string `json:"peer_ip,omitempty"` |
68 |
| - PeerASN int32 `json:"peer_asn,omitempty"` |
69 |
| - Timestamp string `json:"timestamp,omitempty"` |
70 |
| - IGPRouterID string `json:"igp_router_id,omitempty"` |
71 |
| - Protocol string `json:"protocol,omitempty"` |
72 |
| - AreaID string `json:"area_id,omitempty"` |
73 |
| - Nexthop string `json:"nexthop,omitempty"` |
74 |
| - LocalNodeHash string `json:"local_node_hash,omitempty"` |
75 |
| - MTID *MultiTopologyIdentifier `json:"mt_id_tlv,omitempty"` |
76 |
| - Prefix string `json:"prefix,omitempty"` |
77 |
| - PrefixLen int32 `json:"prefix_len,omitempty"` |
78 |
| - PrefixMetric uint32 `json:"prefix_metric,omitempty"` |
79 |
| - IsPrepolicy bool `json:"is_prepolicy,omitempty"` |
80 |
| - IsAdjRIBIn bool `json:"is_adj_rib_in,omitempty"` |
| 39 | +type LsSrv6Sid struct { |
| 40 | + message.LSSRv6SID |
81 | 41 | }
|
82 | 42 |
|
83 |
| -type LSSRv6SID struct { |
84 |
| - Key string `json:"_key,omitempty"` |
85 |
| - ID string `json:"_id,omitempty"` |
86 |
| - RouterHash string `json:"router_hash,omitempty"` |
87 |
| - RouterIP string `json:"router_ip,omitempty"` |
88 |
| - DomainID int64 `json:"domain_id,omitempty"` |
89 |
| - PeerHash string `json:"peer_hash,omitempty"` |
90 |
| - PeerIP string `json:"peer_ip,omitempty"` |
91 |
| - PeerASN int32 `json:"peer_asn,omitempty"` |
92 |
| - Timestamp string `json:"timestamp,omitempty"` |
93 |
| - IGPRouterID string `json:"igp_router_id,omitempty"` |
94 |
| - LocalNodeASN uint32 `json:"local_node_asn,omitempty"` |
95 |
| - Protocol string `json:"protocol,omitempty"` |
96 |
| - Nexthop string `json:"nexthop,omitempty"` |
97 |
| - LocalNodeHash string `json:"local_node_hash,omitempty"` |
98 |
| - MTID *MultiTopologyIdentifier `json:"mt_id_tlv,omitempty"` |
99 |
| - IGPFlags uint8 `json:"igp_flags,omitempty"` |
100 |
| - IsPrepolicy bool `json:"is_prepolicy,omitempty"` |
101 |
| - IsAdjRIBIn bool `json:"is_adj_rib_in,omitempty"` |
102 |
| - SRv6SID string `json:"srv6_sid,omitempty"` |
| 43 | +func (srv6sid LsSrv6Sid) MarshalBinary() ([]byte, error) { |
| 44 | + return json.Marshal(srv6sid) |
103 | 45 | }
|
104 | 46 |
|
105 |
| -type LSNode_Edge struct { |
| 47 | +type LsNodeEdge struct { |
106 | 48 | Key string `json:"_key,omitempty"`
|
107 | 49 | ID string `json:"_id,omitempty"`
|
108 | 50 | From string `json:"_from,omitempty"`
|
109 | 51 | To string `json:"_to,omitempty"`
|
110 | 52 | Link string `json:"link,omitempty"`
|
111 | 53 | }
|
112 | 54 |
|
113 |
| -type LSNode_Coordinates struct { |
| 55 | +func (edge LsNodeEdge) MarshalBinary() ([]byte, error) { |
| 56 | + return json.Marshal(edge) |
| 57 | +} |
| 58 | + |
| 59 | +type LsNodeCoordinates struct { |
114 | 60 | Key string `json:"_key,omitempty"`
|
115 | 61 | ID string `json:"_id,omitempty"`
|
116 | 62 | LsNodeKey string `json:"ls_node_key,omitempty"`
|
117 | 63 | Latitude float64 `json:"latitude,omitempty"`
|
118 | 64 | Longitude float64 `json:"longitude,omitempty"`
|
119 | 65 | }
|
| 66 | + |
| 67 | +func (coordinates LsNodeCoordinates) MarshalBinary() ([]byte, error) { |
| 68 | + return json.Marshal(coordinates) |
| 69 | +} |
0 commit comments