]>
The Tcpdump Group git mirrors - tcpdump/blob - print-rx.c
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.21 2001-06-26 06:19:05 guy Exp $";
27 #include <sys/param.h>
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <netinet/in.h>
32 #include <arpa/inet.h>
34 #include "interface.h"
35 #include "addrtoname.h"
46 static struct tok rx_types
[] = {
47 { RX_PACKET_TYPE_DATA
, "data" },
48 { RX_PACKET_TYPE_ACK
, "ack" },
49 { RX_PACKET_TYPE_BUSY
, "busy" },
50 { RX_PACKET_TYPE_ABORT
, "abort" },
51 { RX_PACKET_TYPE_ACKALL
, "ackall" },
52 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
53 { RX_PACKET_TYPE_RESPONSE
, "response" },
54 { RX_PACKET_TYPE_DEBUG
, "debug" },
55 { RX_PACKET_TYPE_PARAMS
, "params" },
56 { RX_PACKET_TYPE_VERSION
, "version" },
60 static struct tok rx_flags
[] = {
61 { RX_CLIENT_INITIATED
, "client-init" },
62 { RX_REQUEST_ACK
, "req-ack" },
63 { RX_LAST_PACKET
, "last-pckt" },
64 { RX_MORE_PACKETS
, "more-pckts" },
65 { RX_FREE_PACKET
, "free-pckt" }
68 static struct tok fs_req
[] = {
69 { 130, "fetch-data" },
71 { 132, "fetch-status" },
72 { 133, "store-data" },
74 { 135, "store-status" },
75 { 136, "remove-file" },
76 { 137, "create-file" },
82 { 143, "oldsetlock" },
83 { 144, "oldextlock" },
84 { 145, "oldrellock" },
87 { 148, "get-vlinfo" },
88 { 149, "get-vlstats" },
89 { 150, "set-vlstats" },
90 { 151, "get-rootvl" },
91 { 152, "check-token" },
93 { 154, "nget-vlinfo" },
100 { 161, "dfs-lookup" },
101 { 162, "dfs-flushcps" },
102 { 163, "dfs-symlink" },
106 static struct tok cb_req
[] = {
115 { 212, "whoareyou" },
117 { 214, "probeuuid" },
121 static struct tok pt_req
[] = {
123 { 501, "where-is-it" },
124 { 502, "dump-entry" },
125 { 503, "add-to-group" },
126 { 504, "name-to-id" },
127 { 505, "id-to-name" },
129 { 507, "remove-from-group" },
131 { 509, "new-entry" },
134 { 512, "list-entry" },
135 { 513, "change-entry" },
136 { 514, "list-elements" },
137 { 515, "same-mbr-of" },
138 { 516, "set-fld-sentry" },
139 { 517, "list-owned" },
141 { 519, "get-host-cps" },
142 { 520, "update-entry" },
146 static struct tok vldb_req
[] = {
147 { 501, "create-entry" },
148 { 502, "delete-entry" },
149 { 503, "get-entry-by-id" },
150 { 504, "get-entry-by-name" },
151 { 505, "get-new-volume-id" },
152 { 506, "replace-entry" },
153 { 507, "update-entry" },
155 { 509, "releaselock" },
156 { 510, "list-entry" },
157 { 511, "list-attrib" },
158 { 512, "linked-list" },
159 { 513, "get-stats" },
161 { 515, "get-addrs" },
162 { 516, "change-addr" },
163 { 517, "create-entry-n" },
164 { 518, "get-entry-by-id-n" },
165 { 519, "get-entry-by-name-n" },
166 { 520, "replace-entry-n" },
167 { 521, "list-entry-n" },
168 { 522, "list-attrib-n" },
169 { 523, "linked-list-n" },
170 { 524, "update-entry-by-name" },
171 { 525, "create-entry-u" },
172 { 526, "get-entry-by-id-u" },
173 { 527, "get-entry-by-name-u" },
174 { 528, "replace-entry-u" },
175 { 529, "list-entry-u" },
176 { 530, "list-attrib-u" },
177 { 531, "linked-list-u" },
179 { 533, "get-addrs-u" },
183 static struct tok kauth_req
[] = {
185 { 21, "authenticate" },
186 { 22, "authenticate-v2" },
188 { 3, "get-ticket-old" },
189 { 23, "get-ticket" },
192 { 6, "create-user" },
193 { 7, "delete-user" },
199 { 13, "get-random-key" },
201 { 15, "lock-status" },
205 static struct tok vol_req
[] = {
206 { 100, "create-volume" },
207 { 101, "delete-volume" },
210 { 104, "end-trans" },
212 { 106, "set-flags" },
213 { 107, "get-flags" },
214 { 108, "trans-create" },
216 { 110, "get-nth-volume" },
217 { 111, "set-forwarding" },
219 { 113, "get-status" },
220 { 114, "sig-restore" },
221 { 115, "list-partitions" },
222 { 116, "list-volumes" },
223 { 117, "set-id-types" },
225 { 119, "partition-info" },
227 { 121, "list-one-volume" },
230 { 124, "x-list-volumes" },
231 { 125, "x-list-one-volume" },
233 { 127, "x-list-partitions" },
234 { 128, "forward-multiple" },
238 static struct tok bos_req
[] = {
239 { 80, "create-bnode" },
240 { 81, "delete-bnode" },
241 { 82, "set-status" },
242 { 83, "get-status" },
243 { 84, "enumerate-instance" },
244 { 85, "get-instance-info" },
245 { 86, "get-instance-parm" },
246 { 87, "add-superuser" },
247 { 88, "delete-superuser" },
248 { 89, "list-superusers" },
251 { 92, "delete-key" },
252 { 93, "set-cell-name" },
253 { 94, "get-cell-name" },
254 { 95, "get-cell-host" },
255 { 96, "add-cell-host" },
256 { 97, "delete-cell-host" },
257 { 98, "set-t-status" },
258 { 99, "shutdown-all" },
259 { 100, "restart-all" },
260 { 101, "startup-all" },
261 { 102, "set-noauth-flag" },
264 { 105, "start-bozo-install" },
265 { 106, "uninstall" },
266 { 107, "get-dates" },
269 { 110, "set-restart-time" },
270 { 111, "get-restart-time" },
271 { 112, "start-bozo-log" },
273 { 114, "get-instance-strings" },
277 static struct tok ubik_req
[] = {
278 { 10000, "vote-beacon" },
279 { 10001, "vote-debug-old" },
280 { 10002, "vote-sdebug-old" },
281 { 10003, "vote-getsyncsite" },
282 { 10004, "vote-debug" },
283 { 10005, "vote-sdebug" },
284 { 20000, "disk-begin" },
285 { 20001, "disk-commit" },
286 { 20002, "disk-lock" },
287 { 20003, "disk-write" },
288 { 20004, "disk-getversion" },
289 { 20005, "disk-getfile" },
290 { 20006, "disk-sendfile" },
291 { 20007, "disk-abort" },
292 { 20008, "disk-releaselocks" },
293 { 20009, "disk-truncate" },
294 { 20010, "disk-probe" },
295 { 20011, "disk-writev" },
296 { 20012, "disk-interfaceaddr" },
297 { 20013, "disk-setversion" },
301 #define VOTE_LOW 10000
302 #define VOTE_HIGH 10005
303 #define DISK_LOW 20000
304 #define DISK_HIGH 20013
306 static struct tok cb_types
[] = {
313 static struct tok ubik_lock_types
[] = {
320 static char *voltype
[] = { "read-write", "read-only", "backup" };
322 static struct tok afs_fs_errors
[] = {
323 { 101, "salvage volume" },
324 { 102, "no such vnode" },
325 { 103, "no such volume" },
326 { 104, "volume exist" },
327 { 105, "no service" },
328 { 106, "volume offline" },
329 { 107, "voline online" },
331 { 109, "diskquota exceeded" },
332 { 110, "volume busy" },
333 { 111, "volume moved" },
334 { 112, "AFS IO error" },
335 { -100, "restarting fileserver" },
340 * Reasons for acknowledging a packet
343 static struct tok rx_ack_reasons
[] = {
344 { 1, "ack requested" },
345 { 2, "duplicate packet" },
346 { 3, "out of sequence" },
347 { 4, "exceeds window" },
348 { 5, "no buffer space" },
350 { 7, "ping response" },
356 * Cache entries we keep around so we can figure out the RX opcode
357 * numbers for replies. This allows us to make sense of RX reply packets.
360 struct rx_cache_entry
{
361 u_int32_t callnum
; /* Call number (net order) */
362 struct in_addr client
; /* client IP address (net order) */
363 struct in_addr server
; /* server IP address (net order) */
364 int dport
; /* server port (host order) */
365 u_short serviceId
; /* Service identifier (net order) */
366 u_int32_t opcode
; /* RX opcode (host order) */
369 #define RX_CACHE_SIZE 64
371 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
373 static int rx_cache_next
= 0;
374 static int rx_cache_hint
= 0;
375 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
376 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
379 static void ack_print(const u_char
*, int);
380 static void fs_print(const u_char
*, int);
381 static void fs_reply_print(const u_char
*, int, int32_t);
382 static void acl_print(u_char
*, int, u_char
*);
383 static void cb_print(const u_char
*, int);
384 static void cb_reply_print(const u_char
*, int, int32_t);
385 static void prot_print(const u_char
*, int);
386 static void prot_reply_print(const u_char
*, int, int32_t);
387 static void vldb_print(const u_char
*, int);
388 static void vldb_reply_print(const u_char
*, int, int32_t);
389 static void kauth_print(const u_char
*, int);
390 static void kauth_reply_print(const u_char
*, int, int32_t);
391 static void vol_print(const u_char
*, int);
392 static void vol_reply_print(const u_char
*, int, int32_t);
393 static void bos_print(const u_char
*, int);
394 static void bos_reply_print(const u_char
*, int, int32_t);
395 static void ubik_print(const u_char
*, int);
396 static void ubik_reply_print(const u_char
*, int, int32_t);
398 static void rx_ack_print(const u_char
*, int);
400 static int is_ubik(u_int32_t
);
403 * Handle the rx-level packet. See if we know what port it's going to so
404 * we can peek at the afs call inside
408 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
411 register struct rx_header
*rxh
;
415 if (snapend
- bp
< sizeof (struct rx_header
)) {
416 printf(" [|rx] (%d)", length
);
420 rxh
= (struct rx_header
*) bp
;
422 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
428 printf(" cid %08x call# %d",
429 (int) EXTRACT_32BITS(&rxh
->cid
),
430 (int) EXTRACT_32BITS(&rxh
->callNumber
));
432 printf(" seq %d ser %d",
433 (int) EXTRACT_32BITS(&rxh
->seq
),
434 (int) EXTRACT_32BITS(&rxh
->serial
));
437 printf(" secindex %d serviceid %hu",
438 (int) rxh
->securityIndex
,
439 EXTRACT_16BITS(&rxh
->serviceId
));
442 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
443 if (rxh
->flags
& rx_flags
[i
].v
) {
450 printf("<%s>", rx_flags
[i
].s
);
456 * Try to handle AFS calls that we know about. Check the destination
457 * port and make sure it's a data packet. Also, make sure the
458 * seq number is 1 (because otherwise it's a continuation packet,
459 * and we can't interpret that). Also, seems that reply packets
460 * do not have the client-init flag set, so we check for that
464 if (rxh
->type
== RX_PACKET_TYPE_ACK
)
465 ack_print(bp
, length
);
466 else if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
467 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
468 rxh
->flags
& RX_CLIENT_INITIATED
) {
471 * Insert this call into the call cache table, so we
472 * have a chance to print out replies
475 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
478 case FS_RX_PORT
: /* AFS file service */
479 fs_print(bp
, length
);
481 case CB_RX_PORT
: /* AFS callback service */
482 cb_print(bp
, length
);
484 case PROT_RX_PORT
: /* AFS protection service */
485 prot_print(bp
, length
);
487 case VLDB_RX_PORT
: /* AFS VLDB service */
488 vldb_print(bp
, length
);
490 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
491 kauth_print(bp
, length
);
493 case VOL_RX_PORT
: /* AFS Volume service */
494 vol_print(bp
, length
);
496 case BOS_RX_PORT
: /* AFS BOS service */
497 bos_print(bp
, length
);
504 * If it's a reply (client-init is _not_ set, but seq is one)
505 * then look it up in the cache. If we find it, call the reply
506 * printing functions Note that we handle abort packets here,
507 * because printing out the return code can be useful at times.
510 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
511 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
512 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
513 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
514 rx_cache_find(rxh
, (const struct ip
*) bp2
,
518 case FS_RX_PORT
: /* AFS file service */
519 fs_reply_print(bp
, length
, opcode
);
521 case CB_RX_PORT
: /* AFS callback service */
522 cb_reply_print(bp
, length
, opcode
);
524 case PROT_RX_PORT
: /* AFS PT service */
525 prot_reply_print(bp
, length
, opcode
);
527 case VLDB_RX_PORT
: /* AFS VLDB service */
528 vldb_reply_print(bp
, length
, opcode
);
530 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
531 kauth_reply_print(bp
, length
, opcode
);
533 case VOL_RX_PORT
: /* AFS Volume service */
534 vol_reply_print(bp
, length
, opcode
);
536 case BOS_RX_PORT
: /* AFS BOS service */
537 bos_reply_print(bp
, length
, opcode
);
544 * If it's an RX ack packet, then use the appropriate ack decoding
545 * function (there isn't any service-specific information in the
546 * ack packet, so we can use one for all AFS services)
549 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
550 rx_ack_print(bp
, length
);
553 printf(" (%d)", length
);
557 * Insert an entry into the cache. Taken from print-nfs.c
561 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
564 struct rx_cache_entry
*rxent
;
565 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
567 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
570 rxent
= &rx_cache
[rx_cache_next
];
572 if (++rx_cache_next
>= RX_CACHE_SIZE
)
575 rxent
->callnum
= rxh
->callNumber
;
576 rxent
->client
= ip
->ip_src
;
577 rxent
->server
= ip
->ip_dst
;
578 rxent
->dport
= dport
;
579 rxent
->serviceId
= rxh
->serviceId
;
580 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
584 * Lookup an entry in the cache. Also taken from print-nfs.c
586 * Note that because this is a reply, we're looking at the _source_
591 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
595 struct rx_cache_entry
*rxent
;
596 u_int32_t clip
= ip
->ip_dst
.s_addr
;
597 u_int32_t sip
= ip
->ip_src
.s_addr
;
599 /* Start the search where we last left off */
603 rxent
= &rx_cache
[i
];
604 if (rxent
->callnum
== rxh
->callNumber
&&
605 rxent
->client
.s_addr
== clip
&&
606 rxent
->server
.s_addr
== sip
&&
607 rxent
->serviceId
== rxh
->serviceId
&&
608 rxent
->dport
== sport
) {
610 /* We got a match! */
613 *opcode
= rxent
->opcode
;
616 if (++i
> RX_CACHE_SIZE
)
618 } while (i
!= rx_cache_hint
);
620 /* Our search failed */
625 * These extrememly grody macros handle the printing of various AFS stuff.
628 #define FIDOUT() { unsigned long n1, n2, n3; \
629 TCHECK2(bp[0], sizeof(int32_t) * 3); \
630 n1 = EXTRACT_32BITS(bp); \
631 bp += sizeof(int32_t); \
632 n2 = EXTRACT_32BITS(bp); \
633 bp += sizeof(int32_t); \
634 n3 = EXTRACT_32BITS(bp); \
635 bp += sizeof(int32_t); \
636 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
639 #define STROUT(MAX) { int i; \
640 TCHECK2(bp[0], sizeof(int32_t)); \
641 i = (int) EXTRACT_32BITS(bp); \
642 bp += sizeof(int32_t); \
644 strncpy(s, (char *) bp, min(MAX, i)); \
646 printf(" \"%s\"", s); \
647 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
650 #define INTOUT() { int i; \
651 TCHECK2(bp[0], sizeof(int32_t)); \
652 i = (int) EXTRACT_32BITS(bp); \
653 bp += sizeof(int32_t); \
657 #define UINTOUT() { unsigned long i; \
658 TCHECK2(bp[0], sizeof(int32_t)); \
659 i = EXTRACT_32BITS(bp); \
660 bp += sizeof(int32_t); \
664 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
665 TCHECK2(bp[0], sizeof(int32_t)); \
666 t = (time_t) EXTRACT_32BITS(bp); \
667 bp += sizeof(int32_t); \
668 tm = localtime(&t); \
669 strftime(str, 256, "%Y/%m/%d %T", tm); \
670 printf(" %s", str); \
673 #define STOREATTROUT() { unsigned long mask, i; \
674 TCHECK2(bp[0], (sizeof(int32_t)*6)); \
675 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
676 if (mask) printf (" StoreStatus"); \
677 if (mask & 1) { printf(" date"); DATEOUT(); } \
678 else bp += sizeof(int32_t); \
679 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
680 if (mask & 2) printf(" owner %lu", i); \
681 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
682 if (mask & 4) printf(" group %lu", i); \
683 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
684 if (mask & 8) printf(" mode %lo", i & 07777); \
685 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
686 if (mask & 16) printf(" segsize %lu", i); \
687 /* undocumented in 3.3 docu */ \
688 if (mask & 1024) printf(" fsync"); \
691 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
692 TCHECK2(bp[0], sizeof(int32_t) * 2); \
693 epoch = EXTRACT_32BITS(bp); \
694 bp += sizeof(int32_t); \
695 counter = EXTRACT_32BITS(bp); \
696 bp += sizeof(int32_t); \
697 printf(" %d.%d", epoch, counter); \
700 #define AFSUUIDOUT() {u_int32_t temp; int i; \
701 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
702 temp = EXTRACT_32BITS(bp); \
703 bp += sizeof(u_int32_t); \
704 printf(" %08x", temp); \
705 temp = EXTRACT_32BITS(bp); \
706 bp += sizeof(u_int32_t); \
707 printf("%04x", temp); \
708 temp = EXTRACT_32BITS(bp); \
709 bp += sizeof(u_int32_t); \
710 printf("%04x", temp); \
711 for (i = 0; i < 8; i++) { \
712 temp = EXTRACT_32BITS(bp); \
713 bp += sizeof(u_int32_t); \
714 printf("%02x", (unsigned char) temp); \
719 * This is the sickest one of all
722 #define VECOUT(MAX) { char *sp; \
724 TCHECK2(bp[0], MAX * sizeof(int32_t)); \
726 for (k = 0; k < MAX; k++) { \
727 *sp++ = (char) EXTRACT_32BITS(bp); \
728 bp += sizeof(int32_t); \
731 printf(" \"%s\"", s); \
735 ack_print(register const u_char
*bp
, int length
)
743 if (length
<= sizeof(struct rx_header
))
746 bp
+= sizeof(struct rx_header
);
749 * Packets < firstPacket are implicitly acknowledged and may
750 * be discarded by the sender.
752 * Packets >= firstPacket+nAcks are implicitly NOT acknowledged.
754 * No packets with sequence numbers >= firstPacket should be
755 * discarded by the sender (they may thrown out at any time by
758 #define RX_ACK_REASONS "RDOXSprn"
759 /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space,
760 * Ping, ping_Response, No_{progress, particular_reason}.
763 struct rx_ackPacket
{
764 u_short bufferSpace
; /* Skip! */
765 u_short maxSkew
; /* Skip! */
767 u_long previousPacket
; /* Obsolete! */
768 u_long serial
; /* Serial that prompted the ack, */
769 u_char reason
; /* and the reason why. */
771 u_char acks
[RX_MAXACKS
]; /* Selective acks (not a bitmap). */
774 #define RX_ACK_TYPE_NACK 0
776 TCHECK2(bp
[0], 8); /* bufferSpace and maxSkew */
778 printf(" fir %u", (unsigned)EXTRACT_32BITS(bp
));
780 TCHECK2(bp
[0], 8); /* previousPacket and serial */
782 printf(" %u", (unsigned)EXTRACT_32BITS(bp
));
785 printf("%c", RX_ACK_REASONS
[(*bp
- 1) & 07u]);
786 bp
+= 1; /* reason */
791 for (i
= 0; i
< nAcks
; i
++) {
793 putchar(*bp
== RX_ACK_TYPE_NACK
? '-' : '*');
804 * Handle calls to the AFS file service (fs)
808 fs_print(register const u_char
*bp
, int length
)
814 if (length
<= sizeof(struct rx_header
))
817 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
822 * Print out the afs call we're invoking. The table used here was
823 * gleaned from fsint/afsint.xg
826 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
828 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
831 * Print out arguments to some of the AFS calls. This stuff is
835 bp
+= sizeof(struct rx_header
) + 4;
838 * Sigh. This is gross. Ritchie forgive me.
842 case 130: /* Fetch data */
849 case 131: /* Fetch ACL */
850 case 132: /* Fetch Status */
851 case 143: /* Old set lock */
852 case 144: /* Old extend lock */
853 case 145: /* Old release lock */
854 case 156: /* Set lock */
855 case 157: /* Extend lock */
856 case 158: /* Release lock */
859 case 135: /* Store status */
863 case 133: /* Store data */
873 case 134: /* Store ACL */
875 char a
[AFSOPAQUEMAX
+1];
878 i
= EXTRACT_32BITS(bp
);
879 bp
+= sizeof(int32_t);
881 i
= min(AFSOPAQUEMAX
, i
);
882 strncpy(a
, (char *) bp
, i
);
884 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
887 case 137: /* Create file */
888 case 141: /* MakeDir */
893 case 136: /* Remove file */
894 case 142: /* Remove directory */
898 case 138: /* Rename file */
906 case 139: /* Symlink */
918 case 148: /* Get volume info */
921 case 149: /* Get volume stats */
922 case 150: /* Set volume stats */
926 case 154: /* New get volume info */
930 case 155: /* Bulk stat */
934 j
= EXTRACT_32BITS(bp
);
935 bp
+= sizeof(int32_t);
937 for (i
= 0; i
< j
; i
++) {
956 * Handle replies to the AFS file service
960 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
964 struct rx_header
*rxh
;
966 if (length
<= sizeof(struct rx_header
))
969 rxh
= (struct rx_header
*) bp
;
972 * Print out the afs call we're invoking. The table used here was
973 * gleaned from fsint/afsint.xg
976 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
978 bp
+= sizeof(struct rx_header
);
981 * If it was a data packet, interpret the response
984 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
986 case 131: /* Fetch ACL */
988 char a
[AFSOPAQUEMAX
+1];
990 i
= EXTRACT_32BITS(bp
);
991 bp
+= sizeof(int32_t);
993 i
= min(AFSOPAQUEMAX
, i
);
994 strncpy(a
, (char *) bp
, i
);
996 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
999 case 137: /* Create file */
1000 case 141: /* MakeDir */
1004 case 151: /* Get root volume */
1005 printf(" root volume");
1008 case 153: /* Get time */
1014 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1018 * Otherwise, just print out the return code
1020 TCHECK2(bp
[0], sizeof(int32_t));
1021 i
= (int) EXTRACT_32BITS(bp
);
1022 bp
+= sizeof(int32_t);
1024 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
1026 printf(" strange fs reply of type %d", rxh
->type
);
1036 * Print out an AFS ACL string. An AFS ACL is a string that has the
1039 * <positive> <negative>
1043 * "positive" and "negative" are integers which contain the number of
1044 * positive and negative ACL's in the string. The uid/aclbits pair are
1045 * ASCII strings containing the UID/PTS record and and a ascii number
1046 * representing a logical OR of all the ACL permission bits
1050 acl_print(u_char
*s
, int maxsize
, u_char
*end
)
1056 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1059 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1068 * This wacky order preserves the order used by the "fs" command
1071 #define ACLOUT(acl) \
1072 if (acl & PRSFS_READ) \
1074 if (acl & PRSFS_LOOKUP) \
1076 if (acl & PRSFS_INSERT) \
1078 if (acl & PRSFS_DELETE) \
1080 if (acl & PRSFS_WRITE) \
1082 if (acl & PRSFS_LOCK) \
1084 if (acl & PRSFS_ADMINISTER) \
1087 for (i
= 0; i
< pos
; i
++) {
1088 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1091 printf(" +{%s ", user
);
1098 for (i
= 0; i
< neg
; i
++) {
1099 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1102 printf(" -{%s ", user
);
1117 * Handle calls to the AFS callback service
1121 cb_print(register const u_char
*bp
, int length
)
1126 if (length
<= sizeof(struct rx_header
))
1129 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1134 * Print out the afs call we're invoking. The table used here was
1135 * gleaned from fsint/afscbint.xg
1138 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1140 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1142 bp
+= sizeof(struct rx_header
) + 4;
1145 * Print out the afs call we're invoking. The table used here was
1146 * gleaned from fsint/afscbint.xg
1150 case 204: /* Callback */
1154 j
= EXTRACT_32BITS(bp
);
1155 bp
+= sizeof(int32_t);
1157 for (i
= 0; i
< j
; i
++) {
1166 j
= EXTRACT_32BITS(bp
);
1167 bp
+= sizeof(int32_t);
1172 for (i
= 0; i
< j
; i
++) {
1178 t
= EXTRACT_32BITS(bp
);
1179 bp
+= sizeof(int32_t);
1180 tok2str(cb_types
, "type %d", t
);
1199 * Handle replies to the AFS Callback Service
1203 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1205 struct rx_header
*rxh
;
1207 if (length
<= sizeof(struct rx_header
))
1210 rxh
= (struct rx_header
*) bp
;
1213 * Print out the afs call we're invoking. The table used here was
1214 * gleaned from fsint/afscbint.xg
1217 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1219 bp
+= sizeof(struct rx_header
);
1222 * If it was a data packet, interpret the response.
1225 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1227 case 213: /* InitCallBackState3 */
1235 * Otherwise, just print out the return code
1248 * Handle calls to the AFS protection database server
1252 prot_print(register const u_char
*bp
, int length
)
1258 if (length
<= sizeof(struct rx_header
))
1261 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1266 * Print out the afs call we're invoking. The table used here was
1267 * gleaned from ptserver/ptint.xg
1270 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1274 if (is_ubik(pt_op
)) {
1275 ubik_print(bp
, length
);
1279 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1282 * Decode some of the arguments to the PT calls
1285 bp
+= sizeof(struct rx_header
) + 4;
1288 case 500: /* I New User */
1295 case 501: /* Where is it */
1296 case 506: /* Delete */
1297 case 508: /* Get CPS */
1298 case 512: /* List entry */
1299 case 514: /* List elements */
1300 case 517: /* List owned */
1301 case 518: /* Get CPS2 */
1302 case 519: /* Get host CPS */
1306 case 502: /* Dump entry */
1310 case 503: /* Add to group */
1311 case 507: /* Remove from group */
1312 case 515: /* Is a member of? */
1318 case 504: /* Name to ID */
1322 j
= EXTRACT_32BITS(bp
);
1323 bp
+= sizeof(int32_t);
1326 * Who designed this chicken-shit protocol?
1328 * Each character is stored as a 32-bit
1332 for (i
= 0; i
< j
; i
++) {
1339 case 505: /* Id to name */
1344 i
= EXTRACT_32BITS(bp
);
1345 bp
+= sizeof(int32_t);
1346 for (j
= 0; j
< i
; j
++)
1352 case 509: /* New entry */
1359 case 511: /* Set max */
1365 case 513: /* Change entry */
1374 case 520: /* Update entry */
1391 * Handle replies to the AFS protection service
1395 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1397 struct rx_header
*rxh
;
1401 if (length
< sizeof(struct rx_header
))
1404 rxh
= (struct rx_header
*) bp
;
1407 * Print out the afs call we're invoking. The table used here was
1408 * gleaned from ptserver/ptint.xg. Check to see if it's a
1409 * Ubik call, however.
1414 if (is_ubik(opcode
)) {
1415 ubik_reply_print(bp
, length
, opcode
);
1419 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1421 bp
+= sizeof(struct rx_header
);
1424 * If it was a data packet, interpret the response
1427 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1429 case 504: /* Name to ID */
1434 i
= EXTRACT_32BITS(bp
);
1435 bp
+= sizeof(int32_t);
1436 for (j
= 0; j
< i
; j
++)
1442 case 505: /* ID to name */
1446 j
= EXTRACT_32BITS(bp
);
1447 bp
+= sizeof(int32_t);
1450 * Who designed this chicken-shit protocol?
1452 * Each character is stored as a 32-bit
1456 for (i
= 0; i
< j
; i
++) {
1463 case 508: /* Get CPS */
1464 case 514: /* List elements */
1465 case 517: /* List owned */
1466 case 518: /* Get CPS2 */
1467 case 519: /* Get host CPS */
1471 j
= EXTRACT_32BITS(bp
);
1472 bp
+= sizeof(int32_t);
1473 for (i
= 0; i
< j
; i
++) {
1480 case 510: /* List max */
1491 * Otherwise, just print out the return code
1504 * Handle calls to the AFS volume location database service
1508 vldb_print(register const u_char
*bp
, int length
)
1514 if (length
<= sizeof(struct rx_header
))
1517 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1522 * Print out the afs call we're invoking. The table used here was
1523 * gleaned from vlserver/vldbint.xg
1526 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1530 if (is_ubik(vldb_op
)) {
1531 ubik_print(bp
, length
);
1534 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1537 * Decode some of the arguments to the VLDB calls
1540 bp
+= sizeof(struct rx_header
) + 4;
1543 case 501: /* Create new volume */
1544 case 517: /* Create entry N */
1547 case 502: /* Delete entry */
1548 case 503: /* Get entry by ID */
1549 case 507: /* Update entry */
1550 case 508: /* Set lock */
1551 case 509: /* Release lock */
1552 case 518: /* Get entry by ID N */
1555 TCHECK2(bp
[0], sizeof(int32_t));
1556 i
= EXTRACT_32BITS(bp
);
1557 bp
+= sizeof(int32_t);
1559 printf(" type %s", voltype
[i
]);
1561 case 504: /* Get entry by name */
1562 case 519: /* Get entry by name N */
1563 case 524: /* Update entry by name */
1564 case 527: /* Get entry by name U */
1567 case 505: /* Get new vol id */
1571 case 506: /* Replace entry */
1572 case 520: /* Replace entry N */
1575 TCHECK2(bp
[0], sizeof(int32_t));
1576 i
= EXTRACT_32BITS(bp
);
1577 bp
+= sizeof(int32_t);
1579 printf(" type %s", voltype
[i
]);
1582 case 510: /* List entry */
1583 case 521: /* List entry N */
1598 * Handle replies to the AFS volume location database service
1602 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1604 struct rx_header
*rxh
;
1608 if (length
< sizeof(struct rx_header
))
1611 rxh
= (struct rx_header
*) bp
;
1614 * Print out the afs call we're invoking. The table used here was
1615 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1616 * Ubik call, however.
1621 if (is_ubik(opcode
)) {
1622 ubik_reply_print(bp
, length
, opcode
);
1626 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1628 bp
+= sizeof(struct rx_header
);
1631 * If it was a data packet, interpret the response
1634 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1636 case 510: /* List entry */
1639 printf(" nextindex");
1641 case 503: /* Get entry by id */
1642 case 504: /* Get entry by name */
1643 { unsigned long nservers
, j
;
1645 TCHECK2(bp
[0], sizeof(int32_t));
1646 bp
+= sizeof(int32_t);
1647 printf(" numservers");
1648 TCHECK2(bp
[0], sizeof(int32_t));
1649 nservers
= EXTRACT_32BITS(bp
);
1650 bp
+= sizeof(int32_t);
1651 printf(" %lu", nservers
);
1653 for (i
= 0; i
< 8; i
++) {
1654 TCHECK2(bp
[0], sizeof(int32_t));
1657 inet_ntoa(*((struct in_addr
*) bp
)));
1658 bp
+= sizeof(int32_t);
1660 printf(" partitions");
1661 for (i
= 0; i
< 8; i
++) {
1662 TCHECK2(bp
[0], sizeof(int32_t));
1663 j
= EXTRACT_32BITS(bp
);
1664 if (i
< nservers
&& j
<= 26)
1665 printf(" %c", 'a' + (int)j
);
1666 else if (i
< nservers
)
1668 bp
+= sizeof(int32_t);
1670 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1671 bp
+= 8 * sizeof(int32_t);
1680 case 505: /* Get new volume ID */
1684 case 521: /* List entry */
1685 case 529: /* List entry U */
1688 printf(" nextindex");
1690 case 518: /* Get entry by ID N */
1691 case 519: /* Get entry by name N */
1692 { unsigned long nservers
, j
;
1694 printf(" numservers");
1695 TCHECK2(bp
[0], sizeof(int32_t));
1696 nservers
= EXTRACT_32BITS(bp
);
1697 bp
+= sizeof(int32_t);
1698 printf(" %lu", nservers
);
1700 for (i
= 0; i
< 13; i
++) {
1701 TCHECK2(bp
[0], sizeof(int32_t));
1704 inet_ntoa(*((struct in_addr
*) bp
)));
1705 bp
+= sizeof(int32_t);
1707 printf(" partitions");
1708 for (i
= 0; i
< 13; i
++) {
1709 TCHECK2(bp
[0], sizeof(int32_t));
1710 j
= EXTRACT_32BITS(bp
);
1711 if (i
< nservers
&& j
<= 26)
1712 printf(" %c", 'a' + (int)j
);
1713 else if (i
< nservers
)
1715 bp
+= sizeof(int32_t);
1717 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1718 bp
+= 13 * sizeof(int32_t);
1727 case 526: /* Get entry by ID U */
1728 case 527: /* Get entry by name U */
1729 { unsigned long nservers
, j
;
1731 printf(" numservers");
1732 TCHECK2(bp
[0], sizeof(int32_t));
1733 nservers
= EXTRACT_32BITS(bp
);
1734 bp
+= sizeof(int32_t);
1735 printf(" %lu", nservers
);
1737 for (i
= 0; i
< 13; i
++) {
1746 TCHECK2(bp
[0], 4 * 13);
1748 printf(" partitions");
1749 for (i
= 0; i
< 13; i
++) {
1750 TCHECK2(bp
[0], sizeof(int32_t));
1751 j
= EXTRACT_32BITS(bp
);
1752 if (i
< nservers
&& j
<= 26)
1753 printf(" %c", 'a' + (int)j
);
1754 else if (i
< nservers
)
1756 bp
+= sizeof(int32_t);
1758 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1759 bp
+= 13 * sizeof(int32_t);
1773 * Otherwise, just print out the return code
1786 * Handle calls to the AFS Kerberos Authentication service
1790 kauth_print(register const u_char
*bp
, int length
)
1795 if (length
<= sizeof(struct rx_header
))
1798 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1803 * Print out the afs call we're invoking. The table used here was
1804 * gleaned from kauth/kauth.rg
1807 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1811 if (is_ubik(kauth_op
)) {
1812 ubik_print(bp
, length
);
1817 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1820 * Decode some of the arguments to the KA calls
1823 bp
+= sizeof(struct rx_header
) + 4;
1826 case 1: /* Authenticate old */;
1827 case 21: /* Authenticate */
1828 case 22: /* Authenticate-V2 */
1829 case 2: /* Change PW */
1830 case 5: /* Set fields */
1831 case 6: /* Create user */
1832 case 7: /* Delete user */
1833 case 8: /* Get entry */
1834 case 14: /* Unlock */
1835 case 15: /* Lock status */
1836 printf(" principal");
1840 case 3: /* GetTicket-old */
1841 case 23: /* GetTicket */
1848 TCHECK2(bp
[0], sizeof(int32_t));
1849 i
= (int) EXTRACT_32BITS(bp
);
1850 bp
+= sizeof(int32_t);
1853 printf(" principal");
1858 case 4: /* Set Password */
1859 printf(" principal");
1865 case 12: /* Get password */
1876 printf(" [|kauth]");
1880 * Handle replies to the AFS Kerberos Authentication Service
1884 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1886 struct rx_header
*rxh
;
1888 if (length
<= sizeof(struct rx_header
))
1891 rxh
= (struct rx_header
*) bp
;
1894 * Print out the afs call we're invoking. The table used here was
1895 * gleaned from kauth/kauth.rg
1900 if (is_ubik(opcode
)) {
1901 ubik_reply_print(bp
, length
, opcode
);
1905 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1907 bp
+= sizeof(struct rx_header
);
1910 * If it was a data packet, interpret the response.
1913 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1914 /* Well, no, not really. Leave this for later */
1918 * Otherwise, just print out the return code
1927 printf(" [|kauth]");
1931 * Handle calls to the AFS Volume location service
1935 vol_print(register const u_char
*bp
, int length
)
1939 if (length
<= sizeof(struct rx_header
))
1942 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1947 * Print out the afs call we're invoking. The table used here was
1948 * gleaned from volser/volint.xg
1951 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1953 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1956 * Normally there would be a switch statement here to decode the
1957 * arguments to the AFS call, but since I don't have access to
1958 * an AFS server (yet) and I'm not an AFS admin, I can't
1959 * test any of these calls. Leave this blank for now.
1969 * Handle replies to the AFS Volume Service
1973 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1975 struct rx_header
*rxh
;
1977 if (length
<= sizeof(struct rx_header
))
1980 rxh
= (struct rx_header
*) bp
;
1983 * Print out the afs call we're invoking. The table used here was
1984 * gleaned from volser/volint.xg
1987 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
1989 bp
+= sizeof(struct rx_header
);
1992 * If it was a data packet, interpret the response.
1995 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1996 /* Well, no, not really. Leave this for later */
2000 * Otherwise, just print out the return code
2013 * Handle calls to the AFS BOS service
2017 bos_print(register const u_char
*bp
, int length
)
2022 if (length
<= sizeof(struct rx_header
))
2025 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
2030 * Print out the afs call we're invoking. The table used here was
2031 * gleaned from bozo/bosint.xg
2034 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2036 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2039 * Decode some of the arguments to the BOS calls
2042 bp
+= sizeof(struct rx_header
) + 4;
2045 case 80: /* Create B node */
2048 printf(" instance");
2051 case 81: /* Delete B node */
2052 case 83: /* Get status */
2053 case 85: /* Get instance info */
2054 case 87: /* Add super user */
2055 case 88: /* Delete super user */
2056 case 93: /* Set cell name */
2057 case 96: /* Add cell host */
2058 case 97: /* Delete cell host */
2059 case 104: /* Restart */
2060 case 106: /* Uninstall */
2061 case 108: /* Exec */
2062 case 112: /* Getlog */
2063 case 114: /* Get instance strings */
2066 case 82: /* Set status */
2067 case 98: /* Set T status */
2072 case 86: /* Get instance parm */
2077 case 84: /* Enumerate instance */
2078 case 89: /* List super users */
2079 case 90: /* List keys */
2080 case 91: /* Add key */
2081 case 92: /* Delete key */
2082 case 95: /* Get cell host */
2085 case 105: /* Install */
2105 * Handle replies to the AFS BOS Service
2109 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2111 struct rx_header
*rxh
;
2113 if (length
<= sizeof(struct rx_header
))
2116 rxh
= (struct rx_header
*) bp
;
2119 * Print out the afs call we're invoking. The table used here was
2120 * gleaned from volser/volint.xg
2123 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2125 bp
+= sizeof(struct rx_header
);
2128 * If it was a data packet, interpret the response.
2131 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2132 /* Well, no, not really. Leave this for later */
2136 * Otherwise, just print out the return code
2149 * Check to see if this is a Ubik opcode.
2153 is_ubik(u_int32_t opcode
)
2155 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2156 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2163 * Handle Ubik opcodes to any one of the replicated database services
2167 ubik_print(register const u_char
*bp
, int length
)
2173 * Print out the afs call we're invoking. The table used here was
2174 * gleaned from ubik/ubik_int.xg
2177 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2179 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2182 * Decode some of the arguments to the Ubik calls
2185 bp
+= sizeof(struct rx_header
) + 4;
2188 case 10000: /* Beacon */
2190 temp
= EXTRACT_32BITS(bp
);
2191 bp
+= sizeof(int32_t);
2192 printf(" syncsite %s", temp
? "yes" : "no");
2193 printf(" votestart");
2195 printf(" dbversion");
2200 case 10003: /* Get sync site */
2204 case 20000: /* Begin */
2205 case 20001: /* Commit */
2206 case 20007: /* Abort */
2207 case 20008: /* Release locks */
2208 case 20010: /* Writev */
2212 case 20002: /* Lock */
2221 temp
= EXTRACT_32BITS(bp
);
2222 bp
+= sizeof(int32_t);
2223 tok2str(ubik_lock_types
, "type %d", temp
);
2225 case 20003: /* Write */
2233 case 20005: /* Get file */
2237 case 20006: /* Send file */
2242 printf(" dbversion");
2245 case 20009: /* Truncate */
2253 case 20012: /* Set version */
2256 printf(" oldversion");
2258 printf(" newversion");
2272 * Handle Ubik replies to any one of the replicated database services
2276 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2278 struct rx_header
*rxh
;
2280 if (length
< sizeof(struct rx_header
))
2283 rxh
= (struct rx_header
*) bp
;
2286 * Print out the ubik call we're invoking. This table was gleaned
2287 * from ubik/ubik_int.xg
2290 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2292 bp
+= sizeof(struct rx_header
);
2295 * If it was a data packet, print out the arguments to the Ubik calls
2298 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2300 case 10000: /* Beacon */
2303 case 20004: /* Get version */
2304 printf(" dbversion");
2312 * Otherwise, print out "yes" it it was a beacon packet (because
2313 * that's how yes votes are returned, go figure), otherwise
2314 * just print out the error code.
2319 case 10000: /* Beacon */
2320 printf(" vote yes until");
2335 * Handle RX ACK packets.
2339 rx_ack_print(register const u_char
*bp
, int length
)
2341 struct rx_ackPacket
*rxa
;
2344 if (length
< sizeof(struct rx_header
))
2347 bp
+= sizeof(struct rx_header
);
2350 * This may seem a little odd .... the rx_ackPacket structure
2351 * contains an array of individual packet acknowledgements
2352 * (used for selective ack/nack), but since it's variable in size,
2353 * we don't want to truncate based on the size of the whole
2354 * rx_ackPacket structure.
2357 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2359 rxa
= (struct rx_ackPacket
*) bp
;
2360 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2363 * Print out a few useful things from the ack packet structure
2367 printf(" bufspace %d maxskew %d",
2368 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2369 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2371 printf(" first %d serial %d reason %s",
2372 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2373 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2376 * Okay, now we print out the ack array. The way _this_ works
2377 * is that we start at "first", and step through the ack array.
2378 * If we have a contiguous range of acks/nacks, try to
2379 * collapse them into a range.
2381 * If you're really clever, you might have noticed that this
2382 * doesn't seem quite correct. Specifically, due to structure
2383 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2384 * yield the start of the ack array (because RX_MAXACKS is 255
2385 * and the structure will likely get padded to a 2 or 4 byte
2386 * boundary). However, this is the way it's implemented inside
2387 * of AFS - the start of the extra fields are at
2388 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2389 * the exact start of the ack array. Sigh. That's why we aren't
2390 * using bp, but instead use rxa->acks[]. But nAcks gets added
2391 * to bp after this, so bp ends up at the right spot. Go figure.
2394 if (rxa
->nAcks
!= 0) {
2396 TCHECK2(bp
[0], rxa
->nAcks
);
2399 * Sigh, this is gross, but it seems to work to collapse
2403 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2404 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2407 * I figured this deserved _some_ explanation.
2408 * First, print "acked" and the packet seq
2409 * number if this is the first time we've
2410 * seen an acked packet.
2415 rxa
->firstPacket
+ i
);
2420 * Otherwise, if the there is a skip in
2421 * the range (such as an nacked packet in
2422 * the middle of some acked packets),
2423 * then print the current packet number
2424 * seperated from the last number by
2428 else if (last
!= i
- 1) {
2429 printf(",%d", rxa
->firstPacket
+ i
);
2434 * We always set last to the value of
2435 * the last ack we saw. Conversely, start
2436 * is set to the value of the first ack
2437 * we saw in a range.
2443 * Okay, this bit a code gets executed when
2444 * we hit a nack ... in _this_ case we
2445 * want to print out the range of packets
2446 * that were acked, so we need to print
2447 * the _previous_ packet number seperated
2448 * from the first by a dash (-). Since we
2449 * already printed the first packet above,
2450 * just print the final packet. Don't
2451 * do this if there will be a single-length
2454 } else if (last
== i
- 1 && start
!= last
)
2455 printf("-%d", rxa
->firstPacket
+ i
- 1);
2458 * So, what's going on here? We ran off the end of the
2459 * ack list, and if we got a range we need to finish it up.
2460 * So we need to determine if the last packet in the list
2461 * was an ack (if so, then last will be set to it) and
2462 * we need to see if the last range didn't start with the
2463 * last packet (because if it _did_, then that would mean
2464 * that the packet number has already been printed and
2465 * we don't need to print it again).
2468 if (last
== i
- 1 && start
!= last
)
2469 printf("-%d", rxa
->firstPacket
+ i
- 1);
2472 * Same as above, just without comments
2475 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2476 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2478 printf(" nacked %d",
2479 rxa
->firstPacket
+ i
);
2481 } else if (last
!= i
- 1) {
2482 printf(",%d", rxa
->firstPacket
+ i
);
2486 } else if (last
== i
- 1 && start
!= last
)
2487 printf("-%d", rxa
->firstPacket
+ i
- 1);
2489 if (last
== i
- 1 && start
!= last
)
2490 printf("-%d", rxa
->firstPacket
+ i
- 1);
2497 * These are optional fields; depending on your version of AFS,
2498 * you may or may not see them
2501 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2517 printf(" maxpackets");