]>
Commit | Line | Data |
---|---|---|
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 | * | |
16 | * You should have received a copy of the GNU General Public License | |
ac4d0be5 | 17 | * along with GNU Zebra; see the file COPYING. If not, write to the |
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | * Boston, MA 02111-1307, USA. | |
718e3744 | 20 | */ |
21 | ||
22 | #include <zebra.h> | |
23 | ||
508e53e2 | 24 | #include "log.h" |
25 | ||
718e3744 | 26 | #include "ospf6_proto.h" |
27 | ||
ac4d0be5 | 28 | void ospf6_prefix_apply_mask(struct ospf6_prefix *op) |
718e3744 | 29 | { |
ac4d0be5 | 30 | u_char *pnt, mask; |
31 | int index, offset; | |
508e53e2 | 32 | |
ac4d0be5 | 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); | |
508e53e2 | 37 | |
ac4d0be5 | 38 | if (index > 16) { |
39 | zlog_warn("Prefix length too long: %d", op->prefix_length); | |
40 | return; | |
41 | } | |
508e53e2 | 42 | |
ac4d0be5 | 43 | /* nonzero mask means no check for this byte because if it contains |
44 | * prefix bits it must be there for us to write */ | |
45 | if (mask) | |
46 | pnt[index++] &= mask; | |
508e53e2 | 47 | |
ac4d0be5 | 48 | while (index < OSPF6_PREFIX_SPACE(op->prefix_length)) |
49 | pnt[index++] = 0; | |
508e53e2 | 50 | } |
51 | ||
ac4d0be5 | 52 | void ospf6_prefix_options_printbuf(u_int8_t prefix_options, char *buf, int size) |
508e53e2 | 53 | { |
ac4d0be5 | 54 | snprintf(buf, size, "xxx"); |
508e53e2 | 55 | } |
56 | ||
ac4d0be5 | 57 | void ospf6_capability_printbuf(char capability, char *buf, int size) |
508e53e2 | 58 | { |
ac4d0be5 | 59 | char w, v, e, b; |
60 | w = (capability & OSPF6_ROUTER_BIT_W ? 'W' : '-'); | |
61 | v = (capability & OSPF6_ROUTER_BIT_V ? 'V' : '-'); | |
62 | e = (capability & OSPF6_ROUTER_BIT_E ? 'E' : '-'); | |
63 | b = (capability & OSPF6_ROUTER_BIT_B ? 'B' : '-'); | |
64 | snprintf(buf, size, "----%c%c%c%c", w, v, e, b); | |
508e53e2 | 65 | } |
718e3744 | 66 | |
ac4d0be5 | 67 | void ospf6_options_printbuf(u_char *options, char *buf, int size) |
508e53e2 | 68 | { |
ac4d0be5 | 69 | const char *dc, *r, *n, *mc, *e, *v6; |
70 | dc = (OSPF6_OPT_ISSET(options, OSPF6_OPT_DC) ? "DC" : "--"); | |
71 | r = (OSPF6_OPT_ISSET(options, OSPF6_OPT_R) ? "R" : "-"); | |
72 | n = (OSPF6_OPT_ISSET(options, OSPF6_OPT_N) ? "N" : "-"); | |
73 | mc = (OSPF6_OPT_ISSET(options, OSPF6_OPT_MC) ? "MC" : "--"); | |
74 | e = (OSPF6_OPT_ISSET(options, OSPF6_OPT_E) ? "E" : "-"); | |
75 | v6 = (OSPF6_OPT_ISSET(options, OSPF6_OPT_V6) ? "V6" : "--"); | |
76 | snprintf(buf, size, "%s|%s|%s|%s|%s|%s", dc, r, n, mc, e, v6); | |
718e3744 | 77 | } |