ospf6_proto.c 2.4 KB

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