]>
git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_proto.c
2 * Copyright (C) 2003 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
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
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.
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
25 #include "ospf6_proto.h"
27 void ospf6_prefix_in6_addr(struct in6_addr
*in6
, const void *prefix_buf
,
28 const struct ospf6_prefix
*p
)
30 ptrdiff_t in6_off
= (caddr_t
)p
->addr
- (caddr_t
)prefix_buf
;
32 memset(in6
, 0, sizeof(struct in6_addr
));
33 memcpy(in6
, (uint8_t *)prefix_buf
+ in6_off
,
34 OSPF6_PREFIX_SPACE(p
->prefix_length
));
37 void ospf6_prefix_apply_mask(struct ospf6_prefix
*op
)
42 pnt
= (uint8_t *)((caddr_t
)op
+ sizeof(struct ospf6_prefix
));
43 index
= op
->prefix_length
/ 8;
44 offset
= op
->prefix_length
% 8;
45 mask
= 0xff << (8 - offset
);
48 zlog_warn("Prefix length too long: %d", op
->prefix_length
);
52 /* nonzero mask means no check for this byte because if it contains
53 * prefix bits it must be there for us to write */
57 while (index
< OSPF6_PREFIX_SPACE(op
->prefix_length
))
61 void ospf6_prefix_options_printbuf(uint8_t prefix_options
, char *buf
, int size
)
63 const char *dn
, *p
, *mc
, *la
, *nu
;
65 dn
= (CHECK_FLAG(prefix_options
, OSPF6_PREFIX_OPTION_DN
) ? "DN" : "--");
66 p
= (CHECK_FLAG(prefix_options
, OSPF6_PREFIX_OPTION_P
) ? "P" : "--");
67 mc
= (CHECK_FLAG(prefix_options
, OSPF6_PREFIX_OPTION_MC
) ? "MC" : "--");
68 la
= (CHECK_FLAG(prefix_options
, OSPF6_PREFIX_OPTION_LA
) ? "LA" : "--");
69 nu
= (CHECK_FLAG(prefix_options
, OSPF6_PREFIX_OPTION_NU
) ? "NU" : "--");
70 snprintf(buf
, size
, "%s|%s|%s|%s|%s", dn
, p
, mc
, la
, nu
);
73 void ospf6_capability_printbuf(char capability
, char *buf
, int size
)
76 w
= (capability
& OSPF6_ROUTER_BIT_W
? 'W' : '-');
77 v
= (capability
& OSPF6_ROUTER_BIT_V
? 'V' : '-');
78 e
= (capability
& OSPF6_ROUTER_BIT_E
? 'E' : '-');
79 b
= (capability
& OSPF6_ROUTER_BIT_B
? 'B' : '-');
80 snprintf(buf
, size
, "----%c%c%c%c", w
, v
, e
, b
);
83 void ospf6_options_printbuf(uint8_t *options
, char *buf
, int size
)
85 const char *dc
, *r
, *n
, *mc
, *e
, *v6
;
86 dc
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_DC
) ? "DC" : "--");
87 r
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_R
) ? "R" : "-");
88 n
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_N
) ? "N" : "-");
89 mc
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_MC
) ? "MC" : "--");
90 e
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_E
) ? "E" : "-");
91 v6
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_V6
) ? "V6" : "--");
92 snprintf(buf
, size
, "%s|%s|%s|%s|%s|%s", dc
, r
, n
, mc
, e
, v6
);