paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 |
| 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. |
| 20 | */ |
| 21 | |
| 22 | #include <zebra.h> |
| 23 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 24 | #include "log.h" |
| 25 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 26 | #include "ospf6_proto.h" |
| 27 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 28 | void |
| 29 | ospf6_prefix_apply_mask (struct ospf6_prefix *op) |
| 30 | { |
| 31 | u_char *pnt, mask; |
| 32 | int index, offset; |
| 33 | |
| 34 | pnt = (u_char *)((caddr_t) op + sizeof (struct ospf6_prefix)); |
| 35 | index = op->prefix_length / 8; |
| 36 | offset = op->prefix_length % 8; |
| 37 | mask = 0xff << (8 - offset); |
| 38 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 39 | if (index > 16) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 40 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 41 | zlog_warn ("Prefix length too long: %d", op->prefix_length); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 42 | return; |
| 43 | } |
| 44 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 45 | if (index == 16) |
| 46 | return; |
| 47 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 48 | pnt[index] &= mask; |
| 49 | index ++; |
| 50 | |
| 51 | while (index < OSPF6_PREFIX_SPACE (op->prefix_length)) |
| 52 | pnt[index++] = 0; |
| 53 | } |
| 54 | |
| 55 | void |
| 56 | ospf6_prefix_options_printbuf (u_int8_t prefix_options, char *buf, int size) |
| 57 | { |
| 58 | snprintf (buf, size, "xxx"); |
| 59 | } |
| 60 | |
| 61 | void |
| 62 | ospf6_capability_printbuf (char capability, char *buf, int size) |
| 63 | { |
| 64 | char w, v, e, b; |
| 65 | w = (capability & OSPF6_ROUTER_BIT_W ? 'W' : '-'); |
| 66 | v = (capability & OSPF6_ROUTER_BIT_V ? 'V' : '-'); |
| 67 | e = (capability & OSPF6_ROUTER_BIT_E ? 'E' : '-'); |
| 68 | b = (capability & OSPF6_ROUTER_BIT_B ? 'B' : '-'); |
| 69 | snprintf (buf, size, "----%c%c%c%c", w, v, e, b); |
| 70 | } |
| 71 | |
| 72 | void |
| 73 | ospf6_options_printbuf (char *options, char *buf, int size) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 74 | { |
| 75 | char *dc, *r, *n, *mc, *e, *v6; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 76 | dc = (OSPF6_OPT_ISSET (options, OSPF6_OPT_DC) ? "DC" : "--"); |
| 77 | r = (OSPF6_OPT_ISSET (options, OSPF6_OPT_R) ? "R" : "-" ); |
| 78 | n = (OSPF6_OPT_ISSET (options, OSPF6_OPT_N) ? "N" : "-" ); |
| 79 | mc = (OSPF6_OPT_ISSET (options, OSPF6_OPT_MC) ? "MC" : "--"); |
| 80 | e = (OSPF6_OPT_ISSET (options, OSPF6_OPT_E) ? "E" : "-" ); |
| 81 | v6 = (OSPF6_OPT_ISSET (options, OSPF6_OPT_V6) ? "V6" : "--"); |
| 82 | snprintf (buf, size, "%s|%s|%s|%s|%s|%s", dc, r, n, mc, e, v6); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 83 | } |
| 84 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 85 | |