2 * IS-IS Routing protocol - isis_pdu_counter.c
3 * Copyright (C) 2018 Christian Franke, for NetDEF Inc.
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
24 #include "isisd/isis_pdu_counter.h"
25 #include "isisd/isisd.h"
26 #include "isisd/isis_circuit.h"
27 #include "isisd/isis_pdu.h"
29 static int pdu_type_to_counter_index(uint8_t pdu_type
)
33 return L1_LAN_HELLO_INDEX
;
35 return L2_LAN_HELLO_INDEX
;
37 return P2P_HELLO_INDEX
;
39 return L1_LINK_STATE_INDEX
;
41 return L2_LINK_STATE_INDEX
;
43 return FS_LINK_STATE_INDEX
;
44 case L1_COMPLETE_SEQ_NUM
:
45 return L1_COMPLETE_SEQ_NUM_INDEX
;
46 case L2_COMPLETE_SEQ_NUM
:
47 return L2_COMPLETE_SEQ_NUM_INDEX
;
48 case L1_PARTIAL_SEQ_NUM
:
49 return L1_PARTIAL_SEQ_NUM_INDEX
;
50 case L2_PARTIAL_SEQ_NUM
:
51 return L2_PARTIAL_SEQ_NUM_INDEX
;
57 static const char *pdu_counter_index_to_name(enum pdu_counter_index index
)
60 case L1_LAN_HELLO_INDEX
:
62 case L2_LAN_HELLO_INDEX
:
66 case L1_LINK_STATE_INDEX
:
68 case L2_LINK_STATE_INDEX
:
70 case FS_LINK_STATE_INDEX
:
72 case L1_COMPLETE_SEQ_NUM_INDEX
:
74 case L2_COMPLETE_SEQ_NUM_INDEX
:
76 case L1_PARTIAL_SEQ_NUM_INDEX
:
78 case L2_PARTIAL_SEQ_NUM_INDEX
:
85 void pdu_counter_count(pdu_counter_t counter
, uint8_t pdu_type
)
87 int index
= pdu_type_to_counter_index(pdu_type
);
95 void pdu_counter_print(struct vty
*vty
, const char *prefix
,
96 pdu_counter_t counter
)
98 for (int i
= 0; i
< PDU_COUNTER_SIZE
; i
++) {
101 vty_out(vty
, "%s%s: %" PRIu64
"\n", prefix
,
102 pdu_counter_index_to_name(i
), counter
[i
]);