ospf_ri.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * This is an implementation of RFC4970 Router Information
  3. * with support of RFC5088 PCE Capabilites announcement
  4. *
  5. * Module name: Router Information
  6. * Version: 0.99.22
  7. * Created: 2012-02-01 by Olivier Dugeon
  8. * Copyright (C) 2012 Orange Labs http://www.orange.com/
  9. *
  10. * This file is part of GNU Zebra.
  11. *
  12. * GNU Zebra is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2, or (at your option) any
  15. * later version.
  16. *
  17. * GNU Zebra is distributed in the hope that it will be useful, but
  18. * WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  24. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  25. * 02111-1307, USA.
  26. */
  27. #ifndef _ZEBRA_OSPF_ROUTER_INFO_H
  28. #define _ZEBRA_OSPF_ROUTER_INFO_H
  29. /*
  30. * Opaque LSA's link state ID for Router Information is
  31. * structured as follows.
  32. *
  33. * 24 16 8 0
  34. * +--------+--------+--------+--------+
  35. * | 1 | MBZ |........|........|
  36. * +--------+--------+--------+--------+
  37. * |<-Type->|<Resv'd>|<-- Instance --->|
  38. *
  39. *
  40. * Type: IANA has assigned '4' for Router Information.
  41. * MBZ: Reserved, must be set to zero.
  42. * Instance: User may select an arbitrary 16-bit value.
  43. *
  44. */
  45. /*
  46. * 24 16 8 0
  47. * +--------+--------+--------+--------+ ---
  48. * | LS age |Options | 9,10,11| A
  49. * +--------+--------+--------+--------+ |
  50. * | 4 | 0 | Instance | |
  51. * +--------+--------+--------+--------+ |
  52. * | Advertising router | | Standard (Opaque) LSA header;
  53. * +--------+--------+--------+--------+ | Type 9,10 or 11 are used.
  54. * | LS sequence number | |
  55. * +--------+--------+--------+--------+ |
  56. * | LS checksum | Length | V
  57. * +--------+--------+--------+--------+ ---
  58. * | Type | Length | A
  59. * +--------+--------+--------+--------+ | TLV part for Router Information; Values might be
  60. * | Values ... | V structured as a set of sub-TLVs.
  61. * +--------+--------+--------+--------+ ---
  62. */
  63. /*
  64. * Following section defines TLV (tag, length, value) structures,
  65. * used for Router Information.
  66. */
  67. struct ri_tlv_header
  68. {
  69. u_int16_t type; /* RI_TLV_XXX (see below) */
  70. u_int16_t length; /* Value portion only, in byte */
  71. };
  72. #define RI_TLV_HDR_SIZE (sizeof (struct ri_tlv_header))
  73. #define RI_TLV_BODY_SIZE(tlvh) (ROUNDUP (ntohs ((tlvh)->length), sizeof (u_int32_t)))
  74. #define RI_TLV_SIZE(tlvh) (RI_TLV_HDR_SIZE + RI_TLV_BODY_SIZE(tlvh))
  75. #define RI_TLV_HDR_TOP(lsah) (struct ri_tlv_header *)((char *)(lsah) + OSPF_LSA_HEADER_SIZE)
  76. #define RI_TLV_HDR_NEXT(tlvh) (struct ri_tlv_header *)((char *)(tlvh) + RI_TLV_SIZE(tlvh))
  77. /*
  78. * Following section defines TLV body parts.
  79. */
  80. /* Up to now, 8 code point have been assigned to Router Information */
  81. /* Only type 1 Router Capabilities and 6 PCE are supported with this code */
  82. #define RI_IANA_MAX_TYPE 8
  83. /* RFC4970: Router Information Capabilities TLV */ /* Mandatory */
  84. #define RI_TLV_CAPABILITIES 1
  85. struct ri_tlv_router_cap
  86. {
  87. struct ri_tlv_header header; /* Value length is 4 bytes. */
  88. u_int32_t value;
  89. };
  90. #define RI_GRACE_RESTART 0x01
  91. #define RI_GRACE_HELPER 0x02
  92. #define RI_STUB_SUPPORT 0x04
  93. #define RI_TE_SUPPORT 0x08
  94. #define RI_P2P_OVER_LAN 0x10
  95. #define RI_TE_EXPERIMENTAL 0x20
  96. #define RI_TLV_LENGTH 4
  97. /* RFC5088: PCE Capabilities TLV */ /* Optional */
  98. /* RI PCE TLV */
  99. #define RI_TLV_PCE 6
  100. struct ri_tlv_pce
  101. {
  102. struct ri_tlv_header header;
  103. /* A set of PCE-sub-TLVs will follow. */
  104. };
  105. /* PCE Address Sub-TLV */ /* Mandatory */
  106. #define RI_PCE_SUBTLV_ADDRESS 1
  107. struct ri_pce_subtlv_address
  108. {
  109. struct ri_tlv_header header; /* Type = 1; Length is 8 (IPv4) or 20 (IPv6) bytes. */
  110. #define PCE_ADDRESS_LENGTH_IPV4 8
  111. #define PCE_ADDRESS_LENGTH_IPV6 20
  112. struct
  113. {
  114. u_int16_t type; /* Address type: 1 = IPv4, 2 = IPv6 */
  115. #define PCE_ADDRESS_TYPE_IPV4 1
  116. #define PCE_ADDRESS_TYPE_IPV6 2
  117. u_int16_t reserved;
  118. struct in_addr value; /* PCE address */
  119. } address;
  120. };
  121. /* PCE Path-Scope Sub-TLV */ /* Mandatory */
  122. #define RI_PCE_SUBTLV_PATH_SCOPE 2
  123. struct ri_pce_subtlv_path_scope
  124. {
  125. struct ri_tlv_header header; /* Type = 2; Length = 4 bytes. */
  126. u_int32_t value; /* L, R, Rd, S, Sd, Y, PrefL, PrefR, PrefS and PrefY bits see RFC5088 page 9 */
  127. };
  128. /* PCE Domain Sub-TLV */ /* Optional */
  129. #define RI_PCE_SUBTLV_DOMAIN 3
  130. #define PCE_DOMAIN_TYPE_AREA 1
  131. #define PCE_DOMAIN_TYPE_AS 2
  132. struct ri_pce_subtlv_domain
  133. {
  134. struct ri_tlv_header header; /* Type = 3; Length = 8 bytes. */
  135. u_int16_t type; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
  136. u_int16_t reserved;
  137. u_int32_t value;
  138. };
  139. /* PCE Neighbor Sub-TLV */ /* Mandatory if R or S bit is set */
  140. #define RI_PCE_SUBTLV_NEIGHBOR 4
  141. struct ri_pce_subtlv_neighbor
  142. {
  143. struct ri_tlv_header header; /* Type = 4; Length = 8 bytes. */
  144. u_int16_t type; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
  145. u_int16_t reserved;
  146. u_int32_t value;
  147. };
  148. /* PCE Capabilities Flags Sub-TLV */ /* Optional */
  149. #define RI_PCE_SUBTLV_CAP_FLAG 5
  150. #define PCE_CAP_GMPLS_LINK 0x0001
  151. #define PCE_CAP_BIDIRECTIONAL 0x0002
  152. #define PCE_CAP_DIVERSE_PATH 0x0004
  153. #define PCE_CAP_LOAD_BALANCE 0x0008
  154. #define PCE_CAP_SYNCHRONIZED 0x0010
  155. #define PCE_CAP_OBJECTIVES 0x0020
  156. #define PCE_CAP_ADDITIVE 0x0040
  157. #define PCE_CAP_PRIORIZATION 0x0080
  158. #define PCE_CAP_MULTIPLE_REQ 0x0100
  159. struct ri_pce_subtlv_cap_flag
  160. {
  161. struct ri_tlv_header header; /* Type = 5; Length = n x 4 bytes. */
  162. u_int32_t value;
  163. };
  164. /* Prototypes. */
  165. extern int ospf_router_info_init (void);
  166. extern void ospf_router_info_term (void);
  167. #endif /* _ZEBRA_OSPF_ROUTER_INFO_H */