The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Redistribution and use in source and binary forms, with or without |
| 3 | * modification, are permitted provided that: (1) source code |
| 4 | * distributions retain the above copyright notice and this paragraph |
| 5 | * in its entirety, and (2) distributions including binary code include |
| 6 | * the above copyright notice and this paragraph in its entirety in |
| 7 | * the documentation or other materials provided with the distribution. |
| 8 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND |
| 9 | * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT |
| 10 | * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 11 | * FOR A PARTICULAR PURPOSE. |
| 12 | * |
| 13 | * Original code by Andy Heffernan (ahh@juniper.net) |
| 14 | */ |
| 15 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 16 | /* \summary: Pragmatic General Multicast (PGM) printer */ |
| 17 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 18 | #ifdef HAVE_CONFIG_H |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 19 | #include <config.h> |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 20 | #endif |
| 21 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 22 | #include "netdissect-stdinc.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 23 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 24 | #include "netdissect.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 25 | #include "extract.h" |
| 26 | #include "addrtoname.h" |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 27 | #include "addrtostr.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 28 | |
| 29 | #include "ip.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 30 | #include "ip6.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 31 | #include "ipproto.h" |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 32 | #include "af.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 33 | |
| 34 | /* |
| 35 | * PGM header (RFC 3208) |
| 36 | */ |
| 37 | struct pgm_header { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 38 | nd_uint16_t pgm_sport; |
| 39 | nd_uint16_t pgm_dport; |
| 40 | nd_uint8_t pgm_type; |
| 41 | nd_uint8_t pgm_options; |
| 42 | nd_uint16_t pgm_sum; |
| 43 | nd_byte pgm_gsid[6]; |
| 44 | nd_uint16_t pgm_length; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | struct pgm_spm { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 48 | nd_uint32_t pgms_seq; |
| 49 | nd_uint32_t pgms_trailseq; |
| 50 | nd_uint32_t pgms_leadseq; |
| 51 | nd_uint16_t pgms_nla_afi; |
| 52 | nd_uint16_t pgms_reserved; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 53 | /* ... uint8_t pgms_nla[0]; */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 54 | /* ... options */ |
| 55 | }; |
| 56 | |
| 57 | struct pgm_nak { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 58 | nd_uint32_t pgmn_seq; |
| 59 | nd_uint16_t pgmn_source_afi; |
| 60 | nd_uint16_t pgmn_reserved; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 61 | /* ... uint8_t pgmn_source[0]; */ |
| 62 | /* ... uint16_t pgmn_group_afi */ |
| 63 | /* ... uint16_t pgmn_reserved2; */ |
| 64 | /* ... uint8_t pgmn_group[0]; */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 65 | /* ... options */ |
| 66 | }; |
| 67 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 68 | struct pgm_ack { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 69 | nd_uint32_t pgma_rx_max_seq; |
| 70 | nd_uint32_t pgma_bitmap; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 71 | /* ... options */ |
| 72 | }; |
| 73 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 74 | struct pgm_poll { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 75 | nd_uint32_t pgmp_seq; |
| 76 | nd_uint16_t pgmp_round; |
| 77 | nd_uint16_t pgmp_subtype; |
| 78 | nd_uint16_t pgmp_nla_afi; |
| 79 | nd_uint16_t pgmp_reserved; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 80 | /* ... uint8_t pgmp_nla[0]; */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 81 | /* ... options */ |
| 82 | }; |
| 83 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 84 | struct pgm_polr { |
| 85 | nd_uint32_t pgmp_seq; |
| 86 | nd_uint16_t pgmp_round; |
| 87 | nd_uint16_t pgmp_reserved; |
| 88 | /* ... options */ |
| 89 | }; |
| 90 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 91 | struct pgm_data { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 92 | nd_uint32_t pgmd_seq; |
| 93 | nd_uint32_t pgmd_trailseq; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 94 | /* ... options */ |
| 95 | }; |
| 96 | |
| 97 | typedef enum _pgm_type { |
| 98 | PGM_SPM = 0, /* source path message */ |
| 99 | PGM_POLL = 1, /* POLL Request */ |
| 100 | PGM_POLR = 2, /* POLL Response */ |
| 101 | PGM_ODATA = 4, /* original data */ |
| 102 | PGM_RDATA = 5, /* repair data */ |
| 103 | PGM_NAK = 8, /* NAK */ |
| 104 | PGM_NULLNAK = 9, /* Null NAK */ |
| 105 | PGM_NCF = 10, /* NAK Confirmation */ |
| 106 | PGM_ACK = 11, /* ACK for congestion control */ |
| 107 | PGM_SPMR = 12, /* SPM request */ |
| 108 | PGM_MAX = 255 |
| 109 | } pgm_type; |
| 110 | |
| 111 | #define PGM_OPT_BIT_PRESENT 0x01 |
| 112 | #define PGM_OPT_BIT_NETWORK 0x02 |
| 113 | #define PGM_OPT_BIT_VAR_PKTLEN 0x40 |
| 114 | #define PGM_OPT_BIT_PARITY 0x80 |
| 115 | |
| 116 | #define PGM_OPT_LENGTH 0x00 |
| 117 | #define PGM_OPT_FRAGMENT 0x01 |
| 118 | #define PGM_OPT_NAK_LIST 0x02 |
| 119 | #define PGM_OPT_JOIN 0x03 |
| 120 | #define PGM_OPT_NAK_BO_IVL 0x04 |
| 121 | #define PGM_OPT_NAK_BO_RNG 0x05 |
| 122 | |
| 123 | #define PGM_OPT_REDIRECT 0x07 |
| 124 | #define PGM_OPT_PARITY_PRM 0x08 |
| 125 | #define PGM_OPT_PARITY_GRP 0x09 |
| 126 | #define PGM_OPT_CURR_TGSIZE 0x0A |
| 127 | #define PGM_OPT_NBR_UNREACH 0x0B |
| 128 | #define PGM_OPT_PATH_NLA 0x0C |
| 129 | |
| 130 | #define PGM_OPT_SYN 0x0D |
| 131 | #define PGM_OPT_FIN 0x0E |
| 132 | #define PGM_OPT_RST 0x0F |
| 133 | #define PGM_OPT_CR 0x10 |
| 134 | #define PGM_OPT_CRQST 0x11 |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 135 | |
| 136 | #define PGM_OPT_PGMCC_DATA 0x12 |
| 137 | #define PGM_OPT_PGMCC_FEEDBACK 0x13 |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 138 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 139 | #define PGM_OPT_MASK 0x7f |
| 140 | |
| 141 | #define PGM_OPT_END 0x80 /* end of options marker */ |
| 142 | |
| 143 | #define PGM_MIN_OPT_LEN 4 |
| 144 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 145 | void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 146 | pgm_print(netdissect_options *ndo, |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 147 | const u_char *bp, u_int length, |
| 148 | const u_char *bp2) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 149 | { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 150 | const struct pgm_header *pgm; |
| 151 | const struct ip *ip; |
| 152 | uint8_t pgm_type_val; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 153 | uint16_t sport, dport; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 154 | u_int nla_afnum; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 155 | char nla_buf[INET6_ADDRSTRLEN]; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 156 | const struct ip6_hdr *ip6; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 157 | uint8_t opt_type, opt_len; |
| 158 | uint32_t seq, opts_len, len, offset; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 159 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 160 | ndo->ndo_protocol = "pgm"; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 161 | pgm = (const struct pgm_header *)bp; |
| 162 | ip = (const struct ip *)bp2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 163 | if (IP_V(ip) == 6) |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 164 | ip6 = (const struct ip6_hdr *)bp2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 165 | else |
| 166 | ip6 = NULL; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 167 | if (!ND_TTEST_2(pgm->pgm_dport)) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 168 | if (ip6) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 169 | ND_PRINT("%s > %s:", |
| 170 | GET_IP6ADDR_STRING(ip6->ip6_src), |
| 171 | GET_IP6ADDR_STRING(ip6->ip6_dst)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 172 | } else { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 173 | ND_PRINT("%s > %s:", |
| 174 | GET_IPADDR_STRING(ip->ip_src), |
| 175 | GET_IPADDR_STRING(ip->ip_dst)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 176 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 177 | nd_print_trunc(ndo); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 178 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 179 | } |
| 180 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 181 | sport = GET_BE_U_2(pgm->pgm_sport); |
| 182 | dport = GET_BE_U_2(pgm->pgm_dport); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 183 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 184 | if (ip6) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 185 | if (GET_U_1(ip6->ip6_nxt) == IPPROTO_PGM) { |
| 186 | ND_PRINT("%s.%s > %s.%s: ", |
| 187 | GET_IP6ADDR_STRING(ip6->ip6_src), |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 188 | tcpport_string(ndo, sport), |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 189 | GET_IP6ADDR_STRING(ip6->ip6_dst), |
| 190 | tcpport_string(ndo, dport)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 191 | } else { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 192 | ND_PRINT("%s > %s: ", |
| 193 | tcpport_string(ndo, sport), tcpport_string(ndo, dport)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 194 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 195 | } else { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 196 | if (GET_U_1(ip->ip_p) == IPPROTO_PGM) { |
| 197 | ND_PRINT("%s.%s > %s.%s: ", |
| 198 | GET_IPADDR_STRING(ip->ip_src), |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 199 | tcpport_string(ndo, sport), |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 200 | GET_IPADDR_STRING(ip->ip_dst), |
| 201 | tcpport_string(ndo, dport)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 202 | } else { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 203 | ND_PRINT("%s > %s: ", |
| 204 | tcpport_string(ndo, sport), tcpport_string(ndo, dport)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 208 | ND_TCHECK_SIZE(pgm); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 209 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 210 | ND_PRINT("PGM, length %u", GET_BE_U_2(pgm->pgm_length)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 211 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 212 | if (!ndo->ndo_vflag) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 213 | return; |
| 214 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 215 | pgm_type_val = GET_U_1(pgm->pgm_type); |
| 216 | ND_PRINT(" 0x%02x%02x%02x%02x%02x%02x ", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 217 | pgm->pgm_gsid[0], |
| 218 | pgm->pgm_gsid[1], |
| 219 | pgm->pgm_gsid[2], |
| 220 | pgm->pgm_gsid[3], |
| 221 | pgm->pgm_gsid[4], |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 222 | pgm->pgm_gsid[5]); |
| 223 | switch (pgm_type_val) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 224 | case PGM_SPM: { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 225 | const struct pgm_spm *spm; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 226 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 227 | spm = (const struct pgm_spm *)(pgm + 1); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 228 | ND_TCHECK_SIZE(spm); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 229 | bp = (const u_char *) (spm + 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 230 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 231 | switch (GET_BE_U_2(spm->pgms_nla_afi)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 232 | case AFNUM_INET: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 233 | ND_TCHECK_LEN(bp, sizeof(nd_ipv4)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 234 | addrtostr(bp, nla_buf, sizeof(nla_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 235 | bp += sizeof(nd_ipv4); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 236 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 237 | case AFNUM_INET6: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 238 | ND_TCHECK_LEN(bp, sizeof(nd_ipv6)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 239 | addrtostr6(bp, nla_buf, sizeof(nla_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 240 | bp += sizeof(nd_ipv6); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 241 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 242 | default: |
| 243 | goto trunc; |
| 244 | break; |
| 245 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 246 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 247 | ND_PRINT("SPM seq %u trail %u lead %u nla %s", |
| 248 | GET_BE_U_4(spm->pgms_seq), |
| 249 | GET_BE_U_4(spm->pgms_trailseq), |
| 250 | GET_BE_U_4(spm->pgms_leadseq), |
| 251 | nla_buf); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 252 | break; |
| 253 | } |
| 254 | |
| 255 | case PGM_POLL: { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 256 | const struct pgm_poll *pgm_poll; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 257 | uint32_t ivl, rnd, mask; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 258 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 259 | pgm_poll = (const struct pgm_poll *)(pgm + 1); |
| 260 | ND_TCHECK_SIZE(pgm_poll); |
| 261 | bp = (const u_char *) (pgm_poll + 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 262 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 263 | switch (GET_BE_U_2(pgm_poll->pgmp_nla_afi)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 264 | case AFNUM_INET: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 265 | ND_TCHECK_LEN(bp, sizeof(nd_ipv4)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 266 | addrtostr(bp, nla_buf, sizeof(nla_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 267 | bp += sizeof(nd_ipv4); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 268 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 269 | case AFNUM_INET6: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 270 | ND_TCHECK_LEN(bp, sizeof(nd_ipv6)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 271 | addrtostr6(bp, nla_buf, sizeof(nla_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 272 | bp += sizeof(nd_ipv6); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 273 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 274 | default: |
| 275 | goto trunc; |
| 276 | break; |
| 277 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 278 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 279 | ivl = GET_BE_U_4(bp); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 280 | bp += sizeof(uint32_t); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 281 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 282 | rnd = GET_BE_U_4(bp); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 283 | bp += sizeof(uint32_t); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 284 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 285 | mask = GET_BE_U_4(bp); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 286 | bp += sizeof(uint32_t); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 287 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 288 | ND_PRINT("POLL seq %u round %u nla %s ivl %u rnd 0x%08x " |
| 289 | "mask 0x%08x", GET_BE_U_4(pgm_poll->pgmp_seq), |
| 290 | GET_BE_U_2(pgm_poll->pgmp_round), nla_buf, ivl, rnd, |
| 291 | mask); |
| 292 | break; |
| 293 | } |
| 294 | case PGM_POLR: { |
| 295 | const struct pgm_polr *polr_msg; |
| 296 | |
| 297 | polr_msg = (const struct pgm_polr *)(pgm + 1); |
| 298 | ND_TCHECK_SIZE(polr_msg); |
| 299 | ND_PRINT("POLR seq %u round %u", |
| 300 | GET_BE_U_4(polr_msg->pgmp_seq), |
| 301 | GET_BE_U_2(polr_msg->pgmp_round)); |
| 302 | bp = (const u_char *) (polr_msg + 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 303 | break; |
| 304 | } |
| 305 | case PGM_ODATA: { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 306 | const struct pgm_data *odata; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 307 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 308 | odata = (const struct pgm_data *)(pgm + 1); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 309 | ND_TCHECK_SIZE(odata); |
| 310 | ND_PRINT("ODATA trail %u seq %u", |
| 311 | GET_BE_U_4(odata->pgmd_trailseq), |
| 312 | GET_BE_U_4(odata->pgmd_seq)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 313 | bp = (const u_char *) (odata + 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 314 | break; |
| 315 | } |
| 316 | |
| 317 | case PGM_RDATA: { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 318 | const struct pgm_data *rdata; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 319 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 320 | rdata = (const struct pgm_data *)(pgm + 1); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 321 | ND_TCHECK_SIZE(rdata); |
| 322 | ND_PRINT("RDATA trail %u seq %u", |
| 323 | GET_BE_U_4(rdata->pgmd_trailseq), |
| 324 | GET_BE_U_4(rdata->pgmd_seq)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 325 | bp = (const u_char *) (rdata + 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 326 | break; |
| 327 | } |
| 328 | |
| 329 | case PGM_NAK: |
| 330 | case PGM_NULLNAK: |
| 331 | case PGM_NCF: { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 332 | const struct pgm_nak *nak; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 333 | char source_buf[INET6_ADDRSTRLEN], group_buf[INET6_ADDRSTRLEN]; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 334 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 335 | nak = (const struct pgm_nak *)(pgm + 1); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 336 | ND_TCHECK_SIZE(nak); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 337 | bp = (const u_char *) (nak + 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 338 | |
| 339 | /* |
| 340 | * Skip past the source, saving info along the way |
| 341 | * and stopping if we don't have enough. |
| 342 | */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 343 | switch (GET_BE_U_2(nak->pgmn_source_afi)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 344 | case AFNUM_INET: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 345 | ND_TCHECK_LEN(bp, sizeof(nd_ipv4)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 346 | addrtostr(bp, source_buf, sizeof(source_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 347 | bp += sizeof(nd_ipv4); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 348 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 349 | case AFNUM_INET6: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 350 | ND_TCHECK_LEN(bp, sizeof(nd_ipv6)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 351 | addrtostr6(bp, source_buf, sizeof(source_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 352 | bp += sizeof(nd_ipv6); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 353 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 354 | default: |
| 355 | goto trunc; |
| 356 | break; |
| 357 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 358 | |
| 359 | /* |
| 360 | * Skip past the group, saving info along the way |
| 361 | * and stopping if we don't have enough. |
| 362 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 363 | bp += (2 * sizeof(uint16_t)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 364 | switch (GET_BE_U_2(bp)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 365 | case AFNUM_INET: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 366 | ND_TCHECK_LEN(bp, sizeof(nd_ipv4)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 367 | addrtostr(bp, group_buf, sizeof(group_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 368 | bp += sizeof(nd_ipv4); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 369 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 370 | case AFNUM_INET6: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 371 | ND_TCHECK_LEN(bp, sizeof(nd_ipv6)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 372 | addrtostr6(bp, group_buf, sizeof(group_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 373 | bp += sizeof(nd_ipv6); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 374 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 375 | default: |
| 376 | goto trunc; |
| 377 | break; |
| 378 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 379 | |
| 380 | /* |
| 381 | * Options decoding can go here. |
| 382 | */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 383 | switch (pgm_type_val) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 384 | case PGM_NAK: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 385 | ND_PRINT("NAK "); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 386 | break; |
| 387 | case PGM_NULLNAK: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 388 | ND_PRINT("NNAK "); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 389 | break; |
| 390 | case PGM_NCF: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 391 | ND_PRINT("NCF "); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 392 | break; |
| 393 | default: |
| 394 | break; |
| 395 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 396 | ND_PRINT("(%s -> %s), seq %u", |
| 397 | source_buf, group_buf, GET_BE_U_4(nak->pgmn_seq)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 398 | break; |
| 399 | } |
| 400 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 401 | case PGM_ACK: { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 402 | const struct pgm_ack *ack; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 403 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 404 | ack = (const struct pgm_ack *)(pgm + 1); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 405 | ND_TCHECK_SIZE(ack); |
| 406 | ND_PRINT("ACK seq %u", |
| 407 | GET_BE_U_4(ack->pgma_rx_max_seq)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 408 | bp = (const u_char *) (ack + 1); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 409 | break; |
| 410 | } |
| 411 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 412 | case PGM_SPMR: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 413 | ND_PRINT("SPMR"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 414 | break; |
| 415 | |
| 416 | default: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 417 | ND_PRINT("UNKNOWN type 0x%02x", pgm_type_val); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 418 | break; |
| 419 | |
| 420 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 421 | if (GET_U_1(pgm->pgm_options) & PGM_OPT_BIT_PRESENT) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 422 | |
| 423 | /* |
| 424 | * make sure there's enough for the first option header |
| 425 | */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 426 | ND_TCHECK_LEN(bp, PGM_MIN_OPT_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 427 | |
| 428 | /* |
| 429 | * That option header MUST be an OPT_LENGTH option |
| 430 | * (see the first paragraph of section 9.1 in RFC 3208). |
| 431 | */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 432 | opt_type = GET_U_1(bp); |
| 433 | bp++; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 434 | if ((opt_type & PGM_OPT_MASK) != PGM_OPT_LENGTH) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 435 | ND_PRINT("[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 436 | return; |
| 437 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 438 | opt_len = GET_U_1(bp); |
| 439 | bp++; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 440 | if (opt_len != 4) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 441 | ND_PRINT("[Bad OPT_LENGTH option, length %u != 4]", opt_len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 442 | return; |
| 443 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 444 | opts_len = GET_BE_U_2(bp); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 445 | bp += sizeof(uint16_t); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 446 | if (opts_len < 4) { |
| 447 | ND_PRINT("[Bad total option length %u < 4]", opts_len); |
| 448 | return; |
| 449 | } |
| 450 | ND_PRINT(" OPTS LEN %u", opts_len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 451 | opts_len -= 4; |
| 452 | |
| 453 | while (opts_len) { |
| 454 | if (opts_len < PGM_MIN_OPT_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 455 | ND_PRINT("[Total option length leaves no room for final option]"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 456 | return; |
| 457 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 458 | opt_type = GET_U_1(bp); |
| 459 | bp++; |
| 460 | opt_len = GET_U_1(bp); |
| 461 | bp++; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 462 | if (opt_len < PGM_MIN_OPT_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 463 | ND_PRINT("[Bad option, length %u < %u]", opt_len, |
| 464 | PGM_MIN_OPT_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 465 | break; |
| 466 | } |
| 467 | if (opts_len < opt_len) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 468 | ND_PRINT("[Total option length leaves no room for final option]"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 469 | return; |
| 470 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 471 | ND_TCHECK_LEN(bp, opt_len - 2); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 472 | |
| 473 | switch (opt_type & PGM_OPT_MASK) { |
| 474 | case PGM_OPT_LENGTH: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 475 | #define PGM_OPT_LENGTH_LEN (2+2) |
| 476 | if (opt_len != PGM_OPT_LENGTH_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 477 | ND_PRINT("[Bad OPT_LENGTH option, length %u != %u]", |
| 478 | opt_len, PGM_OPT_LENGTH_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 479 | return; |
| 480 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 481 | ND_PRINT(" OPTS LEN (extra?) %u", GET_BE_U_2(bp)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 482 | bp += 2; |
| 483 | opts_len -= PGM_OPT_LENGTH_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 484 | break; |
| 485 | |
| 486 | case PGM_OPT_FRAGMENT: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 487 | #define PGM_OPT_FRAGMENT_LEN (2+2+4+4+4) |
| 488 | if (opt_len != PGM_OPT_FRAGMENT_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 489 | ND_PRINT("[Bad OPT_FRAGMENT option, length %u != %u]", |
| 490 | opt_len, PGM_OPT_FRAGMENT_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 491 | return; |
| 492 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 493 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 494 | seq = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 495 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 496 | offset = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 497 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 498 | len = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 499 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 500 | ND_PRINT(" FRAG seq %u off %u len %u", seq, offset, len); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 501 | opts_len -= PGM_OPT_FRAGMENT_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 502 | break; |
| 503 | |
| 504 | case PGM_OPT_NAK_LIST: |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 505 | bp += 2; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 506 | opt_len -= 4; /* option header */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 507 | ND_PRINT(" NAK LIST"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 508 | while (opt_len) { |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 509 | if (opt_len < 4) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 510 | ND_PRINT("[Option length not a multiple of 4]"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 511 | return; |
| 512 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 513 | ND_PRINT(" %u", GET_BE_U_4(bp)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 514 | bp += 4; |
| 515 | opt_len -= 4; |
| 516 | opts_len -= 4; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 517 | } |
| 518 | break; |
| 519 | |
| 520 | case PGM_OPT_JOIN: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 521 | #define PGM_OPT_JOIN_LEN (2+2+4) |
| 522 | if (opt_len != PGM_OPT_JOIN_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 523 | ND_PRINT("[Bad OPT_JOIN option, length %u != %u]", |
| 524 | opt_len, PGM_OPT_JOIN_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 525 | return; |
| 526 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 527 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 528 | seq = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 529 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 530 | ND_PRINT(" JOIN %u", seq); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 531 | opts_len -= PGM_OPT_JOIN_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 532 | break; |
| 533 | |
| 534 | case PGM_OPT_NAK_BO_IVL: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 535 | #define PGM_OPT_NAK_BO_IVL_LEN (2+2+4+4) |
| 536 | if (opt_len != PGM_OPT_NAK_BO_IVL_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 537 | ND_PRINT("[Bad OPT_NAK_BO_IVL option, length %u != %u]", |
| 538 | opt_len, PGM_OPT_NAK_BO_IVL_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 539 | return; |
| 540 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 541 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 542 | offset = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 543 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 544 | seq = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 545 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 546 | ND_PRINT(" BACKOFF ivl %u ivlseq %u", offset, seq); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 547 | opts_len -= PGM_OPT_NAK_BO_IVL_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 548 | break; |
| 549 | |
| 550 | case PGM_OPT_NAK_BO_RNG: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 551 | #define PGM_OPT_NAK_BO_RNG_LEN (2+2+4+4) |
| 552 | if (opt_len != PGM_OPT_NAK_BO_RNG_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 553 | ND_PRINT("[Bad OPT_NAK_BO_RNG option, length %u != %u]", |
| 554 | opt_len, PGM_OPT_NAK_BO_RNG_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 555 | return; |
| 556 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 557 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 558 | offset = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 559 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 560 | seq = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 561 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 562 | ND_PRINT(" BACKOFF max %u min %u", offset, seq); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 563 | opts_len -= PGM_OPT_NAK_BO_RNG_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 564 | break; |
| 565 | |
| 566 | case PGM_OPT_REDIRECT: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 567 | #define PGM_OPT_REDIRECT_FIXED_LEN (2+2+2+2) |
| 568 | if (opt_len < PGM_OPT_REDIRECT_FIXED_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 569 | ND_PRINT("[Bad OPT_REDIRECT option, length %u < %u]", |
| 570 | opt_len, PGM_OPT_REDIRECT_FIXED_LEN); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 571 | return; |
| 572 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 573 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 574 | nla_afnum = GET_BE_U_2(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 575 | bp += 2+2; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 576 | switch (nla_afnum) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 577 | case AFNUM_INET: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 578 | if (opt_len != PGM_OPT_REDIRECT_FIXED_LEN + sizeof(nd_ipv4)) { |
| 579 | ND_PRINT("[Bad OPT_REDIRECT option, length %u != %u + address size]", |
| 580 | opt_len, PGM_OPT_REDIRECT_FIXED_LEN); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 581 | return; |
| 582 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 583 | ND_TCHECK_LEN(bp, sizeof(nd_ipv4)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 584 | addrtostr(bp, nla_buf, sizeof(nla_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 585 | bp += sizeof(nd_ipv4); |
| 586 | opts_len -= PGM_OPT_REDIRECT_FIXED_LEN + sizeof(nd_ipv4); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 587 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 588 | case AFNUM_INET6: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 589 | if (opt_len != PGM_OPT_REDIRECT_FIXED_LEN + sizeof(nd_ipv6)) { |
| 590 | ND_PRINT("[Bad OPT_REDIRECT option, length %u != %u + address size]", |
| 591 | opt_len, PGM_OPT_REDIRECT_FIXED_LEN); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 592 | return; |
| 593 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 594 | ND_TCHECK_LEN(bp, sizeof(nd_ipv6)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 595 | addrtostr6(bp, nla_buf, sizeof(nla_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 596 | bp += sizeof(nd_ipv6); |
| 597 | opts_len -= PGM_OPT_REDIRECT_FIXED_LEN + sizeof(nd_ipv6); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 598 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 599 | default: |
| 600 | goto trunc; |
| 601 | break; |
| 602 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 603 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 604 | ND_PRINT(" REDIRECT %s", nla_buf); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 605 | break; |
| 606 | |
| 607 | case PGM_OPT_PARITY_PRM: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 608 | #define PGM_OPT_PARITY_PRM_LEN (2+2+4) |
| 609 | if (opt_len != PGM_OPT_PARITY_PRM_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 610 | ND_PRINT("[Bad OPT_PARITY_PRM option, length %u != %u]", |
| 611 | opt_len, PGM_OPT_PARITY_PRM_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 612 | return; |
| 613 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 614 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 615 | len = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 616 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 617 | ND_PRINT(" PARITY MAXTGS %u", len); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 618 | opts_len -= PGM_OPT_PARITY_PRM_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 619 | break; |
| 620 | |
| 621 | case PGM_OPT_PARITY_GRP: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 622 | #define PGM_OPT_PARITY_GRP_LEN (2+2+4) |
| 623 | if (opt_len != PGM_OPT_PARITY_GRP_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 624 | ND_PRINT("[Bad OPT_PARITY_GRP option, length %u != %u]", |
| 625 | opt_len, PGM_OPT_PARITY_GRP_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 626 | return; |
| 627 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 628 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 629 | seq = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 630 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 631 | ND_PRINT(" PARITY GROUP %u", seq); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 632 | opts_len -= PGM_OPT_PARITY_GRP_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 633 | break; |
| 634 | |
| 635 | case PGM_OPT_CURR_TGSIZE: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 636 | #define PGM_OPT_CURR_TGSIZE_LEN (2+2+4) |
| 637 | if (opt_len != PGM_OPT_CURR_TGSIZE_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 638 | ND_PRINT("[Bad OPT_CURR_TGSIZE option, length %u != %u]", |
| 639 | opt_len, PGM_OPT_CURR_TGSIZE_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 640 | return; |
| 641 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 642 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 643 | len = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 644 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 645 | ND_PRINT(" PARITY ATGS %u", len); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 646 | opts_len -= PGM_OPT_CURR_TGSIZE_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 647 | break; |
| 648 | |
| 649 | case PGM_OPT_NBR_UNREACH: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 650 | #define PGM_OPT_NBR_UNREACH_LEN (2+2) |
| 651 | if (opt_len != PGM_OPT_NBR_UNREACH_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 652 | ND_PRINT("[Bad OPT_NBR_UNREACH option, length %u != %u]", |
| 653 | opt_len, PGM_OPT_NBR_UNREACH_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 654 | return; |
| 655 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 656 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 657 | ND_PRINT(" NBR_UNREACH"); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 658 | opts_len -= PGM_OPT_NBR_UNREACH_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 659 | break; |
| 660 | |
| 661 | case PGM_OPT_PATH_NLA: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 662 | ND_PRINT(" PATH_NLA [%u]", opt_len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 663 | bp += opt_len; |
| 664 | opts_len -= opt_len; |
| 665 | break; |
| 666 | |
| 667 | case PGM_OPT_SYN: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 668 | #define PGM_OPT_SYN_LEN (2+2) |
| 669 | if (opt_len != PGM_OPT_SYN_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 670 | ND_PRINT("[Bad OPT_SYN option, length %u != %u]", |
| 671 | opt_len, PGM_OPT_SYN_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 672 | return; |
| 673 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 674 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 675 | ND_PRINT(" SYN"); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 676 | opts_len -= PGM_OPT_SYN_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 677 | break; |
| 678 | |
| 679 | case PGM_OPT_FIN: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 680 | #define PGM_OPT_FIN_LEN (2+2) |
| 681 | if (opt_len != PGM_OPT_FIN_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 682 | ND_PRINT("[Bad OPT_FIN option, length %u != %u]", |
| 683 | opt_len, PGM_OPT_FIN_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 684 | return; |
| 685 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 686 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 687 | ND_PRINT(" FIN"); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 688 | opts_len -= PGM_OPT_FIN_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 689 | break; |
| 690 | |
| 691 | case PGM_OPT_RST: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 692 | #define PGM_OPT_RST_LEN (2+2) |
| 693 | if (opt_len != PGM_OPT_RST_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 694 | ND_PRINT("[Bad OPT_RST option, length %u != %u]", |
| 695 | opt_len, PGM_OPT_RST_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 696 | return; |
| 697 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 698 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 699 | ND_PRINT(" RST"); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 700 | opts_len -= PGM_OPT_RST_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 701 | break; |
| 702 | |
| 703 | case PGM_OPT_CR: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 704 | ND_PRINT(" CR"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 705 | bp += opt_len; |
| 706 | opts_len -= opt_len; |
| 707 | break; |
| 708 | |
| 709 | case PGM_OPT_CRQST: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 710 | #define PGM_OPT_CRQST_LEN (2+2) |
| 711 | if (opt_len != PGM_OPT_CRQST_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 712 | ND_PRINT("[Bad OPT_CRQST option, length %u != %u]", |
| 713 | opt_len, PGM_OPT_CRQST_LEN); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 714 | return; |
| 715 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 716 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 717 | ND_PRINT(" CRQST"); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 718 | opts_len -= PGM_OPT_CRQST_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 719 | break; |
| 720 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 721 | case PGM_OPT_PGMCC_DATA: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 722 | #define PGM_OPT_PGMCC_DATA_FIXED_LEN (2+2+4+2+2) |
| 723 | if (opt_len < PGM_OPT_PGMCC_DATA_FIXED_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 724 | ND_PRINT("[Bad OPT_PGMCC_DATA option, length %u < %u]", |
| 725 | opt_len, PGM_OPT_PGMCC_DATA_FIXED_LEN); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 726 | return; |
| 727 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 728 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 729 | offset = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 730 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 731 | nla_afnum = GET_BE_U_2(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 732 | bp += 2+2; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 733 | switch (nla_afnum) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 734 | case AFNUM_INET: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 735 | if (opt_len != PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(nd_ipv4)) { |
| 736 | ND_PRINT("[Bad OPT_PGMCC_DATA option, length %u != %u + address size]", |
| 737 | opt_len, PGM_OPT_PGMCC_DATA_FIXED_LEN); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 738 | return; |
| 739 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 740 | ND_TCHECK_LEN(bp, sizeof(nd_ipv4)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 741 | addrtostr(bp, nla_buf, sizeof(nla_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 742 | bp += sizeof(nd_ipv4); |
| 743 | opts_len -= PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(nd_ipv4); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 744 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 745 | case AFNUM_INET6: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 746 | if (opt_len != PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(nd_ipv6)) { |
| 747 | ND_PRINT("[Bad OPT_PGMCC_DATA option, length %u != %u + address size]", |
| 748 | opt_len, PGM_OPT_PGMCC_DATA_FIXED_LEN); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 749 | return; |
| 750 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 751 | ND_TCHECK_LEN(bp, sizeof(nd_ipv6)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 752 | addrtostr6(bp, nla_buf, sizeof(nla_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 753 | bp += sizeof(nd_ipv6); |
| 754 | opts_len -= PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(nd_ipv6); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 755 | break; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 756 | default: |
| 757 | goto trunc; |
| 758 | break; |
| 759 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 760 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 761 | ND_PRINT(" PGMCC DATA %u %s", offset, nla_buf); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 762 | break; |
| 763 | |
| 764 | case PGM_OPT_PGMCC_FEEDBACK: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 765 | #define PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN (2+2+4+2+2) |
| 766 | if (opt_len < PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 767 | ND_PRINT("[Bad PGM_OPT_PGMCC_FEEDBACK option, length %u < %u]", |
| 768 | opt_len, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 769 | return; |
| 770 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 771 | bp += 2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 772 | offset = GET_BE_U_4(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 773 | bp += 4; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 774 | nla_afnum = GET_BE_U_2(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 775 | bp += 2+2; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 776 | switch (nla_afnum) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 777 | case AFNUM_INET: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 778 | if (opt_len != PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(nd_ipv4)) { |
| 779 | ND_PRINT("[Bad OPT_PGMCC_FEEDBACK option, length %u != %u + address size]", |
| 780 | opt_len, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 781 | return; |
| 782 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 783 | ND_TCHECK_LEN(bp, sizeof(nd_ipv4)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 784 | addrtostr(bp, nla_buf, sizeof(nla_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 785 | bp += sizeof(nd_ipv4); |
| 786 | opts_len -= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(nd_ipv4); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 787 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 788 | case AFNUM_INET6: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 789 | if (opt_len != PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(nd_ipv6)) { |
| 790 | ND_PRINT("[Bad OPT_PGMCC_FEEDBACK option, length %u != %u + address size]", |
| 791 | opt_len, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 792 | return; |
| 793 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 794 | ND_TCHECK_LEN(bp, sizeof(nd_ipv6)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 795 | addrtostr6(bp, nla_buf, sizeof(nla_buf)); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 796 | bp += sizeof(nd_ipv6); |
| 797 | opts_len -= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(nd_ipv6); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 798 | break; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 799 | default: |
| 800 | goto trunc; |
| 801 | break; |
| 802 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 803 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 804 | ND_PRINT(" PGMCC FEEDBACK %u %s", offset, nla_buf); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 805 | break; |
| 806 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 807 | default: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 808 | ND_PRINT(" OPT_%02X [%u] ", opt_type, opt_len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 809 | bp += opt_len; |
| 810 | opts_len -= opt_len; |
| 811 | break; |
| 812 | } |
| 813 | |
| 814 | if (opt_type & PGM_OPT_END) |
| 815 | break; |
| 816 | } |
| 817 | } |
| 818 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 819 | ND_PRINT(" [%u]", length); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 820 | if (ndo->ndo_packettype == PT_PGM_ZMTP1 && |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 821 | (pgm_type_val == PGM_ODATA || pgm_type_val == PGM_RDATA)) |
| 822 | zmtp1_datagram_print(ndo, bp, |
| 823 | GET_BE_U_2(pgm->pgm_length)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 824 | |
| 825 | return; |
| 826 | |
| 827 | trunc: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 828 | nd_print_trunc(ndo); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 829 | } |