ospf_opaque.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. * Opaque LSA's link state ID is redefined as follows.
  32. *
  33. * 24 16 8 0
  34. * +--------+--------+--------+--------+
  35. * |tttttttt|........|........|........|
  36. * +--------+--------+--------+--------+
  37. * |<-Type->|<------- Opaque ID ------>|
  38. */
  39. #define LSID_OPAQUE_TYPE_MASK 0xff000000 /* 8 bits */
  40. #define LSID_OPAQUE_ID_MASK 0x00ffffff /* 24 bits */
  41. #define GET_OPAQUE_TYPE(lsid) \
  42. (((u_int32_t)(lsid) & LSID_OPAQUE_TYPE_MASK) >> 24)
  43. #define GET_OPAQUE_ID(lsid) \
  44. ((u_int32_t)(lsid) & LSID_OPAQUE_ID_MASK)
  45. #define SET_OPAQUE_LSID(type, id) \
  46. ((((type) << 24) & LSID_OPAQUE_TYPE_MASK) \
  47. | ((id) & LSID_OPAQUE_ID_MASK))
  48. /*
  49. * Opaque LSA types will be assigned by IANA.
  50. * <http://www.iana.org/assignments/ospf-opaque-types>
  51. */
  52. #define OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA 1
  53. #define OPAQUE_TYPE_SYCAMORE_OPTICAL_TOPOLOGY_DESC 2
  54. #define OPAQUE_TYPE_GRACE_LSA 3
  55. #define OPAQUE_TYPE_L1VPN_LSA 5
  56. #define OPAQUE_TYPE_ROUTER_INFORMATION_LSA 4
  57. #define OPAQUE_TYPE_INTER_AS_LSA 6
  58. #define OPAQUE_TYPE_MAX 6
  59. /* Followings types are proposed in internet-draft documents. */
  60. #define OPAQUE_TYPE_8021_QOSPF 129
  61. #define OPAQUE_TYPE_SECONDARY_NEIGHBOR_DISCOVERY 224
  62. #define OPAQUE_TYPE_FLOODGATE 225
  63. /* Ugly hack to make use of an unallocated value for wildcard matching! */
  64. #define OPAQUE_TYPE_WILDCARD 0
  65. #define OPAQUE_TYPE_RANGE_UNASSIGNED(type) \
  66. ( OPAQUE_TYPE_MAX <= (type) && (type) <= 127)
  67. #define OPAQUE_TYPE_RANGE_RESERVED(type) \
  68. (127 < (type) && (type) <= 255)
  69. #define VALID_OPAQUE_INFO_LEN(lsahdr) \
  70. ((ntohs((lsahdr)->length) >= sizeof (struct lsa_header)) && \
  71. ((ntohs((lsahdr)->length) % sizeof (u_int32_t)) == 0))
  72. /* Prototypes. */
  73. extern void ospf_opaque_init (void);
  74. extern void ospf_opaque_term (void);
  75. extern int ospf_opaque_type9_lsa_init (struct ospf_interface *oi);
  76. extern void ospf_opaque_type9_lsa_term (struct ospf_interface *oi);
  77. extern int ospf_opaque_type10_lsa_init (struct ospf_area *area);
  78. extern void ospf_opaque_type10_lsa_term (struct ospf_area *area);
  79. extern int ospf_opaque_type11_lsa_init (struct ospf *ospf);
  80. extern void ospf_opaque_type11_lsa_term (struct ospf *ospf);
  81. extern int
  82. ospf_register_opaque_functab (
  83. u_char lsa_type,
  84. u_char opaque_type,
  85. int (* new_if_hook)(struct interface *ifp),
  86. int (* del_if_hook)(struct interface *ifp),
  87. void (* ism_change_hook)(struct ospf_interface *oi, int old_status),
  88. void (* nsm_change_hook)(struct ospf_neighbor *nbr, int old_status),
  89. void (* config_write_router)(struct vty *vty),
  90. void (* config_write_if )(struct vty *vty, struct interface *ifp),
  91. void (* config_write_debug )(struct vty *vty),
  92. void (* show_opaque_info )(struct vty *vty, struct ospf_lsa *lsa),
  93. int (* lsa_originator)(void *arg),
  94. struct ospf_lsa *(* lsa_refresher )(struct ospf_lsa *lsa),
  95. int (* new_lsa_hook)(struct ospf_lsa *lsa),
  96. int (* del_lsa_hook)(struct ospf_lsa *lsa)
  97. );
  98. extern void ospf_delete_opaque_functab (u_char lsa_type, u_char opaque_type);
  99. extern int ospf_opaque_new_if (struct interface *ifp);
  100. extern int ospf_opaque_del_if (struct interface *ifp);
  101. extern void ospf_opaque_ism_change (struct ospf_interface *oi,
  102. int old_status);
  103. extern void ospf_opaque_nsm_change (struct ospf_neighbor *nbr,
  104. int old_status);
  105. extern void ospf_opaque_config_write_router (struct vty *vty, struct ospf *);
  106. extern void ospf_opaque_config_write_if (struct vty *vty,
  107. struct interface *ifp);
  108. extern void ospf_opaque_config_write_debug (struct vty *vty);
  109. extern void show_opaque_info_detail (struct vty *vty, struct ospf_lsa *lsa);
  110. extern void ospf_opaque_lsa_dump (struct stream *s, u_int16_t length);
  111. extern void ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi,
  112. int *init_delay);
  113. extern struct ospf_lsa *ospf_opaque_lsa_install (struct ospf_lsa *,
  114. int rt_recalc);
  115. extern struct ospf_lsa *ospf_opaque_lsa_refresh (struct ospf_lsa *lsa);
  116. extern void ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
  117. u_char lsa_type,
  118. u_char opaque_type);
  119. extern void ospf_opaque_lsa_refresh_schedule (struct ospf_lsa *lsa);
  120. extern void ospf_opaque_lsa_flush_schedule (struct ospf_lsa *lsa);
  121. extern void ospf_opaque_self_originated_lsa_received (struct ospf_neighbor
  122. *nbr,
  123. struct ospf_lsa *lsa);
  124. extern struct ospf *oi_to_top (struct ospf_interface *oi);
  125. #endif /* _ZEBRA_OSPF_OPAQUE_H */