]>
git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_nb_state.c
2 * Copyright (C) 2018 Volta Networks
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "northbound.h"
25 #include "isisd/isisd.h"
26 #include "isisd/isis_nb.h"
27 #include "isisd/isis_circuit.h"
28 #include "isisd/isis_adjacency.h"
29 #include "isisd/isis_misc.h"
32 * XPath: /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency
35 lib_interface_isis_adjacencies_adjacency_get_next(const void *parent_list_entry
,
36 const void *list_entry
)
38 struct interface
*ifp
;
39 struct isis_circuit
*circuit
;
40 struct isis_adjacency
*adj
, *adj_next
= NULL
;
42 struct listnode
*node
, *node_next
;
44 /* Get first adjacency. */
45 if (list_entry
== NULL
) {
46 ifp
= (struct interface
*)parent_list_entry
;
50 circuit
= circuit_scan_by_ifp(ifp
);
54 switch (circuit
->circ_type
) {
55 case CIRCUIT_T_BROADCAST
:
56 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
;
59 circuit
->u
.bc
.adjdb
[level
- 1]);
65 adj
= circuit
->u
.p2p
.neighbor
;
75 /* Get next adjacency. */
76 adj
= (struct isis_adjacency
*)list_entry
;
77 circuit
= adj
->circuit
;
78 switch (circuit
->circ_type
) {
79 case CIRCUIT_T_BROADCAST
:
80 list
= circuit
->u
.bc
.adjdb
[adj
->level
- 1];
81 node
= listnode_lookup(list
, adj
);
82 node_next
= listnextnode(node
);
84 adj_next
= listgetdata(node_next
);
85 else if (adj
->level
== ISIS_LEVEL1
) {
87 * Once we finish the L1 adjacencies, move to the L2
90 list
= circuit
->u
.bc
.adjdb
[ISIS_LEVEL2
- 1];
91 adj_next
= listnode_head(list
);
95 /* P2P circuits have at most one adjacency. */
105 * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sys-type
108 lib_interface_isis_adjacencies_adjacency_neighbor_sys_type_get_elem(
109 const char *xpath
, const void *list_entry
)
111 const struct isis_adjacency
*adj
= list_entry
;
113 return yang_data_new_enum(xpath
, adj
->level
);
118 * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sysid
121 lib_interface_isis_adjacencies_adjacency_neighbor_sysid_get_elem(
122 const char *xpath
, const void *list_entry
)
124 const struct isis_adjacency
*adj
= list_entry
;
126 return yang_data_new_string(xpath
, sysid_print(adj
->sysid
));
131 * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-extended-circuit-id
134 lib_interface_isis_adjacencies_adjacency_neighbor_extended_circuit_id_get_elem(
135 const char *xpath
, const void *list_entry
)
137 const struct isis_adjacency
*adj
= list_entry
;
139 return yang_data_new_uint32(xpath
, adj
->circuit
->circuit_id
);
144 * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-snpa
147 lib_interface_isis_adjacencies_adjacency_neighbor_snpa_get_elem(
148 const char *xpath
, const void *list_entry
)
150 const struct isis_adjacency
*adj
= list_entry
;
152 return yang_data_new_string(xpath
, snpa_print(adj
->snpa
));
157 * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/hold-timer
159 struct yang_data
*lib_interface_isis_adjacencies_adjacency_hold_timer_get_elem(
160 const char *xpath
, const void *list_entry
)
162 const struct isis_adjacency
*adj
= list_entry
;
164 return yang_data_new_uint16(xpath
, adj
->hold_time
);
169 * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-priority
172 lib_interface_isis_adjacencies_adjacency_neighbor_priority_get_elem(
173 const char *xpath
, const void *list_entry
)
175 const struct isis_adjacency
*adj
= list_entry
;
177 return yang_data_new_uint8(xpath
, adj
->prio
[adj
->level
- 1]);
182 * /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/state
185 lib_interface_isis_adjacencies_adjacency_state_get_elem(const char *xpath
,
186 const void *list_entry
)
188 const struct isis_adjacency
*adj
= list_entry
;
190 return yang_data_new_string(xpath
, isis_adj_yang_state(adj
->adj_state
));
195 * /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-changes
197 struct yang_data
*lib_interface_isis_event_counters_adjacency_changes_get_elem(
198 const char *xpath
, const void *list_entry
)
200 struct interface
*ifp
;
201 struct isis_circuit
*circuit
;
203 ifp
= (struct interface
*)list_entry
;
207 circuit
= circuit_scan_by_ifp(ifp
);
211 return yang_data_new_uint32(xpath
, circuit
->adj_state_changes
);
216 * /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-number
218 struct yang_data
*lib_interface_isis_event_counters_adjacency_number_get_elem(
219 const char *xpath
, const void *list_entry
)
221 struct interface
*ifp
;
222 struct isis_circuit
*circuit
;
223 struct isis_adjacency
*adj
;
224 struct listnode
*node
;
227 ifp
= (struct interface
*)list_entry
;
231 circuit
= circuit_scan_by_ifp(ifp
);
236 * TODO: keep track of the number of adjacencies instead of calculating
239 switch (circuit
->circ_type
) {
240 case CIRCUIT_T_BROADCAST
:
241 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
242 for (ALL_LIST_ELEMENTS_RO(
243 circuit
->u
.bc
.adjdb
[level
- 1], node
, adj
))
248 adj
= circuit
->u
.p2p
.neighbor
;
256 return yang_data_new_uint32(xpath
, total
);
260 * XPath: /frr-interface:lib/interface/frr-isisd:isis/event-counters/init-fails
263 lib_interface_isis_event_counters_init_fails_get_elem(const char *xpath
,
264 const void *list_entry
)
266 struct interface
*ifp
;
267 struct isis_circuit
*circuit
;
269 ifp
= (struct interface
*)list_entry
;
273 circuit
= circuit_scan_by_ifp(ifp
);
277 return yang_data_new_uint32(xpath
, circuit
->init_failures
);
282 * /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-rejects
284 struct yang_data
*lib_interface_isis_event_counters_adjacency_rejects_get_elem(
285 const char *xpath
, const void *list_entry
)
287 struct interface
*ifp
;
288 struct isis_circuit
*circuit
;
290 ifp
= (struct interface
*)list_entry
;
294 circuit
= circuit_scan_by_ifp(ifp
);
298 return yang_data_new_uint32(xpath
, circuit
->rej_adjacencies
);
303 * /frr-interface:lib/interface/frr-isisd:isis/event-counters/id-len-mismatch
305 struct yang_data
*lib_interface_isis_event_counters_id_len_mismatch_get_elem(
306 const char *xpath
, const void *list_entry
)
308 struct interface
*ifp
;
309 struct isis_circuit
*circuit
;
311 ifp
= (struct interface
*)list_entry
;
315 circuit
= circuit_scan_by_ifp(ifp
);
319 return yang_data_new_uint32(xpath
, circuit
->id_len_mismatches
);
324 * /frr-interface:lib/interface/frr-isisd:isis/event-counters/max-area-addresses-mismatch
327 lib_interface_isis_event_counters_max_area_addresses_mismatch_get_elem(
328 const char *xpath
, const void *list_entry
)
330 struct interface
*ifp
;
331 struct isis_circuit
*circuit
;
333 ifp
= (struct interface
*)list_entry
;
337 circuit
= circuit_scan_by_ifp(ifp
);
341 return yang_data_new_uint32(xpath
, circuit
->max_area_addr_mismatches
);
346 * /frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-type-fails
349 lib_interface_isis_event_counters_authentication_type_fails_get_elem(
350 const char *xpath
, const void *list_entry
)
352 struct interface
*ifp
;
353 struct isis_circuit
*circuit
;
355 ifp
= (struct interface
*)list_entry
;
359 circuit
= circuit_scan_by_ifp(ifp
);
363 return yang_data_new_uint32(xpath
, circuit
->auth_type_failures
);
368 * /frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-fails
371 lib_interface_isis_event_counters_authentication_fails_get_elem(
372 const char *xpath
, const void *list_entry
)
374 struct interface
*ifp
;
375 struct isis_circuit
*circuit
;
377 ifp
= (struct interface
*)list_entry
;
381 circuit
= circuit_scan_by_ifp(ifp
);
385 return yang_data_new_uint32(xpath
, circuit
->auth_failures
);