blob: a1a5306b7caf4a7940bc0ee8caf09eaf8139ac76 [file] [log] [blame]
mcrf555c161999-10-07 23:47:09 +00001/*
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
Francois-Xavier Le Bail11d3a012016-08-14 15:42:19 +020022/* \summary: White Board printer */
23
fennerb9ac23c1999-11-21 09:36:43 +000024#ifdef HAVE_CONFIG_H
Guy Harrisfb2479d2018-01-21 12:27:08 -080025#include <config.h>
mcrf555c161999-10-07 23:47:09 +000026#endif
27
Francois-Xavier Le Bail513f7822018-01-20 15:59:49 +010028#include "netdissect-stdinc.h"
mcrf555c161999-10-07 23:47:09 +000029
Francois-Xavier Le Bailc1c3c772015-09-05 23:35:58 +020030#include "netdissect.h"
mcrf555c161999-10-07 23:47:09 +000031#include "addrtoname.h"
guyfcc82f42002-12-11 07:13:49 +000032#include "extract.h"
mcrf555c161999-10-07 23:47:09 +000033
Denis Ovsienko90692fc2014-03-20 14:39:44 +040034
mcrf555c161999-10-07 23:47:09 +000035/* XXX need to add byte-swapping macros! */
guyfcc82f42002-12-11 07:13:49 +000036/* XXX - you mean like the ones in "extract.h"? */
mcrf555c161999-10-07 23:47:09 +000037
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
Guy Harris866358c2019-11-10 20:51:48 -080049#define DOP_ROUNDUP(x) roundup2(x, DOP_ALIGN)
mcrf555c161999-10-07 23:47:09 +000050#define DOP_NEXT(d)\
Guy Harris69cb46a2015-04-26 17:24:42 -070051 ((const struct dophdr *)((const u_char *)(d) + \
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +020052 DOP_ROUNDUP(GET_BE_U_2((d)->dh_len) + sizeof(*(d)))))
mcrf555c161999-10-07 23:47:09 +000053
54/*
55 * Format of the whiteboard packet header.
56 * The transport level header.
57 */
58struct pkt_hdr {
Guy Harrisb0ed96d2017-12-30 18:48:36 -080059 nd_uint32_t ph_src; /* site id of source */
60 nd_uint32_t ph_ts; /* time stamp (for skew computation) */
61 nd_uint16_t ph_version; /* version number */
62 nd_uint8_t ph_type; /* message type */
63 nd_uint8_t ph_flags; /* message flags */
guyfcc82f42002-12-11 07:13:49 +000064};
mcrf555c161999-10-07 23:47:09 +000065
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
guy7a613522001-06-27 05:37:19 +000075#ifdef PF_USER
76#undef PF_USER /* {Digital,Tru64} UNIX define this, alas */
77#endif
78
mcrf555c161999-10-07 23:47:09 +000079/* flags */
80#define PF_USER 0x01 /* hint that packet has interactive data */
81#define PF_VIS 0x02 /* only visible ops wanted */
82
83struct PageID {
Guy Harrisb0ed96d2017-12-30 18:48:36 -080084 nd_uint32_t p_sid; /* session id of initiator */
85 nd_uint32_t p_uid; /* page number */
guyfcc82f42002-12-11 07:13:49 +000086};
mcrf555c161999-10-07 23:47:09 +000087
88struct dophdr {
Guy Harrisb0ed96d2017-12-30 18:48:36 -080089 nd_uint32_t dh_ts; /* sender's timestamp */
90 nd_uint16_t dh_len; /* body length */
91 nd_uint8_t dh_flags;
92 nd_uint8_t dh_type; /* body type */
mcrf555c161999-10-07 23:47:09 +000093 /* body follows */
guyfcc82f42002-12-11 07:13:49 +000094};
mcrf555c161999-10-07 23:47:09 +000095/*
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 */
117struct pkt_dop {
118 struct PageID pd_page; /* page that operations apply to */
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800119 nd_uint32_t pd_sseq; /* start sequence number */
120 nd_uint32_t pd_eseq; /* end sequence number */
mcrf555c161999-10-07 23:47:09 +0000121 /* drawing ops follow */
guyfcc82f42002-12-11 07:13:49 +0000122};
mcrf555c161999-10-07 23:47:09 +0000123
124/*
125 * A repair request.
126 */
127struct pkt_rreq {
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800128 nd_uint32_t pr_id; /* source id of drawops to be repaired */
129 struct PageID pr_page; /* page of drawops */
130 nd_uint32_t pr_sseq; /* start seqno */
131 nd_uint32_t pr_eseq; /* end seqno */
guyfcc82f42002-12-11 07:13:49 +0000132};
mcrf555c161999-10-07 23:47:09 +0000133
134/*
135 * A repair reply.
136 */
137struct pkt_rrep {
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800138 nd_uint32_t pr_id; /* original site id of ops */
mcrf555c161999-10-07 23:47:09 +0000139 struct pkt_dop pr_dop;
140 /* drawing ops follow */
guyfcc82f42002-12-11 07:13:49 +0000141};
mcrf555c161999-10-07 23:47:09 +0000142
143struct id_off {
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800144 nd_uint32_t id;
145 nd_uint32_t off;
guyfcc82f42002-12-11 07:13:49 +0000146};
mcrf555c161999-10-07 23:47:09 +0000147
148struct pgstate {
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800149 nd_uint32_t slot;
mcrf555c161999-10-07 23:47:09 +0000150 struct PageID page;
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800151 nd_uint16_t nid;
152 nd_uint16_t rsvd;
mcrf555c161999-10-07 23:47:09 +0000153 /* seqptr's */
guyfcc82f42002-12-11 07:13:49 +0000154};
mcrf555c161999-10-07 23:47:09 +0000155
156/*
157 * An announcement packet.
158 */
159struct pkt_id {
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800160 nd_uint32_t pi_mslot;
mcrf555c161999-10-07 23:47:09 +0000161 struct PageID pi_mpage; /* current page */
162 struct pgstate pi_ps;
163 /* seqptr's */
164 /* null-terminated site name */
guyfcc82f42002-12-11 07:13:49 +0000165};
mcrf555c161999-10-07 23:47:09 +0000166
167struct pkt_preq {
168 struct PageID pp_page;
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800169 nd_uint32_t pp_low;
170 nd_uint32_t pp_high;
guyfcc82f42002-12-11 07:13:49 +0000171};
mcrf555c161999-10-07 23:47:09 +0000172
173struct pkt_prep {
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800174 nd_uint32_t pp_n; /* size of pageid array */
mcrf555c161999-10-07 23:47:09 +0000175 /* pgstate's follow */
guyfcc82f42002-12-11 07:13:49 +0000176};
mcrf555c161999-10-07 23:47:09 +0000177
178static int
Denis Ovsienko90692fc2014-03-20 14:39:44 +0400179wb_id(netdissect_options *ndo,
180 const struct pkt_id *id, u_int len)
mcrf555c161999-10-07 23:47:09 +0000181{
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800182 u_int i;
mcrf555c161999-10-07 23:47:09 +0000183 const char *cp;
184 const struct id_off *io;
185 char c;
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800186 u_int nid;
mcrf555c161999-10-07 23:47:09 +0000187
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100188 ND_PRINT(" wb-id:");
Francois-Xavier Le Baild526e472018-01-03 21:32:07 +0100189 if (len < sizeof(*id) || !ND_TTEST_SIZE(id))
mcrf555c161999-10-07 23:47:09 +0000190 return (-1);
191 len -= sizeof(*id);
192
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100193 ND_PRINT(" %u/%s:%u (max %u/%s:%u) ",
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200194 GET_BE_U_4(id->pi_ps.slot),
Guy Harris306c2a02020-01-19 19:55:38 -0800195 GET_IPADDR_STRING(id->pi_ps.page.p_sid),
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200196 GET_BE_U_4(id->pi_ps.page.p_uid),
197 GET_BE_U_4(id->pi_mslot),
Guy Harris306c2a02020-01-19 19:55:38 -0800198 GET_IPADDR_STRING(id->pi_mpage.p_sid),
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200199 GET_BE_U_4(id->pi_mpage.p_uid));
mcrf555c161999-10-07 23:47:09 +0000200
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200201 nid = GET_BE_U_2(id->pi_ps.nid);
mcrf555c161999-10-07 23:47:09 +0000202 len -= sizeof(*io) * nid;
Guy Harris69cb46a2015-04-26 17:24:42 -0700203 io = (const struct id_off *)(id + 1);
204 cp = (const char *)(io + nid);
Francois-Xavier Le Bail84ef17a2017-12-11 12:46:51 +0100205 if (ND_TTEST_LEN(cp, len)) {
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100206 ND_PRINT("\"");
Francois-Xavier Le Bail3e3e6d22018-04-30 12:52:10 +0200207 nd_print(ndo, (const u_char *)cp, (const u_char *)cp + len);
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100208 ND_PRINT("\"");
mcrf555c161999-10-07 23:47:09 +0000209 }
210
211 c = '<';
Francois-Xavier Le Baild526e472018-01-03 21:32:07 +0100212 for (i = 0; i < nid && ND_TTEST_SIZE(io); ++io, ++i) {
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100213 ND_PRINT("%c%s:%u",
Guy Harris306c2a02020-01-19 19:55:38 -0800214 c, GET_IPADDR_STRING(io->id), GET_BE_U_4(io->off));
mcrf555c161999-10-07 23:47:09 +0000215 c = ',';
216 }
217 if (i >= nid) {
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100218 ND_PRINT(">");
mcrf555c161999-10-07 23:47:09 +0000219 return (0);
220 }
221 return (-1);
222}
223
224static int
Denis Ovsienko90692fc2014-03-20 14:39:44 +0400225wb_rreq(netdissect_options *ndo,
226 const struct pkt_rreq *rreq, u_int len)
mcrf555c161999-10-07 23:47:09 +0000227{
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100228 ND_PRINT(" wb-rreq:");
Francois-Xavier Le Baild526e472018-01-03 21:32:07 +0100229 if (len < sizeof(*rreq) || !ND_TTEST_SIZE(rreq))
mcrf555c161999-10-07 23:47:09 +0000230 return (-1);
231
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100232 ND_PRINT(" please repair %s %s:%u<%u:%u>",
Guy Harris306c2a02020-01-19 19:55:38 -0800233 GET_IPADDR_STRING(rreq->pr_id),
234 GET_IPADDR_STRING(rreq->pr_page.p_sid),
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200235 GET_BE_U_4(rreq->pr_page.p_uid),
236 GET_BE_U_4(rreq->pr_sseq),
237 GET_BE_U_4(rreq->pr_eseq));
mcrf555c161999-10-07 23:47:09 +0000238 return (0);
239}
240
241static int
Denis Ovsienko90692fc2014-03-20 14:39:44 +0400242wb_preq(netdissect_options *ndo,
243 const struct pkt_preq *preq, u_int len)
mcrf555c161999-10-07 23:47:09 +0000244{
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100245 ND_PRINT(" wb-preq:");
Francois-Xavier Le Baild526e472018-01-03 21:32:07 +0100246 if (len < sizeof(*preq) || !ND_TTEST_SIZE(preq))
mcrf555c161999-10-07 23:47:09 +0000247 return (-1);
248
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100249 ND_PRINT(" need %u/%s:%u",
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200250 GET_BE_U_4(preq->pp_low),
Guy Harris306c2a02020-01-19 19:55:38 -0800251 GET_IPADDR_STRING(preq->pp_page.p_sid),
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200252 GET_BE_U_4(preq->pp_page.p_uid));
mcrf555c161999-10-07 23:47:09 +0000253 return (0);
254}
255
256static int
Denis Ovsienko90692fc2014-03-20 14:39:44 +0400257wb_prep(netdissect_options *ndo,
258 const struct pkt_prep *prep, u_int len)
mcrf555c161999-10-07 23:47:09 +0000259{
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800260 u_int n;
mcrf555c161999-10-07 23:47:09 +0000261 const struct pgstate *ps;
Denis Ovsienko90692fc2014-03-20 14:39:44 +0400262 const u_char *ep = ndo->ndo_snapend;
mcrf555c161999-10-07 23:47:09 +0000263
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100264 ND_PRINT(" wb-prep:");
Francois-Xavier Le Baild526e472018-01-03 21:32:07 +0100265 if (len < sizeof(*prep) || !ND_TTEST_SIZE(prep))
mcrf555c161999-10-07 23:47:09 +0000266 return (-1);
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200267 n = GET_BE_U_4(prep->pp_n);
mcrf555c161999-10-07 23:47:09 +0000268 ps = (const struct pgstate *)(prep + 1);
Francois-Xavier Le Baild526e472018-01-03 21:32:07 +0100269 while (n != 0 && ND_TTEST_SIZE(ps)) {
mcrf555c161999-10-07 23:47:09 +0000270 const struct id_off *io, *ie;
271 char c = '<';
272
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100273 ND_PRINT(" %u/%s:%u",
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200274 GET_BE_U_4(ps->slot),
Guy Harris306c2a02020-01-19 19:55:38 -0800275 GET_IPADDR_STRING(ps->page.p_sid),
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200276 GET_BE_U_4(ps->page.p_uid));
Guy Harris69cb46a2015-04-26 17:24:42 -0700277 io = (const struct id_off *)(ps + 1);
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200278 for (ie = io + GET_U_1(ps->nid); io < ie && ND_TTEST_SIZE(io); ++io) {
Guy Harris306c2a02020-01-19 19:55:38 -0800279 ND_PRINT("%c%s:%u", c, GET_IPADDR_STRING(io->id),
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200280 GET_BE_U_4(io->off));
mcrf555c161999-10-07 23:47:09 +0000281 c = ',';
282 }
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100283 ND_PRINT(">");
Guy Harris69cb46a2015-04-26 17:24:42 -0700284 ps = (const struct pgstate *)io;
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800285 n--;
mcrf555c161999-10-07 23:47:09 +0000286 }
Guy Harris69cb46a2015-04-26 17:24:42 -0700287 return ((const u_char *)ps <= ep? 0 : -1);
mcrf555c161999-10-07 23:47:09 +0000288}
289
290
Denis Ovsienkod8b3af52013-12-19 14:05:59 +0400291static const char *dopstr[] = {
mcrf555c161999-10-07 23:47:09 +0000292 "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
310static int
Guy Harris3a3ec262014-10-19 14:45:20 -0700311wb_dops(netdissect_options *ndo, const struct pkt_dop *dop,
312 uint32_t ss, uint32_t es)
mcrf555c161999-10-07 23:47:09 +0000313{
Guy Harris3a3ec262014-10-19 14:45:20 -0700314 const struct dophdr *dh = (const struct dophdr *)((const u_char *)dop + sizeof(*dop));
315
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100316 ND_PRINT(" <");
mcrf555c161999-10-07 23:47:09 +0000317 for ( ; ss <= es; ++ss) {
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800318 u_int t;
Guy Harris3a3ec262014-10-19 14:45:20 -0700319
Francois-Xavier Le Baild526e472018-01-03 21:32:07 +0100320 if (!ND_TTEST_SIZE(dh)) {
Francois-Xavier Le Bailba8936b2018-05-02 17:15:04 +0200321 nd_print_trunc(ndo);
Guy Harris3a3ec262014-10-19 14:45:20 -0700322 break;
323 }
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200324 t = GET_U_1(dh->dh_type);
mcrf555c161999-10-07 23:47:09 +0000325
326 if (t > DT_MAXTYPE)
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100327 ND_PRINT(" dop-%u!", t);
mcrf555c161999-10-07 23:47:09 +0000328 else {
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100329 ND_PRINT(" %s", dopstr[t]);
mcrf555c161999-10-07 23:47:09 +0000330 if (t == DT_SKIP || t == DT_HOLE) {
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200331 uint32_t ts = GET_BE_U_4(dh->dh_ts);
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100332 ND_PRINT("%u", ts - ss + 1);
mcrf555c161999-10-07 23:47:09 +0000333 if (ss > ts || ts > es) {
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100334 ND_PRINT("[|]");
mcrf555c161999-10-07 23:47:09 +0000335 if (ts < ss)
336 return (0);
337 }
338 ss = ts;
339 }
340 }
341 dh = DOP_NEXT(dh);
mcrf555c161999-10-07 23:47:09 +0000342 }
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100343 ND_PRINT(" >");
mcrf555c161999-10-07 23:47:09 +0000344 return (0);
345}
346
347static int
Denis Ovsienko90692fc2014-03-20 14:39:44 +0400348wb_rrep(netdissect_options *ndo,
349 const struct pkt_rrep *rrep, u_int len)
mcrf555c161999-10-07 23:47:09 +0000350{
351 const struct pkt_dop *dop = &rrep->pr_dop;
352
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100353 ND_PRINT(" wb-rrep:");
Francois-Xavier Le Baild526e472018-01-03 21:32:07 +0100354 if (len < sizeof(*rrep) || !ND_TTEST_SIZE(rrep))
mcrf555c161999-10-07 23:47:09 +0000355 return (-1);
356 len -= sizeof(*rrep);
357
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100358 ND_PRINT(" for %s %s:%u<%u:%u>",
Guy Harris306c2a02020-01-19 19:55:38 -0800359 GET_IPADDR_STRING(rrep->pr_id),
360 GET_IPADDR_STRING(dop->pd_page.p_sid),
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200361 GET_BE_U_4(dop->pd_page.p_uid),
362 GET_BE_U_4(dop->pd_sseq),
363 GET_BE_U_4(dop->pd_eseq));
mcrf555c161999-10-07 23:47:09 +0000364
Denis Ovsienko90692fc2014-03-20 14:39:44 +0400365 if (ndo->ndo_vflag)
Guy Harris3a3ec262014-10-19 14:45:20 -0700366 return (wb_dops(ndo, dop,
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200367 GET_BE_U_4(dop->pd_sseq),
368 GET_BE_U_4(dop->pd_eseq)));
mcrf555c161999-10-07 23:47:09 +0000369 return (0);
370}
371
372static int
Denis Ovsienko90692fc2014-03-20 14:39:44 +0400373wb_drawop(netdissect_options *ndo,
374 const struct pkt_dop *dop, u_int len)
mcrf555c161999-10-07 23:47:09 +0000375{
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100376 ND_PRINT(" wb-dop:");
Francois-Xavier Le Baild526e472018-01-03 21:32:07 +0100377 if (len < sizeof(*dop) || !ND_TTEST_SIZE(dop))
mcrf555c161999-10-07 23:47:09 +0000378 return (-1);
379 len -= sizeof(*dop);
380
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100381 ND_PRINT(" %s:%u<%u:%u>",
Guy Harris306c2a02020-01-19 19:55:38 -0800382 GET_IPADDR_STRING(dop->pd_page.p_sid),
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200383 GET_BE_U_4(dop->pd_page.p_uid),
384 GET_BE_U_4(dop->pd_sseq),
385 GET_BE_U_4(dop->pd_eseq));
mcrf555c161999-10-07 23:47:09 +0000386
Denis Ovsienko90692fc2014-03-20 14:39:44 +0400387 if (ndo->ndo_vflag)
Guy Harris3a3ec262014-10-19 14:45:20 -0700388 return (wb_dops(ndo, dop,
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200389 GET_BE_U_4(dop->pd_sseq),
390 GET_BE_U_4(dop->pd_eseq)));
mcrf555c161999-10-07 23:47:09 +0000391 return (0);
392}
393
394/*
395 * Print whiteboard multicast packets.
396 */
397void
Denis Ovsienko90692fc2014-03-20 14:39:44 +0400398wb_print(netdissect_options *ndo,
Francois-Xavier Le Bailb01a3f22018-01-02 19:08:01 +0100399 const u_char *hdr, u_int len)
mcrf555c161999-10-07 23:47:09 +0000400{
Francois-Xavier Le Bail5cea2702017-12-13 19:17:47 +0100401 const struct pkt_hdr *ph;
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800402 uint8_t type;
mcrf555c161999-10-07 23:47:09 +0000403
Francois-Xavier Le Bail546558e2018-03-14 16:54:17 +0100404 ndo->ndo_protocol = "wb";
mcrf555c161999-10-07 23:47:09 +0000405 ph = (const struct pkt_hdr *)hdr;
Francois-Xavier Le Baild526e472018-01-03 21:32:07 +0100406 if (len < sizeof(*ph) || !ND_TTEST_SIZE(ph)) {
Francois-Xavier Le Bailba8936b2018-05-02 17:15:04 +0200407 nd_print_trunc(ndo);
mcrf555c161999-10-07 23:47:09 +0000408 return;
409 }
410 len -= sizeof(*ph);
411
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200412 if (GET_U_1(ph->ph_flags))
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100413 ND_PRINT("*");
Francois-Xavier Le Bailee68aa32018-06-16 17:23:21 +0200414 type = GET_U_1(ph->ph_type);
Guy Harrisb0ed96d2017-12-30 18:48:36 -0800415 switch (type) {
mcrf555c161999-10-07 23:47:09 +0000416
417 case PT_KILL:
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100418 ND_PRINT(" wb-kill");
mcrf555c161999-10-07 23:47:09 +0000419 return;
420
421 case PT_ID:
Guy Harris69cb46a2015-04-26 17:24:42 -0700422 if (wb_id(ndo, (const struct pkt_id *)(ph + 1), len) >= 0)
mcrf555c161999-10-07 23:47:09 +0000423 return;
Francois-Xavier Le Bailba8936b2018-05-02 17:15:04 +0200424 nd_print_trunc(ndo);
mcrf555c161999-10-07 23:47:09 +0000425 break;
426
427 case PT_RREQ:
Guy Harris69cb46a2015-04-26 17:24:42 -0700428 if (wb_rreq(ndo, (const struct pkt_rreq *)(ph + 1), len) >= 0)
mcrf555c161999-10-07 23:47:09 +0000429 return;
Francois-Xavier Le Bailba8936b2018-05-02 17:15:04 +0200430 nd_print_trunc(ndo);
mcrf555c161999-10-07 23:47:09 +0000431 break;
432
433 case PT_RREP:
Guy Harris69cb46a2015-04-26 17:24:42 -0700434 if (wb_rrep(ndo, (const struct pkt_rrep *)(ph + 1), len) >= 0)
mcrf555c161999-10-07 23:47:09 +0000435 return;
Francois-Xavier Le Bailba8936b2018-05-02 17:15:04 +0200436 nd_print_trunc(ndo);
mcrf555c161999-10-07 23:47:09 +0000437 break;
438
439 case PT_DRAWOP:
Guy Harris69cb46a2015-04-26 17:24:42 -0700440 if (wb_drawop(ndo, (const struct pkt_dop *)(ph + 1), len) >= 0)
mcrf555c161999-10-07 23:47:09 +0000441 return;
Francois-Xavier Le Bailba8936b2018-05-02 17:15:04 +0200442 nd_print_trunc(ndo);
mcrf555c161999-10-07 23:47:09 +0000443 break;
444
445 case PT_PREQ:
Guy Harris69cb46a2015-04-26 17:24:42 -0700446 if (wb_preq(ndo, (const struct pkt_preq *)(ph + 1), len) >= 0)
mcrf555c161999-10-07 23:47:09 +0000447 return;
Francois-Xavier Le Bailba8936b2018-05-02 17:15:04 +0200448 nd_print_trunc(ndo);
mcrf555c161999-10-07 23:47:09 +0000449 break;
450
451 case PT_PREP:
Guy Harris69cb46a2015-04-26 17:24:42 -0700452 if (wb_prep(ndo, (const struct pkt_prep *)(ph + 1), len) >= 0)
mcrf555c161999-10-07 23:47:09 +0000453 return;
Francois-Xavier Le Bailba8936b2018-05-02 17:15:04 +0200454 nd_print_trunc(ndo);
mcrf555c161999-10-07 23:47:09 +0000455 break;
456
457 default:
Francois-Xavier Le Baile2982e72018-01-07 11:47:30 +0100458 ND_PRINT(" wb-%u!", type);
mcrf555c161999-10-07 23:47:09 +0000459 return;
460 }
461}