}
struct ospf6_lsa_handler inter_prefix_handler = {
- OSPF6_LSTYPE_INTER_PREFIX,
- "Inter-Prefix",
- "IAP",
- ospf6_inter_area_prefix_lsa_show,
- ospf6_inter_area_prefix_lsa_get_prefix_str,
+ .lh_type = OSPF6_LSTYPE_INTER_PREFIX,
+ .lh_name = "Inter-Prefix",
+ .lh_short_name = "IAP",
+ .lh_show = ospf6_inter_area_prefix_lsa_show,
+ .lh_get_prefix_str = ospf6_inter_area_prefix_lsa_get_prefix_str,
+ .lh_debug = 0
};
struct ospf6_lsa_handler inter_router_handler = {
- OSPF6_LSTYPE_INTER_ROUTER,
- "Inter-Router",
- "IAR",
- ospf6_inter_area_router_lsa_show,
- ospf6_inter_area_router_lsa_get_prefix_str,
+ .lh_type = OSPF6_LSTYPE_INTER_ROUTER,
+ .lh_name = "Inter-Router",
+ .lh_short_name = "IAR",
+ .lh_show = ospf6_inter_area_router_lsa_show,
+ .lh_get_prefix_str = ospf6_inter_area_router_lsa_get_prefix_str,
+ .lh_debug = 0
};
void ospf6_abr_init(void)
oa->name);
}
-struct ospf6_lsa_handler router_handler = {OSPF6_LSTYPE_ROUTER, "Router", "Rtr",
- ospf6_router_lsa_show,
- ospf6_router_lsa_get_nbr_id};
-
-struct ospf6_lsa_handler network_handler = {OSPF6_LSTYPE_NETWORK, "Network",
- "Net", ospf6_network_lsa_show,
- ospf6_network_lsa_get_ar_id};
-
-struct ospf6_lsa_handler link_handler = {OSPF6_LSTYPE_LINK, "Link", "Lnk",
- ospf6_link_lsa_show,
- ospf6_link_lsa_get_prefix_str};
+struct ospf6_lsa_handler router_handler = {
+ .lh_type = OSPF6_LSTYPE_ROUTER,
+ .lh_name = "Router",
+ .lh_short_name = "Rtr",
+ .lh_show = ospf6_router_lsa_show,
+ .lh_get_prefix_str = ospf6_router_lsa_get_nbr_id,
+ .lh_debug = 0
+};
+
+struct ospf6_lsa_handler network_handler = {
+ .lh_type = OSPF6_LSTYPE_NETWORK,
+ .lh_name = "Network",
+ .lh_short_name = "Net",
+ .lh_show = ospf6_network_lsa_show,
+ .lh_get_prefix_str = ospf6_network_lsa_get_ar_id,
+ .lh_debug = 0
+};
+
+struct ospf6_lsa_handler link_handler = {
+ .lh_type = OSPF6_LSTYPE_LINK,
+ .lh_name = "Link",
+ .lh_short_name = "Lnk",
+ .lh_show = ospf6_link_lsa_show,
+ .lh_get_prefix_str = ospf6_link_lsa_get_prefix_str,
+ .lh_debug = 0
+};
struct ospf6_lsa_handler intra_prefix_handler = {
- OSPF6_LSTYPE_INTRA_PREFIX, "Intra-Prefix", "INP",
- ospf6_intra_prefix_lsa_show, ospf6_intra_prefix_lsa_get_prefix_str};
+ .lh_type = OSPF6_LSTYPE_INTRA_PREFIX,
+ .lh_name = "Intra-Prefix",
+ .lh_short_name = "INP",
+ .lh_show = ospf6_intra_prefix_lsa_show,
+ .lh_get_prefix_str = ospf6_intra_prefix_lsa_get_prefix_str,
+ .lh_debug = 0
+};
void ospf6_intra_init(void)
{
return 0;
}
-struct ospf6_lsa_handler unknown_handler = {
- OSPF6_LSTYPE_UNKNOWN, "Unknown", "Unk", ospf6_unknown_lsa_show, NULL};
+static struct ospf6_lsa_handler unknown_handler = {
+ .lh_type = OSPF6_LSTYPE_UNKNOWN,
+ .lh_name = "Unknown",
+ .lh_short_name = "Unk",
+ .lh_show = ospf6_unknown_lsa_show,
+ .lh_get_prefix_str = NULL,
+ .lh_debug = 0 /* No default debug */
+};
-void ospf6_install_lsa_handler(struct ospf6_lsa_handler *handler)
+void ospf6_install_lsa_handler(const struct ospf6_lsa_handler *handler)
{
/* type in handler is host byte order */
- int index = handler->type & OSPF6_LSTYPE_FCODE_MASK;
- vector_set_index(ospf6_lsa_handler_vector, index, handler);
+ int index = handler->lh_type & OSPF6_LSTYPE_FCODE_MASK;
+ vector_set_index(ospf6_lsa_handler_vector, index, (void *)handler);
}
-struct ospf6_lsa_handler *ospf6_get_lsa_handler(u_int16_t type)
+const struct ospf6_lsa_handler *ospf6_get_lsa_handler(u_int16_t type)
{
- struct ospf6_lsa_handler *handler = NULL;
+ const struct ospf6_lsa_handler *handler = NULL;
unsigned int index = ntohs(type) & OSPF6_LSTYPE_FCODE_MASK;
if (index >= vector_active(ospf6_lsa_handler_vector))
const char *ospf6_lstype_name(u_int16_t type)
{
static char buf[8];
- struct ospf6_lsa_handler *handler;
+ const struct ospf6_lsa_handler *handler;
handler = ospf6_get_lsa_handler(type);
if (handler && handler != &unknown_handler)
- return handler->name;
+ return handler->lh_name;
snprintf(buf, sizeof(buf), "0x%04hx", ntohs(type));
return buf;
const char *ospf6_lstype_short_name(u_int16_t type)
{
static char buf[8];
- struct ospf6_lsa_handler *handler;
+ const struct ospf6_lsa_handler *handler;
handler = ospf6_get_lsa_handler(type);
if (handler && handler != &unknown_handler)
- return handler->short_name;
+ return handler->lh_short_name;
snprintf(buf, sizeof(buf), "0x%04hx", ntohs(type));
return buf;
u_char ospf6_lstype_debug(u_int16_t type)
{
- struct ospf6_lsa_handler *handler;
+ const struct ospf6_lsa_handler *handler;
handler = ospf6_get_lsa_handler(type);
return handler->debug;
}
{
char adv_router[16], id[16];
int type;
- struct ospf6_lsa_handler *handler;
+ const struct ospf6_lsa_handler *handler;
char buf[64], tmpbuf[80];
int cnt = 0;
ospf6_lstype_short_name(lsa->header->type), id,
adv_router, ospf6_lsa_age_current(lsa),
(u_long)ntohl(lsa->header->seqnum),
- handler->get_prefix_str(lsa, buf, sizeof(buf), 0));
+ handler->lh_get_prefix_str(lsa, buf, sizeof(buf), 0));
} else if (type != OSPF6_LSTYPE_UNKNOWN) {
sprintf(tmpbuf, "%-4s %-15s%-15s%4hu %8lx",
ospf6_lstype_short_name(lsa->header->type), id,
adv_router, ospf6_lsa_age_current(lsa),
(u_long)ntohl(lsa->header->seqnum));
- while (handler->get_prefix_str(lsa, buf, sizeof(buf), cnt)
+ while (handler->lh_get_prefix_str(lsa, buf, sizeof(buf), cnt)
!= NULL) {
vty_out(vty, "%s %30s\n", tmpbuf, buf);
cnt++;
void ospf6_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
{
char adv_router[64], id[64];
- struct ospf6_lsa_handler *handler;
+ const struct ospf6_lsa_handler *handler;
struct timeval now, res;
char duration[64];
vty_out(vty, "Duration: %s\n", duration);
handler = ospf6_get_lsa_handler(lsa->header->type);
- if (handler->show == NULL)
- handler = &unknown_handler;
- (*handler->show)(vty, lsa);
+
+ if (handler->lh_show != NULL)
+ handler->lh_show(vty, lsa);
+ else {
+ assert(unknown_handler.lh_show != NULL);
+ unknown_handler.lh_show(vty, lsa);
+ }
vty_out(vty, "\n");
}
vector_free(ospf6_lsa_handler_vector);
}
-static char *ospf6_lsa_handler_name(struct ospf6_lsa_handler *h)
+static char *ospf6_lsa_handler_name(const struct ospf6_lsa_handler *h)
{
static char buf[64];
unsigned int i;
- unsigned int size = strlen(h->name);
+ unsigned int size = strlen(h->lh_name);
- if (!strcmp(h->name, "unknown") && h->type != OSPF6_LSTYPE_UNKNOWN) {
- snprintf(buf, sizeof(buf), "%#04hx", h->type);
+ if (!strcmp(h->lh_name, "unknown") && h->lh_type != OSPF6_LSTYPE_UNKNOWN) {
+ snprintf(buf, sizeof(buf), "%#04hx", h->lh_type);
return buf;
}
for (i = 0; i < MIN(size, sizeof(buf)); i++) {
- if (!islower((unsigned char)h->name[i]))
- buf[i] = tolower((unsigned char)h->name[i]);
+ if (!islower((unsigned char)h->lh_name[i]))
+ buf[i] = tolower((unsigned char)h->lh_name[i]);
else
- buf[i] = h->name[i];
+ buf[i] = h->lh_name[i];
}
buf[size] = '\0';
return buf;
strlen(argv[idx_lsa]->arg))
== 0)
break;
- if (!strcasecmp(argv[idx_lsa]->arg, handler->name))
+ if (!strcasecmp(argv[idx_lsa]->arg, handler->lh_name))
break;
handler = NULL;
}
strlen(argv[idx_lsa]->arg))
== 0)
break;
- if (!strcasecmp(argv[idx_lsa]->arg, handler->name))
+ if (!strcasecmp(argv[idx_lsa]->arg, handler->lh_name))
break;
}
int config_write_ospf6_debug_lsa(struct vty *vty)
{
u_int i;
- struct ospf6_lsa_handler *handler;
+ const struct ospf6_lsa_handler *handler;
for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
handler = vector_slot(ospf6_lsa_handler_vector, i);
#define OSPF6_LSA_SEQWRAPPED 0x20
struct ospf6_lsa_handler {
- u_int16_t type; /* host byte order */
- const char *name;
- const char *short_name;
- int (*show)(struct vty *, struct ospf6_lsa *);
- char *(*get_prefix_str)(struct ospf6_lsa *, char *buf, int buflen,
- int pos);
+ const struct {
+ u_int16_t type; /* host byte order */
+ const char *name;
+ const char *short_name;
+ int (*show)(struct vty *, struct ospf6_lsa *);
+ char *(*get_prefix_str)(struct ospf6_lsa *, char *buf, int buflen,
+ int pos);
+ } s;
+#define lh_type s.type
+#define lh_name s.name
+#define lh_short_name s.short_name
+#define lh_show s.show
+#define lh_get_prefix_str s.get_prefix_str
u_char debug;
+#define lh_debug debug
};
-extern struct ospf6_lsa_handler unknown_handler;
-#define OSPF6_LSA_IS_KNOWN(type) \
- (ospf6_get_lsa_handler(type) != &unknown_handler ? 1 : 0)
+#define OSPF6_LSA_IS_KNOWN(t) \
+ (ospf6_get_lsa_handler(t).lh_type != OSPF6_LSTYPE_UNKNOWN ? 1 : 0)
extern vector ospf6_lsa_handler_vector;
extern int ospf6_lsa_prohibited_duration(u_int16_t type, u_int32_t id,
u_int32_t adv_router, void *scope);
-extern void ospf6_install_lsa_handler(struct ospf6_lsa_handler *handler);
-extern struct ospf6_lsa_handler *ospf6_get_lsa_handler(u_int16_t type);
+extern void ospf6_install_lsa_handler(const struct ospf6_lsa_handler *handler);
+extern const struct ospf6_lsa_handler *ospf6_get_lsa_handler(u_int16_t type);
extern void ospf6_lsa_init(void);
extern void ospf6_lsa_terminate(void);