]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6_proto.c
lib: drop off "masters" list on master_free()
[mirror_frr.git] / ospf6d / ospf6_proto.c
CommitLineData
718e3744 1/*
508e53e2 2 * Copyright (C) 2003 Yasuhiro Ohara
718e3744 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 *
896014f4
DL
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
718e3744 19 */
20
21#include <zebra.h>
22
508e53e2 23#include "log.h"
24
718e3744 25#include "ospf6_proto.h"
26
508e53e2 27void
28ospf6_prefix_apply_mask (struct ospf6_prefix *op)
718e3744 29{
508e53e2 30 u_char *pnt, mask;
31 int index, offset;
32
33 pnt = (u_char *)((caddr_t) op + sizeof (struct ospf6_prefix));
34 index = op->prefix_length / 8;
35 offset = op->prefix_length % 8;
36 mask = 0xff << (8 - offset);
37
6452df09 38 if (index > 16)
508e53e2 39 {
6452df09 40 zlog_warn ("Prefix length too long: %d", op->prefix_length);
508e53e2 41 return;
42 }
43
4c0cf00a
DL
44 /* nonzero mask means no check for this byte because if it contains
45 * prefix bits it must be there for us to write */
46 if (mask)
47 pnt[index++] &= mask;
508e53e2 48
49 while (index < OSPF6_PREFIX_SPACE (op->prefix_length))
50 pnt[index++] = 0;
51}
52
53void
54ospf6_prefix_options_printbuf (u_int8_t prefix_options, char *buf, int size)
55{
56 snprintf (buf, size, "xxx");
57}
58
59void
60ospf6_capability_printbuf (char capability, char *buf, int size)
61{
62 char w, v, e, b;
63 w = (capability & OSPF6_ROUTER_BIT_W ? 'W' : '-');
64 v = (capability & OSPF6_ROUTER_BIT_V ? 'V' : '-');
65 e = (capability & OSPF6_ROUTER_BIT_E ? 'E' : '-');
66 b = (capability & OSPF6_ROUTER_BIT_B ? 'B' : '-');
67 snprintf (buf, size, "----%c%c%c%c", w, v, e, b);
68}
718e3744 69
508e53e2 70void
03d52f8d 71ospf6_options_printbuf (u_char *options, char *buf, int size)
508e53e2 72{
0c083ee9 73 const char *dc, *r, *n, *mc, *e, *v6;
508e53e2 74 dc = (OSPF6_OPT_ISSET (options, OSPF6_OPT_DC) ? "DC" : "--");
75 r = (OSPF6_OPT_ISSET (options, OSPF6_OPT_R) ? "R" : "-" );
76 n = (OSPF6_OPT_ISSET (options, OSPF6_OPT_N) ? "N" : "-" );
77 mc = (OSPF6_OPT_ISSET (options, OSPF6_OPT_MC) ? "MC" : "--");
78 e = (OSPF6_OPT_ISSET (options, OSPF6_OPT_E) ? "E" : "-" );
79 v6 = (OSPF6_OPT_ISSET (options, OSPF6_OPT_V6) ? "V6" : "--");
80 snprintf (buf, size, "%s|%s|%s|%s|%s|%s", dc, r, n, mc, e, v6);
718e3744 81}
82
508e53e2 83