mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 03:47:47 +00:00
ospfd6d: replace handler vector with array
No point in using the vector code for this really. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
7022e70d74
commit
067967b8c7
@ -54,7 +54,7 @@ DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_LSA, "OSPF6 LSA");
|
|||||||
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_LSA_HEADER, "OSPF6 LSA header");
|
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_LSA_HEADER, "OSPF6 LSA header");
|
||||||
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_LSA_SUMMARY, "OSPF6 LSA summary");
|
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_LSA_SUMMARY, "OSPF6 LSA summary");
|
||||||
|
|
||||||
vector ospf6_lsa_handler_vector;
|
static struct ospf6_lsa_handler *lsa_handlers[OSPF6_LSTYPE_SIZE];
|
||||||
|
|
||||||
struct ospf6 *ospf6_get_by_lsdb(struct ospf6_lsa *lsa)
|
struct ospf6 *ospf6_get_by_lsdb(struct ospf6_lsa *lsa)
|
||||||
{
|
{
|
||||||
@ -115,8 +115,13 @@ static struct ospf6_lsa_handler unknown_handler = {
|
|||||||
void ospf6_install_lsa_handler(struct ospf6_lsa_handler *handler)
|
void ospf6_install_lsa_handler(struct ospf6_lsa_handler *handler)
|
||||||
{
|
{
|
||||||
/* type in handler is host byte order */
|
/* type in handler is host byte order */
|
||||||
int index = handler->lh_type & OSPF6_LSTYPE_FCODE_MASK;
|
unsigned int index = handler->lh_type & OSPF6_LSTYPE_FCODE_MASK;
|
||||||
vector_set_index(ospf6_lsa_handler_vector, index, (void *)handler);
|
|
||||||
|
assertf(index < array_size(lsa_handlers), "index=%x", index);
|
||||||
|
assertf(lsa_handlers[index] == NULL, "old=%s, new=%s",
|
||||||
|
lsa_handlers[index]->lh_name, handler->lh_name);
|
||||||
|
|
||||||
|
lsa_handlers[index] = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ospf6_lsa_handler *ospf6_get_lsa_handler(uint16_t type)
|
struct ospf6_lsa_handler *ospf6_get_lsa_handler(uint16_t type)
|
||||||
@ -124,10 +129,8 @@ struct ospf6_lsa_handler *ospf6_get_lsa_handler(uint16_t type)
|
|||||||
struct ospf6_lsa_handler *handler = NULL;
|
struct ospf6_lsa_handler *handler = NULL;
|
||||||
unsigned int index = ntohs(type) & OSPF6_LSTYPE_FCODE_MASK;
|
unsigned int index = ntohs(type) & OSPF6_LSTYPE_FCODE_MASK;
|
||||||
|
|
||||||
if (index >= vector_active(ospf6_lsa_handler_vector))
|
if (index < array_size(lsa_handlers))
|
||||||
handler = &unknown_handler;
|
handler = lsa_handlers[index];
|
||||||
else
|
|
||||||
handler = vector_slot(ospf6_lsa_handler_vector, index);
|
|
||||||
|
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
handler = &unknown_handler;
|
handler = &unknown_handler;
|
||||||
@ -989,13 +992,11 @@ int ospf6_lsa_checksum_valid(struct ospf6_lsa_header *lsa_header)
|
|||||||
|
|
||||||
void ospf6_lsa_init(void)
|
void ospf6_lsa_init(void)
|
||||||
{
|
{
|
||||||
ospf6_lsa_handler_vector = vector_init(0);
|
|
||||||
ospf6_install_lsa_handler(&unknown_handler);
|
ospf6_install_lsa_handler(&unknown_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ospf6_lsa_terminate(void)
|
void ospf6_lsa_terminate(void)
|
||||||
{
|
{
|
||||||
vector_free(ospf6_lsa_handler_vector);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *ospf6_lsa_handler_name(const struct ospf6_lsa_handler *h)
|
static char *ospf6_lsa_handler_name(const struct ospf6_lsa_handler *h)
|
||||||
@ -1020,6 +1021,22 @@ static char *ospf6_lsa_handler_name(const struct ospf6_lsa_handler *h)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ospf6_lsa_debug_set_all(bool val)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
struct ospf6_lsa_handler *handler = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < array_size(lsa_handlers); i++) {
|
||||||
|
handler = lsa_handlers[i];
|
||||||
|
if (handler == NULL)
|
||||||
|
continue;
|
||||||
|
if (val)
|
||||||
|
SET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL);
|
||||||
|
else
|
||||||
|
UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEFPY (debug_ospf6_lsa_all,
|
DEFPY (debug_ospf6_lsa_all,
|
||||||
debug_ospf6_lsa_all_cmd,
|
debug_ospf6_lsa_all_cmd,
|
||||||
"[no$no] debug ospf6 lsa all",
|
"[no$no] debug ospf6 lsa all",
|
||||||
@ -1029,18 +1046,7 @@ DEFPY (debug_ospf6_lsa_all,
|
|||||||
"Debug Link State Advertisements (LSAs)\n"
|
"Debug Link State Advertisements (LSAs)\n"
|
||||||
"Display for all types of LSAs\n")
|
"Display for all types of LSAs\n")
|
||||||
{
|
{
|
||||||
unsigned int i;
|
ospf6_lsa_debug_set_all(!no);
|
||||||
struct ospf6_lsa_handler *handler = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
|
|
||||||
handler = vector_slot(ospf6_lsa_handler_vector, i);
|
|
||||||
if (handler == NULL)
|
|
||||||
continue;
|
|
||||||
if (!no)
|
|
||||||
SET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL);
|
|
||||||
else
|
|
||||||
UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL);
|
|
||||||
}
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1092,8 +1098,8 @@ DEFUN (debug_ospf6_lsa_type,
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct ospf6_lsa_handler *handler = NULL;
|
struct ospf6_lsa_handler *handler = NULL;
|
||||||
|
|
||||||
for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
|
for (i = 0; i < array_size(lsa_handlers); i++) {
|
||||||
handler = vector_slot(ospf6_lsa_handler_vector, i);
|
handler = lsa_handlers[i];
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (strncmp(argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler),
|
if (strncmp(argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler),
|
||||||
@ -1146,8 +1152,8 @@ DEFUN (no_debug_ospf6_lsa_type,
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct ospf6_lsa_handler *handler = NULL;
|
struct ospf6_lsa_handler *handler = NULL;
|
||||||
|
|
||||||
for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
|
for (i = 0; i < array_size(lsa_handlers); i++) {
|
||||||
handler = vector_slot(ospf6_lsa_handler_vector, i);
|
handler = lsa_handlers[i];
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (strncmp(argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler),
|
if (strncmp(argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler),
|
||||||
@ -1194,8 +1200,8 @@ int config_write_ospf6_debug_lsa(struct vty *vty)
|
|||||||
const struct ospf6_lsa_handler *handler;
|
const struct ospf6_lsa_handler *handler;
|
||||||
bool debug_all = true;
|
bool debug_all = true;
|
||||||
|
|
||||||
for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
|
for (i = 0; i < array_size(lsa_handlers); i++) {
|
||||||
handler = vector_slot(ospf6_lsa_handler_vector, i);
|
handler = lsa_handlers[i];
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL)
|
if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL)
|
||||||
@ -1210,8 +1216,8 @@ int config_write_ospf6_debug_lsa(struct vty *vty)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
|
for (i = 0; i < array_size(lsa_handlers); i++) {
|
||||||
handler = vector_slot(ospf6_lsa_handler_vector, i);
|
handler = lsa_handlers[i];
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG))
|
if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG))
|
||||||
|
@ -173,8 +173,6 @@ struct ospf6_lsa_handler {
|
|||||||
#define OSPF6_LSA_IS_KNOWN(t) \
|
#define OSPF6_LSA_IS_KNOWN(t) \
|
||||||
(ospf6_get_lsa_handler(t)->lh_type != OSPF6_LSTYPE_UNKNOWN ? 1 : 0)
|
(ospf6_get_lsa_handler(t)->lh_type != OSPF6_LSTYPE_UNKNOWN ? 1 : 0)
|
||||||
|
|
||||||
extern vector ospf6_lsa_handler_vector;
|
|
||||||
|
|
||||||
/* Macro for LSA Origination */
|
/* Macro for LSA Origination */
|
||||||
/* addr is (struct prefix *) */
|
/* addr is (struct prefix *) */
|
||||||
#define CONTINUE_IF_ADDRESS_LINKLOCAL(debug, addr) \
|
#define CONTINUE_IF_ADDRESS_LINKLOCAL(debug, addr) \
|
||||||
@ -268,6 +266,7 @@ extern int ospf6_lsa_prohibited_duration(uint16_t type, uint32_t id,
|
|||||||
|
|
||||||
extern void ospf6_install_lsa_handler(struct ospf6_lsa_handler *handler);
|
extern void ospf6_install_lsa_handler(struct ospf6_lsa_handler *handler);
|
||||||
extern struct ospf6_lsa_handler *ospf6_get_lsa_handler(uint16_t type);
|
extern struct ospf6_lsa_handler *ospf6_get_lsa_handler(uint16_t type);
|
||||||
|
extern void ospf6_lsa_debug_set_all(bool val);
|
||||||
|
|
||||||
extern void ospf6_lsa_init(void);
|
extern void ospf6_lsa_init(void);
|
||||||
extern void ospf6_lsa_terminate(void);
|
extern void ospf6_lsa_terminate(void);
|
||||||
|
@ -1254,7 +1254,6 @@ DEFUN (no_debug_ospf6,
|
|||||||
OSPF6_STR)
|
OSPF6_STR)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct ospf6_lsa_handler *handler = NULL;
|
|
||||||
|
|
||||||
OSPF6_DEBUG_ABR_OFF();
|
OSPF6_DEBUG_ABR_OFF();
|
||||||
OSPF6_DEBUG_ASBR_OFF();
|
OSPF6_DEBUG_ASBR_OFF();
|
||||||
@ -1264,13 +1263,7 @@ DEFUN (no_debug_ospf6,
|
|||||||
OSPF6_DEBUG_FLOODING_OFF();
|
OSPF6_DEBUG_FLOODING_OFF();
|
||||||
OSPF6_DEBUG_INTERFACE_OFF();
|
OSPF6_DEBUG_INTERFACE_OFF();
|
||||||
|
|
||||||
for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
|
ospf6_lsa_debug_set_all(false);
|
||||||
handler = vector_slot(ospf6_lsa_handler_vector, i);
|
|
||||||
|
|
||||||
if (handler != NULL) {
|
|
||||||
UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++)
|
||||||
OSPF6_DEBUG_MESSAGE_OFF(i,
|
OSPF6_DEBUG_MESSAGE_OFF(i,
|
||||||
|
Loading…
Reference in New Issue
Block a user