ospf_te.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * This is an implementation of draft-katz-yeung-ospf-traffic-06.txt
  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_MPLS_TE_H
  24. #define _ZEBRA_OSPF_MPLS_TE_H
  25. /*
  26. * Opaque LSA's link state ID for Traffic Engineering is
  27. * structured as follows.
  28. *
  29. * 24 16 8 0
  30. * +--------+--------+--------+--------+
  31. * | 1 | MBZ |........|........|
  32. * +--------+--------+--------+--------+
  33. * |<-Type->|<Resv'd>|<-- Instance --->|
  34. *
  35. *
  36. * Type: IANA has assigned '1' for Traffic Engineering.
  37. * MBZ: Reserved, must be set to zero.
  38. * Instance: User may select an arbitrary 16-bit value.
  39. *
  40. */
  41. #define MAX_LEGAL_TE_INSTANCE_NUM (0xffff)
  42. /*
  43. * 24 16 8 0
  44. * +--------+--------+--------+--------+ ---
  45. * | LS age |Options | 10 | A
  46. * +--------+--------+--------+--------+ |
  47. * | 1 | 0 | Instance | |
  48. * +--------+--------+--------+--------+ |
  49. * | Advertising router | | Standard (Opaque) LSA header;
  50. * +--------+--------+--------+--------+ | Only type-10 is used.
  51. * | LS sequence number | |
  52. * +--------+--------+--------+--------+ |
  53. * | LS checksum | Length | V
  54. * +--------+--------+--------+--------+ ---
  55. * | Type | Length | A
  56. * +--------+--------+--------+--------+ | TLV part for TE; Values might be
  57. * | Values ... | V structured as a set of sub-TLVs.
  58. * +--------+--------+--------+--------+ ---
  59. */
  60. /*
  61. * Following section defines TLV (tag, length, value) structures,
  62. * used for Traffic Engineering.
  63. */
  64. struct te_tlv_header
  65. {
  66. u_int16_t type; /* TE_TLV_XXX (see below) */
  67. u_int16_t length; /* Value portion only, in octets */
  68. };
  69. #define TLV_HDR_SIZE \
  70. (sizeof (struct te_tlv_header))
  71. #define TLV_BODY_SIZE(tlvh) \
  72. (ROUNDUP (ntohs ((tlvh)->length), sizeof (u_int32_t)))
  73. #define TLV_SIZE(tlvh) \
  74. (TLV_HDR_SIZE + TLV_BODY_SIZE(tlvh))
  75. #define TLV_HDR_TOP(lsah) \
  76. (struct te_tlv_header *)((char *)(lsah) + OSPF_LSA_HEADER_SIZE)
  77. #define TLV_HDR_NEXT(tlvh) \
  78. (struct te_tlv_header *)((char *)(tlvh) + TLV_SIZE(tlvh))
  79. /*
  80. * Following section defines TLV body parts.
  81. */
  82. /* Router Address TLV *//* Mandatory */
  83. #define TE_TLV_ROUTER_ADDR 1
  84. struct te_tlv_router_addr
  85. {
  86. struct te_tlv_header header; /* Value length is 4 octets. */
  87. struct in_addr value;
  88. };
  89. /* Link TLV */
  90. #define TE_TLV_LINK 2
  91. struct te_tlv_link
  92. {
  93. struct te_tlv_header header;
  94. /* A set of link-sub-TLVs will follow. */
  95. };
  96. /* Link Type Sub-TLV *//* Mandatory */
  97. #define TE_LINK_SUBTLV_LINK_TYPE 1
  98. struct te_link_subtlv_link_type
  99. {
  100. struct te_tlv_header header; /* Value length is 1 octet. */
  101. struct {
  102. #define LINK_TYPE_SUBTLV_VALUE_PTP 1
  103. #define LINK_TYPE_SUBTLV_VALUE_MA 2
  104. u_char value;
  105. u_char padding[3];
  106. } link_type;
  107. };
  108. /* Link Sub-TLV: Link ID *//* Mandatory */
  109. #define TE_LINK_SUBTLV_LINK_ID 2
  110. struct te_link_subtlv_link_id
  111. {
  112. struct te_tlv_header header; /* Value length is 4 octets. */
  113. struct in_addr value; /* Same as router-lsa's link-id. */
  114. };
  115. /* Link Sub-TLV: Local Interface IP Address *//* Optional */
  116. #define TE_LINK_SUBTLV_LCLIF_IPADDR 3
  117. struct te_link_subtlv_lclif_ipaddr
  118. {
  119. struct te_tlv_header header; /* Value length is 4 x N octets. */
  120. struct in_addr value[1]; /* Local IP address(es). */
  121. };
  122. /* Link Sub-TLV: Remote Interface IP Address *//* Optional */
  123. #define TE_LINK_SUBTLV_RMTIF_IPADDR 4
  124. struct te_link_subtlv_rmtif_ipaddr
  125. {
  126. struct te_tlv_header header; /* Value length is 4 x N octets. */
  127. struct in_addr value[1]; /* Neighbor's IP address(es). */
  128. };
  129. /* Link Sub-TLV: Traffic Engineering Metric *//* Optional */
  130. #define TE_LINK_SUBTLV_TE_METRIC 5
  131. struct te_link_subtlv_te_metric
  132. {
  133. struct te_tlv_header header; /* Value length is 4 octets. */
  134. u_int32_t value; /* Link metric for TE purpose. */
  135. };
  136. /* Link Sub-TLV: Maximum Bandwidth *//* Optional */
  137. #define TE_LINK_SUBTLV_MAX_BW 6
  138. struct te_link_subtlv_max_bw
  139. {
  140. struct te_tlv_header header; /* Value length is 4 octets. */
  141. float value; /* bytes/sec */
  142. };
  143. /* Link Sub-TLV: Maximum Reservable Bandwidth *//* Optional */
  144. #define TE_LINK_SUBTLV_MAX_RSV_BW 7
  145. struct te_link_subtlv_max_rsv_bw
  146. {
  147. struct te_tlv_header header; /* Value length is 4 octets. */
  148. float value; /* bytes/sec */
  149. };
  150. /* Link Sub-TLV: Unreserved Bandwidth *//* Optional */
  151. #define TE_LINK_SUBTLV_UNRSV_BW 8
  152. struct te_link_subtlv_unrsv_bw
  153. {
  154. struct te_tlv_header header; /* Value length is 32 octets. */
  155. float value[8]; /* One for each priority level. */
  156. };
  157. /* Link Sub-TLV: Resource Class/Color *//* Optional */
  158. #define TE_LINK_SUBTLV_RSC_CLSCLR 9
  159. struct te_link_subtlv_rsc_clsclr
  160. {
  161. struct te_tlv_header header; /* Value length is 4 octets. */
  162. u_int32_t value; /* Admin. group membership. */
  163. };
  164. /* Here are "non-official" architechtual constants. */
  165. #define MPLS_TE_MINIMUM_BANDWIDTH 1.0 /* Reasonable? *//* XXX */
  166. /* Prototypes. */
  167. extern int ospf_mpls_te_init (void);
  168. extern void ospf_mpls_te_term (void);
  169. #endif /* _ZEBRA_OSPF_MPLS_TE_H */