]>
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.11 2000-02-10 17:56:13 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
));
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_DATA
&&
461 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
462 rxh
->flags
& RX_CLIENT_INITIATED
) {
465 * Insert this call into the call cache table, so we
466 * have a chance to print out replies
469 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
472 case FS_RX_PORT
: /* AFS file service */
473 fs_print(bp
, length
);
475 case CB_RX_PORT
: /* AFS callback service */
476 cb_print(bp
, length
);
478 case PROT_RX_PORT
: /* AFS protection service */
479 prot_print(bp
, length
);
481 case VLDB_RX_PORT
: /* AFS VLDB service */
482 vldb_print(bp
, length
);
484 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
485 kauth_print(bp
, length
);
487 case VOL_RX_PORT
: /* AFS Volume service */
488 vol_print(bp
, length
);
490 case BOS_RX_PORT
: /* AFS BOS service */
491 bos_print(bp
, length
);
498 * If it's a reply (client-init is _not_ set, but seq is one)
499 * then look it up in the cache. If we find it, call the reply
500 * printing functions Note that we handle abort packets here,
501 * because printing out the return code can be useful at times.
504 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
505 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
506 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
507 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
508 rx_cache_find(rxh
, (const struct ip
*) bp2
,
512 case FS_RX_PORT
: /* AFS file service */
513 fs_reply_print(bp
, length
, opcode
);
515 case CB_RX_PORT
: /* AFS callback service */
516 cb_reply_print(bp
, length
, opcode
);
518 case PROT_RX_PORT
: /* AFS PT service */
519 prot_reply_print(bp
, length
, opcode
);
521 case VLDB_RX_PORT
: /* AFS VLDB service */
522 vldb_reply_print(bp
, length
, opcode
);
524 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
525 kauth_reply_print(bp
, length
, opcode
);
527 case VOL_RX_PORT
: /* AFS Volume service */
528 vol_reply_print(bp
, length
, opcode
);
530 case BOS_RX_PORT
: /* AFS BOS service */
531 bos_reply_print(bp
, length
, opcode
);
538 * If it's an RX ack packet, then use the appropriate ack decoding
539 * function (there isn't any service-specific information in the
540 * ack packet, so we can use one for all AFS services)
543 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
544 rx_ack_print(bp
, length
);
547 printf(" (%d)", length
);
551 * Insert an entry into the cache. Taken from print-nfs.c
555 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
558 struct rx_cache_entry
*rxent
;
559 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
561 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
564 rxent
= &rx_cache
[rx_cache_next
];
566 if (++rx_cache_next
>= RX_CACHE_SIZE
)
569 rxent
->callnum
= rxh
->callNumber
;
570 rxent
->client
= ip
->ip_src
;
571 rxent
->server
= ip
->ip_dst
;
572 rxent
->dport
= dport
;
573 rxent
->serviceId
= rxh
->serviceId
;
574 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
578 * Lookup an entry in the cache. Also taken from print-nfs.c
580 * Note that because this is a reply, we're looking at the _source_
585 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
589 struct rx_cache_entry
*rxent
;
590 u_int32_t clip
= ip
->ip_dst
.s_addr
;
591 u_int32_t sip
= ip
->ip_src
.s_addr
;
593 /* Start the search where we last left off */
597 rxent
= &rx_cache
[i
];
598 if (rxent
->callnum
== rxh
->callNumber
&&
599 rxent
->client
.s_addr
== clip
&&
600 rxent
->server
.s_addr
== sip
&&
601 rxent
->serviceId
== rxh
->serviceId
&&
602 rxent
->dport
== sport
) {
604 /* We got a match! */
607 *opcode
= rxent
->opcode
;
610 if (++i
> RX_CACHE_SIZE
)
612 } while (i
!= rx_cache_hint
);
614 /* Our search failed */
619 * These extrememly grody macros handle the printing of various AFS stuff.
622 #define TRUNC(n) if (snapend - bp + 1 <= n) goto trunc;
623 #define FIDOUT() { unsigned long n1, n2, n3; \
624 TRUNC(sizeof(int32_t) * 3); \
625 n1 = EXTRACT_32BITS(bp); \
626 bp += sizeof(int32_t); \
627 n2 = EXTRACT_32BITS(bp); \
628 bp += sizeof(int32_t); \
629 n3 = EXTRACT_32BITS(bp); \
630 bp += sizeof(int32_t); \
631 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
634 #define STROUT(MAX) { int i; \
635 TRUNC(sizeof(int32_t)); \
636 i = (int) EXTRACT_32BITS(bp); \
637 bp += sizeof(int32_t); \
639 strncpy(s, (char *) bp, min(MAX, i)); \
641 printf(" \"%s\"", s); \
642 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
645 #define INTOUT() { int i; \
646 TRUNC(sizeof(int32_t)); \
647 i = (int) EXTRACT_32BITS(bp); \
648 bp += sizeof(int32_t); \
652 #define UINTOUT() { unsigned long i; \
653 TRUNC(sizeof(int32_t)); \
654 i = EXTRACT_32BITS(bp); \
655 bp += sizeof(int32_t); \
659 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
660 TRUNC(sizeof(int32_t)); \
661 t = (time_t) EXTRACT_32BITS(bp); \
662 bp += sizeof(int32_t); \
663 tm = localtime(&t); \
664 strftime(str, 256, "%Y/%m/%d %T", tm); \
665 printf(" %s", str); \
668 #define STOREATTROUT() { unsigned long mask, i; \
669 TRUNC((sizeof(int32_t)*6)); \
670 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
671 if (mask) printf (" StoreStatus"); \
672 if (mask & 1) { printf(" date"); DATEOUT(); } \
673 else bp += sizeof(int32_t); \
674 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
675 if (mask & 2) printf(" owner %lu", i); \
676 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
677 if (mask & 4) printf(" group %lu", i); \
678 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
679 if (mask & 8) printf(" mode %lo", i & 07777); \
680 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
681 if (mask & 16) printf(" segsize %lu", i); \
682 /* undocumented in 3.3 docu */ \
683 if (mask & 1024) printf(" fsync"); \
686 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
687 TRUNC(sizeof(int32_t) * 2); \
688 epoch = EXTRACT_32BITS(bp); \
689 bp += sizeof(int32_t); \
690 counter = EXTRACT_32BITS(bp); \
691 bp += sizeof(int32_t); \
692 printf(" %d.%d", epoch, counter); \
695 #define AFSUUIDOUT() {u_int32_t temp; int i; \
696 TRUNC(11*sizeof(u_int32_t)); \
697 temp = EXTRACT_32BITS(bp); \
698 bp += sizeof(u_int32_t); \
699 printf(" %08x", temp); \
700 temp = EXTRACT_32BITS(bp); \
701 bp += sizeof(u_int32_t); \
702 printf("%04x", temp); \
703 temp = EXTRACT_32BITS(bp); \
704 bp += sizeof(u_int32_t); \
705 printf("%04x", temp); \
706 for (i = 0; i < 8; i++) { \
707 temp = EXTRACT_32BITS(bp); \
708 bp += sizeof(u_int32_t); \
709 printf("%02x", (unsigned char) temp); \
714 * This is the sickest one of all
717 #define VECOUT(MAX) { char *sp; \
719 TRUNC(MAX * sizeof(int32_t)); \
721 for (k = 0; k < MAX; k++) { \
722 *sp++ = (char) EXTRACT_32BITS(bp); \
723 bp += sizeof(int32_t); \
726 printf(" \"%s\"", s); \
730 * Handle calls to the AFS file service (fs)
734 fs_print(register const u_char
*bp
, int length
)
740 if (length
<= sizeof(struct rx_header
))
743 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
748 * Print out the afs call we're invoking. The table used here was
749 * gleaned from fsint/afsint.xg
752 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
754 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
757 * Print out arguments to some of the AFS calls. This stuff is
761 bp
+= sizeof(struct rx_header
) + 4;
764 * Sigh. This is gross. Ritchie forgive me.
768 case 130: /* Fetch data */
775 case 131: /* Fetch ACL */
776 case 132: /* Fetch Status */
777 case 143: /* Old set lock */
778 case 144: /* Old extend lock */
779 case 145: /* Old release lock */
780 case 156: /* Set lock */
781 case 157: /* Extend lock */
782 case 158: /* Release lock */
785 case 135: /* Store status */
789 case 133: /* Store data */
799 case 134: /* Store ACL */
801 char a
[AFSOPAQUEMAX
];
804 i
= EXTRACT_32BITS(bp
);
805 bp
+= sizeof(int32_t);
807 strncpy(a
, (char *) bp
, min(AFSOPAQUEMAX
, i
));
809 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
812 case 137: /* Create file */
813 case 141: /* MakeDir */
818 case 136: /* Remove file */
819 case 142: /* Remove directory */
823 case 138: /* Rename file */
831 case 139: /* Symlink */
843 case 148: /* Get volume info */
846 case 149: /* Get volume stats */
847 case 150: /* Set volume stats */
851 case 154: /* New get volume info */
855 case 155: /* Bulk stat */
859 j
= EXTRACT_32BITS(bp
);
860 bp
+= sizeof(int32_t);
862 for (i
= 0; i
< j
; i
++) {
881 * Handle replies to the AFS file service
885 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
889 struct rx_header
*rxh
;
891 if (length
<= sizeof(struct rx_header
))
894 rxh
= (struct rx_header
*) bp
;
897 * Print out the afs call we're invoking. The table used here was
898 * gleaned from fsint/afsint.xg
901 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
903 bp
+= sizeof(struct rx_header
);
906 * If it was a data packet, interpret the response
909 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
911 case 131: /* Fetch ACL */
913 char a
[AFSOPAQUEMAX
];
915 i
= EXTRACT_32BITS(bp
);
916 bp
+= sizeof(int32_t);
918 strncpy(a
, (char *) bp
, min(AFSOPAQUEMAX
, i
));
920 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
923 case 137: /* Create file */
924 case 141: /* MakeDir */
928 case 151: /* Get root volume */
929 printf(" root volume");
932 case 153: /* Get time */
938 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
942 * Otherwise, just print out the return code
944 TRUNC(sizeof(int32_t));
945 i
= (int) EXTRACT_32BITS(bp
);
946 bp
+= sizeof(int32_t);
948 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
950 printf(" strange fs reply of type %d", rxh
->type
);
960 * Print out an AFS ACL string. An AFS ACL is a string that has the
963 * <positive> <negative>
967 * "positive" and "negative" are integers which contain the number of
968 * positive and negative ACL's in the string. The uid/aclbits pair are
969 * ASCII strings containing the UID/PTS record and and a ascii number
970 * representing a logical OR of all the ACL permission bits
974 acl_print(u_char
*s
, u_char
*end
)
980 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
989 * This wacky order preserves the order used by the "fs" command
992 #define ACLOUT(acl) \
993 if (acl & PRSFS_READ) \
995 if (acl & PRSFS_LOOKUP) \
997 if (acl & PRSFS_INSERT) \
999 if (acl & PRSFS_DELETE) \
1001 if (acl & PRSFS_WRITE) \
1003 if (acl & PRSFS_LOCK) \
1005 if (acl & PRSFS_ADMINISTER) \
1008 for (i
= 0; i
< pos
; i
++) {
1009 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1012 printf(" +{%s ", user
);
1019 for (i
= 0; i
< neg
; i
++) {
1020 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1023 printf(" -{%s ", user
);
1034 * Handle calls to the AFS callback service
1038 cb_print(register const u_char
*bp
, int length
)
1043 if (length
<= sizeof(struct rx_header
))
1046 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1051 * Print out the afs call we're invoking. The table used here was
1052 * gleaned from fsint/afscbint.xg
1055 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1057 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1059 bp
+= sizeof(struct rx_header
) + 4;
1062 * Print out the afs call we're invoking. The table used here was
1063 * gleaned from fsint/afscbint.xg
1067 case 204: /* Callback */
1071 j
= EXTRACT_32BITS(bp
);
1072 bp
+= sizeof(int32_t);
1074 for (i
= 0; i
< j
; i
++) {
1083 j
= EXTRACT_32BITS(bp
);
1084 bp
+= sizeof(int32_t);
1089 for (i
= 0; i
< j
; i
++) {
1095 t
= EXTRACT_32BITS(bp
);
1096 bp
+= sizeof(int32_t);
1097 tok2str(cb_types
, "type %d", t
);
1116 * Handle replies to the AFS Callback Service
1120 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1122 struct rx_header
*rxh
;
1124 if (length
<= sizeof(struct rx_header
))
1127 rxh
= (struct rx_header
*) bp
;
1130 * Print out the afs call we're invoking. The table used here was
1131 * gleaned from fsint/afscbint.xg
1134 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1136 bp
+= sizeof(struct rx_header
);
1139 * If it was a data packet, interpret the response.
1142 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1144 case 213: /* InitCallBackState3 */
1152 * Otherwise, just print out the return code
1165 * Handle calls to the AFS protection database server
1169 prot_print(register const u_char
*bp
, int length
)
1175 if (length
<= sizeof(struct rx_header
))
1178 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1183 * Print out the afs call we're invoking. The table used here was
1184 * gleaned from ptserver/ptint.xg
1187 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1191 if (is_ubik(pt_op
)) {
1192 ubik_print(bp
, length
);
1196 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1199 * Decode some of the arguments to the PT calls
1202 bp
+= sizeof(struct rx_header
) + 4;
1205 case 500: /* I New User */
1212 case 501: /* Where is it */
1213 case 506: /* Delete */
1214 case 508: /* Get CPS */
1215 case 512: /* List entry */
1216 case 514: /* List elements */
1217 case 517: /* List owned */
1218 case 518: /* Get CPS2 */
1219 case 519: /* Get host CPS */
1223 case 502: /* Dump entry */
1227 case 503: /* Add to group */
1228 case 507: /* Remove from group */
1229 case 515: /* Is a member of? */
1235 case 504: /* Name to ID */
1239 j
= EXTRACT_32BITS(bp
);
1240 bp
+= sizeof(int32_t);
1243 * Who designed this chicken-shit protocol?
1245 * Each character is stored as a 32-bit
1249 for (i
= 0; i
< j
; i
++) {
1256 case 505: /* Id to name */
1261 i
= EXTRACT_32BITS(bp
);
1262 bp
+= sizeof(int32_t);
1263 for (j
= 0; j
< i
; j
++)
1269 case 509: /* New entry */
1276 case 511: /* Set max */
1282 case 513: /* Change entry */
1291 case 520: /* Update entry */
1308 * Handle replies to the AFS protection service
1312 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1314 struct rx_header
*rxh
;
1318 if (length
< sizeof(struct rx_header
))
1321 rxh
= (struct rx_header
*) bp
;
1324 * Print out the afs call we're invoking. The table used here was
1325 * gleaned from ptserver/ptint.xg. Check to see if it's a
1326 * Ubik call, however.
1331 if (is_ubik(opcode
)) {
1332 ubik_reply_print(bp
, length
, opcode
);
1336 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1338 bp
+= sizeof(struct rx_header
);
1341 * If it was a data packet, interpret the response
1344 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1346 case 504: /* Name to ID */
1351 i
= EXTRACT_32BITS(bp
);
1352 bp
+= sizeof(int32_t);
1353 for (j
= 0; j
< i
; j
++)
1359 case 505: /* ID to name */
1363 j
= EXTRACT_32BITS(bp
);
1364 bp
+= sizeof(int32_t);
1367 * Who designed this chicken-shit protocol?
1369 * Each character is stored as a 32-bit
1373 for (i
= 0; i
< j
; i
++) {
1380 case 508: /* Get CPS */
1381 case 514: /* List elements */
1382 case 517: /* List owned */
1383 case 518: /* Get CPS2 */
1384 case 519: /* Get host CPS */
1388 j
= EXTRACT_32BITS(bp
);
1389 bp
+= sizeof(int32_t);
1390 for (i
= 0; i
< j
; i
++) {
1397 case 510: /* List max */
1408 * Otherwise, just print out the return code
1421 * Handle calls to the AFS volume location database service
1425 vldb_print(register const u_char
*bp
, int length
)
1431 if (length
<= sizeof(struct rx_header
))
1434 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1439 * Print out the afs call we're invoking. The table used here was
1440 * gleaned from vlserver/vldbint.xg
1443 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1447 if (is_ubik(vldb_op
)) {
1448 ubik_print(bp
, length
);
1451 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1454 * Decode some of the arguments to the VLDB calls
1457 bp
+= sizeof(struct rx_header
) + 4;
1460 case 501: /* Create new volume */
1461 case 517: /* Create entry N */
1464 case 502: /* Delete entry */
1465 case 503: /* Get entry by ID */
1466 case 507: /* Update entry */
1467 case 508: /* Set lock */
1468 case 509: /* Release lock */
1469 case 518: /* Get entry by ID N */
1472 TRUNC(sizeof(int32_t));
1473 i
= EXTRACT_32BITS(bp
);
1474 bp
+= sizeof(int32_t);
1476 printf(" type %s", voltype
[i
]);
1478 case 504: /* Get entry by name */
1479 case 519: /* Get entry by name N */
1480 case 524: /* Update entry by name */
1481 case 527: /* Get entry by name U */
1484 case 505: /* Get new vol id */
1488 case 506: /* Replace entry */
1489 case 520: /* Replace entry N */
1492 TRUNC(sizeof(int32_t));
1493 i
= EXTRACT_32BITS(bp
);
1494 bp
+= sizeof(int32_t);
1496 printf(" type %s", voltype
[i
]);
1499 case 510: /* List entry */
1500 case 521: /* List entry N */
1515 * Handle replies to the AFS volume location database service
1519 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1521 struct rx_header
*rxh
;
1525 if (length
< sizeof(struct rx_header
))
1528 rxh
= (struct rx_header
*) bp
;
1531 * Print out the afs call we're invoking. The table used here was
1532 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1533 * Ubik call, however.
1538 if (is_ubik(opcode
)) {
1539 ubik_reply_print(bp
, length
, opcode
);
1543 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1545 bp
+= sizeof(struct rx_header
);
1548 * If it was a data packet, interpret the response
1551 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1553 case 510: /* List entry */
1556 printf(" nextindex");
1558 case 503: /* Get entry by id */
1559 case 504: /* Get entry by name */
1560 { unsigned long nservers
, j
;
1562 TRUNC(sizeof(int32_t));
1563 bp
+= sizeof(int32_t);
1564 printf(" numservers");
1565 TRUNC(sizeof(int32_t));
1566 nservers
= EXTRACT_32BITS(bp
);
1567 bp
+= sizeof(int32_t);
1568 printf(" %lu", nservers
);
1570 for (i
= 0; i
< 8; i
++) {
1571 TRUNC(sizeof(int32_t));
1574 inet_ntoa(*((struct in_addr
*) bp
)));
1575 bp
+= sizeof(int32_t);
1577 printf(" partitions");
1578 for (i
= 0; i
< 8; i
++) {
1579 TRUNC(sizeof(int32_t));
1580 j
= EXTRACT_32BITS(bp
);
1581 if (i
< nservers
&& j
<= 26)
1582 printf(" %c", 'a' + (int)j
);
1583 else if (i
< nservers
)
1585 bp
+= sizeof(int32_t);
1587 TRUNC(8 * sizeof(int32_t));
1588 bp
+= 8 * sizeof(int32_t);
1597 case 505: /* Get new volume ID */
1601 case 521: /* List entry */
1602 case 529: /* List entry U */
1605 printf(" nextindex");
1607 case 518: /* Get entry by ID N */
1608 case 519: /* Get entry by name N */
1609 { unsigned long nservers
, j
;
1611 printf(" numservers");
1612 TRUNC(sizeof(int32_t));
1613 nservers
= EXTRACT_32BITS(bp
);
1614 bp
+= sizeof(int32_t);
1615 printf(" %lu", nservers
);
1617 for (i
= 0; i
< 13; i
++) {
1618 TRUNC(sizeof(int32_t));
1621 inet_ntoa(*((struct in_addr
*) bp
)));
1622 bp
+= sizeof(int32_t);
1624 printf(" partitions");
1625 for (i
= 0; i
< 13; i
++) {
1626 TRUNC(sizeof(int32_t));
1627 j
= EXTRACT_32BITS(bp
);
1628 if (i
< nservers
&& j
<= 26)
1629 printf(" %c", 'a' + (int)j
);
1630 else if (i
< nservers
)
1632 bp
+= sizeof(int32_t);
1634 TRUNC(13 * sizeof(int32_t));
1635 bp
+= 13 * sizeof(int32_t);
1644 case 526: /* Get entry by ID U */
1645 case 527: /* Get entry by name U */
1646 { unsigned long nservers
, j
;
1648 printf(" numservers");
1649 TRUNC(sizeof(int32_t));
1650 nservers
= EXTRACT_32BITS(bp
);
1651 bp
+= sizeof(int32_t);
1652 printf(" %lu", nservers
);
1654 for (i
= 0; i
< 13; i
++) {
1665 printf(" partitions");
1666 for (i
= 0; i
< 13; i
++) {
1667 TRUNC(sizeof(int32_t));
1668 j
= EXTRACT_32BITS(bp
);
1669 if (i
< nservers
&& j
<= 26)
1670 printf(" %c", 'a' + (int)j
);
1671 else if (i
< nservers
)
1673 bp
+= sizeof(int32_t);
1675 TRUNC(13 * sizeof(int32_t));
1676 bp
+= 13 * sizeof(int32_t);
1690 * Otherwise, just print out the return code
1703 * Handle calls to the AFS Kerberos Authentication service
1707 kauth_print(register const u_char
*bp
, int length
)
1712 if (length
<= sizeof(struct rx_header
))
1715 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1720 * Print out the afs call we're invoking. The table used here was
1721 * gleaned from kauth/kauth.rg
1724 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1728 if (is_ubik(kauth_op
)) {
1729 ubik_print(bp
, length
);
1734 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1737 * Decode some of the arguments to the KA calls
1740 bp
+= sizeof(struct rx_header
) + 4;
1743 case 1: /* Authenticate old */;
1744 case 21: /* Authenticate */
1745 case 22: /* Authenticate-V2 */
1746 case 2: /* Change PW */
1747 case 5: /* Set fields */
1748 case 6: /* Create user */
1749 case 7: /* Delete user */
1750 case 8: /* Get entry */
1751 case 14: /* Unlock */
1752 case 15: /* Lock status */
1753 printf(" principal");
1757 case 3: /* GetTicket-old */
1758 case 23: /* GetTicket */
1765 TRUNC(sizeof(int32_t));
1766 i
= (int) EXTRACT_32BITS(bp
);
1767 bp
+= sizeof(int32_t);
1770 printf(" principal");
1775 case 4: /* Set Password */
1776 printf(" principal");
1782 case 12: /* Get password */
1793 printf(" [|kauth]");
1797 * Handle replies to the AFS Kerberos Authentication Service
1801 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1803 struct rx_header
*rxh
;
1805 if (length
<= sizeof(struct rx_header
))
1808 rxh
= (struct rx_header
*) bp
;
1811 * Print out the afs call we're invoking. The table used here was
1812 * gleaned from kauth/kauth.rg
1817 if (is_ubik(opcode
)) {
1818 ubik_reply_print(bp
, length
, opcode
);
1822 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1824 bp
+= sizeof(struct rx_header
);
1827 * If it was a data packet, interpret the response.
1830 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1831 /* Well, no, not really. Leave this for later */
1835 * Otherwise, just print out the return code
1844 printf(" [|kauth]");
1848 * Handle calls to the AFS Volume location service
1852 vol_print(register const u_char
*bp
, int length
)
1856 if (length
<= sizeof(struct rx_header
))
1859 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1864 * Print out the afs call we're invoking. The table used here was
1865 * gleaned from volser/volint.xg
1868 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1870 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1873 * Normally there would be a switch statement here to decode the
1874 * arguments to the AFS call, but since I don't have access to
1875 * an AFS server (yet) and I'm not an AFS admin, I can't
1876 * test any of these calls. Leave this blank for now.
1886 * Handle replies to the AFS Volume Service
1890 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1892 struct rx_header
*rxh
;
1894 if (length
<= sizeof(struct rx_header
))
1897 rxh
= (struct rx_header
*) bp
;
1900 * Print out the afs call we're invoking. The table used here was
1901 * gleaned from volser/volint.xg
1904 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
1906 bp
+= sizeof(struct rx_header
);
1909 * If it was a data packet, interpret the response.
1912 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1913 /* Well, no, not really. Leave this for later */
1917 * Otherwise, just print out the return code
1930 * Handle calls to the AFS BOS service
1934 bos_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 bozo/bosint.xg
1951 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1953 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
1956 * Decode some of the arguments to the BOS calls
1959 bp
+= sizeof(struct rx_header
) + 4;
1962 case 80: /* Create B node */
1965 printf(" instance");
1968 case 81: /* Delete B node */
1969 case 83: /* Get status */
1970 case 85: /* Get instance info */
1971 case 87: /* Add super user */
1972 case 88: /* Delete super user */
1973 case 93: /* Set cell name */
1974 case 96: /* Add cell host */
1975 case 97: /* Delete cell host */
1976 case 104: /* Restart */
1977 case 106: /* Uninstall */
1978 case 108: /* Exec */
1979 case 112: /* Getlog */
1980 case 114: /* Get instance strings */
1983 case 82: /* Set status */
1984 case 98: /* Set T status */
1989 case 86: /* Get instance parm */
1994 case 84: /* Enumerate instance */
1995 case 89: /* List super users */
1996 case 90: /* List keys */
1997 case 91: /* Add key */
1998 case 92: /* Delete key */
1999 case 95: /* Get cell host */
2002 case 105: /* Install */
2022 * Handle replies to the AFS BOS Service
2026 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2028 struct rx_header
*rxh
;
2030 if (length
<= sizeof(struct rx_header
))
2033 rxh
= (struct rx_header
*) bp
;
2036 * Print out the afs call we're invoking. The table used here was
2037 * gleaned from volser/volint.xg
2040 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2042 bp
+= sizeof(struct rx_header
);
2045 * If it was a data packet, interpret the response.
2048 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2049 /* Well, no, not really. Leave this for later */
2053 * Otherwise, just print out the return code
2066 * Check to see if this is a Ubik opcode.
2070 is_ubik(u_int32_t opcode
)
2072 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2073 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2080 * Handle Ubik opcodes to any one of the replicated database services
2084 ubik_print(register const u_char
*bp
, int length
)
2090 * Print out the afs call we're invoking. The table used here was
2091 * gleaned from ubik/ubik_int.xg
2094 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2096 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2099 * Decode some of the arguments to the Ubik calls
2102 bp
+= sizeof(struct rx_header
) + 4;
2105 case 10000: /* Beacon */
2107 temp
= EXTRACT_32BITS(bp
);
2108 bp
+= sizeof(int32_t);
2109 printf(" syncsite %s", temp
? "yes" : "no");
2110 printf(" votestart");
2112 printf(" dbversion");
2117 case 10003: /* Get sync site */
2121 case 20000: /* Begin */
2122 case 20001: /* Commit */
2123 case 20007: /* Abort */
2124 case 20008: /* Release locks */
2125 case 20010: /* Writev */
2129 case 20002: /* Lock */
2138 temp
= EXTRACT_32BITS(bp
);
2139 bp
+= sizeof(int32_t);
2140 tok2str(ubik_lock_types
, "type %d", temp
);
2142 case 20003: /* Write */
2150 case 20005: /* Get file */
2154 case 20006: /* Send file */
2159 printf(" dbversion");
2162 case 20009: /* Truncate */
2170 case 20012: /* Set version */
2173 printf(" oldversion");
2175 printf(" newversion");
2189 * Handle Ubik replies to any one of the replicated database services
2193 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2195 struct rx_header
*rxh
;
2197 if (length
< sizeof(struct rx_header
))
2200 rxh
= (struct rx_header
*) bp
;
2203 * Print out the ubik call we're invoking. This table was gleaned
2204 * from ubik/ubik_int.xg
2207 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2209 bp
+= sizeof(struct rx_header
);
2212 * If it was a data packet, print out the arguments to the Ubik calls
2215 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2217 case 10000: /* Beacon */
2220 case 20004: /* Get version */
2221 printf(" dbversion");
2229 * Otherwise, print out "yes" it it was a beacon packet (because
2230 * that's how yes votes are returned, go figure), otherwise
2231 * just print out the error code.
2236 case 10000: /* Beacon */
2237 printf(" vote yes until");
2252 * Handle RX ACK packets.
2256 rx_ack_print(register const u_char
*bp
, int length
)
2258 struct rx_ackPacket
*rxa
;
2261 if (length
< sizeof(struct rx_header
))
2264 bp
+= sizeof(struct rx_header
);
2267 * This may seem a little odd .... the rx_ackPacket structure
2268 * contains an array of individual packet acknowledgements
2269 * (used for selective ack/nack), but since it's variable in size,
2270 * we don't want to truncate based on the size of the whole
2271 * rx_ackPacket structure.
2274 TRUNC(sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2276 rxa
= (struct rx_ackPacket
*) bp
;
2277 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2280 * Print out a few useful things from the ack packet structure
2284 printf(" bufspace %d maxskew %d",
2285 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2286 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2288 printf(" first %d serial %d reason %s",
2289 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2290 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2293 * Okay, now we print out the ack array. The way _this_ works
2294 * is that we start at "first", and step through the ack array.
2295 * If we have a contiguous range of acks/nacks, try to
2296 * collapse them into a range.
2298 * If you're really clever, you might have noticed that this
2299 * doesn't seem quite correct. Specifically, due to structure
2300 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2301 * yield the start of the ack array (because RX_MAXACKS is 255
2302 * and the structure will likely get padded to a 2 or 4 byte
2303 * boundary). However, this is the way it's implemented inside
2304 * of AFS - the start of the extra fields are at
2305 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2306 * the exact start of the ack array. Sigh. That's why we aren't
2307 * using bp, but instead use rxa->acks[]. But nAcks gets added
2308 * to bp after this, so bp ends up at the right spot. Go figure.
2311 if (rxa
->nAcks
!= 0) {
2316 * Sigh, this is gross, but it seems to work to collapse
2320 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2321 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2324 * I figured this deserved _some_ explanation.
2325 * First, print "acked" and the packet seq
2326 * number if this is the first time we've
2327 * seen an acked packet.
2332 rxa
->firstPacket
+ i
);
2337 * Otherwise, if the there is a skip in
2338 * the range (such as an nacked packet in
2339 * the middle of some acked packets),
2340 * then print the current packet number
2341 * seperated from the last number by
2345 else if (last
!= i
- 1) {
2346 printf(",%d", rxa
->firstPacket
+ i
);
2351 * We always set last to the value of
2352 * the last ack we saw. Conversely, start
2353 * is set to the value of the first ack
2354 * we saw in a range.
2360 * Okay, this bit a code gets executed when
2361 * we hit a nack ... in _this_ case we
2362 * want to print out the range of packets
2363 * that were acked, so we need to print
2364 * the _previous_ packet number seperated
2365 * from the first by a dash (-). Since we
2366 * already printed the first packet above,
2367 * just print the final packet. Don't
2368 * do this if there will be a single-length
2371 } else if (last
== i
- 1 && start
!= last
)
2372 printf("-%d", rxa
->firstPacket
+ i
- 1);
2375 * So, what's going on here? We ran off the end of the
2376 * ack list, and if we got a range we need to finish it up.
2377 * So we need to determine if the last packet in the list
2378 * was an ack (if so, then last will be set to it) and
2379 * we need to see if the last range didn't start with the
2380 * last packet (because if it _did_, then that would mean
2381 * that the packet number has already been printed and
2382 * we don't need to print it again).
2385 if (last
== i
- 1 && start
!= last
)
2386 printf("-%d", rxa
->firstPacket
+ i
- 1);
2389 * Same as above, just without comments
2392 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2393 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2395 printf(" nacked %d",
2396 rxa
->firstPacket
+ i
);
2398 } else if (last
!= i
- 1) {
2399 printf(",%d", rxa
->firstPacket
+ i
);
2403 } else if (last
== i
- 1 && start
!= last
)
2404 printf("-%d", rxa
->firstPacket
+ i
- 1);
2406 if (last
== i
- 1 && start
!= last
)
2407 printf("-%d", rxa
->firstPacket
+ i
- 1);
2414 * These are optional fields; depending on your version of AFS,
2415 * you may or may not see them
2418 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2434 printf(" maxpackets");