]> The Tcpdump Group git mirrors - tcpdump/blob - print-rx.c
RX: Fix 168 warnings as "declaration of 'x' shadows a previous local"
[tcpdump] / print-rx.c
1 /*
2 * Copyright: (c) 2000 United States Government as represented by the
3 * Secretary of the Navy. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 * 3. The names of the authors may not be used to endorse or promote
16 * products derived from this software without specific prior
17 * written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 */
23 /*
24 * This code unmangles RX packets. RX is the mutant form of RPC that AFS
25 * uses to communicate between clients and servers.
26 *
27 * In this code, I mainly concern myself with decoding the AFS calls, not
28 * with the guts of RX, per se.
29 *
30 * Bah. If I never look at rx_packet.h again, it will be too soon.
31 *
32 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
33 */
34
35 #ifdef HAVE_CONFIG_H
36 #include "config.h"
37 #endif
38
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <tcpdump-stdinc.h>
43
44 #include "interface.h"
45 #include "addrtoname.h"
46 #include "extract.h"
47
48 #include "ip.h"
49
50 #define FS_RX_PORT 7000
51 #define CB_RX_PORT 7001
52 #define PROT_RX_PORT 7002
53 #define VLDB_RX_PORT 7003
54 #define KAUTH_RX_PORT 7004
55 #define VOL_RX_PORT 7005
56 #define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
57 #define BOS_RX_PORT 7007
58
59 #define AFSNAMEMAX 256
60 #define AFSOPAQUEMAX 1024
61 #define PRNAMEMAX 64
62 #define VLNAMEMAX 65
63 #define KANAMEMAX 64
64 #define BOSNAMEMAX 256
65
66 #define PRSFS_READ 1 /* Read files */
67 #define PRSFS_WRITE 2 /* Write files */
68 #define PRSFS_INSERT 4 /* Insert files into a directory */
69 #define PRSFS_LOOKUP 8 /* Lookup files into a directory */
70 #define PRSFS_DELETE 16 /* Delete files */
71 #define PRSFS_LOCK 32 /* Lock files */
72 #define PRSFS_ADMINISTER 64 /* Change ACL's */
73
74 struct rx_header {
75 uint32_t epoch;
76 uint32_t cid;
77 uint32_t callNumber;
78 uint32_t seq;
79 uint32_t serial;
80 uint8_t type;
81 #define RX_PACKET_TYPE_DATA 1
82 #define RX_PACKET_TYPE_ACK 2
83 #define RX_PACKET_TYPE_BUSY 3
84 #define RX_PACKET_TYPE_ABORT 4
85 #define RX_PACKET_TYPE_ACKALL 5
86 #define RX_PACKET_TYPE_CHALLENGE 6
87 #define RX_PACKET_TYPE_RESPONSE 7
88 #define RX_PACKET_TYPE_DEBUG 8
89 #define RX_PACKET_TYPE_PARAMS 9
90 #define RX_PACKET_TYPE_VERSION 13
91 uint8_t flags;
92 #define RX_CLIENT_INITIATED 1
93 #define RX_REQUEST_ACK 2
94 #define RX_LAST_PACKET 4
95 #define RX_MORE_PACKETS 8
96 #define RX_FREE_PACKET 16
97 #define RX_SLOW_START_OK 32
98 #define RX_JUMBO_PACKET 32
99 uint8_t userStatus;
100 uint8_t securityIndex;
101 uint16_t spare; /* How clever: even though the AFS */
102 uint16_t serviceId; /* header files indicate that the */
103 }; /* serviceId is first, it's really */
104 /* encoded _after_ the spare field */
105 /* I wasted a day figuring that out! */
106
107 #define NUM_RX_FLAGS 7
108
109 #define RX_MAXACKS 255
110
111 struct rx_ackPacket {
112 uint16_t bufferSpace; /* Number of packet buffers available */
113 uint16_t maxSkew; /* Max diff between ack'd packet and */
114 /* highest packet received */
115 uint32_t firstPacket; /* The first packet in ack list */
116 uint32_t previousPacket; /* Previous packet recv'd (obsolete) */
117 uint32_t serial; /* # of packet that prompted the ack */
118 uint8_t reason; /* Reason for acknowledgement */
119 uint8_t nAcks; /* Number of acknowledgements */
120 uint8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */
121 };
122
123 /*
124 * Values for the acks array
125 */
126
127 #define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
128 #define RX_ACK_TYPE_ACK 1 /* I have this packet */
129
130 static const struct tok rx_types[] = {
131 { RX_PACKET_TYPE_DATA, "data" },
132 { RX_PACKET_TYPE_ACK, "ack" },
133 { RX_PACKET_TYPE_BUSY, "busy" },
134 { RX_PACKET_TYPE_ABORT, "abort" },
135 { RX_PACKET_TYPE_ACKALL, "ackall" },
136 { RX_PACKET_TYPE_CHALLENGE, "challenge" },
137 { RX_PACKET_TYPE_RESPONSE, "response" },
138 { RX_PACKET_TYPE_DEBUG, "debug" },
139 { RX_PACKET_TYPE_PARAMS, "params" },
140 { RX_PACKET_TYPE_VERSION, "version" },
141 { 0, NULL },
142 };
143
144 static const struct double_tok {
145 int flag; /* Rx flag */
146 int packetType; /* Packet type */
147 const char *s; /* Flag string */
148 } rx_flags[] = {
149 { RX_CLIENT_INITIATED, 0, "client-init" },
150 { RX_REQUEST_ACK, 0, "req-ack" },
151 { RX_LAST_PACKET, 0, "last-pckt" },
152 { RX_MORE_PACKETS, 0, "more-pckts" },
153 { RX_FREE_PACKET, 0, "free-pckt" },
154 { RX_SLOW_START_OK, RX_PACKET_TYPE_ACK, "slow-start" },
155 { RX_JUMBO_PACKET, RX_PACKET_TYPE_DATA, "jumbogram" }
156 };
157
158 static const struct tok fs_req[] = {
159 { 130, "fetch-data" },
160 { 131, "fetch-acl" },
161 { 132, "fetch-status" },
162 { 133, "store-data" },
163 { 134, "store-acl" },
164 { 135, "store-status" },
165 { 136, "remove-file" },
166 { 137, "create-file" },
167 { 138, "rename" },
168 { 139, "symlink" },
169 { 140, "link" },
170 { 141, "makedir" },
171 { 142, "rmdir" },
172 { 143, "oldsetlock" },
173 { 144, "oldextlock" },
174 { 145, "oldrellock" },
175 { 146, "get-stats" },
176 { 147, "give-cbs" },
177 { 148, "get-vlinfo" },
178 { 149, "get-vlstats" },
179 { 150, "set-vlstats" },
180 { 151, "get-rootvl" },
181 { 152, "check-token" },
182 { 153, "get-time" },
183 { 154, "nget-vlinfo" },
184 { 155, "bulk-stat" },
185 { 156, "setlock" },
186 { 157, "extlock" },
187 { 158, "rellock" },
188 { 159, "xstat-ver" },
189 { 160, "get-xstat" },
190 { 161, "dfs-lookup" },
191 { 162, "dfs-flushcps" },
192 { 163, "dfs-symlink" },
193 { 220, "residency" },
194 { 65536, "inline-bulk-status" },
195 { 65537, "fetch-data-64" },
196 { 65538, "store-data-64" },
197 { 65539, "give-up-all-cbs" },
198 { 65540, "get-caps" },
199 { 65541, "cb-rx-conn-addr" },
200 { 0, NULL },
201 };
202
203 static const struct tok cb_req[] = {
204 { 204, "callback" },
205 { 205, "initcb" },
206 { 206, "probe" },
207 { 207, "getlock" },
208 { 208, "getce" },
209 { 209, "xstatver" },
210 { 210, "getxstat" },
211 { 211, "initcb2" },
212 { 212, "whoareyou" },
213 { 213, "initcb3" },
214 { 214, "probeuuid" },
215 { 215, "getsrvprefs" },
216 { 216, "getcellservdb" },
217 { 217, "getlocalcell" },
218 { 218, "getcacheconf" },
219 { 65536, "getce64" },
220 { 65537, "getcellbynum" },
221 { 65538, "tellmeaboutyourself" },
222 { 0, NULL },
223 };
224
225 static const struct tok pt_req[] = {
226 { 500, "new-user" },
227 { 501, "where-is-it" },
228 { 502, "dump-entry" },
229 { 503, "add-to-group" },
230 { 504, "name-to-id" },
231 { 505, "id-to-name" },
232 { 506, "delete" },
233 { 507, "remove-from-group" },
234 { 508, "get-cps" },
235 { 509, "new-entry" },
236 { 510, "list-max" },
237 { 511, "set-max" },
238 { 512, "list-entry" },
239 { 513, "change-entry" },
240 { 514, "list-elements" },
241 { 515, "same-mbr-of" },
242 { 516, "set-fld-sentry" },
243 { 517, "list-owned" },
244 { 518, "get-cps2" },
245 { 519, "get-host-cps" },
246 { 520, "update-entry" },
247 { 521, "list-entries" },
248 { 530, "list-super-groups" },
249 { 0, NULL },
250 };
251
252 static const struct tok vldb_req[] = {
253 { 501, "create-entry" },
254 { 502, "delete-entry" },
255 { 503, "get-entry-by-id" },
256 { 504, "get-entry-by-name" },
257 { 505, "get-new-volume-id" },
258 { 506, "replace-entry" },
259 { 507, "update-entry" },
260 { 508, "setlock" },
261 { 509, "releaselock" },
262 { 510, "list-entry" },
263 { 511, "list-attrib" },
264 { 512, "linked-list" },
265 { 513, "get-stats" },
266 { 514, "probe" },
267 { 515, "get-addrs" },
268 { 516, "change-addr" },
269 { 517, "create-entry-n" },
270 { 518, "get-entry-by-id-n" },
271 { 519, "get-entry-by-name-n" },
272 { 520, "replace-entry-n" },
273 { 521, "list-entry-n" },
274 { 522, "list-attrib-n" },
275 { 523, "linked-list-n" },
276 { 524, "update-entry-by-name" },
277 { 525, "create-entry-u" },
278 { 526, "get-entry-by-id-u" },
279 { 527, "get-entry-by-name-u" },
280 { 528, "replace-entry-u" },
281 { 529, "list-entry-u" },
282 { 530, "list-attrib-u" },
283 { 531, "linked-list-u" },
284 { 532, "regaddr" },
285 { 533, "get-addrs-u" },
286 { 534, "list-attrib-n2" },
287 { 0, NULL },
288 };
289
290 static const struct tok kauth_req[] = {
291 { 1, "auth-old" },
292 { 21, "authenticate" },
293 { 22, "authenticate-v2" },
294 { 2, "change-pw" },
295 { 3, "get-ticket-old" },
296 { 23, "get-ticket" },
297 { 4, "set-pw" },
298 { 5, "set-fields" },
299 { 6, "create-user" },
300 { 7, "delete-user" },
301 { 8, "get-entry" },
302 { 9, "list-entry" },
303 { 10, "get-stats" },
304 { 11, "debug" },
305 { 12, "get-pw" },
306 { 13, "get-random-key" },
307 { 14, "unlock" },
308 { 15, "lock-status" },
309 { 0, NULL },
310 };
311
312 static const struct tok vol_req[] = {
313 { 100, "create-volume" },
314 { 101, "delete-volume" },
315 { 102, "restore" },
316 { 103, "forward" },
317 { 104, "end-trans" },
318 { 105, "clone" },
319 { 106, "set-flags" },
320 { 107, "get-flags" },
321 { 108, "trans-create" },
322 { 109, "dump" },
323 { 110, "get-nth-volume" },
324 { 111, "set-forwarding" },
325 { 112, "get-name" },
326 { 113, "get-status" },
327 { 114, "sig-restore" },
328 { 115, "list-partitions" },
329 { 116, "list-volumes" },
330 { 117, "set-id-types" },
331 { 118, "monitor" },
332 { 119, "partition-info" },
333 { 120, "reclone" },
334 { 121, "list-one-volume" },
335 { 122, "nuke" },
336 { 123, "set-date" },
337 { 124, "x-list-volumes" },
338 { 125, "x-list-one-volume" },
339 { 126, "set-info" },
340 { 127, "x-list-partitions" },
341 { 128, "forward-multiple" },
342 { 65536, "convert-ro" },
343 { 65537, "get-size" },
344 { 65538, "dump-v2" },
345 { 0, NULL },
346 };
347
348 static const struct tok bos_req[] = {
349 { 80, "create-bnode" },
350 { 81, "delete-bnode" },
351 { 82, "set-status" },
352 { 83, "get-status" },
353 { 84, "enumerate-instance" },
354 { 85, "get-instance-info" },
355 { 86, "get-instance-parm" },
356 { 87, "add-superuser" },
357 { 88, "delete-superuser" },
358 { 89, "list-superusers" },
359 { 90, "list-keys" },
360 { 91, "add-key" },
361 { 92, "delete-key" },
362 { 93, "set-cell-name" },
363 { 94, "get-cell-name" },
364 { 95, "get-cell-host" },
365 { 96, "add-cell-host" },
366 { 97, "delete-cell-host" },
367 { 98, "set-t-status" },
368 { 99, "shutdown-all" },
369 { 100, "restart-all" },
370 { 101, "startup-all" },
371 { 102, "set-noauth-flag" },
372 { 103, "re-bozo" },
373 { 104, "restart" },
374 { 105, "start-bozo-install" },
375 { 106, "uninstall" },
376 { 107, "get-dates" },
377 { 108, "exec" },
378 { 109, "prune" },
379 { 110, "set-restart-time" },
380 { 111, "get-restart-time" },
381 { 112, "start-bozo-log" },
382 { 113, "wait-all" },
383 { 114, "get-instance-strings" },
384 { 115, "get-restricted" },
385 { 116, "set-restricted" },
386 { 0, NULL },
387 };
388
389 static const struct tok ubik_req[] = {
390 { 10000, "vote-beacon" },
391 { 10001, "vote-debug-old" },
392 { 10002, "vote-sdebug-old" },
393 { 10003, "vote-getsyncsite" },
394 { 10004, "vote-debug" },
395 { 10005, "vote-sdebug" },
396 { 10006, "vote-xdebug" },
397 { 10007, "vote-xsdebug" },
398 { 20000, "disk-begin" },
399 { 20001, "disk-commit" },
400 { 20002, "disk-lock" },
401 { 20003, "disk-write" },
402 { 20004, "disk-getversion" },
403 { 20005, "disk-getfile" },
404 { 20006, "disk-sendfile" },
405 { 20007, "disk-abort" },
406 { 20008, "disk-releaselocks" },
407 { 20009, "disk-truncate" },
408 { 20010, "disk-probe" },
409 { 20011, "disk-writev" },
410 { 20012, "disk-interfaceaddr" },
411 { 20013, "disk-setversion" },
412 { 0, NULL },
413 };
414
415 #define VOTE_LOW 10000
416 #define VOTE_HIGH 10007
417 #define DISK_LOW 20000
418 #define DISK_HIGH 20013
419
420 static const struct tok cb_types[] = {
421 { 1, "exclusive" },
422 { 2, "shared" },
423 { 3, "dropped" },
424 { 0, NULL },
425 };
426
427 static const struct tok ubik_lock_types[] = {
428 { 1, "read" },
429 { 2, "write" },
430 { 3, "wait" },
431 { 0, NULL },
432 };
433
434 static const char *voltype[] = { "read-write", "read-only", "backup" };
435
436 static const struct tok afs_fs_errors[] = {
437 { 101, "salvage volume" },
438 { 102, "no such vnode" },
439 { 103, "no such volume" },
440 { 104, "volume exist" },
441 { 105, "no service" },
442 { 106, "volume offline" },
443 { 107, "voline online" },
444 { 108, "diskfull" },
445 { 109, "diskquota exceeded" },
446 { 110, "volume busy" },
447 { 111, "volume moved" },
448 { 112, "AFS IO error" },
449 { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */
450 { 0, NULL }
451 };
452
453 /*
454 * Reasons for acknowledging a packet
455 */
456
457 static const struct tok rx_ack_reasons[] = {
458 { 1, "ack requested" },
459 { 2, "duplicate packet" },
460 { 3, "out of sequence" },
461 { 4, "exceeds window" },
462 { 5, "no buffer space" },
463 { 6, "ping" },
464 { 7, "ping response" },
465 { 8, "delay" },
466 { 9, "idle" },
467 { 0, NULL },
468 };
469
470 /*
471 * Cache entries we keep around so we can figure out the RX opcode
472 * numbers for replies. This allows us to make sense of RX reply packets.
473 */
474
475 struct rx_cache_entry {
476 uint32_t callnum; /* Call number (net order) */
477 struct in_addr client; /* client IP address (net order) */
478 struct in_addr server; /* server IP address (net order) */
479 int dport; /* server port (host order) */
480 u_short serviceId; /* Service identifier (net order) */
481 uint32_t opcode; /* RX opcode (host order) */
482 };
483
484 #define RX_CACHE_SIZE 64
485
486 static struct rx_cache_entry rx_cache[RX_CACHE_SIZE];
487
488 static int rx_cache_next = 0;
489 static int rx_cache_hint = 0;
490 static void rx_cache_insert(netdissect_options *, const u_char *, const struct ip *, int);
491 static int rx_cache_find(const struct rx_header *, const struct ip *,
492 int, int32_t *);
493
494 static void fs_print(netdissect_options *, const u_char *, int);
495 static void fs_reply_print(netdissect_options *, const u_char *, int, int32_t);
496 static void acl_print(netdissect_options *, u_char *, int, u_char *);
497 static void cb_print(netdissect_options *, const u_char *, int);
498 static void cb_reply_print(netdissect_options *, const u_char *, int, int32_t);
499 static void prot_print(netdissect_options *, const u_char *, int);
500 static void prot_reply_print(netdissect_options *, const u_char *, int, int32_t);
501 static void vldb_print(netdissect_options *, const u_char *, int);
502 static void vldb_reply_print(netdissect_options *, const u_char *, int, int32_t);
503 static void kauth_print(netdissect_options *, const u_char *, int);
504 static void kauth_reply_print(netdissect_options *, const u_char *, int, int32_t);
505 static void vol_print(netdissect_options *, const u_char *, int);
506 static void vol_reply_print(netdissect_options *, const u_char *, int, int32_t);
507 static void bos_print(netdissect_options *, const u_char *, int);
508 static void bos_reply_print(netdissect_options *, const u_char *, int, int32_t);
509 static void ubik_print(netdissect_options *, const u_char *);
510 static void ubik_reply_print(netdissect_options *, const u_char *, int, int32_t);
511
512 static void rx_ack_print(netdissect_options *, const u_char *, int);
513
514 static int is_ubik(uint32_t);
515
516 /*
517 * Handle the rx-level packet. See if we know what port it's going to so
518 * we can peek at the afs call inside
519 */
520
521 void
522 rx_print(netdissect_options *ndo,
523 register const u_char *bp, int length, int sport, int dport,
524 const u_char *bp2)
525 {
526 register const struct rx_header *rxh;
527 int i;
528 int32_t opcode;
529
530 if (ndo->ndo_snapend - bp < (int)sizeof (struct rx_header)) {
531 ND_PRINT((ndo, " [|rx] (%d)", length));
532 return;
533 }
534
535 rxh = (const struct rx_header *) bp;
536
537 ND_PRINT((ndo, " rx %s", tok2str(rx_types, "type %d", rxh->type)));
538
539 if (ndo->ndo_vflag) {
540 int firstflag = 0;
541
542 if (ndo->ndo_vflag > 1)
543 ND_PRINT((ndo, " cid %08x call# %d",
544 (int) EXTRACT_32BITS(&rxh->cid),
545 (int) EXTRACT_32BITS(&rxh->callNumber)));
546
547 ND_PRINT((ndo, " seq %d ser %d",
548 (int) EXTRACT_32BITS(&rxh->seq),
549 (int) EXTRACT_32BITS(&rxh->serial)));
550
551 if (ndo->ndo_vflag > 2)
552 ND_PRINT((ndo, " secindex %d serviceid %hu",
553 (int) rxh->securityIndex,
554 EXTRACT_16BITS(&rxh->serviceId)));
555
556 if (ndo->ndo_vflag > 1)
557 for (i = 0; i < NUM_RX_FLAGS; i++) {
558 if (rxh->flags & rx_flags[i].flag &&
559 (!rx_flags[i].packetType ||
560 rxh->type == rx_flags[i].packetType)) {
561 if (!firstflag) {
562 firstflag = 1;
563 ND_PRINT((ndo, " "));
564 } else {
565 ND_PRINT((ndo, ","));
566 }
567 ND_PRINT((ndo, "<%s>", rx_flags[i].s));
568 }
569 }
570 }
571
572 /*
573 * Try to handle AFS calls that we know about. Check the destination
574 * port and make sure it's a data packet. Also, make sure the
575 * seq number is 1 (because otherwise it's a continuation packet,
576 * and we can't interpret that). Also, seems that reply packets
577 * do not have the client-init flag set, so we check for that
578 * as well.
579 */
580
581 if (rxh->type == RX_PACKET_TYPE_DATA &&
582 EXTRACT_32BITS(&rxh->seq) == 1 &&
583 rxh->flags & RX_CLIENT_INITIATED) {
584
585 /*
586 * Insert this call into the call cache table, so we
587 * have a chance to print out replies
588 */
589
590 rx_cache_insert(ndo, bp, (const struct ip *) bp2, dport);
591
592 switch (dport) {
593 case FS_RX_PORT: /* AFS file service */
594 fs_print(ndo, bp, length);
595 break;
596 case CB_RX_PORT: /* AFS callback service */
597 cb_print(ndo, bp, length);
598 break;
599 case PROT_RX_PORT: /* AFS protection service */
600 prot_print(ndo, bp, length);
601 break;
602 case VLDB_RX_PORT: /* AFS VLDB service */
603 vldb_print(ndo, bp, length);
604 break;
605 case KAUTH_RX_PORT: /* AFS Kerberos auth service */
606 kauth_print(ndo, bp, length);
607 break;
608 case VOL_RX_PORT: /* AFS Volume service */
609 vol_print(ndo, bp, length);
610 break;
611 case BOS_RX_PORT: /* AFS BOS service */
612 bos_print(ndo, bp, length);
613 break;
614 default:
615 ;
616 }
617
618 /*
619 * If it's a reply (client-init is _not_ set, but seq is one)
620 * then look it up in the cache. If we find it, call the reply
621 * printing functions Note that we handle abort packets here,
622 * because printing out the return code can be useful at times.
623 */
624
625 } else if (((rxh->type == RX_PACKET_TYPE_DATA &&
626 EXTRACT_32BITS(&rxh->seq) == 1) ||
627 rxh->type == RX_PACKET_TYPE_ABORT) &&
628 (rxh->flags & RX_CLIENT_INITIATED) == 0 &&
629 rx_cache_find(rxh, (const struct ip *) bp2,
630 sport, &opcode)) {
631
632 switch (sport) {
633 case FS_RX_PORT: /* AFS file service */
634 fs_reply_print(ndo, bp, length, opcode);
635 break;
636 case CB_RX_PORT: /* AFS callback service */
637 cb_reply_print(ndo, bp, length, opcode);
638 break;
639 case PROT_RX_PORT: /* AFS PT service */
640 prot_reply_print(ndo, bp, length, opcode);
641 break;
642 case VLDB_RX_PORT: /* AFS VLDB service */
643 vldb_reply_print(ndo, bp, length, opcode);
644 break;
645 case KAUTH_RX_PORT: /* AFS Kerberos auth service */
646 kauth_reply_print(ndo, bp, length, opcode);
647 break;
648 case VOL_RX_PORT: /* AFS Volume service */
649 vol_reply_print(ndo, bp, length, opcode);
650 break;
651 case BOS_RX_PORT: /* AFS BOS service */
652 bos_reply_print(ndo, bp, length, opcode);
653 break;
654 default:
655 ;
656 }
657
658 /*
659 * If it's an RX ack packet, then use the appropriate ack decoding
660 * function (there isn't any service-specific information in the
661 * ack packet, so we can use one for all AFS services)
662 */
663
664 } else if (rxh->type == RX_PACKET_TYPE_ACK)
665 rx_ack_print(ndo, bp, length);
666
667
668 ND_PRINT((ndo, " (%d)", length));
669 }
670
671 /*
672 * Insert an entry into the cache. Taken from print-nfs.c
673 */
674
675 static void
676 rx_cache_insert(netdissect_options *ndo,
677 const u_char *bp, const struct ip *ip, int dport)
678 {
679 struct rx_cache_entry *rxent;
680 const struct rx_header *rxh = (const struct rx_header *) bp;
681
682 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t)))
683 return;
684
685 rxent = &rx_cache[rx_cache_next];
686
687 if (++rx_cache_next >= RX_CACHE_SIZE)
688 rx_cache_next = 0;
689
690 rxent->callnum = rxh->callNumber;
691 rxent->client = ip->ip_src;
692 rxent->server = ip->ip_dst;
693 rxent->dport = dport;
694 rxent->serviceId = rxh->serviceId;
695 rxent->opcode = EXTRACT_32BITS(bp + sizeof(struct rx_header));
696 }
697
698 /*
699 * Lookup an entry in the cache. Also taken from print-nfs.c
700 *
701 * Note that because this is a reply, we're looking at the _source_
702 * port.
703 */
704
705 static int
706 rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
707 int32_t *opcode)
708 {
709 int i;
710 struct rx_cache_entry *rxent;
711 uint32_t clip = ip->ip_dst.s_addr;
712 uint32_t sip = ip->ip_src.s_addr;
713
714 /* Start the search where we last left off */
715
716 i = rx_cache_hint;
717 do {
718 rxent = &rx_cache[i];
719 if (rxent->callnum == rxh->callNumber &&
720 rxent->client.s_addr == clip &&
721 rxent->server.s_addr == sip &&
722 rxent->serviceId == rxh->serviceId &&
723 rxent->dport == sport) {
724
725 /* We got a match! */
726
727 rx_cache_hint = i;
728 *opcode = rxent->opcode;
729 return(1);
730 }
731 if (++i >= RX_CACHE_SIZE)
732 i = 0;
733 } while (i != rx_cache_hint);
734
735 /* Our search failed */
736 return(0);
737 }
738
739 /*
740 * These extrememly grody macros handle the printing of various AFS stuff.
741 */
742
743 #define FIDOUT() { unsigned long n1, n2, n3; \
744 ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
745 n1 = EXTRACT_32BITS(bp); \
746 bp += sizeof(int32_t); \
747 n2 = EXTRACT_32BITS(bp); \
748 bp += sizeof(int32_t); \
749 n3 = EXTRACT_32BITS(bp); \
750 bp += sizeof(int32_t); \
751 ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \
752 }
753
754 #define STROUT(MAX) { unsigned int _i; \
755 ND_TCHECK2(bp[0], sizeof(int32_t)); \
756 _i = EXTRACT_32BITS(bp); \
757 if (_i > (MAX)) \
758 goto trunc; \
759 bp += sizeof(int32_t); \
760 ND_PRINT((ndo, " \"")); \
761 if (fn_printn(ndo, bp, _i, ndo->ndo_snapend)) \
762 goto trunc; \
763 ND_PRINT((ndo, "\"")); \
764 bp += ((_i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
765 }
766
767 #define INTOUT() { int _i; \
768 ND_TCHECK2(bp[0], sizeof(int32_t)); \
769 _i = (int) EXTRACT_32BITS(bp); \
770 bp += sizeof(int32_t); \
771 ND_PRINT((ndo, " %d", _i)); \
772 }
773
774 #define UINTOUT() { unsigned long _i; \
775 ND_TCHECK2(bp[0], sizeof(int32_t)); \
776 _i = EXTRACT_32BITS(bp); \
777 bp += sizeof(int32_t); \
778 ND_PRINT((ndo, " %lu", _i)); \
779 }
780
781 #define UINT64OUT() { uint64_t _i; \
782 ND_TCHECK2(bp[0], sizeof(uint64_t)); \
783 _i = EXTRACT_64BITS(bp); \
784 bp += sizeof(uint64_t); \
785 ND_PRINT((ndo, " %" PRIu64, _i)); \
786 }
787
788 #define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \
789 ND_TCHECK2(bp[0], sizeof(int32_t)); \
790 _t = (time_t) EXTRACT_32BITS(bp); \
791 bp += sizeof(int32_t); \
792 tm = localtime(&_t); \
793 strftime(str, 256, "%Y/%m/%d %T", tm); \
794 ND_PRINT((ndo, " %s", str)); \
795 }
796
797 #define STOREATTROUT() { unsigned long mask, _i; \
798 ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \
799 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
800 if (mask) ND_PRINT((ndo, " StoreStatus")); \
801 if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \
802 else bp += sizeof(int32_t); \
803 _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
804 if (mask & 2) ND_PRINT((ndo, " owner %lu", _i)); \
805 _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
806 if (mask & 4) ND_PRINT((ndo, " group %lu", _i)); \
807 _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
808 if (mask & 8) ND_PRINT((ndo, " mode %lo", _i & 07777)); \
809 _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
810 if (mask & 16) ND_PRINT((ndo, " segsize %lu", _i)); \
811 /* undocumented in 3.3 docu */ \
812 if (mask & 1024) ND_PRINT((ndo, " fsync")); \
813 }
814
815 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
816 ND_TCHECK2(bp[0], sizeof(int32_t) * 2); \
817 epoch = EXTRACT_32BITS(bp); \
818 bp += sizeof(int32_t); \
819 counter = EXTRACT_32BITS(bp); \
820 bp += sizeof(int32_t); \
821 ND_PRINT((ndo, " %d.%d", epoch, counter)); \
822 }
823
824 #define AFSUUIDOUT() {uint32_t temp; int _i; \
825 ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \
826 temp = EXTRACT_32BITS(bp); \
827 bp += sizeof(uint32_t); \
828 ND_PRINT((ndo, " %08x", temp)); \
829 temp = EXTRACT_32BITS(bp); \
830 bp += sizeof(uint32_t); \
831 ND_PRINT((ndo, "%04x", temp)); \
832 temp = EXTRACT_32BITS(bp); \
833 bp += sizeof(uint32_t); \
834 ND_PRINT((ndo, "%04x", temp)); \
835 for (_i = 0; _i < 8; _i++) { \
836 temp = EXTRACT_32BITS(bp); \
837 bp += sizeof(uint32_t); \
838 ND_PRINT((ndo, "%02x", (unsigned char) temp)); \
839 } \
840 }
841
842 /*
843 * This is the sickest one of all
844 */
845
846 #define VECOUT(MAX) { u_char *sp; \
847 u_char s[AFSNAMEMAX]; \
848 int k; \
849 if ((MAX) + 1 > sizeof(s)) \
850 goto trunc; \
851 ND_TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
852 sp = s; \
853 for (k = 0; k < (MAX); k++) { \
854 *sp++ = (u_char) EXTRACT_32BITS(bp); \
855 bp += sizeof(int32_t); \
856 } \
857 s[(MAX)] = '\0'; \
858 ND_PRINT((ndo, " \"")); \
859 fn_print(ndo, s, NULL); \
860 ND_PRINT((ndo, "\"")); \
861 }
862
863 #define DESTSERVEROUT() { unsigned long n1, n2, n3; \
864 ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
865 n1 = EXTRACT_32BITS(bp); \
866 bp += sizeof(int32_t); \
867 n2 = EXTRACT_32BITS(bp); \
868 bp += sizeof(int32_t); \
869 n3 = EXTRACT_32BITS(bp); \
870 bp += sizeof(int32_t); \
871 ND_PRINT((ndo, " server %d:%d:%d", (int) n1, (int) n2, (int) n3)); \
872 }
873
874 /*
875 * Handle calls to the AFS file service (fs)
876 */
877
878 static void
879 fs_print(netdissect_options *ndo,
880 register const u_char *bp, int length)
881 {
882 int fs_op;
883 unsigned long i;
884
885 if (length <= (int)sizeof(struct rx_header))
886 return;
887
888 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
889 goto trunc;
890 }
891
892 /*
893 * Print out the afs call we're invoking. The table used here was
894 * gleaned from fsint/afsint.xg
895 */
896
897 fs_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
898
899 ND_PRINT((ndo, " fs call %s", tok2str(fs_req, "op#%d", fs_op)));
900
901 /*
902 * Print out arguments to some of the AFS calls. This stuff is
903 * all from afsint.xg
904 */
905
906 bp += sizeof(struct rx_header) + 4;
907
908 /*
909 * Sigh. This is gross. Ritchie forgive me.
910 */
911
912 switch (fs_op) {
913 case 130: /* Fetch data */
914 FIDOUT();
915 ND_PRINT((ndo, " offset"));
916 UINTOUT();
917 ND_PRINT((ndo, " length"));
918 UINTOUT();
919 break;
920 case 131: /* Fetch ACL */
921 case 132: /* Fetch Status */
922 case 143: /* Old set lock */
923 case 144: /* Old extend lock */
924 case 145: /* Old release lock */
925 case 156: /* Set lock */
926 case 157: /* Extend lock */
927 case 158: /* Release lock */
928 FIDOUT();
929 break;
930 case 135: /* Store status */
931 FIDOUT();
932 STOREATTROUT();
933 break;
934 case 133: /* Store data */
935 FIDOUT();
936 STOREATTROUT();
937 ND_PRINT((ndo, " offset"));
938 UINTOUT();
939 ND_PRINT((ndo, " length"));
940 UINTOUT();
941 ND_PRINT((ndo, " flen"));
942 UINTOUT();
943 break;
944 case 134: /* Store ACL */
945 {
946 char a[AFSOPAQUEMAX+1];
947 FIDOUT();
948 ND_TCHECK2(bp[0], 4);
949 i = EXTRACT_32BITS(bp);
950 bp += sizeof(int32_t);
951 ND_TCHECK2(bp[0], i);
952 i = min(AFSOPAQUEMAX, i);
953 strncpy(a, (const char *) bp, i);
954 a[i] = '\0';
955 acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
956 break;
957 }
958 case 137: /* Create file */
959 case 141: /* MakeDir */
960 FIDOUT();
961 STROUT(AFSNAMEMAX);
962 STOREATTROUT();
963 break;
964 case 136: /* Remove file */
965 case 142: /* Remove directory */
966 FIDOUT();
967 STROUT(AFSNAMEMAX);
968 break;
969 case 138: /* Rename file */
970 ND_PRINT((ndo, " old"));
971 FIDOUT();
972 STROUT(AFSNAMEMAX);
973 ND_PRINT((ndo, " new"));
974 FIDOUT();
975 STROUT(AFSNAMEMAX);
976 break;
977 case 139: /* Symlink */
978 FIDOUT();
979 STROUT(AFSNAMEMAX);
980 ND_PRINT((ndo, " link to"));
981 STROUT(AFSNAMEMAX);
982 break;
983 case 140: /* Link */
984 FIDOUT();
985 STROUT(AFSNAMEMAX);
986 ND_PRINT((ndo, " link to"));
987 FIDOUT();
988 break;
989 case 148: /* Get volume info */
990 STROUT(AFSNAMEMAX);
991 break;
992 case 149: /* Get volume stats */
993 case 150: /* Set volume stats */
994 ND_PRINT((ndo, " volid"));
995 UINTOUT();
996 break;
997 case 154: /* New get volume info */
998 ND_PRINT((ndo, " volname"));
999 STROUT(AFSNAMEMAX);
1000 break;
1001 case 155: /* Bulk stat */
1002 case 65536: /* Inline bulk stat */
1003 {
1004 unsigned long j;
1005 ND_TCHECK2(bp[0], 4);
1006 j = EXTRACT_32BITS(bp);
1007 bp += sizeof(int32_t);
1008
1009 for (i = 0; i < j; i++) {
1010 FIDOUT();
1011 if (i != j - 1)
1012 ND_PRINT((ndo, ","));
1013 }
1014 if (j == 0)
1015 ND_PRINT((ndo, " <none!>"));
1016 }
1017 case 65537: /* Fetch data 64 */
1018 FIDOUT();
1019 ND_PRINT((ndo, " offset"));
1020 UINT64OUT();
1021 ND_PRINT((ndo, " length"));
1022 UINT64OUT();
1023 break;
1024 case 65538: /* Store data 64 */
1025 FIDOUT();
1026 STOREATTROUT();
1027 ND_PRINT((ndo, " offset"));
1028 UINT64OUT();
1029 ND_PRINT((ndo, " length"));
1030 UINT64OUT();
1031 ND_PRINT((ndo, " flen"));
1032 UINT64OUT();
1033 break;
1034 case 65541: /* CallBack rx conn address */
1035 ND_PRINT((ndo, " addr"));
1036 UINTOUT();
1037 default:
1038 ;
1039 }
1040
1041 return;
1042
1043 trunc:
1044 ND_PRINT((ndo, " [|fs]"));
1045 }
1046
1047 /*
1048 * Handle replies to the AFS file service
1049 */
1050
1051 static void
1052 fs_reply_print(netdissect_options *ndo,
1053 register const u_char *bp, int length, int32_t opcode)
1054 {
1055 unsigned long i;
1056 const struct rx_header *rxh;
1057
1058 if (length <= (int)sizeof(struct rx_header))
1059 return;
1060
1061 rxh = (const struct rx_header *) bp;
1062
1063 /*
1064 * Print out the afs call we're invoking. The table used here was
1065 * gleaned from fsint/afsint.xg
1066 */
1067
1068 ND_PRINT((ndo, " fs reply %s", tok2str(fs_req, "op#%d", opcode)));
1069
1070 bp += sizeof(struct rx_header);
1071
1072 /*
1073 * If it was a data packet, interpret the response
1074 */
1075
1076 if (rxh->type == RX_PACKET_TYPE_DATA) {
1077 switch (opcode) {
1078 case 131: /* Fetch ACL */
1079 {
1080 char a[AFSOPAQUEMAX+1];
1081 ND_TCHECK2(bp[0], 4);
1082 i = EXTRACT_32BITS(bp);
1083 bp += sizeof(int32_t);
1084 ND_TCHECK2(bp[0], i);
1085 i = min(AFSOPAQUEMAX, i);
1086 strncpy(a, (const char *) bp, i);
1087 a[i] = '\0';
1088 acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
1089 break;
1090 }
1091 case 137: /* Create file */
1092 case 141: /* MakeDir */
1093 ND_PRINT((ndo, " new"));
1094 FIDOUT();
1095 break;
1096 case 151: /* Get root volume */
1097 ND_PRINT((ndo, " root volume"));
1098 STROUT(AFSNAMEMAX);
1099 break;
1100 case 153: /* Get time */
1101 DATEOUT();
1102 break;
1103 default:
1104 ;
1105 }
1106 } else if (rxh->type == RX_PACKET_TYPE_ABORT) {
1107 /*
1108 * Otherwise, just print out the return code
1109 */
1110 ND_TCHECK2(bp[0], sizeof(int32_t));
1111 i = (int) EXTRACT_32BITS(bp);
1112 bp += sizeof(int32_t);
1113
1114 ND_PRINT((ndo, " error %s", tok2str(afs_fs_errors, "#%d", i)));
1115 } else {
1116 ND_PRINT((ndo, " strange fs reply of type %d", rxh->type));
1117 }
1118
1119 return;
1120
1121 trunc:
1122 ND_PRINT((ndo, " [|fs]"));
1123 }
1124
1125 /*
1126 * Print out an AFS ACL string. An AFS ACL is a string that has the
1127 * following format:
1128 *
1129 * <positive> <negative>
1130 * <uid1> <aclbits1>
1131 * ....
1132 *
1133 * "positive" and "negative" are integers which contain the number of
1134 * positive and negative ACL's in the string. The uid/aclbits pair are
1135 * ASCII strings containing the UID/PTS record and and a ascii number
1136 * representing a logical OR of all the ACL permission bits
1137 */
1138
1139 static void
1140 acl_print(netdissect_options *ndo,
1141 u_char *s, int maxsize, u_char *end)
1142 {
1143 int pos, neg, acl;
1144 int n, i;
1145 char *user;
1146 char fmt[1024];
1147
1148 if ((user = (char *)malloc(maxsize)) == NULL)
1149 return;
1150
1151 if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2)
1152 goto finish;
1153
1154 s += n;
1155
1156 if (s > end)
1157 goto finish;
1158
1159 /*
1160 * This wacky order preserves the order used by the "fs" command
1161 */
1162
1163 #define ACLOUT(acl) \
1164 ND_PRINT((ndo, "%s%s%s%s%s%s%s", \
1165 acl & PRSFS_READ ? "r" : "", \
1166 acl & PRSFS_LOOKUP ? "l" : "", \
1167 acl & PRSFS_INSERT ? "i" : "", \
1168 acl & PRSFS_DELETE ? "d" : "", \
1169 acl & PRSFS_WRITE ? "w" : "", \
1170 acl & PRSFS_LOCK ? "k" : "", \
1171 acl & PRSFS_ADMINISTER ? "a" : ""));
1172
1173 for (i = 0; i < pos; i++) {
1174 snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
1175 if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
1176 goto finish;
1177 s += n;
1178 ND_PRINT((ndo, " +{"));
1179 fn_print(ndo, (u_char *)user, NULL);
1180 ND_PRINT((ndo, " "));
1181 ACLOUT(acl);
1182 ND_PRINT((ndo, "}"));
1183 if (s > end)
1184 goto finish;
1185 }
1186
1187 for (i = 0; i < neg; i++) {
1188 snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
1189 if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
1190 goto finish;
1191 s += n;
1192 ND_PRINT((ndo, " -{"));
1193 fn_print(ndo, (u_char *)user, NULL);
1194 ND_PRINT((ndo, " "));
1195 ACLOUT(acl);
1196 ND_PRINT((ndo, "}"));
1197 if (s > end)
1198 goto finish;
1199 }
1200
1201 finish:
1202 free(user);
1203 return;
1204 }
1205
1206 #undef ACLOUT
1207
1208 /*
1209 * Handle calls to the AFS callback service
1210 */
1211
1212 static void
1213 cb_print(netdissect_options *ndo,
1214 register const u_char *bp, int length)
1215 {
1216 int cb_op;
1217 unsigned long i;
1218
1219 if (length <= (int)sizeof(struct rx_header))
1220 return;
1221
1222 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
1223 goto trunc;
1224 }
1225
1226 /*
1227 * Print out the afs call we're invoking. The table used here was
1228 * gleaned from fsint/afscbint.xg
1229 */
1230
1231 cb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
1232
1233 ND_PRINT((ndo, " cb call %s", tok2str(cb_req, "op#%d", cb_op)));
1234
1235 bp += sizeof(struct rx_header) + 4;
1236
1237 /*
1238 * Print out the afs call we're invoking. The table used here was
1239 * gleaned from fsint/afscbint.xg
1240 */
1241
1242 switch (cb_op) {
1243 case 204: /* Callback */
1244 {
1245 unsigned long j, t;
1246 ND_TCHECK2(bp[0], 4);
1247 j = EXTRACT_32BITS(bp);
1248 bp += sizeof(int32_t);
1249
1250 for (i = 0; i < j; i++) {
1251 FIDOUT();
1252 if (i != j - 1)
1253 ND_PRINT((ndo, ","));
1254 }
1255
1256 if (j == 0)
1257 ND_PRINT((ndo, " <none!>"));
1258
1259 j = EXTRACT_32BITS(bp);
1260 bp += sizeof(int32_t);
1261
1262 if (j != 0)
1263 ND_PRINT((ndo, ";"));
1264
1265 for (i = 0; i < j; i++) {
1266 ND_PRINT((ndo, " ver"));
1267 INTOUT();
1268 ND_PRINT((ndo, " expires"));
1269 DATEOUT();
1270 ND_TCHECK2(bp[0], 4);
1271 t = EXTRACT_32BITS(bp);
1272 bp += sizeof(int32_t);
1273 tok2str(cb_types, "type %d", t);
1274 }
1275 }
1276 case 214: {
1277 ND_PRINT((ndo, " afsuuid"));
1278 AFSUUIDOUT();
1279 break;
1280 }
1281 default:
1282 ;
1283 }
1284
1285 return;
1286
1287 trunc:
1288 ND_PRINT((ndo, " [|cb]"));
1289 }
1290
1291 /*
1292 * Handle replies to the AFS Callback Service
1293 */
1294
1295 static void
1296 cb_reply_print(netdissect_options *ndo,
1297 register const u_char *bp, int length, int32_t opcode)
1298 {
1299 const struct rx_header *rxh;
1300
1301 if (length <= (int)sizeof(struct rx_header))
1302 return;
1303
1304 rxh = (const struct rx_header *) bp;
1305
1306 /*
1307 * Print out the afs call we're invoking. The table used here was
1308 * gleaned from fsint/afscbint.xg
1309 */
1310
1311 ND_PRINT((ndo, " cb reply %s", tok2str(cb_req, "op#%d", opcode)));
1312
1313 bp += sizeof(struct rx_header);
1314
1315 /*
1316 * If it was a data packet, interpret the response.
1317 */
1318
1319 if (rxh->type == RX_PACKET_TYPE_DATA)
1320 switch (opcode) {
1321 case 213: /* InitCallBackState3 */
1322 AFSUUIDOUT();
1323 break;
1324 default:
1325 ;
1326 }
1327 else {
1328 /*
1329 * Otherwise, just print out the return code
1330 */
1331 ND_PRINT((ndo, " errcode"));
1332 INTOUT();
1333 }
1334
1335 return;
1336
1337 trunc:
1338 ND_PRINT((ndo, " [|cb]"));
1339 }
1340
1341 /*
1342 * Handle calls to the AFS protection database server
1343 */
1344
1345 static void
1346 prot_print(netdissect_options *ndo,
1347 register const u_char *bp, int length)
1348 {
1349 unsigned long i;
1350 int pt_op;
1351
1352 if (length <= (int)sizeof(struct rx_header))
1353 return;
1354
1355 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
1356 goto trunc;
1357 }
1358
1359 /*
1360 * Print out the afs call we're invoking. The table used here was
1361 * gleaned from ptserver/ptint.xg
1362 */
1363
1364 pt_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
1365
1366 ND_PRINT((ndo, " pt"));
1367
1368 if (is_ubik(pt_op)) {
1369 ubik_print(ndo, bp);
1370 return;
1371 }
1372
1373 ND_PRINT((ndo, " call %s", tok2str(pt_req, "op#%d", pt_op)));
1374
1375 /*
1376 * Decode some of the arguments to the PT calls
1377 */
1378
1379 bp += sizeof(struct rx_header) + 4;
1380
1381 switch (pt_op) {
1382 case 500: /* I New User */
1383 STROUT(PRNAMEMAX);
1384 ND_PRINT((ndo, " id"));
1385 INTOUT();
1386 ND_PRINT((ndo, " oldid"));
1387 INTOUT();
1388 break;
1389 case 501: /* Where is it */
1390 case 506: /* Delete */
1391 case 508: /* Get CPS */
1392 case 512: /* List entry */
1393 case 514: /* List elements */
1394 case 517: /* List owned */
1395 case 518: /* Get CPS2 */
1396 case 519: /* Get host CPS */
1397 case 530: /* List super groups */
1398 ND_PRINT((ndo, " id"));
1399 INTOUT();
1400 break;
1401 case 502: /* Dump entry */
1402 ND_PRINT((ndo, " pos"));
1403 INTOUT();
1404 break;
1405 case 503: /* Add to group */
1406 case 507: /* Remove from group */
1407 case 515: /* Is a member of? */
1408 ND_PRINT((ndo, " uid"));
1409 INTOUT();
1410 ND_PRINT((ndo, " gid"));
1411 INTOUT();
1412 break;
1413 case 504: /* Name to ID */
1414 {
1415 unsigned long j;
1416 ND_TCHECK2(bp[0], 4);
1417 j = EXTRACT_32BITS(bp);
1418 bp += sizeof(int32_t);
1419
1420 /*
1421 * Who designed this chicken-shit protocol?
1422 *
1423 * Each character is stored as a 32-bit
1424 * integer!
1425 */
1426
1427 for (i = 0; i < j; i++) {
1428 VECOUT(PRNAMEMAX);
1429 }
1430 if (j == 0)
1431 ND_PRINT((ndo, " <none!>"));
1432 }
1433 break;
1434 case 505: /* Id to name */
1435 {
1436 unsigned long j;
1437 ND_PRINT((ndo, " ids:"));
1438 ND_TCHECK2(bp[0], 4);
1439 i = EXTRACT_32BITS(bp);
1440 bp += sizeof(int32_t);
1441 for (j = 0; j < i; j++)
1442 INTOUT();
1443 if (j == 0)
1444 ND_PRINT((ndo, " <none!>"));
1445 }
1446 break;
1447 case 509: /* New entry */
1448 STROUT(PRNAMEMAX);
1449 ND_PRINT((ndo, " flag"));
1450 INTOUT();
1451 ND_PRINT((ndo, " oid"));
1452 INTOUT();
1453 break;
1454 case 511: /* Set max */
1455 ND_PRINT((ndo, " id"));
1456 INTOUT();
1457 ND_PRINT((ndo, " gflag"));
1458 INTOUT();
1459 break;
1460 case 513: /* Change entry */
1461 ND_PRINT((ndo, " id"));
1462 INTOUT();
1463 STROUT(PRNAMEMAX);
1464 ND_PRINT((ndo, " oldid"));
1465 INTOUT();
1466 ND_PRINT((ndo, " newid"));
1467 INTOUT();
1468 break;
1469 case 520: /* Update entry */
1470 ND_PRINT((ndo, " id"));
1471 INTOUT();
1472 STROUT(PRNAMEMAX);
1473 break;
1474 default:
1475 ;
1476 }
1477
1478
1479 return;
1480
1481 trunc:
1482 ND_PRINT((ndo, " [|pt]"));
1483 }
1484
1485 /*
1486 * Handle replies to the AFS protection service
1487 */
1488
1489 static void
1490 prot_reply_print(netdissect_options *ndo,
1491 register const u_char *bp, int length, int32_t opcode)
1492 {
1493 const struct rx_header *rxh;
1494 unsigned long i;
1495
1496 if (length < (int)sizeof(struct rx_header))
1497 return;
1498
1499 rxh = (const struct rx_header *) bp;
1500
1501 /*
1502 * Print out the afs call we're invoking. The table used here was
1503 * gleaned from ptserver/ptint.xg. Check to see if it's a
1504 * Ubik call, however.
1505 */
1506
1507 ND_PRINT((ndo, " pt"));
1508
1509 if (is_ubik(opcode)) {
1510 ubik_reply_print(ndo, bp, length, opcode);
1511 return;
1512 }
1513
1514 ND_PRINT((ndo, " reply %s", tok2str(pt_req, "op#%d", opcode)));
1515
1516 bp += sizeof(struct rx_header);
1517
1518 /*
1519 * If it was a data packet, interpret the response
1520 */
1521
1522 if (rxh->type == RX_PACKET_TYPE_DATA)
1523 switch (opcode) {
1524 case 504: /* Name to ID */
1525 {
1526 unsigned long j;
1527 ND_PRINT((ndo, " ids:"));
1528 ND_TCHECK2(bp[0], 4);
1529 i = EXTRACT_32BITS(bp);
1530 bp += sizeof(int32_t);
1531 for (j = 0; j < i; j++)
1532 INTOUT();
1533 if (j == 0)
1534 ND_PRINT((ndo, " <none!>"));
1535 }
1536 break;
1537 case 505: /* ID to name */
1538 {
1539 unsigned long j;
1540 ND_TCHECK2(bp[0], 4);
1541 j = EXTRACT_32BITS(bp);
1542 bp += sizeof(int32_t);
1543
1544 /*
1545 * Who designed this chicken-shit protocol?
1546 *
1547 * Each character is stored as a 32-bit
1548 * integer!
1549 */
1550
1551 for (i = 0; i < j; i++) {
1552 VECOUT(PRNAMEMAX);
1553 }
1554 if (j == 0)
1555 ND_PRINT((ndo, " <none!>"));
1556 }
1557 break;
1558 case 508: /* Get CPS */
1559 case 514: /* List elements */
1560 case 517: /* List owned */
1561 case 518: /* Get CPS2 */
1562 case 519: /* Get host CPS */
1563 {
1564 unsigned long j;
1565 ND_TCHECK2(bp[0], 4);
1566 j = EXTRACT_32BITS(bp);
1567 bp += sizeof(int32_t);
1568 for (i = 0; i < j; i++) {
1569 INTOUT();
1570 }
1571 if (j == 0)
1572 ND_PRINT((ndo, " <none!>"));
1573 }
1574 break;
1575 case 510: /* List max */
1576 ND_PRINT((ndo, " maxuid"));
1577 INTOUT();
1578 ND_PRINT((ndo, " maxgid"));
1579 INTOUT();
1580 break;
1581 default:
1582 ;
1583 }
1584 else {
1585 /*
1586 * Otherwise, just print out the return code
1587 */
1588 ND_PRINT((ndo, " errcode"));
1589 INTOUT();
1590 }
1591
1592 return;
1593
1594 trunc:
1595 ND_PRINT((ndo, " [|pt]"));
1596 }
1597
1598 /*
1599 * Handle calls to the AFS volume location database service
1600 */
1601
1602 static void
1603 vldb_print(netdissect_options *ndo,
1604 register const u_char *bp, int length)
1605 {
1606 int vldb_op;
1607 unsigned long i;
1608
1609 if (length <= (int)sizeof(struct rx_header))
1610 return;
1611
1612 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
1613 goto trunc;
1614 }
1615
1616 /*
1617 * Print out the afs call we're invoking. The table used here was
1618 * gleaned from vlserver/vldbint.xg
1619 */
1620
1621 vldb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
1622
1623 ND_PRINT((ndo, " vldb"));
1624
1625 if (is_ubik(vldb_op)) {
1626 ubik_print(ndo, bp);
1627 return;
1628 }
1629 ND_PRINT((ndo, " call %s", tok2str(vldb_req, "op#%d", vldb_op)));
1630
1631 /*
1632 * Decode some of the arguments to the VLDB calls
1633 */
1634
1635 bp += sizeof(struct rx_header) + 4;
1636
1637 switch (vldb_op) {
1638 case 501: /* Create new volume */
1639 case 517: /* Create entry N */
1640 VECOUT(VLNAMEMAX);
1641 break;
1642 case 502: /* Delete entry */
1643 case 503: /* Get entry by ID */
1644 case 507: /* Update entry */
1645 case 508: /* Set lock */
1646 case 509: /* Release lock */
1647 case 518: /* Get entry by ID N */
1648 ND_PRINT((ndo, " volid"));
1649 INTOUT();
1650 ND_TCHECK2(bp[0], sizeof(int32_t));
1651 i = EXTRACT_32BITS(bp);
1652 bp += sizeof(int32_t);
1653 if (i <= 2)
1654 ND_PRINT((ndo, " type %s", voltype[i]));
1655 break;
1656 case 504: /* Get entry by name */
1657 case 519: /* Get entry by name N */
1658 case 524: /* Update entry by name */
1659 case 527: /* Get entry by name U */
1660 STROUT(VLNAMEMAX);
1661 break;
1662 case 505: /* Get new vol id */
1663 ND_PRINT((ndo, " bump"));
1664 INTOUT();
1665 break;
1666 case 506: /* Replace entry */
1667 case 520: /* Replace entry N */
1668 ND_PRINT((ndo, " volid"));
1669 INTOUT();
1670 ND_TCHECK2(bp[0], sizeof(int32_t));
1671 i = EXTRACT_32BITS(bp);
1672 bp += sizeof(int32_t);
1673 if (i <= 2)
1674 ND_PRINT((ndo, " type %s", voltype[i]));
1675 VECOUT(VLNAMEMAX);
1676 break;
1677 case 510: /* List entry */
1678 case 521: /* List entry N */
1679 ND_PRINT((ndo, " index"));
1680 INTOUT();
1681 break;
1682 default:
1683 ;
1684 }
1685
1686 return;
1687
1688 trunc:
1689 ND_PRINT((ndo, " [|vldb]"));
1690 }
1691
1692 /*
1693 * Handle replies to the AFS volume location database service
1694 */
1695
1696 static void
1697 vldb_reply_print(netdissect_options *ndo,
1698 register const u_char *bp, int length, int32_t opcode)
1699 {
1700 const struct rx_header *rxh;
1701 unsigned long i;
1702
1703 if (length < (int)sizeof(struct rx_header))
1704 return;
1705
1706 rxh = (const struct rx_header *) bp;
1707
1708 /*
1709 * Print out the afs call we're invoking. The table used here was
1710 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1711 * Ubik call, however.
1712 */
1713
1714 ND_PRINT((ndo, " vldb"));
1715
1716 if (is_ubik(opcode)) {
1717 ubik_reply_print(ndo, bp, length, opcode);
1718 return;
1719 }
1720
1721 ND_PRINT((ndo, " reply %s", tok2str(vldb_req, "op#%d", opcode)));
1722
1723 bp += sizeof(struct rx_header);
1724
1725 /*
1726 * If it was a data packet, interpret the response
1727 */
1728
1729 if (rxh->type == RX_PACKET_TYPE_DATA)
1730 switch (opcode) {
1731 case 510: /* List entry */
1732 ND_PRINT((ndo, " count"));
1733 INTOUT();
1734 ND_PRINT((ndo, " nextindex"));
1735 INTOUT();
1736 case 503: /* Get entry by id */
1737 case 504: /* Get entry by name */
1738 { unsigned long nservers, j;
1739 VECOUT(VLNAMEMAX);
1740 ND_TCHECK2(bp[0], sizeof(int32_t));
1741 bp += sizeof(int32_t);
1742 ND_PRINT((ndo, " numservers"));
1743 ND_TCHECK2(bp[0], sizeof(int32_t));
1744 nservers = EXTRACT_32BITS(bp);
1745 bp += sizeof(int32_t);
1746 ND_PRINT((ndo, " %lu", nservers));
1747 ND_PRINT((ndo, " servers"));
1748 for (i = 0; i < 8; i++) {
1749 ND_TCHECK2(bp[0], sizeof(int32_t));
1750 if (i < nservers)
1751 ND_PRINT((ndo, " %s",
1752 intoa(((const struct in_addr *) bp)->s_addr)));
1753 bp += sizeof(int32_t);
1754 }
1755 ND_PRINT((ndo, " partitions"));
1756 for (i = 0; i < 8; i++) {
1757 ND_TCHECK2(bp[0], sizeof(int32_t));
1758 j = EXTRACT_32BITS(bp);
1759 if (i < nservers && j <= 26)
1760 ND_PRINT((ndo, " %c", 'a' + (int)j));
1761 else if (i < nservers)
1762 ND_PRINT((ndo, " %lu", j));
1763 bp += sizeof(int32_t);
1764 }
1765 ND_TCHECK2(bp[0], 8 * sizeof(int32_t));
1766 bp += 8 * sizeof(int32_t);
1767 ND_PRINT((ndo, " rwvol"));
1768 UINTOUT();
1769 ND_PRINT((ndo, " rovol"));
1770 UINTOUT();
1771 ND_PRINT((ndo, " backup"));
1772 UINTOUT();
1773 }
1774 break;
1775 case 505: /* Get new volume ID */
1776 ND_PRINT((ndo, " newvol"));
1777 UINTOUT();
1778 break;
1779 case 521: /* List entry */
1780 case 529: /* List entry U */
1781 ND_PRINT((ndo, " count"));
1782 INTOUT();
1783 ND_PRINT((ndo, " nextindex"));
1784 INTOUT();
1785 case 518: /* Get entry by ID N */
1786 case 519: /* Get entry by name N */
1787 { unsigned long nservers, j;
1788 VECOUT(VLNAMEMAX);
1789 ND_PRINT((ndo, " numservers"));
1790 ND_TCHECK2(bp[0], sizeof(int32_t));
1791 nservers = EXTRACT_32BITS(bp);
1792 bp += sizeof(int32_t);
1793 ND_PRINT((ndo, " %lu", nservers));
1794 ND_PRINT((ndo, " servers"));
1795 for (i = 0; i < 13; i++) {
1796 ND_TCHECK2(bp[0], sizeof(int32_t));
1797 if (i < nservers)
1798 ND_PRINT((ndo, " %s",
1799 intoa(((const struct in_addr *) bp)->s_addr)));
1800 bp += sizeof(int32_t);
1801 }
1802 ND_PRINT((ndo, " partitions"));
1803 for (i = 0; i < 13; i++) {
1804 ND_TCHECK2(bp[0], sizeof(int32_t));
1805 j = EXTRACT_32BITS(bp);
1806 if (i < nservers && j <= 26)
1807 ND_PRINT((ndo, " %c", 'a' + (int)j));
1808 else if (i < nservers)
1809 ND_PRINT((ndo, " %lu", j));
1810 bp += sizeof(int32_t);
1811 }
1812 ND_TCHECK2(bp[0], 13 * sizeof(int32_t));
1813 bp += 13 * sizeof(int32_t);
1814 ND_PRINT((ndo, " rwvol"));
1815 UINTOUT();
1816 ND_PRINT((ndo, " rovol"));
1817 UINTOUT();
1818 ND_PRINT((ndo, " backup"));
1819 UINTOUT();
1820 }
1821 break;
1822 case 526: /* Get entry by ID U */
1823 case 527: /* Get entry by name U */
1824 { unsigned long nservers, j;
1825 VECOUT(VLNAMEMAX);
1826 ND_PRINT((ndo, " numservers"));
1827 ND_TCHECK2(bp[0], sizeof(int32_t));
1828 nservers = EXTRACT_32BITS(bp);
1829 bp += sizeof(int32_t);
1830 ND_PRINT((ndo, " %lu", nservers));
1831 ND_PRINT((ndo, " servers"));
1832 for (i = 0; i < 13; i++) {
1833 if (i < nservers) {
1834 ND_PRINT((ndo, " afsuuid"));
1835 AFSUUIDOUT();
1836 } else {
1837 ND_TCHECK2(bp[0], 44);
1838 bp += 44;
1839 }
1840 }
1841 ND_TCHECK2(bp[0], 4 * 13);
1842 bp += 4 * 13;
1843 ND_PRINT((ndo, " partitions"));
1844 for (i = 0; i < 13; i++) {
1845 ND_TCHECK2(bp[0], sizeof(int32_t));
1846 j = EXTRACT_32BITS(bp);
1847 if (i < nservers && j <= 26)
1848 ND_PRINT((ndo, " %c", 'a' + (int)j));
1849 else if (i < nservers)
1850 ND_PRINT((ndo, " %lu", j));
1851 bp += sizeof(int32_t);
1852 }
1853 ND_TCHECK2(bp[0], 13 * sizeof(int32_t));
1854 bp += 13 * sizeof(int32_t);
1855 ND_PRINT((ndo, " rwvol"));
1856 UINTOUT();
1857 ND_PRINT((ndo, " rovol"));
1858 UINTOUT();
1859 ND_PRINT((ndo, " backup"));
1860 UINTOUT();
1861 }
1862 default:
1863 ;
1864 }
1865
1866 else {
1867 /*
1868 * Otherwise, just print out the return code
1869 */
1870 ND_PRINT((ndo, " errcode"));
1871 INTOUT();
1872 }
1873
1874 return;
1875
1876 trunc:
1877 ND_PRINT((ndo, " [|vldb]"));
1878 }
1879
1880 /*
1881 * Handle calls to the AFS Kerberos Authentication service
1882 */
1883
1884 static void
1885 kauth_print(netdissect_options *ndo,
1886 register const u_char *bp, int length)
1887 {
1888 int kauth_op;
1889
1890 if (length <= (int)sizeof(struct rx_header))
1891 return;
1892
1893 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
1894 goto trunc;
1895 }
1896
1897 /*
1898 * Print out the afs call we're invoking. The table used here was
1899 * gleaned from kauth/kauth.rg
1900 */
1901
1902 kauth_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
1903
1904 ND_PRINT((ndo, " kauth"));
1905
1906 if (is_ubik(kauth_op)) {
1907 ubik_print(ndo, bp);
1908 return;
1909 }
1910
1911
1912 ND_PRINT((ndo, " call %s", tok2str(kauth_req, "op#%d", kauth_op)));
1913
1914 /*
1915 * Decode some of the arguments to the KA calls
1916 */
1917
1918 bp += sizeof(struct rx_header) + 4;
1919
1920 switch (kauth_op) {
1921 case 1: /* Authenticate old */;
1922 case 21: /* Authenticate */
1923 case 22: /* Authenticate-V2 */
1924 case 2: /* Change PW */
1925 case 5: /* Set fields */
1926 case 6: /* Create user */
1927 case 7: /* Delete user */
1928 case 8: /* Get entry */
1929 case 14: /* Unlock */
1930 case 15: /* Lock status */
1931 ND_PRINT((ndo, " principal"));
1932 STROUT(KANAMEMAX);
1933 STROUT(KANAMEMAX);
1934 break;
1935 case 3: /* GetTicket-old */
1936 case 23: /* GetTicket */
1937 {
1938 int i;
1939 ND_PRINT((ndo, " kvno"));
1940 INTOUT();
1941 ND_PRINT((ndo, " domain"));
1942 STROUT(KANAMEMAX);
1943 ND_TCHECK2(bp[0], sizeof(int32_t));
1944 i = (int) EXTRACT_32BITS(bp);
1945 bp += sizeof(int32_t);
1946 ND_TCHECK2(bp[0], i);
1947 bp += i;
1948 ND_PRINT((ndo, " principal"));
1949 STROUT(KANAMEMAX);
1950 STROUT(KANAMEMAX);
1951 break;
1952 }
1953 case 4: /* Set Password */
1954 ND_PRINT((ndo, " principal"));
1955 STROUT(KANAMEMAX);
1956 STROUT(KANAMEMAX);
1957 ND_PRINT((ndo, " kvno"));
1958 INTOUT();
1959 break;
1960 case 12: /* Get password */
1961 ND_PRINT((ndo, " name"));
1962 STROUT(KANAMEMAX);
1963 break;
1964 default:
1965 ;
1966 }
1967
1968 return;
1969
1970 trunc:
1971 ND_PRINT((ndo, " [|kauth]"));
1972 }
1973
1974 /*
1975 * Handle replies to the AFS Kerberos Authentication Service
1976 */
1977
1978 static void
1979 kauth_reply_print(netdissect_options *ndo,
1980 register const u_char *bp, int length, int32_t opcode)
1981 {
1982 const struct rx_header *rxh;
1983
1984 if (length <= (int)sizeof(struct rx_header))
1985 return;
1986
1987 rxh = (const struct rx_header *) bp;
1988
1989 /*
1990 * Print out the afs call we're invoking. The table used here was
1991 * gleaned from kauth/kauth.rg
1992 */
1993
1994 ND_PRINT((ndo, " kauth"));
1995
1996 if (is_ubik(opcode)) {
1997 ubik_reply_print(ndo, bp, length, opcode);
1998 return;
1999 }
2000
2001 ND_PRINT((ndo, " reply %s", tok2str(kauth_req, "op#%d", opcode)));
2002
2003 bp += sizeof(struct rx_header);
2004
2005 /*
2006 * If it was a data packet, interpret the response.
2007 */
2008
2009 if (rxh->type == RX_PACKET_TYPE_DATA)
2010 /* Well, no, not really. Leave this for later */
2011 ;
2012 else {
2013 /*
2014 * Otherwise, just print out the return code
2015 */
2016 ND_PRINT((ndo, " errcode"));
2017 INTOUT();
2018 }
2019
2020 return;
2021
2022 trunc:
2023 ND_PRINT((ndo, " [|kauth]"));
2024 }
2025
2026 /*
2027 * Handle calls to the AFS Volume location service
2028 */
2029
2030 static void
2031 vol_print(netdissect_options *ndo,
2032 register const u_char *bp, int length)
2033 {
2034 int vol_op;
2035
2036 if (length <= (int)sizeof(struct rx_header))
2037 return;
2038
2039 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
2040 goto trunc;
2041 }
2042
2043 /*
2044 * Print out the afs call we're invoking. The table used here was
2045 * gleaned from volser/volint.xg
2046 */
2047
2048 vol_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
2049
2050 ND_PRINT((ndo, " vol call %s", tok2str(vol_req, "op#%d", vol_op)));
2051
2052 bp += sizeof(struct rx_header) + 4;
2053
2054 switch (vol_op) {
2055 case 100: /* Create volume */
2056 ND_PRINT((ndo, " partition"));
2057 UINTOUT();
2058 ND_PRINT((ndo, " name"));
2059 STROUT(AFSNAMEMAX);
2060 ND_PRINT((ndo, " type"));
2061 UINTOUT();
2062 ND_PRINT((ndo, " parent"));
2063 UINTOUT();
2064 break;
2065 case 101: /* Delete volume */
2066 case 107: /* Get flags */
2067 ND_PRINT((ndo, " trans"));
2068 UINTOUT();
2069 break;
2070 case 102: /* Restore */
2071 ND_PRINT((ndo, " totrans"));
2072 UINTOUT();
2073 ND_PRINT((ndo, " flags"));
2074 UINTOUT();
2075 break;
2076 case 103: /* Forward */
2077 ND_PRINT((ndo, " fromtrans"));
2078 UINTOUT();
2079 ND_PRINT((ndo, " fromdate"));
2080 DATEOUT();
2081 DESTSERVEROUT();
2082 ND_PRINT((ndo, " desttrans"));
2083 INTOUT();
2084 break;
2085 case 104: /* End trans */
2086 ND_PRINT((ndo, " trans"));
2087 UINTOUT();
2088 break;
2089 case 105: /* Clone */
2090 ND_PRINT((ndo, " trans"));
2091 UINTOUT();
2092 ND_PRINT((ndo, " purgevol"));
2093 UINTOUT();
2094 ND_PRINT((ndo, " newtype"));
2095 UINTOUT();
2096 ND_PRINT((ndo, " newname"));
2097 STROUT(AFSNAMEMAX);
2098 break;
2099 case 106: /* Set flags */
2100 ND_PRINT((ndo, " trans"));
2101 UINTOUT();
2102 ND_PRINT((ndo, " flags"));
2103 UINTOUT();
2104 break;
2105 case 108: /* Trans create */
2106 ND_PRINT((ndo, " vol"));
2107 UINTOUT();
2108 ND_PRINT((ndo, " partition"));
2109 UINTOUT();
2110 ND_PRINT((ndo, " flags"));
2111 UINTOUT();
2112 break;
2113 case 109: /* Dump */
2114 case 655537: /* Get size */
2115 ND_PRINT((ndo, " fromtrans"));
2116 UINTOUT();
2117 ND_PRINT((ndo, " fromdate"));
2118 DATEOUT();
2119 break;
2120 case 110: /* Get n-th volume */
2121 ND_PRINT((ndo, " index"));
2122 UINTOUT();
2123 break;
2124 case 111: /* Set forwarding */
2125 ND_PRINT((ndo, " tid"));
2126 UINTOUT();
2127 ND_PRINT((ndo, " newsite"));
2128 UINTOUT();
2129 break;
2130 case 112: /* Get name */
2131 case 113: /* Get status */
2132 ND_PRINT((ndo, " tid"));
2133 break;
2134 case 114: /* Signal restore */
2135 ND_PRINT((ndo, " name"));
2136 STROUT(AFSNAMEMAX);
2137 ND_PRINT((ndo, " type"));
2138 UINTOUT();
2139 ND_PRINT((ndo, " pid"));
2140 UINTOUT();
2141 ND_PRINT((ndo, " cloneid"));
2142 UINTOUT();
2143 break;
2144 case 116: /* List volumes */
2145 ND_PRINT((ndo, " partition"));
2146 UINTOUT();
2147 ND_PRINT((ndo, " flags"));
2148 UINTOUT();
2149 break;
2150 case 117: /* Set id types */
2151 ND_PRINT((ndo, " tid"));
2152 UINTOUT();
2153 ND_PRINT((ndo, " name"));
2154 STROUT(AFSNAMEMAX);
2155 ND_PRINT((ndo, " type"));
2156 UINTOUT();
2157 ND_PRINT((ndo, " pid"));
2158 UINTOUT();
2159 ND_PRINT((ndo, " clone"));
2160 UINTOUT();
2161 ND_PRINT((ndo, " backup"));
2162 UINTOUT();
2163 break;
2164 case 119: /* Partition info */
2165 ND_PRINT((ndo, " name"));
2166 STROUT(AFSNAMEMAX);
2167 break;
2168 case 120: /* Reclone */
2169 ND_PRINT((ndo, " tid"));
2170 UINTOUT();
2171 break;
2172 case 121: /* List one volume */
2173 case 122: /* Nuke volume */
2174 case 124: /* Extended List volumes */
2175 case 125: /* Extended List one volume */
2176 case 65536: /* Convert RO to RW volume */
2177 ND_PRINT((ndo, " partid"));
2178 UINTOUT();
2179 ND_PRINT((ndo, " volid"));
2180 UINTOUT();
2181 break;
2182 case 123: /* Set date */
2183 ND_PRINT((ndo, " tid"));
2184 UINTOUT();
2185 ND_PRINT((ndo, " date"));
2186 DATEOUT();
2187 break;
2188 case 126: /* Set info */
2189 ND_PRINT((ndo, " tid"));
2190 UINTOUT();
2191 break;
2192 case 128: /* Forward multiple */
2193 ND_PRINT((ndo, " fromtrans"));
2194 UINTOUT();
2195 ND_PRINT((ndo, " fromdate"));
2196 DATEOUT();
2197 {
2198 unsigned long i, j;
2199 ND_TCHECK2(bp[0], 4);
2200 j = EXTRACT_32BITS(bp);
2201 bp += sizeof(int32_t);
2202 for (i = 0; i < j; i++) {
2203 DESTSERVEROUT();
2204 if (i != j - 1)
2205 ND_PRINT((ndo, ","));
2206 }
2207 if (j == 0)
2208 ND_PRINT((ndo, " <none!>"));
2209 }
2210 break;
2211 case 65538: /* Dump version 2 */
2212 ND_PRINT((ndo, " fromtrans"));
2213 UINTOUT();
2214 ND_PRINT((ndo, " fromdate"));
2215 DATEOUT();
2216 ND_PRINT((ndo, " flags"));
2217 UINTOUT();
2218 break;
2219 default:
2220 ;
2221 }
2222 return;
2223
2224 trunc:
2225 ND_PRINT((ndo, " [|vol]"));
2226 }
2227
2228 /*
2229 * Handle replies to the AFS Volume Service
2230 */
2231
2232 static void
2233 vol_reply_print(netdissect_options *ndo,
2234 register const u_char *bp, int length, int32_t opcode)
2235 {
2236 const struct rx_header *rxh;
2237
2238 if (length <= (int)sizeof(struct rx_header))
2239 return;
2240
2241 rxh = (const struct rx_header *) bp;
2242
2243 /*
2244 * Print out the afs call we're invoking. The table used here was
2245 * gleaned from volser/volint.xg
2246 */
2247
2248 ND_PRINT((ndo, " vol reply %s", tok2str(vol_req, "op#%d", opcode)));
2249
2250 bp += sizeof(struct rx_header);
2251
2252 /*
2253 * If it was a data packet, interpret the response.
2254 */
2255
2256 if (rxh->type == RX_PACKET_TYPE_DATA) {
2257 switch (opcode) {
2258 case 100: /* Create volume */
2259 ND_PRINT((ndo, " volid"));
2260 UINTOUT();
2261 ND_PRINT((ndo, " trans"));
2262 UINTOUT();
2263 break;
2264 case 104: /* End transaction */
2265 UINTOUT();
2266 break;
2267 case 105: /* Clone */
2268 ND_PRINT((ndo, " newvol"));
2269 UINTOUT();
2270 break;
2271 case 107: /* Get flags */
2272 UINTOUT();
2273 break;
2274 case 108: /* Transaction create */
2275 ND_PRINT((ndo, " trans"));
2276 UINTOUT();
2277 break;
2278 case 110: /* Get n-th volume */
2279 ND_PRINT((ndo, " volume"));
2280 UINTOUT();
2281 ND_PRINT((ndo, " partition"));
2282 UINTOUT();
2283 break;
2284 case 112: /* Get name */
2285 STROUT(AFSNAMEMAX);
2286 break;
2287 case 113: /* Get status */
2288 ND_PRINT((ndo, " volid"));
2289 UINTOUT();
2290 ND_PRINT((ndo, " nextuniq"));
2291 UINTOUT();
2292 ND_PRINT((ndo, " type"));
2293 UINTOUT();
2294 ND_PRINT((ndo, " parentid"));
2295 UINTOUT();
2296 ND_PRINT((ndo, " clone"));
2297 UINTOUT();
2298 ND_PRINT((ndo, " backup"));
2299 UINTOUT();
2300 ND_PRINT((ndo, " restore"));
2301 UINTOUT();
2302 ND_PRINT((ndo, " maxquota"));
2303 UINTOUT();
2304 ND_PRINT((ndo, " minquota"));
2305 UINTOUT();
2306 ND_PRINT((ndo, " owner"));
2307 UINTOUT();
2308 ND_PRINT((ndo, " create"));
2309 DATEOUT();
2310 ND_PRINT((ndo, " access"));
2311 DATEOUT();
2312 ND_PRINT((ndo, " update"));
2313 DATEOUT();
2314 ND_PRINT((ndo, " expire"));
2315 DATEOUT();
2316 ND_PRINT((ndo, " backup"));
2317 DATEOUT();
2318 ND_PRINT((ndo, " copy"));
2319 DATEOUT();
2320 break;
2321 case 115: /* Old list partitions */
2322 break;
2323 case 116: /* List volumes */
2324 case 121: /* List one volume */
2325 {
2326 unsigned long i, j;
2327 ND_TCHECK2(bp[0], 4);
2328 j = EXTRACT_32BITS(bp);
2329 bp += sizeof(int32_t);
2330 for (i = 0; i < j; i++) {
2331 ND_PRINT((ndo, " name"));
2332 VECOUT(32);
2333 ND_PRINT((ndo, " volid"));
2334 UINTOUT();
2335 ND_PRINT((ndo, " type"));
2336 bp += sizeof(int32_t) * 21;
2337 if (i != j - 1)
2338 ND_PRINT((ndo, ","));
2339 }
2340 if (j == 0)
2341 ND_PRINT((ndo, " <none!>"));
2342 }
2343 break;
2344
2345
2346 default:
2347 ;
2348 }
2349 } else {
2350 /*
2351 * Otherwise, just print out the return code
2352 */
2353 ND_PRINT((ndo, " errcode"));
2354 INTOUT();
2355 }
2356
2357 return;
2358
2359 trunc:
2360 ND_PRINT((ndo, " [|vol]"));
2361 }
2362
2363 /*
2364 * Handle calls to the AFS BOS service
2365 */
2366
2367 static void
2368 bos_print(netdissect_options *ndo,
2369 register const u_char *bp, int length)
2370 {
2371 int bos_op;
2372
2373 if (length <= (int)sizeof(struct rx_header))
2374 return;
2375
2376 if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
2377 goto trunc;
2378 }
2379
2380 /*
2381 * Print out the afs call we're invoking. The table used here was
2382 * gleaned from bozo/bosint.xg
2383 */
2384
2385 bos_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
2386
2387 ND_PRINT((ndo, " bos call %s", tok2str(bos_req, "op#%d", bos_op)));
2388
2389 /*
2390 * Decode some of the arguments to the BOS calls
2391 */
2392
2393 bp += sizeof(struct rx_header) + 4;
2394
2395 switch (bos_op) {
2396 case 80: /* Create B node */
2397 ND_PRINT((ndo, " type"));
2398 STROUT(BOSNAMEMAX);
2399 ND_PRINT((ndo, " instance"));
2400 STROUT(BOSNAMEMAX);
2401 break;
2402 case 81: /* Delete B node */
2403 case 83: /* Get status */
2404 case 85: /* Get instance info */
2405 case 87: /* Add super user */
2406 case 88: /* Delete super user */
2407 case 93: /* Set cell name */
2408 case 96: /* Add cell host */
2409 case 97: /* Delete cell host */
2410 case 104: /* Restart */
2411 case 106: /* Uninstall */
2412 case 108: /* Exec */
2413 case 112: /* Getlog */
2414 case 114: /* Get instance strings */
2415 STROUT(BOSNAMEMAX);
2416 break;
2417 case 82: /* Set status */
2418 case 98: /* Set T status */
2419 STROUT(BOSNAMEMAX);
2420 ND_PRINT((ndo, " status"));
2421 INTOUT();
2422 break;
2423 case 86: /* Get instance parm */
2424 STROUT(BOSNAMEMAX);
2425 ND_PRINT((ndo, " num"));
2426 INTOUT();
2427 break;
2428 case 84: /* Enumerate instance */
2429 case 89: /* List super users */
2430 case 90: /* List keys */
2431 case 91: /* Add key */
2432 case 92: /* Delete key */
2433 case 95: /* Get cell host */
2434 INTOUT();
2435 break;
2436 case 105: /* Install */
2437 STROUT(BOSNAMEMAX);
2438 ND_PRINT((ndo, " size"));
2439 INTOUT();
2440 ND_PRINT((ndo, " flags"));
2441 INTOUT();
2442 ND_PRINT((ndo, " date"));
2443 INTOUT();
2444 break;
2445 default:
2446 ;
2447 }
2448
2449 return;
2450
2451 trunc:
2452 ND_PRINT((ndo, " [|bos]"));
2453 }
2454
2455 /*
2456 * Handle replies to the AFS BOS Service
2457 */
2458
2459 static void
2460 bos_reply_print(netdissect_options *ndo,
2461 register const u_char *bp, int length, int32_t opcode)
2462 {
2463 const struct rx_header *rxh;
2464
2465 if (length <= (int)sizeof(struct rx_header))
2466 return;
2467
2468 rxh = (const struct rx_header *) bp;
2469
2470 /*
2471 * Print out the afs call we're invoking. The table used here was
2472 * gleaned from volser/volint.xg
2473 */
2474
2475 ND_PRINT((ndo, " bos reply %s", tok2str(bos_req, "op#%d", opcode)));
2476
2477 bp += sizeof(struct rx_header);
2478
2479 /*
2480 * If it was a data packet, interpret the response.
2481 */
2482
2483 if (rxh->type == RX_PACKET_TYPE_DATA)
2484 /* Well, no, not really. Leave this for later */
2485 ;
2486 else {
2487 /*
2488 * Otherwise, just print out the return code
2489 */
2490 ND_PRINT((ndo, " errcode"));
2491 INTOUT();
2492 }
2493
2494 return;
2495
2496 trunc:
2497 ND_PRINT((ndo, " [|bos]"));
2498 }
2499
2500 /*
2501 * Check to see if this is a Ubik opcode.
2502 */
2503
2504 static int
2505 is_ubik(uint32_t opcode)
2506 {
2507 if ((opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
2508 (opcode >= DISK_LOW && opcode <= DISK_HIGH))
2509 return(1);
2510 else
2511 return(0);
2512 }
2513
2514 /*
2515 * Handle Ubik opcodes to any one of the replicated database services
2516 */
2517
2518 static void
2519 ubik_print(netdissect_options *ndo,
2520 register const u_char *bp)
2521 {
2522 int ubik_op;
2523 int32_t temp;
2524
2525 /*
2526 * Print out the afs call we're invoking. The table used here was
2527 * gleaned from ubik/ubik_int.xg
2528 */
2529
2530 ubik_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
2531
2532 ND_PRINT((ndo, " ubik call %s", tok2str(ubik_req, "op#%d", ubik_op)));
2533
2534 /*
2535 * Decode some of the arguments to the Ubik calls
2536 */
2537
2538 bp += sizeof(struct rx_header) + 4;
2539
2540 switch (ubik_op) {
2541 case 10000: /* Beacon */
2542 ND_TCHECK2(bp[0], 4);
2543 temp = EXTRACT_32BITS(bp);
2544 bp += sizeof(int32_t);
2545 ND_PRINT((ndo, " syncsite %s", temp ? "yes" : "no"));
2546 ND_PRINT((ndo, " votestart"));
2547 DATEOUT();
2548 ND_PRINT((ndo, " dbversion"));
2549 UBIK_VERSIONOUT();
2550 ND_PRINT((ndo, " tid"));
2551 UBIK_VERSIONOUT();
2552 break;
2553 case 10003: /* Get sync site */
2554 ND_PRINT((ndo, " site"));
2555 UINTOUT();
2556 break;
2557 case 20000: /* Begin */
2558 case 20001: /* Commit */
2559 case 20007: /* Abort */
2560 case 20008: /* Release locks */
2561 case 20010: /* Writev */
2562 ND_PRINT((ndo, " tid"));
2563 UBIK_VERSIONOUT();
2564 break;
2565 case 20002: /* Lock */
2566 ND_PRINT((ndo, " tid"));
2567 UBIK_VERSIONOUT();
2568 ND_PRINT((ndo, " file"));
2569 INTOUT();
2570 ND_PRINT((ndo, " pos"));
2571 INTOUT();
2572 ND_PRINT((ndo, " length"));
2573 INTOUT();
2574 temp = EXTRACT_32BITS(bp);
2575 bp += sizeof(int32_t);
2576 tok2str(ubik_lock_types, "type %d", temp);
2577 break;
2578 case 20003: /* Write */
2579 ND_PRINT((ndo, " tid"));
2580 UBIK_VERSIONOUT();
2581 ND_PRINT((ndo, " file"));
2582 INTOUT();
2583 ND_PRINT((ndo, " pos"));
2584 INTOUT();
2585 break;
2586 case 20005: /* Get file */
2587 ND_PRINT((ndo, " file"));
2588 INTOUT();
2589 break;
2590 case 20006: /* Send file */
2591 ND_PRINT((ndo, " file"));
2592 INTOUT();
2593 ND_PRINT((ndo, " length"));
2594 INTOUT();
2595 ND_PRINT((ndo, " dbversion"));
2596 UBIK_VERSIONOUT();
2597 break;
2598 case 20009: /* Truncate */
2599 ND_PRINT((ndo, " tid"));
2600 UBIK_VERSIONOUT();
2601 ND_PRINT((ndo, " file"));
2602 INTOUT();
2603 ND_PRINT((ndo, " length"));
2604 INTOUT();
2605 break;
2606 case 20012: /* Set version */
2607 ND_PRINT((ndo, " tid"));
2608 UBIK_VERSIONOUT();
2609 ND_PRINT((ndo, " oldversion"));
2610 UBIK_VERSIONOUT();
2611 ND_PRINT((ndo, " newversion"));
2612 UBIK_VERSIONOUT();
2613 break;
2614 default:
2615 ;
2616 }
2617
2618 return;
2619
2620 trunc:
2621 ND_PRINT((ndo, " [|ubik]"));
2622 }
2623
2624 /*
2625 * Handle Ubik replies to any one of the replicated database services
2626 */
2627
2628 static void
2629 ubik_reply_print(netdissect_options *ndo,
2630 register const u_char *bp, int length, int32_t opcode)
2631 {
2632 const struct rx_header *rxh;
2633
2634 if (length < (int)sizeof(struct rx_header))
2635 return;
2636
2637 rxh = (const struct rx_header *) bp;
2638
2639 /*
2640 * Print out the ubik call we're invoking. This table was gleaned
2641 * from ubik/ubik_int.xg
2642 */
2643
2644 ND_PRINT((ndo, " ubik reply %s", tok2str(ubik_req, "op#%d", opcode)));
2645
2646 bp += sizeof(struct rx_header);
2647
2648 /*
2649 * If it was a data packet, print out the arguments to the Ubik calls
2650 */
2651
2652 if (rxh->type == RX_PACKET_TYPE_DATA)
2653 switch (opcode) {
2654 case 10000: /* Beacon */
2655 ND_PRINT((ndo, " vote no"));
2656 break;
2657 case 20004: /* Get version */
2658 ND_PRINT((ndo, " dbversion"));
2659 UBIK_VERSIONOUT();
2660 break;
2661 default:
2662 ;
2663 }
2664
2665 /*
2666 * Otherwise, print out "yes" it it was a beacon packet (because
2667 * that's how yes votes are returned, go figure), otherwise
2668 * just print out the error code.
2669 */
2670
2671 else
2672 switch (opcode) {
2673 case 10000: /* Beacon */
2674 ND_PRINT((ndo, " vote yes until"));
2675 DATEOUT();
2676 break;
2677 default:
2678 ND_PRINT((ndo, " errcode"));
2679 INTOUT();
2680 }
2681
2682 return;
2683
2684 trunc:
2685 ND_PRINT((ndo, " [|ubik]"));
2686 }
2687
2688 /*
2689 * Handle RX ACK packets.
2690 */
2691
2692 static void
2693 rx_ack_print(netdissect_options *ndo,
2694 register const u_char *bp, int length)
2695 {
2696 const struct rx_ackPacket *rxa;
2697 int i, start, last;
2698 uint32_t firstPacket;
2699
2700 if (length < (int)sizeof(struct rx_header))
2701 return;
2702
2703 bp += sizeof(struct rx_header);
2704
2705 /*
2706 * This may seem a little odd .... the rx_ackPacket structure
2707 * contains an array of individual packet acknowledgements
2708 * (used for selective ack/nack), but since it's variable in size,
2709 * we don't want to truncate based on the size of the whole
2710 * rx_ackPacket structure.
2711 */
2712
2713 ND_TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS);
2714
2715 rxa = (const struct rx_ackPacket *) bp;
2716 bp += (sizeof(struct rx_ackPacket) - RX_MAXACKS);
2717
2718 /*
2719 * Print out a few useful things from the ack packet structure
2720 */
2721
2722 if (ndo->ndo_vflag > 2)
2723 ND_PRINT((ndo, " bufspace %d maxskew %d",
2724 (int) EXTRACT_16BITS(&rxa->bufferSpace),
2725 (int) EXTRACT_16BITS(&rxa->maxSkew)));
2726
2727 firstPacket = EXTRACT_32BITS(&rxa->firstPacket);
2728 ND_PRINT((ndo, " first %d serial %d reason %s",
2729 firstPacket, EXTRACT_32BITS(&rxa->serial),
2730 tok2str(rx_ack_reasons, "#%d", (int) rxa->reason)));
2731
2732 /*
2733 * Okay, now we print out the ack array. The way _this_ works
2734 * is that we start at "first", and step through the ack array.
2735 * If we have a contiguous range of acks/nacks, try to
2736 * collapse them into a range.
2737 *
2738 * If you're really clever, you might have noticed that this
2739 * doesn't seem quite correct. Specifically, due to structure
2740 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2741 * yield the start of the ack array (because RX_MAXACKS is 255
2742 * and the structure will likely get padded to a 2 or 4 byte
2743 * boundary). However, this is the way it's implemented inside
2744 * of AFS - the start of the extra fields are at
2745 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2746 * the exact start of the ack array. Sigh. That's why we aren't
2747 * using bp, but instead use rxa->acks[]. But nAcks gets added
2748 * to bp after this, so bp ends up at the right spot. Go figure.
2749 */
2750
2751 if (rxa->nAcks != 0) {
2752
2753 ND_TCHECK2(bp[0], rxa->nAcks);
2754
2755 /*
2756 * Sigh, this is gross, but it seems to work to collapse
2757 * ranges correctly.
2758 */
2759
2760 for (i = 0, start = last = -2; i < rxa->nAcks; i++)
2761 if (rxa->acks[i] == RX_ACK_TYPE_ACK) {
2762
2763 /*
2764 * I figured this deserved _some_ explanation.
2765 * First, print "acked" and the packet seq
2766 * number if this is the first time we've
2767 * seen an acked packet.
2768 */
2769
2770 if (last == -2) {
2771 ND_PRINT((ndo, " acked %d", firstPacket + i));
2772 start = i;
2773 }
2774
2775 /*
2776 * Otherwise, if there is a skip in
2777 * the range (such as an nacked packet in
2778 * the middle of some acked packets),
2779 * then print the current packet number
2780 * seperated from the last number by
2781 * a comma.
2782 */
2783
2784 else if (last != i - 1) {
2785 ND_PRINT((ndo, ",%d", firstPacket + i));
2786 start = i;
2787 }
2788
2789 /*
2790 * We always set last to the value of
2791 * the last ack we saw. Conversely, start
2792 * is set to the value of the first ack
2793 * we saw in a range.
2794 */
2795
2796 last = i;
2797
2798 /*
2799 * Okay, this bit a code gets executed when
2800 * we hit a nack ... in _this_ case we
2801 * want to print out the range of packets
2802 * that were acked, so we need to print
2803 * the _previous_ packet number seperated
2804 * from the first by a dash (-). Since we
2805 * already printed the first packet above,
2806 * just print the final packet. Don't
2807 * do this if there will be a single-length
2808 * range.
2809 */
2810 } else if (last == i - 1 && start != last)
2811 ND_PRINT((ndo, "-%d", firstPacket + i - 1));
2812
2813 /*
2814 * So, what's going on here? We ran off the end of the
2815 * ack list, and if we got a range we need to finish it up.
2816 * So we need to determine if the last packet in the list
2817 * was an ack (if so, then last will be set to it) and
2818 * we need to see if the last range didn't start with the
2819 * last packet (because if it _did_, then that would mean
2820 * that the packet number has already been printed and
2821 * we don't need to print it again).
2822 */
2823
2824 if (last == i - 1 && start != last)
2825 ND_PRINT((ndo, "-%d", firstPacket + i - 1));
2826
2827 /*
2828 * Same as above, just without comments
2829 */
2830
2831 for (i = 0, start = last = -2; i < rxa->nAcks; i++)
2832 if (rxa->acks[i] == RX_ACK_TYPE_NACK) {
2833 if (last == -2) {
2834 ND_PRINT((ndo, " nacked %d", firstPacket + i));
2835 start = i;
2836 } else if (last != i - 1) {
2837 ND_PRINT((ndo, ",%d", firstPacket + i));
2838 start = i;
2839 }
2840 last = i;
2841 } else if (last == i - 1 && start != last)
2842 ND_PRINT((ndo, "-%d", firstPacket + i - 1));
2843
2844 if (last == i - 1 && start != last)
2845 ND_PRINT((ndo, "-%d", firstPacket + i - 1));
2846
2847 bp += rxa->nAcks;
2848 }
2849
2850
2851 /*
2852 * These are optional fields; depending on your version of AFS,
2853 * you may or may not see them
2854 */
2855
2856 #define TRUNCRET(n) if (ndo->ndo_snapend - bp + 1 <= n) return;
2857
2858 if (ndo->ndo_vflag > 1) {
2859 TRUNCRET(4);
2860 ND_PRINT((ndo, " ifmtu"));
2861 INTOUT();
2862
2863 TRUNCRET(4);
2864 ND_PRINT((ndo, " maxmtu"));
2865 INTOUT();
2866
2867 TRUNCRET(4);
2868 ND_PRINT((ndo, " rwind"));
2869 INTOUT();
2870
2871 TRUNCRET(4);
2872 ND_PRINT((ndo, " maxpackets"));
2873 INTOUT();
2874 }
2875
2876 return;
2877
2878 trunc:
2879 ND_PRINT((ndo, " [|ack]"));
2880 }
2881 #undef TRUNCRET