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 |
| 19 | #include "config.h" |
| 20 | #endif |
| 21 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -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 | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 38 | uint16_t pgm_sport; |
| 39 | uint16_t pgm_dport; |
| 40 | uint8_t pgm_type; |
| 41 | uint8_t pgm_options; |
| 42 | uint16_t pgm_sum; |
| 43 | uint8_t pgm_gsid[6]; |
| 44 | 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 | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 48 | uint32_t pgms_seq; |
| 49 | uint32_t pgms_trailseq; |
| 50 | uint32_t pgms_leadseq; |
| 51 | uint16_t pgms_nla_afi; |
| 52 | uint16_t pgms_reserved; |
| 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 | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 58 | uint32_t pgmn_seq; |
| 59 | uint16_t pgmn_source_afi; |
| 60 | uint16_t pgmn_reserved; |
| 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 | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 69 | uint32_t pgma_rx_max_seq; |
| 70 | 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 | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 75 | uint32_t pgmp_seq; |
| 76 | uint16_t pgmp_round; |
| 77 | uint16_t pgmp_reserved; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 78 | /* ... options */ |
| 79 | }; |
| 80 | |
| 81 | struct pgm_polr { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 82 | uint32_t pgmp_seq; |
| 83 | uint16_t pgmp_round; |
| 84 | uint16_t pgmp_subtype; |
| 85 | uint16_t pgmp_nla_afi; |
| 86 | uint16_t pgmp_reserved; |
| 87 | /* ... uint8_t pgmp_nla[0]; */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 88 | /* ... options */ |
| 89 | }; |
| 90 | |
| 91 | struct pgm_data { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 92 | uint32_t pgmd_seq; |
| 93 | 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, |
| 147 | register const u_char *bp, register u_int length, |
| 148 | register const u_char *bp2) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 149 | { |
| 150 | register const struct pgm_header *pgm; |
| 151 | register const struct ip *ip; |
| 152 | register char ch; |
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]; |
| 156 | register 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 | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 160 | pgm = (const struct pgm_header *)bp; |
| 161 | ip = (const struct ip *)bp2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 162 | if (IP_V(ip) == 6) |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 163 | ip6 = (const struct ip6_hdr *)bp2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 164 | else |
| 165 | ip6 = NULL; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 166 | ch = '\0'; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 167 | if (!ND_TTEST(pgm->pgm_dport)) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 168 | if (ip6) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 169 | ND_PRINT((ndo, "%s > %s: [|pgm]", |
| 170 | ip6addr_string(ndo, &ip6->ip6_src), |
| 171 | ip6addr_string(ndo, &ip6->ip6_dst))); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 172 | } else { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 173 | ND_PRINT((ndo, "%s > %s: [|pgm]", |
| 174 | ipaddr_string(ndo, &ip->ip_src), |
| 175 | ipaddr_string(ndo, &ip->ip_dst))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 176 | } |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 177 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | sport = EXTRACT_16BITS(&pgm->pgm_sport); |
| 181 | dport = EXTRACT_16BITS(&pgm->pgm_dport); |
| 182 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 183 | if (ip6) { |
| 184 | if (ip6->ip6_nxt == IPPROTO_PGM) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 185 | ND_PRINT((ndo, "%s.%s > %s.%s: ", |
| 186 | ip6addr_string(ndo, &ip6->ip6_src), |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 187 | tcpport_string(ndo, sport), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 188 | ip6addr_string(ndo, &ip6->ip6_dst), |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 189 | tcpport_string(ndo, dport))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 190 | } else { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 191 | ND_PRINT((ndo, "%s > %s: ", |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 192 | tcpport_string(ndo, sport), tcpport_string(ndo, dport))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 193 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 194 | } else { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 195 | if (ip->ip_p == IPPROTO_PGM) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 196 | ND_PRINT((ndo, "%s.%s > %s.%s: ", |
| 197 | ipaddr_string(ndo, &ip->ip_src), |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 198 | tcpport_string(ndo, sport), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 199 | ipaddr_string(ndo, &ip->ip_dst), |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 200 | tcpport_string(ndo, dport))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 201 | } else { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 202 | ND_PRINT((ndo, "%s > %s: ", |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 203 | tcpport_string(ndo, sport), tcpport_string(ndo, dport))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 207 | ND_TCHECK(*pgm); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 208 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 209 | ND_PRINT((ndo, "PGM, length %u", EXTRACT_16BITS(&pgm->pgm_length))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 210 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 211 | if (!ndo->ndo_vflag) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 212 | return; |
| 213 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 214 | ND_PRINT((ndo, " 0x%02x%02x%02x%02x%02x%02x ", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 215 | pgm->pgm_gsid[0], |
| 216 | pgm->pgm_gsid[1], |
| 217 | pgm->pgm_gsid[2], |
| 218 | pgm->pgm_gsid[3], |
| 219 | pgm->pgm_gsid[4], |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 220 | pgm->pgm_gsid[5])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 221 | switch (pgm->pgm_type) { |
| 222 | case PGM_SPM: { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 223 | const struct pgm_spm *spm; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 224 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 225 | spm = (const struct pgm_spm *)(pgm + 1); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 226 | ND_TCHECK(*spm); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 227 | bp = (const u_char *) (spm + 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 228 | |
| 229 | switch (EXTRACT_16BITS(&spm->pgms_nla_afi)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 230 | case AFNUM_INET: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 231 | ND_TCHECK2(*bp, sizeof(struct in_addr)); |
| 232 | addrtostr(bp, nla_buf, sizeof(nla_buf)); |
| 233 | bp += sizeof(struct in_addr); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 234 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 235 | case AFNUM_INET6: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 236 | ND_TCHECK2(*bp, sizeof(struct in6_addr)); |
| 237 | addrtostr6(bp, nla_buf, sizeof(nla_buf)); |
| 238 | bp += sizeof(struct in6_addr); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 239 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 240 | default: |
| 241 | goto trunc; |
| 242 | break; |
| 243 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 244 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 245 | ND_PRINT((ndo, "SPM seq %u trail %u lead %u nla %s", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 246 | EXTRACT_32BITS(&spm->pgms_seq), |
| 247 | EXTRACT_32BITS(&spm->pgms_trailseq), |
| 248 | EXTRACT_32BITS(&spm->pgms_leadseq), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 249 | nla_buf)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 250 | break; |
| 251 | } |
| 252 | |
| 253 | case PGM_POLL: { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 254 | const struct pgm_poll *poll_msg; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 255 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 256 | poll_msg = (const struct pgm_poll *)(pgm + 1); |
| 257 | ND_TCHECK(*poll_msg); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 258 | ND_PRINT((ndo, "POLL seq %u round %u", |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 259 | EXTRACT_32BITS(&poll_msg->pgmp_seq), |
| 260 | EXTRACT_16BITS(&poll_msg->pgmp_round))); |
| 261 | bp = (const u_char *) (poll_msg + 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 262 | break; |
| 263 | } |
| 264 | case PGM_POLR: { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 265 | const struct pgm_polr *polr; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 266 | uint32_t ivl, rnd, mask; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 267 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 268 | polr = (const struct pgm_polr *)(pgm + 1); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 269 | ND_TCHECK(*polr); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 270 | bp = (const u_char *) (polr + 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 271 | |
| 272 | switch (EXTRACT_16BITS(&polr->pgmp_nla_afi)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 273 | case AFNUM_INET: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 274 | ND_TCHECK2(*bp, sizeof(struct in_addr)); |
| 275 | addrtostr(bp, nla_buf, sizeof(nla_buf)); |
| 276 | bp += sizeof(struct in_addr); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 277 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 278 | case AFNUM_INET6: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 279 | ND_TCHECK2(*bp, sizeof(struct in6_addr)); |
| 280 | addrtostr6(bp, nla_buf, sizeof(nla_buf)); |
| 281 | bp += sizeof(struct in6_addr); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 282 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 283 | default: |
| 284 | goto trunc; |
| 285 | break; |
| 286 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 287 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 288 | ND_TCHECK2(*bp, sizeof(uint32_t)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 289 | ivl = EXTRACT_32BITS(bp); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 290 | bp += sizeof(uint32_t); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 291 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 292 | ND_TCHECK2(*bp, sizeof(uint32_t)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 293 | rnd = EXTRACT_32BITS(bp); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 294 | bp += sizeof(uint32_t); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 295 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 296 | ND_TCHECK2(*bp, sizeof(uint32_t)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 297 | mask = EXTRACT_32BITS(bp); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 298 | bp += sizeof(uint32_t); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 299 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 300 | ND_PRINT((ndo, "POLR seq %u round %u nla %s ivl %u rnd 0x%08x " |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 301 | "mask 0x%08x", EXTRACT_32BITS(&polr->pgmp_seq), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 302 | EXTRACT_16BITS(&polr->pgmp_round), nla_buf, ivl, rnd, mask)); |
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 | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 309 | ND_TCHECK(*odata); |
| 310 | ND_PRINT((ndo, "ODATA trail %u seq %u", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 311 | EXTRACT_32BITS(&odata->pgmd_trailseq), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 312 | EXTRACT_32BITS(&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 | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 321 | ND_TCHECK(*rdata); |
| 322 | ND_PRINT((ndo, "RDATA trail %u seq %u", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 323 | EXTRACT_32BITS(&rdata->pgmd_trailseq), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 324 | EXTRACT_32BITS(&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 | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 336 | ND_TCHECK(*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 | */ |
| 343 | switch (EXTRACT_16BITS(&nak->pgmn_source_afi)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 344 | case AFNUM_INET: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 345 | ND_TCHECK2(*bp, sizeof(struct in_addr)); |
| 346 | addrtostr(bp, source_buf, sizeof(source_buf)); |
| 347 | bp += sizeof(struct in_addr); |
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 | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 350 | ND_TCHECK2(*bp, sizeof(struct in6_addr)); |
| 351 | addrtostr6(bp, source_buf, sizeof(source_buf)); |
| 352 | bp += sizeof(struct in6_addr); |
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 | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 364 | ND_TCHECK_16BITS(bp); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 365 | switch (EXTRACT_16BITS(bp)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 366 | case AFNUM_INET: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 367 | ND_TCHECK2(*bp, sizeof(struct in_addr)); |
| 368 | addrtostr(bp, group_buf, sizeof(group_buf)); |
| 369 | bp += sizeof(struct in_addr); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 370 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 371 | case AFNUM_INET6: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 372 | ND_TCHECK2(*bp, sizeof(struct in6_addr)); |
| 373 | addrtostr6(bp, group_buf, sizeof(group_buf)); |
| 374 | bp += sizeof(struct in6_addr); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 375 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 376 | default: |
| 377 | goto trunc; |
| 378 | break; |
| 379 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 380 | |
| 381 | /* |
| 382 | * Options decoding can go here. |
| 383 | */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 384 | switch (pgm->pgm_type) { |
| 385 | case PGM_NAK: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 386 | ND_PRINT((ndo, "NAK ")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 387 | break; |
| 388 | case PGM_NULLNAK: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 389 | ND_PRINT((ndo, "NNAK ")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 390 | break; |
| 391 | case PGM_NCF: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 392 | ND_PRINT((ndo, "NCF ")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 393 | break; |
| 394 | default: |
| 395 | break; |
| 396 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 397 | ND_PRINT((ndo, "(%s -> %s), seq %u", |
| 398 | source_buf, group_buf, EXTRACT_32BITS(&nak->pgmn_seq))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 399 | break; |
| 400 | } |
| 401 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 402 | case PGM_ACK: { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 403 | const struct pgm_ack *ack; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 404 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 405 | ack = (const struct pgm_ack *)(pgm + 1); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 406 | ND_TCHECK(*ack); |
| 407 | ND_PRINT((ndo, "ACK seq %u", |
| 408 | EXTRACT_32BITS(&ack->pgma_rx_max_seq))); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 409 | bp = (const u_char *) (ack + 1); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 410 | break; |
| 411 | } |
| 412 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 413 | case PGM_SPMR: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 414 | ND_PRINT((ndo, "SPMR")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 415 | break; |
| 416 | |
| 417 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 418 | ND_PRINT((ndo, "UNKNOWN type 0x%02x", pgm->pgm_type)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 419 | break; |
| 420 | |
| 421 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 422 | if (pgm->pgm_options & PGM_OPT_BIT_PRESENT) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 423 | |
| 424 | /* |
| 425 | * make sure there's enough for the first option header |
| 426 | */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 427 | if (!ND_TTEST2(*bp, PGM_MIN_OPT_LEN)) { |
| 428 | ND_PRINT((ndo, "[|OPT]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 429 | return; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 430 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 431 | |
| 432 | /* |
| 433 | * That option header MUST be an OPT_LENGTH option |
| 434 | * (see the first paragraph of section 9.1 in RFC 3208). |
| 435 | */ |
| 436 | opt_type = *bp++; |
| 437 | if ((opt_type & PGM_OPT_MASK) != PGM_OPT_LENGTH) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 438 | ND_PRINT((ndo, "[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] | 439 | return; |
| 440 | } |
| 441 | opt_len = *bp++; |
| 442 | if (opt_len != 4) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 443 | ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != 4]", opt_len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 444 | return; |
| 445 | } |
| 446 | opts_len = EXTRACT_16BITS(bp); |
| 447 | if (opts_len < 4) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 448 | ND_PRINT((ndo, "[Bad total option length %u < 4]", opts_len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 449 | return; |
| 450 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 451 | bp += sizeof(uint16_t); |
| 452 | ND_PRINT((ndo, " OPTS LEN %d", opts_len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 453 | opts_len -= 4; |
| 454 | |
| 455 | while (opts_len) { |
| 456 | if (opts_len < PGM_MIN_OPT_LEN) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 457 | ND_PRINT((ndo, "[Total option length leaves no room for final option]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 458 | return; |
| 459 | } |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 460 | if (!ND_TTEST2(*bp, 2)) { |
| 461 | ND_PRINT((ndo, " [|OPT]")); |
| 462 | return; |
| 463 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 464 | opt_type = *bp++; |
| 465 | opt_len = *bp++; |
| 466 | if (opt_len < PGM_MIN_OPT_LEN) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 467 | ND_PRINT((ndo, "[Bad option, length %u < %u]", opt_len, |
| 468 | PGM_MIN_OPT_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 469 | break; |
| 470 | } |
| 471 | if (opts_len < opt_len) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 472 | ND_PRINT((ndo, "[Total option length leaves no room for final option]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 473 | return; |
| 474 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 475 | if (!ND_TTEST2(*bp, opt_len - 2)) { |
| 476 | ND_PRINT((ndo, " [|OPT]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 477 | return; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 478 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 479 | |
| 480 | switch (opt_type & PGM_OPT_MASK) { |
| 481 | case PGM_OPT_LENGTH: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 482 | #define PGM_OPT_LENGTH_LEN (2+2) |
| 483 | if (opt_len != PGM_OPT_LENGTH_LEN) { |
| 484 | ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != %u]", |
| 485 | opt_len, PGM_OPT_LENGTH_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 486 | return; |
| 487 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 488 | ND_PRINT((ndo, " OPTS LEN (extra?) %d", EXTRACT_16BITS(bp))); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 489 | bp += 2; |
| 490 | opts_len -= PGM_OPT_LENGTH_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 491 | break; |
| 492 | |
| 493 | case PGM_OPT_FRAGMENT: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 494 | #define PGM_OPT_FRAGMENT_LEN (2+2+4+4+4) |
| 495 | if (opt_len != PGM_OPT_FRAGMENT_LEN) { |
| 496 | ND_PRINT((ndo, "[Bad OPT_FRAGMENT option, length %u != %u]", |
| 497 | opt_len, PGM_OPT_FRAGMENT_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 498 | return; |
| 499 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 500 | bp += 2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 501 | seq = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 502 | bp += 4; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 503 | offset = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 504 | bp += 4; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 505 | len = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 506 | bp += 4; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 507 | ND_PRINT((ndo, " FRAG seq %u off %u len %u", seq, offset, len)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 508 | opts_len -= PGM_OPT_FRAGMENT_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 509 | break; |
| 510 | |
| 511 | case PGM_OPT_NAK_LIST: |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 512 | bp += 2; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 513 | opt_len -= 4; /* option header */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 514 | ND_PRINT((ndo, " NAK LIST")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 515 | while (opt_len) { |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 516 | if (opt_len < 4) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 517 | ND_PRINT((ndo, "[Option length not a multiple of 4]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 518 | return; |
| 519 | } |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 520 | ND_TCHECK2(*bp, 4); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 521 | ND_PRINT((ndo, " %u", EXTRACT_32BITS(bp))); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 522 | bp += 4; |
| 523 | opt_len -= 4; |
| 524 | opts_len -= 4; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 525 | } |
| 526 | break; |
| 527 | |
| 528 | case PGM_OPT_JOIN: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 529 | #define PGM_OPT_JOIN_LEN (2+2+4) |
| 530 | if (opt_len != PGM_OPT_JOIN_LEN) { |
| 531 | ND_PRINT((ndo, "[Bad OPT_JOIN option, length %u != %u]", |
| 532 | opt_len, PGM_OPT_JOIN_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 533 | return; |
| 534 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 535 | bp += 2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 536 | seq = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 537 | bp += 4; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 538 | ND_PRINT((ndo, " JOIN %u", seq)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 539 | opts_len -= PGM_OPT_JOIN_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 540 | break; |
| 541 | |
| 542 | case PGM_OPT_NAK_BO_IVL: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 543 | #define PGM_OPT_NAK_BO_IVL_LEN (2+2+4+4) |
| 544 | if (opt_len != PGM_OPT_NAK_BO_IVL_LEN) { |
| 545 | ND_PRINT((ndo, "[Bad OPT_NAK_BO_IVL option, length %u != %u]", |
| 546 | opt_len, PGM_OPT_NAK_BO_IVL_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 547 | return; |
| 548 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 549 | bp += 2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 550 | offset = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 551 | bp += 4; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 552 | seq = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 553 | bp += 4; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 554 | ND_PRINT((ndo, " BACKOFF ivl %u ivlseq %u", offset, seq)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 555 | opts_len -= PGM_OPT_NAK_BO_IVL_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 556 | break; |
| 557 | |
| 558 | case PGM_OPT_NAK_BO_RNG: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 559 | #define PGM_OPT_NAK_BO_RNG_LEN (2+2+4+4) |
| 560 | if (opt_len != PGM_OPT_NAK_BO_RNG_LEN) { |
| 561 | ND_PRINT((ndo, "[Bad OPT_NAK_BO_RNG option, length %u != %u]", |
| 562 | opt_len, PGM_OPT_NAK_BO_RNG_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 563 | return; |
| 564 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 565 | bp += 2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 566 | offset = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 567 | bp += 4; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 568 | seq = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 569 | bp += 4; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 570 | ND_PRINT((ndo, " BACKOFF max %u min %u", offset, seq)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 571 | opts_len -= PGM_OPT_NAK_BO_RNG_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 572 | break; |
| 573 | |
| 574 | case PGM_OPT_REDIRECT: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 575 | #define PGM_OPT_REDIRECT_FIXED_LEN (2+2+2+2) |
| 576 | if (opt_len < PGM_OPT_REDIRECT_FIXED_LEN) { |
| 577 | ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u < %u]", |
| 578 | opt_len, PGM_OPT_REDIRECT_FIXED_LEN)); |
| 579 | return; |
| 580 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 581 | bp += 2; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 582 | nla_afnum = EXTRACT_16BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 583 | bp += 2+2; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 584 | switch (nla_afnum) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 585 | case AFNUM_INET: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 586 | if (opt_len != PGM_OPT_REDIRECT_FIXED_LEN + sizeof(struct in_addr)) { |
| 587 | ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != %u + address size]", |
| 588 | opt_len, PGM_OPT_REDIRECT_FIXED_LEN)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 589 | return; |
| 590 | } |
| 591 | ND_TCHECK2(*bp, sizeof(struct in_addr)); |
| 592 | addrtostr(bp, nla_buf, sizeof(nla_buf)); |
| 593 | bp += sizeof(struct in_addr); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 594 | opts_len -= PGM_OPT_REDIRECT_FIXED_LEN + sizeof(struct in_addr); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 595 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 596 | case AFNUM_INET6: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 597 | if (opt_len != PGM_OPT_REDIRECT_FIXED_LEN + sizeof(struct in6_addr)) { |
| 598 | ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != %u + address size]", |
| 599 | PGM_OPT_REDIRECT_FIXED_LEN, opt_len)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 600 | return; |
| 601 | } |
| 602 | ND_TCHECK2(*bp, sizeof(struct in6_addr)); |
| 603 | addrtostr6(bp, nla_buf, sizeof(nla_buf)); |
| 604 | bp += sizeof(struct in6_addr); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 605 | opts_len -= PGM_OPT_REDIRECT_FIXED_LEN + sizeof(struct in6_addr); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 606 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 607 | default: |
| 608 | goto trunc; |
| 609 | break; |
| 610 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 611 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 612 | ND_PRINT((ndo, " REDIRECT %s", nla_buf)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 613 | break; |
| 614 | |
| 615 | case PGM_OPT_PARITY_PRM: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 616 | #define PGM_OPT_PARITY_PRM_LEN (2+2+4) |
| 617 | if (opt_len != PGM_OPT_PARITY_PRM_LEN) { |
| 618 | ND_PRINT((ndo, "[Bad OPT_PARITY_PRM option, length %u != %u]", |
| 619 | opt_len, PGM_OPT_PARITY_PRM_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 620 | return; |
| 621 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 622 | bp += 2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 623 | len = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 624 | bp += 4; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 625 | ND_PRINT((ndo, " PARITY MAXTGS %u", len)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 626 | opts_len -= PGM_OPT_PARITY_PRM_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 627 | break; |
| 628 | |
| 629 | case PGM_OPT_PARITY_GRP: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 630 | #define PGM_OPT_PARITY_GRP_LEN (2+2+4) |
| 631 | if (opt_len != PGM_OPT_PARITY_GRP_LEN) { |
| 632 | ND_PRINT((ndo, "[Bad OPT_PARITY_GRP option, length %u != %u]", |
| 633 | opt_len, PGM_OPT_PARITY_GRP_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 634 | return; |
| 635 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 636 | bp += 2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 637 | seq = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 638 | bp += 4; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 639 | ND_PRINT((ndo, " PARITY GROUP %u", seq)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 640 | opts_len -= PGM_OPT_PARITY_GRP_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 641 | break; |
| 642 | |
| 643 | case PGM_OPT_CURR_TGSIZE: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 644 | #define PGM_OPT_CURR_TGSIZE_LEN (2+2+4) |
| 645 | if (opt_len != PGM_OPT_CURR_TGSIZE_LEN) { |
| 646 | ND_PRINT((ndo, "[Bad OPT_CURR_TGSIZE option, length %u != %u]", |
| 647 | opt_len, PGM_OPT_CURR_TGSIZE_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 648 | return; |
| 649 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 650 | bp += 2; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 651 | len = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 652 | bp += 4; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 653 | ND_PRINT((ndo, " PARITY ATGS %u", len)); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 654 | opts_len -= PGM_OPT_CURR_TGSIZE_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 655 | break; |
| 656 | |
| 657 | case PGM_OPT_NBR_UNREACH: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 658 | #define PGM_OPT_NBR_UNREACH_LEN (2+2) |
| 659 | if (opt_len != PGM_OPT_NBR_UNREACH_LEN) { |
| 660 | ND_PRINT((ndo, "[Bad OPT_NBR_UNREACH option, length %u != %u]", |
| 661 | opt_len, PGM_OPT_NBR_UNREACH_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 662 | return; |
| 663 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 664 | bp += 2; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 665 | ND_PRINT((ndo, " NBR_UNREACH")); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 666 | opts_len -= PGM_OPT_NBR_UNREACH_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 667 | break; |
| 668 | |
| 669 | case PGM_OPT_PATH_NLA: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 670 | ND_PRINT((ndo, " PATH_NLA [%d]", opt_len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 671 | bp += opt_len; |
| 672 | opts_len -= opt_len; |
| 673 | break; |
| 674 | |
| 675 | case PGM_OPT_SYN: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 676 | #define PGM_OPT_SYN_LEN (2+2) |
| 677 | if (opt_len != PGM_OPT_SYN_LEN) { |
| 678 | ND_PRINT((ndo, "[Bad OPT_SYN option, length %u != %u]", |
| 679 | opt_len, PGM_OPT_SYN_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 680 | return; |
| 681 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 682 | bp += 2; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 683 | ND_PRINT((ndo, " SYN")); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 684 | opts_len -= PGM_OPT_SYN_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 685 | break; |
| 686 | |
| 687 | case PGM_OPT_FIN: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 688 | #define PGM_OPT_FIN_LEN (2+2) |
| 689 | if (opt_len != PGM_OPT_FIN_LEN) { |
| 690 | ND_PRINT((ndo, "[Bad OPT_FIN option, length %u != %u]", |
| 691 | opt_len, PGM_OPT_FIN_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 692 | return; |
| 693 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 694 | bp += 2; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 695 | ND_PRINT((ndo, " FIN")); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 696 | opts_len -= PGM_OPT_FIN_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 697 | break; |
| 698 | |
| 699 | case PGM_OPT_RST: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 700 | #define PGM_OPT_RST_LEN (2+2) |
| 701 | if (opt_len != PGM_OPT_RST_LEN) { |
| 702 | ND_PRINT((ndo, "[Bad OPT_RST option, length %u != %u]", |
| 703 | opt_len, PGM_OPT_RST_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 704 | return; |
| 705 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 706 | bp += 2; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 707 | ND_PRINT((ndo, " RST")); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 708 | opts_len -= PGM_OPT_RST_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 709 | break; |
| 710 | |
| 711 | case PGM_OPT_CR: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 712 | ND_PRINT((ndo, " CR")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 713 | bp += opt_len; |
| 714 | opts_len -= opt_len; |
| 715 | break; |
| 716 | |
| 717 | case PGM_OPT_CRQST: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 718 | #define PGM_OPT_CRQST_LEN (2+2) |
| 719 | if (opt_len != PGM_OPT_CRQST_LEN) { |
| 720 | ND_PRINT((ndo, "[Bad OPT_CRQST option, length %u != %u]", |
| 721 | opt_len, PGM_OPT_CRQST_LEN)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 722 | return; |
| 723 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 724 | bp += 2; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 725 | ND_PRINT((ndo, " CRQST")); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 726 | opts_len -= PGM_OPT_CRQST_LEN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 727 | break; |
| 728 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 729 | case PGM_OPT_PGMCC_DATA: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 730 | #define PGM_OPT_PGMCC_DATA_FIXED_LEN (2+2+4+2+2) |
| 731 | if (opt_len < PGM_OPT_PGMCC_DATA_FIXED_LEN) { |
| 732 | ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u < %u]", |
| 733 | opt_len, PGM_OPT_PGMCC_DATA_FIXED_LEN)); |
| 734 | return; |
| 735 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 736 | bp += 2; |
| 737 | offset = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 738 | bp += 4; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 739 | nla_afnum = EXTRACT_16BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 740 | bp += 2+2; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 741 | switch (nla_afnum) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 742 | case AFNUM_INET: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 743 | if (opt_len != PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(struct in_addr)) { |
| 744 | ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != %u + address size]", |
| 745 | opt_len, PGM_OPT_PGMCC_DATA_FIXED_LEN)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 746 | return; |
| 747 | } |
| 748 | ND_TCHECK2(*bp, sizeof(struct in_addr)); |
| 749 | addrtostr(bp, nla_buf, sizeof(nla_buf)); |
| 750 | bp += sizeof(struct in_addr); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 751 | opts_len -= PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(struct in_addr); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 752 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 753 | case AFNUM_INET6: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 754 | if (opt_len != PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(struct in6_addr)) { |
| 755 | ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != %u + address size]", |
| 756 | opt_len, PGM_OPT_PGMCC_DATA_FIXED_LEN)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 757 | return; |
| 758 | } |
| 759 | ND_TCHECK2(*bp, sizeof(struct in6_addr)); |
| 760 | addrtostr6(bp, nla_buf, sizeof(nla_buf)); |
| 761 | bp += sizeof(struct in6_addr); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 762 | opts_len -= PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(struct in6_addr); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 763 | break; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 764 | default: |
| 765 | goto trunc; |
| 766 | break; |
| 767 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 768 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 769 | ND_PRINT((ndo, " PGMCC DATA %u %s", offset, nla_buf)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 770 | break; |
| 771 | |
| 772 | case PGM_OPT_PGMCC_FEEDBACK: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 773 | #define PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN (2+2+4+2+2) |
| 774 | if (opt_len < PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN) { |
| 775 | ND_PRINT((ndo, "[Bad PGM_OPT_PGMCC_FEEDBACK option, length %u < %u]", |
| 776 | opt_len, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN)); |
| 777 | return; |
| 778 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 779 | bp += 2; |
| 780 | offset = EXTRACT_32BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 781 | bp += 4; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 782 | nla_afnum = EXTRACT_16BITS(bp); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 783 | bp += 2+2; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 784 | switch (nla_afnum) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 785 | case AFNUM_INET: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 786 | if (opt_len != PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(struct in_addr)) { |
| 787 | ND_PRINT((ndo, "[Bad OPT_PGMCC_FEEDBACK option, length %u != %u + address size]", |
| 788 | opt_len, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 789 | return; |
| 790 | } |
| 791 | ND_TCHECK2(*bp, sizeof(struct in_addr)); |
| 792 | addrtostr(bp, nla_buf, sizeof(nla_buf)); |
| 793 | bp += sizeof(struct in_addr); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 794 | opts_len -= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(struct in_addr); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 795 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 796 | case AFNUM_INET6: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 797 | if (opt_len != PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(struct in6_addr)) { |
| 798 | ND_PRINT((ndo, "[Bad OPT_PGMCC_FEEDBACK option, length %u != %u + address size]", |
| 799 | opt_len, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 800 | return; |
| 801 | } |
| 802 | ND_TCHECK2(*bp, sizeof(struct in6_addr)); |
| 803 | addrtostr6(bp, nla_buf, sizeof(nla_buf)); |
| 804 | bp += sizeof(struct in6_addr); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 805 | opts_len -= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(struct in6_addr); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 806 | break; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 807 | default: |
| 808 | goto trunc; |
| 809 | break; |
| 810 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 811 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 812 | ND_PRINT((ndo, " PGMCC FEEDBACK %u %s", offset, nla_buf)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 813 | break; |
| 814 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 815 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 816 | ND_PRINT((ndo, " OPT_%02X [%d] ", opt_type, opt_len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 817 | bp += opt_len; |
| 818 | opts_len -= opt_len; |
| 819 | break; |
| 820 | } |
| 821 | |
| 822 | if (opt_type & PGM_OPT_END) |
| 823 | break; |
| 824 | } |
| 825 | } |
| 826 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 827 | ND_PRINT((ndo, " [%u]", length)); |
| 828 | if (ndo->ndo_packettype == PT_PGM_ZMTP1 && |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 829 | (pgm->pgm_type == PGM_ODATA || pgm->pgm_type == PGM_RDATA)) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 830 | zmtp1_print_datagram(ndo, bp, EXTRACT_16BITS(&pgm->pgm_length)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 831 | |
| 832 | return; |
| 833 | |
| 834 | trunc: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 835 | ND_PRINT((ndo, "[|pgm]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 836 | if (ch != '\0') |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 837 | ND_PRINT((ndo, ">")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 838 | } |