blob: 3eca7319389144a0b7bd13b635e5980228f9e802 [file] [log] [blame]
jardineb5d44e2003-12-23 08:09:43 +00001/*
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
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24#ifndef _ZEBRA_ISIS_PDU_H
25#define _ZEBRA_ISIS_PDU_H
26
Paul Jakma238497f2007-08-07 18:49:18 +000027#ifdef __SUNPRO_C
28#pragma pack(1)
29#endif
30
jardineb5d44e2003-12-23 08:09:43 +000031/*
32 * ISO 9542 - 7.5,7.6
33 *
34 * ES to IS Fixed Header
35 * +-------+-------+-------+-------+-------+-------+-------+-------+
36 * | Intradomain Routeing Protocol Discriminator |
37 * +-------+-------+-------+-------+-------+-------+-------+-------+
38 * | Length Indicator |
39 * +-------+-------+-------+-------+-------+-------+-------+-------+
40 * | Version/Protocol ID extension |
41 * +-------+-------+-------+-------+-------+-------+-------+-------+
42 * | Reserved = 0 |
43 * +-------+-------+-------+-------+-------+-------+-------+-------+
44 * | 0 | 0 | 0 | PDU Type |
45 * +-------+-------+-------+-------+-------+-------+-------+-------+
46 * | Holding Time | 2
47 * +-------+-------+-------+-------+-------+-------+-------+-------+
48 * | Checksum | 2
49 * +-------+-------+-------+-------+-------+-------+-------+-------+
50 */
51
52struct esis_fixed_hdr
53{
54 u_char idrp;
55 u_char length;
56 u_char version;
57 u_char id_len;
58 u_char pdu_type;
59 u_int16_t holdtime;
60 u_int16_t checksum;
hassof390d2c2004-09-10 20:48:21 +000061} __attribute__ ((packed));
jardineb5d44e2003-12-23 08:09:43 +000062
63#define ESIS_FIXED_HDR_LEN 9
64
65#define ESH_PDU 2
66#define ISH_PDU 4
67#define RD_PDU 5
68
69/*
70 * IS to IS Fixed Header
71 * +-------+-------+-------+-------+-------+-------+-------+-------+
72 * | Intradomain Routeing Protocol Discriminator |
73 * +-------+-------+-------+-------+-------+-------+-------+-------+
74 * | Length Indicator |
75 * +-------+-------+-------+-------+-------+-------+-------+-------+
76 * | Version/Protocol ID extension |
77 * +-------+-------+-------+-------+-------+-------+-------+-------+
78 * | R | R | R | PDU Type |
79 * +-------+-------+-------+-------+-------+-------+-------+-------+
80 * | Version |
81 * +-------+-------+-------+-------+-------+-------+-------+-------+
82 * | Reserved |
83 * +-------+-------+-------+-------+-------+-------+-------+-------+
84 * | Maximum Area Addresses |
85 * +-------+-------+-------+-------+-------+-------+-------+-------+
86 */
87
hassof390d2c2004-09-10 20:48:21 +000088struct isis_fixed_hdr
jardineb5d44e2003-12-23 08:09:43 +000089{
90 u_char idrp;
91 u_char length;
92 u_char version1;
93 u_char id_len;
94 u_char pdu_type;
95 u_char version2;
96 u_char reserved;
97 u_char max_area_addrs;
Josh Bailey3f045a02012-03-24 08:35:20 -070098} __attribute__ ((packed));
jardineb5d44e2003-12-23 08:09:43 +000099
100#define ISIS_FIXED_HDR_LEN 8
101
102/*
103 * IS-IS PDU types.
104 */
105
106#define L1_LAN_HELLO 15
107#define L2_LAN_HELLO 16
108/*
109 * L1 and L2 LAN IS to IS Hello PDU header
110 * +-------+-------+-------+-------+-------+-------+-------+-------+
111 * | Reserved | Circuit Type | 1
112 * +-------+-------+-------+-------+-------+-------+-------+-------+
113 * + Source ID + id_len
114 * +-------+-------+-------+-------+-------+-------+-------+-------+
115 * | Holding Time | 2
116 * +-------+-------+-------+-------+-------+-------+-------+-------+
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700117 * | PDU Length | 2
jardineb5d44e2003-12-23 08:09:43 +0000118 * +-------+-------+-------+-------+-------+-------+-------+-------+
119 * | R | Priority | 1
120 * +-------+-------+-------+-------+-------+-------+-------+-------+
121 * | LAN ID | id_len + 1
122 * +-------+-------+-------+-------+-------+-------+-------+-------+
123 */
hassof390d2c2004-09-10 20:48:21 +0000124struct isis_lan_hello_hdr
125{
126 u_char circuit_t;
127 u_char source_id[ISIS_SYS_ID_LEN];
128 u_int16_t hold_time;
129 u_int16_t pdu_len;
130 u_char prio;
131 u_char lan_id[ISIS_SYS_ID_LEN + 1];
132} __attribute__ ((packed));
jardineb5d44e2003-12-23 08:09:43 +0000133#define ISIS_LANHELLO_HDRLEN 19
134
135#define P2P_HELLO 17
136/*
137 * Point-to-point IS to IS hello PDU header
138 * +-------+-------+-------+-------+-------+-------+-------+-------+
139 * | Reserved | Circuit Type | 1
140 * +-------+-------+-------+-------+-------+-------+-------+-------+
141 * + Source ID + id_len
142 * +-------+-------+-------+-------+-------+-------+-------+-------+
143 * + Holding Time + 2
144 * +-------+-------+-------+-------+-------+-------+-------+-------+
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700145 * + PDU Length + 2
jardineb5d44e2003-12-23 08:09:43 +0000146 * +-------+-------+-------+-------+-------+-------+-------+-------+
147 * | Local Circuit ID | 1
148 * +-------+-------+-------+-------+-------+-------+-------+-------+
149 */
hassof390d2c2004-09-10 20:48:21 +0000150struct isis_p2p_hello_hdr
151{
152 u_char circuit_t;
153 u_char source_id[ISIS_SYS_ID_LEN];
154 u_int16_t hold_time;
155 u_int16_t pdu_len;
jardineb5d44e2003-12-23 08:09:43 +0000156 u_char local_id;
hassof390d2c2004-09-10 20:48:21 +0000157} __attribute__ ((packed));
jardineb5d44e2003-12-23 08:09:43 +0000158#define ISIS_P2PHELLO_HDRLEN 12
159
160#define L1_LINK_STATE 18
161#define L2_LINK_STATE 20
162/*
163 * L1 and L2 IS to IS link state PDU header
164 * +-------+-------+-------+-------+-------+-------+-------+-------+
165 * + PDU Length + 2
166 * +-------+-------+-------+-------+-------+-------+-------+-------+
167 * + Remaining Lifetime + 2
168 * +-------+-------+-------+-------+-------+-------+-------+-------+
169 * | LSP ID | id_len + 2
170 * +-------+-------+-------+-------+-------+-------+-------+-------+
171 * + Sequence Number + 4
172 * +-------+-------+-------+-------+-------+-------+-------+-------+
173 * + Checksum + 2
174 * +-------+-------+-------+-------+-------+-------+-------+-------+
175 * | P | ATT |LSPDBOL| ISTYPE |
176 * +-------+-------+-------+-------+-------+-------+-------+-------+
177 */
hassof390d2c2004-09-10 20:48:21 +0000178struct isis_link_state_hdr
179{
180 u_int16_t pdu_len;
jardineb5d44e2003-12-23 08:09:43 +0000181 u_int16_t rem_lifetime;
hassof390d2c2004-09-10 20:48:21 +0000182 u_char lsp_id[ISIS_SYS_ID_LEN + 2];
jardineb5d44e2003-12-23 08:09:43 +0000183 u_int32_t seq_num;
184 u_int16_t checksum;
hassof390d2c2004-09-10 20:48:21 +0000185 u_int8_t lsp_bits;
186} __attribute__ ((packed));
jardineb5d44e2003-12-23 08:09:43 +0000187#define ISIS_LSP_HDR_LEN 19
188
Josh Bailey3f045a02012-03-24 08:35:20 -0700189/*
190 * Since the length field of LSP Entries TLV is one byte long, and each LSP
191 * entry is LSP_ENTRIES_LEN (16) bytes long, the maximum number of LSP entries
192 * can be accomodated in a TLV is
193 * 255 / 16 = 15.
194 *
195 * Therefore, the maximum length of the LSP Entries TLV is
196 * 16 * 15 + 2 (header) = 242 bytes.
197 */
198#define MAX_LSP_ENTRIES_TLV_SIZE 242
199
jardineb5d44e2003-12-23 08:09:43 +0000200#define L1_COMPLETE_SEQ_NUM 24
201#define L2_COMPLETE_SEQ_NUM 25
202/*
203 * L1 and L2 IS to IS complete sequence numbers PDU header
204 * +-------+-------+-------+-------+-------+-------+-------+-------+
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700205 * + PDU Length + 2
jardineb5d44e2003-12-23 08:09:43 +0000206 * +-------+-------+-------+-------+-------+-------+-------+-------+
207 * + Source ID + id_len + 1
208 * +-------+-------+-------+-------+-------+-------+-------+-------+
209 * + Start LSP ID + id_len + 2
210 * +-------+-------+-------+-------+-------+-------+-------+-------+
211 * + End LSP ID + id_len + 2
212 * +-------+-------+-------+-------+-------+-------+-------+-------+
213 */
hassof390d2c2004-09-10 20:48:21 +0000214struct isis_complete_seqnum_hdr
215{
jardineb5d44e2003-12-23 08:09:43 +0000216 u_int16_t pdu_len;
hassof390d2c2004-09-10 20:48:21 +0000217 u_char source_id[ISIS_SYS_ID_LEN + 1];
218 u_char start_lsp_id[ISIS_SYS_ID_LEN + 2];
219 u_char stop_lsp_id[ISIS_SYS_ID_LEN + 2];
jardineb5d44e2003-12-23 08:09:43 +0000220};
221#define ISIS_CSNP_HDRLEN 25
222
223#define L1_PARTIAL_SEQ_NUM 26
224#define L2_PARTIAL_SEQ_NUM 27
225/*
226 * L1 and L2 IS to IS partial sequence numbers PDU header
227 * +-------+-------+-------+-------+-------+-------+-------+-------+
228 * + PDU Length + 2
229 * +-------+-------+-------+-------+-------+-------+-------+-------+
230 * + Source ID + id_len + 1
231 * +---------------------------------------------------------------+
232 */
hassof390d2c2004-09-10 20:48:21 +0000233struct isis_partial_seqnum_hdr
234{
jardineb5d44e2003-12-23 08:09:43 +0000235 u_int16_t pdu_len;
hassof390d2c2004-09-10 20:48:21 +0000236 u_char source_id[ISIS_SYS_ID_LEN + 1];
jardineb5d44e2003-12-23 08:09:43 +0000237};
238#define ISIS_PSNP_HDRLEN 9
239
Paul Jakma238497f2007-08-07 18:49:18 +0000240#ifdef __SUNPRO_C
241#pragma pack()
242#endif
243
jardineb5d44e2003-12-23 08:09:43 +0000244/*
245 * Function for receiving IS-IS PDUs
246 */
247int isis_receive (struct thread *thread);
248
249/*
250 * calling arguments for snp_process ()
251 */
252#define ISIS_SNP_PSNP_FLAG 0
253#define ISIS_SNP_CSNP_FLAG 1
254
Josh Bailey3f045a02012-03-24 08:35:20 -0700255#define ISIS_AUTH_MD5_SIZE 16U
256
jardineb5d44e2003-12-23 08:09:43 +0000257/*
258 * Sending functions
259 */
hassof390d2c2004-09-10 20:48:21 +0000260int send_lan_l1_hello (struct thread *thread);
261int send_lan_l2_hello (struct thread *thread);
262int send_p2p_hello (struct thread *thread);
263int send_csnp (struct isis_circuit *circuit, int level);
264int send_l1_csnp (struct thread *thread);
265int send_l2_csnp (struct thread *thread);
266int send_l1_psnp (struct thread *thread);
267int send_l2_psnp (struct thread *thread);
268int send_lsp (struct thread *thread);
269int ack_lsp (struct isis_link_state_hdr *hdr,
270 struct isis_circuit *circuit, int level);
271void fill_fixed_hdr (struct isis_fixed_hdr *hdr, u_char pdu_type);
272int send_hello (struct isis_circuit *circuit, int level);
jardineb5d44e2003-12-23 08:09:43 +0000273
jardineb5d44e2003-12-23 08:09:43 +0000274#endif /* _ZEBRA_ISIS_PDU_H */