ospf6_proto.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Common protocol data and data structures.
  3. * Copyright (C) 2003 Yasuhiro Ohara
  4. *
  5. * This file is part of GNU Zebra.
  6. *
  7. * GNU Zebra is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2, or (at your option) any
  10. * later version.
  11. *
  12. * GNU Zebra is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Zebra; see the file COPYING. If not, write to the
  19. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. */
  22. #ifndef OSPF6_PROTO_H
  23. #define OSPF6_PROTO_H
  24. /* OSPF protocol version */
  25. #define OSPFV3_VERSION 3
  26. /* OSPF protocol number. */
  27. #ifndef IPPROTO_OSPFIGP
  28. #define IPPROTO_OSPFIGP 89
  29. #endif
  30. /* TOS field normaly null */
  31. #define DEFAULT_TOS_VALUE 0x0
  32. /* Architectural Constants */
  33. #define LS_REFRESH_TIME 1800 /* 30 min */
  34. #define MIN_LS_INTERVAL 5
  35. #define MIN_LS_ARRIVAL 1
  36. #define MAXAGE 3600 /* 1 hour */
  37. #define CHECK_AGE 300 /* 5 min */
  38. #define MAX_AGE_DIFF 900 /* 15 min */
  39. #define LS_INFINITY 0xffffff /* 24-bit binary value */
  40. #define INITIAL_SEQUENCE_NUMBER 0x80000001 /* signed 32-bit integer */
  41. #define MAX_SEQUENCE_NUMBER 0x7fffffff /* signed 32-bit integer */
  42. #define ALLSPFROUTERS6 "ff02::5"
  43. #define ALLDROUTERS6 "ff02::6"
  44. /* Configurable Constants */
  45. #define DEFAULT_HELLO_INTERVAL 10
  46. #define DEFAULT_ROUTER_DEAD_INTERVAL 40
  47. #define OSPF6_ROUTER_BIT_W (1 << 3)
  48. #define OSPF6_ROUTER_BIT_V (1 << 2)
  49. #define OSPF6_ROUTER_BIT_E (1 << 1)
  50. #define OSPF6_ROUTER_BIT_B (1 << 0)
  51. /* OSPF options */
  52. /* present in HELLO, DD, LSA */
  53. #define OSPF6_OPT_SET(x,opt) ((x)[2] |= (opt))
  54. #define OSPF6_OPT_ISSET(x,opt) ((x)[2] & (opt))
  55. #define OSPF6_OPT_CLEAR(x,opt) ((x)[2] &= ~(opt))
  56. #define OSPF6_OPT_CLEAR_ALL(x) ((x)[0] = (x)[1] = (x)[2] = 0)
  57. #define OSPF6_OPT_DC (1 << 5) /* Demand Circuit handling Capability */
  58. #define OSPF6_OPT_R (1 << 4) /* Forwarding Capability (Any Protocol) */
  59. #define OSPF6_OPT_N (1 << 3) /* Handling Type-7 LSA Capability */
  60. #define OSPF6_OPT_MC (1 << 2) /* Multicasting Capability */
  61. #define OSPF6_OPT_E (1 << 1) /* AS External Capability */
  62. #define OSPF6_OPT_V6 (1 << 0) /* IPv6 forwarding Capability */
  63. /* OSPF6 Prefix */
  64. struct ospf6_prefix
  65. {
  66. u_int8_t prefix_length;
  67. u_int8_t prefix_options;
  68. union {
  69. u_int16_t _prefix_metric;
  70. u_int16_t _prefix_referenced_lstype;
  71. } u;
  72. #define prefix_metric u._prefix_metric
  73. #define prefix_refer_lstype u._prefix_referenced_lstype
  74. /* followed by one address_prefix */
  75. };
  76. #define OSPF6_PREFIX_OPTION_NU (1 << 0) /* No Unicast */
  77. #define OSPF6_PREFIX_OPTION_LA (1 << 1) /* Local Address */
  78. #define OSPF6_PREFIX_OPTION_MC (1 << 2) /* MultiCast */
  79. #define OSPF6_PREFIX_OPTION_P (1 << 3) /* Propagate (NSSA) */
  80. /* caddr_t OSPF6_PREFIX_BODY (struct ospf6_prefix *); */
  81. #define OSPF6_PREFIX_BODY(x) ((caddr_t)(x) + sizeof (struct ospf6_prefix))
  82. /* size_t OSPF6_PREFIX_SPACE (int prefixlength); */
  83. #define OSPF6_PREFIX_SPACE(x) ((((x) + 31) / 32) * 4)
  84. /* size_t OSPF6_PREFIX_SIZE (struct ospf6_prefix *); */
  85. #define OSPF6_PREFIX_SIZE(x) \
  86. (OSPF6_PREFIX_SPACE ((x)->prefix_length) + sizeof (struct ospf6_prefix))
  87. /* struct ospf6_prefix *OSPF6_PREFIX_NEXT (struct ospf6_prefix *); */
  88. #define OSPF6_PREFIX_NEXT(x) \
  89. ((struct ospf6_prefix *)((caddr_t)(x) + OSPF6_PREFIX_SIZE (x)))
  90. #define ospf6_prefix_in6_addr(in6, op) \
  91. do { \
  92. memset (in6, 0, sizeof (struct in6_addr)); \
  93. memcpy (in6, (caddr_t) (op) + sizeof (struct ospf6_prefix), \
  94. OSPF6_PREFIX_SPACE ((op)->prefix_length)); \
  95. } while (0)
  96. extern void ospf6_prefix_apply_mask (struct ospf6_prefix *op);
  97. extern void ospf6_prefix_options_printbuf (u_int8_t prefix_options,
  98. char *buf, int size);
  99. extern void ospf6_capability_printbuf (char capability, char *buf, int size);
  100. extern void ospf6_options_printbuf (u_char *options, char *buf, int size);
  101. #endif /* OSPF6_PROTO_H */