]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_proto.c
Merge pull request #964 from opensourcerouting/plist-trie-corruption-3.0
[mirror_frr.git] / ospf6d / ospf6_proto.c
1 /*
2 * Copyright (C) 2003 Yasuhiro Ohara
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <zebra.h>
22
23 #include "log.h"
24
25 #include "ospf6_proto.h"
26
27 void ospf6_prefix_apply_mask(struct ospf6_prefix *op)
28 {
29 u_char *pnt, mask;
30 int index, offset;
31
32 pnt = (u_char *)((caddr_t)op + sizeof(struct ospf6_prefix));
33 index = op->prefix_length / 8;
34 offset = op->prefix_length % 8;
35 mask = 0xff << (8 - offset);
36
37 if (index > 16) {
38 zlog_warn("Prefix length too long: %d", op->prefix_length);
39 return;
40 }
41
42 /* nonzero mask means no check for this byte because if it contains
43 * prefix bits it must be there for us to write */
44 if (mask)
45 pnt[index++] &= mask;
46
47 while (index < OSPF6_PREFIX_SPACE(op->prefix_length))
48 pnt[index++] = 0;
49 }
50
51 void ospf6_prefix_options_printbuf(u_int8_t prefix_options, char *buf, int size)
52 {
53 snprintf(buf, size, "xxx");
54 }
55
56 void ospf6_capability_printbuf(char capability, char *buf, int size)
57 {
58 char w, v, e, b;
59 w = (capability & OSPF6_ROUTER_BIT_W ? 'W' : '-');
60 v = (capability & OSPF6_ROUTER_BIT_V ? 'V' : '-');
61 e = (capability & OSPF6_ROUTER_BIT_E ? 'E' : '-');
62 b = (capability & OSPF6_ROUTER_BIT_B ? 'B' : '-');
63 snprintf(buf, size, "----%c%c%c%c", w, v, e, b);
64 }
65
66 void ospf6_options_printbuf(u_char *options, char *buf, int size)
67 {
68 const char *dc, *r, *n, *mc, *e, *v6;
69 dc = (OSPF6_OPT_ISSET(options, OSPF6_OPT_DC) ? "DC" : "--");
70 r = (OSPF6_OPT_ISSET(options, OSPF6_OPT_R) ? "R" : "-");
71 n = (OSPF6_OPT_ISSET(options, OSPF6_OPT_N) ? "N" : "-");
72 mc = (OSPF6_OPT_ISSET(options, OSPF6_OPT_MC) ? "MC" : "--");
73 e = (OSPF6_OPT_ISSET(options, OSPF6_OPT_E) ? "E" : "-");
74 v6 = (OSPF6_OPT_ISSET(options, OSPF6_OPT_V6) ? "V6" : "--");
75 snprintf(buf, size, "%s|%s|%s|%s|%s|%s", dc, r, n, mc, e, v6);
76 }