4 * Copyright: (c) 2000 United States Government as represented by the
5 * Secretary of the Navy. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. The names of the authors may not be used to endorse or promote
18 * products derived from this software without specific prior
21 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26 * This code unmangles RX packets. RX is the mutant form of RPC that AFS
27 * uses to communicate between clients and servers.
29 * In this code, I mainly concern myself with decoding the AFS calls, not
30 * with the guts of RX, per se.
32 * Bah. If I never look at rx_packet.h again, it will be too soon.
34 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
37 #include <sys/cdefs.h>
40 static const char rcsid
[] _U_
=
41 "@(#) Header: /tcpdump/master/tcpdump/print-rx.c,v 1.37.2.2 2007/06/15 19:43:15 guy Exp";
43 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
54 #include <tcpdump-stdinc.h>
56 #include "interface.h"
57 #include "addrtoname.h"
64 static struct tok rx_types
[] = {
65 { RX_PACKET_TYPE_DATA
, "data" },
66 { RX_PACKET_TYPE_ACK
, "ack" },
67 { RX_PACKET_TYPE_BUSY
, "busy" },
68 { RX_PACKET_TYPE_ABORT
, "abort" },
69 { RX_PACKET_TYPE_ACKALL
, "ackall" },
70 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
71 { RX_PACKET_TYPE_RESPONSE
, "response" },
72 { RX_PACKET_TYPE_DEBUG
, "debug" },
73 { RX_PACKET_TYPE_PARAMS
, "params" },
74 { RX_PACKET_TYPE_VERSION
, "version" },
78 static struct double_tok
{
79 int flag
; /* Rx flag */
80 int packetType
; /* Packet type */
81 const char *s
; /* Flag string */
83 { RX_CLIENT_INITIATED
, 0, "client-init" },
84 { RX_REQUEST_ACK
, 0, "req-ack" },
85 { RX_LAST_PACKET
, 0, "last-pckt" },
86 { RX_MORE_PACKETS
, 0, "more-pckts" },
87 { RX_FREE_PACKET
, 0, "free-pckt" },
88 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
89 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
92 static struct tok fs_req
[] = {
93 { 130, "fetch-data" },
95 { 132, "fetch-status" },
96 { 133, "store-data" },
98 { 135, "store-status" },
99 { 136, "remove-file" },
100 { 137, "create-file" },
106 { 143, "oldsetlock" },
107 { 144, "oldextlock" },
108 { 145, "oldrellock" },
109 { 146, "get-stats" },
111 { 148, "get-vlinfo" },
112 { 149, "get-vlstats" },
113 { 150, "set-vlstats" },
114 { 151, "get-rootvl" },
115 { 152, "check-token" },
117 { 154, "nget-vlinfo" },
118 { 155, "bulk-stat" },
122 { 159, "xstat-ver" },
123 { 160, "get-xstat" },
124 { 161, "dfs-lookup" },
125 { 162, "dfs-flushcps" },
126 { 163, "dfs-symlink" },
127 { 220, "residency" },
131 static struct tok cb_req
[] = {
140 { 212, "whoareyou" },
142 { 214, "probeuuid" },
143 { 215, "getsrvprefs" },
144 { 216, "getcellservdb" },
145 { 217, "getlocalcell" },
146 { 218, "getcacheconf" },
150 static struct tok pt_req
[] = {
152 { 501, "where-is-it" },
153 { 502, "dump-entry" },
154 { 503, "add-to-group" },
155 { 504, "name-to-id" },
156 { 505, "id-to-name" },
158 { 507, "remove-from-group" },
160 { 509, "new-entry" },
163 { 512, "list-entry" },
164 { 513, "change-entry" },
165 { 514, "list-elements" },
166 { 515, "same-mbr-of" },
167 { 516, "set-fld-sentry" },
168 { 517, "list-owned" },
170 { 519, "get-host-cps" },
171 { 520, "update-entry" },
172 { 521, "list-entries" },
176 static struct tok vldb_req
[] = {
177 { 501, "create-entry" },
178 { 502, "delete-entry" },
179 { 503, "get-entry-by-id" },
180 { 504, "get-entry-by-name" },
181 { 505, "get-new-volume-id" },
182 { 506, "replace-entry" },
183 { 507, "update-entry" },
185 { 509, "releaselock" },
186 { 510, "list-entry" },
187 { 511, "list-attrib" },
188 { 512, "linked-list" },
189 { 513, "get-stats" },
191 { 515, "get-addrs" },
192 { 516, "change-addr" },
193 { 517, "create-entry-n" },
194 { 518, "get-entry-by-id-n" },
195 { 519, "get-entry-by-name-n" },
196 { 520, "replace-entry-n" },
197 { 521, "list-entry-n" },
198 { 522, "list-attrib-n" },
199 { 523, "linked-list-n" },
200 { 524, "update-entry-by-name" },
201 { 525, "create-entry-u" },
202 { 526, "get-entry-by-id-u" },
203 { 527, "get-entry-by-name-u" },
204 { 528, "replace-entry-u" },
205 { 529, "list-entry-u" },
206 { 530, "list-attrib-u" },
207 { 531, "linked-list-u" },
209 { 533, "get-addrs-u" },
210 { 534, "list-attrib-n2" },
214 static struct tok kauth_req
[] = {
216 { 21, "authenticate" },
217 { 22, "authenticate-v2" },
219 { 3, "get-ticket-old" },
220 { 23, "get-ticket" },
223 { 6, "create-user" },
224 { 7, "delete-user" },
230 { 13, "get-random-key" },
232 { 15, "lock-status" },
236 static struct tok vol_req
[] = {
237 { 100, "create-volume" },
238 { 101, "delete-volume" },
241 { 104, "end-trans" },
243 { 106, "set-flags" },
244 { 107, "get-flags" },
245 { 108, "trans-create" },
247 { 110, "get-nth-volume" },
248 { 111, "set-forwarding" },
250 { 113, "get-status" },
251 { 114, "sig-restore" },
252 { 115, "list-partitions" },
253 { 116, "list-volumes" },
254 { 117, "set-id-types" },
256 { 119, "partition-info" },
258 { 121, "list-one-volume" },
261 { 124, "x-list-volumes" },
262 { 125, "x-list-one-volume" },
264 { 127, "x-list-partitions" },
265 { 128, "forward-multiple" },
269 static struct tok bos_req
[] = {
270 { 80, "create-bnode" },
271 { 81, "delete-bnode" },
272 { 82, "set-status" },
273 { 83, "get-status" },
274 { 84, "enumerate-instance" },
275 { 85, "get-instance-info" },
276 { 86, "get-instance-parm" },
277 { 87, "add-superuser" },
278 { 88, "delete-superuser" },
279 { 89, "list-superusers" },
282 { 92, "delete-key" },
283 { 93, "set-cell-name" },
284 { 94, "get-cell-name" },
285 { 95, "get-cell-host" },
286 { 96, "add-cell-host" },
287 { 97, "delete-cell-host" },
288 { 98, "set-t-status" },
289 { 99, "shutdown-all" },
290 { 100, "restart-all" },
291 { 101, "startup-all" },
292 { 102, "set-noauth-flag" },
295 { 105, "start-bozo-install" },
296 { 106, "uninstall" },
297 { 107, "get-dates" },
300 { 110, "set-restart-time" },
301 { 111, "get-restart-time" },
302 { 112, "start-bozo-log" },
304 { 114, "get-instance-strings" },
305 { 115, "get-restricted" },
306 { 116, "set-restricted" },
310 static struct tok ubik_req
[] = {
311 { 10000, "vote-beacon" },
312 { 10001, "vote-debug-old" },
313 { 10002, "vote-sdebug-old" },
314 { 10003, "vote-getsyncsite" },
315 { 10004, "vote-debug" },
316 { 10005, "vote-sdebug" },
317 { 20000, "disk-begin" },
318 { 20001, "disk-commit" },
319 { 20002, "disk-lock" },
320 { 20003, "disk-write" },
321 { 20004, "disk-getversion" },
322 { 20005, "disk-getfile" },
323 { 20006, "disk-sendfile" },
324 { 20007, "disk-abort" },
325 { 20008, "disk-releaselocks" },
326 { 20009, "disk-truncate" },
327 { 20010, "disk-probe" },
328 { 20011, "disk-writev" },
329 { 20012, "disk-interfaceaddr" },
330 { 20013, "disk-setversion" },
334 #define VOTE_LOW 10000
335 #define VOTE_HIGH 10005
336 #define DISK_LOW 20000
337 #define DISK_HIGH 20013
339 static struct tok cb_types
[] = {
346 static struct tok ubik_lock_types
[] = {
353 static const char *voltype
[] = { "read-write", "read-only", "backup" };
355 static struct tok afs_fs_errors
[] = {
356 { 101, "salvage volume" },
357 { 102, "no such vnode" },
358 { 103, "no such volume" },
359 { 104, "volume exist" },
360 { 105, "no service" },
361 { 106, "volume offline" },
362 { 107, "voline online" },
364 { 109, "diskquota exceeded" },
365 { 110, "volume busy" },
366 { 111, "volume moved" },
367 { 112, "AFS IO error" },
368 { -100, "restarting fileserver" },
373 * Reasons for acknowledging a packet
376 static struct tok rx_ack_reasons
[] = {
377 { 1, "ack requested" },
378 { 2, "duplicate packet" },
379 { 3, "out of sequence" },
380 { 4, "exceeds window" },
381 { 5, "no buffer space" },
383 { 7, "ping response" },
390 * Cache entries we keep around so we can figure out the RX opcode
391 * numbers for replies. This allows us to make sense of RX reply packets.
394 struct rx_cache_entry
{
395 u_int32_t callnum
; /* Call number (net order) */
396 struct in_addr client
; /* client IP address (net order) */
397 struct in_addr server
; /* server IP address (net order) */
398 int dport
; /* server port (host order) */
399 u_short serviceId
; /* Service identifier (net order) */
400 u_int32_t opcode
; /* RX opcode (host order) */
403 #define RX_CACHE_SIZE 64
405 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
407 static int rx_cache_next
= 0;
408 static int rx_cache_hint
= 0;
409 static void rx_cache_insert(const u_char
*, const struct ip
*, int);
410 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
413 static void fs_print(const u_char
*, int);
414 static void fs_reply_print(const u_char
*, int, int32_t);
415 static void acl_print(u_char
*, int, u_char
*);
416 static void cb_print(const u_char
*, int);
417 static void cb_reply_print(const u_char
*, int, int32_t);
418 static void prot_print(const u_char
*, int);
419 static void prot_reply_print(const u_char
*, int, int32_t);
420 static void vldb_print(const u_char
*, int);
421 static void vldb_reply_print(const u_char
*, int, int32_t);
422 static void kauth_print(const u_char
*, int);
423 static void kauth_reply_print(const u_char
*, int, int32_t);
424 static void vol_print(const u_char
*, int);
425 static void vol_reply_print(const u_char
*, int, int32_t);
426 static void bos_print(const u_char
*, int);
427 static void bos_reply_print(const u_char
*, int, int32_t);
428 static void ubik_print(const u_char
*);
429 static void ubik_reply_print(const u_char
*, int, int32_t);
431 static void rx_ack_print(const u_char
*, int);
433 static int is_ubik(u_int32_t
);
436 * Handle the rx-level packet. See if we know what port it's going to so
437 * we can peek at the afs call inside
441 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
444 register struct rx_header
*rxh
;
448 if (snapend
- bp
< (int)sizeof (struct rx_header
)) {
449 printf(" [|rx] (%d)", length
);
453 rxh
= (struct rx_header
*) bp
;
455 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
461 printf(" cid %08x call# %d",
462 (int) EXTRACT_32BITS(&rxh
->cid
),
463 (int) EXTRACT_32BITS(&rxh
->callNumber
));
465 printf(" seq %d ser %d",
466 (int) EXTRACT_32BITS(&rxh
->seq
),
467 (int) EXTRACT_32BITS(&rxh
->serial
));
470 printf(" secindex %d serviceid %hu",
471 (int) rxh
->securityIndex
,
472 EXTRACT_16BITS(&rxh
->serviceId
));
475 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
476 if (rxh
->flags
& rx_flags
[i
].flag
&&
477 (!rx_flags
[i
].packetType
||
478 rxh
->type
== rx_flags
[i
].packetType
)) {
485 printf("<%s>", rx_flags
[i
].s
);
491 * Try to handle AFS calls that we know about. Check the destination
492 * port and make sure it's a data packet. Also, make sure the
493 * seq number is 1 (because otherwise it's a continuation packet,
494 * and we can't interpret that). Also, seems that reply packets
495 * do not have the client-init flag set, so we check for that
499 if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
500 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
501 rxh
->flags
& RX_CLIENT_INITIATED
) {
504 * Insert this call into the call cache table, so we
505 * have a chance to print out replies
508 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
);
511 case FS_RX_PORT
: /* AFS file service */
512 fs_print(bp
, length
);
514 case CB_RX_PORT
: /* AFS callback service */
515 cb_print(bp
, length
);
517 case PROT_RX_PORT
: /* AFS protection service */
518 prot_print(bp
, length
);
520 case VLDB_RX_PORT
: /* AFS VLDB service */
521 vldb_print(bp
, length
);
523 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
524 kauth_print(bp
, length
);
526 case VOL_RX_PORT
: /* AFS Volume service */
527 vol_print(bp
, length
);
529 case BOS_RX_PORT
: /* AFS BOS service */
530 bos_print(bp
, length
);
537 * If it's a reply (client-init is _not_ set, but seq is one)
538 * then look it up in the cache. If we find it, call the reply
539 * printing functions Note that we handle abort packets here,
540 * because printing out the return code can be useful at times.
543 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
544 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
545 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
546 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
547 rx_cache_find(rxh
, (const struct ip
*) bp2
,
551 case FS_RX_PORT
: /* AFS file service */
552 fs_reply_print(bp
, length
, opcode
);
554 case CB_RX_PORT
: /* AFS callback service */
555 cb_reply_print(bp
, length
, opcode
);
557 case PROT_RX_PORT
: /* AFS PT service */
558 prot_reply_print(bp
, length
, opcode
);
560 case VLDB_RX_PORT
: /* AFS VLDB service */
561 vldb_reply_print(bp
, length
, opcode
);
563 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
564 kauth_reply_print(bp
, length
, opcode
);
566 case VOL_RX_PORT
: /* AFS Volume service */
567 vol_reply_print(bp
, length
, opcode
);
569 case BOS_RX_PORT
: /* AFS BOS service */
570 bos_reply_print(bp
, length
, opcode
);
577 * If it's an RX ack packet, then use the appropriate ack decoding
578 * function (there isn't any service-specific information in the
579 * ack packet, so we can use one for all AFS services)
582 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
583 rx_ack_print(bp
, length
);
586 printf(" (%d)", length
);
590 * Insert an entry into the cache. Taken from print-nfs.c
594 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
)
596 struct rx_cache_entry
*rxent
;
597 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
599 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t)))
602 rxent
= &rx_cache
[rx_cache_next
];
604 if (++rx_cache_next
>= RX_CACHE_SIZE
)
607 rxent
->callnum
= rxh
->callNumber
;
608 rxent
->client
= ip
->ip_src
;
609 rxent
->server
= ip
->ip_dst
;
610 rxent
->dport
= dport
;
611 rxent
->serviceId
= rxh
->serviceId
;
612 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
616 * Lookup an entry in the cache. Also taken from print-nfs.c
618 * Note that because this is a reply, we're looking at the _source_
623 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
627 struct rx_cache_entry
*rxent
;
628 u_int32_t clip
= ip
->ip_dst
.s_addr
;
629 u_int32_t sip
= ip
->ip_src
.s_addr
;
631 /* Start the search where we last left off */
635 rxent
= &rx_cache
[i
];
636 if (rxent
->callnum
== rxh
->callNumber
&&
637 rxent
->client
.s_addr
== clip
&&
638 rxent
->server
.s_addr
== sip
&&
639 rxent
->serviceId
== rxh
->serviceId
&&
640 rxent
->dport
== sport
) {
642 /* We got a match! */
645 *opcode
= rxent
->opcode
;
648 if (++i
> RX_CACHE_SIZE
)
650 } while (i
!= rx_cache_hint
);
652 /* Our search failed */
657 * These extrememly grody macros handle the printing of various AFS stuff.
660 #define FIDOUT() { unsigned long n1, n2, n3; \
661 TCHECK2(bp[0], sizeof(int32_t) * 3); \
662 n1 = EXTRACT_32BITS(bp); \
663 bp += sizeof(int32_t); \
664 n2 = EXTRACT_32BITS(bp); \
665 bp += sizeof(int32_t); \
666 n3 = EXTRACT_32BITS(bp); \
667 bp += sizeof(int32_t); \
668 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
671 #define STROUT(MAX) { unsigned int i; \
672 TCHECK2(bp[0], sizeof(int32_t)); \
673 i = EXTRACT_32BITS(bp); \
676 bp += sizeof(int32_t); \
678 if (fn_printn(bp, i, snapend)) \
681 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
684 #define INTOUT() { int i; \
685 TCHECK2(bp[0], sizeof(int32_t)); \
686 i = (int) EXTRACT_32BITS(bp); \
687 bp += sizeof(int32_t); \
691 #define UINTOUT() { unsigned long i; \
692 TCHECK2(bp[0], sizeof(int32_t)); \
693 i = EXTRACT_32BITS(bp); \
694 bp += sizeof(int32_t); \
698 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
699 TCHECK2(bp[0], sizeof(int32_t)); \
700 t = (time_t) EXTRACT_32BITS(bp); \
701 bp += sizeof(int32_t); \
702 tm = localtime(&t); \
703 strftime(str, 256, "%Y/%m/%d %T", tm); \
704 printf(" %s", str); \
707 #define STOREATTROUT() { unsigned long mask, i; \
708 TCHECK2(bp[0], (sizeof(int32_t)*6)); \
709 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
710 if (mask) printf (" StoreStatus"); \
711 if (mask & 1) { printf(" date"); DATEOUT(); } \
712 else bp += sizeof(int32_t); \
713 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
714 if (mask & 2) printf(" owner %lu", i); \
715 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
716 if (mask & 4) printf(" group %lu", i); \
717 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
718 if (mask & 8) printf(" mode %lo", i & 07777); \
719 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
720 if (mask & 16) printf(" segsize %lu", i); \
721 /* undocumented in 3.3 docu */ \
722 if (mask & 1024) printf(" fsync"); \
725 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
726 TCHECK2(bp[0], sizeof(int32_t) * 2); \
727 epoch = EXTRACT_32BITS(bp); \
728 bp += sizeof(int32_t); \
729 counter = EXTRACT_32BITS(bp); \
730 bp += sizeof(int32_t); \
731 printf(" %d.%d", epoch, counter); \
734 #define AFSUUIDOUT() {u_int32_t temp; int i; \
735 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
736 temp = EXTRACT_32BITS(bp); \
737 bp += sizeof(u_int32_t); \
738 printf(" %08x", temp); \
739 temp = EXTRACT_32BITS(bp); \
740 bp += sizeof(u_int32_t); \
741 printf("%04x", temp); \
742 temp = EXTRACT_32BITS(bp); \
743 bp += sizeof(u_int32_t); \
744 printf("%04x", temp); \
745 for (i = 0; i < 8; i++) { \
746 temp = EXTRACT_32BITS(bp); \
747 bp += sizeof(u_int32_t); \
748 printf("%02x", (unsigned char) temp); \
753 * This is the sickest one of all
756 #define VECOUT(MAX) { u_char *sp; \
757 u_char s[AFSNAMEMAX]; \
759 if ((MAX) + 1 > sizeof(s)) \
761 TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
763 for (k = 0; k < (MAX); k++) { \
764 *sp++ = (u_char) EXTRACT_32BITS(bp); \
765 bp += sizeof(int32_t); \
774 * Handle calls to the AFS file service (fs)
778 fs_print(register const u_char
*bp
, int length
)
783 if (length
<= (int)sizeof(struct rx_header
))
786 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
791 * Print out the afs call we're invoking. The table used here was
792 * gleaned from fsint/afsint.xg
795 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
797 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
800 * Print out arguments to some of the AFS calls. This stuff is
804 bp
+= sizeof(struct rx_header
) + 4;
807 * Sigh. This is gross. Ritchie forgive me.
811 case 130: /* Fetch data */
818 case 131: /* Fetch ACL */
819 case 132: /* Fetch Status */
820 case 143: /* Old set lock */
821 case 144: /* Old extend lock */
822 case 145: /* Old release lock */
823 case 156: /* Set lock */
824 case 157: /* Extend lock */
825 case 158: /* Release lock */
828 case 135: /* Store status */
832 case 133: /* Store data */
842 case 134: /* Store ACL */
844 char a
[AFSOPAQUEMAX
+1];
847 i
= EXTRACT_32BITS(bp
);
848 bp
+= sizeof(int32_t);
850 i
= min(AFSOPAQUEMAX
, i
);
851 strncpy(a
, (char *) bp
, i
);
853 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
856 case 137: /* Create file */
857 case 141: /* MakeDir */
862 case 136: /* Remove file */
863 case 142: /* Remove directory */
867 case 138: /* Rename file */
875 case 139: /* Symlink */
887 case 148: /* Get volume info */
890 case 149: /* Get volume stats */
891 case 150: /* Set volume stats */
895 case 154: /* New get volume info */
899 case 155: /* Bulk stat */
903 j
= EXTRACT_32BITS(bp
);
904 bp
+= sizeof(int32_t);
906 for (i
= 0; i
< j
; i
++) {
925 * Handle replies to the AFS file service
929 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
932 struct rx_header
*rxh
;
934 if (length
<= (int)sizeof(struct rx_header
))
937 rxh
= (struct rx_header
*) bp
;
940 * Print out the afs call we're invoking. The table used here was
941 * gleaned from fsint/afsint.xg
944 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
946 bp
+= sizeof(struct rx_header
);
949 * If it was a data packet, interpret the response
952 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
954 case 131: /* Fetch ACL */
956 char a
[AFSOPAQUEMAX
+1];
958 i
= EXTRACT_32BITS(bp
);
959 bp
+= sizeof(int32_t);
961 i
= min(AFSOPAQUEMAX
, i
);
962 strncpy(a
, (char *) bp
, i
);
964 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
967 case 137: /* Create file */
968 case 141: /* MakeDir */
972 case 151: /* Get root volume */
973 printf(" root volume");
976 case 153: /* Get time */
982 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
986 * Otherwise, just print out the return code
988 TCHECK2(bp
[0], sizeof(int32_t));
989 i
= (int) EXTRACT_32BITS(bp
);
990 bp
+= sizeof(int32_t);
992 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
994 printf(" strange fs reply of type %d", rxh
->type
);
1004 * Print out an AFS ACL string. An AFS ACL is a string that has the
1007 * <positive> <negative>
1011 * "positive" and "negative" are integers which contain the number of
1012 * positive and negative ACL's in the string. The uid/aclbits pair are
1013 * ASCII strings containing the UID/PTS record and and a ascii number
1014 * representing a logical OR of all the ACL permission bits
1018 acl_print(u_char
*s
, int maxsize
, u_char
*end
)
1025 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1028 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1037 * This wacky order preserves the order used by the "fs" command
1040 #define ACLOUT(acl) \
1041 if (acl & PRSFS_READ) \
1043 if (acl & PRSFS_LOOKUP) \
1045 if (acl & PRSFS_INSERT) \
1047 if (acl & PRSFS_DELETE) \
1049 if (acl & PRSFS_WRITE) \
1051 if (acl & PRSFS_LOCK) \
1053 if (acl & PRSFS_ADMINISTER) \
1056 for (i
= 0; i
< pos
; i
++) {
1057 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1058 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1062 fn_print((u_char
*)user
, NULL
);
1070 for (i
= 0; i
< neg
; i
++) {
1071 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1072 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1076 fn_print((u_char
*)user
, NULL
);
1092 * Handle calls to the AFS callback service
1096 cb_print(register const u_char
*bp
, int length
)
1101 if (length
<= (int)sizeof(struct rx_header
))
1104 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1109 * Print out the afs call we're invoking. The table used here was
1110 * gleaned from fsint/afscbint.xg
1113 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1115 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1117 bp
+= sizeof(struct rx_header
) + 4;
1120 * Print out the afs call we're invoking. The table used here was
1121 * gleaned from fsint/afscbint.xg
1125 case 204: /* Callback */
1129 j
= EXTRACT_32BITS(bp
);
1130 bp
+= sizeof(int32_t);
1132 for (i
= 0; i
< j
; i
++) {
1141 j
= EXTRACT_32BITS(bp
);
1142 bp
+= sizeof(int32_t);
1147 for (i
= 0; i
< j
; i
++) {
1153 t
= EXTRACT_32BITS(bp
);
1154 bp
+= sizeof(int32_t);
1155 tok2str(cb_types
, "type %d", t
);
1174 * Handle replies to the AFS Callback Service
1178 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1180 struct rx_header
*rxh
;
1182 if (length
<= (int)sizeof(struct rx_header
))
1185 rxh
= (struct rx_header
*) bp
;
1188 * Print out the afs call we're invoking. The table used here was
1189 * gleaned from fsint/afscbint.xg
1192 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1194 bp
+= sizeof(struct rx_header
);
1197 * If it was a data packet, interpret the response.
1200 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1202 case 213: /* InitCallBackState3 */
1210 * Otherwise, just print out the return code
1223 * Handle calls to the AFS protection database server
1227 prot_print(register const u_char
*bp
, int length
)
1232 if (length
<= (int)sizeof(struct rx_header
))
1235 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1240 * Print out the afs call we're invoking. The table used here was
1241 * gleaned from ptserver/ptint.xg
1244 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1248 if (is_ubik(pt_op
)) {
1253 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1256 * Decode some of the arguments to the PT calls
1259 bp
+= sizeof(struct rx_header
) + 4;
1262 case 500: /* I New User */
1269 case 501: /* Where is it */
1270 case 506: /* Delete */
1271 case 508: /* Get CPS */
1272 case 512: /* List entry */
1273 case 514: /* List elements */
1274 case 517: /* List owned */
1275 case 518: /* Get CPS2 */
1276 case 519: /* Get host CPS */
1280 case 502: /* Dump entry */
1284 case 503: /* Add to group */
1285 case 507: /* Remove from group */
1286 case 515: /* Is a member of? */
1292 case 504: /* Name to ID */
1296 j
= EXTRACT_32BITS(bp
);
1297 bp
+= sizeof(int32_t);
1300 * Who designed this chicken-shit protocol?
1302 * Each character is stored as a 32-bit
1306 for (i
= 0; i
< j
; i
++) {
1313 case 505: /* Id to name */
1318 i
= EXTRACT_32BITS(bp
);
1319 bp
+= sizeof(int32_t);
1320 for (j
= 0; j
< i
; j
++)
1326 case 509: /* New entry */
1333 case 511: /* Set max */
1339 case 513: /* Change entry */
1348 case 520: /* Update entry */
1365 * Handle replies to the AFS protection service
1369 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1371 struct rx_header
*rxh
;
1374 if (length
< (int)sizeof(struct rx_header
))
1377 rxh
= (struct rx_header
*) bp
;
1380 * Print out the afs call we're invoking. The table used here was
1381 * gleaned from ptserver/ptint.xg. Check to see if it's a
1382 * Ubik call, however.
1387 if (is_ubik(opcode
)) {
1388 ubik_reply_print(bp
, length
, opcode
);
1392 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1394 bp
+= sizeof(struct rx_header
);
1397 * If it was a data packet, interpret the response
1400 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1402 case 504: /* Name to ID */
1407 i
= EXTRACT_32BITS(bp
);
1408 bp
+= sizeof(int32_t);
1409 for (j
= 0; j
< i
; j
++)
1415 case 505: /* ID to name */
1419 j
= EXTRACT_32BITS(bp
);
1420 bp
+= sizeof(int32_t);
1423 * Who designed this chicken-shit protocol?
1425 * Each character is stored as a 32-bit
1429 for (i
= 0; i
< j
; i
++) {
1436 case 508: /* Get CPS */
1437 case 514: /* List elements */
1438 case 517: /* List owned */
1439 case 518: /* Get CPS2 */
1440 case 519: /* Get host CPS */
1444 j
= EXTRACT_32BITS(bp
);
1445 bp
+= sizeof(int32_t);
1446 for (i
= 0; i
< j
; i
++) {
1453 case 510: /* List max */
1464 * Otherwise, just print out the return code
1477 * Handle calls to the AFS volume location database service
1481 vldb_print(register const u_char
*bp
, int length
)
1486 if (length
<= (int)sizeof(struct rx_header
))
1489 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1494 * Print out the afs call we're invoking. The table used here was
1495 * gleaned from vlserver/vldbint.xg
1498 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1502 if (is_ubik(vldb_op
)) {
1506 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1509 * Decode some of the arguments to the VLDB calls
1512 bp
+= sizeof(struct rx_header
) + 4;
1515 case 501: /* Create new volume */
1516 case 517: /* Create entry N */
1519 case 502: /* Delete entry */
1520 case 503: /* Get entry by ID */
1521 case 507: /* Update entry */
1522 case 508: /* Set lock */
1523 case 509: /* Release lock */
1524 case 518: /* Get entry by ID N */
1527 TCHECK2(bp
[0], sizeof(int32_t));
1528 i
= EXTRACT_32BITS(bp
);
1529 bp
+= sizeof(int32_t);
1531 printf(" type %s", voltype
[i
]);
1533 case 504: /* Get entry by name */
1534 case 519: /* Get entry by name N */
1535 case 524: /* Update entry by name */
1536 case 527: /* Get entry by name U */
1539 case 505: /* Get new vol id */
1543 case 506: /* Replace entry */
1544 case 520: /* Replace entry N */
1547 TCHECK2(bp
[0], sizeof(int32_t));
1548 i
= EXTRACT_32BITS(bp
);
1549 bp
+= sizeof(int32_t);
1551 printf(" type %s", voltype
[i
]);
1554 case 510: /* List entry */
1555 case 521: /* List entry N */
1570 * Handle replies to the AFS volume location database service
1574 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1576 struct rx_header
*rxh
;
1579 if (length
< (int)sizeof(struct rx_header
))
1582 rxh
= (struct rx_header
*) bp
;
1585 * Print out the afs call we're invoking. The table used here was
1586 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1587 * Ubik call, however.
1592 if (is_ubik(opcode
)) {
1593 ubik_reply_print(bp
, length
, opcode
);
1597 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1599 bp
+= sizeof(struct rx_header
);
1602 * If it was a data packet, interpret the response
1605 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1607 case 510: /* List entry */
1610 printf(" nextindex");
1612 case 503: /* Get entry by id */
1613 case 504: /* Get entry by name */
1614 { unsigned long nservers
, j
;
1616 TCHECK2(bp
[0], sizeof(int32_t));
1617 bp
+= sizeof(int32_t);
1618 printf(" numservers");
1619 TCHECK2(bp
[0], sizeof(int32_t));
1620 nservers
= EXTRACT_32BITS(bp
);
1621 bp
+= sizeof(int32_t);
1622 printf(" %lu", nservers
);
1624 for (i
= 0; i
< 8; i
++) {
1625 TCHECK2(bp
[0], sizeof(int32_t));
1628 intoa(((struct in_addr
*) bp
)->s_addr
));
1629 bp
+= sizeof(int32_t);
1631 printf(" partitions");
1632 for (i
= 0; i
< 8; i
++) {
1633 TCHECK2(bp
[0], sizeof(int32_t));
1634 j
= EXTRACT_32BITS(bp
);
1635 if (i
< nservers
&& j
<= 26)
1636 printf(" %c", 'a' + (int)j
);
1637 else if (i
< nservers
)
1639 bp
+= sizeof(int32_t);
1641 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1642 bp
+= 8 * sizeof(int32_t);
1651 case 505: /* Get new volume ID */
1655 case 521: /* List entry */
1656 case 529: /* List entry U */
1659 printf(" nextindex");
1661 case 518: /* Get entry by ID N */
1662 case 519: /* Get entry by name N */
1663 { unsigned long nservers
, j
;
1665 printf(" numservers");
1666 TCHECK2(bp
[0], sizeof(int32_t));
1667 nservers
= EXTRACT_32BITS(bp
);
1668 bp
+= sizeof(int32_t);
1669 printf(" %lu", nservers
);
1671 for (i
= 0; i
< 13; i
++) {
1672 TCHECK2(bp
[0], sizeof(int32_t));
1675 intoa(((struct in_addr
*) bp
)->s_addr
));
1676 bp
+= sizeof(int32_t);
1678 printf(" partitions");
1679 for (i
= 0; i
< 13; i
++) {
1680 TCHECK2(bp
[0], sizeof(int32_t));
1681 j
= EXTRACT_32BITS(bp
);
1682 if (i
< nservers
&& j
<= 26)
1683 printf(" %c", 'a' + (int)j
);
1684 else if (i
< nservers
)
1686 bp
+= sizeof(int32_t);
1688 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1689 bp
+= 13 * sizeof(int32_t);
1698 case 526: /* Get entry by ID U */
1699 case 527: /* Get entry by name U */
1700 { unsigned long nservers
, j
;
1702 printf(" numservers");
1703 TCHECK2(bp
[0], sizeof(int32_t));
1704 nservers
= EXTRACT_32BITS(bp
);
1705 bp
+= sizeof(int32_t);
1706 printf(" %lu", nservers
);
1708 for (i
= 0; i
< 13; i
++) {
1717 TCHECK2(bp
[0], 4 * 13);
1719 printf(" partitions");
1720 for (i
= 0; i
< 13; i
++) {
1721 TCHECK2(bp
[0], sizeof(int32_t));
1722 j
= EXTRACT_32BITS(bp
);
1723 if (i
< nservers
&& j
<= 26)
1724 printf(" %c", 'a' + (int)j
);
1725 else if (i
< nservers
)
1727 bp
+= sizeof(int32_t);
1729 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1730 bp
+= 13 * sizeof(int32_t);
1744 * Otherwise, just print out the return code
1757 * Handle calls to the AFS Kerberos Authentication service
1761 kauth_print(register const u_char
*bp
, int length
)
1765 if (length
<= (int)sizeof(struct rx_header
))
1768 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1773 * Print out the afs call we're invoking. The table used here was
1774 * gleaned from kauth/kauth.rg
1777 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1781 if (is_ubik(kauth_op
)) {
1787 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1790 * Decode some of the arguments to the KA calls
1793 bp
+= sizeof(struct rx_header
) + 4;
1796 case 1: /* Authenticate old */;
1797 case 21: /* Authenticate */
1798 case 22: /* Authenticate-V2 */
1799 case 2: /* Change PW */
1800 case 5: /* Set fields */
1801 case 6: /* Create user */
1802 case 7: /* Delete user */
1803 case 8: /* Get entry */
1804 case 14: /* Unlock */
1805 case 15: /* Lock status */
1806 printf(" principal");
1810 case 3: /* GetTicket-old */
1811 case 23: /* GetTicket */
1818 TCHECK2(bp
[0], sizeof(int32_t));
1819 i
= (int) EXTRACT_32BITS(bp
);
1820 bp
+= sizeof(int32_t);
1823 printf(" principal");
1828 case 4: /* Set Password */
1829 printf(" principal");
1835 case 12: /* Get password */
1846 printf(" [|kauth]");
1850 * Handle replies to the AFS Kerberos Authentication Service
1854 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1856 struct rx_header
*rxh
;
1858 if (length
<= (int)sizeof(struct rx_header
))
1861 rxh
= (struct rx_header
*) bp
;
1864 * Print out the afs call we're invoking. The table used here was
1865 * gleaned from kauth/kauth.rg
1870 if (is_ubik(opcode
)) {
1871 ubik_reply_print(bp
, length
, opcode
);
1875 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1877 bp
+= sizeof(struct rx_header
);
1880 * If it was a data packet, interpret the response.
1883 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1884 /* Well, no, not really. Leave this for later */
1888 * Otherwise, just print out the return code
1897 printf(" [|kauth]");
1901 * Handle calls to the AFS Volume location service
1905 vol_print(register const u_char
*bp
, int length
)
1909 if (length
<= (int)sizeof(struct rx_header
))
1912 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1917 * Print out the afs call we're invoking. The table used here was
1918 * gleaned from volser/volint.xg
1921 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1923 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1926 * Normally there would be a switch statement here to decode the
1927 * arguments to the AFS call, but since I don't have access to
1928 * an AFS server (yet) and I'm not an AFS admin, I can't
1929 * test any of these calls. Leave this blank for now.
1939 * Handle replies to the AFS Volume Service
1943 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1945 struct rx_header
*rxh
;
1947 if (length
<= (int)sizeof(struct rx_header
))
1950 rxh
= (struct rx_header
*) bp
;
1953 * Print out the afs call we're invoking. The table used here was
1954 * gleaned from volser/volint.xg
1957 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
1959 bp
+= sizeof(struct rx_header
);
1962 * If it was a data packet, interpret the response.
1965 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1966 /* Well, no, not really. Leave this for later */
1970 * Otherwise, just print out the return code
1983 * Handle calls to the AFS BOS service
1987 bos_print(register const u_char
*bp
, int length
)
1991 if (length
<= (int)sizeof(struct rx_header
))
1994 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1999 * Print out the afs call we're invoking. The table used here was
2000 * gleaned from bozo/bosint.xg
2003 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2005 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2008 * Decode some of the arguments to the BOS calls
2011 bp
+= sizeof(struct rx_header
) + 4;
2014 case 80: /* Create B node */
2017 printf(" instance");
2020 case 81: /* Delete B node */
2021 case 83: /* Get status */
2022 case 85: /* Get instance info */
2023 case 87: /* Add super user */
2024 case 88: /* Delete super user */
2025 case 93: /* Set cell name */
2026 case 96: /* Add cell host */
2027 case 97: /* Delete cell host */
2028 case 104: /* Restart */
2029 case 106: /* Uninstall */
2030 case 108: /* Exec */
2031 case 112: /* Getlog */
2032 case 114: /* Get instance strings */
2035 case 82: /* Set status */
2036 case 98: /* Set T status */
2041 case 86: /* Get instance parm */
2046 case 84: /* Enumerate instance */
2047 case 89: /* List super users */
2048 case 90: /* List keys */
2049 case 91: /* Add key */
2050 case 92: /* Delete key */
2051 case 95: /* Get cell host */
2054 case 105: /* Install */
2074 * Handle replies to the AFS BOS Service
2078 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2080 struct rx_header
*rxh
;
2082 if (length
<= (int)sizeof(struct rx_header
))
2085 rxh
= (struct rx_header
*) bp
;
2088 * Print out the afs call we're invoking. The table used here was
2089 * gleaned from volser/volint.xg
2092 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2094 bp
+= sizeof(struct rx_header
);
2097 * If it was a data packet, interpret the response.
2100 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2101 /* Well, no, not really. Leave this for later */
2105 * Otherwise, just print out the return code
2118 * Check to see if this is a Ubik opcode.
2122 is_ubik(u_int32_t opcode
)
2124 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2125 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2132 * Handle Ubik opcodes to any one of the replicated database services
2136 ubik_print(register const u_char
*bp
)
2142 * Print out the afs call we're invoking. The table used here was
2143 * gleaned from ubik/ubik_int.xg
2146 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2148 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2151 * Decode some of the arguments to the Ubik calls
2154 bp
+= sizeof(struct rx_header
) + 4;
2157 case 10000: /* Beacon */
2159 temp
= EXTRACT_32BITS(bp
);
2160 bp
+= sizeof(int32_t);
2161 printf(" syncsite %s", temp
? "yes" : "no");
2162 printf(" votestart");
2164 printf(" dbversion");
2169 case 10003: /* Get sync site */
2173 case 20000: /* Begin */
2174 case 20001: /* Commit */
2175 case 20007: /* Abort */
2176 case 20008: /* Release locks */
2177 case 20010: /* Writev */
2181 case 20002: /* Lock */
2190 temp
= EXTRACT_32BITS(bp
);
2191 bp
+= sizeof(int32_t);
2192 tok2str(ubik_lock_types
, "type %d", temp
);
2194 case 20003: /* Write */
2202 case 20005: /* Get file */
2206 case 20006: /* Send file */
2211 printf(" dbversion");
2214 case 20009: /* Truncate */
2222 case 20012: /* Set version */
2225 printf(" oldversion");
2227 printf(" newversion");
2241 * Handle Ubik replies to any one of the replicated database services
2245 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2247 struct rx_header
*rxh
;
2249 if (length
< (int)sizeof(struct rx_header
))
2252 rxh
= (struct rx_header
*) bp
;
2255 * Print out the ubik call we're invoking. This table was gleaned
2256 * from ubik/ubik_int.xg
2259 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2261 bp
+= sizeof(struct rx_header
);
2264 * If it was a data packet, print out the arguments to the Ubik calls
2267 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2269 case 10000: /* Beacon */
2272 case 20004: /* Get version */
2273 printf(" dbversion");
2281 * Otherwise, print out "yes" it it was a beacon packet (because
2282 * that's how yes votes are returned, go figure), otherwise
2283 * just print out the error code.
2288 case 10000: /* Beacon */
2289 printf(" vote yes until");
2304 * Handle RX ACK packets.
2308 rx_ack_print(register const u_char
*bp
, int length
)
2310 struct rx_ackPacket
*rxa
;
2312 u_int32_t firstPacket
;
2314 if (length
< (int)sizeof(struct rx_header
))
2317 bp
+= sizeof(struct rx_header
);
2320 * This may seem a little odd .... the rx_ackPacket structure
2321 * contains an array of individual packet acknowledgements
2322 * (used for selective ack/nack), but since it's variable in size,
2323 * we don't want to truncate based on the size of the whole
2324 * rx_ackPacket structure.
2327 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2329 rxa
= (struct rx_ackPacket
*) bp
;
2330 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2333 * Print out a few useful things from the ack packet structure
2337 printf(" bufspace %d maxskew %d",
2338 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2339 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2341 firstPacket
= EXTRACT_32BITS(&rxa
->firstPacket
);
2342 printf(" first %d serial %d reason %s",
2343 firstPacket
, EXTRACT_32BITS(&rxa
->serial
),
2344 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2347 * Okay, now we print out the ack array. The way _this_ works
2348 * is that we start at "first", and step through the ack array.
2349 * If we have a contiguous range of acks/nacks, try to
2350 * collapse them into a range.
2352 * If you're really clever, you might have noticed that this
2353 * doesn't seem quite correct. Specifically, due to structure
2354 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2355 * yield the start of the ack array (because RX_MAXACKS is 255
2356 * and the structure will likely get padded to a 2 or 4 byte
2357 * boundary). However, this is the way it's implemented inside
2358 * of AFS - the start of the extra fields are at
2359 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2360 * the exact start of the ack array. Sigh. That's why we aren't
2361 * using bp, but instead use rxa->acks[]. But nAcks gets added
2362 * to bp after this, so bp ends up at the right spot. Go figure.
2365 if (rxa
->nAcks
!= 0) {
2367 TCHECK2(bp
[0], rxa
->nAcks
);
2370 * Sigh, this is gross, but it seems to work to collapse
2374 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2375 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2378 * I figured this deserved _some_ explanation.
2379 * First, print "acked" and the packet seq
2380 * number if this is the first time we've
2381 * seen an acked packet.
2391 * Otherwise, if the there is a skip in
2392 * the range (such as an nacked packet in
2393 * the middle of some acked packets),
2394 * then print the current packet number
2395 * seperated from the last number by
2399 else if (last
!= i
- 1) {
2400 printf(",%d", firstPacket
+ i
);
2405 * We always set last to the value of
2406 * the last ack we saw. Conversely, start
2407 * is set to the value of the first ack
2408 * we saw in a range.
2414 * Okay, this bit a code gets executed when
2415 * we hit a nack ... in _this_ case we
2416 * want to print out the range of packets
2417 * that were acked, so we need to print
2418 * the _previous_ packet number seperated
2419 * from the first by a dash (-). Since we
2420 * already printed the first packet above,
2421 * just print the final packet. Don't
2422 * do this if there will be a single-length
2425 } else if (last
== i
- 1 && start
!= last
)
2426 printf("-%d", firstPacket
+ i
- 1);
2429 * So, what's going on here? We ran off the end of the
2430 * ack list, and if we got a range we need to finish it up.
2431 * So we need to determine if the last packet in the list
2432 * was an ack (if so, then last will be set to it) and
2433 * we need to see if the last range didn't start with the
2434 * last packet (because if it _did_, then that would mean
2435 * that the packet number has already been printed and
2436 * we don't need to print it again).
2439 if (last
== i
- 1 && start
!= last
)
2440 printf("-%d", firstPacket
+ i
- 1);
2443 * Same as above, just without comments
2446 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2447 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2449 printf(" nacked %d",
2452 } else if (last
!= i
- 1) {
2453 printf(",%d", firstPacket
+ i
);
2457 } else if (last
== i
- 1 && start
!= last
)
2458 printf("-%d", firstPacket
+ i
- 1);
2460 if (last
== i
- 1 && start
!= last
)
2461 printf("-%d", firstPacket
+ i
- 1);
2468 * These are optional fields; depending on your version of AFS,
2469 * you may or may not see them
2472 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2488 printf(" maxpackets");