]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_pdu.h
isisd: send/receive *SNPs with new parser
[mirror_frr.git] / isisd / isis_pdu.h
CommitLineData
eb5d44eb 1/*
2 * IS-IS Rout(e)ing protocol - isis_pdu.h
3 * PDU processing
4 *
5 * Copyright (C) 2001,2002 Sampo Saaristo
d62a17ae 6 * Tampere University of Technology
eb5d44eb 7 * Institute of Communications Engineering
8 *
d62a17ae 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)
eb5d44eb 12 * any later version.
13 *
d62a17ae 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
eb5d44eb 17 * more details.
896014f4
DL
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; see the file COPYING; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
eb5d44eb 22 */
23
24#ifndef _ZEBRA_ISIS_PDU_H
25#define _ZEBRA_ISIS_PDU_H
26
238497fc
PJ
27#ifdef __SUNPRO_C
28#pragma pack(1)
29#endif
30
eb5d44eb 31/*
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
d62a17ae 52struct esis_fixed_hdr {
53 u_char idrp;
54 u_char length;
55 u_char version;
56 u_char id_len;
57 u_char pdu_type;
58 u_int16_t holdtime;
59 u_int16_t checksum;
60} __attribute__((packed));
eb5d44eb 61
62#define ESIS_FIXED_HDR_LEN 9
63
64#define ESH_PDU 2
65#define ISH_PDU 4
66#define RD_PDU 5
67
eb5d44eb 68#define ISIS_FIXED_HDR_LEN 8
69
70/*
71 * IS-IS PDU types.
72 */
73
74#define L1_LAN_HELLO 15
75#define L2_LAN_HELLO 16
76/*
77 * L1 and L2 LAN IS to IS Hello PDU header
78 * +-------+-------+-------+-------+-------+-------+-------+-------+
79 * | Reserved | Circuit Type | 1
80 * +-------+-------+-------+-------+-------+-------+-------+-------+
d62a17ae 81 * + Source ID + id_len
eb5d44eb 82 * +-------+-------+-------+-------+-------+-------+-------+-------+
d62a17ae 83 * | Holding Time | 2
eb5d44eb 84 * +-------+-------+-------+-------+-------+-------+-------+-------+
d62a17ae 85 * | PDU Length | 2
eb5d44eb 86 * +-------+-------+-------+-------+-------+-------+-------+-------+
87 * | R | Priority | 1
88 * +-------+-------+-------+-------+-------+-------+-------+-------+
89 * | LAN ID | id_len + 1
90 * +-------+-------+-------+-------+-------+-------+-------+-------+
91 */
d62a17ae 92struct isis_lan_hello_hdr {
93 u_char circuit_t;
94 u_char source_id[ISIS_SYS_ID_LEN];
95 u_int16_t hold_time;
96 u_int16_t pdu_len;
97 u_char prio;
98 u_char lan_id[ISIS_SYS_ID_LEN + 1];
99} __attribute__((packed));
eb5d44eb 100#define ISIS_LANHELLO_HDRLEN 19
101
102#define P2P_HELLO 17
103/*
104 * Point-to-point IS to IS hello PDU header
105 * +-------+-------+-------+-------+-------+-------+-------+-------+
106 * | Reserved | Circuit Type | 1
107 * +-------+-------+-------+-------+-------+-------+-------+-------+
d62a17ae 108 * + Source ID + id_len
eb5d44eb 109 * +-------+-------+-------+-------+-------+-------+-------+-------+
d62a17ae 110 * + Holding Time + 2
eb5d44eb 111 * +-------+-------+-------+-------+-------+-------+-------+-------+
d62a17ae 112 * + PDU Length + 2
eb5d44eb 113 * +-------+-------+-------+-------+-------+-------+-------+-------+
114 * | Local Circuit ID | 1
115 * +-------+-------+-------+-------+-------+-------+-------+-------+
116 */
d62a17ae 117struct isis_p2p_hello_hdr {
118 u_char circuit_t;
119 u_char source_id[ISIS_SYS_ID_LEN];
120 u_int16_t hold_time;
121 u_int16_t pdu_len;
122 u_char local_id;
123} __attribute__((packed));
eb5d44eb 124#define ISIS_P2PHELLO_HDRLEN 12
125
126#define L1_LINK_STATE 18
127#define L2_LINK_STATE 20
128/*
129 * L1 and L2 IS to IS link state PDU header
130 * +-------+-------+-------+-------+-------+-------+-------+-------+
131 * + PDU Length + 2
132 * +-------+-------+-------+-------+-------+-------+-------+-------+
d62a17ae 133 * + Remaining Lifetime + 2
eb5d44eb 134 * +-------+-------+-------+-------+-------+-------+-------+-------+
135 * | LSP ID | id_len + 2
136 * +-------+-------+-------+-------+-------+-------+-------+-------+
137 * + Sequence Number + 4
138 * +-------+-------+-------+-------+-------+-------+-------+-------+
139 * + Checksum + 2
140 * +-------+-------+-------+-------+-------+-------+-------+-------+
141 * | P | ATT |LSPDBOL| ISTYPE |
142 * +-------+-------+-------+-------+-------+-------+-------+-------+
143 */
d62a17ae 144struct isis_link_state_hdr {
145 u_int16_t pdu_len;
146 u_int16_t rem_lifetime;
147 u_char lsp_id[ISIS_SYS_ID_LEN + 2];
148 u_int32_t seq_num;
149 u_int16_t checksum;
150 u_int8_t lsp_bits;
151} __attribute__((packed));
eb5d44eb 152#define ISIS_LSP_HDR_LEN 19
153
3f045a08
JB
154/*
155 * Since the length field of LSP Entries TLV is one byte long, and each LSP
156 * entry is LSP_ENTRIES_LEN (16) bytes long, the maximum number of LSP entries
157 * can be accomodated in a TLV is
158 * 255 / 16 = 15.
d62a17ae 159 *
3f045a08
JB
160 * Therefore, the maximum length of the LSP Entries TLV is
161 * 16 * 15 + 2 (header) = 242 bytes.
162 */
163#define MAX_LSP_ENTRIES_TLV_SIZE 242
164
eb5d44eb 165#define L1_COMPLETE_SEQ_NUM 24
166#define L2_COMPLETE_SEQ_NUM 25
167/*
168 * L1 and L2 IS to IS complete sequence numbers PDU header
169 * +-------+-------+-------+-------+-------+-------+-------+-------+
d62a17ae 170 * + PDU Length + 2
eb5d44eb 171 * +-------+-------+-------+-------+-------+-------+-------+-------+
172 * + Source ID + id_len + 1
173 * +-------+-------+-------+-------+-------+-------+-------+-------+
174 * + Start LSP ID + id_len + 2
175 * +-------+-------+-------+-------+-------+-------+-------+-------+
176 * + End LSP ID + id_len + 2
177 * +-------+-------+-------+-------+-------+-------+-------+-------+
178 */
d62a17ae 179struct isis_complete_seqnum_hdr {
180 u_int16_t pdu_len;
181 u_char source_id[ISIS_SYS_ID_LEN + 1];
182 u_char start_lsp_id[ISIS_SYS_ID_LEN + 2];
183 u_char stop_lsp_id[ISIS_SYS_ID_LEN + 2];
eb5d44eb 184};
185#define ISIS_CSNP_HDRLEN 25
186
187#define L1_PARTIAL_SEQ_NUM 26
188#define L2_PARTIAL_SEQ_NUM 27
189/*
190 * L1 and L2 IS to IS partial sequence numbers PDU header
191 * +-------+-------+-------+-------+-------+-------+-------+-------+
192 * + PDU Length + 2
193 * +-------+-------+-------+-------+-------+-------+-------+-------+
194 * + Source ID + id_len + 1
195 * +---------------------------------------------------------------+
196 */
d62a17ae 197struct isis_partial_seqnum_hdr {
198 u_int16_t pdu_len;
199 u_char source_id[ISIS_SYS_ID_LEN + 1];
eb5d44eb 200};
201#define ISIS_PSNP_HDRLEN 9
202
238497fc
PJ
203#ifdef __SUNPRO_C
204#pragma pack()
205#endif
206
eb5d44eb 207/*
208 * Function for receiving IS-IS PDUs
209 */
d62a17ae 210int isis_receive(struct thread *thread);
eb5d44eb 211
212/*
213 * calling arguments for snp_process ()
214 */
215#define ISIS_SNP_PSNP_FLAG 0
216#define ISIS_SNP_CSNP_FLAG 1
217
3f045a08
JB
218#define ISIS_AUTH_MD5_SIZE 16U
219
eb5d44eb 220/*
221 * Sending functions
222 */
d62a17ae 223int send_lan_l1_hello(struct thread *thread);
224int send_lan_l2_hello(struct thread *thread);
225int send_p2p_hello(struct thread *thread);
226int send_csnp(struct isis_circuit *circuit, int level);
227int send_l1_csnp(struct thread *thread);
228int send_l2_csnp(struct thread *thread);
229int send_l1_psnp(struct thread *thread);
230int send_l2_psnp(struct thread *thread);
231int send_lsp(struct thread *thread);
232int ack_lsp(struct isis_link_state_hdr *hdr, struct isis_circuit *circuit,
233 int level);
88f9d911 234void fill_fixed_hdr(uint8_t pdu_type, struct stream *stream);
d62a17ae 235int send_hello(struct isis_circuit *circuit, int level);
eb5d44eb 236
eb5d44eb 237#endif /* _ZEBRA_ISIS_PDU_H */