diff options
author | Igor Ryzhov <iryzhov@nfware.com> | 2021-05-17 12:07:24 +0200 |
---|---|---|
committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-05-17 12:07:24 +0200 |
commit | 5ff4ad8ee33b3d8cb5e2a6e0fbf0f0c1706676a2 (patch) | |
tree | e27b6d84ba7f2727404ccb9ac6a636c66c967481 /isisd | |
parent | Merge pull request #8556 from donaldsharp/bgp_pbr_weird (diff) | |
download | frr-5ff4ad8ee33b3d8cb5e2a6e0fbf0f0c1706676a2.tar.xz frr-5ff4ad8ee33b3d8cb5e2a6e0fbf0f0c1706676a2.zip |
isisd: fix build warning and simplify code
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'isisd')
-rw-r--r-- | isisd/isis_snmp.c | 93 |
1 files changed, 36 insertions, 57 deletions
diff --git a/isisd/isis_snmp.c b/isisd/isis_snmp.c index dfc865162..fa2f9a766 100644 --- a/isisd/isis_snmp.c +++ b/isisd/isis_snmp.c @@ -616,11 +616,44 @@ static uint8_t isis_null_sysid[ISIS_SYS_ID_LEN]; #define ISIS_SNMP_ADJ_STATE_UP (3) #define ISIS_SNMP_ADJ_STATE_FAILED (4) +static inline uint32_t isis_snmp_adj_state(enum isis_adj_state state) +{ + switch (state) { + case ISIS_ADJ_UNKNOWN: + return ISIS_SNMP_ADJ_STATE_DOWN; + case ISIS_ADJ_INITIALIZING: + return ISIS_SNMP_ADJ_STATE_INITIALIZING; + case ISIS_ADJ_UP: + return ISIS_SNMP_ADJ_STATE_UP; + case ISIS_ADJ_DOWN: + return ISIS_SNMP_ADJ_STATE_FAILED; + } + + return 0; /* not reached */ +} + #define ISIS_SNMP_ADJ_NEIGHTYPE_IS_L1 (1) #define ISIS_SNMP_ADJ_NEIGHTYPE_IS_L2 (2) #define ISIS_SNMP_ADJ_NEIGHTYPE_IS_L1_L2 (3) #define ISIS_SNMP_ADJ_NEIGHTYPE_UNKNOWN (4) +static inline uint32_t isis_snmp_adj_neightype(enum isis_system_type type) +{ + switch (type) { + case ISIS_SYSTYPE_UNKNOWN: + case ISIS_SYSTYPE_ES: + return ISIS_SNMP_ADJ_NEIGHTYPE_UNKNOWN; + case ISIS_SYSTYPE_IS: + return ISIS_SNMP_ADJ_NEIGHTYPE_IS_L1_L2; + case ISIS_SYSTYPE_L1_IS: + return ISIS_SNMP_ADJ_NEIGHTYPE_IS_L1; + case ISIS_SYSTYPE_L2_IS: + return ISIS_SNMP_ADJ_NEIGHTYPE_IS_L2; + } + + return 0; /* not reached */ +} + #define ISIS_SNMP_INET_TYPE_V4 (1) #define ISIS_SNMP_INET_TYPE_V6 (2) @@ -2510,23 +2543,7 @@ static uint8_t *isis_snmp_find_isadj(struct variable *v, oid *name, switch (v->magic) { case ISIS_ISADJ_STATE: - - switch (adj->adj_state) { - case ISIS_ADJ_UNKNOWN: - case ISIS_ADJ_DOWN: - val = ISIS_SNMP_ADJ_STATE_DOWN; - break; - - case ISIS_ADJ_INITIALIZING: - val = ISIS_SNMP_ADJ_STATE_INITIALIZING; - break; - - case ISIS_ADJ_UP: - val = ISIS_SNMP_ADJ_STATE_UP; - break; - } - - return SNMP_INTEGER(val); + return SNMP_INTEGER(isis_snmp_adj_state(adj->adj_state)); case ISIS_ISADJ_3WAYSTATE: return SNMP_INTEGER(adj->threeway_state); @@ -2538,27 +2555,7 @@ static uint8_t *isis_snmp_find_isadj(struct variable *v, oid *name, } case ISIS_ISADJ_NEIGHSYSTYPE: - - switch (adj->sys_type) { - case ISIS_SYSTYPE_UNKNOWN: - case ISIS_SYSTYPE_ES: - val = ISIS_SNMP_ADJ_NEIGHTYPE_UNKNOWN; - break; - - case ISIS_SYSTYPE_IS: - val = ISIS_SNMP_ADJ_NEIGHTYPE_IS_L1_L2; - break; - - case ISIS_SYSTYPE_L1_IS: - val = ISIS_SNMP_ADJ_NEIGHTYPE_IS_L1; - break; - - case ISIS_SYSTYPE_L2_IS: - val = ISIS_SNMP_ADJ_NEIGHTYPE_IS_L2; - break; - } - - return SNMP_INTEGER(val); + return SNMP_INTEGER(isis_snmp_adj_neightype(adj->sys_type)); case ISIS_ISADJ_NEIGHSYSID: *var_len = sizeof(adj->sysid); @@ -3345,25 +3342,7 @@ static int isis_snmp_adj_state_change_update(const struct isis_adjacency *adj) lsp_id[ISIS_SYS_ID_LEN] = 0; lsp_id[ISIS_SYS_ID_LEN + 1] = 0; - val = ISIS_SNMP_ADJ_STATE_DOWN; - - switch (adj->adj_state) { - case ISIS_ADJ_UNKNOWN: - val = ISIS_SNMP_ADJ_STATE_DOWN; - break; - - case ISIS_ADJ_INITIALIZING: - val = ISIS_SNMP_ADJ_STATE_INITIALIZING; - break; - - case ISIS_ADJ_UP: - val = ISIS_SNMP_ADJ_STATE_UP; - break; - - case ISIS_ADJ_DOWN: - val = ISIS_SNMP_ADJ_STATE_FAILED; - break; - } + val = isis_snmp_adj_state(adj->adj_state); isis_snmp_update_worker_b( adj->circuit, ISIS_TRAP_ADJ_STATE_CHANGE, |