jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 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 | |
| 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 | |
| 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 | |
| 48 | struct esis_fixed_hdr |
| 49 | { |
| 50 | u_char idrp; |
| 51 | u_char length; |
| 52 | u_char version; |
| 53 | u_char id_len; |
| 54 | u_char pdu_type; |
| 55 | u_int16_t holdtime; |
| 56 | u_int16_t checksum; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 57 | } __attribute__ ((packed)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 58 | |
| 59 | #define ESIS_FIXED_HDR_LEN 9 |
| 60 | |
| 61 | #define ESH_PDU 2 |
| 62 | #define ISH_PDU 4 |
| 63 | #define RD_PDU 5 |
| 64 | |
| 65 | /* |
| 66 | * IS to IS Fixed Header |
| 67 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 68 | * | Intradomain Routeing Protocol Discriminator | |
| 69 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 70 | * | Length Indicator | |
| 71 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 72 | * | Version/Protocol ID extension | |
| 73 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 74 | * | R | R | R | PDU Type | |
| 75 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 76 | * | Version | |
| 77 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 78 | * | Reserved | |
| 79 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 80 | * | Maximum Area Addresses | |
| 81 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 82 | */ |
| 83 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 84 | struct isis_fixed_hdr |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 85 | { |
| 86 | u_char idrp; |
| 87 | u_char length; |
| 88 | u_char version1; |
| 89 | u_char id_len; |
| 90 | u_char pdu_type; |
| 91 | u_char version2; |
| 92 | u_char reserved; |
| 93 | u_char max_area_addrs; |
| 94 | }; |
| 95 | |
| 96 | #define ISIS_FIXED_HDR_LEN 8 |
| 97 | |
| 98 | /* |
| 99 | * IS-IS PDU types. |
| 100 | */ |
| 101 | |
| 102 | #define L1_LAN_HELLO 15 |
| 103 | #define L2_LAN_HELLO 16 |
| 104 | /* |
| 105 | * L1 and L2 LAN IS to IS Hello PDU header |
| 106 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 107 | * | Reserved | Circuit Type | 1 |
| 108 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 109 | * + Source ID + id_len |
| 110 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 111 | * | Holding Time | 2 |
| 112 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 113 | * | PDU Lenght | 2 |
| 114 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 115 | * | R | Priority | 1 |
| 116 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 117 | * | LAN ID | id_len + 1 |
| 118 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 119 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 120 | struct isis_lan_hello_hdr |
| 121 | { |
| 122 | u_char circuit_t; |
| 123 | u_char source_id[ISIS_SYS_ID_LEN]; |
| 124 | u_int16_t hold_time; |
| 125 | u_int16_t pdu_len; |
| 126 | u_char prio; |
| 127 | u_char lan_id[ISIS_SYS_ID_LEN + 1]; |
| 128 | } __attribute__ ((packed)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 129 | #define ISIS_LANHELLO_HDRLEN 19 |
| 130 | |
| 131 | #define P2P_HELLO 17 |
| 132 | /* |
| 133 | * Point-to-point IS to IS hello PDU header |
| 134 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 135 | * | Reserved | Circuit Type | 1 |
| 136 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 137 | * + Source ID + id_len |
| 138 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 139 | * + Holding Time + 2 |
| 140 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 141 | * + PDU Lenght + 2 |
| 142 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 143 | * | Local Circuit ID | 1 |
| 144 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 145 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 146 | struct isis_p2p_hello_hdr |
| 147 | { |
| 148 | u_char circuit_t; |
| 149 | u_char source_id[ISIS_SYS_ID_LEN]; |
| 150 | u_int16_t hold_time; |
| 151 | u_int16_t pdu_len; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 152 | u_char local_id; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 153 | } __attribute__ ((packed)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 154 | #define ISIS_P2PHELLO_HDRLEN 12 |
| 155 | |
| 156 | #define L1_LINK_STATE 18 |
| 157 | #define L2_LINK_STATE 20 |
| 158 | /* |
| 159 | * L1 and L2 IS to IS link state PDU header |
| 160 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 161 | * + PDU Length + 2 |
| 162 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 163 | * + Remaining Lifetime + 2 |
| 164 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 165 | * | LSP ID | id_len + 2 |
| 166 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 167 | * + Sequence Number + 4 |
| 168 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 169 | * + Checksum + 2 |
| 170 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 171 | * | P | ATT |LSPDBOL| ISTYPE | |
| 172 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 173 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 174 | struct isis_link_state_hdr |
| 175 | { |
| 176 | u_int16_t pdu_len; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 177 | u_int16_t rem_lifetime; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 178 | u_char lsp_id[ISIS_SYS_ID_LEN + 2]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 179 | u_int32_t seq_num; |
| 180 | u_int16_t checksum; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 181 | u_int8_t lsp_bits; |
| 182 | } __attribute__ ((packed)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 183 | #define ISIS_LSP_HDR_LEN 19 |
| 184 | |
| 185 | #define L1_COMPLETE_SEQ_NUM 24 |
| 186 | #define L2_COMPLETE_SEQ_NUM 25 |
| 187 | /* |
| 188 | * L1 and L2 IS to IS complete sequence numbers PDU header |
| 189 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 190 | * + PDU Lenght + 2 |
| 191 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 192 | * + Source ID + id_len + 1 |
| 193 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 194 | * + Start LSP ID + id_len + 2 |
| 195 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 196 | * + End LSP ID + id_len + 2 |
| 197 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 198 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 199 | struct isis_complete_seqnum_hdr |
| 200 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 201 | u_int16_t pdu_len; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 202 | u_char source_id[ISIS_SYS_ID_LEN + 1]; |
| 203 | u_char start_lsp_id[ISIS_SYS_ID_LEN + 2]; |
| 204 | u_char stop_lsp_id[ISIS_SYS_ID_LEN + 2]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 205 | }; |
| 206 | #define ISIS_CSNP_HDRLEN 25 |
| 207 | |
| 208 | #define L1_PARTIAL_SEQ_NUM 26 |
| 209 | #define L2_PARTIAL_SEQ_NUM 27 |
| 210 | /* |
| 211 | * L1 and L2 IS to IS partial sequence numbers PDU header |
| 212 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 213 | * + PDU Length + 2 |
| 214 | * +-------+-------+-------+-------+-------+-------+-------+-------+ |
| 215 | * + Source ID + id_len + 1 |
| 216 | * +---------------------------------------------------------------+ |
| 217 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 218 | struct isis_partial_seqnum_hdr |
| 219 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 220 | u_int16_t pdu_len; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 221 | u_char source_id[ISIS_SYS_ID_LEN + 1]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 222 | }; |
| 223 | #define ISIS_PSNP_HDRLEN 9 |
| 224 | |
| 225 | /* |
| 226 | * Function for receiving IS-IS PDUs |
| 227 | */ |
| 228 | int isis_receive (struct thread *thread); |
| 229 | |
| 230 | /* |
| 231 | * calling arguments for snp_process () |
| 232 | */ |
| 233 | #define ISIS_SNP_PSNP_FLAG 0 |
| 234 | #define ISIS_SNP_CSNP_FLAG 1 |
| 235 | |
| 236 | /* |
| 237 | * Sending functions |
| 238 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 239 | int send_lan_l1_hello (struct thread *thread); |
| 240 | int send_lan_l2_hello (struct thread *thread); |
| 241 | int send_p2p_hello (struct thread *thread); |
| 242 | int send_csnp (struct isis_circuit *circuit, int level); |
| 243 | int send_l1_csnp (struct thread *thread); |
| 244 | int send_l2_csnp (struct thread *thread); |
| 245 | int send_l1_psnp (struct thread *thread); |
| 246 | int send_l2_psnp (struct thread *thread); |
| 247 | int send_lsp (struct thread *thread); |
| 248 | int ack_lsp (struct isis_link_state_hdr *hdr, |
| 249 | struct isis_circuit *circuit, int level); |
| 250 | void fill_fixed_hdr (struct isis_fixed_hdr *hdr, u_char pdu_type); |
| 251 | int send_hello (struct isis_circuit *circuit, int level); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 252 | |
| 253 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 254 | int authentication_check (struct isis_passwd *one, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 255 | struct isis_passwd *theother); |
| 256 | |
| 257 | #endif /* _ZEBRA_ISIS_PDU_H */ |