jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_tlv.h |
| 3 | * IS-IS TLV related routines |
| 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_TLV_H |
| 25 | #define _ZEBRA_ISIS_TLV_H |
| 26 | |
| 27 | /* |
| 28 | * Structures found in TLV's. |
| 29 | * this header is fully complient with |
hasso | 00995cf | 2004-05-19 13:43:50 +0000 | [diff] [blame] | 30 | * RFC 3359 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 31 | 1. TLV Codepoints reserved |
| 32 | ____________________________________________________ |
| 33 | Name Value IIH LSP SNP Status |
| 34 | ____________________________________________________ |
| 35 | |
| 36 | Area Addresses 1 y y n ISO 10589 |
| 37 | IIS Neighbors 2 n y n ISO 10589 |
| 38 | ES Neighbors 3 n y n ISO 10589 |
| 39 | Part. DIS 4 n y n ISO 10589 |
| 40 | Prefix Neighbors 5 n y n ISO 10589 |
| 41 | IIS Neighbors 6 y n n ISO 10589 |
| 42 | Padding 8 y n n ISO 10589 |
| 43 | LSP Entries 9 n n y ISO 10589 |
| 44 | Authentication 10 y y y ISO 10589 |
hasso | 90f0c88 | 2004-09-15 21:46:55 +0000 | [diff] [blame] | 45 | Opt. Checksum 12 y n y RFC 3358 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 46 | LSPBufferSize 14 n y n ISO 10589 Rev 2 Draft |
hasso | 90f0c88 | 2004-09-15 21:46:55 +0000 | [diff] [blame] | 47 | TE IIS Neigh. 22 n y n RFC 3784 |
| 48 | IS Alias ID 24 n y n RFC 3786 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 49 | DECnet Phase IV 42 y n n DEC (ancient) |
hasso | 00995cf | 2004-05-19 13:43:50 +0000 | [diff] [blame] | 50 | Lucent Proprietary 66 n y n |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 51 | IP Int. Reach 128 n y n RFC 1195 |
| 52 | Prot. Supported 129 y y n RFC 1195 |
| 53 | IP Ext. Address 130 n y n RFC 1195 |
| 54 | IDRPI 131 n y y RFC 1195 |
| 55 | IP Intf. Address 132 y y n RFC 1195 |
| 56 | Illegal 133 n n n RFC 1195 (not used) |
hasso | 90f0c88 | 2004-09-15 21:46:55 +0000 | [diff] [blame] | 57 | Router ID 134 n y n RFC 3784 |
| 58 | TE IP. Reach 135 n y n RFC 3784 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 59 | Dynamic Name 137 n y n RFC 2763 |
| 60 | Nortel Proprietary 176 n y n |
| 61 | Nortel Proprietary 177 n y n |
hasso | 90f0c88 | 2004-09-15 21:46:55 +0000 | [diff] [blame] | 62 | Restart TLV 211 y n n RFC 3847 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 63 | MT-ISN 222 n y n IETF-draft |
| 64 | M-Topologies 229 y y n IETF-draft |
| 65 | IPv6 Intf. Addr. 232 y y n IETF-draft |
| 66 | MT IP. Reach 235 n y n IETF-draft |
| 67 | IPv6 IP. Reach 236 n y n IETF-draft |
| 68 | MT IPv6 IP. Reach 237 n y n IETF-draft |
hasso | 90f0c88 | 2004-09-15 21:46:55 +0000 | [diff] [blame] | 69 | P2P Adjacency State 240 y n n RFC 3373 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 70 | |
| 71 | */ |
| 72 | |
| 73 | #define AREA_ADDRESSES 1 |
| 74 | #define IS_NEIGHBOURS 2 |
| 75 | #define ES_NEIGHBOURS 3 |
| 76 | #define PARTITION_DESIG_LEVEL2_IS 4 |
| 77 | #define PREFIX_NEIGHBOURS 5 |
| 78 | #define LAN_NEIGHBOURS 6 |
| 79 | #define PADDING 8 |
| 80 | #define LSP_ENTRIES 9 |
| 81 | #define AUTH_INFO 10 |
| 82 | #define CHECKSUM 12 |
| 83 | #define TE_IS_NEIGHBOURS 22 |
| 84 | #define IPV4_INT_REACHABILITY 128 |
| 85 | #define IPV4_EXT_REACHABILITY 130 |
| 86 | #define PROTOCOLS_SUPPORTED 129 |
| 87 | #define IDRP_INFO 131 |
| 88 | #define IPV4_ADDR 132 |
| 89 | #define TE_ROUTER_ID 134 |
| 90 | #define TE_IPV4_REACHABILITY 135 |
| 91 | #define DYNAMIC_HOSTNAME 137 |
hasso | 00995cf | 2004-05-19 13:43:50 +0000 | [diff] [blame] | 92 | #define GRACEFUL_RESTART 211 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 93 | #define IPV6_REACHABILITY 236 |
| 94 | #define IPV6_ADDR 232 |
| 95 | #define WAY3_HELLO 240 |
| 96 | |
| 97 | #define IS_NEIGHBOURS_LEN (ISIS_SYS_ID_LEN + 5) |
| 98 | #define LAN_NEIGHBOURS_LEN 6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 99 | #define LSP_ENTRIES_LEN (10 + ISIS_SYS_ID_LEN) /* FIXME: should be entry */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 100 | #define IPV4_REACH_LEN 12 |
| 101 | #define IPV6_REACH_LEN 22 |
| 102 | |
| 103 | /* struct for neighbor */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 104 | struct is_neigh |
| 105 | { |
| 106 | struct metric metrics; |
| 107 | u_char neigh_id[ISIS_SYS_ID_LEN + 1]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | /* struct for te is neighbor */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 111 | struct te_is_neigh |
| 112 | { |
| 113 | u_char neigh_id[ISIS_SYS_ID_LEN + 1]; |
| 114 | u_char te_metric[3]; |
| 115 | u_char sub_tlvs_length; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | /* struct for es neighbors */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 119 | struct es_neigh |
| 120 | { |
| 121 | struct metric metrics; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 122 | /* approximate position of first, we use the |
| 123 | * length ((uchar*)metric-1) to know all */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 124 | u_char first_es_neigh[ISIS_SYS_ID_LEN]; |
| 125 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 128 | struct partition_desig_level2_is |
| 129 | { |
| 130 | struct list *isis_system_ids; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | /* struct for lan neighbors */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 134 | struct lan_neigh |
| 135 | { |
| 136 | u_char LAN_addr[6]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 137 | }; |
| 138 | |
| 139 | /* struct for LSP entry */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 140 | struct lsp_entry |
| 141 | { |
| 142 | u_int16_t rem_lifetime; |
| 143 | u_char lsp_id[ISIS_SYS_ID_LEN + 2]; |
| 144 | u_int32_t seq_num; |
| 145 | u_int16_t checksum; |
| 146 | } __attribute__ ((packed)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 147 | |
| 148 | /* struct for checksum */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 149 | struct checksum |
| 150 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 151 | u_int16_t checksum; |
| 152 | }; |
| 153 | |
| 154 | /* ipv4 reachability */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 155 | struct ipv4_reachability |
| 156 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 157 | struct metric metrics; |
| 158 | struct in_addr prefix; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 159 | struct in_addr mask; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 160 | }; |
| 161 | |
| 162 | /* te router id */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 163 | struct te_router_id |
| 164 | { |
| 165 | struct in_addr id; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | /* te ipv4 reachability */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 169 | struct te_ipv4_reachability |
| 170 | { |
| 171 | u_int32_t te_metric; |
| 172 | u_char control; |
| 173 | u_char prefix_start; /* since this is variable length by nature it only */ |
| 174 | }; /* points to an approximate location */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 175 | |
| 176 | |
| 177 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 178 | struct idrp_info |
| 179 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 180 | u_char len; |
| 181 | u_char *value; |
| 182 | }; |
| 183 | |
| 184 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 185 | struct ipv6_reachability |
| 186 | { |
| 187 | u_int32_t metric; |
| 188 | u_char control_info; |
| 189 | u_char prefix_len; |
| 190 | u_char prefix[16]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 191 | }; |
| 192 | #endif /* HAVE_IPV6 */ |
| 193 | |
| 194 | /* bits in control_info */ |
| 195 | #define CTRL_INFO_DIRECTION 0x80 |
| 196 | #define DIRECTION_UP 0 |
| 197 | #define DIRECTION_DOWN 1 |
| 198 | #define CTRL_INFO_DISTRIBUTION 0x40 |
| 199 | #define DISTRIBUTION_INTERNAL 0 |
| 200 | #define DISTRIBUTION_EXTERNAL 1 |
| 201 | #define CTRL_INFO_SUBTLVS 0x20 |
| 202 | |
| 203 | /* |
| 204 | * Pointer to each tlv type, filled by parse_tlvs() |
| 205 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 206 | struct tlvs |
| 207 | { |
| 208 | struct list *area_addrs; |
| 209 | struct list *is_neighs; |
| 210 | struct list *te_is_neighs; |
| 211 | struct list *es_neighs; |
| 212 | struct list *lsp_entries; |
| 213 | struct list *prefix_neighs; |
| 214 | struct list *lan_neighs; |
| 215 | struct checksum *checksum; |
| 216 | struct nlpids *nlpids; |
| 217 | struct list *ipv4_addrs; |
| 218 | struct list *ipv4_int_reachs; |
| 219 | struct list *ipv4_ext_reachs; |
| 220 | struct list *te_ipv4_reachs; |
| 221 | struct hostname *hostname; |
| 222 | struct te_router_id *router_id; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 223 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 224 | struct list *ipv6_addrs; |
| 225 | struct list *ipv6_reachs; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 226 | #endif |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 227 | struct isis_passwd auth_info; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 228 | }; |
| 229 | |
| 230 | /* |
| 231 | * Own definitions - used to bitmask found and expected |
| 232 | */ |
| 233 | |
| 234 | #define TLVFLAG_AREA_ADDRS (1<<0) |
| 235 | #define TLVFLAG_IS_NEIGHS (1<<1) |
| 236 | #define TLVFLAG_ES_NEIGHS (1<<2) |
| 237 | #define TLVFLAG_PARTITION_DESIG_LEVEL2_IS (1<<3) |
| 238 | #define TLVFLAG_PREFIX_NEIGHS (1<<4) |
| 239 | #define TLVFLAG_LAN_NEIGHS (1<<5) |
| 240 | #define TLVFLAG_LSP_ENTRIES (1<<6) |
| 241 | #define TLVFLAG_PADDING (1<<7) |
| 242 | #define TLVFLAG_AUTH_INFO (1<<8) |
| 243 | #define TLVFLAG_IPV4_INT_REACHABILITY (1<<9) |
| 244 | #define TLVFLAG_NLPID (1<<10) |
| 245 | #define TLVFLAG_IPV4_EXT_REACHABILITY (1<<11) |
| 246 | #define TLVFLAG_IPV4_ADDR (1<<12) |
| 247 | #define TLVFLAG_DYN_HOSTNAME (1<<13) |
| 248 | #define TLVFLAG_IPV6_ADDR (1<<14) |
| 249 | #define TLVFLAG_IPV6_REACHABILITY (1<<15) |
| 250 | #define TLVFLAG_TE_IS_NEIGHS (1<<16) |
| 251 | #define TLVFLAG_TE_IPV4_REACHABILITY (1<<17) |
| 252 | #define TLVFLAG_3WAY_HELLO (1<<18) |
| 253 | #define TLVFLAG_TE_ROUTER_ID (1<<19) |
| 254 | #define TLVFLAG_CHECKSUM (1<<20) |
hasso | 00995cf | 2004-05-19 13:43:50 +0000 | [diff] [blame] | 255 | #define TLVFLAG_GRACEFUL_RESTART (1<<21) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 256 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 257 | void init_tlvs (struct tlvs *tlvs, uint32_t expected); |
| 258 | void free_tlvs (struct tlvs *tlvs); |
| 259 | int parse_tlvs (char *areatag, u_char * stream, int size, |
| 260 | u_int32_t * expected, u_int32_t * found, struct tlvs *tlvs); |
| 261 | void free_tlv (void *val); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 262 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 263 | int tlv_add_area_addrs (struct list *area_addrs, struct stream *stream); |
| 264 | int tlv_add_is_neighs (struct list *is_neighs, struct stream *stream); |
| 265 | int tlv_add_lan_neighs (struct list *lan_neighs, struct stream *stream); |
| 266 | int tlv_add_nlpid (struct nlpids *nlpids, struct stream *stream); |
| 267 | int tlv_add_checksum (struct checksum *checksum, struct stream *stream); |
| 268 | int tlv_add_authinfo (char auth_type, char authlen, char *auth_value, |
| 269 | struct stream *stream); |
| 270 | int tlv_add_ip_addrs (struct list *ip_addrs, struct stream *stream); |
| 271 | int tlv_add_dynamic_hostname (struct hostname *hostname, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 272 | struct stream *stream); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 273 | int tlv_add_lsp_entries (struct list *lsps, struct stream *stream); |
| 274 | int tlv_add_ipv4_reachs (struct list *ipv4_reachs, struct stream *stream); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 275 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 276 | int tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream); |
| 277 | int tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 278 | #endif /* HAVE_IPV6 */ |
| 279 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 280 | int tlv_add_padding (struct stream *stream); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 281 | |
| 282 | #endif /* _ZEBRA_ISIS_TLV_H */ |