File: | home/sharpd/frr3/bgpd/bgp_snmp_bgp4v2.c |
Warning: | line 551, column 3 Value stored to 'safi' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | /* BGP4V2-MIB SNMP support |
3 | * |
4 | * Copyright (C) 2022 Donatas Abraitis <donatas@opensourcerouting.org> |
5 | */ |
6 | |
7 | #include <zebra.h> |
8 | |
9 | #include <net-snmp/net-snmp-config.h> |
10 | #include <net-snmp/net-snmp-includes.h> |
11 | |
12 | #include "if.h" |
13 | #include "log.h" |
14 | #include "prefix.h" |
15 | #include "command.h" |
16 | #include "frrevent.h" |
17 | #include "smux.h" |
18 | #include "filter.h" |
19 | #include "hook.h" |
20 | #include "libfrr.h" |
21 | |
22 | #include "bgpd/bgpd.h" |
23 | #include "bgpd/bgp_table.h" |
24 | #include "bgpd/bgp_aspath.h" |
25 | #include "bgpd/bgp_attr.h" |
26 | #include "bgpd/bgp_debug.h" |
27 | #include "bgpd/bgp_route.h" |
28 | #include "bgpd/bgp_fsm.h" |
29 | #include "bgpd/bgp_snmp.h" |
30 | #include "bgpd/bgp_snmp_bgp4v2.h" |
31 | |
32 | SNMP_LOCAL_VARIABLESstatic long snmp_int_val __attribute__((unused)); static struct in_addr snmp_in_addr_val __attribute__((unused)); static uint8_t snmp_octet_val __attribute__((unused)); static char snmp_string_val [255] __attribute__((unused)); |
33 | |
34 | static oid bgpv2_oid[] = {BGP4V2MIB1, 3, 6, 1, 3, 5, 1}; |
35 | static oid bgpv2_trap_oid[] = { BGP4V2MIB1, 3, 6, 1, 3, 5, 1, 0 }; |
36 | static struct in_addr bgp_empty_addr = {}; |
37 | |
38 | static struct peer *peer_lookup_all_vrf(struct ipaddr *addr) |
39 | { |
40 | struct bgp *bgp; |
41 | struct peer *peer; |
42 | struct listnode *node; |
43 | struct listnode *bgpnode; |
44 | |
45 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, bgpnode, bgp)(bgpnode) = ((bm->bgp) ? ((bm->bgp)->head) : ((void* )0)), ((bgp) = ((void*)0)); (bgpnode) != ((void*)0) && ((bgp) = ((({ static const struct xref_assert _xref __attribute__ ( (used)) = { .xref = { (((void*)0)), (XREFT_ASSERT), 45, "bgpd/bgp_snmp_bgp4v2.c" , __func__, }, .expr = "bgpnode", }; static const struct xref * const xref_p_30 __attribute__((used, section("xref_array") )) = &(_xref.xref); if (__builtin_expect((bgpnode) ? 0 : 1 , 0)) do { _zlog_assert_failed(&_xref, ((void*)0)); } while (bgpnode); }), ({ static const struct xref_assert _xref __attribute__ ( (used)) = { .xref = { (((void*)0)), (XREFT_ASSERT), 45, "bgpd/bgp_snmp_bgp4v2.c" , __func__, }, .expr = "(bgpnode)->data != NULL", }; static const struct xref * const xref_p_31 __attribute__((used, section ("xref_array"))) = &(_xref.xref); if (__builtin_expect((( bgpnode)->data != ((void*)0)) ? 0 : 1, 0)) do { _zlog_assert_failed (&_xref, ((void*)0)); } while ((bgpnode)->data != ((void *)0)); }), (bgpnode)->data)), 1); (bgpnode) = ((bgpnode) ? ((bgpnode)->next) : ((void*)0)), ((bgp) = ((void*)0))) { |
46 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)(node) = ((bgp->peer) ? ((bgp->peer)->head) : ((void *)0)), ((peer) = ((void*)0)); (node) != ((void*)0) && ((peer) = ((({ static const struct xref_assert _xref __attribute__ ( (used)) = { .xref = { (((void*)0)), (XREFT_ASSERT), 46, "bgpd/bgp_snmp_bgp4v2.c" , __func__, }, .expr = "node", }; static const struct xref * const xref_p_32 __attribute__((used, section("xref_array"))) = & (_xref.xref); if (__builtin_expect((node) ? 0 : 1, 0)) do { _zlog_assert_failed (&_xref, ((void*)0)); } while (node); }), ({ static const struct xref_assert _xref __attribute__( (used)) = { .xref = { (((void*)0)), (XREFT_ASSERT), 46, "bgpd/bgp_snmp_bgp4v2.c", __func__ , }, .expr = "(node)->data != NULL", }; static const struct xref * const xref_p_33 __attribute__((used, section("xref_array" ))) = &(_xref.xref); if (__builtin_expect(((node)->data != ((void*)0)) ? 0 : 1, 0)) do { _zlog_assert_failed(&_xref , ((void*)0)); } while ((node)->data != ((void*)0)); }), ( node)->data)), 1); (node) = ((node) ? ((node)->next) : ( (void*)0)), ((peer) = ((void*)0))) { |
47 | switch (sockunion_family(&peer->connection->su)(&peer->connection->su)->sa.sa_family) { |
48 | case AF_INET2: |
49 | if (IPV4_ADDR_SAME(&peer->connection->su.sinipv4_addr_same((&peer->connection->su.sin .sin_addr ), (&addr->ip._v4_addr)) |
50 | .sin_addr,ipv4_addr_same((&peer->connection->su.sin .sin_addr ), (&addr->ip._v4_addr)) |
51 | &addr->ip._v4_addr)ipv4_addr_same((&peer->connection->su.sin .sin_addr ), (&addr->ip._v4_addr))) |
52 | return peer; |
53 | break; |
54 | case AF_INET610: |
55 | if (IPV6_ADDR_SAME(&peer->connection->su.sin6(memcmp ((&peer->connection->su.sin6 .sin6_addr), ( &addr->ip._v6_addr), 16) == 0) |
56 | .sin6_addr,(memcmp ((&peer->connection->su.sin6 .sin6_addr), ( &addr->ip._v6_addr), 16) == 0) |
57 | &addr->ip._v6_addr)(memcmp ((&peer->connection->su.sin6 .sin6_addr), ( &addr->ip._v6_addr), 16) == 0)) |
58 | return peer; |
59 | break; |
60 | default: |
61 | break; |
62 | } |
63 | } |
64 | } |
65 | |
66 | return NULL((void*)0); |
67 | } |
68 | |
69 | static struct peer *peer_lookup_all_vrf_next(struct ipaddr *addr, oid *offset, |
70 | sa_family_t family) |
71 | { |
72 | struct bgp *bgp; |
73 | struct peer *peer; |
74 | struct peer *next_peer = NULL((void*)0); |
75 | struct listnode *node; |
76 | struct listnode *bgpnode; |
77 | |
78 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, bgpnode, bgp)(bgpnode) = ((bm->bgp) ? ((bm->bgp)->head) : ((void* )0)), ((bgp) = ((void*)0)); (bgpnode) != ((void*)0) && ((bgp) = ((({ static const struct xref_assert _xref __attribute__ ( (used)) = { .xref = { (((void*)0)), (XREFT_ASSERT), 78, "bgpd/bgp_snmp_bgp4v2.c" , __func__, }, .expr = "bgpnode", }; static const struct xref * const xref_p_34 __attribute__((used, section("xref_array") )) = &(_xref.xref); if (__builtin_expect((bgpnode) ? 0 : 1 , 0)) do { _zlog_assert_failed(&_xref, ((void*)0)); } while (bgpnode); }), ({ static const struct xref_assert _xref __attribute__ ( (used)) = { .xref = { (((void*)0)), (XREFT_ASSERT), 78, "bgpd/bgp_snmp_bgp4v2.c" , __func__, }, .expr = "(bgpnode)->data != NULL", }; static const struct xref * const xref_p_35 __attribute__((used, section ("xref_array"))) = &(_xref.xref); if (__builtin_expect((( bgpnode)->data != ((void*)0)) ? 0 : 1, 0)) do { _zlog_assert_failed (&_xref, ((void*)0)); } while ((bgpnode)->data != ((void *)0)); }), (bgpnode)->data)), 1); (bgpnode) = ((bgpnode) ? ((bgpnode)->next) : ((void*)0)), ((bgp) = ((void*)0))) { |
79 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)(node) = ((bgp->peer) ? ((bgp->peer)->head) : ((void *)0)), ((peer) = ((void*)0)); (node) != ((void*)0) && ((peer) = ((({ static const struct xref_assert _xref __attribute__ ( (used)) = { .xref = { (((void*)0)), (XREFT_ASSERT), 79, "bgpd/bgp_snmp_bgp4v2.c" , __func__, }, .expr = "node", }; static const struct xref * const xref_p_36 __attribute__((used, section("xref_array"))) = & (_xref.xref); if (__builtin_expect((node) ? 0 : 1, 0)) do { _zlog_assert_failed (&_xref, ((void*)0)); } while (node); }), ({ static const struct xref_assert _xref __attribute__( (used)) = { .xref = { (((void*)0)), (XREFT_ASSERT), 79, "bgpd/bgp_snmp_bgp4v2.c", __func__ , }, .expr = "(node)->data != NULL", }; static const struct xref * const xref_p_37 __attribute__((used, section("xref_array" ))) = &(_xref.xref); if (__builtin_expect(((node)->data != ((void*)0)) ? 0 : 1, 0)) do { _zlog_assert_failed(&_xref , ((void*)0)); } while ((node)->data != ((void*)0)); }), ( node)->data)), 1); (node) = ((node) ? ((node)->next) : ( (void*)0)), ((peer) = ((void*)0))) { |
80 | sa_family_t peer_family = |
81 | sockunion_family(&peer->connection->su)(&peer->connection->su)->sa.sa_family; |
82 | |
83 | if (peer_family != family) |
84 | continue; |
85 | |
86 | switch (peer_family) { |
87 | case AF_INET2: |
88 | oid2in_addr(offset, IN_ADDR_SIZEsizeof(struct in_addr), |
89 | &addr->ip._v4_addr); |
90 | if (IPV4_ADDR_CMP(&peer->connection->su.sinmemcmp ((&peer->connection->su.sin .sin_addr), (& addr->ip._v4_addr), 4) |
91 | .sin_addr,memcmp ((&peer->connection->su.sin .sin_addr), (& addr->ip._v4_addr), 4) |
92 | &addr->ip._v4_addr)memcmp ((&peer->connection->su.sin .sin_addr), (& addr->ip._v4_addr), 4) < 0 || |
93 | IPV4_ADDR_SAME(&peer->connection->su.sinipv4_addr_same((&peer->connection->su.sin .sin_addr ), (&addr->ip._v4_addr)) |
94 | .sin_addr,ipv4_addr_same((&peer->connection->su.sin .sin_addr ), (&addr->ip._v4_addr)) |
95 | &addr->ip._v4_addr)ipv4_addr_same((&peer->connection->su.sin .sin_addr ), (&addr->ip._v4_addr))) |
96 | continue; |
97 | |
98 | if (!next_peer || |
99 | IPV4_ADDR_CMP(&next_peer->connection->su.sinmemcmp ((&next_peer->connection->su.sin .sin_addr), (&peer->connection->su.sin .sin_addr), 4) |
100 | .sin_addr,memcmp ((&next_peer->connection->su.sin .sin_addr), (&peer->connection->su.sin .sin_addr), 4) |
101 | &peer->connection->su.sinmemcmp ((&next_peer->connection->su.sin .sin_addr), (&peer->connection->su.sin .sin_addr), 4) |
102 | .sin_addr)memcmp ((&next_peer->connection->su.sin .sin_addr), (&peer->connection->su.sin .sin_addr), 4) > 0) |
103 | next_peer = peer; |
104 | |
105 | break; |
106 | case AF_INET610: |
107 | oid2in6_addr(offset, &addr->ip._v6_addr); |
108 | if (IPV6_ADDR_CMP(&peer->connection->su.sin6memcmp ((&peer->connection->su.sin6 .sin6_addr), (& addr->ip._v6_addr), 16) |
109 | .sin6_addr,memcmp ((&peer->connection->su.sin6 .sin6_addr), (& addr->ip._v6_addr), 16) |
110 | &addr->ip._v6_addr)memcmp ((&peer->connection->su.sin6 .sin6_addr), (& addr->ip._v6_addr), 16) < 0 || |
111 | IPV6_ADDR_SAME(&peer->connection->su.sin6(memcmp ((&peer->connection->su.sin6 .sin6_addr), ( &addr->ip._v6_addr), 16) == 0) |
112 | .sin6_addr,(memcmp ((&peer->connection->su.sin6 .sin6_addr), ( &addr->ip._v6_addr), 16) == 0) |
113 | &addr->ip._v6_addr)(memcmp ((&peer->connection->su.sin6 .sin6_addr), ( &addr->ip._v6_addr), 16) == 0)) |
114 | continue; |
115 | |
116 | if (!next_peer || |
117 | IPV6_ADDR_CMP(&next_peer->connection->sumemcmp ((&next_peer->connection->su .sin6.sin6_addr ), (&peer->connection->su.sin6 .sin6_addr), 16) |
118 | .sin6.sin6_addr,memcmp ((&next_peer->connection->su .sin6.sin6_addr ), (&peer->connection->su.sin6 .sin6_addr), 16) |
119 | &peer->connection->su.sin6memcmp ((&next_peer->connection->su .sin6.sin6_addr ), (&peer->connection->su.sin6 .sin6_addr), 16) |
120 | .sin6_addr)memcmp ((&next_peer->connection->su .sin6.sin6_addr ), (&peer->connection->su.sin6 .sin6_addr), 16) > 0) |
121 | next_peer = peer; |
122 | |
123 | break; |
124 | default: |
125 | break; |
126 | } |
127 | } |
128 | } |
129 | |
130 | if (next_peer) |
131 | return next_peer; |
132 | |
133 | return NULL((void*)0); |
134 | } |
135 | |
136 | static struct peer *bgpv2PeerTable_lookup(struct variable *v, oid name[], |
137 | size_t *length, int exact, |
138 | struct ipaddr *addr) |
139 | { |
140 | struct peer *peer = NULL((void*)0); |
141 | size_t namelen = v ? v->namelen : BGP4V2_PEER_ENTRY_OFFSET13; |
142 | oid *offset = name + namelen; |
143 | sa_family_t family = name[namelen - 1] == 1 ? AF_INET2 : AF_INET610; |
144 | int afi_len = IN_ADDR_SIZEsizeof(struct in_addr); |
145 | size_t offsetlen = *length - namelen; |
146 | |
147 | if (family == AF_INET610) |
148 | afi_len = IN6_ADDR_SIZEsizeof(struct in6_addr); |
149 | |
150 | /* Somehow with net-snmp 5.7.3, every OID item in an array |
151 | * is uninitialized and has a max random value, let's zero it. |
152 | * With 5.8, 5.9, it works fine even without this hack. |
153 | */ |
154 | if (!offsetlen) { |
155 | for (int i = 0; i < afi_len; i++) |
156 | *(offset + i) = 0; |
157 | } |
158 | |
159 | if (exact) { |
160 | if (family == AF_INET2) { |
161 | oid2in_addr(offset, afi_len, &addr->ip._v4_addr); |
162 | peer = peer_lookup_all_vrf(addr); |
163 | return peer; |
164 | } else if (family == AF_INET610) { |
165 | oid2in6_addr(offset, &addr->ip._v6_addr); |
166 | return peer_lookup_all_vrf(addr); |
167 | } |
168 | } else { |
169 | peer = peer_lookup_all_vrf_next(addr, offset, family); |
170 | if (peer == NULL((void*)0)) |
171 | return NULL((void*)0); |
172 | |
173 | switch (sockunion_family(&peer->connection->su)(&peer->connection->su)->sa.sa_family) { |
174 | case AF_INET2: |
175 | oid_copy_in_addr(offset, |
176 | &peer->connection->su.sin.sin_addr); |
177 | *length = afi_len + namelen; |
178 | return peer; |
179 | case AF_INET610: |
180 | oid_copy_in6_addr(offset, |
181 | &peer->connection->su.sin6.sin6_addr); |
182 | *length = afi_len + namelen; |
183 | return peer; |
184 | default: |
185 | break; |
186 | } |
187 | } |
188 | |
189 | return NULL((void*)0); |
190 | } |
191 | |
192 | static uint8_t *bgpv2PeerTable(struct variable *v, oid name[], size_t *length, |
193 | int exact, size_t *var_len, |
194 | WriteMethod **write_method) |
195 | { |
196 | struct peer *peer; |
197 | struct ipaddr addr = {}; |
198 | |
199 | if (smux_header_table(v, name, length, exact, var_len, write_method) == |
200 | MATCH_FAILED(-1)) |
201 | return NULL((void*)0); |
202 | |
203 | peer = bgpv2PeerTable_lookup(v, name, length, exact, &addr); |
204 | if (!peer) |
205 | return NULL((void*)0); |
206 | |
207 | switch (v->magic) { |
208 | case BGP4V2_PEER_INSTANCE1: |
209 | return SNMP_INTEGER(peer->bgp->vrf_id)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->bgp ->vrf_id, (uint8_t *)&snmp_int_val); |
210 | case BGP4V2_PEER_LOCAL_ADDR_TYPE2: |
211 | if (peer->su_local) |
212 | return SNMP_INTEGER(peer->su_local->sa.sa_family ==(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->su_local ->sa.sa_family == 2 ? AFI_IP : AFI_IP6, (uint8_t *)&snmp_int_val ) |
213 | AF_INET(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->su_local ->sa.sa_family == 2 ? AFI_IP : AFI_IP6, (uint8_t *)&snmp_int_val ) |
214 | ? AFI_IP(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->su_local ->sa.sa_family == 2 ? AFI_IP : AFI_IP6, (uint8_t *)&snmp_int_val ) |
215 | : AFI_IP6)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->su_local ->sa.sa_family == 2 ? AFI_IP : AFI_IP6, (uint8_t *)&snmp_int_val ); |
216 | else |
217 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
218 | case BGP4V2_PEER_LOCAL_ADDR3: |
219 | if (peer->su_local) |
220 | if (peer->su_local->sa.sa_family == AF_INET2) |
221 | return SNMP_IPADDRESS((*var_len = sizeof(struct in_addr), snmp_in_addr_val = peer-> su_local->sin.sin_addr, (uint8_t *)&snmp_in_addr_val) |
222 | peer->su_local->sin.sin_addr)(*var_len = sizeof(struct in_addr), snmp_in_addr_val = peer-> su_local->sin.sin_addr, (uint8_t *)&snmp_in_addr_val); |
223 | else |
224 | return SNMP_IP6ADDRESS((*var_len = sizeof(struct in6_addr), (uint8_t *)&peer-> su_local->sin6.sin6_addr) |
225 | peer->su_local->sin6.sin6_addr)(*var_len = sizeof(struct in6_addr), (uint8_t *)&peer-> su_local->sin6.sin6_addr); |
226 | else |
227 | return SNMP_IPADDRESS(bgp_empty_addr)(*var_len = sizeof(struct in_addr), snmp_in_addr_val = bgp_empty_addr , (uint8_t *)&snmp_in_addr_val); |
228 | case BGP4V2_PEER_REMOTE_ADDR_TYPE4: |
229 | if (peer->su_remote) |
230 | return SNMP_INTEGER(peer->su_remote->sa.sa_family ==(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->su_remote ->sa.sa_family == 2 ? AFI_IP : AFI_IP6, (uint8_t *)&snmp_int_val ) |
231 | AF_INET(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->su_remote ->sa.sa_family == 2 ? AFI_IP : AFI_IP6, (uint8_t *)&snmp_int_val ) |
232 | ? AFI_IP(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->su_remote ->sa.sa_family == 2 ? AFI_IP : AFI_IP6, (uint8_t *)&snmp_int_val ) |
233 | : AFI_IP6)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->su_remote ->sa.sa_family == 2 ? AFI_IP : AFI_IP6, (uint8_t *)&snmp_int_val ); |
234 | else |
235 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
236 | case BGP4V2_PEER_REMOTE_ADDR5: |
237 | if (peer->su_remote) |
238 | if (peer->su_remote->sa.sa_family == AF_INET2) |
239 | return SNMP_IPADDRESS((*var_len = sizeof(struct in_addr), snmp_in_addr_val = peer-> su_remote->sin.sin_addr, (uint8_t *)&snmp_in_addr_val) |
240 | peer->su_remote->sin.sin_addr)(*var_len = sizeof(struct in_addr), snmp_in_addr_val = peer-> su_remote->sin.sin_addr, (uint8_t *)&snmp_in_addr_val); |
241 | else |
242 | return SNMP_IP6ADDRESS((*var_len = sizeof(struct in6_addr), (uint8_t *)&peer-> su_remote->sin6.sin6_addr) |
243 | peer->su_remote->sin6.sin6_addr)(*var_len = sizeof(struct in6_addr), (uint8_t *)&peer-> su_remote->sin6.sin6_addr); |
244 | else |
245 | return SNMP_IPADDRESS(bgp_empty_addr)(*var_len = sizeof(struct in_addr), snmp_in_addr_val = bgp_empty_addr , (uint8_t *)&snmp_in_addr_val); |
246 | case BGP4V2_PEER_LOCAL_PORT6: |
247 | if (peer->su_local) |
248 | if (peer->su_local->sa.sa_family == AF_INET2) |
249 | return SNMP_INTEGER((*var_len = sizeof(snmp_int_val), snmp_int_val = ntohs(peer-> su_local->sin.sin_port), (uint8_t *)&snmp_int_val) |
250 | ntohs(peer->su_local->sin.sin_port))(*var_len = sizeof(snmp_int_val), snmp_int_val = ntohs(peer-> su_local->sin.sin_port), (uint8_t *)&snmp_int_val); |
251 | else |
252 | return SNMP_INTEGER((*var_len = sizeof(snmp_int_val), snmp_int_val = ntohs(peer-> su_local->sin6.sin6_port), (uint8_t *)&snmp_int_val) |
253 | ntohs(peer->su_local->sin6.sin6_port))(*var_len = sizeof(snmp_int_val), snmp_int_val = ntohs(peer-> su_local->sin6.sin6_port), (uint8_t *)&snmp_int_val); |
254 | else |
255 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
256 | case BGP4V2_PEER_LOCAL_AS7: |
257 | return SNMP_INTEGER(peer->local_as)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->local_as , (uint8_t *)&snmp_int_val); |
258 | case BGP4V2_PEER_LOCAL_IDENTIFIER8: |
259 | return SNMP_IPADDRESS(peer->local_id)(*var_len = sizeof(struct in_addr), snmp_in_addr_val = peer-> local_id, (uint8_t *)&snmp_in_addr_val); |
260 | case BGP4V2_PEER_REMOTE_PORT9: |
261 | if (peer->su_remote) |
262 | if (peer->su_remote->sa.sa_family == AF_INET2) |
263 | return SNMP_INTEGER((*var_len = sizeof(snmp_int_val), snmp_int_val = ntohs(peer-> su_remote->sin.sin_port), (uint8_t *)&snmp_int_val) |
264 | ntohs(peer->su_remote->sin.sin_port))(*var_len = sizeof(snmp_int_val), snmp_int_val = ntohs(peer-> su_remote->sin.sin_port), (uint8_t *)&snmp_int_val); |
265 | else |
266 | return SNMP_INTEGER((*var_len = sizeof(snmp_int_val), snmp_int_val = ntohs(peer-> su_remote->sin6.sin6_port), (uint8_t *)&snmp_int_val) |
267 | ntohs(peer->su_remote->sin6.sin6_port))(*var_len = sizeof(snmp_int_val), snmp_int_val = ntohs(peer-> su_remote->sin6.sin6_port), (uint8_t *)&snmp_int_val); |
268 | else |
269 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
270 | case BGP4V2_PEER_REMOTE_AS10: |
271 | return SNMP_INTEGER(peer->as)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->as, (uint8_t *)&snmp_int_val); |
272 | case BGP4V2_PEER_REMOTE_IDENTIFIER11: |
273 | return SNMP_IPADDRESS(peer->remote_id)(*var_len = sizeof(struct in_addr), snmp_in_addr_val = peer-> remote_id, (uint8_t *)&snmp_in_addr_val); |
274 | case BGP4V2_PEER_ADMIN_STATUS12: |
275 | #define BGP_PEER_ADMIN_STATUS_HALTED1 1 |
276 | #define BGP_PEER_ADMIN_STATUS_RUNNING2 2 |
277 | if (BGP_PEER_START_SUPPRESSED(peer)((((peer)->flags) & ((1ULL << 1))) || (((peer)-> sflags) & ((1U << 1))) || (((peer)->bgp->flags ) & ((1ULL << 25))) || (peer)->shut_during_cfg)) |
278 | return SNMP_INTEGER(BGP_PEER_ADMIN_STATUS_HALTED)(*var_len = sizeof(snmp_int_val), snmp_int_val = 1, (uint8_t * )&snmp_int_val); |
279 | else |
280 | return SNMP_INTEGER(BGP_PEER_ADMIN_STATUS_RUNNING)(*var_len = sizeof(snmp_int_val), snmp_int_val = 2, (uint8_t * )&snmp_int_val); |
281 | case BGP4V2_PEER_STATE13: |
282 | return SNMP_INTEGER(peer->connection->status)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->connection ->status, (uint8_t *)&snmp_int_val); |
283 | case BGP4V2_PEER_DESCRIPTION14: |
284 | if (peer->desc) |
285 | return SNMP_STRING(peer->desc)(*var_len = (((sizeof(snmp_string_val))<(strlen(peer->desc ) + 1))?(sizeof(snmp_string_val)):(strlen(peer->desc) + 1) ), strlcpy(snmp_string_val, peer->desc, *var_len), (uint8_t *)&snmp_string_val); |
286 | break; |
287 | default: |
288 | break; |
289 | } |
290 | |
291 | return NULL((void*)0); |
292 | } |
293 | |
294 | static uint8_t *bgpv2PeerErrorsTable(struct variable *v, oid name[], |
295 | size_t *length, int exact, size_t *var_len, |
296 | WriteMethod **write_method) |
297 | { |
298 | struct peer *peer; |
299 | struct ipaddr addr = {}; |
300 | |
301 | if (smux_header_table(v, name, length, exact, var_len, write_method) == |
302 | MATCH_FAILED(-1)) |
303 | return NULL((void*)0); |
304 | |
305 | peer = bgpv2PeerTable_lookup(v, name, length, exact, &addr); |
306 | if (!peer) |
307 | return NULL((void*)0); |
308 | |
309 | switch (v->magic) { |
310 | case BGP4V2_PEER_LAST_ERROR_CODE_RECEIVED1: |
311 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED13U) |
312 | return SNMP_INTEGER(peer->notify.code)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->notify .code, (uint8_t *)&snmp_int_val); |
313 | else |
314 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
315 | case BGP4V2_PEER_LAST_ERROR_SUBCODE_RECEIVED2: |
316 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED13U) |
317 | return SNMP_INTEGER(peer->notify.subcode)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->notify .subcode, (uint8_t *)&snmp_int_val); |
318 | else |
319 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
320 | case BGP4V2_PEER_LAST_ERROR_RECEIVED_TIME3: |
321 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED13U) |
322 | return SNMP_INTEGER(peer->resettime)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->resettime , (uint8_t *)&snmp_int_val); |
323 | else |
324 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
325 | case BGP4V2_PEER_LAST_ERROR_RECEIVED_TEXT4: |
326 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED13U) { |
327 | struct bgp_notify notify = peer->notify; |
328 | char msg_buf[255]; |
329 | const char *msg_str = NULL((void*)0); |
330 | |
331 | if (notify.code == BGP_NOTIFY_CEASE6 && |
332 | (notify.subcode == |
333 | BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN2 || |
334 | notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET4)) { |
335 | msg_str = bgp_notify_admin_message( |
336 | msg_buf, sizeof(msg_buf), |
337 | (uint8_t *)notify.data, notify.length); |
338 | return SNMP_STRING(msg_str)(*var_len = (((sizeof(snmp_string_val))<(strlen(msg_str) + 1))?(sizeof(snmp_string_val)):(strlen(msg_str) + 1)), strlcpy (snmp_string_val, msg_str, *var_len), (uint8_t *)&snmp_string_val ); |
339 | } |
340 | } |
341 | return SNMP_STRING("")(*var_len = (((sizeof(snmp_string_val))<(strlen("") + 1))? (sizeof(snmp_string_val)):(strlen("") + 1)), strlcpy(snmp_string_val , "", *var_len), (uint8_t *)&snmp_string_val); |
342 | case BGP4V2_PEER_LAST_ERROR_RECEIVED_DATA5: |
343 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED13U) |
344 | return SNMP_STRING(peer->notify.data)(*var_len = (((sizeof(snmp_string_val))<(strlen(peer->notify .data) + 1))?(sizeof(snmp_string_val)):(strlen(peer->notify .data) + 1)), strlcpy(snmp_string_val, peer->notify.data, * var_len), (uint8_t *)&snmp_string_val); |
345 | else |
346 | return SNMP_STRING("")(*var_len = (((sizeof(snmp_string_val))<(strlen("") + 1))? (sizeof(snmp_string_val)):(strlen("") + 1)), strlcpy(snmp_string_val , "", *var_len), (uint8_t *)&snmp_string_val); |
347 | case BGP4V2_PEER_LAST_ERROR_CODE_SENT6: |
348 | if (peer->last_reset != PEER_DOWN_NOTIFY_RECEIVED13U) |
349 | return SNMP_INTEGER(peer->notify.code)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->notify .code, (uint8_t *)&snmp_int_val); |
350 | else |
351 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
352 | case BGP4V2_PEER_LAST_ERROR_SUBCODE_SENT7: |
353 | if (peer->last_reset != PEER_DOWN_NOTIFY_RECEIVED13U) |
354 | return SNMP_INTEGER(peer->notify.subcode)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->notify .subcode, (uint8_t *)&snmp_int_val); |
355 | else |
356 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
357 | case BGP4V2_PEER_LAST_ERROR_SENT_TIME8: |
358 | if (peer->last_reset != PEER_DOWN_NOTIFY_RECEIVED13U) |
359 | return SNMP_INTEGER(peer->resettime)(*var_len = sizeof(snmp_int_val), snmp_int_val = peer->resettime , (uint8_t *)&snmp_int_val); |
360 | else |
361 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
362 | case BGP4V2_PEER_LAST_ERROR_SENT_TEXT9: |
363 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND14U || |
364 | peer->last_reset == PEER_DOWN_RTT_SHUTDOWN35U || |
365 | peer->last_reset == PEER_DOWN_USER_SHUTDOWN11U) { |
366 | struct bgp_notify notify = peer->notify; |
367 | char msg_buf[255]; |
368 | const char *msg_str = NULL((void*)0); |
369 | |
370 | if (notify.code == BGP_NOTIFY_CEASE6 && |
371 | (notify.subcode == |
372 | BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN2 || |
373 | notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET4)) { |
374 | msg_str = bgp_notify_admin_message( |
375 | msg_buf, sizeof(msg_buf), |
376 | (uint8_t *)notify.data, notify.length); |
377 | return SNMP_STRING(msg_str)(*var_len = (((sizeof(snmp_string_val))<(strlen(msg_str) + 1))?(sizeof(snmp_string_val)):(strlen(msg_str) + 1)), strlcpy (snmp_string_val, msg_str, *var_len), (uint8_t *)&snmp_string_val ); |
378 | } |
379 | } |
380 | return SNMP_STRING("")(*var_len = (((sizeof(snmp_string_val))<(strlen("") + 1))? (sizeof(snmp_string_val)):(strlen("") + 1)), strlcpy(snmp_string_val , "", *var_len), (uint8_t *)&snmp_string_val); |
381 | case BGP4V2_PEER_LAST_ERROR_SENT_DATA10: |
382 | if ((peer->last_reset == PEER_DOWN_NOTIFY_SEND14U || |
383 | peer->last_reset == PEER_DOWN_RTT_SHUTDOWN35U || |
384 | peer->last_reset == PEER_DOWN_USER_SHUTDOWN11U) && |
385 | peer->notify.data) |
386 | return SNMP_STRING(peer->notify.data)(*var_len = (((sizeof(snmp_string_val))<(strlen(peer->notify .data) + 1))?(sizeof(snmp_string_val)):(strlen(peer->notify .data) + 1)), strlcpy(snmp_string_val, peer->notify.data, * var_len), (uint8_t *)&snmp_string_val); |
387 | else |
388 | return SNMP_STRING("")(*var_len = (((sizeof(snmp_string_val))<(strlen("") + 1))? (sizeof(snmp_string_val)):(strlen("") + 1)), strlcpy(snmp_string_val , "", *var_len), (uint8_t *)&snmp_string_val); |
389 | default: |
390 | break; |
391 | } |
392 | |
393 | return NULL((void*)0); |
394 | } |
395 | |
396 | static uint8_t *bgpv2PeerEventTimesTable(struct variable *v, oid name[], |
397 | size_t *length, int exact, |
398 | size_t *var_len, |
399 | WriteMethod **write_method) |
400 | { |
401 | struct peer *peer; |
402 | struct ipaddr addr = {}; |
403 | |
404 | if (smux_header_table(v, name, length, exact, var_len, write_method) == |
405 | MATCH_FAILED(-1)) |
406 | return NULL((void*)0); |
407 | |
408 | peer = bgpv2PeerTable_lookup(v, name, length, exact, &addr); |
409 | if (!peer) |
410 | return NULL((void*)0); |
411 | |
412 | switch (v->magic) { |
413 | case BGP4V2_PEER_FSM_ESTABLISHED_TIME1: |
414 | if (!peer->uptime) |
415 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
416 | else |
417 | return SNMP_INTEGER(monotime(NULL) - peer->uptime)(*var_len = sizeof(snmp_int_val), snmp_int_val = monotime(((void *)0)) - peer->uptime, (uint8_t *)&snmp_int_val); |
418 | case BGP4V2_PEER_PEER_IN_UPDATES_ELAPSED_TIME2: |
419 | if (!peer->update_time) |
420 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
421 | else |
422 | return SNMP_INTEGER(monotime(NULL) - peer->update_time)(*var_len = sizeof(snmp_int_val), snmp_int_val = monotime(((void *)0)) - peer->update_time, (uint8_t *)&snmp_int_val); |
423 | default: |
424 | break; |
425 | } |
426 | |
427 | return NULL((void*)0); |
428 | } |
429 | |
430 | static struct bgp_path_info * |
431 | bgp4v2PathAttrLookup(struct variable *v, oid name[], size_t *length, |
432 | struct bgp *bgp, struct prefix *addr, int exact) |
433 | { |
434 | oid *offset; |
435 | int offsetlen; |
436 | struct bgp_path_info *path, *min; |
437 | struct bgp_dest *dest; |
438 | union sockunion su; |
439 | unsigned int len; |
440 | struct ipaddr paddr = {}; |
441 | size_t namelen = v ? v->namelen : BGP4V2_NLRI_ENTRY_OFFSET13; |
442 | sa_family_t family; |
443 | sa_family_t min_family = 0; /* family of the selected min path */ |
444 | afi_t afi; |
445 | safi_t safi; |
446 | size_t afi_len; |
447 | long prefix_type = 0; |
448 | long peer_addr_type = 0; |
449 | long nrli_index = 1; |
450 | long cur_index = 0; |
451 | |
452 | /* Bgp4V2AddressFamilyIdentifierTC limited to IPv6 */ |
453 | if (name[namelen - 1] > IANA_AFI_IPV6) |
454 | return NULL((void*)0); |
455 | afi = afi_iana2int(name[namelen - 1]); |
456 | afi_len = afi == AFI_IP ? IN_ADDR_SIZEsizeof(struct in_addr) : IN6_ADDR_SIZEsizeof(struct in6_addr); |
457 | assert(IS_VALID_AFI(afi))({ static const struct xref_assert _xref __attribute__( (used )) = { .xref = { (((void*)0)), (XREFT_ASSERT), 457, "bgpd/bgp_snmp_bgp4v2.c" , __func__, }, .expr = "IS_VALID_AFI(afi)", }; static const struct xref * const xref_p_38 __attribute__((used, section("xref_array" ))) = &(_xref.xref); if (__builtin_expect((((afi) > AFI_UNSPEC && (afi) < AFI_MAX)) ? 0 : 1, 0)) do { _zlog_assert_failed (&_xref, ((void*)0)); } while (((afi) > AFI_UNSPEC && (afi) < AFI_MAX)); }); |
458 | |
459 | #define BGP_NLRI_ENTRY_OFFSETnamelen namelen |
460 | #define BGP4V2_NLRI_V4_V4_OFFSETsizeof(struct in_addr) + sizeof(struct in_addr) + 5 IN_ADDR_SIZEsizeof(struct in_addr) + IN_ADDR_SIZEsizeof(struct in_addr) + 5 |
461 | #define BGP4V2_NLRI_V4_V6_OFFSETsizeof(struct in_addr) + sizeof(struct in6_addr) + 5 IN_ADDR_SIZEsizeof(struct in_addr) + IN6_ADDR_SIZEsizeof(struct in6_addr) + 5 |
462 | #define BGP4V2_NLRI_V6_V6_OFFSETsizeof(struct in6_addr) + sizeof(struct in6_addr) + 5 IN6_ADDR_SIZEsizeof(struct in6_addr) + IN6_ADDR_SIZEsizeof(struct in6_addr) + 5 |
463 | |
464 | |
465 | sockunion_init(&su); |
466 | |
467 | if (exact) { |
468 | if (*length - namelen != BGP4V2_NLRI_V4_V4_OFFSETsizeof(struct in_addr) + sizeof(struct in_addr) + 5 && |
469 | *length - namelen != BGP4V2_NLRI_V4_V6_OFFSETsizeof(struct in_addr) + sizeof(struct in6_addr) + 5 && |
470 | *length - namelen != BGP4V2_NLRI_V6_V6_OFFSETsizeof(struct in6_addr) + sizeof(struct in6_addr) + 5) |
471 | return NULL((void*)0); |
472 | |
473 | /* Set OID offset for prefix type */ |
474 | offset = name + namelen; |
475 | |
476 | /* Bgp4V2SubsequentAddressFamilyIdentifierTC */ |
477 | /* limited to Labeled unicast */ |
478 | if (*offset > IANA_SAFI_LABELED_UNICAST) |
479 | return NULL((void*)0); |
480 | safi = safi_iana2int(*offset); |
481 | offset++; |
482 | |
483 | /* get bgp4V2NlriPrefixType */ |
484 | prefix_type = *offset; |
485 | offset++; |
486 | |
487 | /* get bgp4V2NlriPrefix */ |
488 | if (prefix_type == IANA_AFI_IPV4) { |
489 | oid2in_addr(offset, IN_ADDR_SIZEsizeof(struct in_addr), &addr->u.prefix4); |
490 | addr->family = AF_INET2; |
491 | offset += IN_ADDR_SIZEsizeof(struct in_addr); |
492 | } else if (prefix_type == IANA_AFI_IPV6) { |
493 | oid2in6_addr(offset, &addr->u.prefix6); |
494 | addr->family = AF_INET610; |
495 | offset += IN6_ADDR_SIZEsizeof(struct in6_addr); |
496 | } |
497 | |
498 | /* get bgp4V2NlriPrefixLen */ |
499 | addr->prefixlen = *offset; |
500 | offset++; |
501 | |
502 | /* get bgp4V2PeerRemoteAddrType */ |
503 | peer_addr_type = *offset; |
504 | if (peer_addr_type == IANA_AFI_IPV4) |
505 | family = AF_INET2; |
506 | else |
507 | family = AF_INET610; |
508 | offset++; |
509 | |
510 | /* Peer address */ |
511 | su.sin.sin_family = family; |
512 | |
513 | /* get bgp4V2PeerRemoteAddr*/ |
514 | if (family == AF_INET2) { |
515 | oid2in_addr(offset, IN_ADDR_SIZEsizeof(struct in_addr), &su.sin.sin_addr); |
516 | offset += IN_ADDR_SIZEsizeof(struct in_addr); |
517 | } else { |
518 | oid2in6_addr(offset, &su.sin6.sin6_addr); |
519 | offset += IN6_ADDR_SIZEsizeof(struct in6_addr); |
520 | } |
521 | |
522 | /* bgp4V2NlriIndex */ |
523 | nrli_index = *offset; |
524 | offset++; |
525 | |
526 | /* Lookup node */ |
527 | dest = bgp_node_lookup(bgp->rib[afi][safi], addr); |
528 | if (dest) { |
529 | for (path = bgp_dest_get_bgp_path_info(dest); path; |
530 | path = path->next) |
531 | if (sockunion_same(&path->peer->connection->su, |
532 | &su)) { |
533 | cur_index++; |
534 | if (cur_index == nrli_index) |
535 | return path; |
536 | } |
537 | |
538 | bgp_dest_unlock_node(dest); |
539 | } |
540 | |
541 | return NULL((void*)0); |
542 | } |
543 | |
544 | /* Set OID offset for prefix type */ |
545 | offset = name + namelen; |
546 | offsetlen = *length - namelen; |
547 | len = offsetlen; |
548 | |
549 | if (offsetlen == 0) { |
550 | dest = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); |
551 | safi = SAFI_UNICAST; |
Value stored to 'safi' is never read | |
552 | } else { |
553 | |
554 | /* bgp4V2NlriAfi is already get */ |
555 | /* it is comming from the name parameter */ |
556 | |
557 | /* get bgp4V2NlriSafi */ |
558 | /* Bgp4V2SubsequentAddressFamilyIdentifierTC */ |
559 | /* limited to Labeled unicast */ |
560 | if (*offset > IANA_SAFI_LABELED_UNICAST) |
561 | return NULL((void*)0); |
562 | safi = safi_iana2int(*offset); |
563 | offset++; |
564 | |
565 | /* get bgp4V2NlriPrefixType */ |
566 | prefix_type = *offset; |
567 | offset++; |
568 | /* get bgp4V2NlriPrefix */ |
569 | if (prefix_type == IANA_AFI_IPV4) { |
570 | oid2in_addr(offset, IN_ADDR_SIZEsizeof(struct in_addr), &addr->u.prefix4); |
571 | addr->family = AF_INET2; |
572 | offset += IN_ADDR_SIZEsizeof(struct in_addr); |
573 | offsetlen -= IN_ADDR_SIZEsizeof(struct in_addr); |
574 | } else if (prefix_type == IANA_AFI_IPV6) { |
575 | oid2in6_addr(offset, &addr->u.prefix6); |
576 | addr->family = AF_INET610; |
577 | offset += IN6_ADDR_SIZEsizeof(struct in6_addr); |
578 | offsetlen -= IN6_ADDR_SIZEsizeof(struct in6_addr); |
579 | } |
580 | |
581 | /* get bgp4V2NlriPrefixLen */ |
582 | if (offsetlen > 0) |
583 | addr->prefixlen = *offset; |
584 | else |
585 | addr->prefixlen = afi_len * 8; |
586 | |
587 | offset++; |
588 | offsetlen--; |
589 | |
590 | /* get node */ |
591 | dest = bgp_node_lookup(bgp->rib[afi][safi], addr); |
592 | } |
593 | |
594 | if (!dest) |
595 | return NULL((void*)0); |
596 | |
597 | if (offsetlen > 0) { |
598 | len = offsetlen; |
599 | if (len > afi_len) |
600 | len = afi_len; |
601 | |
602 | |
603 | /* get bgp4V2PeerRemoteAddrType */ |
604 | peer_addr_type = *offset; |
605 | if (peer_addr_type == IANA_AFI_IPV4) |
606 | family = AF_INET2; |
607 | else |
608 | family = AF_INET610; |
609 | offset++; |
610 | |
611 | if (family == AF_INET2) { |
612 | oid2in_addr(offset, IN_ADDR_SIZEsizeof(struct in_addr), &paddr.ip._v4_addr); |
613 | offset += IN_ADDR_SIZEsizeof(struct in_addr); |
614 | } else { |
615 | oid2in6_addr(offset, &paddr.ip._v6_addr); |
616 | offset += IN6_ADDR_SIZEsizeof(struct in6_addr); |
617 | } |
618 | /* get bgp4V2NlriIndex */ |
619 | nrli_index = *offset; |
620 | offset++; |
621 | |
622 | } else { |
623 | /* default case start with ipv4*/ |
624 | if (afi == AFI_IP) |
625 | family = AF_INET2; |
626 | else |
627 | family = AF_INET610; |
628 | memset(&paddr.ip, 0, sizeof(paddr.ip)); |
629 | nrli_index = 1; |
630 | } |
631 | |
632 | do { |
633 | min = NULL((void*)0); |
634 | min_family = 0; |
635 | cur_index = 0; |
636 | |
637 | for (path = bgp_dest_get_bgp_path_info(dest); path; |
638 | path = path->next) { |
639 | sa_family_t path_family = |
640 | sockunion_family(&path->peer->connection->su)(&path->peer->connection->su)->sa.sa_family; |
641 | /* the next addr must be > to the current */ |
642 | if (path_family < family) |
643 | continue; |
644 | |
645 | if (family == AF_INET2 && |
646 | IPV4_ADDR_CMP(&paddr.ip._v4_addr,memcmp ((&paddr.ip._v4_addr), (&path->peer->connection ->su.sin .sin_addr), 4) |
647 | &path->peer->connection->su.sinmemcmp ((&paddr.ip._v4_addr), (&path->peer->connection ->su.sin .sin_addr), 4) |
648 | .sin_addr)memcmp ((&paddr.ip._v4_addr), (&path->peer->connection ->su.sin .sin_addr), 4) > 0) |
649 | continue; |
650 | else if (family == AF_INET610 && |
651 | IPV6_ADDR_CMP(&paddr.ip._v6_addr,memcmp ((&paddr.ip._v6_addr), (&path->peer->connection ->su.sin6 .sin6_addr), 16) |
652 | &path->peer->connection->su.sin6memcmp ((&paddr.ip._v6_addr), (&path->peer->connection ->su.sin6 .sin6_addr), 16) |
653 | .sin6_addr)memcmp ((&paddr.ip._v6_addr), (&path->peer->connection ->su.sin6 .sin6_addr), 16) > 0) |
654 | continue; |
655 | |
656 | if (family == AF_INET2 && |
657 | IPV4_ADDR_CMP(&paddr.ip._v4_addr,memcmp ((&paddr.ip._v4_addr), (&path->peer->connection ->su.sin .sin_addr), 4) |
658 | &path->peer->connection->su.sinmemcmp ((&paddr.ip._v4_addr), (&path->peer->connection ->su.sin .sin_addr), 4) |
659 | .sin_addr)memcmp ((&paddr.ip._v4_addr), (&path->peer->connection ->su.sin .sin_addr), 4) == 0) { |
660 | if (cur_index == nrli_index) { |
661 | min = path; |
662 | min_family = family; |
663 | nrli_index++; |
664 | break; |
665 | } |
666 | cur_index++; |
667 | continue; |
668 | } else if (family == AF_INET610 && |
669 | IPV6_ADDR_CMP(&paddr.ip._v6_addr,memcmp ((&paddr.ip._v6_addr), (&path->peer->connection ->su .sin6.sin6_addr), 16) |
670 | &path->peer->connection->sumemcmp ((&paddr.ip._v6_addr), (&path->peer->connection ->su .sin6.sin6_addr), 16) |
671 | .sin6.sin6_addr)memcmp ((&paddr.ip._v6_addr), (&path->peer->connection ->su .sin6.sin6_addr), 16) == 0) { |
672 | if (cur_index == nrli_index) { |
673 | min = path; |
674 | min_family = family; |
675 | nrli_index++; |
676 | break; |
677 | } |
678 | cur_index++; |
679 | continue; |
680 | } |
681 | |
682 | /* first valid path its the min peer addr*/ |
683 | if (!min) { |
684 | min = path; |
685 | min_family = path_family; |
686 | continue; |
687 | } |
688 | |
689 | /* consider path < min */ |
690 | if (path_family < min_family) { |
691 | min = path; |
692 | min_family = path_family; |
693 | continue; |
694 | } |
695 | |
696 | if (path_family == AF_INET2 |
697 | && IPV4_ADDR_CMP(&path->peer->connection->su.sin.sin_addr,memcmp ((&path->peer->connection->su.sin.sin_addr ), (&min->peer->connection->su.sin.sin_addr), 4) |
698 | &min->peer->connection->su.sin.sin_addr)memcmp ((&path->peer->connection->su.sin.sin_addr ), (&min->peer->connection->su.sin.sin_addr), 4) |
699 | < 0) { |
700 | min = path; |
701 | min_family = path_family; |
702 | |
703 | } else if (path_family == AF_INET610 |
704 | && IPV6_ADDR_CMP(memcmp ((&path->peer->connection->su.sin6.sin6_addr ), (&min->peer->connection->su.sin6.sin6_addr), 16 ) |
705 | &path->peer->connection->su.sin6.sin6_addr,memcmp ((&path->peer->connection->su.sin6.sin6_addr ), (&min->peer->connection->su.sin6.sin6_addr), 16 ) |
706 | &min->peer->connection->su.sin6.sin6_addr)memcmp ((&path->peer->connection->su.sin6.sin6_addr ), (&min->peer->connection->su.sin6.sin6_addr), 16 ) |
707 | < 0) { |
708 | min = path; |
709 | min_family = path_family; |
710 | } |
711 | } |
712 | |
713 | if (min) { |
714 | const struct prefix *rn_p = bgp_dest_get_prefix(dest); |
715 | |
716 | offset = name + namelen; |
717 | |
718 | /* encode bgp4V2NlriSafi*/ |
719 | *offset = SAFI_UNICAST; |
720 | offset++; |
721 | /* encode bgp4V2NlriPrefixType into index*/ |
722 | /* encode bgp4V2NlriPrefix into index */ |
723 | if (rn_p->family == AF_INET2) { |
724 | *offset = IANA_AFI_IPV4; |
725 | offset++; |
726 | oid_copy_in_addr(offset, &rn_p->u.prefix4); |
727 | offset += IN_ADDR_SIZEsizeof(struct in_addr); |
728 | } else { |
729 | *offset = IANA_AFI_IPV6; |
730 | offset++; |
731 | oid_copy_in6_addr(offset, &rn_p->u.prefix6); |
732 | offset += IN6_ADDR_SIZEsizeof(struct in6_addr); |
733 | } |
734 | /* encode bgp4V2NlriPrefixLen into index*/ |
735 | *offset = rn_p->prefixlen; |
736 | offset++; |
737 | |
738 | /* Encode bgp4V2PeerRemoteAddrType */ |
739 | /* Encode bgp4V2PeerRemoteAddr */ |
740 | if (min_family == AF_INET2) { |
741 | *offset = IANA_AFI_IPV4; |
742 | offset++; |
743 | oid_copy_in_addr(offset, |
744 | &min->peer->connection->su.sin.sin_addr); |
745 | offset += IN_ADDR_SIZEsizeof(struct in_addr); |
746 | addr->u.prefix4 = rn_p->u.prefix4; |
747 | } else { |
748 | *offset = IANA_AFI_IPV6; |
749 | offset++; |
750 | oid_copy_in6_addr( |
751 | offset, &min->peer->connection->su.sin6.sin6_addr); |
752 | offset += IN6_ADDR_SIZEsizeof(struct in6_addr); |
753 | addr->u.prefix6 = rn_p->u.prefix6; |
754 | } |
755 | |
756 | /* Encode bgp4V2NlriIndex*/ |
757 | |
758 | *offset = nrli_index; |
759 | offset++; |
760 | |
761 | *length = offset - name; |
762 | |
763 | addr->prefixlen = rn_p->prefixlen; |
764 | addr->family = rn_p->family; |
765 | |
766 | bgp_dest_unlock_node(dest); |
767 | |
768 | return min; |
769 | } |
770 | |
771 | memset(&paddr.ip, 0, sizeof(paddr.ip)); |
772 | nrli_index = 1; |
773 | |
774 | } while ((dest = bgp_route_next(dest))); |
775 | |
776 | return NULL((void*)0); |
777 | } |
778 | |
779 | static uint8_t *bgp4v2PathAttrTable(struct variable *v, oid name[], |
780 | size_t *length, int exact, size_t *var_len, |
781 | WriteMethod **write_method) |
782 | { |
783 | struct bgp *bgp; |
784 | struct bgp_path_info *path; |
785 | struct peer_af *paf = NULL((void*)0); |
786 | struct prefix addr = {}; |
787 | const struct prefix *prefix = NULL((void*)0); |
788 | enum bgp_af_index index; |
789 | |
790 | bgp = bgp_get_default(); |
791 | if (!bgp) |
792 | return NULL((void*)0); |
793 | |
794 | if (smux_header_table(v, name, length, exact, var_len, write_method) == |
795 | MATCH_FAILED(-1)) |
796 | return NULL((void*)0); |
797 | |
798 | path = bgp4v2PathAttrLookup(v, name, length, bgp, &addr, exact); |
799 | if (!path) |
800 | return NULL((void*)0); |
801 | |
802 | prefix = bgp_dest_get_prefix(path->net); |
803 | |
804 | AF_FOREACH (index)for ((index) = BGP_AF_START; (index) < BGP_AF_MAX; (index) ++) { |
805 | paf = path->peer->peer_af_array[index]; |
806 | if (paf) |
807 | break; |
808 | } |
809 | |
810 | switch (v->magic) { |
811 | case BGP4V2_NLRI_INDEX1: |
812 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
813 | case BGP4V2_NLRI_AFI2: |
814 | if (paf) |
815 | return SNMP_INTEGER(paf->afi)(*var_len = sizeof(snmp_int_val), snmp_int_val = paf->afi, (uint8_t *)&snmp_int_val); |
816 | else |
817 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
818 | case BGP4V2_NLRI_SAFI3: |
819 | if (paf) |
820 | return SNMP_INTEGER(paf->safi)(*var_len = sizeof(snmp_int_val), snmp_int_val = paf->safi , (uint8_t *)&snmp_int_val); |
821 | else |
822 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
823 | case BGP4V2_NLRI_PREFIX_TYPE4: |
824 | if (paf) |
825 | return SNMP_INTEGER(paf->afi)(*var_len = sizeof(snmp_int_val), snmp_int_val = paf->afi, (uint8_t *)&snmp_int_val); |
826 | else |
827 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
828 | case BGP4V2_NLRI_PREFIX5: |
829 | if (prefix->family == AF_INET610) |
830 | return SNMP_IP6ADDRESS(prefix->u.prefix6)(*var_len = sizeof(struct in6_addr), (uint8_t *)&prefix-> u.prefix6); |
831 | else |
832 | return SNMP_IPADDRESS(prefix->u.prefix4)(*var_len = sizeof(struct in_addr), snmp_in_addr_val = prefix ->u.prefix4, (uint8_t *)&snmp_in_addr_val); |
833 | case BGP4V2_NLRI_PREFIX_LEN6: |
834 | return SNMP_INTEGER(prefix->prefixlen)(*var_len = sizeof(snmp_int_val), snmp_int_val = prefix->prefixlen , (uint8_t *)&snmp_int_val); |
835 | case BGP4V2_NLRI_BEST7: |
836 | if (CHECK_FLAG(path->flags, BGP_PATH_SELECTED)((path->flags) & ((1 << 3)))) |
837 | return SNMP_INTEGER(1)(*var_len = sizeof(snmp_int_val), snmp_int_val = 1, (uint8_t * )&snmp_int_val); |
838 | else |
839 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
840 | case BGP4V2_NLRI_CALC_LOCAL_PREF8: |
841 | if (CHECK_FLAG(path->attr->flag,((path->attr->flag) & (__builtin_choose_expr((5) >= 1 && (5) <= 64, 1ULL << ((5)-1), (void)0))) |
842 | ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))((path->attr->flag) & (__builtin_choose_expr((5) >= 1 && (5) <= 64, 1ULL << ((5)-1), (void)0)))) |
843 | return SNMP_INTEGER(path->attr->local_pref)(*var_len = sizeof(snmp_int_val), snmp_int_val = path->attr ->local_pref, (uint8_t *)&snmp_int_val); |
844 | else |
845 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
846 | case BGP4V2_NLRI_ORIGIN9: |
847 | switch (path->attr->origin) { |
848 | case BGP_ORIGIN_IGP0: |
849 | return SNMP_INTEGER(1)(*var_len = sizeof(snmp_int_val), snmp_int_val = 1, (uint8_t * )&snmp_int_val); |
850 | case BGP_ORIGIN_EGP1: |
851 | return SNMP_INTEGER(2)(*var_len = sizeof(snmp_int_val), snmp_int_val = 2, (uint8_t * )&snmp_int_val); |
852 | case BGP_ORIGIN_INCOMPLETE2: |
853 | return SNMP_INTEGER(3)(*var_len = sizeof(snmp_int_val), snmp_int_val = 3, (uint8_t * )&snmp_int_val); |
854 | default: |
855 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
856 | } |
857 | case BGP4V2_NLRI_NEXT_HOP_ADDR_TYPE10: |
858 | switch (path->attr->mp_nexthop_len) { |
859 | case BGP_ATTR_NHLEN_IPV44: |
860 | return SNMP_INTEGER(1)(*var_len = sizeof(snmp_int_val), snmp_int_val = 1, (uint8_t * )&snmp_int_val); |
861 | case BGP_ATTR_NHLEN_IPV6_GLOBAL16: |
862 | return SNMP_INTEGER(2)(*var_len = sizeof(snmp_int_val), snmp_int_val = 2, (uint8_t * )&snmp_int_val); |
863 | case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL(16 * 2): |
864 | if (path->attr->mp_nexthop_prefer_global) |
865 | return SNMP_INTEGER(2)(*var_len = sizeof(snmp_int_val), snmp_int_val = 2, (uint8_t * )&snmp_int_val); |
866 | else |
867 | return SNMP_INTEGER(4)(*var_len = sizeof(snmp_int_val), snmp_int_val = 4, (uint8_t * )&snmp_int_val); |
868 | default: |
869 | return SNMP_INTEGER(1)(*var_len = sizeof(snmp_int_val), snmp_int_val = 1, (uint8_t * )&snmp_int_val); |
870 | } |
871 | case BGP4V2_NLRI_NEXT_HOP_ADDR11: |
872 | switch (path->attr->mp_nexthop_len) { |
873 | case BGP_ATTR_NHLEN_IPV44: |
874 | return SNMP_IPADDRESS(path->attr->mp_nexthop_global_in)(*var_len = sizeof(struct in_addr), snmp_in_addr_val = path-> attr->mp_nexthop_global_in, (uint8_t *)&snmp_in_addr_val ); |
875 | case BGP_ATTR_NHLEN_IPV6_GLOBAL16: |
876 | return SNMP_IP6ADDRESS(path->attr->mp_nexthop_global)(*var_len = sizeof(struct in6_addr), (uint8_t *)&path-> attr->mp_nexthop_global); |
877 | case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL(16 * 2): |
878 | if (path->attr->mp_nexthop_prefer_global) |
879 | return SNMP_IP6ADDRESS((*var_len = sizeof(struct in6_addr), (uint8_t *)&path-> attr->mp_nexthop_global) |
880 | path->attr->mp_nexthop_global)(*var_len = sizeof(struct in6_addr), (uint8_t *)&path-> attr->mp_nexthop_global); |
881 | else |
882 | return SNMP_IP6ADDRESS((*var_len = sizeof(struct in6_addr), (uint8_t *)&path-> attr->mp_nexthop_local) |
883 | path->attr->mp_nexthop_local)(*var_len = sizeof(struct in6_addr), (uint8_t *)&path-> attr->mp_nexthop_local); |
884 | default: |
885 | return SNMP_IPADDRESS(path->attr->nexthop)(*var_len = sizeof(struct in_addr), snmp_in_addr_val = path-> attr->nexthop, (uint8_t *)&snmp_in_addr_val); |
886 | } |
887 | break; |
888 | case BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR_TYPE12: |
889 | case BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR13: |
890 | /* Not properly defined in specification what should be here. */ |
891 | break; |
892 | case BGP4V2_NLRI_LOCAL_PREF_PRESENT14: |
893 | if (CHECK_FLAG(path->attr->flag,((path->attr->flag) & (__builtin_choose_expr((5) >= 1 && (5) <= 64, 1ULL << ((5)-1), (void)0))) |
894 | ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))((path->attr->flag) & (__builtin_choose_expr((5) >= 1 && (5) <= 64, 1ULL << ((5)-1), (void)0)))) |
895 | return SNMP_INTEGER(1)(*var_len = sizeof(snmp_int_val), snmp_int_val = 1, (uint8_t * )&snmp_int_val); |
896 | else |
897 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
898 | case BGP4V2_NLRI_LOCAL_PREF15: |
899 | if (CHECK_FLAG(path->attr->flag,((path->attr->flag) & (__builtin_choose_expr((5) >= 1 && (5) <= 64, 1ULL << ((5)-1), (void)0))) |
900 | ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))((path->attr->flag) & (__builtin_choose_expr((5) >= 1 && (5) <= 64, 1ULL << ((5)-1), (void)0)))) |
901 | return SNMP_INTEGER(path->attr->local_pref)(*var_len = sizeof(snmp_int_val), snmp_int_val = path->attr ->local_pref, (uint8_t *)&snmp_int_val); |
902 | else |
903 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
904 | case BGP4V2_NLRI_MED_PRESENT16: |
905 | if (CHECK_FLAG(path->attr->flag,((path->attr->flag) & (__builtin_choose_expr((4) >= 1 && (4) <= 64, 1ULL << ((4)-1), (void)0))) |
906 | ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))((path->attr->flag) & (__builtin_choose_expr((4) >= 1 && (4) <= 64, 1ULL << ((4)-1), (void)0)))) |
907 | return SNMP_INTEGER(1)(*var_len = sizeof(snmp_int_val), snmp_int_val = 1, (uint8_t * )&snmp_int_val); |
908 | else |
909 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
910 | case BGP4V2_NLRI_MED17: |
911 | if (CHECK_FLAG(path->attr->flag,((path->attr->flag) & (__builtin_choose_expr((4) >= 1 && (4) <= 64, 1ULL << ((4)-1), (void)0))) |
912 | ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))((path->attr->flag) & (__builtin_choose_expr((4) >= 1 && (4) <= 64, 1ULL << ((4)-1), (void)0)))) |
913 | return SNMP_INTEGER(path->attr->med)(*var_len = sizeof(snmp_int_val), snmp_int_val = path->attr ->med, (uint8_t *)&snmp_int_val); |
914 | else |
915 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
916 | case BGP4V2_NLRI_ATOMIC_AGGREGATE18: |
917 | if (CHECK_FLAG(path->attr->flag,((path->attr->flag) & (__builtin_choose_expr((6) >= 1 && (6) <= 64, 1ULL << ((6)-1), (void)0))) |
918 | ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))((path->attr->flag) & (__builtin_choose_expr((6) >= 1 && (6) <= 64, 1ULL << ((6)-1), (void)0)))) |
919 | return SNMP_INTEGER(1)(*var_len = sizeof(snmp_int_val), snmp_int_val = 1, (uint8_t * )&snmp_int_val); |
920 | else |
921 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
922 | case BGP4V2_NLRI_AGGREGATOR_PRESENT19: |
923 | if (CHECK_FLAG(path->attr->flag,((path->attr->flag) & (__builtin_choose_expr((7) >= 1 && (7) <= 64, 1ULL << ((7)-1), (void)0))) |
924 | ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR))((path->attr->flag) & (__builtin_choose_expr((7) >= 1 && (7) <= 64, 1ULL << ((7)-1), (void)0)))) |
925 | return SNMP_INTEGER(1)(*var_len = sizeof(snmp_int_val), snmp_int_val = 1, (uint8_t * )&snmp_int_val); |
926 | else |
927 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
928 | case BGP4V2_NLRI_AGGREGATOR_AS20: |
929 | if (CHECK_FLAG(path->attr->flag,((path->attr->flag) & (__builtin_choose_expr((7) >= 1 && (7) <= 64, 1ULL << ((7)-1), (void)0))) |
930 | ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR))((path->attr->flag) & (__builtin_choose_expr((7) >= 1 && (7) <= 64, 1ULL << ((7)-1), (void)0)))) |
931 | return SNMP_INTEGER(path->attr->aggregator_as)(*var_len = sizeof(snmp_int_val), snmp_int_val = path->attr ->aggregator_as, (uint8_t *)&snmp_int_val); |
932 | else |
933 | return SNMP_INTEGER(0)(*var_len = sizeof(snmp_int_val), snmp_int_val = 0, (uint8_t * )&snmp_int_val); |
934 | case BGP4V2_NLRI_AGGREGATOR_ADDR21: |
935 | if (CHECK_FLAG(path->attr->flag,((path->attr->flag) & (__builtin_choose_expr((7) >= 1 && (7) <= 64, 1ULL << ((7)-1), (void)0))) |
936 | ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR))((path->attr->flag) & (__builtin_choose_expr((7) >= 1 && (7) <= 64, 1ULL << ((7)-1), (void)0)))) |
937 | return SNMP_IPADDRESS(path->attr->aggregator_addr)(*var_len = sizeof(struct in_addr), snmp_in_addr_val = path-> attr->aggregator_addr, (uint8_t *)&snmp_in_addr_val); |
938 | else |
939 | return SNMP_IPADDRESS(bgp_empty_addr)(*var_len = sizeof(struct in_addr), snmp_in_addr_val = bgp_empty_addr , (uint8_t *)&snmp_in_addr_val); |
940 | case BGP4V2_NLRI_AS_PATH_CALC_LENGTH22: |
941 | return SNMP_INTEGER(path->attr->aspath->segments->length)(*var_len = sizeof(snmp_int_val), snmp_int_val = path->attr ->aspath->segments->length, (uint8_t *)&snmp_int_val ); |
942 | case BGP4V2_NLRI_AS_PATH24: |
943 | return aspath_snmp_pathseg(path->attr->aspath, var_len); |
944 | case BGP4V2_NLRI_PATH_ATTR_UNKNOWN25: |
945 | *var_len = 0; |
946 | return NULL((void*)0); |
947 | } |
948 | return NULL((void*)0); |
949 | } |
950 | |
951 | /* BGP V2 Traps. */ |
952 | static struct trap_object bgpv2TrapEstListv4[] = { |
953 | { 6, { 1, 2, 1, BGP4V2_PEER_STATE13, 1, 1 } }, |
954 | { 6, { 1, 2, 1, BGP4V2_PEER_LOCAL_PORT6, 1, 1 } }, |
955 | { 6, { 1, 2, 1, BGP4V2_PEER_REMOTE_PORT9, 1, 1 } } |
956 | }; |
957 | |
958 | static struct trap_object bgpv2TrapEstListv6[] = { |
959 | { 6, { 1, 2, 1, BGP4V2_PEER_STATE13, 1, 2 } }, |
960 | { 6, { 1, 2, 1, BGP4V2_PEER_LOCAL_PORT6, 1, 2 } }, |
961 | { 6, { 1, 2, 1, BGP4V2_PEER_REMOTE_PORT9, 1, 2 } } |
962 | }; |
963 | |
964 | static struct trap_object bgpv2TrapBackListv4[] = { |
965 | { 6, { 1, 2, 1, BGP4V2_PEER_STATE13, 1, 1 } }, |
966 | { 6, { 1, 2, 1, BGP4V2_PEER_LOCAL_PORT6, 1, 1 } }, |
967 | { 6, { 1, 2, 1, BGP4V2_PEER_REMOTE_PORT9, 1, 1 } }, |
968 | { 6, { 1, 3, 1, BGP4V2_PEER_LAST_ERROR_CODE_RECEIVED1, 1, 1 } }, |
969 | { 6, { 1, 3, 1, BGP4V2_PEER_LAST_ERROR_SUBCODE_RECEIVED2, 1, 1 } }, |
970 | { 6, { 1, 3, 1, BGP4V2_PEER_LAST_ERROR_RECEIVED_TEXT4, 1, 1 } } |
971 | }; |
972 | |
973 | static struct trap_object bgpv2TrapBackListv6[] = { |
974 | { 6, { 1, 2, 1, BGP4V2_PEER_STATE13, 1, 2 } }, |
975 | { 6, { 1, 2, 1, BGP4V2_PEER_LOCAL_PORT6, 1, 2 } }, |
976 | { 6, { 1, 2, 1, BGP4V2_PEER_REMOTE_PORT9, 1, 2 } }, |
977 | { 6, { 1, 3, 1, BGP4V2_PEER_LAST_ERROR_CODE_RECEIVED1, 1, 2 } }, |
978 | { 6, { 1, 3, 1, BGP4V2_PEER_LAST_ERROR_SUBCODE_RECEIVED2, 1, 2 } }, |
979 | { 6, { 1, 3, 1, BGP4V2_PEER_LAST_ERROR_RECEIVED_TEXT4, 1, 2 } } |
980 | }; |
981 | |
982 | static struct variable bgpv2_variables[] = { |
983 | /* bgp4V2PeerEntry */ |
984 | {BGP4V2_PEER_INSTANCE1, |
985 | ASN_UNSIGNED(0x40U | 2), |
986 | RONLY0x1, |
987 | bgpv2PeerTable, |
988 | 6, |
989 | {1, 2, 1, BGP4V2_PEER_INSTANCE1, 1, 1}}, |
990 | {BGP4V2_PEER_INSTANCE1, |
991 | ASN_UNSIGNED(0x40U | 2), |
992 | RONLY0x1, |
993 | bgpv2PeerTable, |
994 | 6, |
995 | {1, 2, 1, BGP4V2_PEER_INSTANCE1, 1, 2}}, |
996 | {BGP4V2_PEER_LOCAL_ADDR_TYPE2, |
997 | ASN_INTEGER0x02U, |
998 | RONLY0x1, |
999 | bgpv2PeerTable, |
1000 | 6, |
1001 | {1, 2, 1, BGP4V2_PEER_LOCAL_ADDR_TYPE2, 1, 1}}, |
1002 | {BGP4V2_PEER_LOCAL_ADDR_TYPE2, |
1003 | ASN_INTEGER0x02U, |
1004 | RONLY0x1, |
1005 | bgpv2PeerTable, |
1006 | 6, |
1007 | {1, 2, 1, BGP4V2_PEER_LOCAL_ADDR_TYPE2, 1, 2}}, |
1008 | {BGP4V2_PEER_LOCAL_ADDR3, |
1009 | ASN_OCTET_STR0x04U, |
1010 | RONLY0x1, |
1011 | bgpv2PeerTable, |
1012 | 6, |
1013 | {1, 2, 1, BGP4V2_PEER_LOCAL_ADDR3, 1, 1}}, |
1014 | {BGP4V2_PEER_LOCAL_ADDR3, |
1015 | ASN_OCTET_STR0x04U, |
1016 | RONLY0x1, |
1017 | bgpv2PeerTable, |
1018 | 6, |
1019 | {1, 2, 1, BGP4V2_PEER_LOCAL_ADDR3, 1, 2}}, |
1020 | {BGP4V2_PEER_REMOTE_ADDR_TYPE4, |
1021 | ASN_INTEGER0x02U, |
1022 | RONLY0x1, |
1023 | bgpv2PeerTable, |
1024 | 6, |
1025 | {1, 2, 1, BGP4V2_PEER_REMOTE_ADDR_TYPE4, 1, 1}}, |
1026 | {BGP4V2_PEER_REMOTE_ADDR_TYPE4, |
1027 | ASN_INTEGER0x02U, |
1028 | RONLY0x1, |
1029 | bgpv2PeerTable, |
1030 | 6, |
1031 | {1, 2, 1, BGP4V2_PEER_REMOTE_ADDR_TYPE4, 1, 2}}, |
1032 | {BGP4V2_PEER_REMOTE_ADDR5, |
1033 | ASN_OCTET_STR0x04U, |
1034 | RONLY0x1, |
1035 | bgpv2PeerTable, |
1036 | 6, |
1037 | {1, 2, 1, BGP4V2_PEER_REMOTE_ADDR5, 1, 1}}, |
1038 | {BGP4V2_PEER_REMOTE_ADDR5, |
1039 | ASN_OCTET_STR0x04U, |
1040 | RONLY0x1, |
1041 | bgpv2PeerTable, |
1042 | 6, |
1043 | {1, 2, 1, BGP4V2_PEER_REMOTE_ADDR5, 1, 2}}, |
1044 | {BGP4V2_PEER_LOCAL_PORT6, |
1045 | ASN_UNSIGNED(0x40U | 2), |
1046 | RONLY0x1, |
1047 | bgpv2PeerTable, |
1048 | 6, |
1049 | {1, 2, 1, BGP4V2_PEER_LOCAL_PORT6, 1, 1}}, |
1050 | {BGP4V2_PEER_LOCAL_PORT6, |
1051 | ASN_UNSIGNED(0x40U | 2), |
1052 | RONLY0x1, |
1053 | bgpv2PeerTable, |
1054 | 6, |
1055 | {1, 2, 1, BGP4V2_PEER_LOCAL_PORT6, 1, 2}}, |
1056 | {BGP4V2_PEER_LOCAL_AS7, |
1057 | ASN_UNSIGNED(0x40U | 2), |
1058 | RONLY0x1, |
1059 | bgpv2PeerTable, |
1060 | 6, |
1061 | {1, 2, 1, BGP4V2_PEER_LOCAL_AS7, 1, 1}}, |
1062 | {BGP4V2_PEER_LOCAL_AS7, |
1063 | ASN_UNSIGNED(0x40U | 2), |
1064 | RONLY0x1, |
1065 | bgpv2PeerTable, |
1066 | 6, |
1067 | {1, 2, 1, BGP4V2_PEER_LOCAL_AS7, 1, 2}}, |
1068 | {BGP4V2_PEER_LOCAL_IDENTIFIER8, |
1069 | ASN_OCTET_STR0x04U, |
1070 | RONLY0x1, |
1071 | bgpv2PeerTable, |
1072 | 6, |
1073 | {1, 2, 1, BGP4V2_PEER_LOCAL_IDENTIFIER8, 1, 1}}, |
1074 | {BGP4V2_PEER_LOCAL_IDENTIFIER8, |
1075 | ASN_OCTET_STR0x04U, |
1076 | RONLY0x1, |
1077 | bgpv2PeerTable, |
1078 | 6, |
1079 | {1, 2, 1, BGP4V2_PEER_LOCAL_IDENTIFIER8, 1, 2}}, |
1080 | {BGP4V2_PEER_REMOTE_PORT9, |
1081 | ASN_UNSIGNED(0x40U | 2), |
1082 | RONLY0x1, |
1083 | bgpv2PeerTable, |
1084 | 6, |
1085 | {1, 2, 1, BGP4V2_PEER_REMOTE_PORT9, 1, 1}}, |
1086 | {BGP4V2_PEER_REMOTE_PORT9, |
1087 | ASN_UNSIGNED(0x40U | 2), |
1088 | RONLY0x1, |
1089 | bgpv2PeerTable, |
1090 | 6, |
1091 | {1, 2, 1, BGP4V2_PEER_REMOTE_PORT9, 1, 2}}, |
1092 | {BGP4V2_PEER_REMOTE_AS10, |
1093 | ASN_UNSIGNED(0x40U | 2), |
1094 | RONLY0x1, |
1095 | bgpv2PeerTable, |
1096 | 6, |
1097 | {1, 2, 1, BGP4V2_PEER_REMOTE_AS10, 1, 1}}, |
1098 | {BGP4V2_PEER_REMOTE_AS10, |
1099 | ASN_UNSIGNED(0x40U | 2), |
1100 | RONLY0x1, |
1101 | bgpv2PeerTable, |
1102 | 6, |
1103 | {1, 2, 1, BGP4V2_PEER_REMOTE_AS10, 1, 2}}, |
1104 | {BGP4V2_PEER_REMOTE_IDENTIFIER11, |
1105 | ASN_OCTET_STR0x04U, |
1106 | RONLY0x1, |
1107 | bgpv2PeerTable, |
1108 | 6, |
1109 | {1, 2, 1, BGP4V2_PEER_REMOTE_IDENTIFIER11, 1, 1}}, |
1110 | {BGP4V2_PEER_REMOTE_IDENTIFIER11, |
1111 | ASN_OCTET_STR0x04U, |
1112 | RONLY0x1, |
1113 | bgpv2PeerTable, |
1114 | 6, |
1115 | {1, 2, 1, BGP4V2_PEER_REMOTE_IDENTIFIER11, 1, 2}}, |
1116 | {BGP4V2_PEER_ADMIN_STATUS12, |
1117 | ASN_INTEGER0x02U, |
1118 | RONLY0x1, |
1119 | bgpv2PeerTable, |
1120 | 6, |
1121 | {1, 2, 1, BGP4V2_PEER_ADMIN_STATUS12, 1, 1}}, |
1122 | {BGP4V2_PEER_ADMIN_STATUS12, |
1123 | ASN_INTEGER0x02U, |
1124 | RONLY0x1, |
1125 | bgpv2PeerTable, |
1126 | 6, |
1127 | {1, 2, 1, BGP4V2_PEER_ADMIN_STATUS12, 1, 2}}, |
1128 | {BGP4V2_PEER_STATE13, |
1129 | ASN_INTEGER0x02U, |
1130 | RONLY0x1, |
1131 | bgpv2PeerTable, |
1132 | 6, |
1133 | {1, 2, 1, BGP4V2_PEER_STATE13, 1, 1}}, |
1134 | {BGP4V2_PEER_STATE13, |
1135 | ASN_INTEGER0x02U, |
1136 | RONLY0x1, |
1137 | bgpv2PeerTable, |
1138 | 6, |
1139 | {1, 2, 1, BGP4V2_PEER_STATE13, 1, 2}}, |
1140 | {BGP4V2_PEER_DESCRIPTION14, |
1141 | ASN_OCTET_STR0x04U, |
1142 | RONLY0x1, |
1143 | bgpv2PeerTable, |
1144 | 6, |
1145 | {1, 2, 1, BGP4V2_PEER_DESCRIPTION14, 1, 1}}, |
1146 | {BGP4V2_PEER_DESCRIPTION14, |
1147 | ASN_OCTET_STR0x04U, |
1148 | RONLY0x1, |
1149 | bgpv2PeerTable, |
1150 | 6, |
1151 | {1, 2, 1, BGP4V2_PEER_DESCRIPTION14, 1, 2}}, |
1152 | /* bgp4V2PeerErrorsEntry */ |
1153 | {BGP4V2_PEER_LAST_ERROR_CODE_RECEIVED1, |
1154 | ASN_UNSIGNED(0x40U | 2), |
1155 | RONLY0x1, |
1156 | bgpv2PeerErrorsTable, |
1157 | 6, |
1158 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_CODE_RECEIVED1, 1, 1}}, |
1159 | {BGP4V2_PEER_LAST_ERROR_CODE_RECEIVED1, |
1160 | ASN_UNSIGNED(0x40U | 2), |
1161 | RONLY0x1, |
1162 | bgpv2PeerErrorsTable, |
1163 | 6, |
1164 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_CODE_RECEIVED1, 1, 2}}, |
1165 | {BGP4V2_PEER_LAST_ERROR_SUBCODE_RECEIVED2, |
1166 | ASN_UNSIGNED(0x40U | 2), |
1167 | RONLY0x1, |
1168 | bgpv2PeerErrorsTable, |
1169 | 6, |
1170 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_SUBCODE_RECEIVED2, 1, 1}}, |
1171 | {BGP4V2_PEER_LAST_ERROR_SUBCODE_RECEIVED2, |
1172 | ASN_UNSIGNED(0x40U | 2), |
1173 | RONLY0x1, |
1174 | bgpv2PeerErrorsTable, |
1175 | 6, |
1176 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_SUBCODE_RECEIVED2, 1, 2}}, |
1177 | {BGP4V2_PEER_LAST_ERROR_RECEIVED_TIME3, |
1178 | ASN_TIMETICKS(0x40U | 3), |
1179 | RONLY0x1, |
1180 | bgpv2PeerErrorsTable, |
1181 | 6, |
1182 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_RECEIVED_TIME3, 1, 1}}, |
1183 | {BGP4V2_PEER_LAST_ERROR_RECEIVED_TIME3, |
1184 | ASN_TIMETICKS(0x40U | 3), |
1185 | RONLY0x1, |
1186 | bgpv2PeerErrorsTable, |
1187 | 6, |
1188 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_RECEIVED_TIME3, 1, 2}}, |
1189 | {BGP4V2_PEER_LAST_ERROR_RECEIVED_TEXT4, |
1190 | ASN_OCTET_STR0x04U, |
1191 | RONLY0x1, |
1192 | bgpv2PeerErrorsTable, |
1193 | 6, |
1194 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_RECEIVED_TEXT4, 1, 1}}, |
1195 | {BGP4V2_PEER_LAST_ERROR_RECEIVED_TEXT4, |
1196 | ASN_OCTET_STR0x04U, |
1197 | RONLY0x1, |
1198 | bgpv2PeerErrorsTable, |
1199 | 6, |
1200 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_RECEIVED_TEXT4, 1, 2}}, |
1201 | {BGP4V2_PEER_LAST_ERROR_RECEIVED_DATA5, |
1202 | ASN_OCTET_STR0x04U, |
1203 | RONLY0x1, |
1204 | bgpv2PeerErrorsTable, |
1205 | 6, |
1206 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_RECEIVED_DATA5, 1, 1}}, |
1207 | {BGP4V2_PEER_LAST_ERROR_RECEIVED_DATA5, |
1208 | ASN_OCTET_STR0x04U, |
1209 | RONLY0x1, |
1210 | bgpv2PeerErrorsTable, |
1211 | 6, |
1212 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_RECEIVED_DATA5, 1, 2}}, |
1213 | {BGP4V2_PEER_LAST_ERROR_CODE_SENT6, |
1214 | ASN_UNSIGNED(0x40U | 2), |
1215 | RONLY0x1, |
1216 | bgpv2PeerErrorsTable, |
1217 | 6, |
1218 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_CODE_SENT6, 1, 1}}, |
1219 | {BGP4V2_PEER_LAST_ERROR_CODE_SENT6, |
1220 | ASN_UNSIGNED(0x40U | 2), |
1221 | RONLY0x1, |
1222 | bgpv2PeerErrorsTable, |
1223 | 6, |
1224 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_CODE_SENT6, 1, 2}}, |
1225 | {BGP4V2_PEER_LAST_ERROR_SUBCODE_SENT7, |
1226 | ASN_UNSIGNED(0x40U | 2), |
1227 | RONLY0x1, |
1228 | bgpv2PeerErrorsTable, |
1229 | 6, |
1230 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_SUBCODE_SENT7, 1, 1}}, |
1231 | {BGP4V2_PEER_LAST_ERROR_SUBCODE_SENT7, |
1232 | ASN_UNSIGNED(0x40U | 2), |
1233 | RONLY0x1, |
1234 | bgpv2PeerErrorsTable, |
1235 | 6, |
1236 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_SUBCODE_SENT7, 1, 2}}, |
1237 | {BGP4V2_PEER_LAST_ERROR_SENT_TIME8, |
1238 | ASN_TIMETICKS(0x40U | 3), |
1239 | RONLY0x1, |
1240 | bgpv2PeerErrorsTable, |
1241 | 6, |
1242 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_SENT_TIME8, 1, 1}}, |
1243 | {BGP4V2_PEER_LAST_ERROR_SENT_TIME8, |
1244 | ASN_TIMETICKS(0x40U | 3), |
1245 | RONLY0x1, |
1246 | bgpv2PeerErrorsTable, |
1247 | 6, |
1248 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_SENT_TIME8, 1, 2}}, |
1249 | {BGP4V2_PEER_LAST_ERROR_SENT_TEXT9, |
1250 | ASN_OCTET_STR0x04U, |
1251 | RONLY0x1, |
1252 | bgpv2PeerErrorsTable, |
1253 | 6, |
1254 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_SENT_TEXT9, 1, 1}}, |
1255 | {BGP4V2_PEER_LAST_ERROR_SENT_TEXT9, |
1256 | ASN_OCTET_STR0x04U, |
1257 | RONLY0x1, |
1258 | bgpv2PeerErrorsTable, |
1259 | 6, |
1260 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_SENT_TEXT9, 1, 2}}, |
1261 | {BGP4V2_PEER_LAST_ERROR_SENT_DATA10, |
1262 | ASN_OCTET_STR0x04U, |
1263 | RONLY0x1, |
1264 | bgpv2PeerErrorsTable, |
1265 | 6, |
1266 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_SENT_DATA10, 1, 1}}, |
1267 | {BGP4V2_PEER_LAST_ERROR_SENT_DATA10, |
1268 | ASN_OCTET_STR0x04U, |
1269 | RONLY0x1, |
1270 | bgpv2PeerErrorsTable, |
1271 | 6, |
1272 | {1, 3, 1, BGP4V2_PEER_LAST_ERROR_SENT_DATA10, 1, 2}}, |
1273 | /* bgp4V2PeerEventTimesEntry */ |
1274 | {BGP4V2_PEER_FSM_ESTABLISHED_TIME1, |
1275 | ASN_UNSIGNED(0x40U | 2), |
1276 | RONLY0x1, |
1277 | bgpv2PeerEventTimesTable, |
1278 | 6, |
1279 | {1, 4, 1, BGP4V2_PEER_FSM_ESTABLISHED_TIME1, 1, 1}}, |
1280 | {BGP4V2_PEER_FSM_ESTABLISHED_TIME1, |
1281 | ASN_UNSIGNED(0x40U | 2), |
1282 | RONLY0x1, |
1283 | bgpv2PeerEventTimesTable, |
1284 | 6, |
1285 | {1, 4, 1, BGP4V2_PEER_FSM_ESTABLISHED_TIME1, 1, 2}}, |
1286 | {BGP4V2_PEER_PEER_IN_UPDATES_ELAPSED_TIME2, |
1287 | ASN_UNSIGNED(0x40U | 2), |
1288 | RONLY0x1, |
1289 | bgpv2PeerEventTimesTable, |
1290 | 6, |
1291 | {1, 4, 1, BGP4V2_PEER_PEER_IN_UPDATES_ELAPSED_TIME2, 1, 1}}, |
1292 | {BGP4V2_PEER_PEER_IN_UPDATES_ELAPSED_TIME2, |
1293 | ASN_UNSIGNED(0x40U | 2), |
1294 | RONLY0x1, |
1295 | bgpv2PeerEventTimesTable, |
1296 | 6, |
1297 | {1, 4, 1, BGP4V2_PEER_PEER_IN_UPDATES_ELAPSED_TIME2, 1, 2}}, |
1298 | /* bgp4V2NlriTable */ |
1299 | {BGP4V2_NLRI_INDEX1, |
1300 | ASN_UNSIGNED(0x40U | 2), |
1301 | RONLY0x1, |
1302 | bgp4v2PathAttrTable, |
1303 | 6, |
1304 | {1, 9, 1, BGP4V2_NLRI_INDEX1, 1, 1}}, |
1305 | {BGP4V2_NLRI_INDEX1, |
1306 | ASN_UNSIGNED(0x40U | 2), |
1307 | RONLY0x1, |
1308 | bgp4v2PathAttrTable, |
1309 | 6, |
1310 | {1, 9, 1, BGP4V2_NLRI_INDEX1, 1, 2}}, |
1311 | {BGP4V2_NLRI_AFI2, |
1312 | ASN_INTEGER0x02U, |
1313 | RONLY0x1, |
1314 | bgp4v2PathAttrTable, |
1315 | 6, |
1316 | {1, 9, 1, BGP4V2_NLRI_AFI2, 1, 1}}, |
1317 | {BGP4V2_NLRI_AFI2, |
1318 | ASN_INTEGER0x02U, |
1319 | RONLY0x1, |
1320 | bgp4v2PathAttrTable, |
1321 | 6, |
1322 | {1, 9, 1, BGP4V2_NLRI_AFI2, 1, 2}}, |
1323 | {BGP4V2_NLRI_SAFI3, |
1324 | ASN_INTEGER0x02U, |
1325 | RONLY0x1, |
1326 | bgp4v2PathAttrTable, |
1327 | 6, |
1328 | {1, 9, 1, BGP4V2_NLRI_SAFI3, 1, 1}}, |
1329 | {BGP4V2_NLRI_SAFI3, |
1330 | ASN_INTEGER0x02U, |
1331 | RONLY0x1, |
1332 | bgp4v2PathAttrTable, |
1333 | 6, |
1334 | {1, 9, 1, BGP4V2_NLRI_SAFI3, 1, 2}}, |
1335 | {BGP4V2_NLRI_PREFIX_TYPE4, |
1336 | ASN_INTEGER0x02U, |
1337 | RONLY0x1, |
1338 | bgp4v2PathAttrTable, |
1339 | 6, |
1340 | {1, 9, 1, BGP4V2_NLRI_PREFIX_TYPE4, 1, 1}}, |
1341 | {BGP4V2_NLRI_PREFIX_TYPE4, |
1342 | ASN_INTEGER0x02U, |
1343 | RONLY0x1, |
1344 | bgp4v2PathAttrTable, |
1345 | 6, |
1346 | {1, 9, 1, BGP4V2_NLRI_PREFIX_TYPE4, 1, 2}}, |
1347 | {BGP4V2_NLRI_PREFIX5, |
1348 | ASN_OCTET_STR0x04U, |
1349 | RONLY0x1, |
1350 | bgp4v2PathAttrTable, |
1351 | 6, |
1352 | {1, 9, 1, BGP4V2_NLRI_PREFIX5, 1, 1}}, |
1353 | {BGP4V2_NLRI_PREFIX5, |
1354 | ASN_OCTET_STR0x04U, |
1355 | RONLY0x1, |
1356 | bgp4v2PathAttrTable, |
1357 | 6, |
1358 | {1, 9, 1, BGP4V2_NLRI_PREFIX5, 1, 2}}, |
1359 | {BGP4V2_NLRI_PREFIX_LEN6, |
1360 | ASN_UNSIGNED(0x40U | 2), |
1361 | RONLY0x1, |
1362 | bgp4v2PathAttrTable, |
1363 | 6, |
1364 | {1, 9, 1, BGP4V2_NLRI_PREFIX_LEN6, 1, 1}}, |
1365 | {BGP4V2_NLRI_PREFIX_LEN6, |
1366 | ASN_UNSIGNED(0x40U | 2), |
1367 | RONLY0x1, |
1368 | bgp4v2PathAttrTable, |
1369 | 6, |
1370 | {1, 9, 1, BGP4V2_NLRI_PREFIX_LEN6, 1, 2}}, |
1371 | {BGP4V2_NLRI_BEST7, |
1372 | ASN_INTEGER0x02U, |
1373 | RONLY0x1, |
1374 | bgp4v2PathAttrTable, |
1375 | 6, |
1376 | {1, 9, 1, BGP4V2_NLRI_BEST7, 1, 1}}, |
1377 | {BGP4V2_NLRI_BEST7, |
1378 | ASN_INTEGER0x02U, |
1379 | RONLY0x1, |
1380 | bgp4v2PathAttrTable, |
1381 | 6, |
1382 | {1, 9, 1, BGP4V2_NLRI_BEST7, 1, 2}}, |
1383 | {BGP4V2_NLRI_CALC_LOCAL_PREF8, |
1384 | ASN_UNSIGNED(0x40U | 2), |
1385 | RONLY0x1, |
1386 | bgp4v2PathAttrTable, |
1387 | 6, |
1388 | {1, 9, 1, BGP4V2_NLRI_CALC_LOCAL_PREF8, 1, 1}}, |
1389 | {BGP4V2_NLRI_CALC_LOCAL_PREF8, |
1390 | ASN_UNSIGNED(0x40U | 2), |
1391 | RONLY0x1, |
1392 | bgp4v2PathAttrTable, |
1393 | 6, |
1394 | {1, 9, 1, BGP4V2_NLRI_CALC_LOCAL_PREF8, 1, 2}}, |
1395 | {BGP4V2_NLRI_ORIGIN9, |
1396 | ASN_INTEGER0x02U, |
1397 | RONLY0x1, |
1398 | bgp4v2PathAttrTable, |
1399 | 6, |
1400 | {1, 9, 1, BGP4V2_NLRI_ORIGIN9, 1, 1}}, |
1401 | {BGP4V2_NLRI_ORIGIN9, |
1402 | ASN_INTEGER0x02U, |
1403 | RONLY0x1, |
1404 | bgp4v2PathAttrTable, |
1405 | 6, |
1406 | {1, 9, 1, BGP4V2_NLRI_ORIGIN9, 1, 2}}, |
1407 | {BGP4V2_NLRI_NEXT_HOP_ADDR_TYPE10, |
1408 | ASN_INTEGER0x02U, |
1409 | RONLY0x1, |
1410 | bgp4v2PathAttrTable, |
1411 | 6, |
1412 | {1, 9, 1, BGP4V2_NLRI_NEXT_HOP_ADDR_TYPE10, 1, 1}}, |
1413 | {BGP4V2_NLRI_NEXT_HOP_ADDR_TYPE10, |
1414 | ASN_INTEGER0x02U, |
1415 | RONLY0x1, |
1416 | bgp4v2PathAttrTable, |
1417 | 6, |
1418 | {1, 9, 1, BGP4V2_NLRI_NEXT_HOP_ADDR_TYPE10, 1, 2}}, |
1419 | {BGP4V2_NLRI_NEXT_HOP_ADDR11, |
1420 | ASN_OCTET_STR0x04U, |
1421 | RONLY0x1, |
1422 | bgp4v2PathAttrTable, |
1423 | 6, |
1424 | {1, 9, 1, BGP4V2_NLRI_NEXT_HOP_ADDR11, 1, 1}}, |
1425 | {BGP4V2_NLRI_NEXT_HOP_ADDR11, |
1426 | ASN_OCTET_STR0x04U, |
1427 | RONLY0x1, |
1428 | bgp4v2PathAttrTable, |
1429 | 6, |
1430 | {1, 9, 1, BGP4V2_NLRI_NEXT_HOP_ADDR11, 1, 2}}, |
1431 | {BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR_TYPE12, |
1432 | ASN_INTEGER0x02U, |
1433 | RONLY0x1, |
1434 | bgp4v2PathAttrTable, |
1435 | 6, |
1436 | {1, 9, 1, BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR_TYPE12, 1, 1}}, |
1437 | {BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR_TYPE12, |
1438 | ASN_INTEGER0x02U, |
1439 | RONLY0x1, |
1440 | bgp4v2PathAttrTable, |
1441 | 6, |
1442 | {1, 9, 1, BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR_TYPE12, 1, 2}}, |
1443 | {BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR13, |
1444 | ASN_OCTET_STR0x04U, |
1445 | RONLY0x1, |
1446 | bgp4v2PathAttrTable, |
1447 | 6, |
1448 | {1, 9, 1, BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR13, 1, 1}}, |
1449 | {BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR13, |
1450 | ASN_OCTET_STR0x04U, |
1451 | RONLY0x1, |
1452 | bgp4v2PathAttrTable, |
1453 | 6, |
1454 | {1, 9, 1, BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR13, 1, 2}}, |
1455 | {BGP4V2_NLRI_LOCAL_PREF_PRESENT14, |
1456 | ASN_INTEGER0x02U, |
1457 | RONLY0x1, |
1458 | bgp4v2PathAttrTable, |
1459 | 6, |
1460 | {1, 9, 1, BGP4V2_NLRI_LOCAL_PREF_PRESENT14, 1, 1}}, |
1461 | {BGP4V2_NLRI_LOCAL_PREF_PRESENT14, |
1462 | ASN_INTEGER0x02U, |
1463 | RONLY0x1, |
1464 | bgp4v2PathAttrTable, |
1465 | 6, |
1466 | {1, 9, 1, BGP4V2_NLRI_LOCAL_PREF_PRESENT14, 1, 2}}, |
1467 | {BGP4V2_NLRI_LOCAL_PREF15, |
1468 | ASN_UNSIGNED(0x40U | 2), |
1469 | RONLY0x1, |
1470 | bgp4v2PathAttrTable, |
1471 | 6, |
1472 | {1, 9, 1, BGP4V2_NLRI_LOCAL_PREF15, 1, 1}}, |
1473 | {BGP4V2_NLRI_LOCAL_PREF15, |
1474 | ASN_UNSIGNED(0x40U | 2), |
1475 | RONLY0x1, |
1476 | bgp4v2PathAttrTable, |
1477 | 6, |
1478 | {1, 9, 1, BGP4V2_NLRI_LOCAL_PREF15, 1, 2}}, |
1479 | {BGP4V2_NLRI_MED_PRESENT16, |
1480 | ASN_INTEGER0x02U, |
1481 | RONLY0x1, |
1482 | bgp4v2PathAttrTable, |
1483 | 6, |
1484 | {1, 9, 1, BGP4V2_NLRI_MED_PRESENT16, 1, 1}}, |
1485 | {BGP4V2_NLRI_MED_PRESENT16, |
1486 | ASN_INTEGER0x02U, |
1487 | RONLY0x1, |
1488 | bgp4v2PathAttrTable, |
1489 | 6, |
1490 | {1, 9, 1, BGP4V2_NLRI_MED_PRESENT16, 1, 2}}, |
1491 | {BGP4V2_NLRI_MED17, |
1492 | ASN_UNSIGNED(0x40U | 2), |
1493 | RONLY0x1, |
1494 | bgp4v2PathAttrTable, |
1495 | 6, |
1496 | {1, 9, 1, BGP4V2_NLRI_MED17, 1, 1}}, |
1497 | {BGP4V2_NLRI_MED17, |
1498 | ASN_UNSIGNED(0x40U | 2), |
1499 | RONLY0x1, |
1500 | bgp4v2PathAttrTable, |
1501 | 6, |
1502 | {1, 9, 1, BGP4V2_NLRI_MED17, 1, 2}}, |
1503 | {BGP4V2_NLRI_ATOMIC_AGGREGATE18, |
1504 | ASN_INTEGER0x02U, |
1505 | RONLY0x1, |
1506 | bgp4v2PathAttrTable, |
1507 | 6, |
1508 | {1, 9, 1, BGP4V2_NLRI_ATOMIC_AGGREGATE18, 1, 1}}, |
1509 | {BGP4V2_NLRI_ATOMIC_AGGREGATE18, |
1510 | ASN_INTEGER0x02U, |
1511 | RONLY0x1, |
1512 | bgp4v2PathAttrTable, |
1513 | 6, |
1514 | {1, 9, 1, BGP4V2_NLRI_ATOMIC_AGGREGATE18, 1, 2}}, |
1515 | {BGP4V2_NLRI_AGGREGATOR_PRESENT19, |
1516 | ASN_INTEGER0x02U, |
1517 | RONLY0x1, |
1518 | bgp4v2PathAttrTable, |
1519 | 6, |
1520 | {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_PRESENT19, 1, 1}}, |
1521 | {BGP4V2_NLRI_AGGREGATOR_PRESENT19, |
1522 | ASN_INTEGER0x02U, |
1523 | RONLY0x1, |
1524 | bgp4v2PathAttrTable, |
1525 | 6, |
1526 | {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_PRESENT19, 1, 2}}, |
1527 | {BGP4V2_NLRI_AGGREGATOR_AS20, |
1528 | ASN_UNSIGNED(0x40U | 2), |
1529 | RONLY0x1, |
1530 | bgp4v2PathAttrTable, |
1531 | 6, |
1532 | {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_AS20, 1, 1}}, |
1533 | {BGP4V2_NLRI_AGGREGATOR_AS20, |
1534 | ASN_UNSIGNED(0x40U | 2), |
1535 | RONLY0x1, |
1536 | bgp4v2PathAttrTable, |
1537 | 6, |
1538 | {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_AS20, 1, 2}}, |
1539 | {BGP4V2_NLRI_AGGREGATOR_ADDR21, |
1540 | ASN_OCTET_STR0x04U, |
1541 | RONLY0x1, |
1542 | bgp4v2PathAttrTable, |
1543 | 6, |
1544 | {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_ADDR21, 1, 1}}, |
1545 | {BGP4V2_NLRI_AGGREGATOR_ADDR21, |
1546 | ASN_OCTET_STR0x04U, |
1547 | RONLY0x1, |
1548 | bgp4v2PathAttrTable, |
1549 | 6, |
1550 | {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_ADDR21, 1, 2}}, |
1551 | {BGP4V2_NLRI_AS_PATH_CALC_LENGTH22, |
1552 | ASN_UNSIGNED(0x40U | 2), |
1553 | RONLY0x1, |
1554 | bgp4v2PathAttrTable, |
1555 | 6, |
1556 | {1, 9, 1, BGP4V2_NLRI_AS_PATH_CALC_LENGTH22, 1, 1}}, |
1557 | {BGP4V2_NLRI_AS_PATH_CALC_LENGTH22, |
1558 | ASN_UNSIGNED(0x40U | 2), |
1559 | RONLY0x1, |
1560 | bgp4v2PathAttrTable, |
1561 | 6, |
1562 | {1, 9, 1, BGP4V2_NLRI_AS_PATH_CALC_LENGTH22, 1, 2}}, |
1563 | {BGP4V2_NLRI_AS_PATH_STRING23, |
1564 | ASN_OCTET_STR0x04U, |
1565 | RONLY0x1, |
1566 | bgp4v2PathAttrTable, |
1567 | 6, |
1568 | {1, 9, 1, BGP4V2_NLRI_AS_PATH_STRING23, 1, 1}}, |
1569 | {BGP4V2_NLRI_AS_PATH_STRING23, |
1570 | ASN_OCTET_STR0x04U, |
1571 | RONLY0x1, |
1572 | bgp4v2PathAttrTable, |
1573 | 6, |
1574 | {1, 9, 1, BGP4V2_NLRI_AS_PATH_STRING23, 1, 2}}, |
1575 | {BGP4V2_NLRI_AS_PATH24, |
1576 | ASN_OCTET_STR0x04U, |
1577 | RONLY0x1, |
1578 | bgp4v2PathAttrTable, |
1579 | 6, |
1580 | {1, 9, 1, BGP4V2_NLRI_AS_PATH24, 1, 1}}, |
1581 | {BGP4V2_NLRI_AS_PATH24, |
1582 | ASN_OCTET_STR0x04U, |
1583 | RONLY0x1, |
1584 | bgp4v2PathAttrTable, |
1585 | 6, |
1586 | {1, 9, 1, BGP4V2_NLRI_AS_PATH24, 1, 2}}, |
1587 | {BGP4V2_NLRI_PATH_ATTR_UNKNOWN25, |
1588 | ASN_OCTET_STR0x04U, |
1589 | RONLY0x1, |
1590 | bgp4v2PathAttrTable, |
1591 | 6, |
1592 | {1, 9, 1, BGP4V2_NLRI_PATH_ATTR_UNKNOWN25, 1, 1}}, |
1593 | {BGP4V2_NLRI_PATH_ATTR_UNKNOWN25, |
1594 | ASN_OCTET_STR0x04U, |
1595 | RONLY0x1, |
1596 | bgp4v2PathAttrTable, |
1597 | 6, |
1598 | {1, 9, 1, BGP4V2_NLRI_PATH_ATTR_UNKNOWN25, 1, 2}}, |
1599 | }; |
1600 | |
1601 | int bgpv2TrapEstablished(struct peer *peer) |
1602 | { |
1603 | oid index[sizeof(oid) * IN6_ADDR_SIZEsizeof(struct in6_addr)]; |
1604 | size_t length; |
1605 | |
1606 | if (!CHECK_FLAG(bm->options, BGP_OPT_TRAPS_BGP4MIBV2)((bm->options) & ((1 << 4)))) |
1607 | return 0; |
1608 | |
1609 | /* Check if this peer just went to Established */ |
1610 | if ((peer->connection->ostatus != OpenConfirm) || |
1611 | !(peer_established(peer->connection))) |
1612 | return 0; |
1613 | |
1614 | switch (sockunion_family(&peer->connection->su)(&peer->connection->su)->sa.sa_family) { |
1615 | case AF_INET2: |
1616 | oid_copy_in_addr(index, &peer->connection->su.sin.sin_addr); |
1617 | length = IN_ADDR_SIZEsizeof(struct in_addr); |
1618 | smux_trap(bgpv2_variables, array_size(bgpv2_variables)(sizeof(bgpv2_variables) / sizeof(bgpv2_variables[0])), |
1619 | bgpv2_trap_oid, array_size(bgpv2_trap_oid)(sizeof(bgpv2_trap_oid) / sizeof(bgpv2_trap_oid[0])), bgpv2_oid, |
1620 | sizeof(bgpv2_oid) / sizeof(oid), index, length, |
1621 | bgpv2TrapEstListv4, array_size(bgpv2TrapEstListv4)(sizeof(bgpv2TrapEstListv4) / sizeof(bgpv2TrapEstListv4[0])), |
1622 | BGP4V2ESTABLISHED1); |
1623 | break; |
1624 | case AF_INET610: |
1625 | oid_copy_in6_addr(index, &peer->connection->su.sin6.sin6_addr); |
1626 | length = IN6_ADDR_SIZEsizeof(struct in6_addr); |
1627 | smux_trap(bgpv2_variables, array_size(bgpv2_variables)(sizeof(bgpv2_variables) / sizeof(bgpv2_variables[0])), |
1628 | bgpv2_trap_oid, array_size(bgpv2_trap_oid)(sizeof(bgpv2_trap_oid) / sizeof(bgpv2_trap_oid[0])), bgpv2_oid, |
1629 | sizeof(bgpv2_oid) / sizeof(oid), index, length, |
1630 | bgpv2TrapEstListv6, array_size(bgpv2TrapEstListv6)(sizeof(bgpv2TrapEstListv6) / sizeof(bgpv2TrapEstListv6[0])), |
1631 | BGP4V2ESTABLISHED1); |
1632 | break; |
1633 | default: |
1634 | break; |
1635 | } |
1636 | |
1637 | return 0; |
1638 | } |
1639 | |
1640 | int bgpv2TrapBackwardTransition(struct peer *peer) |
1641 | { |
1642 | oid index[sizeof(oid) * IN6_ADDR_SIZEsizeof(struct in6_addr)]; |
1643 | size_t length; |
1644 | |
1645 | if (!CHECK_FLAG(bm->options, BGP_OPT_TRAPS_BGP4MIBV2)((bm->options) & ((1 << 4)))) |
1646 | return 0; |
1647 | |
1648 | switch (sockunion_family(&peer->connection->su)(&peer->connection->su)->sa.sa_family) { |
1649 | case AF_INET2: |
1650 | oid_copy_in_addr(index, &peer->connection->su.sin.sin_addr); |
1651 | length = IN_ADDR_SIZEsizeof(struct in_addr); |
1652 | smux_trap(bgpv2_variables, array_size(bgpv2_variables)(sizeof(bgpv2_variables) / sizeof(bgpv2_variables[0])), |
1653 | bgpv2_trap_oid, array_size(bgpv2_trap_oid)(sizeof(bgpv2_trap_oid) / sizeof(bgpv2_trap_oid[0])), bgpv2_oid, |
1654 | sizeof(bgpv2_oid) / sizeof(oid), index, length, |
1655 | bgpv2TrapBackListv4, array_size(bgpv2TrapBackListv4)(sizeof(bgpv2TrapBackListv4) / sizeof(bgpv2TrapBackListv4[0]) ), |
1656 | BGP4V2BACKWARDTRANSITION2); |
1657 | break; |
1658 | case AF_INET610: |
1659 | oid_copy_in6_addr(index, &peer->connection->su.sin6.sin6_addr); |
1660 | length = IN6_ADDR_SIZEsizeof(struct in6_addr); |
1661 | smux_trap(bgpv2_variables, array_size(bgpv2_variables)(sizeof(bgpv2_variables) / sizeof(bgpv2_variables[0])), |
1662 | bgpv2_trap_oid, array_size(bgpv2_trap_oid)(sizeof(bgpv2_trap_oid) / sizeof(bgpv2_trap_oid[0])), bgpv2_oid, |
1663 | sizeof(bgpv2_oid) / sizeof(oid), index, length, |
1664 | bgpv2TrapBackListv6, array_size(bgpv2TrapBackListv6)(sizeof(bgpv2TrapBackListv6) / sizeof(bgpv2TrapBackListv6[0]) ), |
1665 | BGP4V2BACKWARDTRANSITION2); |
1666 | break; |
1667 | default: |
1668 | break; |
1669 | } |
1670 | |
1671 | return 0; |
1672 | } |
1673 | |
1674 | int bgp_snmp_bgp4v2_init(struct event_loop *tm) |
1675 | { |
1676 | REGISTER_MIB("mibII/bgpv2", bgpv2_variables, variable, bgpv2_oid)smux_register_mib("mibII/bgpv2", (struct variable *)bgpv2_variables , sizeof(struct variable), sizeof(bgpv2_variables) / sizeof(struct variable), bgpv2_oid, sizeof(bgpv2_oid) / sizeof(oid)); |
1677 | return 0; |
1678 | } |