bgp_encap_types.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * Copyright 2015, LabN Consulting, L.L.C.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. */
  19. #ifndef _QUAGGA_BGP_ENCAP_TYPES_H
  20. #define _QUAGGA_BGP_ENCAP_TYPES_H
  21. /* from http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#tunnel-types */
  22. typedef enum {
  23. BGP_ENCAP_TYPE_RESERVED=0,
  24. BGP_ENCAP_TYPE_L2TPV3_OVER_IP=1,
  25. BGP_ENCAP_TYPE_GRE=2,
  26. BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT=3,
  27. BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE=4,
  28. BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE=5,
  29. BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE=6,
  30. BGP_ENCAP_TYPE_IP_IN_IP=7,
  31. BGP_ENCAP_TYPE_VXLAN=8,
  32. BGP_ENCAP_TYPE_NVGRE=9,
  33. BGP_ENCAP_TYPE_MPLS=10,
  34. BGP_ENCAP_TYPE_MPLS_IN_GRE=11,
  35. BGP_ENCAP_TYPE_VXLAN_GPE=12,
  36. BGP_ENCAP_TYPE_MPLS_IN_UDP=13,
  37. BGP_ENCAP_TYPE_PBB
  38. } bgp_encap_types;
  39. typedef enum {
  40. BGP_ENCAP_SUBTLV_TYPE_ENCAPSULATION=1,
  41. BGP_ENCAP_SUBTLV_TYPE_PROTO_TYPE=2,
  42. BGP_ENCAP_SUBTLV_TYPE_IPSEC_TA=3,
  43. BGP_ENCAP_SUBTLV_TYPE_COLOR=4,
  44. BGP_ENCAP_SUBTLV_TYPE_REMOTE_ENDPOINT=6 /* speculative, IANA assignment TBD */
  45. } bgp_encap_subtlv_types;
  46. /*
  47. * Tunnel Encapsulation Attribute subtlvs
  48. */
  49. struct bgp_tea_subtlv_encap_l2tpv3_over_ip {
  50. uint32_t sessionid;
  51. uint8_t cookie_length;
  52. uint8_t cookie[8];
  53. };
  54. struct bgp_tea_subtlv_encap_gre_key {
  55. uint32_t gre_key;
  56. };
  57. struct bgp_tea_subtlv_encap_pbb {
  58. uint32_t flag_isid:1;
  59. uint32_t flag_vid:1;
  60. uint32_t isid:24;
  61. uint16_t vid:12;
  62. uint8_t macaddr[6];
  63. };
  64. struct bgp_tea_subtlv_proto_type {
  65. uint16_t proto; /* ether-type */
  66. };
  67. struct bgp_tea_subtlv_color {
  68. uint32_t color;
  69. };
  70. /* per draft-rosen-idr-tunnel-encaps */
  71. struct bgp_tea_subtlv_remote_endpoint {
  72. u_char family; /* IPv4 or IPv6 */
  73. union {
  74. struct in_addr v4;
  75. struct in6_addr v6;
  76. } ip_address;
  77. as_t as4; /* always 4 bytes */
  78. };
  79. /*
  80. * This is the length of the value part of the ipsec tunnel authenticator
  81. * subtlv. Currently we only support the length for authenticator type 1.
  82. */
  83. #define BGP_ENCAP_SUBTLV_IPSEC_TA_SIZE 20
  84. struct bgp_tea_subtlv_ipsec_ta {
  85. uint16_t authenticator_type; /* only type 1 is supported so far */
  86. uint8_t authenticator_length; /* octets in value field */
  87. uint8_t value[BGP_ENCAP_SUBTLV_IPSEC_TA_SIZE];
  88. };
  89. /*
  90. * Subtlv valid flags
  91. * TBD change names to add "VALID"
  92. */
  93. #define BGP_TEA_SUBTLV_ENCAP 0x00000001
  94. #define BGP_TEA_SUBTLV_PROTO_TYPE 0x00000002
  95. #define BGP_TEA_SUBTLV_COLOR 0x00000004
  96. #define BGP_TEA_SUBTLV_IPSEC_TA 0x00000008
  97. #define BGP_TEA_SUBTLV_REMOTE_ENDPOINT 0x00000010
  98. #define CHECK_SUBTLV_FLAG(ptr, flag) CHECK_FLAG((ptr)->valid_subtlvs, (flag))
  99. #define SET_SUBTLV_FLAG(ptr, flag) SET_FLAG((ptr)->valid_subtlvs, (flag))
  100. #define UNSET_SUBTLV_FLAG(ptr, flag) UNSET_FLAG((ptr)->valid_subtlvs, (flag))
  101. /*
  102. * Tunnel Type-specific APIs
  103. */
  104. struct bgp_encap_type_reserved {
  105. uint32_t valid_subtlvs;
  106. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  107. };
  108. struct bgp_encap_type_l2tpv3_over_ip {
  109. uint32_t valid_subtlvs;
  110. struct bgp_tea_subtlv_encap_l2tpv3_over_ip st_encap;
  111. struct bgp_tea_subtlv_proto_type st_proto; /* optional */
  112. struct bgp_tea_subtlv_color st_color; /* optional */
  113. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  114. };
  115. struct bgp_encap_type_gre {
  116. uint32_t valid_subtlvs;
  117. struct bgp_tea_subtlv_encap_gre_key st_encap; /* optional */
  118. struct bgp_tea_subtlv_proto_type st_proto; /* optional */
  119. struct bgp_tea_subtlv_color st_color; /* optional */
  120. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  121. };
  122. struct bgp_encap_type_ip_in_ip {
  123. uint32_t valid_subtlvs;
  124. struct bgp_tea_subtlv_proto_type st_proto; /* optional */
  125. struct bgp_tea_subtlv_color st_color; /* optional */
  126. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  127. };
  128. struct bgp_encap_type_transmit_tunnel_endpoint {
  129. uint32_t valid_subtlvs;
  130. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  131. /* No subtlvs defined in spec? */
  132. };
  133. struct bgp_encap_type_ipsec_in_tunnel_mode {
  134. uint32_t valid_subtlvs;
  135. struct bgp_tea_subtlv_ipsec_ta st_ipsec_ta; /* optional */
  136. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  137. };
  138. struct bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode {
  139. uint32_t valid_subtlvs;
  140. struct bgp_tea_subtlv_ipsec_ta st_ipsec_ta; /* optional */
  141. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  142. };
  143. struct bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode {
  144. uint32_t valid_subtlvs;
  145. struct bgp_tea_subtlv_ipsec_ta st_ipsec_ta; /* optional */
  146. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  147. };
  148. struct bgp_encap_type_vxlan {
  149. uint32_t valid_subtlvs;
  150. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  151. /* No subtlvs defined in spec? */
  152. };
  153. struct bgp_encap_type_nvgre {
  154. uint32_t valid_subtlvs;
  155. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  156. /* No subtlvs defined in spec? */
  157. };
  158. struct bgp_encap_type_mpls {
  159. uint32_t valid_subtlvs;
  160. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  161. /* No subtlvs defined in spec? */
  162. };
  163. struct bgp_encap_type_mpls_in_gre {
  164. uint32_t valid_subtlvs;
  165. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  166. /* No subtlvs defined in spec? */
  167. };
  168. struct bgp_encap_type_vxlan_gpe {
  169. uint32_t valid_subtlvs;
  170. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  171. /* No subtlvs defined in spec? */
  172. };
  173. struct bgp_encap_type_mpls_in_udp {
  174. uint32_t valid_subtlvs;
  175. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  176. /* No subtlvs defined in spec? */
  177. };
  178. struct bgp_encap_type_pbb {
  179. uint32_t valid_subtlvs;
  180. struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
  181. struct bgp_tea_subtlv_encap_pbb st_encap;
  182. };
  183. #endif /* _QUAGGA_BGP_ENCAP_TYPES_H */