ospf_opaque.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * This is an implementation of rfc2370.
  3. * Copyright (C) 2001 KDD R&D Laboratories, Inc.
  4. * http://www.kddlabs.co.jp/
  5. *
  6. * This file is part of GNU Zebra.
  7. *
  8. * GNU Zebra is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2, or (at your option) any
  11. * later version.
  12. *
  13. * GNU Zebra is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  20. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  21. * 02111-1307, USA.
  22. */
  23. #ifndef _ZEBRA_OSPF_OPAQUE_H
  24. #define _ZEBRA_OSPF_OPAQUE_H
  25. #include "vty.h"
  26. #define IS_OPAQUE_LSA(type) \
  27. ((type) == OSPF_OPAQUE_LINK_LSA || \
  28. (type) == OSPF_OPAQUE_AREA_LSA || \
  29. (type) == OSPF_OPAQUE_AS_LSA)
  30. /*
  31. * Usage of Opaque-LSA administrative flags in "struct ospf".
  32. *
  33. * 7 6 5 4 3 2 1 0
  34. * +---+---+---+---+---+---+---+---+
  35. * |///|///|///|///|B11|B10|B09| O |
  36. * +---+---+---+---+---+---+---+---+
  37. * |<--------->| A
  38. * | +--- Operation status (operational = 1)
  39. * +----------- Blocking status for each LSA type
  40. */
  41. #define IS_OPAQUE_LSA_ORIGINATION_BLOCKED(V) \
  42. CHECK_FLAG((V), (OPAQUE_BLOCK_TYPE_09_LSA_BIT | \
  43. OPAQUE_BLOCK_TYPE_10_LSA_BIT | \
  44. OPAQUE_BLOCK_TYPE_11_LSA_BIT))
  45. /*
  46. * Opaque LSA's link state ID is redefined as follows.
  47. *
  48. * 24 16 8 0
  49. * +--------+--------+--------+--------+
  50. * |tttttttt|........|........|........|
  51. * +--------+--------+--------+--------+
  52. * |<-Type->|<------- Opaque ID ------>|
  53. */
  54. #define LSID_OPAQUE_TYPE_MASK 0xff000000 /* 8 bits */
  55. #define LSID_OPAQUE_ID_MASK 0x00ffffff /* 24 bits */
  56. #define GET_OPAQUE_TYPE(lsid) \
  57. (((u_int32_t)(lsid) & LSID_OPAQUE_TYPE_MASK) >> 24)
  58. #define GET_OPAQUE_ID(lsid) \
  59. ((u_int32_t)(lsid) & LSID_OPAQUE_ID_MASK)
  60. #define SET_OPAQUE_LSID(type, id) \
  61. ((((type) << 24) & LSID_OPAQUE_TYPE_MASK) \
  62. | ((id) & LSID_OPAQUE_ID_MASK))
  63. /*
  64. * Opaque LSA types will be assigned by IANA.
  65. * <http://www.iana.org/assignments/ospf-opaque-types>
  66. */
  67. #define OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA 1
  68. #define OPAQUE_TYPE_SYCAMORE_OPTICAL_TOPOLOGY_DESC 2
  69. #define OPAQUE_TYPE_GRACE_LSA 3
  70. /* Followings types are proposed in internet-draft documents. */
  71. #define OPAQUE_TYPE_8021_QOSPF 129
  72. #define OPAQUE_TYPE_SECONDARY_NEIGHBOR_DISCOVERY 224
  73. #define OPAQUE_TYPE_FLOODGATE 225
  74. /* Ugly hack to make use of an unallocated value for wildcard matching! */
  75. #define OPAQUE_TYPE_WILDCARD 0
  76. #define OPAQUE_TYPE_RANGE_UNASSIGNED(type) \
  77. ( 4 <= (type) && (type) <= 127)
  78. #define OPAQUE_TYPE_RANGE_RESERVED(type) \
  79. (127 < (type) && (type) <= 255)
  80. #define VALID_OPAQUE_INFO_LEN(lsahdr) \
  81. ((ntohs((lsahdr)->length) >= sizeof (struct lsa_header)) && \
  82. ((ntohs((lsahdr)->length) % sizeof (u_int32_t)) == 0))
  83. /* Prototypes. */
  84. extern void ospf_opaque_init (void);
  85. extern void ospf_opaque_term (void);
  86. extern int ospf_opaque_type9_lsa_init (struct ospf_interface *oi);
  87. extern void ospf_opaque_type9_lsa_term (struct ospf_interface *oi);
  88. extern int ospf_opaque_type10_lsa_init (struct ospf_area *area);
  89. extern void ospf_opaque_type10_lsa_term (struct ospf_area *area);
  90. extern int ospf_opaque_type11_lsa_init (struct ospf *ospf);
  91. extern void ospf_opaque_type11_lsa_term (struct ospf *ospf);
  92. extern int
  93. ospf_register_opaque_functab (
  94. u_char lsa_type,
  95. u_char opaque_type,
  96. int (* new_if_hook)(struct interface *ifp),
  97. int (* del_if_hook)(struct interface *ifp),
  98. void (* ism_change_hook)(struct ospf_interface *oi, int old_status),
  99. void (* nsm_change_hook)(struct ospf_neighbor *nbr, int old_status),
  100. void (* config_write_router)(struct vty *vty),
  101. void (* config_write_if )(struct vty *vty, struct interface *ifp),
  102. void (* config_write_debug )(struct vty *vty),
  103. void (* show_opaque_info )(struct vty *vty, struct ospf_lsa *lsa),
  104. int (* lsa_originator)(void *arg),
  105. struct ospf_lsa *(* lsa_refresher )(struct ospf_lsa *lsa),
  106. int (* new_lsa_hook)(struct ospf_lsa *lsa),
  107. int (* del_lsa_hook)(struct ospf_lsa *lsa)
  108. );
  109. extern void ospf_delete_opaque_functab (u_char lsa_type, u_char opaque_type);
  110. extern int ospf_opaque_new_if (struct interface *ifp);
  111. extern int ospf_opaque_del_if (struct interface *ifp);
  112. extern void ospf_opaque_ism_change (struct ospf_interface *oi,
  113. int old_status);
  114. extern void ospf_opaque_nsm_change (struct ospf_neighbor *nbr,
  115. int old_status);
  116. extern void ospf_opaque_config_write_router (struct vty *vty, struct ospf *);
  117. extern void ospf_opaque_config_write_if (struct vty *vty,
  118. struct interface *ifp);
  119. extern void ospf_opaque_config_write_debug (struct vty *vty);
  120. extern void show_opaque_info_detail (struct vty *vty, struct ospf_lsa *lsa);
  121. extern void ospf_opaque_lsa_dump (struct stream *s, u_int16_t length);
  122. extern void ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi,
  123. int *init_delay);
  124. extern struct ospf_lsa *ospf_opaque_lsa_install (struct ospf_lsa *,
  125. int rt_recalc);
  126. extern struct ospf_lsa *ospf_opaque_lsa_refresh (struct ospf_lsa *lsa);
  127. extern void ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
  128. u_char lsa_type,
  129. u_char opaque_type);
  130. extern void ospf_opaque_lsa_refresh_schedule (struct ospf_lsa *lsa);
  131. extern void ospf_opaque_lsa_flush_schedule (struct ospf_lsa *lsa);
  132. extern void ospf_opaque_adjust_lsreq (struct ospf_neighbor *nbr,
  133. struct list *lsas);
  134. extern void ospf_opaque_self_originated_lsa_received (struct ospf_neighbor
  135. *nbr,
  136. struct ospf_lsa *lsa);
  137. extern void ospf_opaque_ls_ack_received (struct ospf_neighbor *nbr,
  138. struct ospf_lsa *lsa);
  139. extern void htonf (float *src, float *dst);
  140. extern void ntohf (float *src, float *dst);
  141. extern struct ospf *oi_to_top (struct ospf_interface *oi);
  142. #endif /* _ZEBRA_OSPF_OPAQUE_H */