The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996 |
| 3 | * The Regents of the University of California. All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms are permitted |
| 6 | * provided that the above copyright notice and this paragraph are |
| 7 | * duplicated in all such forms and that any documentation, |
| 8 | * advertising materials, and other materials related to such |
| 9 | * distribution and use acknowledge that the software was developed |
| 10 | * by the University of California, Lawrence Berkeley Laboratory, |
| 11 | * Berkeley, CA. The name of the University may not be used to |
| 12 | * endorse or promote products derived from this software without |
| 13 | * specific prior written permission. |
| 14 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
| 15 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 17 | * |
| 18 | * Initial contribution from Jeff Honig (jch@MITCHELL.CIT.CORNELL.EDU). |
| 19 | */ |
| 20 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 21 | /* \summary: Exterior Gateway Protocol (EGP) printer */ |
| 22 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include "config.h" |
| 25 | #endif |
| 26 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 27 | #include <netdissect-stdinc.h> |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 28 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 29 | #include "netdissect.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 30 | #include "addrtoname.h" |
| 31 | #include "extract.h" |
| 32 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 33 | struct egp_packet { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 34 | uint8_t egp_version; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 35 | #define EGP_VERSION 2 |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 36 | uint8_t egp_type; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 37 | #define EGPT_ACQUIRE 3 |
| 38 | #define EGPT_REACH 5 |
| 39 | #define EGPT_POLL 2 |
| 40 | #define EGPT_UPDATE 1 |
| 41 | #define EGPT_ERROR 8 |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 42 | uint8_t egp_code; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 43 | #define EGPC_REQUEST 0 |
| 44 | #define EGPC_CONFIRM 1 |
| 45 | #define EGPC_REFUSE 2 |
| 46 | #define EGPC_CEASE 3 |
| 47 | #define EGPC_CEASEACK 4 |
| 48 | #define EGPC_HELLO 0 |
| 49 | #define EGPC_HEARDU 1 |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 50 | uint8_t egp_status; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 51 | #define EGPS_UNSPEC 0 |
| 52 | #define EGPS_ACTIVE 1 |
| 53 | #define EGPS_PASSIVE 2 |
| 54 | #define EGPS_NORES 3 |
| 55 | #define EGPS_ADMIN 4 |
| 56 | #define EGPS_GODOWN 5 |
| 57 | #define EGPS_PARAM 6 |
| 58 | #define EGPS_PROTO 7 |
| 59 | #define EGPS_INDET 0 |
| 60 | #define EGPS_UP 1 |
| 61 | #define EGPS_DOWN 2 |
| 62 | #define EGPS_UNSOL 0x80 |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 63 | uint16_t egp_checksum; |
| 64 | uint16_t egp_as; |
| 65 | uint16_t egp_sequence; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 66 | union { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 67 | uint16_t egpu_hello; |
| 68 | uint8_t egpu_gws[2]; |
| 69 | uint16_t egpu_reason; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 70 | #define EGPR_UNSPEC 0 |
| 71 | #define EGPR_BADHEAD 1 |
| 72 | #define EGPR_BADDATA 2 |
| 73 | #define EGPR_NOREACH 3 |
| 74 | #define EGPR_XSPOLL 4 |
| 75 | #define EGPR_NORESP 5 |
| 76 | #define EGPR_UVERSION 6 |
| 77 | } egp_handg; |
| 78 | #define egp_hello egp_handg.egpu_hello |
| 79 | #define egp_intgw egp_handg.egpu_gws[0] |
| 80 | #define egp_extgw egp_handg.egpu_gws[1] |
| 81 | #define egp_reason egp_handg.egpu_reason |
| 82 | union { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 83 | uint16_t egpu_poll; |
| 84 | uint32_t egpu_sourcenet; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 85 | } egp_pands; |
| 86 | #define egp_poll egp_pands.egpu_poll |
| 87 | #define egp_sourcenet egp_pands.egpu_sourcenet |
| 88 | }; |
| 89 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 90 | static const char *egp_acquire_codes[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 91 | "request", |
| 92 | "confirm", |
| 93 | "refuse", |
| 94 | "cease", |
| 95 | "cease_ack" |
| 96 | }; |
| 97 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 98 | static const char *egp_acquire_status[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 99 | "unspecified", |
| 100 | "active_mode", |
| 101 | "passive_mode", |
| 102 | "insufficient_resources", |
| 103 | "administratively_prohibited", |
| 104 | "going_down", |
| 105 | "parameter_violation", |
| 106 | "protocol_violation" |
| 107 | }; |
| 108 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 109 | static const char *egp_reach_codes[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 110 | "hello", |
| 111 | "i-h-u" |
| 112 | }; |
| 113 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 114 | static const char *egp_status_updown[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 115 | "indeterminate", |
| 116 | "up", |
| 117 | "down" |
| 118 | }; |
| 119 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 120 | static const char *egp_reasons[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 121 | "unspecified", |
| 122 | "bad_EGP_header_format", |
| 123 | "bad_EGP_data_field_format", |
| 124 | "reachability_info_unavailable", |
| 125 | "excessive_polling_rate", |
| 126 | "no_response", |
| 127 | "unsupported_version" |
| 128 | }; |
| 129 | |
| 130 | static void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 131 | egpnrprint(netdissect_options *ndo, |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 132 | register const struct egp_packet *egp, u_int length) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 133 | { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 134 | register const uint8_t *cp; |
| 135 | uint32_t addr; |
| 136 | register uint32_t net; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 137 | register u_int netlen; |
| 138 | int gateways, distances, networks; |
| 139 | int t_gateways; |
| 140 | const char *comma; |
| 141 | |
| 142 | addr = egp->egp_sourcenet; |
| 143 | if (IN_CLASSA(addr)) { |
| 144 | net = addr & IN_CLASSA_NET; |
| 145 | netlen = 1; |
| 146 | } else if (IN_CLASSB(addr)) { |
| 147 | net = addr & IN_CLASSB_NET; |
| 148 | netlen = 2; |
| 149 | } else if (IN_CLASSC(addr)) { |
| 150 | net = addr & IN_CLASSC_NET; |
| 151 | netlen = 3; |
| 152 | } else { |
| 153 | net = 0; |
| 154 | netlen = 0; |
| 155 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 156 | cp = (const uint8_t *)(egp + 1); |
| 157 | length -= sizeof(*egp); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 158 | |
| 159 | t_gateways = egp->egp_intgw + egp->egp_extgw; |
| 160 | for (gateways = 0; gateways < t_gateways; ++gateways) { |
| 161 | /* Pickup host part of gateway address */ |
| 162 | addr = 0; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 163 | if (length < 4 - netlen) |
| 164 | goto trunc; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 165 | ND_TCHECK2(cp[0], 4 - netlen); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 166 | switch (netlen) { |
| 167 | |
| 168 | case 1: |
| 169 | addr = *cp++; |
| 170 | /* fall through */ |
| 171 | case 2: |
| 172 | addr = (addr << 8) | *cp++; |
| 173 | /* fall through */ |
| 174 | case 3: |
| 175 | addr = (addr << 8) | *cp++; |
| 176 | } |
| 177 | addr |= net; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 178 | length -= 4 - netlen; |
| 179 | if (length < 1) |
| 180 | goto trunc; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 181 | ND_TCHECK2(cp[0], 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 182 | distances = *cp++; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 183 | length--; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 184 | ND_PRINT((ndo, " %s %s ", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 185 | gateways < (int)egp->egp_intgw ? "int" : "ext", |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 186 | ipaddr_string(ndo, &addr))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 187 | |
| 188 | comma = ""; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 189 | ND_PRINT((ndo, "(")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 190 | while (--distances >= 0) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 191 | if (length < 2) |
| 192 | goto trunc; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 193 | ND_TCHECK2(cp[0], 2); |
| 194 | ND_PRINT((ndo, "%sd%d:", comma, (int)*cp++)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 195 | comma = ", "; |
| 196 | networks = *cp++; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 197 | length -= 2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 198 | while (--networks >= 0) { |
| 199 | /* Pickup network number */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 200 | if (length < 1) |
| 201 | goto trunc; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 202 | ND_TCHECK2(cp[0], 1); |
| 203 | addr = (uint32_t)*cp++ << 24; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 204 | length--; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 205 | if (IN_CLASSB(addr)) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 206 | if (length < 1) |
| 207 | goto trunc; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 208 | ND_TCHECK2(cp[0], 1); |
| 209 | addr |= (uint32_t)*cp++ << 16; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 210 | length--; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 211 | } else if (!IN_CLASSA(addr)) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 212 | if (length < 2) |
| 213 | goto trunc; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 214 | ND_TCHECK2(cp[0], 2); |
| 215 | addr |= (uint32_t)*cp++ << 16; |
| 216 | addr |= (uint32_t)*cp++ << 8; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 217 | length -= 2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 218 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 219 | ND_PRINT((ndo, " %s", ipaddr_string(ndo, &addr))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 220 | } |
| 221 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 222 | ND_PRINT((ndo, ")")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 223 | } |
| 224 | return; |
| 225 | trunc: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 226 | ND_PRINT((ndo, "[|]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 230 | egp_print(netdissect_options *ndo, |
| 231 | register const uint8_t *bp, register u_int length) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 232 | { |
| 233 | register const struct egp_packet *egp; |
| 234 | register int status; |
| 235 | register int code; |
| 236 | register int type; |
| 237 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 238 | egp = (const struct egp_packet *)bp; |
| 239 | if (length < sizeof(*egp) || !ND_TTEST(*egp)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 240 | ND_PRINT((ndo, "[|egp]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 241 | return; |
| 242 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 243 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 244 | if (!ndo->ndo_vflag) { |
| 245 | ND_PRINT((ndo, "EGPv%u, AS %u, seq %u, length %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 246 | egp->egp_version, |
| 247 | EXTRACT_16BITS(&egp->egp_as), |
| 248 | EXTRACT_16BITS(&egp->egp_sequence), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 249 | length)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 250 | return; |
| 251 | } else |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 252 | ND_PRINT((ndo, "EGPv%u, length %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 253 | egp->egp_version, |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 254 | length)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 255 | |
| 256 | if (egp->egp_version != EGP_VERSION) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 257 | ND_PRINT((ndo, "[version %d]", egp->egp_version)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 258 | return; |
| 259 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 260 | |
| 261 | type = egp->egp_type; |
| 262 | code = egp->egp_code; |
| 263 | status = egp->egp_status; |
| 264 | |
| 265 | switch (type) { |
| 266 | case EGPT_ACQUIRE: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 267 | ND_PRINT((ndo, " acquire")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 268 | switch (code) { |
| 269 | case EGPC_REQUEST: |
| 270 | case EGPC_CONFIRM: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 271 | ND_PRINT((ndo, " %s", egp_acquire_codes[code])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 272 | switch (status) { |
| 273 | case EGPS_UNSPEC: |
| 274 | case EGPS_ACTIVE: |
| 275 | case EGPS_PASSIVE: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 276 | ND_PRINT((ndo, " %s", egp_acquire_status[status])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 277 | break; |
| 278 | |
| 279 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 280 | ND_PRINT((ndo, " [status %d]", status)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 281 | break; |
| 282 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 283 | ND_PRINT((ndo, " hello:%d poll:%d", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 284 | EXTRACT_16BITS(&egp->egp_hello), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 285 | EXTRACT_16BITS(&egp->egp_poll))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 286 | break; |
| 287 | |
| 288 | case EGPC_REFUSE: |
| 289 | case EGPC_CEASE: |
| 290 | case EGPC_CEASEACK: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 291 | ND_PRINT((ndo, " %s", egp_acquire_codes[code])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 292 | switch (status ) { |
| 293 | case EGPS_UNSPEC: |
| 294 | case EGPS_NORES: |
| 295 | case EGPS_ADMIN: |
| 296 | case EGPS_GODOWN: |
| 297 | case EGPS_PARAM: |
| 298 | case EGPS_PROTO: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 299 | ND_PRINT((ndo, " %s", egp_acquire_status[status])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 300 | break; |
| 301 | |
| 302 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 303 | ND_PRINT((ndo, "[status %d]", status)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 304 | break; |
| 305 | } |
| 306 | break; |
| 307 | |
| 308 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 309 | ND_PRINT((ndo, "[code %d]", code)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 310 | break; |
| 311 | } |
| 312 | break; |
| 313 | |
| 314 | case EGPT_REACH: |
| 315 | switch (code) { |
| 316 | |
| 317 | case EGPC_HELLO: |
| 318 | case EGPC_HEARDU: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 319 | ND_PRINT((ndo, " %s", egp_reach_codes[code])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 320 | if (status <= EGPS_DOWN) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 321 | ND_PRINT((ndo, " state:%s", egp_status_updown[status])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 322 | else |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 323 | ND_PRINT((ndo, " [status %d]", status)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 324 | break; |
| 325 | |
| 326 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 327 | ND_PRINT((ndo, "[reach code %d]", code)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 328 | break; |
| 329 | } |
| 330 | break; |
| 331 | |
| 332 | case EGPT_POLL: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 333 | ND_PRINT((ndo, " poll")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 334 | if (egp->egp_status <= EGPS_DOWN) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 335 | ND_PRINT((ndo, " state:%s", egp_status_updown[status])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 336 | else |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 337 | ND_PRINT((ndo, " [status %d]", status)); |
| 338 | ND_PRINT((ndo, " net:%s", ipaddr_string(ndo, &egp->egp_sourcenet))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 339 | break; |
| 340 | |
| 341 | case EGPT_UPDATE: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 342 | ND_PRINT((ndo, " update")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 343 | if (status & EGPS_UNSOL) { |
| 344 | status &= ~EGPS_UNSOL; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 345 | ND_PRINT((ndo, " unsolicited")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 346 | } |
| 347 | if (status <= EGPS_DOWN) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 348 | ND_PRINT((ndo, " state:%s", egp_status_updown[status])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 349 | else |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 350 | ND_PRINT((ndo, " [status %d]", status)); |
| 351 | ND_PRINT((ndo, " %s int %d ext %d", |
| 352 | ipaddr_string(ndo, &egp->egp_sourcenet), |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 353 | egp->egp_intgw, |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 354 | egp->egp_extgw)); |
| 355 | if (ndo->ndo_vflag) |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 356 | egpnrprint(ndo, egp, length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 357 | break; |
| 358 | |
| 359 | case EGPT_ERROR: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 360 | ND_PRINT((ndo, " error")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 361 | if (status <= EGPS_DOWN) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 362 | ND_PRINT((ndo, " state:%s", egp_status_updown[status])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 363 | else |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 364 | ND_PRINT((ndo, " [status %d]", status)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 365 | |
| 366 | if (EXTRACT_16BITS(&egp->egp_reason) <= EGPR_UVERSION) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 367 | ND_PRINT((ndo, " %s", egp_reasons[EXTRACT_16BITS(&egp->egp_reason)])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 368 | else |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 369 | ND_PRINT((ndo, " [reason %d]", EXTRACT_16BITS(&egp->egp_reason))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 370 | break; |
| 371 | |
| 372 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 373 | ND_PRINT((ndo, "[type %d]", type)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 374 | break; |
| 375 | } |
| 376 | } |