]>
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.25 2001-07-09 09:24:09 itojun 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"
42 static struct tok rx_types
[] = {
43 { RX_PACKET_TYPE_DATA
, "data" },
44 { RX_PACKET_TYPE_ACK
, "ack" },
45 { RX_PACKET_TYPE_BUSY
, "busy" },
46 { RX_PACKET_TYPE_ABORT
, "abort" },
47 { RX_PACKET_TYPE_ACKALL
, "ackall" },
48 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
49 { RX_PACKET_TYPE_RESPONSE
, "response" },
50 { RX_PACKET_TYPE_DEBUG
, "debug" },
51 { RX_PACKET_TYPE_PARAMS
, "params" },
52 { RX_PACKET_TYPE_VERSION
, "version" },
56 static struct tok rx_flags
[] = {
57 { RX_CLIENT_INITIATED
, "client-init" },
58 { RX_REQUEST_ACK
, "req-ack" },
59 { RX_LAST_PACKET
, "last-pckt" },
60 { RX_MORE_PACKETS
, "more-pckts" },
61 { RX_FREE_PACKET
, "free-pckt" }
64 static struct tok fs_req
[] = {
65 { 130, "fetch-data" },
67 { 132, "fetch-status" },
68 { 133, "store-data" },
70 { 135, "store-status" },
71 { 136, "remove-file" },
72 { 137, "create-file" },
78 { 143, "oldsetlock" },
79 { 144, "oldextlock" },
80 { 145, "oldrellock" },
83 { 148, "get-vlinfo" },
84 { 149, "get-vlstats" },
85 { 150, "set-vlstats" },
86 { 151, "get-rootvl" },
87 { 152, "check-token" },
89 { 154, "nget-vlinfo" },
96 { 161, "dfs-lookup" },
97 { 162, "dfs-flushcps" },
98 { 163, "dfs-symlink" },
102 static struct tok cb_req
[] = {
111 { 212, "whoareyou" },
113 { 214, "probeuuid" },
117 static struct tok pt_req
[] = {
119 { 501, "where-is-it" },
120 { 502, "dump-entry" },
121 { 503, "add-to-group" },
122 { 504, "name-to-id" },
123 { 505, "id-to-name" },
125 { 507, "remove-from-group" },
127 { 509, "new-entry" },
130 { 512, "list-entry" },
131 { 513, "change-entry" },
132 { 514, "list-elements" },
133 { 515, "same-mbr-of" },
134 { 516, "set-fld-sentry" },
135 { 517, "list-owned" },
137 { 519, "get-host-cps" },
138 { 520, "update-entry" },
142 static struct tok vldb_req
[] = {
143 { 501, "create-entry" },
144 { 502, "delete-entry" },
145 { 503, "get-entry-by-id" },
146 { 504, "get-entry-by-name" },
147 { 505, "get-new-volume-id" },
148 { 506, "replace-entry" },
149 { 507, "update-entry" },
151 { 509, "releaselock" },
152 { 510, "list-entry" },
153 { 511, "list-attrib" },
154 { 512, "linked-list" },
155 { 513, "get-stats" },
157 { 515, "get-addrs" },
158 { 516, "change-addr" },
159 { 517, "create-entry-n" },
160 { 518, "get-entry-by-id-n" },
161 { 519, "get-entry-by-name-n" },
162 { 520, "replace-entry-n" },
163 { 521, "list-entry-n" },
164 { 522, "list-attrib-n" },
165 { 523, "linked-list-n" },
166 { 524, "update-entry-by-name" },
167 { 525, "create-entry-u" },
168 { 526, "get-entry-by-id-u" },
169 { 527, "get-entry-by-name-u" },
170 { 528, "replace-entry-u" },
171 { 529, "list-entry-u" },
172 { 530, "list-attrib-u" },
173 { 531, "linked-list-u" },
175 { 533, "get-addrs-u" },
179 static struct tok kauth_req
[] = {
181 { 21, "authenticate" },
182 { 22, "authenticate-v2" },
184 { 3, "get-ticket-old" },
185 { 23, "get-ticket" },
188 { 6, "create-user" },
189 { 7, "delete-user" },
195 { 13, "get-random-key" },
197 { 15, "lock-status" },
201 static struct tok vol_req
[] = {
202 { 100, "create-volume" },
203 { 101, "delete-volume" },
206 { 104, "end-trans" },
208 { 106, "set-flags" },
209 { 107, "get-flags" },
210 { 108, "trans-create" },
212 { 110, "get-nth-volume" },
213 { 111, "set-forwarding" },
215 { 113, "get-status" },
216 { 114, "sig-restore" },
217 { 115, "list-partitions" },
218 { 116, "list-volumes" },
219 { 117, "set-id-types" },
221 { 119, "partition-info" },
223 { 121, "list-one-volume" },
226 { 124, "x-list-volumes" },
227 { 125, "x-list-one-volume" },
229 { 127, "x-list-partitions" },
230 { 128, "forward-multiple" },
234 static struct tok bos_req
[] = {
235 { 80, "create-bnode" },
236 { 81, "delete-bnode" },
237 { 82, "set-status" },
238 { 83, "get-status" },
239 { 84, "enumerate-instance" },
240 { 85, "get-instance-info" },
241 { 86, "get-instance-parm" },
242 { 87, "add-superuser" },
243 { 88, "delete-superuser" },
244 { 89, "list-superusers" },
247 { 92, "delete-key" },
248 { 93, "set-cell-name" },
249 { 94, "get-cell-name" },
250 { 95, "get-cell-host" },
251 { 96, "add-cell-host" },
252 { 97, "delete-cell-host" },
253 { 98, "set-t-status" },
254 { 99, "shutdown-all" },
255 { 100, "restart-all" },
256 { 101, "startup-all" },
257 { 102, "set-noauth-flag" },
260 { 105, "start-bozo-install" },
261 { 106, "uninstall" },
262 { 107, "get-dates" },
265 { 110, "set-restart-time" },
266 { 111, "get-restart-time" },
267 { 112, "start-bozo-log" },
269 { 114, "get-instance-strings" },
273 static struct tok ubik_req
[] = {
274 { 10000, "vote-beacon" },
275 { 10001, "vote-debug-old" },
276 { 10002, "vote-sdebug-old" },
277 { 10003, "vote-getsyncsite" },
278 { 10004, "vote-debug" },
279 { 10005, "vote-sdebug" },
280 { 20000, "disk-begin" },
281 { 20001, "disk-commit" },
282 { 20002, "disk-lock" },
283 { 20003, "disk-write" },
284 { 20004, "disk-getversion" },
285 { 20005, "disk-getfile" },
286 { 20006, "disk-sendfile" },
287 { 20007, "disk-abort" },
288 { 20008, "disk-releaselocks" },
289 { 20009, "disk-truncate" },
290 { 20010, "disk-probe" },
291 { 20011, "disk-writev" },
292 { 20012, "disk-interfaceaddr" },
293 { 20013, "disk-setversion" },
297 #define VOTE_LOW 10000
298 #define VOTE_HIGH 10005
299 #define DISK_LOW 20000
300 #define DISK_HIGH 20013
302 static struct tok cb_types
[] = {
309 static struct tok ubik_lock_types
[] = {
316 static char *voltype
[] = { "read-write", "read-only", "backup" };
318 static struct tok afs_fs_errors
[] = {
319 { 101, "salvage volume" },
320 { 102, "no such vnode" },
321 { 103, "no such volume" },
322 { 104, "volume exist" },
323 { 105, "no service" },
324 { 106, "volume offline" },
325 { 107, "voline online" },
327 { 109, "diskquota exceeded" },
328 { 110, "volume busy" },
329 { 111, "volume moved" },
330 { 112, "AFS IO error" },
331 { -100, "restarting fileserver" },
336 * Reasons for acknowledging a packet
339 static struct tok rx_ack_reasons
[] = {
340 { 1, "ack requested" },
341 { 2, "duplicate packet" },
342 { 3, "out of sequence" },
343 { 4, "exceeds window" },
344 { 5, "no buffer space" },
346 { 7, "ping response" },
352 * Cache entries we keep around so we can figure out the RX opcode
353 * numbers for replies. This allows us to make sense of RX reply packets.
356 struct rx_cache_entry
{
357 u_int32_t callnum
; /* Call number (net order) */
358 struct in_addr client
; /* client IP address (net order) */
359 struct in_addr server
; /* server IP address (net order) */
360 int dport
; /* server port (host order) */
361 u_short serviceId
; /* Service identifier (net order) */
362 u_int32_t opcode
; /* RX opcode (host order) */
365 #define RX_CACHE_SIZE 64
367 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
369 static int rx_cache_next
= 0;
370 static int rx_cache_hint
= 0;
371 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
372 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
375 static void ack_print(const u_char
*, int);
376 static void fs_print(const u_char
*, int);
377 static void fs_reply_print(const u_char
*, int, int32_t);
378 static void acl_print(u_char
*, int, u_char
*);
379 static void cb_print(const u_char
*, int);
380 static void cb_reply_print(const u_char
*, int, int32_t);
381 static void prot_print(const u_char
*, int);
382 static void prot_reply_print(const u_char
*, int, int32_t);
383 static void vldb_print(const u_char
*, int);
384 static void vldb_reply_print(const u_char
*, int, int32_t);
385 static void kauth_print(const u_char
*, int);
386 static void kauth_reply_print(const u_char
*, int, int32_t);
387 static void vol_print(const u_char
*, int);
388 static void vol_reply_print(const u_char
*, int, int32_t);
389 static void bos_print(const u_char
*, int);
390 static void bos_reply_print(const u_char
*, int, int32_t);
391 static void ubik_print(const u_char
*, int);
392 static void ubik_reply_print(const u_char
*, int, int32_t);
394 static void rx_ack_print(const u_char
*, int);
396 static int is_ubik(u_int32_t
);
399 * Handle the rx-level packet. See if we know what port it's going to so
400 * we can peek at the afs call inside
404 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
407 register struct rx_header
*rxh
;
411 if (snapend
- bp
< sizeof (struct rx_header
)) {
412 printf(" [|rx] (%d)", length
);
416 rxh
= (struct rx_header
*) bp
;
418 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
424 printf(" cid %08x call# %d",
425 (int) EXTRACT_32BITS(&rxh
->cid
),
426 (int) EXTRACT_32BITS(&rxh
->callNumber
));
428 printf(" seq %d ser %d",
429 (int) EXTRACT_32BITS(&rxh
->seq
),
430 (int) EXTRACT_32BITS(&rxh
->serial
));
433 printf(" secindex %d serviceid %hu",
434 (int) rxh
->securityIndex
,
435 EXTRACT_16BITS(&rxh
->serviceId
));
438 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
439 if (rxh
->flags
& rx_flags
[i
].v
) {
446 printf("<%s>", rx_flags
[i
].s
);
452 * Try to handle AFS calls that we know about. Check the destination
453 * port and make sure it's a data packet. Also, make sure the
454 * seq number is 1 (because otherwise it's a continuation packet,
455 * and we can't interpret that). Also, seems that reply packets
456 * do not have the client-init flag set, so we check for that
460 if (rxh
->type
== RX_PACKET_TYPE_ACK
)
461 ack_print(bp
, length
);
462 else if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
463 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
464 rxh
->flags
& RX_CLIENT_INITIATED
) {
467 * Insert this call into the call cache table, so we
468 * have a chance to print out replies
471 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
474 case FS_RX_PORT
: /* AFS file service */
475 fs_print(bp
, length
);
477 case CB_RX_PORT
: /* AFS callback service */
478 cb_print(bp
, length
);
480 case PROT_RX_PORT
: /* AFS protection service */
481 prot_print(bp
, length
);
483 case VLDB_RX_PORT
: /* AFS VLDB service */
484 vldb_print(bp
, length
);
486 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
487 kauth_print(bp
, length
);
489 case VOL_RX_PORT
: /* AFS Volume service */
490 vol_print(bp
, length
);
492 case BOS_RX_PORT
: /* AFS BOS service */
493 bos_print(bp
, length
);
500 * If it's a reply (client-init is _not_ set, but seq is one)
501 * then look it up in the cache. If we find it, call the reply
502 * printing functions Note that we handle abort packets here,
503 * because printing out the return code can be useful at times.
506 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
507 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
508 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
509 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
510 rx_cache_find(rxh
, (const struct ip
*) bp2
,
514 case FS_RX_PORT
: /* AFS file service */
515 fs_reply_print(bp
, length
, opcode
);
517 case CB_RX_PORT
: /* AFS callback service */
518 cb_reply_print(bp
, length
, opcode
);
520 case PROT_RX_PORT
: /* AFS PT service */
521 prot_reply_print(bp
, length
, opcode
);
523 case VLDB_RX_PORT
: /* AFS VLDB service */
524 vldb_reply_print(bp
, length
, opcode
);
526 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
527 kauth_reply_print(bp
, length
, opcode
);
529 case VOL_RX_PORT
: /* AFS Volume service */
530 vol_reply_print(bp
, length
, opcode
);
532 case BOS_RX_PORT
: /* AFS BOS service */
533 bos_reply_print(bp
, length
, opcode
);
540 * If it's an RX ack packet, then use the appropriate ack decoding
541 * function (there isn't any service-specific information in the
542 * ack packet, so we can use one for all AFS services)
545 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
546 rx_ack_print(bp
, length
);
549 printf(" (%d)", length
);
553 * Insert an entry into the cache. Taken from print-nfs.c
557 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
560 struct rx_cache_entry
*rxent
;
561 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
563 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
566 rxent
= &rx_cache
[rx_cache_next
];
568 if (++rx_cache_next
>= RX_CACHE_SIZE
)
571 rxent
->callnum
= rxh
->callNumber
;
572 rxent
->client
= ip
->ip_src
;
573 rxent
->server
= ip
->ip_dst
;
574 rxent
->dport
= dport
;
575 rxent
->serviceId
= rxh
->serviceId
;
576 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
580 * Lookup an entry in the cache. Also taken from print-nfs.c
582 * Note that because this is a reply, we're looking at the _source_
587 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
591 struct rx_cache_entry
*rxent
;
592 u_int32_t clip
= ip
->ip_dst
.s_addr
;
593 u_int32_t sip
= ip
->ip_src
.s_addr
;
595 /* Start the search where we last left off */
599 rxent
= &rx_cache
[i
];
600 if (rxent
->callnum
== rxh
->callNumber
&&
601 rxent
->client
.s_addr
== clip
&&
602 rxent
->server
.s_addr
== sip
&&
603 rxent
->serviceId
== rxh
->serviceId
&&
604 rxent
->dport
== sport
) {
606 /* We got a match! */
609 *opcode
= rxent
->opcode
;
612 if (++i
> RX_CACHE_SIZE
)
614 } while (i
!= rx_cache_hint
);
616 /* Our search failed */
621 * These extrememly grody macros handle the printing of various AFS stuff.
624 #define FIDOUT() { unsigned long n1, n2, n3; \
625 TCHECK2(bp[0], sizeof(int32_t) * 3); \
626 n1 = EXTRACT_32BITS(bp); \
627 bp += sizeof(int32_t); \
628 n2 = EXTRACT_32BITS(bp); \
629 bp += sizeof(int32_t); \
630 n3 = EXTRACT_32BITS(bp); \
631 bp += sizeof(int32_t); \
632 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
635 #define STROUT(MAX) { unsigned int i; \
636 TCHECK2(bp[0], sizeof(int32_t)); \
637 i = EXTRACT_32BITS(bp); \
640 bp += sizeof(int32_t); \
642 if (fn_printn(bp, i, snapend)) \
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; \
721 char s[AFSNAMEMAX]; \
723 if ((MAX) + 1 > sizeof(s)) \
725 TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
727 for (k = 0; k < (MAX); k++) { \
728 *sp++ = (char) EXTRACT_32BITS(bp); \
729 bp += sizeof(int32_t); \
738 ack_print(register const u_char
*bp
, int length
)
746 if (length
<= sizeof(struct rx_header
))
749 bp
+= sizeof(struct rx_header
);
752 * Packets < firstPacket are implicitly acknowledged and may
753 * be discarded by the sender.
755 * Packets >= firstPacket+nAcks are implicitly NOT acknowledged.
757 * No packets with sequence numbers >= firstPacket should be
758 * discarded by the sender (they may thrown out at any time by
761 #define RX_ACK_REASONS "RDOXSprn"
762 /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space,
763 * Ping, ping_Response, No_{progress, particular_reason}.
766 struct rx_ackPacket
{
767 u_short bufferSpace
; /* Skip! */
768 u_short maxSkew
; /* Skip! */
770 u_long previousPacket
; /* Obsolete! */
771 u_long serial
; /* Serial that prompted the ack, */
772 u_char reason
; /* and the reason why. */
774 u_char acks
[RX_MAXACKS
]; /* Selective acks (not a bitmap). */
777 #define RX_ACK_TYPE_NACK 0
779 TCHECK2(bp
[0], 8); /* bufferSpace and maxSkew */
781 printf(" fir %u", (unsigned)EXTRACT_32BITS(bp
));
783 TCHECK2(bp
[0], 8); /* previousPacket and serial */
785 printf(" %u", (unsigned)EXTRACT_32BITS(bp
));
788 printf("%c", RX_ACK_REASONS
[(*bp
- 1) & 07u]);
789 bp
+= 1; /* reason */
794 for (i
= 0; i
< nAcks
; i
++) {
796 putchar(*bp
== RX_ACK_TYPE_NACK
? '-' : '*');
807 * Handle calls to the AFS file service (fs)
811 fs_print(register const u_char
*bp
, int length
)
816 if (length
<= sizeof(struct rx_header
))
819 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
824 * Print out the afs call we're invoking. The table used here was
825 * gleaned from fsint/afsint.xg
828 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
830 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
833 * Print out arguments to some of the AFS calls. This stuff is
837 bp
+= sizeof(struct rx_header
) + 4;
840 * Sigh. This is gross. Ritchie forgive me.
844 case 130: /* Fetch data */
851 case 131: /* Fetch ACL */
852 case 132: /* Fetch Status */
853 case 143: /* Old set lock */
854 case 144: /* Old extend lock */
855 case 145: /* Old release lock */
856 case 156: /* Set lock */
857 case 157: /* Extend lock */
858 case 158: /* Release lock */
861 case 135: /* Store status */
865 case 133: /* Store data */
875 case 134: /* Store ACL */
877 char a
[AFSOPAQUEMAX
+1];
880 i
= EXTRACT_32BITS(bp
);
881 bp
+= sizeof(int32_t);
883 i
= min(AFSOPAQUEMAX
, i
);
884 strncpy(a
, (char *) bp
, i
);
886 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
889 case 137: /* Create file */
890 case 141: /* MakeDir */
895 case 136: /* Remove file */
896 case 142: /* Remove directory */
900 case 138: /* Rename file */
908 case 139: /* Symlink */
920 case 148: /* Get volume info */
923 case 149: /* Get volume stats */
924 case 150: /* Set volume stats */
928 case 154: /* New get volume info */
932 case 155: /* Bulk stat */
936 j
= EXTRACT_32BITS(bp
);
937 bp
+= sizeof(int32_t);
939 for (i
= 0; i
< j
; i
++) {
958 * Handle replies to the AFS file service
962 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
965 struct rx_header
*rxh
;
967 if (length
<= sizeof(struct rx_header
))
970 rxh
= (struct rx_header
*) bp
;
973 * Print out the afs call we're invoking. The table used here was
974 * gleaned from fsint/afsint.xg
977 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
979 bp
+= sizeof(struct rx_header
);
982 * If it was a data packet, interpret the response
985 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
987 case 131: /* Fetch ACL */
989 char a
[AFSOPAQUEMAX
+1];
991 i
= EXTRACT_32BITS(bp
);
992 bp
+= sizeof(int32_t);
994 i
= min(AFSOPAQUEMAX
, i
);
995 strncpy(a
, (char *) bp
, i
);
997 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1000 case 137: /* Create file */
1001 case 141: /* MakeDir */
1005 case 151: /* Get root volume */
1006 printf(" root volume");
1009 case 153: /* Get time */
1015 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1019 * Otherwise, just print out the return code
1021 TCHECK2(bp
[0], sizeof(int32_t));
1022 i
= (int) EXTRACT_32BITS(bp
);
1023 bp
+= sizeof(int32_t);
1025 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
1027 printf(" strange fs reply of type %d", rxh
->type
);
1037 * Print out an AFS ACL string. An AFS ACL is a string that has the
1040 * <positive> <negative>
1044 * "positive" and "negative" are integers which contain the number of
1045 * positive and negative ACL's in the string. The uid/aclbits pair are
1046 * ASCII strings containing the UID/PTS record and and a ascii number
1047 * representing a logical OR of all the ACL permission bits
1051 acl_print(u_char
*s
, int maxsize
, u_char
*end
)
1057 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1060 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1069 * This wacky order preserves the order used by the "fs" command
1072 #define ACLOUT(acl) \
1073 if (acl & PRSFS_READ) \
1075 if (acl & PRSFS_LOOKUP) \
1077 if (acl & PRSFS_INSERT) \
1079 if (acl & PRSFS_DELETE) \
1081 if (acl & PRSFS_WRITE) \
1083 if (acl & PRSFS_LOCK) \
1085 if (acl & PRSFS_ADMINISTER) \
1088 for (i
= 0; i
< pos
; i
++) {
1089 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1093 fn_print(user
, NULL
);
1101 for (i
= 0; i
< neg
; i
++) {
1102 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1106 fn_print(user
, NULL
);
1122 * Handle calls to the AFS callback service
1126 cb_print(register const u_char
*bp
, int length
)
1131 if (length
<= sizeof(struct rx_header
))
1134 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1139 * Print out the afs call we're invoking. The table used here was
1140 * gleaned from fsint/afscbint.xg
1143 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1145 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1147 bp
+= sizeof(struct rx_header
) + 4;
1150 * Print out the afs call we're invoking. The table used here was
1151 * gleaned from fsint/afscbint.xg
1155 case 204: /* Callback */
1159 j
= EXTRACT_32BITS(bp
);
1160 bp
+= sizeof(int32_t);
1162 for (i
= 0; i
< j
; i
++) {
1171 j
= EXTRACT_32BITS(bp
);
1172 bp
+= sizeof(int32_t);
1177 for (i
= 0; i
< j
; i
++) {
1183 t
= EXTRACT_32BITS(bp
);
1184 bp
+= sizeof(int32_t);
1185 tok2str(cb_types
, "type %d", t
);
1204 * Handle replies to the AFS Callback Service
1208 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1210 struct rx_header
*rxh
;
1212 if (length
<= sizeof(struct rx_header
))
1215 rxh
= (struct rx_header
*) bp
;
1218 * Print out the afs call we're invoking. The table used here was
1219 * gleaned from fsint/afscbint.xg
1222 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1224 bp
+= sizeof(struct rx_header
);
1227 * If it was a data packet, interpret the response.
1230 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1232 case 213: /* InitCallBackState3 */
1240 * Otherwise, just print out the return code
1253 * Handle calls to the AFS protection database server
1257 prot_print(register const u_char
*bp
, int length
)
1262 if (length
<= sizeof(struct rx_header
))
1265 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1270 * Print out the afs call we're invoking. The table used here was
1271 * gleaned from ptserver/ptint.xg
1274 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1278 if (is_ubik(pt_op
)) {
1279 ubik_print(bp
, length
);
1283 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1286 * Decode some of the arguments to the PT calls
1289 bp
+= sizeof(struct rx_header
) + 4;
1292 case 500: /* I New User */
1299 case 501: /* Where is it */
1300 case 506: /* Delete */
1301 case 508: /* Get CPS */
1302 case 512: /* List entry */
1303 case 514: /* List elements */
1304 case 517: /* List owned */
1305 case 518: /* Get CPS2 */
1306 case 519: /* Get host CPS */
1310 case 502: /* Dump entry */
1314 case 503: /* Add to group */
1315 case 507: /* Remove from group */
1316 case 515: /* Is a member of? */
1322 case 504: /* Name to ID */
1326 j
= EXTRACT_32BITS(bp
);
1327 bp
+= sizeof(int32_t);
1330 * Who designed this chicken-shit protocol?
1332 * Each character is stored as a 32-bit
1336 for (i
= 0; i
< j
; i
++) {
1343 case 505: /* Id to name */
1348 i
= EXTRACT_32BITS(bp
);
1349 bp
+= sizeof(int32_t);
1350 for (j
= 0; j
< i
; j
++)
1356 case 509: /* New entry */
1363 case 511: /* Set max */
1369 case 513: /* Change entry */
1378 case 520: /* Update entry */
1395 * Handle replies to the AFS protection service
1399 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1401 struct rx_header
*rxh
;
1404 if (length
< sizeof(struct rx_header
))
1407 rxh
= (struct rx_header
*) bp
;
1410 * Print out the afs call we're invoking. The table used here was
1411 * gleaned from ptserver/ptint.xg. Check to see if it's a
1412 * Ubik call, however.
1417 if (is_ubik(opcode
)) {
1418 ubik_reply_print(bp
, length
, opcode
);
1422 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1424 bp
+= sizeof(struct rx_header
);
1427 * If it was a data packet, interpret the response
1430 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1432 case 504: /* Name to ID */
1437 i
= EXTRACT_32BITS(bp
);
1438 bp
+= sizeof(int32_t);
1439 for (j
= 0; j
< i
; j
++)
1445 case 505: /* ID to name */
1449 j
= EXTRACT_32BITS(bp
);
1450 bp
+= sizeof(int32_t);
1453 * Who designed this chicken-shit protocol?
1455 * Each character is stored as a 32-bit
1459 for (i
= 0; i
< j
; i
++) {
1466 case 508: /* Get CPS */
1467 case 514: /* List elements */
1468 case 517: /* List owned */
1469 case 518: /* Get CPS2 */
1470 case 519: /* Get host CPS */
1474 j
= EXTRACT_32BITS(bp
);
1475 bp
+= sizeof(int32_t);
1476 for (i
= 0; i
< j
; i
++) {
1483 case 510: /* List max */
1494 * Otherwise, just print out the return code
1507 * Handle calls to the AFS volume location database service
1511 vldb_print(register const u_char
*bp
, int length
)
1516 if (length
<= sizeof(struct rx_header
))
1519 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1524 * Print out the afs call we're invoking. The table used here was
1525 * gleaned from vlserver/vldbint.xg
1528 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1532 if (is_ubik(vldb_op
)) {
1533 ubik_print(bp
, length
);
1536 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1539 * Decode some of the arguments to the VLDB calls
1542 bp
+= sizeof(struct rx_header
) + 4;
1545 case 501: /* Create new volume */
1546 case 517: /* Create entry N */
1549 case 502: /* Delete entry */
1550 case 503: /* Get entry by ID */
1551 case 507: /* Update entry */
1552 case 508: /* Set lock */
1553 case 509: /* Release lock */
1554 case 518: /* Get entry by ID N */
1557 TCHECK2(bp
[0], sizeof(int32_t));
1558 i
= EXTRACT_32BITS(bp
);
1559 bp
+= sizeof(int32_t);
1561 printf(" type %s", voltype
[i
]);
1563 case 504: /* Get entry by name */
1564 case 519: /* Get entry by name N */
1565 case 524: /* Update entry by name */
1566 case 527: /* Get entry by name U */
1569 case 505: /* Get new vol id */
1573 case 506: /* Replace entry */
1574 case 520: /* Replace entry N */
1577 TCHECK2(bp
[0], sizeof(int32_t));
1578 i
= EXTRACT_32BITS(bp
);
1579 bp
+= sizeof(int32_t);
1581 printf(" type %s", voltype
[i
]);
1584 case 510: /* List entry */
1585 case 521: /* List entry N */
1600 * Handle replies to the AFS volume location database service
1604 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1606 struct rx_header
*rxh
;
1609 if (length
< sizeof(struct rx_header
))
1612 rxh
= (struct rx_header
*) bp
;
1615 * Print out the afs call we're invoking. The table used here was
1616 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1617 * Ubik call, however.
1622 if (is_ubik(opcode
)) {
1623 ubik_reply_print(bp
, length
, opcode
);
1627 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1629 bp
+= sizeof(struct rx_header
);
1632 * If it was a data packet, interpret the response
1635 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1637 case 510: /* List entry */
1640 printf(" nextindex");
1642 case 503: /* Get entry by id */
1643 case 504: /* Get entry by name */
1644 { unsigned long nservers
, j
;
1646 TCHECK2(bp
[0], sizeof(int32_t));
1647 bp
+= sizeof(int32_t);
1648 printf(" numservers");
1649 TCHECK2(bp
[0], sizeof(int32_t));
1650 nservers
= EXTRACT_32BITS(bp
);
1651 bp
+= sizeof(int32_t);
1652 printf(" %lu", nservers
);
1654 for (i
= 0; i
< 8; i
++) {
1655 TCHECK2(bp
[0], sizeof(int32_t));
1658 inet_ntoa(*((struct in_addr
*) bp
)));
1659 bp
+= sizeof(int32_t);
1661 printf(" partitions");
1662 for (i
= 0; i
< 8; i
++) {
1663 TCHECK2(bp
[0], sizeof(int32_t));
1664 j
= EXTRACT_32BITS(bp
);
1665 if (i
< nservers
&& j
<= 26)
1666 printf(" %c", 'a' + (int)j
);
1667 else if (i
< nservers
)
1669 bp
+= sizeof(int32_t);
1671 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1672 bp
+= 8 * sizeof(int32_t);
1681 case 505: /* Get new volume ID */
1685 case 521: /* List entry */
1686 case 529: /* List entry U */
1689 printf(" nextindex");
1691 case 518: /* Get entry by ID N */
1692 case 519: /* Get entry by name N */
1693 { unsigned long nservers
, j
;
1695 printf(" numservers");
1696 TCHECK2(bp
[0], sizeof(int32_t));
1697 nservers
= EXTRACT_32BITS(bp
);
1698 bp
+= sizeof(int32_t);
1699 printf(" %lu", nservers
);
1701 for (i
= 0; i
< 13; i
++) {
1702 TCHECK2(bp
[0], sizeof(int32_t));
1705 inet_ntoa(*((struct in_addr
*) bp
)));
1706 bp
+= sizeof(int32_t);
1708 printf(" partitions");
1709 for (i
= 0; i
< 13; i
++) {
1710 TCHECK2(bp
[0], sizeof(int32_t));
1711 j
= EXTRACT_32BITS(bp
);
1712 if (i
< nservers
&& j
<= 26)
1713 printf(" %c", 'a' + (int)j
);
1714 else if (i
< nservers
)
1716 bp
+= sizeof(int32_t);
1718 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1719 bp
+= 13 * sizeof(int32_t);
1728 case 526: /* Get entry by ID U */
1729 case 527: /* Get entry by name U */
1730 { unsigned long nservers
, j
;
1732 printf(" numservers");
1733 TCHECK2(bp
[0], sizeof(int32_t));
1734 nservers
= EXTRACT_32BITS(bp
);
1735 bp
+= sizeof(int32_t);
1736 printf(" %lu", nservers
);
1738 for (i
= 0; i
< 13; i
++) {
1747 TCHECK2(bp
[0], 4 * 13);
1749 printf(" partitions");
1750 for (i
= 0; i
< 13; i
++) {
1751 TCHECK2(bp
[0], sizeof(int32_t));
1752 j
= EXTRACT_32BITS(bp
);
1753 if (i
< nservers
&& j
<= 26)
1754 printf(" %c", 'a' + (int)j
);
1755 else if (i
< nservers
)
1757 bp
+= sizeof(int32_t);
1759 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1760 bp
+= 13 * sizeof(int32_t);
1774 * Otherwise, just print out the return code
1787 * Handle calls to the AFS Kerberos Authentication service
1791 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
)
2021 if (length
<= sizeof(struct rx_header
))
2024 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
2029 * Print out the afs call we're invoking. The table used here was
2030 * gleaned from bozo/bosint.xg
2033 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2035 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2038 * Decode some of the arguments to the BOS calls
2041 bp
+= sizeof(struct rx_header
) + 4;
2044 case 80: /* Create B node */
2047 printf(" instance");
2050 case 81: /* Delete B node */
2051 case 83: /* Get status */
2052 case 85: /* Get instance info */
2053 case 87: /* Add super user */
2054 case 88: /* Delete super user */
2055 case 93: /* Set cell name */
2056 case 96: /* Add cell host */
2057 case 97: /* Delete cell host */
2058 case 104: /* Restart */
2059 case 106: /* Uninstall */
2060 case 108: /* Exec */
2061 case 112: /* Getlog */
2062 case 114: /* Get instance strings */
2065 case 82: /* Set status */
2066 case 98: /* Set T status */
2071 case 86: /* Get instance parm */
2076 case 84: /* Enumerate instance */
2077 case 89: /* List super users */
2078 case 90: /* List keys */
2079 case 91: /* Add key */
2080 case 92: /* Delete key */
2081 case 95: /* Get cell host */
2084 case 105: /* Install */
2104 * Handle replies to the AFS BOS Service
2108 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2110 struct rx_header
*rxh
;
2112 if (length
<= sizeof(struct rx_header
))
2115 rxh
= (struct rx_header
*) bp
;
2118 * Print out the afs call we're invoking. The table used here was
2119 * gleaned from volser/volint.xg
2122 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2124 bp
+= sizeof(struct rx_header
);
2127 * If it was a data packet, interpret the response.
2130 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2131 /* Well, no, not really. Leave this for later */
2135 * Otherwise, just print out the return code
2148 * Check to see if this is a Ubik opcode.
2152 is_ubik(u_int32_t opcode
)
2154 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2155 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2162 * Handle Ubik opcodes to any one of the replicated database services
2166 ubik_print(register const u_char
*bp
, int length
)
2172 * Print out the afs call we're invoking. The table used here was
2173 * gleaned from ubik/ubik_int.xg
2176 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2178 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2181 * Decode some of the arguments to the Ubik calls
2184 bp
+= sizeof(struct rx_header
) + 4;
2187 case 10000: /* Beacon */
2189 temp
= EXTRACT_32BITS(bp
);
2190 bp
+= sizeof(int32_t);
2191 printf(" syncsite %s", temp
? "yes" : "no");
2192 printf(" votestart");
2194 printf(" dbversion");
2199 case 10003: /* Get sync site */
2203 case 20000: /* Begin */
2204 case 20001: /* Commit */
2205 case 20007: /* Abort */
2206 case 20008: /* Release locks */
2207 case 20010: /* Writev */
2211 case 20002: /* Lock */
2220 temp
= EXTRACT_32BITS(bp
);
2221 bp
+= sizeof(int32_t);
2222 tok2str(ubik_lock_types
, "type %d", temp
);
2224 case 20003: /* Write */
2232 case 20005: /* Get file */
2236 case 20006: /* Send file */
2241 printf(" dbversion");
2244 case 20009: /* Truncate */
2252 case 20012: /* Set version */
2255 printf(" oldversion");
2257 printf(" newversion");
2271 * Handle Ubik replies to any one of the replicated database services
2275 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2277 struct rx_header
*rxh
;
2279 if (length
< sizeof(struct rx_header
))
2282 rxh
= (struct rx_header
*) bp
;
2285 * Print out the ubik call we're invoking. This table was gleaned
2286 * from ubik/ubik_int.xg
2289 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2291 bp
+= sizeof(struct rx_header
);
2294 * If it was a data packet, print out the arguments to the Ubik calls
2297 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2299 case 10000: /* Beacon */
2302 case 20004: /* Get version */
2303 printf(" dbversion");
2311 * Otherwise, print out "yes" it it was a beacon packet (because
2312 * that's how yes votes are returned, go figure), otherwise
2313 * just print out the error code.
2318 case 10000: /* Beacon */
2319 printf(" vote yes until");
2334 * Handle RX ACK packets.
2338 rx_ack_print(register const u_char
*bp
, int length
)
2340 struct rx_ackPacket
*rxa
;
2343 if (length
< sizeof(struct rx_header
))
2346 bp
+= sizeof(struct rx_header
);
2349 * This may seem a little odd .... the rx_ackPacket structure
2350 * contains an array of individual packet acknowledgements
2351 * (used for selective ack/nack), but since it's variable in size,
2352 * we don't want to truncate based on the size of the whole
2353 * rx_ackPacket structure.
2356 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2358 rxa
= (struct rx_ackPacket
*) bp
;
2359 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2362 * Print out a few useful things from the ack packet structure
2366 printf(" bufspace %d maxskew %d",
2367 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2368 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2370 printf(" first %d serial %d reason %s",
2371 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2372 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2375 * Okay, now we print out the ack array. The way _this_ works
2376 * is that we start at "first", and step through the ack array.
2377 * If we have a contiguous range of acks/nacks, try to
2378 * collapse them into a range.
2380 * If you're really clever, you might have noticed that this
2381 * doesn't seem quite correct. Specifically, due to structure
2382 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2383 * yield the start of the ack array (because RX_MAXACKS is 255
2384 * and the structure will likely get padded to a 2 or 4 byte
2385 * boundary). However, this is the way it's implemented inside
2386 * of AFS - the start of the extra fields are at
2387 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2388 * the exact start of the ack array. Sigh. That's why we aren't
2389 * using bp, but instead use rxa->acks[]. But nAcks gets added
2390 * to bp after this, so bp ends up at the right spot. Go figure.
2393 if (rxa
->nAcks
!= 0) {
2395 TCHECK2(bp
[0], rxa
->nAcks
);
2398 * Sigh, this is gross, but it seems to work to collapse
2402 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2403 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2406 * I figured this deserved _some_ explanation.
2407 * First, print "acked" and the packet seq
2408 * number if this is the first time we've
2409 * seen an acked packet.
2414 rxa
->firstPacket
+ i
);
2419 * Otherwise, if the there is a skip in
2420 * the range (such as an nacked packet in
2421 * the middle of some acked packets),
2422 * then print the current packet number
2423 * seperated from the last number by
2427 else if (last
!= i
- 1) {
2428 printf(",%d", rxa
->firstPacket
+ i
);
2433 * We always set last to the value of
2434 * the last ack we saw. Conversely, start
2435 * is set to the value of the first ack
2436 * we saw in a range.
2442 * Okay, this bit a code gets executed when
2443 * we hit a nack ... in _this_ case we
2444 * want to print out the range of packets
2445 * that were acked, so we need to print
2446 * the _previous_ packet number seperated
2447 * from the first by a dash (-). Since we
2448 * already printed the first packet above,
2449 * just print the final packet. Don't
2450 * do this if there will be a single-length
2453 } else if (last
== i
- 1 && start
!= last
)
2454 printf("-%d", rxa
->firstPacket
+ i
- 1);
2457 * So, what's going on here? We ran off the end of the
2458 * ack list, and if we got a range we need to finish it up.
2459 * So we need to determine if the last packet in the list
2460 * was an ack (if so, then last will be set to it) and
2461 * we need to see if the last range didn't start with the
2462 * last packet (because if it _did_, then that would mean
2463 * that the packet number has already been printed and
2464 * we don't need to print it again).
2467 if (last
== i
- 1 && start
!= last
)
2468 printf("-%d", rxa
->firstPacket
+ i
- 1);
2471 * Same as above, just without comments
2474 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2475 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2477 printf(" nacked %d",
2478 rxa
->firstPacket
+ i
);
2480 } else if (last
!= i
- 1) {
2481 printf(",%d", rxa
->firstPacket
+ i
);
2485 } else if (last
== i
- 1 && start
!= last
)
2486 printf("-%d", rxa
->firstPacket
+ i
- 1);
2488 if (last
== i
- 1 && start
!= last
)
2489 printf("-%d", rxa
->firstPacket
+ i
- 1);
2496 * These are optional fields; depending on your version of AFS,
2497 * you may or may not see them
2500 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2516 printf(" maxpackets");