]>
git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_proto.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2003 Yasuhiro Ohara
10 #include "ospf6_proto.h"
12 void ospf6_prefix_in6_addr(struct in6_addr
*in6
, const void *prefix_buf
,
13 const struct ospf6_prefix
*p
)
15 ptrdiff_t in6_off
= (caddr_t
)p
->addr
- (caddr_t
)prefix_buf
;
17 memset(in6
, 0, sizeof(struct in6_addr
));
18 memcpy(in6
, (uint8_t *)prefix_buf
+ in6_off
,
19 OSPF6_PREFIX_SPACE(p
->prefix_length
));
22 void ospf6_prefix_apply_mask(struct ospf6_prefix
*op
)
27 pnt
= (uint8_t *)((caddr_t
)op
+ sizeof(struct ospf6_prefix
));
28 index
= op
->prefix_length
/ 8;
29 offset
= op
->prefix_length
% 8;
30 mask
= 0xff << (8 - offset
);
33 zlog_warn("Prefix length too long: %d", op
->prefix_length
);
37 /* nonzero mask means no check for this byte because if it contains
38 * prefix bits it must be there for us to write */
42 while (index
< OSPF6_PREFIX_SPACE(op
->prefix_length
))
46 void ospf6_prefix_options_printbuf(uint8_t prefix_options
, char *buf
, int size
)
48 const char *dn
, *p
, *mc
, *la
, *nu
;
50 dn
= (CHECK_FLAG(prefix_options
, OSPF6_PREFIX_OPTION_DN
) ? "DN" : "--");
51 p
= (CHECK_FLAG(prefix_options
, OSPF6_PREFIX_OPTION_P
) ? "P" : "--");
52 mc
= (CHECK_FLAG(prefix_options
, OSPF6_PREFIX_OPTION_MC
) ? "MC" : "--");
53 la
= (CHECK_FLAG(prefix_options
, OSPF6_PREFIX_OPTION_LA
) ? "LA" : "--");
54 nu
= (CHECK_FLAG(prefix_options
, OSPF6_PREFIX_OPTION_NU
) ? "NU" : "--");
55 snprintf(buf
, size
, "%s|%s|%s|%s|%s", dn
, p
, mc
, la
, nu
);
58 void ospf6_capability_printbuf(char capability
, char *buf
, int size
)
61 w
= (capability
& OSPF6_ROUTER_BIT_W
? 'W' : '-');
62 v
= (capability
& OSPF6_ROUTER_BIT_V
? 'V' : '-');
63 e
= (capability
& OSPF6_ROUTER_BIT_E
? 'E' : '-');
64 b
= (capability
& OSPF6_ROUTER_BIT_B
? 'B' : '-');
65 snprintf(buf
, size
, "----%c%c%c%c", w
, v
, e
, b
);
68 void ospf6_options_printbuf(uint8_t *options
, char *buf
, int size
)
70 const char *dc
, *r
, *n
, *mc
, *e
, *v6
, *af
, *at
, *l
;
71 dc
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_DC
) ? "DC" : "--");
72 r
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_R
) ? "R" : "-");
73 n
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_N
) ? "N" : "-");
74 mc
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_MC
) ? "MC" : "--");
75 e
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_E
) ? "E" : "-");
76 v6
= (OSPF6_OPT_ISSET(options
, OSPF6_OPT_V6
) ? "V6" : "--");
77 af
= (OSPF6_OPT_ISSET_EXT(options
, OSPF6_OPT_AF
) ? "AF" : "--");
78 at
= (OSPF6_OPT_ISSET_EXT(options
, OSPF6_OPT_AT
) ? "AT" : "--");
79 l
= (OSPF6_OPT_ISSET_EXT(options
, OSPF6_OPT_L
) ? "L" : "-");
80 snprintf(buf
, size
, "%s|%s|%s|-|-|%s|%s|%s|%s|%s|%s", at
, l
, af
, dc
, r
,