isis_pdu.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * IS-IS Rout(e)ing protocol - isis_pdu.h
  3. * PDU processing
  4. *
  5. * Copyright (C) 2001,2002 Sampo Saaristo
  6. * Tampere University of Technology
  7. * Institute of Communications Engineering
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public Licenseas published by the Free
  11. * Software Foundation; either version 2 of the License, or (at your option)
  12. * any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  17. * more details.
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. #ifndef _ZEBRA_ISIS_PDU_H
  23. #define _ZEBRA_ISIS_PDU_H
  24. #ifdef __SUNPRO_C
  25. #pragma pack(1)
  26. #endif
  27. /*
  28. * ISO 9542 - 7.5,7.6
  29. *
  30. * ES to IS Fixed Header
  31. * +-------+-------+-------+-------+-------+-------+-------+-------+
  32. * | Intradomain Routeing Protocol Discriminator |
  33. * +-------+-------+-------+-------+-------+-------+-------+-------+
  34. * | Length Indicator |
  35. * +-------+-------+-------+-------+-------+-------+-------+-------+
  36. * | Version/Protocol ID extension |
  37. * +-------+-------+-------+-------+-------+-------+-------+-------+
  38. * | Reserved = 0 |
  39. * +-------+-------+-------+-------+-------+-------+-------+-------+
  40. * | 0 | 0 | 0 | PDU Type |
  41. * +-------+-------+-------+-------+-------+-------+-------+-------+
  42. * | Holding Time | 2
  43. * +-------+-------+-------+-------+-------+-------+-------+-------+
  44. * | Checksum | 2
  45. * +-------+-------+-------+-------+-------+-------+-------+-------+
  46. */
  47. struct esis_fixed_hdr
  48. {
  49. u_char idrp;
  50. u_char length;
  51. u_char version;
  52. u_char id_len;
  53. u_char pdu_type;
  54. u_int16_t holdtime;
  55. u_int16_t checksum;
  56. } __attribute__ ((packed));
  57. #define ESIS_FIXED_HDR_LEN 9
  58. #define ESH_PDU 2
  59. #define ISH_PDU 4
  60. #define RD_PDU 5
  61. /*
  62. * IS to IS Fixed Header
  63. * +-------+-------+-------+-------+-------+-------+-------+-------+
  64. * | Intradomain Routeing Protocol Discriminator |
  65. * +-------+-------+-------+-------+-------+-------+-------+-------+
  66. * | Length Indicator |
  67. * +-------+-------+-------+-------+-------+-------+-------+-------+
  68. * | Version/Protocol ID extension |
  69. * +-------+-------+-------+-------+-------+-------+-------+-------+
  70. * | R | R | R | PDU Type |
  71. * +-------+-------+-------+-------+-------+-------+-------+-------+
  72. * | Version |
  73. * +-------+-------+-------+-------+-------+-------+-------+-------+
  74. * | Reserved |
  75. * +-------+-------+-------+-------+-------+-------+-------+-------+
  76. * | Maximum Area Addresses |
  77. * +-------+-------+-------+-------+-------+-------+-------+-------+
  78. */
  79. struct isis_fixed_hdr
  80. {
  81. u_char idrp;
  82. u_char length;
  83. u_char version1;
  84. u_char id_len;
  85. u_char pdu_type;
  86. u_char version2;
  87. u_char reserved;
  88. u_char max_area_addrs;
  89. } __attribute__ ((packed));
  90. #define ISIS_FIXED_HDR_LEN 8
  91. /*
  92. * IS-IS PDU types.
  93. */
  94. #define L1_LAN_HELLO 15
  95. #define L2_LAN_HELLO 16
  96. /*
  97. * L1 and L2 LAN IS to IS Hello PDU header
  98. * +-------+-------+-------+-------+-------+-------+-------+-------+
  99. * | Reserved | Circuit Type | 1
  100. * +-------+-------+-------+-------+-------+-------+-------+-------+
  101. * + Source ID + id_len
  102. * +-------+-------+-------+-------+-------+-------+-------+-------+
  103. * | Holding Time | 2
  104. * +-------+-------+-------+-------+-------+-------+-------+-------+
  105. * | PDU Length | 2
  106. * +-------+-------+-------+-------+-------+-------+-------+-------+
  107. * | R | Priority | 1
  108. * +-------+-------+-------+-------+-------+-------+-------+-------+
  109. * | LAN ID | id_len + 1
  110. * +-------+-------+-------+-------+-------+-------+-------+-------+
  111. */
  112. struct isis_lan_hello_hdr
  113. {
  114. u_char circuit_t;
  115. u_char source_id[ISIS_SYS_ID_LEN];
  116. u_int16_t hold_time;
  117. u_int16_t pdu_len;
  118. u_char prio;
  119. u_char lan_id[ISIS_SYS_ID_LEN + 1];
  120. } __attribute__ ((packed));
  121. #define ISIS_LANHELLO_HDRLEN 19
  122. #define P2P_HELLO 17
  123. /*
  124. * Point-to-point IS to IS hello PDU header
  125. * +-------+-------+-------+-------+-------+-------+-------+-------+
  126. * | Reserved | Circuit Type | 1
  127. * +-------+-------+-------+-------+-------+-------+-------+-------+
  128. * + Source ID + id_len
  129. * +-------+-------+-------+-------+-------+-------+-------+-------+
  130. * + Holding Time + 2
  131. * +-------+-------+-------+-------+-------+-------+-------+-------+
  132. * + PDU Length + 2
  133. * +-------+-------+-------+-------+-------+-------+-------+-------+
  134. * | Local Circuit ID | 1
  135. * +-------+-------+-------+-------+-------+-------+-------+-------+
  136. */
  137. struct isis_p2p_hello_hdr
  138. {
  139. u_char circuit_t;
  140. u_char source_id[ISIS_SYS_ID_LEN];
  141. u_int16_t hold_time;
  142. u_int16_t pdu_len;
  143. u_char local_id;
  144. } __attribute__ ((packed));
  145. #define ISIS_P2PHELLO_HDRLEN 12
  146. #define L1_LINK_STATE 18
  147. #define L2_LINK_STATE 20
  148. /*
  149. * L1 and L2 IS to IS link state PDU header
  150. * +-------+-------+-------+-------+-------+-------+-------+-------+
  151. * + PDU Length + 2
  152. * +-------+-------+-------+-------+-------+-------+-------+-------+
  153. * + Remaining Lifetime + 2
  154. * +-------+-------+-------+-------+-------+-------+-------+-------+
  155. * | LSP ID | id_len + 2
  156. * +-------+-------+-------+-------+-------+-------+-------+-------+
  157. * + Sequence Number + 4
  158. * +-------+-------+-------+-------+-------+-------+-------+-------+
  159. * + Checksum + 2
  160. * +-------+-------+-------+-------+-------+-------+-------+-------+
  161. * | P | ATT |LSPDBOL| ISTYPE |
  162. * +-------+-------+-------+-------+-------+-------+-------+-------+
  163. */
  164. struct isis_link_state_hdr
  165. {
  166. u_int16_t pdu_len;
  167. u_int16_t rem_lifetime;
  168. u_char lsp_id[ISIS_SYS_ID_LEN + 2];
  169. u_int32_t seq_num;
  170. u_int16_t checksum;
  171. u_int8_t lsp_bits;
  172. } __attribute__ ((packed));
  173. #define ISIS_LSP_HDR_LEN 19
  174. /*
  175. * Since the length field of LSP Entries TLV is one byte long, and each LSP
  176. * entry is LSP_ENTRIES_LEN (16) bytes long, the maximum number of LSP entries
  177. * can be accomodated in a TLV is
  178. * 255 / 16 = 15.
  179. *
  180. * Therefore, the maximum length of the LSP Entries TLV is
  181. * 16 * 15 + 2 (header) = 242 bytes.
  182. */
  183. #define MAX_LSP_ENTRIES_TLV_SIZE 242
  184. #define L1_COMPLETE_SEQ_NUM 24
  185. #define L2_COMPLETE_SEQ_NUM 25
  186. /*
  187. * L1 and L2 IS to IS complete sequence numbers PDU header
  188. * +-------+-------+-------+-------+-------+-------+-------+-------+
  189. * + PDU Length + 2
  190. * +-------+-------+-------+-------+-------+-------+-------+-------+
  191. * + Source ID + id_len + 1
  192. * +-------+-------+-------+-------+-------+-------+-------+-------+
  193. * + Start LSP ID + id_len + 2
  194. * +-------+-------+-------+-------+-------+-------+-------+-------+
  195. * + End LSP ID + id_len + 2
  196. * +-------+-------+-------+-------+-------+-------+-------+-------+
  197. */
  198. struct isis_complete_seqnum_hdr
  199. {
  200. u_int16_t pdu_len;
  201. u_char source_id[ISIS_SYS_ID_LEN + 1];
  202. u_char start_lsp_id[ISIS_SYS_ID_LEN + 2];
  203. u_char stop_lsp_id[ISIS_SYS_ID_LEN + 2];
  204. };
  205. #define ISIS_CSNP_HDRLEN 25
  206. #define L1_PARTIAL_SEQ_NUM 26
  207. #define L2_PARTIAL_SEQ_NUM 27
  208. /*
  209. * L1 and L2 IS to IS partial sequence numbers PDU header
  210. * +-------+-------+-------+-------+-------+-------+-------+-------+
  211. * + PDU Length + 2
  212. * +-------+-------+-------+-------+-------+-------+-------+-------+
  213. * + Source ID + id_len + 1
  214. * +---------------------------------------------------------------+
  215. */
  216. struct isis_partial_seqnum_hdr
  217. {
  218. u_int16_t pdu_len;
  219. u_char source_id[ISIS_SYS_ID_LEN + 1];
  220. };
  221. #define ISIS_PSNP_HDRLEN 9
  222. #ifdef __SUNPRO_C
  223. #pragma pack()
  224. #endif
  225. /*
  226. * Function for receiving IS-IS PDUs
  227. */
  228. int isis_receive (struct thread *thread);
  229. /*
  230. * calling arguments for snp_process ()
  231. */
  232. #define ISIS_SNP_PSNP_FLAG 0
  233. #define ISIS_SNP_CSNP_FLAG 1
  234. #define ISIS_AUTH_MD5_SIZE 16U
  235. /*
  236. * Sending functions
  237. */
  238. int send_lan_l1_hello (struct thread *thread);
  239. int send_lan_l2_hello (struct thread *thread);
  240. int send_p2p_hello (struct thread *thread);
  241. int send_csnp (struct isis_circuit *circuit, int level);
  242. int send_l1_csnp (struct thread *thread);
  243. int send_l2_csnp (struct thread *thread);
  244. int send_l1_psnp (struct thread *thread);
  245. int send_l2_psnp (struct thread *thread);
  246. int send_lsp (struct thread *thread);
  247. int ack_lsp (struct isis_link_state_hdr *hdr,
  248. struct isis_circuit *circuit, int level);
  249. void fill_fixed_hdr (struct isis_fixed_hdr *hdr, u_char pdu_type);
  250. int send_hello (struct isis_circuit *circuit, int level);
  251. #endif /* _ZEBRA_ISIS_PDU_H */