X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ospf6d%2Fospf6_proto.c;h=864974c9a4c3d952723a1a9a6dede2e786c685ab;hb=91d227b7e3cb53ad8fdbcd9d4cff7f0a666918e3;hp=1538c891ca16af6dab02a4905d2d701cc193d2db;hpb=fe2bfdd608f66eb64e87c8a413dea730e1aa1bd6;p=mirror_frr.git diff --git a/ospf6d/ospf6_proto.c b/ospf6d/ospf6_proto.c index 1538c891c..864974c9a 100644 --- a/ospf6d/ospf6_proto.c +++ b/ospf6d/ospf6_proto.c @@ -24,60 +24,63 @@ #include "ospf6_proto.h" -void -ospf6_prefix_apply_mask (struct ospf6_prefix *op) +void ospf6_prefix_in6_addr(struct in6_addr *in6, const void *prefix_buf, + const struct ospf6_prefix *p) { - u_char *pnt, mask; - int index, offset; + ptrdiff_t in6_off = (caddr_t)p->addr - (caddr_t)prefix_buf; - pnt = (u_char *)((caddr_t) op + sizeof (struct ospf6_prefix)); - index = op->prefix_length / 8; - offset = op->prefix_length % 8; - mask = 0xff << (8 - offset); + memset(in6, 0, sizeof(struct in6_addr)); + memcpy(in6, (uint8_t *)prefix_buf + in6_off, + OSPF6_PREFIX_SPACE(p->prefix_length)); +} + +void ospf6_prefix_apply_mask(struct ospf6_prefix *op) +{ + uint8_t *pnt, mask; + int index, offset; - if (index > 16) - { - zlog_warn ("Prefix length too long: %d", op->prefix_length); - return; - } + pnt = (uint8_t *)((caddr_t)op + sizeof(struct ospf6_prefix)); + index = op->prefix_length / 8; + offset = op->prefix_length % 8; + mask = 0xff << (8 - offset); - /* nonzero mask means no check for this byte because if it contains - * prefix bits it must be there for us to write */ - if (mask) - pnt[index++] &= mask; + if (index > 16) { + zlog_warn("Prefix length too long: %d", op->prefix_length); + return; + } - while (index < OSPF6_PREFIX_SPACE (op->prefix_length)) - pnt[index++] = 0; + /* nonzero mask means no check for this byte because if it contains + * prefix bits it must be there for us to write */ + if (mask) + pnt[index++] &= mask; + + while (index < OSPF6_PREFIX_SPACE(op->prefix_length)) + pnt[index++] = 0; } -void -ospf6_prefix_options_printbuf (u_int8_t prefix_options, char *buf, int size) +void ospf6_prefix_options_printbuf(uint8_t prefix_options, char *buf, int size) { - snprintf (buf, size, "xxx"); + snprintf(buf, size, "xxx"); } -void -ospf6_capability_printbuf (char capability, char *buf, int size) +void ospf6_capability_printbuf(char capability, char *buf, int size) { - char w, v, e, b; - w = (capability & OSPF6_ROUTER_BIT_W ? 'W' : '-'); - v = (capability & OSPF6_ROUTER_BIT_V ? 'V' : '-'); - e = (capability & OSPF6_ROUTER_BIT_E ? 'E' : '-'); - b = (capability & OSPF6_ROUTER_BIT_B ? 'B' : '-'); - snprintf (buf, size, "----%c%c%c%c", w, v, e, b); + char w, v, e, b; + w = (capability & OSPF6_ROUTER_BIT_W ? 'W' : '-'); + v = (capability & OSPF6_ROUTER_BIT_V ? 'V' : '-'); + e = (capability & OSPF6_ROUTER_BIT_E ? 'E' : '-'); + b = (capability & OSPF6_ROUTER_BIT_B ? 'B' : '-'); + snprintf(buf, size, "----%c%c%c%c", w, v, e, b); } -void -ospf6_options_printbuf (u_char *options, char *buf, int size) +void ospf6_options_printbuf(uint8_t *options, char *buf, int size) { - const char *dc, *r, *n, *mc, *e, *v6; - dc = (OSPF6_OPT_ISSET (options, OSPF6_OPT_DC) ? "DC" : "--"); - r = (OSPF6_OPT_ISSET (options, OSPF6_OPT_R) ? "R" : "-" ); - n = (OSPF6_OPT_ISSET (options, OSPF6_OPT_N) ? "N" : "-" ); - mc = (OSPF6_OPT_ISSET (options, OSPF6_OPT_MC) ? "MC" : "--"); - e = (OSPF6_OPT_ISSET (options, OSPF6_OPT_E) ? "E" : "-" ); - v6 = (OSPF6_OPT_ISSET (options, OSPF6_OPT_V6) ? "V6" : "--"); - snprintf (buf, size, "%s|%s|%s|%s|%s|%s", dc, r, n, mc, e, v6); + const char *dc, *r, *n, *mc, *e, *v6; + dc = (OSPF6_OPT_ISSET(options, OSPF6_OPT_DC) ? "DC" : "--"); + r = (OSPF6_OPT_ISSET(options, OSPF6_OPT_R) ? "R" : "-"); + n = (OSPF6_OPT_ISSET(options, OSPF6_OPT_N) ? "N" : "-"); + mc = (OSPF6_OPT_ISSET(options, OSPF6_OPT_MC) ? "MC" : "--"); + e = (OSPF6_OPT_ISSET(options, OSPF6_OPT_E) ? "E" : "-"); + v6 = (OSPF6_OPT_ISSET(options, OSPF6_OPT_V6) ? "V6" : "--"); + snprintf(buf, size, "%s|%s|%s|%s|%s|%s", dc, r, n, mc, e, v6); } - -