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