The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1 | /* |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 2 | * Copyright (c) 1998-2004 Hannes Gredler <hannes@gredler.at> |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 3 | * The TCPDUMP project |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that: (1) source code |
| 7 | * distributions retain the above copyright notice and this paragraph |
| 8 | * in its entirety, and (2) distributions including binary code include |
| 9 | * the above copyright notice and this paragraph in its entirety in |
| 10 | * the documentation or other materials provided with the distribution. |
| 11 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND |
| 12 | * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT |
| 13 | * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 | * FOR A PARTICULAR PURPOSE. |
| 15 | */ |
| 16 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 17 | /* \summary: Enhanced Interior Gateway Routing Protocol (EIGRP) printer */ |
| 18 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 19 | /* |
| 20 | * specification: |
| 21 | * |
| 22 | * https://web.archive.org/web/20190722221712/https://www.rhyshaden.com/eigrp.htm |
| 23 | * RFC 7868 |
| 24 | */ |
| 25 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 26 | #ifdef HAVE_CONFIG_H |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 27 | #include <config.h> |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 28 | #endif |
| 29 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 30 | #include "netdissect-stdinc.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 31 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 32 | #include <string.h> |
| 33 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 34 | #include "netdissect.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 35 | #include "extract.h" |
| 36 | #include "addrtoname.h" |
| 37 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 38 | |
| 39 | struct eigrp_common_header { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 40 | nd_uint8_t version; |
| 41 | nd_uint8_t opcode; |
| 42 | nd_uint16_t checksum; |
| 43 | nd_uint32_t flags; |
| 44 | nd_uint32_t seq; |
| 45 | nd_uint32_t ack; |
| 46 | nd_uint16_t vrid; |
| 47 | nd_uint16_t asn; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | #define EIGRP_VERSION 2 |
| 51 | |
| 52 | #define EIGRP_OPCODE_UPDATE 1 |
| 53 | #define EIGRP_OPCODE_QUERY 3 |
| 54 | #define EIGRP_OPCODE_REPLY 4 |
| 55 | #define EIGRP_OPCODE_HELLO 5 |
| 56 | #define EIGRP_OPCODE_IPXSAP 6 |
| 57 | #define EIGRP_OPCODE_PROBE 7 |
| 58 | |
| 59 | static const struct tok eigrp_opcode_values[] = { |
| 60 | { EIGRP_OPCODE_UPDATE, "Update" }, |
| 61 | { EIGRP_OPCODE_QUERY, "Query" }, |
| 62 | { EIGRP_OPCODE_REPLY, "Reply" }, |
| 63 | { EIGRP_OPCODE_HELLO, "Hello" }, |
| 64 | { EIGRP_OPCODE_IPXSAP, "IPX SAP" }, |
| 65 | { EIGRP_OPCODE_PROBE, "Probe" }, |
| 66 | { 0, NULL} |
| 67 | }; |
| 68 | |
| 69 | static const struct tok eigrp_common_header_flag_values[] = { |
| 70 | { 0x01, "Init" }, |
| 71 | { 0x02, "Conditionally Received" }, |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 72 | { 0x04, "Restart" }, |
| 73 | { 0x08, "End-of-Table" }, |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 74 | { 0, NULL} |
| 75 | }; |
| 76 | |
| 77 | struct eigrp_tlv_header { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 78 | nd_uint16_t type; |
| 79 | nd_uint16_t length; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | #define EIGRP_TLV_GENERAL_PARM 0x0001 |
| 83 | #define EIGRP_TLV_AUTH 0x0002 |
| 84 | #define EIGRP_TLV_SEQ 0x0003 |
| 85 | #define EIGRP_TLV_SW_VERSION 0x0004 |
| 86 | #define EIGRP_TLV_MCAST_SEQ 0x0005 |
| 87 | #define EIGRP_TLV_IP_INT 0x0102 |
| 88 | #define EIGRP_TLV_IP_EXT 0x0103 |
| 89 | #define EIGRP_TLV_AT_INT 0x0202 |
| 90 | #define EIGRP_TLV_AT_EXT 0x0203 |
| 91 | #define EIGRP_TLV_AT_CABLE_SETUP 0x0204 |
| 92 | #define EIGRP_TLV_IPX_INT 0x0302 |
| 93 | #define EIGRP_TLV_IPX_EXT 0x0303 |
| 94 | |
| 95 | static const struct tok eigrp_tlv_values[] = { |
| 96 | { EIGRP_TLV_GENERAL_PARM, "General Parameters"}, |
| 97 | { EIGRP_TLV_AUTH, "Authentication"}, |
| 98 | { EIGRP_TLV_SEQ, "Sequence"}, |
| 99 | { EIGRP_TLV_SW_VERSION, "Software Version"}, |
| 100 | { EIGRP_TLV_MCAST_SEQ, "Next Multicast Sequence"}, |
| 101 | { EIGRP_TLV_IP_INT, "IP Internal routes"}, |
| 102 | { EIGRP_TLV_IP_EXT, "IP External routes"}, |
| 103 | { EIGRP_TLV_AT_INT, "AppleTalk Internal routes"}, |
| 104 | { EIGRP_TLV_AT_EXT, "AppleTalk External routes"}, |
| 105 | { EIGRP_TLV_AT_CABLE_SETUP, "AppleTalk Cable setup"}, |
| 106 | { EIGRP_TLV_IPX_INT, "IPX Internal routes"}, |
| 107 | { EIGRP_TLV_IPX_EXT, "IPX External routes"}, |
| 108 | { 0, NULL} |
| 109 | }; |
| 110 | |
| 111 | struct eigrp_tlv_general_parm_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 112 | nd_uint8_t k1; |
| 113 | nd_uint8_t k2; |
| 114 | nd_uint8_t k3; |
| 115 | nd_uint8_t k4; |
| 116 | nd_uint8_t k5; |
| 117 | nd_uint8_t res; |
| 118 | nd_uint16_t holdtime; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 119 | }; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 120 | |
| 121 | struct eigrp_tlv_sw_version_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 122 | nd_uint8_t ios_major; |
| 123 | nd_uint8_t ios_minor; |
| 124 | nd_uint8_t eigrp_major; |
| 125 | nd_uint8_t eigrp_minor; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 126 | }; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 127 | |
| 128 | struct eigrp_tlv_ip_int_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 129 | nd_ipv4 nexthop; |
| 130 | nd_uint32_t delay; |
| 131 | nd_uint32_t bandwidth; |
| 132 | nd_uint24_t mtu; |
| 133 | nd_uint8_t hopcount; |
| 134 | nd_uint8_t reliability; |
| 135 | nd_uint8_t load; |
| 136 | nd_byte reserved[2]; |
| 137 | nd_uint8_t plen; |
| 138 | nd_uint8_t destination; /* variable length [1-4] bytes encoding */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 139 | }; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 140 | |
| 141 | struct eigrp_tlv_ip_ext_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 142 | nd_ipv4 nexthop; |
| 143 | nd_ipv4 origin_router; |
| 144 | nd_uint32_t origin_as; |
| 145 | nd_uint32_t tag; |
| 146 | nd_uint32_t metric; |
| 147 | nd_byte reserved[2]; |
| 148 | nd_uint8_t proto_id; |
| 149 | nd_uint8_t flags; |
| 150 | nd_uint32_t delay; |
| 151 | nd_uint32_t bandwidth; |
| 152 | nd_uint24_t mtu; |
| 153 | nd_uint8_t hopcount; |
| 154 | nd_uint8_t reliability; |
| 155 | nd_uint8_t load; |
| 156 | nd_byte reserved2[2]; |
| 157 | nd_uint8_t plen; |
| 158 | nd_uint8_t destination; /* variable length [1-4] bytes encoding */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 159 | }; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 160 | |
| 161 | struct eigrp_tlv_at_cable_setup_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 162 | nd_uint16_t cable_start; |
| 163 | nd_uint16_t cable_end; |
| 164 | nd_uint32_t router_id; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 165 | }; |
| 166 | |
| 167 | struct eigrp_tlv_at_int_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 168 | nd_byte nexthop[4]; |
| 169 | nd_uint32_t delay; |
| 170 | nd_uint32_t bandwidth; |
| 171 | nd_uint24_t mtu; |
| 172 | nd_uint8_t hopcount; |
| 173 | nd_uint8_t reliability; |
| 174 | nd_uint8_t load; |
| 175 | nd_byte reserved[2]; |
| 176 | nd_uint16_t cable_start; |
| 177 | nd_uint16_t cable_end; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 178 | }; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 179 | |
| 180 | struct eigrp_tlv_at_ext_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 181 | nd_byte nexthop[4]; |
| 182 | nd_uint32_t origin_router; |
| 183 | nd_uint32_t origin_as; |
| 184 | nd_uint32_t tag; |
| 185 | nd_uint8_t proto_id; |
| 186 | nd_uint8_t flags; |
| 187 | nd_uint16_t metric; |
| 188 | nd_uint32_t delay; |
| 189 | nd_uint32_t bandwidth; |
| 190 | nd_uint24_t mtu; |
| 191 | nd_uint8_t hopcount; |
| 192 | nd_uint8_t reliability; |
| 193 | nd_uint8_t load; |
| 194 | nd_byte reserved2[2]; |
| 195 | nd_uint16_t cable_start; |
| 196 | nd_uint16_t cable_end; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 197 | }; |
| 198 | |
| 199 | static const struct tok eigrp_ext_proto_id_values[] = { |
| 200 | { 0x01, "IGRP" }, |
| 201 | { 0x02, "EIGRP" }, |
| 202 | { 0x03, "Static" }, |
| 203 | { 0x04, "RIP" }, |
| 204 | { 0x05, "Hello" }, |
| 205 | { 0x06, "OSPF" }, |
| 206 | { 0x07, "IS-IS" }, |
| 207 | { 0x08, "EGP" }, |
| 208 | { 0x09, "BGP" }, |
| 209 | { 0x0a, "IDRP" }, |
| 210 | { 0x0b, "Connected" }, |
| 211 | { 0, NULL} |
| 212 | }; |
| 213 | |
| 214 | void |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 215 | eigrp_print(netdissect_options *ndo, const u_char *pptr, u_int len) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 216 | { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 217 | const struct eigrp_common_header *eigrp_com_header; |
| 218 | const struct eigrp_tlv_header *eigrp_tlv_header; |
| 219 | const u_char *tptr,*tlv_tptr; |
| 220 | u_int tlen,eigrp_tlv_len,eigrp_tlv_type,tlv_tlen, byte_length, bit_length; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 221 | uint8_t prefix[4]; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 222 | |
| 223 | union { |
| 224 | const struct eigrp_tlv_general_parm_t *eigrp_tlv_general_parm; |
| 225 | const struct eigrp_tlv_sw_version_t *eigrp_tlv_sw_version; |
| 226 | const struct eigrp_tlv_ip_int_t *eigrp_tlv_ip_int; |
| 227 | const struct eigrp_tlv_ip_ext_t *eigrp_tlv_ip_ext; |
| 228 | const struct eigrp_tlv_at_cable_setup_t *eigrp_tlv_at_cable_setup; |
| 229 | const struct eigrp_tlv_at_int_t *eigrp_tlv_at_int; |
| 230 | const struct eigrp_tlv_at_ext_t *eigrp_tlv_at_ext; |
| 231 | } tlv_ptr; |
| 232 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 233 | ndo->ndo_protocol = "eigrp"; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 234 | tptr=pptr; |
| 235 | eigrp_com_header = (const struct eigrp_common_header *)pptr; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 236 | ND_TCHECK_SIZE(eigrp_com_header); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 237 | |
| 238 | /* |
| 239 | * Sanity checking of the header. |
| 240 | */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 241 | if (GET_U_1(eigrp_com_header->version) != EIGRP_VERSION) { |
| 242 | ND_PRINT("EIGRP version %u packet not supported", |
| 243 | GET_U_1(eigrp_com_header->version)); |
| 244 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | /* in non-verbose mode just lets print the basic Message Type*/ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 248 | if (ndo->ndo_vflag < 1) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 249 | ND_PRINT("EIGRP %s, length: %u", |
| 250 | tok2str(eigrp_opcode_values, "unknown (%u)",GET_U_1(eigrp_com_header->opcode)), |
| 251 | len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 252 | return; |
| 253 | } |
| 254 | |
| 255 | /* ok they seem to want to know everything - lets fully decode it */ |
| 256 | |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 257 | if (len < sizeof(struct eigrp_common_header)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 258 | ND_PRINT("EIGRP %s, length: %u (too short, < %zu)", |
| 259 | tok2str(eigrp_opcode_values, "unknown (%u)",GET_U_1(eigrp_com_header->opcode)), |
| 260 | len, sizeof(struct eigrp_common_header)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 261 | return; |
| 262 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 263 | tlen=len-sizeof(struct eigrp_common_header); |
| 264 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 265 | ND_PRINT("\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [%s]" |
| 266 | "\n\tseq: 0x%08x, ack: 0x%08x, VRID: %u, AS: %u, length: %u", |
| 267 | GET_U_1(eigrp_com_header->version), |
| 268 | tok2str(eigrp_opcode_values, "unknown, type: %u",GET_U_1(eigrp_com_header->opcode)), |
| 269 | GET_U_1(eigrp_com_header->opcode), |
| 270 | GET_BE_U_2(eigrp_com_header->checksum), |
| 271 | bittok2str(eigrp_common_header_flag_values, |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 272 | "none", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 273 | GET_BE_U_4(eigrp_com_header->flags)), |
| 274 | GET_BE_U_4(eigrp_com_header->seq), |
| 275 | GET_BE_U_4(eigrp_com_header->ack), |
| 276 | GET_BE_U_2(eigrp_com_header->vrid), |
| 277 | GET_BE_U_2(eigrp_com_header->asn), |
| 278 | tlen); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 279 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 280 | tptr+=sizeof(struct eigrp_common_header); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 281 | |
| 282 | while(tlen>0) { |
| 283 | /* did we capture enough for fully decoding the object header ? */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 284 | ND_TCHECK_LEN(tptr, sizeof(struct eigrp_tlv_header)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 285 | |
| 286 | eigrp_tlv_header = (const struct eigrp_tlv_header *)tptr; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 287 | eigrp_tlv_len=GET_BE_U_2(eigrp_tlv_header->length); |
| 288 | eigrp_tlv_type=GET_BE_U_2(eigrp_tlv_header->type); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 289 | |
| 290 | |
| 291 | if (eigrp_tlv_len < sizeof(struct eigrp_tlv_header) || |
| 292 | eigrp_tlv_len > tlen) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 293 | print_unknown_data(ndo,tptr+sizeof(struct eigrp_tlv_header),"\n\t ",tlen); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 294 | return; |
| 295 | } |
| 296 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 297 | ND_PRINT("\n\t %s TLV (0x%04x), length: %u", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 298 | tok2str(eigrp_tlv_values, |
| 299 | "Unknown", |
| 300 | eigrp_tlv_type), |
| 301 | eigrp_tlv_type, |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 302 | eigrp_tlv_len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 303 | |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 304 | if (eigrp_tlv_len < sizeof(struct eigrp_tlv_header)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 305 | ND_PRINT(" (too short, < %zu)", |
| 306 | sizeof(struct eigrp_tlv_header)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 307 | break; |
| 308 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 309 | tlv_tptr=tptr+sizeof(struct eigrp_tlv_header); |
| 310 | tlv_tlen=eigrp_tlv_len-sizeof(struct eigrp_tlv_header); |
| 311 | |
| 312 | /* did we capture enough for fully decoding the object ? */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 313 | ND_TCHECK_LEN(tptr, eigrp_tlv_len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 314 | |
| 315 | switch(eigrp_tlv_type) { |
| 316 | |
| 317 | case EIGRP_TLV_GENERAL_PARM: |
| 318 | tlv_ptr.eigrp_tlv_general_parm = (const struct eigrp_tlv_general_parm_t *)tlv_tptr; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 319 | if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_general_parm)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 320 | ND_PRINT(" (too short, < %zu)", |
| 321 | sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_general_parm)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 322 | break; |
| 323 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 324 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 325 | ND_PRINT("\n\t holdtime: %us, k1 %u, k2 %u, k3 %u, k4 %u, k5 %u", |
| 326 | GET_BE_U_2(tlv_ptr.eigrp_tlv_general_parm->holdtime), |
| 327 | GET_U_1(tlv_ptr.eigrp_tlv_general_parm->k1), |
| 328 | GET_U_1(tlv_ptr.eigrp_tlv_general_parm->k2), |
| 329 | GET_U_1(tlv_ptr.eigrp_tlv_general_parm->k3), |
| 330 | GET_U_1(tlv_ptr.eigrp_tlv_general_parm->k4), |
| 331 | GET_U_1(tlv_ptr.eigrp_tlv_general_parm->k5)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 332 | break; |
| 333 | |
| 334 | case EIGRP_TLV_SW_VERSION: |
| 335 | tlv_ptr.eigrp_tlv_sw_version = (const struct eigrp_tlv_sw_version_t *)tlv_tptr; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 336 | if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_sw_version)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 337 | ND_PRINT(" (too short, < %zu)", |
| 338 | sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_sw_version)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 339 | break; |
| 340 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 341 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 342 | ND_PRINT("\n\t IOS version: %u.%u, EIGRP version %u.%u", |
| 343 | GET_U_1(tlv_ptr.eigrp_tlv_sw_version->ios_major), |
| 344 | GET_U_1(tlv_ptr.eigrp_tlv_sw_version->ios_minor), |
| 345 | GET_U_1(tlv_ptr.eigrp_tlv_sw_version->eigrp_major), |
| 346 | GET_U_1(tlv_ptr.eigrp_tlv_sw_version->eigrp_minor)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 347 | break; |
| 348 | |
| 349 | case EIGRP_TLV_IP_INT: |
| 350 | tlv_ptr.eigrp_tlv_ip_int = (const struct eigrp_tlv_ip_int_t *)tlv_tptr; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 351 | if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_ip_int)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 352 | ND_PRINT(" (too short, < %zu)", |
| 353 | sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_ip_int)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 354 | break; |
| 355 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 356 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 357 | bit_length = GET_U_1(tlv_ptr.eigrp_tlv_ip_int->plen); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 358 | if (bit_length > 32) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 359 | ND_PRINT("\n\t illegal prefix length %u",bit_length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 360 | break; |
| 361 | } |
| 362 | byte_length = (bit_length + 7) / 8; /* variable length encoding */ |
| 363 | memset(prefix, 0, 4); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 364 | GET_CPY_BYTES(prefix, tlv_ptr.eigrp_tlv_ip_int->destination, byte_length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 365 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 366 | ND_PRINT("\n\t IPv4 prefix: %15s/%u, nexthop: ", |
| 367 | ipaddr_string(ndo, prefix), /* local buffer, not packet data; don't use GET_IPADDR_STRING() */ |
| 368 | bit_length); |
| 369 | if (GET_BE_U_4(tlv_ptr.eigrp_tlv_ip_int->nexthop) == 0) |
| 370 | ND_PRINT("self"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 371 | else |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 372 | ND_PRINT("%s", |
| 373 | GET_IPADDR_STRING(tlv_ptr.eigrp_tlv_ip_int->nexthop)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 374 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 375 | ND_PRINT("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", |
| 376 | (GET_BE_U_4(tlv_ptr.eigrp_tlv_ip_int->delay)/100), |
| 377 | GET_BE_U_4(tlv_ptr.eigrp_tlv_ip_int->bandwidth), |
| 378 | GET_BE_U_3(tlv_ptr.eigrp_tlv_ip_int->mtu), |
| 379 | GET_U_1(tlv_ptr.eigrp_tlv_ip_int->hopcount), |
| 380 | GET_U_1(tlv_ptr.eigrp_tlv_ip_int->reliability), |
| 381 | GET_U_1(tlv_ptr.eigrp_tlv_ip_int->load)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 382 | break; |
| 383 | |
| 384 | case EIGRP_TLV_IP_EXT: |
| 385 | tlv_ptr.eigrp_tlv_ip_ext = (const struct eigrp_tlv_ip_ext_t *)tlv_tptr; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 386 | if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_ip_ext)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 387 | ND_PRINT(" (too short, < %zu)", |
| 388 | sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_ip_ext)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 389 | break; |
| 390 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 391 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 392 | bit_length = GET_U_1(tlv_ptr.eigrp_tlv_ip_ext->plen); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 393 | if (bit_length > 32) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 394 | ND_PRINT("\n\t illegal prefix length %u",bit_length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 395 | break; |
| 396 | } |
| 397 | byte_length = (bit_length + 7) / 8; /* variable length encoding */ |
| 398 | memset(prefix, 0, 4); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 399 | GET_CPY_BYTES(prefix, tlv_ptr.eigrp_tlv_ip_ext->destination, byte_length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 400 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 401 | ND_PRINT("\n\t IPv4 prefix: %15s/%u, nexthop: ", |
| 402 | ipaddr_string(ndo, prefix), /* local buffer, not packet data; don't use GET_IPADDR_STRING() */ |
| 403 | bit_length); |
| 404 | if (GET_BE_U_4(tlv_ptr.eigrp_tlv_ip_ext->nexthop) == 0) |
| 405 | ND_PRINT("self"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 406 | else |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 407 | ND_PRINT("%s", |
| 408 | GET_IPADDR_STRING(tlv_ptr.eigrp_tlv_ip_ext->nexthop)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 409 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 410 | ND_PRINT("\n\t origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u", |
| 411 | GET_IPADDR_STRING(tlv_ptr.eigrp_tlv_ip_ext->origin_router), |
| 412 | GET_BE_U_4(tlv_ptr.eigrp_tlv_ip_ext->origin_as), |
| 413 | tok2str(eigrp_ext_proto_id_values,"unknown",GET_U_1(tlv_ptr.eigrp_tlv_ip_ext->proto_id)), |
| 414 | GET_U_1(tlv_ptr.eigrp_tlv_ip_ext->flags), |
| 415 | GET_BE_U_4(tlv_ptr.eigrp_tlv_ip_ext->tag), |
| 416 | GET_BE_U_4(tlv_ptr.eigrp_tlv_ip_ext->metric)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 417 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 418 | ND_PRINT("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", |
| 419 | (GET_BE_U_4(tlv_ptr.eigrp_tlv_ip_ext->delay)/100), |
| 420 | GET_BE_U_4(tlv_ptr.eigrp_tlv_ip_ext->bandwidth), |
| 421 | GET_BE_U_3(tlv_ptr.eigrp_tlv_ip_ext->mtu), |
| 422 | GET_U_1(tlv_ptr.eigrp_tlv_ip_ext->hopcount), |
| 423 | GET_U_1(tlv_ptr.eigrp_tlv_ip_ext->reliability), |
| 424 | GET_U_1(tlv_ptr.eigrp_tlv_ip_ext->load)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 425 | break; |
| 426 | |
| 427 | case EIGRP_TLV_AT_CABLE_SETUP: |
| 428 | tlv_ptr.eigrp_tlv_at_cable_setup = (const struct eigrp_tlv_at_cable_setup_t *)tlv_tptr; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 429 | if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_at_cable_setup)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 430 | ND_PRINT(" (too short, < %zu)", |
| 431 | sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_at_cable_setup)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 432 | break; |
| 433 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 434 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 435 | ND_PRINT("\n\t Cable-range: %u-%u, Router-ID %u", |
| 436 | GET_BE_U_2(tlv_ptr.eigrp_tlv_at_cable_setup->cable_start), |
| 437 | GET_BE_U_2(tlv_ptr.eigrp_tlv_at_cable_setup->cable_end), |
| 438 | GET_BE_U_4(tlv_ptr.eigrp_tlv_at_cable_setup->router_id)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 439 | break; |
| 440 | |
| 441 | case EIGRP_TLV_AT_INT: |
| 442 | tlv_ptr.eigrp_tlv_at_int = (const struct eigrp_tlv_at_int_t *)tlv_tptr; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 443 | if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_at_int)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 444 | ND_PRINT(" (too short, < %zu)", |
| 445 | sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_at_int)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 446 | break; |
| 447 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 448 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 449 | ND_PRINT("\n\t Cable-Range: %u-%u, nexthop: ", |
| 450 | GET_BE_U_2(tlv_ptr.eigrp_tlv_at_int->cable_start), |
| 451 | GET_BE_U_2(tlv_ptr.eigrp_tlv_at_int->cable_end)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 452 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 453 | if (GET_BE_U_4(tlv_ptr.eigrp_tlv_at_int->nexthop) == 0) |
| 454 | ND_PRINT("self"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 455 | else |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 456 | ND_PRINT("%u.%u", |
| 457 | GET_BE_U_2(&tlv_ptr.eigrp_tlv_at_int->nexthop[0]), |
| 458 | GET_BE_U_2(&tlv_ptr.eigrp_tlv_at_int->nexthop[2])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 459 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 460 | ND_PRINT("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", |
| 461 | (GET_BE_U_4(tlv_ptr.eigrp_tlv_at_int->delay)/100), |
| 462 | GET_BE_U_4(tlv_ptr.eigrp_tlv_at_int->bandwidth), |
| 463 | GET_BE_U_3(tlv_ptr.eigrp_tlv_at_int->mtu), |
| 464 | GET_U_1(tlv_ptr.eigrp_tlv_at_int->hopcount), |
| 465 | GET_U_1(tlv_ptr.eigrp_tlv_at_int->reliability), |
| 466 | GET_U_1(tlv_ptr.eigrp_tlv_at_int->load)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 467 | break; |
| 468 | |
| 469 | case EIGRP_TLV_AT_EXT: |
| 470 | tlv_ptr.eigrp_tlv_at_ext = (const struct eigrp_tlv_at_ext_t *)tlv_tptr; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 471 | if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_at_ext)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 472 | ND_PRINT(" (too short, < %zu)", |
| 473 | sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_at_ext)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 474 | break; |
| 475 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 476 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 477 | ND_PRINT("\n\t Cable-Range: %u-%u, nexthop: ", |
| 478 | GET_BE_U_2(tlv_ptr.eigrp_tlv_at_ext->cable_start), |
| 479 | GET_BE_U_2(tlv_ptr.eigrp_tlv_at_ext->cable_end)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 480 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 481 | if (GET_BE_U_4(tlv_ptr.eigrp_tlv_at_ext->nexthop) == 0) |
| 482 | ND_PRINT("self"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 483 | else |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 484 | ND_PRINT("%u.%u", |
| 485 | GET_BE_U_2(&tlv_ptr.eigrp_tlv_at_ext->nexthop[0]), |
| 486 | GET_BE_U_2(&tlv_ptr.eigrp_tlv_at_ext->nexthop[2])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 487 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 488 | ND_PRINT("\n\t origin-router %u, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u", |
| 489 | GET_BE_U_4(tlv_ptr.eigrp_tlv_at_ext->origin_router), |
| 490 | GET_BE_U_4(tlv_ptr.eigrp_tlv_at_ext->origin_as), |
| 491 | tok2str(eigrp_ext_proto_id_values,"unknown",GET_U_1(tlv_ptr.eigrp_tlv_at_ext->proto_id)), |
| 492 | GET_U_1(tlv_ptr.eigrp_tlv_at_ext->flags), |
| 493 | GET_BE_U_4(tlv_ptr.eigrp_tlv_at_ext->tag), |
| 494 | GET_BE_U_2(tlv_ptr.eigrp_tlv_at_ext->metric)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 495 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 496 | ND_PRINT("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", |
| 497 | (GET_BE_U_4(tlv_ptr.eigrp_tlv_at_ext->delay)/100), |
| 498 | GET_BE_U_4(tlv_ptr.eigrp_tlv_at_ext->bandwidth), |
| 499 | GET_BE_U_3(tlv_ptr.eigrp_tlv_at_ext->mtu), |
| 500 | GET_U_1(tlv_ptr.eigrp_tlv_at_ext->hopcount), |
| 501 | GET_U_1(tlv_ptr.eigrp_tlv_at_ext->reliability), |
| 502 | GET_U_1(tlv_ptr.eigrp_tlv_at_ext->load)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 503 | break; |
| 504 | |
| 505 | /* |
| 506 | * FIXME those are the defined TLVs that lack a decoder |
| 507 | * you are welcome to contribute code ;-) |
| 508 | */ |
| 509 | |
| 510 | case EIGRP_TLV_AUTH: |
| 511 | case EIGRP_TLV_SEQ: |
| 512 | case EIGRP_TLV_MCAST_SEQ: |
| 513 | case EIGRP_TLV_IPX_INT: |
| 514 | case EIGRP_TLV_IPX_EXT: |
| 515 | |
| 516 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 517 | if (ndo->ndo_vflag <= 1) |
| 518 | print_unknown_data(ndo,tlv_tptr,"\n\t ",tlv_tlen); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 519 | break; |
| 520 | } |
| 521 | /* do we want to see an additionally hexdump ? */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 522 | if (ndo->ndo_vflag > 1) |
| 523 | print_unknown_data(ndo,tptr+sizeof(struct eigrp_tlv_header),"\n\t ", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 524 | eigrp_tlv_len-sizeof(struct eigrp_tlv_header)); |
| 525 | |
| 526 | tptr+=eigrp_tlv_len; |
| 527 | tlen-=eigrp_tlv_len; |
| 528 | } |
| 529 | return; |
| 530 | trunc: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 531 | nd_print_trunc(ndo); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 532 | } |