]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_pdu.h
Merge pull request #12851 from sri-mohan1/sri-mohan-ldp
[mirror_frr.git] / isisd / isis_pdu.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * IS-IS Rout(e)ing protocol - isis_pdu.h
4 * PDU processing
5 *
6 * Copyright (C) 2001,2002 Sampo Saaristo
7 * Tampere University of Technology
8 * Institute of Communications Engineering
9 */
10
11 #ifndef _ZEBRA_ISIS_PDU_H
12 #define _ZEBRA_ISIS_PDU_H
13
14 #include "isisd/isis_tx_queue.h"
15
16 #ifdef __SUNPRO_C
17 #pragma pack(1)
18 #endif
19
20 /*
21 * ISO 9542 - 7.5,7.6
22 *
23 * ES to IS Fixed Header
24 * +-------+-------+-------+-------+-------+-------+-------+-------+
25 * | Intradomain Routeing Protocol Discriminator |
26 * +-------+-------+-------+-------+-------+-------+-------+-------+
27 * | Length Indicator |
28 * +-------+-------+-------+-------+-------+-------+-------+-------+
29 * | Version/Protocol ID extension |
30 * +-------+-------+-------+-------+-------+-------+-------+-------+
31 * | Reserved = 0 |
32 * +-------+-------+-------+-------+-------+-------+-------+-------+
33 * | 0 | 0 | 0 | PDU Type |
34 * +-------+-------+-------+-------+-------+-------+-------+-------+
35 * | Holding Time | 2
36 * +-------+-------+-------+-------+-------+-------+-------+-------+
37 * | Checksum | 2
38 * +-------+-------+-------+-------+-------+-------+-------+-------+
39 */
40
41 struct esis_fixed_hdr {
42 uint8_t idrp;
43 uint8_t length;
44 uint8_t version;
45 uint8_t id_len;
46 uint8_t pdu_type;
47 uint16_t holdtime;
48 uint16_t checksum;
49 } __attribute__((packed));
50
51 #define ESIS_FIXED_HDR_LEN 9
52
53 #define ESH_PDU 2
54 #define ISH_PDU 4
55 #define RD_PDU 5
56
57 #define ISIS_FIXED_HDR_LEN 8
58
59 /*
60 * IS-IS PDU types.
61 */
62
63 #define L1_LAN_HELLO 15
64 #define L2_LAN_HELLO 16
65 /*
66 * L1 and L2 LAN IS to IS Hello PDU header
67 * +-------+-------+-------+-------+-------+-------+-------+-------+
68 * | Reserved | Circuit Type | 1
69 * +-------+-------+-------+-------+-------+-------+-------+-------+
70 * + Source ID + id_len
71 * +-------+-------+-------+-------+-------+-------+-------+-------+
72 * | Holding Time | 2
73 * +-------+-------+-------+-------+-------+-------+-------+-------+
74 * | PDU Length | 2
75 * +-------+-------+-------+-------+-------+-------+-------+-------+
76 * | R | Priority | 1
77 * +-------+-------+-------+-------+-------+-------+-------+-------+
78 * | LAN ID | id_len + 1
79 * +-------+-------+-------+-------+-------+-------+-------+-------+
80 */
81 struct isis_lan_hello_hdr {
82 uint8_t circuit_t;
83 uint8_t source_id[ISIS_SYS_ID_LEN];
84 uint16_t hold_time;
85 uint16_t pdu_len;
86 uint8_t prio;
87 uint8_t lan_id[ISIS_SYS_ID_LEN + 1];
88 } __attribute__((packed));
89 #define ISIS_LANHELLO_HDRLEN 19
90
91 #define P2P_HELLO 17
92 /*
93 * Point-to-point IS to IS hello PDU header
94 * +-------+-------+-------+-------+-------+-------+-------+-------+
95 * | Reserved | Circuit Type | 1
96 * +-------+-------+-------+-------+-------+-------+-------+-------+
97 * + Source ID + id_len
98 * +-------+-------+-------+-------+-------+-------+-------+-------+
99 * + Holding Time + 2
100 * +-------+-------+-------+-------+-------+-------+-------+-------+
101 * + PDU Length + 2
102 * +-------+-------+-------+-------+-------+-------+-------+-------+
103 * | Local Circuit ID | 1
104 * +-------+-------+-------+-------+-------+-------+-------+-------+
105 */
106 struct isis_p2p_hello_hdr {
107 uint8_t circuit_t;
108 uint8_t source_id[ISIS_SYS_ID_LEN];
109 uint16_t hold_time;
110 uint16_t pdu_len;
111 uint8_t local_id;
112 } __attribute__((packed));
113 #define ISIS_P2PHELLO_HDRLEN 12
114
115 #define L1_LINK_STATE 18
116 #define L2_LINK_STATE 20
117 #define FS_LINK_STATE 10
118 #define L2_CIRCUIT_FLOODING_SCOPE 2
119 struct isis_lsp_hdr {
120 uint16_t pdu_len;
121 uint16_t rem_lifetime;
122 uint8_t lsp_id[ISIS_SYS_ID_LEN + 2];
123 uint32_t seqno;
124 uint16_t checksum;
125 uint8_t lsp_bits;
126 };
127 #define ISIS_LSP_HDR_LEN 19
128
129 /*
130 * Since the length field of LSP Entries TLV is one byte long, and each LSP
131 * entry is LSP_ENTRIES_LEN (16) bytes long, the maximum number of LSP entries
132 * can be accommodated in a TLV is
133 * 255 / 16 = 15.
134 *
135 * Therefore, the maximum length of the LSP Entries TLV is
136 * 16 * 15 + 2 (header) = 242 bytes.
137 */
138 #define MAX_LSP_ENTRIES_TLV_SIZE 242
139
140 #define L1_COMPLETE_SEQ_NUM 24
141 #define L2_COMPLETE_SEQ_NUM 25
142 /*
143 * L1 and L2 IS to IS complete sequence numbers PDU header
144 * +-------+-------+-------+-------+-------+-------+-------+-------+
145 * + PDU Length + 2
146 * +-------+-------+-------+-------+-------+-------+-------+-------+
147 * + Source ID + id_len + 1
148 * +-------+-------+-------+-------+-------+-------+-------+-------+
149 * + Start LSP ID + id_len + 2
150 * +-------+-------+-------+-------+-------+-------+-------+-------+
151 * + End LSP ID + id_len + 2
152 * +-------+-------+-------+-------+-------+-------+-------+-------+
153 */
154 struct isis_complete_seqnum_hdr {
155 uint16_t pdu_len;
156 uint8_t source_id[ISIS_SYS_ID_LEN + 1];
157 uint8_t start_lsp_id[ISIS_SYS_ID_LEN + 2];
158 uint8_t stop_lsp_id[ISIS_SYS_ID_LEN + 2];
159 };
160 #define ISIS_CSNP_HDRLEN 25
161
162 #define L1_PARTIAL_SEQ_NUM 26
163 #define L2_PARTIAL_SEQ_NUM 27
164 /*
165 * L1 and L2 IS to IS partial sequence numbers PDU header
166 * +-------+-------+-------+-------+-------+-------+-------+-------+
167 * + PDU Length + 2
168 * +-------+-------+-------+-------+-------+-------+-------+-------+
169 * + Source ID + id_len + 1
170 * +---------------------------------------------------------------+
171 */
172 struct isis_partial_seqnum_hdr {
173 uint16_t pdu_len;
174 uint8_t source_id[ISIS_SYS_ID_LEN + 1];
175 };
176 #define ISIS_PSNP_HDRLEN 9
177
178 #ifdef __SUNPRO_C
179 #pragma pack()
180 #endif
181
182 /*
183 * Function for receiving IS-IS PDUs
184 */
185 void isis_receive(struct thread *thread);
186
187 /*
188 * calling arguments for snp_process ()
189 */
190 #define ISIS_SNP_PSNP_FLAG 0
191 #define ISIS_SNP_CSNP_FLAG 1
192
193 #define ISIS_AUTH_MD5_SIZE 16U
194
195 /*
196 * Sending functions
197 */
198 void send_hello_sched(struct isis_circuit *circuit, int level, long delay);
199 int send_csnp(struct isis_circuit *circuit, int level);
200 void send_l1_csnp(struct thread *thread);
201 void send_l2_csnp(struct thread *thread);
202 void send_l1_psnp(struct thread *thread);
203 void send_l2_psnp(struct thread *thread);
204 void send_lsp(struct isis_circuit *circuit,
205 struct isis_lsp *lsp, enum isis_tx_type tx_type);
206 void fill_fixed_hdr(uint8_t pdu_type, struct stream *stream);
207 int send_hello(struct isis_circuit *circuit, int level);
208 int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa);
209 #endif /* _ZEBRA_ISIS_PDU_H */