]>
The Tcpdump Group git mirrors - tcpdump/blob - print-rx.c
cff131c553274575a347b5009bf8a27fba15b638
2 * This code unmangles RX packets. RX is the mutant form of RPC that AFS
3 * uses to communicate between clients and servers.
5 * In this code, I mainly concern myself with decoding the AFS calls, not
6 * with the guts of RX, per se.
8 * Bah. If I never look at rx_packet.h again, it will be too soon.
10 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
15 static const char rcsid
[] =
16 "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.15 2000-07-29 09:20:26 assar Exp $";
26 #include <sys/param.h>
28 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <netinet/in.h>
31 #include <netinet/in_systm.h>
32 #include <netinet/ip.h>
33 #include <arpa/inet.h>
35 #include "interface.h"
36 #include "addrtoname.h"
39 #undef NOERROR /* Solaris sucks */
40 #include <arpa/nameser.h>
44 static struct tok rx_types
[] = {
45 { RX_PACKET_TYPE_DATA
, "data" },
46 { RX_PACKET_TYPE_ACK
, "ack" },
47 { RX_PACKET_TYPE_BUSY
, "busy" },
48 { RX_PACKET_TYPE_ABORT
, "abort" },
49 { RX_PACKET_TYPE_ACKALL
, "ackall" },
50 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
51 { RX_PACKET_TYPE_RESPONSE
, "response" },
52 { RX_PACKET_TYPE_DEBUG
, "debug" },
53 { RX_PACKET_TYPE_PARAMS
, "params" },
54 { RX_PACKET_TYPE_VERSION
, "version" },
58 static struct tok rx_flags
[] = {
59 { RX_CLIENT_INITIATED
, "client-init" },
60 { RX_REQUEST_ACK
, "req-ack" },
61 { RX_LAST_PACKET
, "last-pckt" },
62 { RX_MORE_PACKETS
, "more-pckts" },
63 { RX_FREE_PACKET
, "free-pckt" }
66 static struct tok fs_req
[] = {
67 { 130, "fetch-data" },
69 { 132, "fetch-status" },
70 { 133, "store-data" },
72 { 135, "store-status" },
73 { 136, "remove-file" },
74 { 137, "create-file" },
80 { 143, "oldsetlock" },
81 { 144, "oldextlock" },
82 { 145, "oldrellock" },
85 { 148, "get-vlinfo" },
86 { 149, "get-vlstats" },
87 { 150, "set-vlstats" },
88 { 151, "get-rootvl" },
89 { 152, "check-token" },
91 { 154, "nget-vlinfo" },
98 { 161, "dfs-lookup" },
99 { 162, "dfs-flushcps" },
100 { 163, "dfs-symlink" },
104 static struct tok cb_req
[] = {
113 { 212, "whoareyou" },
115 { 214, "probeuuid" },
119 static struct tok pt_req
[] = {
121 { 501, "where-is-it" },
122 { 502, "dump-entry" },
123 { 503, "add-to-group" },
124 { 504, "name-to-id" },
125 { 505, "id-to-name" },
127 { 507, "remove-from-group" },
129 { 509, "new-entry" },
132 { 512, "list-entry" },
133 { 513, "change-entry" },
134 { 514, "list-elements" },
135 { 515, "same-mbr-of" },
136 { 516, "set-fld-sentry" },
137 { 517, "list-owned" },
139 { 519, "get-host-cps" },
140 { 520, "update-entry" },
144 static struct tok vldb_req
[] = {
145 { 501, "create-entry" },
146 { 502, "delete-entry" },
147 { 503, "get-entry-by-id" },
148 { 504, "get-entry-by-name" },
149 { 505, "get-new-volume-id" },
150 { 506, "replace-entry" },
151 { 507, "update-entry" },
153 { 509, "releaselock" },
154 { 510, "list-entry" },
155 { 511, "list-attrib" },
156 { 512, "linked-list" },
157 { 513, "get-stats" },
159 { 515, "get-addrs" },
160 { 516, "change-addr" },
161 { 517, "create-entry-n" },
162 { 518, "get-entry-by-id-n" },
163 { 519, "get-entry-by-name-n" },
164 { 520, "replace-entry-n" },
165 { 521, "list-entry-n" },
166 { 522, "list-attrib-n" },
167 { 523, "linked-list-n" },
168 { 524, "update-entry-by-name" },
169 { 525, "create-entry-u" },
170 { 526, "get-entry-by-id-u" },
171 { 527, "get-entry-by-name-u" },
172 { 528, "replace-entry-u" },
173 { 529, "list-entry-u" },
174 { 530, "list-attrib-u" },
175 { 531, "linked-list-u" },
177 { 533, "get-addrs-u" },
181 static struct tok kauth_req
[] = {
183 { 21, "authenticate" },
184 { 22, "authenticate-v2" },
186 { 3, "get-ticket-old" },
187 { 23, "get-ticket" },
190 { 6, "create-user" },
191 { 7, "delete-user" },
197 { 13, "get-random-key" },
199 { 15, "lock-status" },
203 static struct tok vol_req
[] = {
204 { 100, "create-volume" },
205 { 101, "delete-volume" },
208 { 104, "end-trans" },
210 { 106, "set-flags" },
211 { 107, "get-flags" },
212 { 108, "trans-create" },
214 { 110, "get-nth-volume" },
215 { 111, "set-forwarding" },
217 { 113, "get-status" },
218 { 114, "sig-restore" },
219 { 115, "list-partitions" },
220 { 116, "list-volumes" },
221 { 117, "set-id-types" },
223 { 119, "partition-info" },
225 { 121, "list-one-volume" },
228 { 124, "x-list-volumes" },
229 { 125, "x-list-one-volume" },
231 { 127, "x-list-partitions" },
232 { 128, "forward-multiple" },
236 static struct tok bos_req
[] = {
237 { 80, "create-bnode" },
238 { 81, "delete-bnode" },
239 { 82, "set-status" },
240 { 83, "get-status" },
241 { 84, "enumerate-instance" },
242 { 85, "get-instance-info" },
243 { 86, "get-instance-parm" },
244 { 87, "add-superuser" },
245 { 88, "delete-superuser" },
246 { 89, "list-superusers" },
249 { 92, "delete-key" },
250 { 93, "set-cell-name" },
251 { 94, "get-cell-name" },
252 { 95, "get-cell-host" },
253 { 96, "add-cell-host" },
254 { 97, "delete-cell-host" },
255 { 98, "set-t-status" },
256 { 99, "shutdown-all" },
257 { 100, "restart-all" },
258 { 101, "startup-all" },
259 { 102, "set-noauth-flag" },
262 { 105, "start-bozo-install" },
263 { 106, "uninstall" },
264 { 107, "get-dates" },
267 { 110, "set-restart-time" },
268 { 111, "get-restart-time" },
269 { 112, "start-bozo-log" },
271 { 114, "get-instance-strings" },
275 static struct tok ubik_req
[] = {
276 { 10000, "vote-beacon" },
277 { 10001, "vote-debug-old" },
278 { 10002, "vote-sdebug-old" },
279 { 10003, "vote-getsyncsite" },
280 { 10004, "vote-debug" },
281 { 10005, "vote-sdebug" },
282 { 20000, "disk-begin" },
283 { 20001, "disk-commit" },
284 { 20002, "disk-lock" },
285 { 20003, "disk-write" },
286 { 20004, "disk-getversion" },
287 { 20005, "disk-getfile" },
288 { 20006, "disk-sendfile" },
289 { 20007, "disk-abort" },
290 { 20008, "disk-releaselocks" },
291 { 20009, "disk-truncate" },
292 { 20010, "disk-probe" },
293 { 20011, "disk-writev" },
294 { 20012, "disk-interfaceaddr" },
295 { 20013, "disk-setversion" },
299 #define VOTE_LOW 10000
300 #define VOTE_HIGH 10005
301 #define DISK_LOW 20000
302 #define DISK_HIGH 20013
304 static struct tok cb_types
[] = {
311 static struct tok ubik_lock_types
[] = {
318 static char *voltype
[] = { "read-write", "read-only", "backup" };
320 static struct tok afs_fs_errors
[] = {
321 { 101, "salvage volume" },
322 { 102, "no such vnode" },
323 { 103, "no such volume" },
324 { 104, "volume exist" },
325 { 105, "no service" },
326 { 106, "volume offline" },
327 { 107, "voline online" },
329 { 109, "diskquota exceeded" },
330 { 110, "volume busy" },
331 { 111, "volume moved" },
332 { 112, "AFS IO error" },
333 { -100, "restarting fileserver" },
338 * Reasons for acknowledging a packet
341 static struct tok rx_ack_reasons
[] = {
342 { 1, "ack requested" },
343 { 2, "duplicate packet" },
344 { 3, "out of sequence" },
345 { 4, "exceeds window" },
346 { 5, "no buffer space" },
348 { 7, "ping response" },
354 * Cache entries we keep around so we can figure out the RX opcode
355 * numbers for replies. This allows us to make sense of RX reply packets.
358 struct rx_cache_entry
{
359 u_int32_t callnum
; /* Call number (net order) */
360 struct in_addr client
; /* client IP address (net order) */
361 struct in_addr server
; /* server IP address (net order) */
362 int dport
; /* server port (host order) */
363 u_short serviceId
; /* Service identifier (net order) */
364 u_int32_t opcode
; /* RX opcode (host order) */
367 #define RX_CACHE_SIZE 64
369 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
371 static int rx_cache_next
= 0;
372 static int rx_cache_hint
= 0;
373 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
374 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
377 static void ack_print(const u_char
*, int);
378 static void fs_print(const u_char
*, int);
379 static void fs_reply_print(const u_char
*, int, int32_t);
380 static void acl_print(u_char
*, u_char
*);
381 static void cb_print(const u_char
*, int);
382 static void cb_reply_print(const u_char
*, int, int32_t);
383 static void prot_print(const u_char
*, int);
384 static void prot_reply_print(const u_char
*, int, int32_t);
385 static void vldb_print(const u_char
*, int);
386 static void vldb_reply_print(const u_char
*, int, int32_t);
387 static void kauth_print(const u_char
*, int);
388 static void kauth_reply_print(const u_char
*, int, int32_t);
389 static void vol_print(const u_char
*, int);
390 static void vol_reply_print(const u_char
*, int, int32_t);
391 static void bos_print(const u_char
*, int);
392 static void bos_reply_print(const u_char
*, int, int32_t);
393 static void ubik_print(const u_char
*, int);
394 static void ubik_reply_print(const u_char
*, int, int32_t);
396 static void rx_ack_print(const u_char
*, int);
398 static int is_ubik(u_int32_t
);
401 * Handle the rx-level packet. See if we know what port it's going to so
402 * we can peek at the afs call inside
406 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
409 register struct rx_header
*rxh
;
413 if (snapend
- bp
< sizeof (struct rx_header
)) {
414 printf(" [|rx] (%d)", length
);
418 rxh
= (struct rx_header
*) bp
;
420 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
426 printf(" cid %08x call# %d",
427 (int) EXTRACT_32BITS(&rxh
->cid
),
428 (int) EXTRACT_32BITS(&rxh
->callNumber
));
430 printf(" seq %d ser %d",
431 (int) EXTRACT_32BITS(&rxh
->seq
),
432 (int) EXTRACT_32BITS(&rxh
->serial
));
435 printf(" secindex %d serviceid %hu",
436 (int) rxh
->securityIndex
,
437 EXTRACT_16BITS(&rxh
->serviceId
));
440 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
441 if (rxh
->flags
& rx_flags
[i
].v
) {
448 printf("<%s>", rx_flags
[i
].s
);
454 * Try to handle AFS calls that we know about. Check the destination
455 * port and make sure it's a data packet. Also, make sure the
456 * seq number is 1 (because otherwise it's a continuation packet,
457 * and we can't interpret that). Also, seems that reply packets
458 * do not have the client-init flag set, so we check for that
462 if (rxh
->type
== RX_PACKET_TYPE_ACK
)
463 ack_print(bp
, length
);
464 else if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
465 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
466 rxh
->flags
& RX_CLIENT_INITIATED
) {
469 * Insert this call into the call cache table, so we
470 * have a chance to print out replies
473 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
476 case FS_RX_PORT
: /* AFS file service */
477 fs_print(bp
, length
);
479 case CB_RX_PORT
: /* AFS callback service */
480 cb_print(bp
, length
);
482 case PROT_RX_PORT
: /* AFS protection service */
483 prot_print(bp
, length
);
485 case VLDB_RX_PORT
: /* AFS VLDB service */
486 vldb_print(bp
, length
);
488 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
489 kauth_print(bp
, length
);
491 case VOL_RX_PORT
: /* AFS Volume service */
492 vol_print(bp
, length
);
494 case BOS_RX_PORT
: /* AFS BOS service */
495 bos_print(bp
, length
);
502 * If it's a reply (client-init is _not_ set, but seq is one)
503 * then look it up in the cache. If we find it, call the reply
504 * printing functions Note that we handle abort packets here,
505 * because printing out the return code can be useful at times.
508 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
509 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
510 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
511 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
512 rx_cache_find(rxh
, (const struct ip
*) bp2
,
516 case FS_RX_PORT
: /* AFS file service */
517 fs_reply_print(bp
, length
, opcode
);
519 case CB_RX_PORT
: /* AFS callback service */
520 cb_reply_print(bp
, length
, opcode
);
522 case PROT_RX_PORT
: /* AFS PT service */
523 prot_reply_print(bp
, length
, opcode
);
525 case VLDB_RX_PORT
: /* AFS VLDB service */
526 vldb_reply_print(bp
, length
, opcode
);
528 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
529 kauth_reply_print(bp
, length
, opcode
);
531 case VOL_RX_PORT
: /* AFS Volume service */
532 vol_reply_print(bp
, length
, opcode
);
534 case BOS_RX_PORT
: /* AFS BOS service */
535 bos_reply_print(bp
, length
, opcode
);
542 * If it's an RX ack packet, then use the appropriate ack decoding
543 * function (there isn't any service-specific information in the
544 * ack packet, so we can use one for all AFS services)
547 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
548 rx_ack_print(bp
, length
);
551 printf(" (%d)", length
);
555 * Insert an entry into the cache. Taken from print-nfs.c
559 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
562 struct rx_cache_entry
*rxent
;
563 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
565 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
568 rxent
= &rx_cache
[rx_cache_next
];
570 if (++rx_cache_next
>= RX_CACHE_SIZE
)
573 rxent
->callnum
= rxh
->callNumber
;
574 rxent
->client
= ip
->ip_src
;
575 rxent
->server
= ip
->ip_dst
;
576 rxent
->dport
= dport
;
577 rxent
->serviceId
= rxh
->serviceId
;
578 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
582 * Lookup an entry in the cache. Also taken from print-nfs.c
584 * Note that because this is a reply, we're looking at the _source_
589 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
593 struct rx_cache_entry
*rxent
;
594 u_int32_t clip
= ip
->ip_dst
.s_addr
;
595 u_int32_t sip
= ip
->ip_src
.s_addr
;
597 /* Start the search where we last left off */
601 rxent
= &rx_cache
[i
];
602 if (rxent
->callnum
== rxh
->callNumber
&&
603 rxent
->client
.s_addr
== clip
&&
604 rxent
->server
.s_addr
== sip
&&
605 rxent
->serviceId
== rxh
->serviceId
&&
606 rxent
->dport
== sport
) {
608 /* We got a match! */
611 *opcode
= rxent
->opcode
;
614 if (++i
> RX_CACHE_SIZE
)
616 } while (i
!= rx_cache_hint
);
618 /* Our search failed */
623 * These extrememly grody macros handle the printing of various AFS stuff.
626 #define FIDOUT() { unsigned long n1, n2, n3; \
627 TCHECK2(bp[0], sizeof(int32_t) * 3); \
628 n1 = EXTRACT_32BITS(bp); \
629 bp += sizeof(int32_t); \
630 n2 = EXTRACT_32BITS(bp); \
631 bp += sizeof(int32_t); \
632 n3 = EXTRACT_32BITS(bp); \
633 bp += sizeof(int32_t); \
634 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
637 #define STROUT(MAX) { int i; \
638 TCHECK2(bp[0], sizeof(int32_t)); \
639 i = (int) EXTRACT_32BITS(bp); \
640 bp += sizeof(int32_t); \
642 strncpy(s, (char *) bp, min(MAX, i)); \
644 printf(" \"%s\"", s); \
645 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
648 #define INTOUT() { int i; \
649 TCHECK2(bp[0], sizeof(int32_t)); \
650 i = (int) EXTRACT_32BITS(bp); \
651 bp += sizeof(int32_t); \
655 #define UINTOUT() { unsigned long i; \
656 TCHECK2(bp[0], sizeof(int32_t)); \
657 i = EXTRACT_32BITS(bp); \
658 bp += sizeof(int32_t); \
662 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
663 TCHECK2(bp[0], sizeof(int32_t)); \
664 t = (time_t) EXTRACT_32BITS(bp); \
665 bp += sizeof(int32_t); \
666 tm = localtime(&t); \
667 strftime(str, 256, "%Y/%m/%d %T", tm); \
668 printf(" %s", str); \
671 #define STOREATTROUT() { unsigned long mask, i; \
672 TCHECK2(bp[0], (sizeof(int32_t)*6)); \
673 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
674 if (mask) printf (" StoreStatus"); \
675 if (mask & 1) { printf(" date"); DATEOUT(); } \
676 else bp += sizeof(int32_t); \
677 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
678 if (mask & 2) printf(" owner %lu", i); \
679 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
680 if (mask & 4) printf(" group %lu", i); \
681 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
682 if (mask & 8) printf(" mode %lo", i & 07777); \
683 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
684 if (mask & 16) printf(" segsize %lu", i); \
685 /* undocumented in 3.3 docu */ \
686 if (mask & 1024) printf(" fsync"); \
689 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
690 TCHECK2(bp[0], sizeof(int32_t) * 2); \
691 epoch = EXTRACT_32BITS(bp); \
692 bp += sizeof(int32_t); \
693 counter = EXTRACT_32BITS(bp); \
694 bp += sizeof(int32_t); \
695 printf(" %d.%d", epoch, counter); \
698 #define AFSUUIDOUT() {u_int32_t temp; int i; \
699 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
700 temp = EXTRACT_32BITS(bp); \
701 bp += sizeof(u_int32_t); \
702 printf(" %08x", temp); \
703 temp = EXTRACT_32BITS(bp); \
704 bp += sizeof(u_int32_t); \
705 printf("%04x", temp); \
706 temp = EXTRACT_32BITS(bp); \
707 bp += sizeof(u_int32_t); \
708 printf("%04x", temp); \
709 for (i = 0; i < 8; i++) { \
710 temp = EXTRACT_32BITS(bp); \
711 bp += sizeof(u_int32_t); \
712 printf("%02x", (unsigned char) temp); \
717 * This is the sickest one of all
720 #define VECOUT(MAX) { char *sp; \
722 TCHECK2(bp[0], MAX * sizeof(int32_t)); \
724 for (k = 0; k < MAX; k++) { \
725 *sp++ = (char) EXTRACT_32BITS(bp); \
726 bp += sizeof(int32_t); \
729 printf(" \"%s\"", s); \
733 ack_print(register const u_char
*bp
, int length
)
741 if (length
<= sizeof(struct rx_header
))
744 bp
+= sizeof(struct rx_header
);
747 * Packets < firstPacket are implicitly acknowledged and may
748 * be discarded by the sender.
750 * Packets >= firstPacket+nAcks are implicitly NOT acknowledged.
752 * No packets with sequence numbers >= firstPacket should be
753 * discarded by the sender (they may thrown out at any time by
756 #define RX_ACK_REASONS "RDOXSprn"
757 /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space,
758 * Ping, ping_Response, No_{progress, particular_reason}.
761 struct rx_ackPacket
{
762 u_short bufferSpace
; /* Skip! */
763 u_short maxSkew
; /* Skip! */
765 u_long previousPacket
; /* Obsolete! */
766 u_long serial
; /* Serial that prompted the ack, */
767 u_char reason
; /* and the reason why. */
769 u_char acks
[RX_MAXACKS
]; /* Selective acks (not a bitmap). */
772 #define RX_ACK_TYPE_NACK 0
774 TCHECK2(bp
[0], 8); /* bufferSpace and maxSkew */
776 printf(" fir %u", (unsigned)EXTRACT_32BITS(bp
));
778 TCHECK2(bp
[0], 8); /* previousPacket and serial */
780 printf(" %u", (unsigned)EXTRACT_32BITS(bp
));
783 printf("%c", RX_ACK_REASONS
[(*bp
- 1) & 07u]);
784 bp
+= 1; /* reason */
789 for (i
= 0; i
< nAcks
; i
++) {
791 putchar(*bp
== RX_ACK_TYPE_NACK
? '-' : '*');
802 * Handle calls to the AFS file service (fs)
806 fs_print(register const u_char
*bp
, int length
)
812 if (length
<= sizeof(struct rx_header
))
815 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
820 * Print out the afs call we're invoking. The table used here was
821 * gleaned from fsint/afsint.xg
824 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
826 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
829 * Print out arguments to some of the AFS calls. This stuff is
833 bp
+= sizeof(struct rx_header
) + 4;
836 * Sigh. This is gross. Ritchie forgive me.
840 case 130: /* Fetch data */
847 case 131: /* Fetch ACL */
848 case 132: /* Fetch Status */
849 case 143: /* Old set lock */
850 case 144: /* Old extend lock */
851 case 145: /* Old release lock */
852 case 156: /* Set lock */
853 case 157: /* Extend lock */
854 case 158: /* Release lock */
857 case 135: /* Store status */
861 case 133: /* Store data */
871 case 134: /* Store ACL */
873 char a
[AFSOPAQUEMAX
];
876 i
= EXTRACT_32BITS(bp
);
877 bp
+= sizeof(int32_t);
879 strncpy(a
, (char *) bp
, min(AFSOPAQUEMAX
, i
));
881 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
884 case 137: /* Create file */
885 case 141: /* MakeDir */
890 case 136: /* Remove file */
891 case 142: /* Remove directory */
895 case 138: /* Rename file */
903 case 139: /* Symlink */
915 case 148: /* Get volume info */
918 case 149: /* Get volume stats */
919 case 150: /* Set volume stats */
923 case 154: /* New get volume info */
927 case 155: /* Bulk stat */
931 j
= EXTRACT_32BITS(bp
);
932 bp
+= sizeof(int32_t);
934 for (i
= 0; i
< j
; i
++) {
953 * Handle replies to the AFS file service
957 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
961 struct rx_header
*rxh
;
963 if (length
<= sizeof(struct rx_header
))
966 rxh
= (struct rx_header
*) bp
;
969 * Print out the afs call we're invoking. The table used here was
970 * gleaned from fsint/afsint.xg
973 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
975 bp
+= sizeof(struct rx_header
);
978 * If it was a data packet, interpret the response
981 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
983 case 131: /* Fetch ACL */
985 char a
[AFSOPAQUEMAX
];
987 i
= EXTRACT_32BITS(bp
);
988 bp
+= sizeof(int32_t);
990 strncpy(a
, (char *) bp
, min(AFSOPAQUEMAX
, i
));
992 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
995 case 137: /* Create file */
996 case 141: /* MakeDir */
1000 case 151: /* Get root volume */
1001 printf(" root volume");
1004 case 153: /* Get time */
1010 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1014 * Otherwise, just print out the return code
1016 TCHECK2(bp
[0], sizeof(int32_t));
1017 i
= (int) EXTRACT_32BITS(bp
);
1018 bp
+= sizeof(int32_t);
1020 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
1022 printf(" strange fs reply of type %d", rxh
->type
);
1032 * Print out an AFS ACL string. An AFS ACL is a string that has the
1035 * <positive> <negative>
1039 * "positive" and "negative" are integers which contain the number of
1040 * positive and negative ACL's in the string. The uid/aclbits pair are
1041 * ASCII strings containing the UID/PTS record and and a ascii number
1042 * representing a logical OR of all the ACL permission bits
1046 acl_print(u_char
*s
, u_char
*end
)
1052 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1061 * This wacky order preserves the order used by the "fs" command
1064 #define ACLOUT(acl) \
1065 if (acl & PRSFS_READ) \
1067 if (acl & PRSFS_LOOKUP) \
1069 if (acl & PRSFS_INSERT) \
1071 if (acl & PRSFS_DELETE) \
1073 if (acl & PRSFS_WRITE) \
1075 if (acl & PRSFS_LOCK) \
1077 if (acl & PRSFS_ADMINISTER) \
1080 for (i
= 0; i
< pos
; i
++) {
1081 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1084 printf(" +{%s ", user
);
1091 for (i
= 0; i
< neg
; i
++) {
1092 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1095 printf(" -{%s ", user
);
1106 * Handle calls to the AFS callback service
1110 cb_print(register const u_char
*bp
, int length
)
1115 if (length
<= sizeof(struct rx_header
))
1118 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1123 * Print out the afs call we're invoking. The table used here was
1124 * gleaned from fsint/afscbint.xg
1127 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1129 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1131 bp
+= sizeof(struct rx_header
) + 4;
1134 * Print out the afs call we're invoking. The table used here was
1135 * gleaned from fsint/afscbint.xg
1139 case 204: /* Callback */
1143 j
= EXTRACT_32BITS(bp
);
1144 bp
+= sizeof(int32_t);
1146 for (i
= 0; i
< j
; i
++) {
1155 j
= EXTRACT_32BITS(bp
);
1156 bp
+= sizeof(int32_t);
1161 for (i
= 0; i
< j
; i
++) {
1167 t
= EXTRACT_32BITS(bp
);
1168 bp
+= sizeof(int32_t);
1169 tok2str(cb_types
, "type %d", t
);
1188 * Handle replies to the AFS Callback Service
1192 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1194 struct rx_header
*rxh
;
1196 if (length
<= sizeof(struct rx_header
))
1199 rxh
= (struct rx_header
*) bp
;
1202 * Print out the afs call we're invoking. The table used here was
1203 * gleaned from fsint/afscbint.xg
1206 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1208 bp
+= sizeof(struct rx_header
);
1211 * If it was a data packet, interpret the response.
1214 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1216 case 213: /* InitCallBackState3 */
1224 * Otherwise, just print out the return code
1237 * Handle calls to the AFS protection database server
1241 prot_print(register const u_char
*bp
, int length
)
1247 if (length
<= sizeof(struct rx_header
))
1250 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1255 * Print out the afs call we're invoking. The table used here was
1256 * gleaned from ptserver/ptint.xg
1259 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1263 if (is_ubik(pt_op
)) {
1264 ubik_print(bp
, length
);
1268 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1271 * Decode some of the arguments to the PT calls
1274 bp
+= sizeof(struct rx_header
) + 4;
1277 case 500: /* I New User */
1284 case 501: /* Where is it */
1285 case 506: /* Delete */
1286 case 508: /* Get CPS */
1287 case 512: /* List entry */
1288 case 514: /* List elements */
1289 case 517: /* List owned */
1290 case 518: /* Get CPS2 */
1291 case 519: /* Get host CPS */
1295 case 502: /* Dump entry */
1299 case 503: /* Add to group */
1300 case 507: /* Remove from group */
1301 case 515: /* Is a member of? */
1307 case 504: /* Name to ID */
1311 j
= EXTRACT_32BITS(bp
);
1312 bp
+= sizeof(int32_t);
1315 * Who designed this chicken-shit protocol?
1317 * Each character is stored as a 32-bit
1321 for (i
= 0; i
< j
; i
++) {
1328 case 505: /* Id to name */
1333 i
= EXTRACT_32BITS(bp
);
1334 bp
+= sizeof(int32_t);
1335 for (j
= 0; j
< i
; j
++)
1341 case 509: /* New entry */
1348 case 511: /* Set max */
1354 case 513: /* Change entry */
1363 case 520: /* Update entry */
1380 * Handle replies to the AFS protection service
1384 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1386 struct rx_header
*rxh
;
1390 if (length
< sizeof(struct rx_header
))
1393 rxh
= (struct rx_header
*) bp
;
1396 * Print out the afs call we're invoking. The table used here was
1397 * gleaned from ptserver/ptint.xg. Check to see if it's a
1398 * Ubik call, however.
1403 if (is_ubik(opcode
)) {
1404 ubik_reply_print(bp
, length
, opcode
);
1408 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1410 bp
+= sizeof(struct rx_header
);
1413 * If it was a data packet, interpret the response
1416 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1418 case 504: /* Name to ID */
1423 i
= EXTRACT_32BITS(bp
);
1424 bp
+= sizeof(int32_t);
1425 for (j
= 0; j
< i
; j
++)
1431 case 505: /* ID to name */
1435 j
= EXTRACT_32BITS(bp
);
1436 bp
+= sizeof(int32_t);
1439 * Who designed this chicken-shit protocol?
1441 * Each character is stored as a 32-bit
1445 for (i
= 0; i
< j
; i
++) {
1452 case 508: /* Get CPS */
1453 case 514: /* List elements */
1454 case 517: /* List owned */
1455 case 518: /* Get CPS2 */
1456 case 519: /* Get host CPS */
1460 j
= EXTRACT_32BITS(bp
);
1461 bp
+= sizeof(int32_t);
1462 for (i
= 0; i
< j
; i
++) {
1469 case 510: /* List max */
1480 * Otherwise, just print out the return code
1493 * Handle calls to the AFS volume location database service
1497 vldb_print(register const u_char
*bp
, int length
)
1503 if (length
<= sizeof(struct rx_header
))
1506 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1511 * Print out the afs call we're invoking. The table used here was
1512 * gleaned from vlserver/vldbint.xg
1515 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1519 if (is_ubik(vldb_op
)) {
1520 ubik_print(bp
, length
);
1523 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1526 * Decode some of the arguments to the VLDB calls
1529 bp
+= sizeof(struct rx_header
) + 4;
1532 case 501: /* Create new volume */
1533 case 517: /* Create entry N */
1536 case 502: /* Delete entry */
1537 case 503: /* Get entry by ID */
1538 case 507: /* Update entry */
1539 case 508: /* Set lock */
1540 case 509: /* Release lock */
1541 case 518: /* Get entry by ID N */
1544 TCHECK2(bp
[0], sizeof(int32_t));
1545 i
= EXTRACT_32BITS(bp
);
1546 bp
+= sizeof(int32_t);
1548 printf(" type %s", voltype
[i
]);
1550 case 504: /* Get entry by name */
1551 case 519: /* Get entry by name N */
1552 case 524: /* Update entry by name */
1553 case 527: /* Get entry by name U */
1556 case 505: /* Get new vol id */
1560 case 506: /* Replace entry */
1561 case 520: /* Replace entry N */
1564 TCHECK2(bp
[0], sizeof(int32_t));
1565 i
= EXTRACT_32BITS(bp
);
1566 bp
+= sizeof(int32_t);
1568 printf(" type %s", voltype
[i
]);
1571 case 510: /* List entry */
1572 case 521: /* List entry N */
1587 * Handle replies to the AFS volume location database service
1591 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1593 struct rx_header
*rxh
;
1597 if (length
< sizeof(struct rx_header
))
1600 rxh
= (struct rx_header
*) bp
;
1603 * Print out the afs call we're invoking. The table used here was
1604 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1605 * Ubik call, however.
1610 if (is_ubik(opcode
)) {
1611 ubik_reply_print(bp
, length
, opcode
);
1615 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1617 bp
+= sizeof(struct rx_header
);
1620 * If it was a data packet, interpret the response
1623 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1625 case 510: /* List entry */
1628 printf(" nextindex");
1630 case 503: /* Get entry by id */
1631 case 504: /* Get entry by name */
1632 { unsigned long nservers
, j
;
1634 TCHECK2(bp
[0], sizeof(int32_t));
1635 bp
+= sizeof(int32_t);
1636 printf(" numservers");
1637 TCHECK2(bp
[0], sizeof(int32_t));
1638 nservers
= EXTRACT_32BITS(bp
);
1639 bp
+= sizeof(int32_t);
1640 printf(" %lu", nservers
);
1642 for (i
= 0; i
< 8; i
++) {
1643 TCHECK2(bp
[0], sizeof(int32_t));
1646 inet_ntoa(*((struct in_addr
*) bp
)));
1647 bp
+= sizeof(int32_t);
1649 printf(" partitions");
1650 for (i
= 0; i
< 8; i
++) {
1651 TCHECK2(bp
[0], sizeof(int32_t));
1652 j
= EXTRACT_32BITS(bp
);
1653 if (i
< nservers
&& j
<= 26)
1654 printf(" %c", 'a' + (int)j
);
1655 else if (i
< nservers
)
1657 bp
+= sizeof(int32_t);
1659 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1660 bp
+= 8 * sizeof(int32_t);
1669 case 505: /* Get new volume ID */
1673 case 521: /* List entry */
1674 case 529: /* List entry U */
1677 printf(" nextindex");
1679 case 518: /* Get entry by ID N */
1680 case 519: /* Get entry by name N */
1681 { unsigned long nservers
, j
;
1683 printf(" numservers");
1684 TCHECK2(bp
[0], sizeof(int32_t));
1685 nservers
= EXTRACT_32BITS(bp
);
1686 bp
+= sizeof(int32_t);
1687 printf(" %lu", nservers
);
1689 for (i
= 0; i
< 13; i
++) {
1690 TCHECK2(bp
[0], sizeof(int32_t));
1693 inet_ntoa(*((struct in_addr
*) bp
)));
1694 bp
+= sizeof(int32_t);
1696 printf(" partitions");
1697 for (i
= 0; i
< 13; i
++) {
1698 TCHECK2(bp
[0], sizeof(int32_t));
1699 j
= EXTRACT_32BITS(bp
);
1700 if (i
< nservers
&& j
<= 26)
1701 printf(" %c", 'a' + (int)j
);
1702 else if (i
< nservers
)
1704 bp
+= sizeof(int32_t);
1706 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1707 bp
+= 13 * sizeof(int32_t);
1716 case 526: /* Get entry by ID U */
1717 case 527: /* Get entry by name U */
1718 { unsigned long nservers
, j
;
1720 printf(" numservers");
1721 TCHECK2(bp
[0], sizeof(int32_t));
1722 nservers
= EXTRACT_32BITS(bp
);
1723 bp
+= sizeof(int32_t);
1724 printf(" %lu", nservers
);
1726 for (i
= 0; i
< 13; i
++) {
1735 TCHECK2(bp
[0], 4 * 13);
1737 printf(" partitions");
1738 for (i
= 0; i
< 13; i
++) {
1739 TCHECK2(bp
[0], sizeof(int32_t));
1740 j
= EXTRACT_32BITS(bp
);
1741 if (i
< nservers
&& j
<= 26)
1742 printf(" %c", 'a' + (int)j
);
1743 else if (i
< nservers
)
1745 bp
+= sizeof(int32_t);
1747 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1748 bp
+= 13 * sizeof(int32_t);
1762 * Otherwise, just print out the return code
1775 * Handle calls to the AFS Kerberos Authentication service
1779 kauth_print(register const u_char
*bp
, int length
)
1784 if (length
<= sizeof(struct rx_header
))
1787 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1792 * Print out the afs call we're invoking. The table used here was
1793 * gleaned from kauth/kauth.rg
1796 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1800 if (is_ubik(kauth_op
)) {
1801 ubik_print(bp
, length
);
1806 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1809 * Decode some of the arguments to the KA calls
1812 bp
+= sizeof(struct rx_header
) + 4;
1815 case 1: /* Authenticate old */;
1816 case 21: /* Authenticate */
1817 case 22: /* Authenticate-V2 */
1818 case 2: /* Change PW */
1819 case 5: /* Set fields */
1820 case 6: /* Create user */
1821 case 7: /* Delete user */
1822 case 8: /* Get entry */
1823 case 14: /* Unlock */
1824 case 15: /* Lock status */
1825 printf(" principal");
1829 case 3: /* GetTicket-old */
1830 case 23: /* GetTicket */
1837 TCHECK2(bp
[0], sizeof(int32_t));
1838 i
= (int) EXTRACT_32BITS(bp
);
1839 bp
+= sizeof(int32_t);
1842 printf(" principal");
1847 case 4: /* Set Password */
1848 printf(" principal");
1854 case 12: /* Get password */
1865 printf(" [|kauth]");
1869 * Handle replies to the AFS Kerberos Authentication Service
1873 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1875 struct rx_header
*rxh
;
1877 if (length
<= sizeof(struct rx_header
))
1880 rxh
= (struct rx_header
*) bp
;
1883 * Print out the afs call we're invoking. The table used here was
1884 * gleaned from kauth/kauth.rg
1889 if (is_ubik(opcode
)) {
1890 ubik_reply_print(bp
, length
, opcode
);
1894 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1896 bp
+= sizeof(struct rx_header
);
1899 * If it was a data packet, interpret the response.
1902 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1903 /* Well, no, not really. Leave this for later */
1907 * Otherwise, just print out the return code
1916 printf(" [|kauth]");
1920 * Handle calls to the AFS Volume location service
1924 vol_print(register const u_char
*bp
, int length
)
1928 if (length
<= sizeof(struct rx_header
))
1931 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1936 * Print out the afs call we're invoking. The table used here was
1937 * gleaned from volser/volint.xg
1940 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1942 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1945 * Normally there would be a switch statement here to decode the
1946 * arguments to the AFS call, but since I don't have access to
1947 * an AFS server (yet) and I'm not an AFS admin, I can't
1948 * test any of these calls. Leave this blank for now.
1958 * Handle replies to the AFS Volume Service
1962 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1964 struct rx_header
*rxh
;
1966 if (length
<= sizeof(struct rx_header
))
1969 rxh
= (struct rx_header
*) bp
;
1972 * Print out the afs call we're invoking. The table used here was
1973 * gleaned from volser/volint.xg
1976 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
1978 bp
+= sizeof(struct rx_header
);
1981 * If it was a data packet, interpret the response.
1984 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1985 /* Well, no, not really. Leave this for later */
1989 * Otherwise, just print out the return code
2002 * Handle calls to the AFS BOS service
2006 bos_print(register const u_char
*bp
, int length
)
2011 if (length
<= sizeof(struct rx_header
))
2014 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
2019 * Print out the afs call we're invoking. The table used here was
2020 * gleaned from bozo/bosint.xg
2023 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2025 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2028 * Decode some of the arguments to the BOS calls
2031 bp
+= sizeof(struct rx_header
) + 4;
2034 case 80: /* Create B node */
2037 printf(" instance");
2040 case 81: /* Delete B node */
2041 case 83: /* Get status */
2042 case 85: /* Get instance info */
2043 case 87: /* Add super user */
2044 case 88: /* Delete super user */
2045 case 93: /* Set cell name */
2046 case 96: /* Add cell host */
2047 case 97: /* Delete cell host */
2048 case 104: /* Restart */
2049 case 106: /* Uninstall */
2050 case 108: /* Exec */
2051 case 112: /* Getlog */
2052 case 114: /* Get instance strings */
2055 case 82: /* Set status */
2056 case 98: /* Set T status */
2061 case 86: /* Get instance parm */
2066 case 84: /* Enumerate instance */
2067 case 89: /* List super users */
2068 case 90: /* List keys */
2069 case 91: /* Add key */
2070 case 92: /* Delete key */
2071 case 95: /* Get cell host */
2074 case 105: /* Install */
2094 * Handle replies to the AFS BOS Service
2098 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2100 struct rx_header
*rxh
;
2102 if (length
<= sizeof(struct rx_header
))
2105 rxh
= (struct rx_header
*) bp
;
2108 * Print out the afs call we're invoking. The table used here was
2109 * gleaned from volser/volint.xg
2112 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2114 bp
+= sizeof(struct rx_header
);
2117 * If it was a data packet, interpret the response.
2120 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2121 /* Well, no, not really. Leave this for later */
2125 * Otherwise, just print out the return code
2138 * Check to see if this is a Ubik opcode.
2142 is_ubik(u_int32_t opcode
)
2144 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2145 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2152 * Handle Ubik opcodes to any one of the replicated database services
2156 ubik_print(register const u_char
*bp
, int length
)
2162 * Print out the afs call we're invoking. The table used here was
2163 * gleaned from ubik/ubik_int.xg
2166 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2168 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2171 * Decode some of the arguments to the Ubik calls
2174 bp
+= sizeof(struct rx_header
) + 4;
2177 case 10000: /* Beacon */
2179 temp
= EXTRACT_32BITS(bp
);
2180 bp
+= sizeof(int32_t);
2181 printf(" syncsite %s", temp
? "yes" : "no");
2182 printf(" votestart");
2184 printf(" dbversion");
2189 case 10003: /* Get sync site */
2193 case 20000: /* Begin */
2194 case 20001: /* Commit */
2195 case 20007: /* Abort */
2196 case 20008: /* Release locks */
2197 case 20010: /* Writev */
2201 case 20002: /* Lock */
2210 temp
= EXTRACT_32BITS(bp
);
2211 bp
+= sizeof(int32_t);
2212 tok2str(ubik_lock_types
, "type %d", temp
);
2214 case 20003: /* Write */
2222 case 20005: /* Get file */
2226 case 20006: /* Send file */
2231 printf(" dbversion");
2234 case 20009: /* Truncate */
2242 case 20012: /* Set version */
2245 printf(" oldversion");
2247 printf(" newversion");
2261 * Handle Ubik replies to any one of the replicated database services
2265 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2267 struct rx_header
*rxh
;
2269 if (length
< sizeof(struct rx_header
))
2272 rxh
= (struct rx_header
*) bp
;
2275 * Print out the ubik call we're invoking. This table was gleaned
2276 * from ubik/ubik_int.xg
2279 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2281 bp
+= sizeof(struct rx_header
);
2284 * If it was a data packet, print out the arguments to the Ubik calls
2287 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2289 case 10000: /* Beacon */
2292 case 20004: /* Get version */
2293 printf(" dbversion");
2301 * Otherwise, print out "yes" it it was a beacon packet (because
2302 * that's how yes votes are returned, go figure), otherwise
2303 * just print out the error code.
2308 case 10000: /* Beacon */
2309 printf(" vote yes until");
2324 * Handle RX ACK packets.
2328 rx_ack_print(register const u_char
*bp
, int length
)
2330 struct rx_ackPacket
*rxa
;
2333 if (length
< sizeof(struct rx_header
))
2336 bp
+= sizeof(struct rx_header
);
2339 * This may seem a little odd .... the rx_ackPacket structure
2340 * contains an array of individual packet acknowledgements
2341 * (used for selective ack/nack), but since it's variable in size,
2342 * we don't want to truncate based on the size of the whole
2343 * rx_ackPacket structure.
2346 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2348 rxa
= (struct rx_ackPacket
*) bp
;
2349 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2352 * Print out a few useful things from the ack packet structure
2356 printf(" bufspace %d maxskew %d",
2357 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2358 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2360 printf(" first %d serial %d reason %s",
2361 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2362 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2365 * Okay, now we print out the ack array. The way _this_ works
2366 * is that we start at "first", and step through the ack array.
2367 * If we have a contiguous range of acks/nacks, try to
2368 * collapse them into a range.
2370 * If you're really clever, you might have noticed that this
2371 * doesn't seem quite correct. Specifically, due to structure
2372 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2373 * yield the start of the ack array (because RX_MAXACKS is 255
2374 * and the structure will likely get padded to a 2 or 4 byte
2375 * boundary). However, this is the way it's implemented inside
2376 * of AFS - the start of the extra fields are at
2377 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2378 * the exact start of the ack array. Sigh. That's why we aren't
2379 * using bp, but instead use rxa->acks[]. But nAcks gets added
2380 * to bp after this, so bp ends up at the right spot. Go figure.
2383 if (rxa
->nAcks
!= 0) {
2385 TCHECK2(bp
[0], rxa
->nAcks
);
2388 * Sigh, this is gross, but it seems to work to collapse
2392 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2393 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2396 * I figured this deserved _some_ explanation.
2397 * First, print "acked" and the packet seq
2398 * number if this is the first time we've
2399 * seen an acked packet.
2404 rxa
->firstPacket
+ i
);
2409 * Otherwise, if the there is a skip in
2410 * the range (such as an nacked packet in
2411 * the middle of some acked packets),
2412 * then print the current packet number
2413 * seperated from the last number by
2417 else if (last
!= i
- 1) {
2418 printf(",%d", rxa
->firstPacket
+ i
);
2423 * We always set last to the value of
2424 * the last ack we saw. Conversely, start
2425 * is set to the value of the first ack
2426 * we saw in a range.
2432 * Okay, this bit a code gets executed when
2433 * we hit a nack ... in _this_ case we
2434 * want to print out the range of packets
2435 * that were acked, so we need to print
2436 * the _previous_ packet number seperated
2437 * from the first by a dash (-). Since we
2438 * already printed the first packet above,
2439 * just print the final packet. Don't
2440 * do this if there will be a single-length
2443 } else if (last
== i
- 1 && start
!= last
)
2444 printf("-%d", rxa
->firstPacket
+ i
- 1);
2447 * So, what's going on here? We ran off the end of the
2448 * ack list, and if we got a range we need to finish it up.
2449 * So we need to determine if the last packet in the list
2450 * was an ack (if so, then last will be set to it) and
2451 * we need to see if the last range didn't start with the
2452 * last packet (because if it _did_, then that would mean
2453 * that the packet number has already been printed and
2454 * we don't need to print it again).
2457 if (last
== i
- 1 && start
!= last
)
2458 printf("-%d", rxa
->firstPacket
+ i
- 1);
2461 * Same as above, just without comments
2464 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2465 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2467 printf(" nacked %d",
2468 rxa
->firstPacket
+ i
);
2470 } else if (last
!= i
- 1) {
2471 printf(",%d", rxa
->firstPacket
+ i
);
2475 } else if (last
== i
- 1 && start
!= last
)
2476 printf("-%d", rxa
->firstPacket
+ i
- 1);
2478 if (last
== i
- 1 && start
!= last
)
2479 printf("-%d", rxa
->firstPacket
+ i
- 1);
2486 * These are optional fields; depending on your version of AFS,
2487 * you may or may not see them
2490 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2506 printf(" maxpackets");