]>
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.9 2000-02-09 16:00:50 kenh Exp $";
25 #include <sys/param.h>
27 #include <sys/types.h>
28 #include <sys/socket.h>
29 #include <netinet/in.h>
30 #include <netinet/in_systm.h>
31 #include <netinet/ip.h>
32 #include <arpa/inet.h>
34 #include "interface.h"
35 #include "addrtoname.h"
38 #undef NOERROR /* Solaris sucks */
39 #include <arpa/nameser.h>
43 static struct tok rx_types
[] = {
44 { RX_PACKET_TYPE_DATA
, "data" },
45 { RX_PACKET_TYPE_ACK
, "ack" },
46 { RX_PACKET_TYPE_BUSY
, "busy" },
47 { RX_PACKET_TYPE_ABORT
, "abort" },
48 { RX_PACKET_TYPE_ACKALL
, "ackall" },
49 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
50 { RX_PACKET_TYPE_RESPONSE
, "response" },
51 { RX_PACKET_TYPE_DEBUG
, "debug" },
52 { RX_PACKET_TYPE_PARAMS
, "params" },
53 { RX_PACKET_TYPE_VERSION
, "version" },
57 static struct tok rx_flags
[] = {
58 { RX_CLIENT_INITIATED
, "client-init" },
59 { RX_REQUEST_ACK
, "req-ack" },
60 { RX_LAST_PACKET
, "last-pckt" },
61 { RX_MORE_PACKETS
, "more-pckts" },
62 { RX_FREE_PACKET
, "free-pckt" }
65 static struct tok fs_req
[] = {
66 { 130, "fetch-data" },
68 { 132, "fetch-status" },
69 { 133, "store-data" },
71 { 135, "store-status" },
72 { 136, "remove-file" },
73 { 137, "create-file" },
79 { 143, "oldsetlock" },
80 { 144, "oldextlock" },
81 { 145, "oldrellock" },
84 { 148, "get-vlinfo" },
85 { 149, "get-vlstats" },
86 { 150, "set-vlstats" },
87 { 151, "get-rootvl" },
88 { 152, "check-token" },
90 { 154, "nget-vlinfo" },
97 { 161, "dfs-lookup" },
98 { 162, "dfs-flushcps" },
99 { 163, "dfs-symlink" },
103 static struct tok cb_req
[] = {
112 { 212, "whoareyou" },
114 { 214, "probeuuid" },
118 static struct tok pt_req
[] = {
120 { 501, "where-is-it" },
121 { 502, "dump-entry" },
122 { 503, "add-to-group" },
123 { 504, "name-to-id" },
124 { 505, "id-to-name" },
126 { 507, "remove-from-group" },
128 { 509, "new-entry" },
131 { 512, "list-entry" },
132 { 513, "change-entry" },
133 { 514, "list-elements" },
134 { 515, "same-mbr-of" },
135 { 516, "set-fld-sentry" },
136 { 517, "list-owned" },
138 { 519, "get-host-cps" },
139 { 520, "update-entry" },
143 static struct tok vldb_req
[] = {
144 { 501, "create-entry" },
145 { 502, "delete-entry" },
146 { 503, "get-entry-by-id" },
147 { 504, "get-entry-by-name" },
148 { 505, "get-new-volume-id" },
149 { 506, "replace-entry" },
150 { 507, "update-entry" },
152 { 509, "releaselock" },
153 { 510, "list-entry" },
154 { 511, "list-attrib" },
155 { 512, "linked-list" },
156 { 513, "get-stats" },
158 { 515, "get-addrs" },
159 { 516, "change-addr" },
160 { 517, "create-entry-n" },
161 { 518, "get-entry-by-id-n" },
162 { 519, "get-entry-by-name-n" },
163 { 520, "replace-entry-n" },
164 { 521, "list-entry-n" },
165 { 522, "list-attrib-n" },
166 { 523, "linked-list-n" },
167 { 524, "update-entry-by-name" },
168 { 525, "create-entry-u" },
169 { 526, "get-entry-by-id-u" },
170 { 527, "get-entry-by-name-u" },
171 { 528, "replace-entry-u" },
172 { 529, "list-entry-u" },
173 { 530, "list-attrib-u" },
174 { 531, "linked-list-u" },
176 { 533, "get-addrs-u" },
180 static struct tok kauth_req
[] = {
182 { 21, "authenticate" },
183 { 22, "authenticate-v2" },
185 { 3, "get-ticket-old" },
186 { 23, "get-ticket" },
189 { 6, "create-user" },
190 { 7, "delete-user" },
196 { 13, "get-random-key" },
198 { 15, "lock-status" },
202 static struct tok vol_req
[] = {
203 { 100, "create-volume" },
204 { 101, "delete-volume" },
207 { 104, "end-trans" },
209 { 106, "set-flags" },
210 { 107, "get-flags" },
211 { 108, "trans-create" },
213 { 110, "get-nth-volume" },
214 { 111, "set-forwarding" },
216 { 113, "get-status" },
217 { 114, "sig-restore" },
218 { 115, "list-partitions" },
219 { 116, "list-volumes" },
220 { 117, "set-id-types" },
222 { 119, "partition-info" },
224 { 121, "list-one-volume" },
227 { 124, "x-list-volumes" },
228 { 125, "x-list-one-volume" },
230 { 127, "x-list-partitions" },
231 { 128, "forward-multiple" },
235 static struct tok bos_req
[] = {
236 { 80, "create-bnode" },
237 { 81, "delete-bnode" },
238 { 82, "set-status" },
239 { 83, "get-status" },
240 { 84, "enumerate-instance" },
241 { 85, "get-instance-info" },
242 { 86, "get-instance-parm" },
243 { 87, "add-superuser" },
244 { 88, "delete-superuser" },
245 { 89, "list-superusers" },
248 { 92, "delete-key" },
249 { 93, "set-cell-name" },
250 { 94, "get-cell-name" },
251 { 95, "get-cell-host" },
252 { 96, "add-cell-host" },
253 { 97, "delete-cell-host" },
254 { 98, "set-t-status" },
255 { 99, "shutdown-all" },
256 { 100, "restart-all" },
257 { 101, "startup-all" },
258 { 102, "set-noauth-flag" },
261 { 105, "start-bozo-install" },
262 { 106, "uninstall" },
263 { 107, "get-dates" },
266 { 110, "set-restart-time" },
267 { 111, "get-restart-time" },
268 { 112, "start-bozo-log" },
270 { 114, "get-instance-strings" },
274 static struct tok ubik_req
[] = {
275 { 10000, "vote-beacon" },
276 { 10001, "vote-debug-old" },
277 { 10002, "vote-sdebug-old" },
278 { 10003, "vote-getsyncsite" },
279 { 10004, "vote-debug" },
280 { 10005, "vote-sdebug" },
281 { 20000, "disk-begin" },
282 { 20001, "disk-commit" },
283 { 20002, "disk-lock" },
284 { 20003, "disk-write" },
285 { 20004, "disk-getversion" },
286 { 20005, "disk-getfile" },
287 { 20006, "disk-sendfile" },
288 { 20007, "disk-abort" },
289 { 20008, "disk-releaselocks" },
290 { 20009, "disk-truncate" },
291 { 20010, "disk-probe" },
292 { 20011, "disk-writev" },
293 { 20012, "disk-interfaceaddr" },
294 { 20013, "disk-setversion" },
298 #define VOTE_LOW 10000
299 #define VOTE_HIGH 10005
300 #define DISK_LOW 20000
301 #define DISK_HIGH 20013
303 static struct tok cb_types
[] = {
310 static struct tok ubik_lock_types
[] = {
317 static char *voltype
[] = { "read-write", "read-only", "backup" };
319 static struct tok afs_fs_errors
[] = {
320 { 101, "salvage volume" },
321 { 102, "no such vnode" },
322 { 103, "no such volume" },
323 { 104, "volume exist" },
324 { 105, "no service" },
325 { 106, "volume offline" },
326 { 107, "voline online" },
328 { 109, "diskquota exceeded" },
329 { 110, "volume busy" },
330 { 111, "volume moved" },
331 { 112, "AFS IO error" },
332 { -100, "restarting fileserver" },
337 * Reasons for acknowledging a packet
340 static struct tok rx_ack_reasons
[] = {
341 { 1, "ack requested" },
342 { 2, "duplicate packet" },
343 { 3, "out of sequence" },
344 { 4, "exceeds window" },
345 { 5, "no buffer space" },
347 { 7, "ping response" },
353 * Cache entries we keep around so we can figure out the RX opcode
354 * numbers for replies. This allows us to make sense of RX reply packets.
357 struct rx_cache_entry
{
358 u_int32_t callnum
; /* Call number (net order) */
359 struct in_addr client
; /* client IP address (net order) */
360 struct in_addr server
; /* server IP address (net order) */
361 int dport
; /* server port (host order) */
362 u_short serviceId
; /* Service identifier (net order) */
363 u_int32_t opcode
; /* RX opcode (host order) */
366 #define RX_CACHE_SIZE 64
368 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
370 static int rx_cache_next
= 0;
371 static int rx_cache_hint
= 0;
372 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
373 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
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
*, 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
));
422 printf(" cid %08x call# %d seq %d ser %d",
423 (int) EXTRACT_32BITS(&rxh
->cid
),
424 (int) EXTRACT_32BITS(&rxh
->callNumber
),
425 (int) EXTRACT_32BITS(&rxh
->seq
),
426 (int) EXTRACT_32BITS(&rxh
->serial
));
428 printf(" secindex %d serviceid %hu",
429 (int) rxh
->securityIndex
,
430 EXTRACT_16BITS(&rxh
->serviceId
));
431 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
432 if (rxh
->flags
& rx_flags
[i
].v
) {
439 printf("<%s>", rx_flags
[i
].s
);
445 * Try to handle AFS calls that we know about. Check the destination
446 * port and make sure it's a data packet. Also, make sure the
447 * seq number is 1 (because otherwise it's a continuation packet,
448 * and we can't interpret that). Also, seems that reply packets
449 * do not have the client-init flag set, so we check for that
453 if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
454 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
455 rxh
->flags
& RX_CLIENT_INITIATED
) {
458 * Insert this call into the call cache table, so we
459 * have a chance to print out replies
462 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
465 case FS_RX_PORT
: /* AFS file service */
466 fs_print(bp
, length
);
468 case CB_RX_PORT
: /* AFS callback service */
469 cb_print(bp
, length
);
471 case PROT_RX_PORT
: /* AFS protection service */
472 prot_print(bp
, length
);
474 case VLDB_RX_PORT
: /* AFS VLDB service */
475 vldb_print(bp
, length
);
477 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
478 kauth_print(bp
, length
);
480 case VOL_RX_PORT
: /* AFS Volume service */
481 vol_print(bp
, length
);
483 case BOS_RX_PORT
: /* AFS BOS service */
484 bos_print(bp
, length
);
491 * If it's a reply (client-init is _not_ set, but seq is one)
492 * then look it up in the cache. If we find it, call the reply
493 * printing functions Note that we handle abort packets here,
494 * because printing out the return code can be useful at times.
497 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
498 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
499 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
500 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
501 rx_cache_find(rxh
, (const struct ip
*) bp2
,
505 case FS_RX_PORT
: /* AFS file service */
506 fs_reply_print(bp
, length
, opcode
);
508 case CB_RX_PORT
: /* AFS callback service */
509 cb_reply_print(bp
, length
, opcode
);
511 case PROT_RX_PORT
: /* AFS PT service */
512 prot_reply_print(bp
, length
, opcode
);
514 case VLDB_RX_PORT
: /* AFS VLDB service */
515 vldb_reply_print(bp
, length
, opcode
);
517 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
518 kauth_reply_print(bp
, length
, opcode
);
520 case VOL_RX_PORT
: /* AFS Volume service */
521 vol_reply_print(bp
, length
, opcode
);
523 case BOS_RX_PORT
: /* AFS BOS service */
524 bos_reply_print(bp
, length
, opcode
);
531 * If it's an RX ack packet, then use the appropriate ack decoding
532 * function (there isn't any service-specific information in the
533 * ack packet, so we can use one for all AFS services)
536 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
537 rx_ack_print(bp
, length
);
540 printf(" (%d)", length
);
544 * Insert an entry into the cache. Taken from print-nfs.c
548 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
551 struct rx_cache_entry
*rxent
;
552 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
554 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
557 rxent
= &rx_cache
[rx_cache_next
];
559 if (++rx_cache_next
>= RX_CACHE_SIZE
)
562 rxent
->callnum
= rxh
->callNumber
;
563 rxent
->client
= ip
->ip_src
;
564 rxent
->server
= ip
->ip_dst
;
565 rxent
->dport
= dport
;
566 rxent
->serviceId
= rxh
->serviceId
;
567 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
571 * Lookup an entry in the cache. Also taken from print-nfs.c
573 * Note that because this is a reply, we're looking at the _source_
578 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
582 struct rx_cache_entry
*rxent
;
583 u_int32_t clip
= ip
->ip_dst
.s_addr
;
584 u_int32_t sip
= ip
->ip_src
.s_addr
;
586 /* Start the search where we last left off */
590 rxent
= &rx_cache
[i
];
591 if (rxent
->callnum
== rxh
->callNumber
&&
592 rxent
->client
.s_addr
== clip
&&
593 rxent
->server
.s_addr
== sip
&&
594 rxent
->serviceId
== rxh
->serviceId
&&
595 rxent
->dport
== sport
) {
597 /* We got a match! */
600 *opcode
= rxent
->opcode
;
603 if (++i
> RX_CACHE_SIZE
)
605 } while (i
!= rx_cache_hint
);
607 /* Our search failed */
612 * These extrememly grody macros handle the printing of various AFS stuff.
615 #define TRUNC(n) if (snapend - bp + 1 <= n) goto trunc;
616 #define FIDOUT() { unsigned long n1, n2, n3; \
617 TRUNC(sizeof(int32_t) * 3); \
618 n1 = EXTRACT_32BITS(bp); \
619 bp += sizeof(int32_t); \
620 n2 = EXTRACT_32BITS(bp); \
621 bp += sizeof(int32_t); \
622 n3 = EXTRACT_32BITS(bp); \
623 bp += sizeof(int32_t); \
624 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
627 #define STROUT(MAX) { int i; \
628 TRUNC(sizeof(int32_t)); \
629 i = (int) EXTRACT_32BITS(bp); \
630 bp += sizeof(int32_t); \
632 strncpy(s, (char *) bp, min(MAX, i)); \
634 printf(" \"%s\"", s); \
635 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
638 #define INTOUT() { int i; \
639 TRUNC(sizeof(int32_t)); \
640 i = (int) EXTRACT_32BITS(bp); \
641 bp += sizeof(int32_t); \
645 #define UINTOUT() { unsigned long i; \
646 TRUNC(sizeof(int32_t)); \
647 i = EXTRACT_32BITS(bp); \
648 bp += sizeof(int32_t); \
652 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
653 TRUNC(sizeof(int32_t)); \
654 t = (time_t) EXTRACT_32BITS(bp); \
655 bp += sizeof(int32_t); \
656 tm = localtime(&t); \
657 strftime(str, 256, "%Y/%m/%d %T", tm); \
658 printf(" %s", str); \
661 #define STOREATTROUT() { unsigned long mask, i; \
662 TRUNC((sizeof(int32_t)*6)); \
663 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
664 if (mask) printf (" StoreStatus"); \
665 if (mask & 1) { printf(" date"); DATEOUT(); } \
666 else bp += sizeof(int32_t); \
667 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
668 if (mask & 2) printf(" owner %lu", i); \
669 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
670 if (mask & 4) printf(" group %lu", i); \
671 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
672 if (mask & 8) printf(" mode %lo", i & 07777); \
673 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
674 if (mask & 16) printf(" segsize %lu", i); \
675 /* undocumented in 3.3 docu */ \
676 if (mask & 1024) printf(" fsync"); \
679 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
680 TRUNC(sizeof(int32_t) * 2); \
681 epoch = EXTRACT_32BITS(bp); \
682 bp += sizeof(int32_t); \
683 counter = EXTRACT_32BITS(bp); \
684 bp += sizeof(int32_t); \
685 printf(" %d.%d", epoch, counter); \
688 #define AFSUUIDOUT() {u_int32_t temp; int i; \
689 TRUNC(11*sizeof(u_int32_t)); \
690 temp = EXTRACT_32BITS(bp); \
691 bp += sizeof(u_int32_t); \
692 printf(" %08x", temp); \
693 temp = EXTRACT_32BITS(bp); \
694 bp += sizeof(u_int32_t); \
695 printf("%04x", temp); \
696 temp = EXTRACT_32BITS(bp); \
697 bp += sizeof(u_int32_t); \
698 printf("%04x", temp); \
699 for (i = 0; i < 8; i++) { \
700 temp = EXTRACT_32BITS(bp); \
701 bp += sizeof(u_int32_t); \
702 printf("%02x", (unsigned char) temp); \
707 * This is the sickest one of all
710 #define VECOUT(MAX) { char *sp; \
712 TRUNC(MAX * sizeof(int32_t)); \
714 for (k = 0; k < MAX; k++) { \
715 *sp++ = (char) EXTRACT_32BITS(bp); \
716 bp += sizeof(int32_t); \
719 printf(" \"%s\"", s); \
723 * Handle calls to the AFS file service (fs)
727 fs_print(register const u_char
*bp
, int length
)
733 if (length
<= sizeof(struct rx_header
))
736 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
741 * Print out the afs call we're invoking. The table used here was
742 * gleaned from fsint/afsint.xg
745 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
747 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
750 * Print out arguments to some of the AFS calls. This stuff is
754 bp
+= sizeof(struct rx_header
) + 4;
757 * Sigh. This is gross. Ritchie forgive me.
761 case 130: /* Fetch data */
768 case 131: /* Fetch ACL */
769 case 132: /* Fetch Status */
770 case 143: /* Old set lock */
771 case 144: /* Old extend lock */
772 case 145: /* Old release lock */
773 case 156: /* Set lock */
774 case 157: /* Extend lock */
775 case 158: /* Release lock */
778 case 135: /* Store status */
782 case 133: /* Store data */
792 case 134: /* Store ACL */
794 char a
[AFSOPAQUEMAX
];
797 i
= EXTRACT_32BITS(bp
);
798 bp
+= sizeof(int32_t);
800 strncpy(a
, (char *) bp
, min(AFSOPAQUEMAX
, i
));
802 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
805 case 137: /* Create file */
806 case 141: /* MakeDir */
811 case 136: /* Remove file */
812 case 142: /* Remove directory */
816 case 138: /* Rename file */
824 case 139: /* Symlink */
836 case 148: /* Get volume info */
839 case 149: /* Get volume stats */
840 case 150: /* Set volume stats */
844 case 154: /* New get volume info */
848 case 155: /* Bulk stat */
852 j
= EXTRACT_32BITS(bp
);
853 bp
+= sizeof(int32_t);
855 for (i
= 0; i
< j
; i
++) {
874 * Handle replies to the AFS file service
878 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
882 struct rx_header
*rxh
;
884 if (length
<= sizeof(struct rx_header
))
887 rxh
= (struct rx_header
*) bp
;
890 * Print out the afs call we're invoking. The table used here was
891 * gleaned from fsint/afsint.xg
894 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
896 bp
+= sizeof(struct rx_header
);
899 * If it was a data packet, interpret the response
902 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
904 case 131: /* Fetch ACL */
906 char a
[AFSOPAQUEMAX
];
908 i
= EXTRACT_32BITS(bp
);
909 bp
+= sizeof(int32_t);
911 strncpy(a
, (char *) bp
, min(AFSOPAQUEMAX
, i
));
913 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
916 case 137: /* Create file */
917 case 141: /* MakeDir */
921 case 151: /* Get root volume */
922 printf(" root volume");
925 case 153: /* Get time */
931 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
935 * Otherwise, just print out the return code
937 TRUNC(sizeof(int32_t));
938 i
= (int) EXTRACT_32BITS(bp
);
939 bp
+= sizeof(int32_t);
941 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
943 printf(" strange fs reply of type %d", rxh
->type
);
953 * Print out an AFS ACL string. An AFS ACL is a string that has the
956 * <positive> <negative>
960 * "positive" and "negative" are integers which contain the number of
961 * positive and negative ACL's in the string. The uid/aclbits pair are
962 * ASCII strings containing the UID/PTS record and and a ascii number
963 * representing a logical OR of all the ACL permission bits
967 acl_print(u_char
*s
, u_char
*end
)
973 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
982 * This wacky order preserves the order used by the "fs" command
985 #define ACLOUT(acl) \
986 if (acl & PRSFS_READ) \
988 if (acl & PRSFS_LOOKUP) \
990 if (acl & PRSFS_INSERT) \
992 if (acl & PRSFS_DELETE) \
994 if (acl & PRSFS_WRITE) \
996 if (acl & PRSFS_LOCK) \
998 if (acl & PRSFS_ADMINISTER) \
1001 for (i
= 0; i
< pos
; i
++) {
1002 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1005 printf(" +{%s ", user
);
1012 for (i
= 0; i
< neg
; i
++) {
1013 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1016 printf(" -{%s ", user
);
1027 * Handle calls to the AFS callback service
1031 cb_print(register const u_char
*bp
, int length
)
1036 if (length
<= sizeof(struct rx_header
))
1039 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1044 * Print out the afs call we're invoking. The table used here was
1045 * gleaned from fsint/afscbint.xg
1048 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1050 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1052 bp
+= sizeof(struct rx_header
) + 4;
1055 * Print out the afs call we're invoking. The table used here was
1056 * gleaned from fsint/afscbint.xg
1060 case 204: /* Callback */
1064 j
= EXTRACT_32BITS(bp
);
1065 bp
+= sizeof(int32_t);
1067 for (i
= 0; i
< j
; i
++) {
1076 j
= EXTRACT_32BITS(bp
);
1077 bp
+= sizeof(int32_t);
1082 for (i
= 0; i
< j
; i
++) {
1088 t
= EXTRACT_32BITS(bp
);
1089 bp
+= sizeof(int32_t);
1090 tok2str(cb_types
, "type %d", t
);
1109 * Handle replies to the AFS Callback Service
1113 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1115 struct rx_header
*rxh
;
1117 if (length
<= sizeof(struct rx_header
))
1120 rxh
= (struct rx_header
*) bp
;
1123 * Print out the afs call we're invoking. The table used here was
1124 * gleaned from fsint/afscbint.xg
1127 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1129 bp
+= sizeof(struct rx_header
);
1132 * If it was a data packet, interpret the response.
1135 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1137 case 213: /* InitCallBackState3 */
1145 * Otherwise, just print out the return code
1158 * Handle calls to the AFS protection database server
1162 prot_print(register const u_char
*bp
, int length
)
1168 if (length
<= sizeof(struct rx_header
))
1171 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1176 * Print out the afs call we're invoking. The table used here was
1177 * gleaned from ptserver/ptint.xg
1180 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1184 if (is_ubik(pt_op
)) {
1185 ubik_print(bp
, length
);
1189 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1192 * Decode some of the arguments to the PT calls
1195 bp
+= sizeof(struct rx_header
) + 4;
1198 case 500: /* I New User */
1205 case 501: /* Where is it */
1206 case 506: /* Delete */
1207 case 508: /* Get CPS */
1208 case 512: /* List entry */
1209 case 514: /* List elements */
1210 case 517: /* List owned */
1211 case 518: /* Get CPS2 */
1212 case 519: /* Get host CPS */
1216 case 502: /* Dump entry */
1220 case 503: /* Add to group */
1221 case 507: /* Remove from group */
1222 case 515: /* Is a member of? */
1228 case 504: /* Name to ID */
1232 j
= EXTRACT_32BITS(bp
);
1233 bp
+= sizeof(int32_t);
1236 * Who designed this chicken-shit protocol?
1238 * Each character is stored as a 32-bit
1242 for (i
= 0; i
< j
; i
++) {
1249 case 505: /* Id to name */
1254 i
= EXTRACT_32BITS(bp
);
1255 bp
+= sizeof(int32_t);
1256 for (j
= 0; j
< i
; j
++)
1262 case 509: /* New entry */
1269 case 511: /* Set max */
1275 case 513: /* Change entry */
1284 case 520: /* Update entry */
1301 * Handle replies to the AFS protection service
1305 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1307 struct rx_header
*rxh
;
1311 if (length
< sizeof(struct rx_header
))
1314 rxh
= (struct rx_header
*) bp
;
1317 * Print out the afs call we're invoking. The table used here was
1318 * gleaned from ptserver/ptint.xg. Check to see if it's a
1319 * Ubik call, however.
1324 if (is_ubik(opcode
)) {
1325 ubik_reply_print(bp
, length
, opcode
);
1329 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1331 bp
+= sizeof(struct rx_header
);
1334 * If it was a data packet, interpret the response
1337 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1339 case 504: /* Name to ID */
1344 i
= EXTRACT_32BITS(bp
);
1345 bp
+= sizeof(int32_t);
1346 for (j
= 0; j
< i
; j
++)
1352 case 505: /* ID to name */
1356 j
= EXTRACT_32BITS(bp
);
1357 bp
+= sizeof(int32_t);
1360 * Who designed this chicken-shit protocol?
1362 * Each character is stored as a 32-bit
1366 for (i
= 0; i
< j
; i
++) {
1373 case 508: /* Get CPS */
1374 case 514: /* List elements */
1375 case 517: /* List owned */
1376 case 518: /* Get CPS2 */
1377 case 519: /* Get host CPS */
1381 j
= EXTRACT_32BITS(bp
);
1382 bp
+= sizeof(int32_t);
1383 for (i
= 0; i
< j
; i
++) {
1390 case 510: /* List max */
1401 * Otherwise, just print out the return code
1414 * Handle calls to the AFS volume location database service
1418 vldb_print(register const u_char
*bp
, int length
)
1424 if (length
<= sizeof(struct rx_header
))
1427 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1432 * Print out the afs call we're invoking. The table used here was
1433 * gleaned from vlserver/vldbint.xg
1436 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1440 if (is_ubik(vldb_op
)) {
1441 ubik_print(bp
, length
);
1444 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1447 * Decode some of the arguments to the VLDB calls
1450 bp
+= sizeof(struct rx_header
) + 4;
1453 case 501: /* Create new volume */
1454 case 517: /* Create entry N */
1457 case 502: /* Delete entry */
1458 case 503: /* Get entry by ID */
1459 case 507: /* Update entry */
1460 case 508: /* Set lock */
1461 case 509: /* Release lock */
1462 case 518: /* Get entry by ID N */
1465 TRUNC(sizeof(int32_t));
1466 i
= EXTRACT_32BITS(bp
);
1467 bp
+= sizeof(int32_t);
1469 printf(" type %s", voltype
[i
]);
1471 case 504: /* Get entry by name */
1472 case 519: /* Get entry by name N */
1473 case 524: /* Update entry by name */
1474 case 527: /* Get entry by name U */
1477 case 505: /* Get new vol id */
1481 case 506: /* Replace entry */
1482 case 520: /* Replace entry N */
1485 TRUNC(sizeof(int32_t));
1486 i
= EXTRACT_32BITS(bp
);
1487 bp
+= sizeof(int32_t);
1489 printf(" type %s", voltype
[i
]);
1492 case 510: /* List entry */
1493 case 521: /* List entry N */
1508 * Handle replies to the AFS volume location database service
1512 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1514 struct rx_header
*rxh
;
1518 if (length
< sizeof(struct rx_header
))
1521 rxh
= (struct rx_header
*) bp
;
1524 * Print out the afs call we're invoking. The table used here was
1525 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1526 * Ubik call, however.
1531 if (is_ubik(opcode
)) {
1532 ubik_reply_print(bp
, length
, opcode
);
1536 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1538 bp
+= sizeof(struct rx_header
);
1541 * If it was a data packet, interpret the response
1544 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1546 case 510: /* List entry */
1549 printf(" nextindex");
1551 case 503: /* Get entry by id */
1552 case 504: /* Get entry by name */
1553 { unsigned long nservers
, j
;
1555 TRUNC(sizeof(int32_t));
1556 bp
+= sizeof(int32_t);
1557 printf(" numservers");
1558 TRUNC(sizeof(int32_t));
1559 nservers
= EXTRACT_32BITS(bp
);
1560 bp
+= sizeof(int32_t);
1561 printf(" %lu", nservers
);
1563 for (i
= 0; i
< 8; i
++) {
1564 TRUNC(sizeof(int32_t));
1567 inet_ntoa(*((struct in_addr
*) bp
)));
1568 bp
+= sizeof(int32_t);
1570 printf(" partitions");
1571 for (i
= 0; i
< 8; i
++) {
1572 TRUNC(sizeof(int32_t));
1573 j
= EXTRACT_32BITS(bp
);
1574 if (i
< nservers
&& j
<= 26)
1575 printf(" %c", 'a' + (int)j
);
1576 else if (i
< nservers
)
1578 bp
+= sizeof(int32_t);
1580 TRUNC(8 * sizeof(int32_t));
1581 bp
+= 8 * sizeof(int32_t);
1590 case 505: /* Get new volume ID */
1594 case 521: /* List entry */
1595 case 529: /* List entry U */
1598 printf(" nextindex");
1600 case 518: /* Get entry by ID N */
1601 case 519: /* Get entry by name N */
1602 { unsigned long nservers
, j
;
1604 printf(" numservers");
1605 TRUNC(sizeof(int32_t));
1606 nservers
= EXTRACT_32BITS(bp
);
1607 bp
+= sizeof(int32_t);
1608 printf(" %lu", nservers
);
1610 for (i
= 0; i
< 13; i
++) {
1611 TRUNC(sizeof(int32_t));
1614 inet_ntoa(*((struct in_addr
*) bp
)));
1615 bp
+= sizeof(int32_t);
1617 printf(" partitions");
1618 for (i
= 0; i
< 13; i
++) {
1619 TRUNC(sizeof(int32_t));
1620 j
= EXTRACT_32BITS(bp
);
1621 if (i
< nservers
&& j
<= 26)
1622 printf(" %c", 'a' + (int)j
);
1623 else if (i
< nservers
)
1625 bp
+= sizeof(int32_t);
1627 TRUNC(13 * sizeof(int32_t));
1628 bp
+= 13 * sizeof(int32_t);
1637 case 526: /* Get entry by ID U */
1638 case 527: /* Get entry by name U */
1639 { unsigned long nservers
, j
;
1641 printf(" numservers");
1642 TRUNC(sizeof(int32_t));
1643 nservers
= EXTRACT_32BITS(bp
);
1644 bp
+= sizeof(int32_t);
1645 printf(" %lu", nservers
);
1647 for (i
= 0; i
< 13; i
++) {
1658 printf(" partitions");
1659 for (i
= 0; i
< 13; i
++) {
1660 TRUNC(sizeof(int32_t));
1661 j
= EXTRACT_32BITS(bp
);
1662 if (i
< nservers
&& j
<= 26)
1663 printf(" %c", 'a' + (int)j
);
1664 else if (i
< nservers
)
1666 bp
+= sizeof(int32_t);
1668 TRUNC(13 * sizeof(int32_t));
1669 bp
+= 13 * sizeof(int32_t);
1683 * Otherwise, just print out the return code
1696 * Handle calls to the AFS Kerberos Authentication service
1700 kauth_print(register const u_char
*bp
, int length
)
1705 if (length
<= sizeof(struct rx_header
))
1708 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1713 * Print out the afs call we're invoking. The table used here was
1714 * gleaned from kauth/kauth.rg
1717 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1721 if (is_ubik(kauth_op
)) {
1722 ubik_print(bp
, length
);
1727 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1730 * Decode some of the arguments to the KA calls
1733 bp
+= sizeof(struct rx_header
) + 4;
1736 case 1: /* Authenticate old */;
1737 case 21: /* Authenticate */
1738 case 22: /* Authenticate-V2 */
1739 case 2: /* Change PW */
1740 case 5: /* Set fields */
1741 case 6: /* Create user */
1742 case 7: /* Delete user */
1743 case 8: /* Get entry */
1744 case 14: /* Unlock */
1745 case 15: /* Lock status */
1746 printf(" principal");
1750 case 3: /* GetTicket-old */
1751 case 23: /* GetTicket */
1758 TRUNC(sizeof(int32_t));
1759 i
= (int) EXTRACT_32BITS(bp
);
1760 bp
+= sizeof(int32_t);
1763 printf(" principal");
1768 case 4: /* Set Password */
1769 printf(" principal");
1775 case 12: /* Get password */
1786 printf(" [|kauth]");
1790 * Handle replies to the AFS Kerberos Authentication Service
1794 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1796 struct rx_header
*rxh
;
1798 if (length
<= sizeof(struct rx_header
))
1801 rxh
= (struct rx_header
*) bp
;
1804 * Print out the afs call we're invoking. The table used here was
1805 * gleaned from kauth/kauth.rg
1810 if (is_ubik(opcode
)) {
1811 ubik_reply_print(bp
, length
, opcode
);
1815 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1817 bp
+= sizeof(struct rx_header
);
1820 * If it was a data packet, interpret the response.
1823 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1824 /* Well, no, not really. Leave this for later */
1828 * Otherwise, just print out the return code
1837 printf(" [|kauth]");
1841 * Handle calls to the AFS Volume location service
1845 vol_print(register const u_char
*bp
, int length
)
1849 if (length
<= sizeof(struct rx_header
))
1852 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1857 * Print out the afs call we're invoking. The table used here was
1858 * gleaned from volser/volint.xg
1861 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1863 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1866 * Normally there would be a switch statement here to decode the
1867 * arguments to the AFS call, but since I don't have access to
1868 * an AFS server (yet) and I'm not an AFS admin, I can't
1869 * test any of these calls. Leave this blank for now.
1879 * Handle replies to the AFS Volume Service
1883 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1885 struct rx_header
*rxh
;
1887 if (length
<= sizeof(struct rx_header
))
1890 rxh
= (struct rx_header
*) bp
;
1893 * Print out the afs call we're invoking. The table used here was
1894 * gleaned from volser/volint.xg
1897 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
1899 bp
+= sizeof(struct rx_header
);
1902 * If it was a data packet, interpret the response.
1905 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1906 /* Well, no, not really. Leave this for later */
1910 * Otherwise, just print out the return code
1923 * Handle calls to the AFS BOS service
1927 bos_print(register const u_char
*bp
, int length
)
1932 if (length
<= sizeof(struct rx_header
))
1935 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1940 * Print out the afs call we're invoking. The table used here was
1941 * gleaned from bozo/bosint.xg
1944 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1946 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
1949 * Decode some of the arguments to the BOS calls
1952 bp
+= sizeof(struct rx_header
) + 4;
1955 case 80: /* Create B node */
1958 printf(" instance");
1961 case 81: /* Delete B node */
1962 case 83: /* Get status */
1963 case 85: /* Get instance info */
1964 case 87: /* Add super user */
1965 case 88: /* Delete super user */
1966 case 93: /* Set cell name */
1967 case 96: /* Add cell host */
1968 case 97: /* Delete cell host */
1969 case 104: /* Restart */
1970 case 106: /* Uninstall */
1971 case 108: /* Exec */
1972 case 112: /* Getlog */
1973 case 114: /* Get instance strings */
1976 case 82: /* Set status */
1977 case 98: /* Set T status */
1982 case 86: /* Get instance parm */
1987 case 84: /* Enumerate instance */
1988 case 89: /* List super users */
1989 case 90: /* List keys */
1990 case 91: /* Add key */
1991 case 92: /* Delete key */
1992 case 95: /* Get cell host */
1995 case 105: /* Install */
2015 * Handle replies to the AFS BOS Service
2019 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2021 struct rx_header
*rxh
;
2023 if (length
<= sizeof(struct rx_header
))
2026 rxh
= (struct rx_header
*) bp
;
2029 * Print out the afs call we're invoking. The table used here was
2030 * gleaned from volser/volint.xg
2033 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2035 bp
+= sizeof(struct rx_header
);
2038 * If it was a data packet, interpret the response.
2041 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2042 /* Well, no, not really. Leave this for later */
2046 * Otherwise, just print out the return code
2059 * Check to see if this is a Ubik opcode.
2063 is_ubik(u_int32_t opcode
)
2065 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2066 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2073 * Handle Ubik opcodes to any one of the replicated database services
2077 ubik_print(register const u_char
*bp
, int length
)
2083 * Print out the afs call we're invoking. The table used here was
2084 * gleaned from ubik/ubik_int.xg
2087 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2089 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2092 * Decode some of the arguments to the Ubik calls
2095 bp
+= sizeof(struct rx_header
) + 4;
2098 case 10000: /* Beacon */
2100 temp
= EXTRACT_32BITS(bp
);
2101 bp
+= sizeof(int32_t);
2102 printf(" syncsite %s", temp
? "yes" : "no");
2103 printf(" votestart");
2105 printf(" dbversion");
2110 case 10003: /* Get sync site */
2114 case 20000: /* Begin */
2115 case 20001: /* Commit */
2116 case 20007: /* Abort */
2117 case 20008: /* Release locks */
2118 case 20010: /* Writev */
2122 case 20002: /* Lock */
2131 temp
= EXTRACT_32BITS(bp
);
2132 bp
+= sizeof(int32_t);
2133 tok2str(ubik_lock_types
, "type %d", temp
);
2135 case 20003: /* Write */
2143 case 20005: /* Get file */
2147 case 20006: /* Send file */
2152 printf(" dbversion");
2155 case 20009: /* Truncate */
2163 case 20012: /* Set version */
2166 printf(" oldversion");
2168 printf(" newversion");
2182 * Handle Ubik replies to any one of the replicated database services
2186 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2188 struct rx_header
*rxh
;
2190 if (length
< sizeof(struct rx_header
))
2193 rxh
= (struct rx_header
*) bp
;
2196 * Print out the ubik call we're invoking. This table was gleaned
2197 * from ubik/ubik_int.xg
2200 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2202 bp
+= sizeof(struct rx_header
);
2205 * If it was a data packet, print out the arguments to the Ubik calls
2208 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2210 case 10000: /* Beacon */
2213 case 20004: /* Get version */
2214 printf(" dbversion");
2222 * Otherwise, print out "yes" it it was a beacon packet (because
2223 * that's how yes votes are returned, go figure), otherwise
2224 * just print out the error code.
2229 case 10000: /* Beacon */
2230 printf(" vote yes until");
2245 * Handle RX ACK packets.
2249 rx_ack_print(register const u_char
*bp
, int length
)
2251 struct rx_ackPacket
*rxa
;
2254 if (length
< sizeof(struct rx_header
))
2257 bp
+= sizeof(struct rx_header
);
2260 * This may seem a little odd .... the rx_ackPacket structure
2261 * contains an array of individual packet acknowledgements
2262 * (used for selective ack/nack), but since it's variable in size,
2263 * we don't want to truncate based on the size of the whole
2264 * rx_ackPacket structure.
2267 TRUNC(sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2269 rxa
= (struct rx_ackPacket
*) bp
;
2270 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2273 * Print out a few useful things from the ack packet structure
2277 printf(" bufspace %d maxskew %d",
2278 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2279 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2281 printf(" first %d serial %d reason %s",
2282 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2283 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2286 * Okay, now we print out the ack array. The way _this_ works
2287 * is that we start at "first", and step through the ack array.
2288 * If we have a contiguous range of acks/nacks, try to
2289 * collapse them into a range.
2291 * If you're really clever, you might have noticed that this
2292 * doesn't seem quite correct. Specifically, due to structure
2293 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2294 * yield the start of the ack array (because RX_MAXACKS is 255
2295 * and the structure will likely get padded to a 2 or 4 byte
2296 * boundary). However, this is the way it's implemented inside
2297 * of AFS - the start of the extra fields are at
2298 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2299 * the exact start of the ack array. Sigh. That's why we aren't
2300 * using bp, but instead use rxa->acks[]. But nAcks gets added
2301 * to bp after this, so bp ends up at the right spot. Go figure.
2304 if (rxa
->nAcks
!= 0) {
2309 * Sigh, this is gross, but it seems to work to collapse
2313 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2314 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2317 * I figured this deserved _some_ explanation.
2318 * First, print "acked" and the packet seq
2319 * number if this is the first time we've
2320 * seen an acked packet.
2325 rxa
->firstPacket
+ i
);
2330 * Otherwise, if the there is a skip in
2331 * the range (such as an nacked packet in
2332 * the middle of some acked packets),
2333 * then print the current packet number
2334 * seperated from the last number by
2338 else if (last
!= i
- 1) {
2339 printf(",%d", rxa
->firstPacket
+ i
);
2344 * We always set last to the value of
2345 * the last ack we saw. Conversely, start
2346 * is set to the value of the first ack
2347 * we saw in a range.
2353 * Okay, this bit a code gets executed when
2354 * we hit a nack ... in _this_ case we
2355 * want to print out the range of packets
2356 * that were acked, so we need to print
2357 * the _previous_ packet number seperated
2358 * from the first by a dash (-). Since we
2359 * already printed the first packet above,
2360 * just print the final packet.
2362 } else if (last
== i
- 1)
2363 printf("-%d", rxa
->firstPacket
+ i
- 1);
2366 * So, what's going on here? We ran off the end of the
2367 * ack list, and if we got a range we need to finish it up.
2368 * So we need to determine if the last packet in the list
2369 * was an ack (if so, then last will be set to it) and
2370 * we need to see if the last range didn't start with the
2371 * last packet (because if it _did_, then that would mean
2372 * that the packet number has already been printed and
2373 * we don't need to print it again).
2376 if (last
== i
- 1 && start
!= last
)
2377 printf("-%d", rxa
->firstPacket
+ i
- 1);
2380 * Same as above, just without comments
2383 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2384 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2386 printf(" nacked %d",
2387 rxa
->firstPacket
+ i
);
2389 } else if (last
!= i
- 1) {
2390 printf(",%d", rxa
->firstPacket
+ i
);
2394 } else if (last
== i
- 1)
2395 printf("-%d", rxa
->firstPacket
+ i
- 1);
2397 if (last
== i
- 1 && start
!= last
)
2398 printf("-%d", rxa
->firstPacket
+ i
- 1);
2405 * These are optional fields; depending on your version of AFS,
2406 * you may or may not see them
2409 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2425 printf(" maxpackets");