| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1993, 1994, 1995, 1996 |
| 3 | * The Regents of the University of California. All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that: (1) source code distributions |
| 7 | * retain the above copyright notice and this paragraph in its entirety, (2) |
| 8 | * distributions including binary code include the above copyright notice and |
| 9 | * this paragraph in its entirety in the documentation or other materials |
| 10 | * provided with the distribution, and (3) all advertising materials mentioning |
| 11 | * features or use of this software display the following acknowledgement: |
| 12 | * ``This product includes software developed by the University of California, |
| 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of |
| 14 | * the University nor the names of its contributors may be used to endorse |
| 15 | * or promote products derived from this software without specific prior |
| 16 | * written permission. |
| 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 20 | */ |
| 21 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 22 | #define NETDISSECT_REWORKED |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include "config.h" |
| 25 | #endif |
| 26 | |
| 27 | #include <tcpdump-stdinc.h> |
| 28 | |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 29 | #include "interface.h" |
| 30 | #include "addrtoname.h" |
| 31 | #include "extract.h" |
| 32 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 33 | static const char tstr[] = "[|wb]"; |
| 34 | |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 35 | /* XXX need to add byte-swapping macros! */ |
| 36 | /* XXX - you mean like the ones in "extract.h"? */ |
| 37 | |
| 38 | /* |
| 39 | * Largest packet size. Everything should fit within this space. |
| 40 | * For instance, multiline objects are sent piecewise. |
| 41 | */ |
| 42 | #define MAXFRAMESIZE 1024 |
| 43 | |
| 44 | /* |
| 45 | * Multiple drawing ops can be sent in one packet. Each one starts on a |
| 46 | * an even multiple of DOP_ALIGN bytes, which must be a power of two. |
| 47 | */ |
| 48 | #define DOP_ALIGN 4 |
| 49 | #define DOP_ROUNDUP(x) ((((int)(x)) + (DOP_ALIGN - 1)) & ~(DOP_ALIGN - 1)) |
| 50 | #define DOP_NEXT(d)\ |
| 51 | ((struct dophdr *)((u_char *)(d) + \ |
| 52 | DOP_ROUNDUP(EXTRACT_16BITS(&(d)->dh_len) + sizeof(*(d))))) |
| 53 | |
| 54 | /* |
| 55 | * Format of the whiteboard packet header. |
| 56 | * The transport level header. |
| 57 | */ |
| 58 | struct pkt_hdr { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 59 | uint32_t ph_src; /* site id of source */ |
| 60 | uint32_t ph_ts; /* time stamp (for skew computation) */ |
| 61 | uint16_t ph_version; /* version number */ |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 62 | u_char ph_type; /* message type */ |
| 63 | u_char ph_flags; /* message flags */ |
| 64 | }; |
| 65 | |
| 66 | /* Packet types */ |
| 67 | #define PT_DRAWOP 0 /* drawing operation */ |
| 68 | #define PT_ID 1 /* announcement packet */ |
| 69 | #define PT_RREQ 2 /* repair request */ |
| 70 | #define PT_RREP 3 /* repair reply */ |
| 71 | #define PT_KILL 4 /* terminate participation */ |
| 72 | #define PT_PREQ 5 /* page vector request */ |
| 73 | #define PT_PREP 7 /* page vector reply */ |
| 74 | |
| 75 | #ifdef PF_USER |
| 76 | #undef PF_USER /* {Digital,Tru64} UNIX define this, alas */ |
| 77 | #endif |
| 78 | |
| 79 | /* flags */ |
| 80 | #define PF_USER 0x01 /* hint that packet has interactive data */ |
| 81 | #define PF_VIS 0x02 /* only visible ops wanted */ |
| 82 | |
| 83 | struct PageID { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 84 | uint32_t p_sid; /* session id of initiator */ |
| 85 | uint32_t p_uid; /* page number */ |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | struct dophdr { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 89 | uint32_t dh_ts; /* sender's timestamp */ |
| 90 | uint16_t dh_len; /* body length */ |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 91 | u_char dh_flags; |
| 92 | u_char dh_type; /* body type */ |
| 93 | /* body follows */ |
| 94 | }; |
| 95 | /* |
| 96 | * Drawing op sub-types. |
| 97 | */ |
| 98 | #define DT_RECT 2 |
| 99 | #define DT_LINE 3 |
| 100 | #define DT_ML 4 |
| 101 | #define DT_DEL 5 |
| 102 | #define DT_XFORM 6 |
| 103 | #define DT_ELL 7 |
| 104 | #define DT_CHAR 8 |
| 105 | #define DT_STR 9 |
| 106 | #define DT_NOP 10 |
| 107 | #define DT_PSCODE 11 |
| 108 | #define DT_PSCOMP 12 |
| 109 | #define DT_REF 13 |
| 110 | #define DT_SKIP 14 |
| 111 | #define DT_HOLE 15 |
| 112 | #define DT_MAXTYPE 15 |
| 113 | |
| 114 | /* |
| 115 | * A drawing operation. |
| 116 | */ |
| 117 | struct pkt_dop { |
| 118 | struct PageID pd_page; /* page that operations apply to */ |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 119 | uint32_t pd_sseq; /* start sequence number */ |
| 120 | uint32_t pd_eseq; /* end sequence number */ |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 121 | /* drawing ops follow */ |
| 122 | }; |
| 123 | |
| 124 | /* |
| 125 | * A repair request. |
| 126 | */ |
| 127 | struct pkt_rreq { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 128 | uint32_t pr_id; /* source id of drawops to be repaired */ |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 129 | struct PageID pr_page; /* page of drawops */ |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 130 | uint32_t pr_sseq; /* start seqno */ |
| 131 | uint32_t pr_eseq; /* end seqno */ |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | /* |
| 135 | * A repair reply. |
| 136 | */ |
| 137 | struct pkt_rrep { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 138 | uint32_t pr_id; /* original site id of ops */ |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 139 | struct pkt_dop pr_dop; |
| 140 | /* drawing ops follow */ |
| 141 | }; |
| 142 | |
| 143 | struct id_off { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 144 | uint32_t id; |
| 145 | uint32_t off; |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | struct pgstate { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 149 | uint32_t slot; |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 150 | struct PageID page; |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 151 | uint16_t nid; |
| 152 | uint16_t rsvd; |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 153 | /* seqptr's */ |
| 154 | }; |
| 155 | |
| 156 | /* |
| 157 | * An announcement packet. |
| 158 | */ |
| 159 | struct pkt_id { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 160 | uint32_t pi_mslot; |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 161 | struct PageID pi_mpage; /* current page */ |
| 162 | struct pgstate pi_ps; |
| 163 | /* seqptr's */ |
| 164 | /* null-terminated site name */ |
| 165 | }; |
| 166 | |
| 167 | struct pkt_preq { |
| 168 | struct PageID pp_page; |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 169 | uint32_t pp_low; |
| 170 | uint32_t pp_high; |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 171 | }; |
| 172 | |
| 173 | struct pkt_prep { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 174 | uint32_t pp_n; /* size of pageid array */ |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 175 | /* pgstate's follow */ |
| 176 | }; |
| 177 | |
| 178 | static int |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 179 | wb_id(netdissect_options *ndo, |
| 180 | const struct pkt_id *id, u_int len) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 181 | { |
| 182 | int i; |
| 183 | const char *cp; |
| 184 | const struct id_off *io; |
| 185 | char c; |
| 186 | int nid; |
| 187 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 188 | ND_PRINT((ndo, " wb-id:")); |
| 189 | if (len < sizeof(*id) || !ND_TTEST(*id)) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 190 | return (-1); |
| 191 | len -= sizeof(*id); |
| 192 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 193 | ND_PRINT((ndo, " %u/%s:%u (max %u/%s:%u) ", |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 194 | EXTRACT_32BITS(&id->pi_ps.slot), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 195 | ipaddr_string(ndo, &id->pi_ps.page.p_sid), |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 196 | EXTRACT_32BITS(&id->pi_ps.page.p_uid), |
| 197 | EXTRACT_32BITS(&id->pi_mslot), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 198 | ipaddr_string(ndo, &id->pi_mpage.p_sid), |
| 199 | EXTRACT_32BITS(&id->pi_mpage.p_uid))); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 200 | |
| 201 | nid = EXTRACT_16BITS(&id->pi_ps.nid); |
| 202 | len -= sizeof(*io) * nid; |
| 203 | io = (struct id_off *)(id + 1); |
| 204 | cp = (char *)(io + nid); |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 205 | if (ND_TTEST2(cp, len)) { |
| 206 | ND_PRINT((ndo, "\"")); |
| 207 | fn_print(ndo, (u_char *)cp, (u_char *)cp + len); |
| 208 | ND_PRINT((ndo, "\"")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | c = '<'; |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 212 | for (i = 0; i < nid && ND_TTEST(*io); ++io, ++i) { |
| 213 | ND_PRINT((ndo, "%c%s:%u", |
| 214 | c, ipaddr_string(ndo, &io->id), EXTRACT_32BITS(&io->off))); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 215 | c = ','; |
| 216 | } |
| 217 | if (i >= nid) { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 218 | ND_PRINT((ndo, ">")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 219 | return (0); |
| 220 | } |
| 221 | return (-1); |
| 222 | } |
| 223 | |
| 224 | static int |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 225 | wb_rreq(netdissect_options *ndo, |
| 226 | const struct pkt_rreq *rreq, u_int len) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 227 | { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 228 | ND_PRINT((ndo, " wb-rreq:")); |
| 229 | if (len < sizeof(*rreq) || !ND_TTEST(*rreq)) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 230 | return (-1); |
| 231 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 232 | ND_PRINT((ndo, " please repair %s %s:%u<%u:%u>", |
| 233 | ipaddr_string(ndo, &rreq->pr_id), |
| 234 | ipaddr_string(ndo, &rreq->pr_page.p_sid), |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 235 | EXTRACT_32BITS(&rreq->pr_page.p_uid), |
| 236 | EXTRACT_32BITS(&rreq->pr_sseq), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 237 | EXTRACT_32BITS(&rreq->pr_eseq))); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 238 | return (0); |
| 239 | } |
| 240 | |
| 241 | static int |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 242 | wb_preq(netdissect_options *ndo, |
| 243 | const struct pkt_preq *preq, u_int len) |
| 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, " wb-preq:")); |
| 246 | if (len < sizeof(*preq) || !ND_TTEST(*preq)) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 247 | return (-1); |
| 248 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 249 | ND_PRINT((ndo, " need %u/%s:%u", |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 250 | EXTRACT_32BITS(&preq->pp_low), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 251 | ipaddr_string(ndo, &preq->pp_page.p_sid), |
| 252 | EXTRACT_32BITS(&preq->pp_page.p_uid))); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 253 | return (0); |
| 254 | } |
| 255 | |
| 256 | static int |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 257 | wb_prep(netdissect_options *ndo, |
| 258 | const struct pkt_prep *prep, u_int len) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 259 | { |
| 260 | int n; |
| 261 | const struct pgstate *ps; |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 262 | const u_char *ep = ndo->ndo_snapend; |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 263 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 264 | ND_PRINT((ndo, " wb-prep:")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 265 | if (len < sizeof(*prep)) { |
| 266 | return (-1); |
| 267 | } |
| 268 | n = EXTRACT_32BITS(&prep->pp_n); |
| 269 | ps = (const struct pgstate *)(prep + 1); |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 270 | while (--n >= 0 && ND_TTEST(*ps)) { |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 271 | const struct id_off *io, *ie; |
| 272 | char c = '<'; |
| 273 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 274 | ND_PRINT((ndo, " %u/%s:%u", |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 275 | EXTRACT_32BITS(&ps->slot), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 276 | ipaddr_string(ndo, &ps->page.p_sid), |
| 277 | EXTRACT_32BITS(&ps->page.p_uid))); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 278 | io = (struct id_off *)(ps + 1); |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 279 | for (ie = io + ps->nid; io < ie && ND_TTEST(*io); ++io) { |
| 280 | ND_PRINT((ndo, "%c%s:%u", c, ipaddr_string(ndo, &io->id), |
| 281 | EXTRACT_32BITS(&io->off))); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 282 | c = ','; |
| 283 | } |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 284 | ND_PRINT((ndo, ">")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 285 | ps = (struct pgstate *)io; |
| 286 | } |
| 287 | return ((u_char *)ps <= ep? 0 : -1); |
| 288 | } |
| 289 | |
| 290 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 291 | static const char *dopstr[] = { |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 292 | "dop-0!", |
| 293 | "dop-1!", |
| 294 | "RECT", |
| 295 | "LINE", |
| 296 | "ML", |
| 297 | "DEL", |
| 298 | "XFORM", |
| 299 | "ELL", |
| 300 | "CHAR", |
| 301 | "STR", |
| 302 | "NOP", |
| 303 | "PSCODE", |
| 304 | "PSCOMP", |
| 305 | "REF", |
| 306 | "SKIP", |
| 307 | "HOLE", |
| 308 | }; |
| 309 | |
| 310 | static int |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 311 | wb_dops(netdissect_options *ndo, const struct pkt_dop *dop, |
| 312 | uint32_t ss, uint32_t es) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 313 | { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 314 | const struct dophdr *dh = (const struct dophdr *)((const u_char *)dop + sizeof(*dop)); |
| 315 | |
| 316 | ND_PRINT((ndo, " <")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 317 | for ( ; ss <= es; ++ss) { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 318 | int t; |
| 319 | |
| 320 | if (!ND_TTEST(*dh)) { |
| 321 | ND_PRINT((ndo, "%s", tstr)); |
| 322 | break; |
| 323 | } |
| 324 | t = dh->dh_type; |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 325 | |
| 326 | if (t > DT_MAXTYPE) |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 327 | ND_PRINT((ndo, " dop-%d!", t)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 328 | else { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 329 | ND_PRINT((ndo, " %s", dopstr[t])); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 330 | if (t == DT_SKIP || t == DT_HOLE) { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 331 | uint32_t ts = EXTRACT_32BITS(&dh->dh_ts); |
| 332 | ND_PRINT((ndo, "%d", ts - ss + 1)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 333 | if (ss > ts || ts > es) { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 334 | ND_PRINT((ndo, "[|]")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 335 | if (ts < ss) |
| 336 | return (0); |
| 337 | } |
| 338 | ss = ts; |
| 339 | } |
| 340 | } |
| 341 | dh = DOP_NEXT(dh); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 342 | } |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 343 | ND_PRINT((ndo, " >")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 344 | return (0); |
| 345 | } |
| 346 | |
| 347 | static int |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 348 | wb_rrep(netdissect_options *ndo, |
| 349 | const struct pkt_rrep *rrep, u_int len) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 350 | { |
| 351 | const struct pkt_dop *dop = &rrep->pr_dop; |
| 352 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 353 | ND_PRINT((ndo, " wb-rrep:")); |
| 354 | if (len < sizeof(*rrep) || !ND_TTEST(*rrep)) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 355 | return (-1); |
| 356 | len -= sizeof(*rrep); |
| 357 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 358 | ND_PRINT((ndo, " for %s %s:%u<%u:%u>", |
| 359 | ipaddr_string(ndo, &rrep->pr_id), |
| 360 | ipaddr_string(ndo, &dop->pd_page.p_sid), |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 361 | EXTRACT_32BITS(&dop->pd_page.p_uid), |
| 362 | EXTRACT_32BITS(&dop->pd_sseq), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 363 | EXTRACT_32BITS(&dop->pd_eseq))); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 364 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 365 | if (ndo->ndo_vflag) |
| 366 | return (wb_dops(ndo, dop, |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 367 | EXTRACT_32BITS(&dop->pd_sseq), |
| 368 | EXTRACT_32BITS(&dop->pd_eseq))); |
| 369 | return (0); |
| 370 | } |
| 371 | |
| 372 | static int |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 373 | wb_drawop(netdissect_options *ndo, |
| 374 | const struct pkt_dop *dop, u_int len) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 375 | { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 376 | ND_PRINT((ndo, " wb-dop:")); |
| 377 | if (len < sizeof(*dop) || !ND_TTEST(*dop)) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 378 | return (-1); |
| 379 | len -= sizeof(*dop); |
| 380 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 381 | ND_PRINT((ndo, " %s:%u<%u:%u>", |
| 382 | ipaddr_string(ndo, &dop->pd_page.p_sid), |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 383 | EXTRACT_32BITS(&dop->pd_page.p_uid), |
| 384 | EXTRACT_32BITS(&dop->pd_sseq), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 385 | EXTRACT_32BITS(&dop->pd_eseq))); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 386 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 387 | if (ndo->ndo_vflag) |
| 388 | return (wb_dops(ndo, dop, |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 389 | EXTRACT_32BITS(&dop->pd_sseq), |
| 390 | EXTRACT_32BITS(&dop->pd_eseq))); |
| 391 | return (0); |
| 392 | } |
| 393 | |
| 394 | /* |
| 395 | * Print whiteboard multicast packets. |
| 396 | */ |
| 397 | void |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 398 | wb_print(netdissect_options *ndo, |
| 399 | register const void *hdr, register u_int len) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 400 | { |
| 401 | register const struct pkt_hdr *ph; |
| 402 | |
| 403 | ph = (const struct pkt_hdr *)hdr; |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 404 | if (len < sizeof(*ph) || !ND_TTEST(*ph)) { |
| 405 | ND_PRINT((ndo, "%s", tstr)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 406 | return; |
| 407 | } |
| 408 | len -= sizeof(*ph); |
| 409 | |
| 410 | if (ph->ph_flags) |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 411 | ND_PRINT((ndo, "*")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 412 | switch (ph->ph_type) { |
| 413 | |
| 414 | case PT_KILL: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 415 | ND_PRINT((ndo, " wb-kill")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 416 | return; |
| 417 | |
| 418 | case PT_ID: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 419 | if (wb_id(ndo, (struct pkt_id *)(ph + 1), len) >= 0) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 420 | return; |
| 421 | break; |
| 422 | |
| 423 | case PT_RREQ: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 424 | if (wb_rreq(ndo, (struct pkt_rreq *)(ph + 1), len) >= 0) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 425 | return; |
| 426 | break; |
| 427 | |
| 428 | case PT_RREP: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 429 | if (wb_rrep(ndo, (struct pkt_rrep *)(ph + 1), len) >= 0) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 430 | return; |
| 431 | break; |
| 432 | |
| 433 | case PT_DRAWOP: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 434 | if (wb_drawop(ndo, (struct pkt_dop *)(ph + 1), len) >= 0) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 435 | return; |
| 436 | break; |
| 437 | |
| 438 | case PT_PREQ: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 439 | if (wb_preq(ndo, (struct pkt_preq *)(ph + 1), len) >= 0) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 440 | return; |
| 441 | break; |
| 442 | |
| 443 | case PT_PREP: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 444 | if (wb_prep(ndo, (struct pkt_prep *)(ph + 1), len) >= 0) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 445 | return; |
| 446 | break; |
| 447 | |
| 448 | default: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame^] | 449 | ND_PRINT((ndo, " wb-%d!", ph->ph_type)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 450 | return; |
| 451 | } |
| 452 | } |