]>
The Tcpdump Group git mirrors - tcpdump/blob - print-rx.c
6e5c2bd90f831f03eb1055e72f860f7e8f2660fb
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.12 2000-07-10 04:38:25 assar Exp $";
26 #include <sys/param.h>
28 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <netinet/in.h>
31 #include <netinet/in_systm.h>
32 #include <netinet/ip.h>
33 #include <arpa/inet.h>
35 #include "interface.h"
36 #include "addrtoname.h"
39 #undef NOERROR /* Solaris sucks */
40 #include <arpa/nameser.h>
44 static struct tok rx_types
[] = {
45 { RX_PACKET_TYPE_DATA
, "data" },
46 { RX_PACKET_TYPE_ACK
, "ack" },
47 { RX_PACKET_TYPE_BUSY
, "busy" },
48 { RX_PACKET_TYPE_ABORT
, "abort" },
49 { RX_PACKET_TYPE_ACKALL
, "ackall" },
50 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
51 { RX_PACKET_TYPE_RESPONSE
, "response" },
52 { RX_PACKET_TYPE_DEBUG
, "debug" },
53 { RX_PACKET_TYPE_PARAMS
, "params" },
54 { RX_PACKET_TYPE_VERSION
, "version" },
58 static struct tok rx_flags
[] = {
59 { RX_CLIENT_INITIATED
, "client-init" },
60 { RX_REQUEST_ACK
, "req-ack" },
61 { RX_LAST_PACKET
, "last-pckt" },
62 { RX_MORE_PACKETS
, "more-pckts" },
63 { RX_FREE_PACKET
, "free-pckt" }
66 static struct tok fs_req
[] = {
67 { 130, "fetch-data" },
69 { 132, "fetch-status" },
70 { 133, "store-data" },
72 { 135, "store-status" },
73 { 136, "remove-file" },
74 { 137, "create-file" },
80 { 143, "oldsetlock" },
81 { 144, "oldextlock" },
82 { 145, "oldrellock" },
85 { 148, "get-vlinfo" },
86 { 149, "get-vlstats" },
87 { 150, "set-vlstats" },
88 { 151, "get-rootvl" },
89 { 152, "check-token" },
91 { 154, "nget-vlinfo" },
98 { 161, "dfs-lookup" },
99 { 162, "dfs-flushcps" },
100 { 163, "dfs-symlink" },
104 static struct tok cb_req
[] = {
113 { 212, "whoareyou" },
115 { 214, "probeuuid" },
119 static struct tok pt_req
[] = {
121 { 501, "where-is-it" },
122 { 502, "dump-entry" },
123 { 503, "add-to-group" },
124 { 504, "name-to-id" },
125 { 505, "id-to-name" },
127 { 507, "remove-from-group" },
129 { 509, "new-entry" },
132 { 512, "list-entry" },
133 { 513, "change-entry" },
134 { 514, "list-elements" },
135 { 515, "same-mbr-of" },
136 { 516, "set-fld-sentry" },
137 { 517, "list-owned" },
139 { 519, "get-host-cps" },
140 { 520, "update-entry" },
144 static struct tok vldb_req
[] = {
145 { 501, "create-entry" },
146 { 502, "delete-entry" },
147 { 503, "get-entry-by-id" },
148 { 504, "get-entry-by-name" },
149 { 505, "get-new-volume-id" },
150 { 506, "replace-entry" },
151 { 507, "update-entry" },
153 { 509, "releaselock" },
154 { 510, "list-entry" },
155 { 511, "list-attrib" },
156 { 512, "linked-list" },
157 { 513, "get-stats" },
159 { 515, "get-addrs" },
160 { 516, "change-addr" },
161 { 517, "create-entry-n" },
162 { 518, "get-entry-by-id-n" },
163 { 519, "get-entry-by-name-n" },
164 { 520, "replace-entry-n" },
165 { 521, "list-entry-n" },
166 { 522, "list-attrib-n" },
167 { 523, "linked-list-n" },
168 { 524, "update-entry-by-name" },
169 { 525, "create-entry-u" },
170 { 526, "get-entry-by-id-u" },
171 { 527, "get-entry-by-name-u" },
172 { 528, "replace-entry-u" },
173 { 529, "list-entry-u" },
174 { 530, "list-attrib-u" },
175 { 531, "linked-list-u" },
177 { 533, "get-addrs-u" },
181 static struct tok kauth_req
[] = {
183 { 21, "authenticate" },
184 { 22, "authenticate-v2" },
186 { 3, "get-ticket-old" },
187 { 23, "get-ticket" },
190 { 6, "create-user" },
191 { 7, "delete-user" },
197 { 13, "get-random-key" },
199 { 15, "lock-status" },
203 static struct tok vol_req
[] = {
204 { 100, "create-volume" },
205 { 101, "delete-volume" },
208 { 104, "end-trans" },
210 { 106, "set-flags" },
211 { 107, "get-flags" },
212 { 108, "trans-create" },
214 { 110, "get-nth-volume" },
215 { 111, "set-forwarding" },
217 { 113, "get-status" },
218 { 114, "sig-restore" },
219 { 115, "list-partitions" },
220 { 116, "list-volumes" },
221 { 117, "set-id-types" },
223 { 119, "partition-info" },
225 { 121, "list-one-volume" },
228 { 124, "x-list-volumes" },
229 { 125, "x-list-one-volume" },
231 { 127, "x-list-partitions" },
232 { 128, "forward-multiple" },
236 static struct tok bos_req
[] = {
237 { 80, "create-bnode" },
238 { 81, "delete-bnode" },
239 { 82, "set-status" },
240 { 83, "get-status" },
241 { 84, "enumerate-instance" },
242 { 85, "get-instance-info" },
243 { 86, "get-instance-parm" },
244 { 87, "add-superuser" },
245 { 88, "delete-superuser" },
246 { 89, "list-superusers" },
249 { 92, "delete-key" },
250 { 93, "set-cell-name" },
251 { 94, "get-cell-name" },
252 { 95, "get-cell-host" },
253 { 96, "add-cell-host" },
254 { 97, "delete-cell-host" },
255 { 98, "set-t-status" },
256 { 99, "shutdown-all" },
257 { 100, "restart-all" },
258 { 101, "startup-all" },
259 { 102, "set-noauth-flag" },
262 { 105, "start-bozo-install" },
263 { 106, "uninstall" },
264 { 107, "get-dates" },
267 { 110, "set-restart-time" },
268 { 111, "get-restart-time" },
269 { 112, "start-bozo-log" },
271 { 114, "get-instance-strings" },
275 static struct tok ubik_req
[] = {
276 { 10000, "vote-beacon" },
277 { 10001, "vote-debug-old" },
278 { 10002, "vote-sdebug-old" },
279 { 10003, "vote-getsyncsite" },
280 { 10004, "vote-debug" },
281 { 10005, "vote-sdebug" },
282 { 20000, "disk-begin" },
283 { 20001, "disk-commit" },
284 { 20002, "disk-lock" },
285 { 20003, "disk-write" },
286 { 20004, "disk-getversion" },
287 { 20005, "disk-getfile" },
288 { 20006, "disk-sendfile" },
289 { 20007, "disk-abort" },
290 { 20008, "disk-releaselocks" },
291 { 20009, "disk-truncate" },
292 { 20010, "disk-probe" },
293 { 20011, "disk-writev" },
294 { 20012, "disk-interfaceaddr" },
295 { 20013, "disk-setversion" },
299 #define VOTE_LOW 10000
300 #define VOTE_HIGH 10005
301 #define DISK_LOW 20000
302 #define DISK_HIGH 20013
304 static struct tok cb_types
[] = {
311 static struct tok ubik_lock_types
[] = {
318 static char *voltype
[] = { "read-write", "read-only", "backup" };
320 static struct tok afs_fs_errors
[] = {
321 { 101, "salvage volume" },
322 { 102, "no such vnode" },
323 { 103, "no such volume" },
324 { 104, "volume exist" },
325 { 105, "no service" },
326 { 106, "volume offline" },
327 { 107, "voline online" },
329 { 109, "diskquota exceeded" },
330 { 110, "volume busy" },
331 { 111, "volume moved" },
332 { 112, "AFS IO error" },
333 { -100, "restarting fileserver" },
338 * Reasons for acknowledging a packet
341 static struct tok rx_ack_reasons
[] = {
342 { 1, "ack requested" },
343 { 2, "duplicate packet" },
344 { 3, "out of sequence" },
345 { 4, "exceeds window" },
346 { 5, "no buffer space" },
348 { 7, "ping response" },
354 * Cache entries we keep around so we can figure out the RX opcode
355 * numbers for replies. This allows us to make sense of RX reply packets.
358 struct rx_cache_entry
{
359 u_int32_t callnum
; /* Call number (net order) */
360 struct in_addr client
; /* client IP address (net order) */
361 struct in_addr server
; /* server IP address (net order) */
362 int dport
; /* server port (host order) */
363 u_short serviceId
; /* Service identifier (net order) */
364 u_int32_t opcode
; /* RX opcode (host order) */
367 #define RX_CACHE_SIZE 64
369 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
371 static int rx_cache_next
= 0;
372 static int rx_cache_hint
= 0;
373 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
374 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
377 static void fs_print(const u_char
*, int);
378 static void fs_reply_print(const u_char
*, int, int32_t);
379 static void acl_print(u_char
*, u_char
*);
380 static void cb_print(const u_char
*, int);
381 static void cb_reply_print(const u_char
*, int, int32_t);
382 static void prot_print(const u_char
*, int);
383 static void prot_reply_print(const u_char
*, int, int32_t);
384 static void vldb_print(const u_char
*, int);
385 static void vldb_reply_print(const u_char
*, int, int32_t);
386 static void kauth_print(const u_char
*, int);
387 static void kauth_reply_print(const u_char
*, int, int32_t);
388 static void vol_print(const u_char
*, int);
389 static void vol_reply_print(const u_char
*, int, int32_t);
390 static void bos_print(const u_char
*, int);
391 static void bos_reply_print(const u_char
*, int, int32_t);
392 static void ubik_print(const u_char
*, int);
393 static void ubik_reply_print(const u_char
*, int, int32_t);
395 static void rx_ack_print(const u_char
*, int);
397 static int is_ubik(u_int32_t
);
400 * Handle the rx-level packet. See if we know what port it's going to so
401 * we can peek at the afs call inside
405 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
408 register struct rx_header
*rxh
;
412 if (snapend
- bp
< sizeof (struct rx_header
)) {
413 printf(" [|rx] (%d)", length
);
417 rxh
= (struct rx_header
*) bp
;
419 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
425 printf(" cid %08x call# %d",
426 (int) EXTRACT_32BITS(&rxh
->cid
),
427 (int) EXTRACT_32BITS(&rxh
->callNumber
));
429 printf(" seq %d ser %d",
430 (int) EXTRACT_32BITS(&rxh
->seq
),
431 (int) EXTRACT_32BITS(&rxh
->serial
));
434 printf(" secindex %d serviceid %hu",
435 (int) rxh
->securityIndex
,
436 EXTRACT_16BITS(&rxh
->serviceId
));
439 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
440 if (rxh
->flags
& rx_flags
[i
].v
) {
447 printf("<%s>", rx_flags
[i
].s
);
453 * Try to handle AFS calls that we know about. Check the destination
454 * port and make sure it's a data packet. Also, make sure the
455 * seq number is 1 (because otherwise it's a continuation packet,
456 * and we can't interpret that). Also, seems that reply packets
457 * do not have the client-init flag set, so we check for that
461 if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
462 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
463 rxh
->flags
& RX_CLIENT_INITIATED
) {
466 * Insert this call into the call cache table, so we
467 * have a chance to print out replies
470 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
473 case FS_RX_PORT
: /* AFS file service */
474 fs_print(bp
, length
);
476 case CB_RX_PORT
: /* AFS callback service */
477 cb_print(bp
, length
);
479 case PROT_RX_PORT
: /* AFS protection service */
480 prot_print(bp
, length
);
482 case VLDB_RX_PORT
: /* AFS VLDB service */
483 vldb_print(bp
, length
);
485 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
486 kauth_print(bp
, length
);
488 case VOL_RX_PORT
: /* AFS Volume service */
489 vol_print(bp
, length
);
491 case BOS_RX_PORT
: /* AFS BOS service */
492 bos_print(bp
, length
);
499 * If it's a reply (client-init is _not_ set, but seq is one)
500 * then look it up in the cache. If we find it, call the reply
501 * printing functions Note that we handle abort packets here,
502 * because printing out the return code can be useful at times.
505 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
506 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
507 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
508 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
509 rx_cache_find(rxh
, (const struct ip
*) bp2
,
513 case FS_RX_PORT
: /* AFS file service */
514 fs_reply_print(bp
, length
, opcode
);
516 case CB_RX_PORT
: /* AFS callback service */
517 cb_reply_print(bp
, length
, opcode
);
519 case PROT_RX_PORT
: /* AFS PT service */
520 prot_reply_print(bp
, length
, opcode
);
522 case VLDB_RX_PORT
: /* AFS VLDB service */
523 vldb_reply_print(bp
, length
, opcode
);
525 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
526 kauth_reply_print(bp
, length
, opcode
);
528 case VOL_RX_PORT
: /* AFS Volume service */
529 vol_reply_print(bp
, length
, opcode
);
531 case BOS_RX_PORT
: /* AFS BOS service */
532 bos_reply_print(bp
, length
, opcode
);
539 * If it's an RX ack packet, then use the appropriate ack decoding
540 * function (there isn't any service-specific information in the
541 * ack packet, so we can use one for all AFS services)
544 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
545 rx_ack_print(bp
, length
);
548 printf(" (%d)", length
);
552 * Insert an entry into the cache. Taken from print-nfs.c
556 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
559 struct rx_cache_entry
*rxent
;
560 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
562 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
565 rxent
= &rx_cache
[rx_cache_next
];
567 if (++rx_cache_next
>= RX_CACHE_SIZE
)
570 rxent
->callnum
= rxh
->callNumber
;
571 rxent
->client
= ip
->ip_src
;
572 rxent
->server
= ip
->ip_dst
;
573 rxent
->dport
= dport
;
574 rxent
->serviceId
= rxh
->serviceId
;
575 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
579 * Lookup an entry in the cache. Also taken from print-nfs.c
581 * Note that because this is a reply, we're looking at the _source_
586 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
590 struct rx_cache_entry
*rxent
;
591 u_int32_t clip
= ip
->ip_dst
.s_addr
;
592 u_int32_t sip
= ip
->ip_src
.s_addr
;
594 /* Start the search where we last left off */
598 rxent
= &rx_cache
[i
];
599 if (rxent
->callnum
== rxh
->callNumber
&&
600 rxent
->client
.s_addr
== clip
&&
601 rxent
->server
.s_addr
== sip
&&
602 rxent
->serviceId
== rxh
->serviceId
&&
603 rxent
->dport
== sport
) {
605 /* We got a match! */
608 *opcode
= rxent
->opcode
;
611 if (++i
> RX_CACHE_SIZE
)
613 } while (i
!= rx_cache_hint
);
615 /* Our search failed */
620 * These extrememly grody macros handle the printing of various AFS stuff.
623 #define TRUNC(n) if (snapend - bp + 1 <= n) goto trunc;
624 #define FIDOUT() { unsigned long n1, n2, n3; \
625 TRUNC(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) { int i; \
636 TRUNC(sizeof(int32_t)); \
637 i = (int) EXTRACT_32BITS(bp); \
638 bp += sizeof(int32_t); \
640 strncpy(s, (char *) bp, min(MAX, i)); \
642 printf(" \"%s\"", s); \
643 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
646 #define INTOUT() { int i; \
647 TRUNC(sizeof(int32_t)); \
648 i = (int) EXTRACT_32BITS(bp); \
649 bp += sizeof(int32_t); \
653 #define UINTOUT() { unsigned long i; \
654 TRUNC(sizeof(int32_t)); \
655 i = EXTRACT_32BITS(bp); \
656 bp += sizeof(int32_t); \
660 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
661 TRUNC(sizeof(int32_t)); \
662 t = (time_t) EXTRACT_32BITS(bp); \
663 bp += sizeof(int32_t); \
664 tm = localtime(&t); \
665 strftime(str, 256, "%Y/%m/%d %T", tm); \
666 printf(" %s", str); \
669 #define STOREATTROUT() { unsigned long mask, i; \
670 TRUNC((sizeof(int32_t)*6)); \
671 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
672 if (mask) printf (" StoreStatus"); \
673 if (mask & 1) { printf(" date"); DATEOUT(); } \
674 else bp += sizeof(int32_t); \
675 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
676 if (mask & 2) printf(" owner %lu", i); \
677 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
678 if (mask & 4) printf(" group %lu", i); \
679 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
680 if (mask & 8) printf(" mode %lo", i & 07777); \
681 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
682 if (mask & 16) printf(" segsize %lu", i); \
683 /* undocumented in 3.3 docu */ \
684 if (mask & 1024) printf(" fsync"); \
687 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
688 TRUNC(sizeof(int32_t) * 2); \
689 epoch = EXTRACT_32BITS(bp); \
690 bp += sizeof(int32_t); \
691 counter = EXTRACT_32BITS(bp); \
692 bp += sizeof(int32_t); \
693 printf(" %d.%d", epoch, counter); \
696 #define AFSUUIDOUT() {u_int32_t temp; int i; \
697 TRUNC(11*sizeof(u_int32_t)); \
698 temp = EXTRACT_32BITS(bp); \
699 bp += sizeof(u_int32_t); \
700 printf(" %08x", temp); \
701 temp = EXTRACT_32BITS(bp); \
702 bp += sizeof(u_int32_t); \
703 printf("%04x", temp); \
704 temp = EXTRACT_32BITS(bp); \
705 bp += sizeof(u_int32_t); \
706 printf("%04x", temp); \
707 for (i = 0; i < 8; i++) { \
708 temp = EXTRACT_32BITS(bp); \
709 bp += sizeof(u_int32_t); \
710 printf("%02x", (unsigned char) temp); \
715 * This is the sickest one of all
718 #define VECOUT(MAX) { char *sp; \
720 TRUNC(MAX * sizeof(int32_t)); \
722 for (k = 0; k < MAX; k++) { \
723 *sp++ = (char) EXTRACT_32BITS(bp); \
724 bp += sizeof(int32_t); \
727 printf(" \"%s\"", s); \
731 * Handle calls to the AFS file service (fs)
735 fs_print(register const u_char
*bp
, int length
)
741 if (length
<= sizeof(struct rx_header
))
744 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
749 * Print out the afs call we're invoking. The table used here was
750 * gleaned from fsint/afsint.xg
753 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
755 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
758 * Print out arguments to some of the AFS calls. This stuff is
762 bp
+= sizeof(struct rx_header
) + 4;
765 * Sigh. This is gross. Ritchie forgive me.
769 case 130: /* Fetch data */
776 case 131: /* Fetch ACL */
777 case 132: /* Fetch Status */
778 case 143: /* Old set lock */
779 case 144: /* Old extend lock */
780 case 145: /* Old release lock */
781 case 156: /* Set lock */
782 case 157: /* Extend lock */
783 case 158: /* Release lock */
786 case 135: /* Store status */
790 case 133: /* Store data */
800 case 134: /* Store ACL */
802 char a
[AFSOPAQUEMAX
];
805 i
= EXTRACT_32BITS(bp
);
806 bp
+= sizeof(int32_t);
808 strncpy(a
, (char *) bp
, min(AFSOPAQUEMAX
, i
));
810 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
813 case 137: /* Create file */
814 case 141: /* MakeDir */
819 case 136: /* Remove file */
820 case 142: /* Remove directory */
824 case 138: /* Rename file */
832 case 139: /* Symlink */
844 case 148: /* Get volume info */
847 case 149: /* Get volume stats */
848 case 150: /* Set volume stats */
852 case 154: /* New get volume info */
856 case 155: /* Bulk stat */
860 j
= EXTRACT_32BITS(bp
);
861 bp
+= sizeof(int32_t);
863 for (i
= 0; i
< j
; i
++) {
882 * Handle replies to the AFS file service
886 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
890 struct rx_header
*rxh
;
892 if (length
<= sizeof(struct rx_header
))
895 rxh
= (struct rx_header
*) bp
;
898 * Print out the afs call we're invoking. The table used here was
899 * gleaned from fsint/afsint.xg
902 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
904 bp
+= sizeof(struct rx_header
);
907 * If it was a data packet, interpret the response
910 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
912 case 131: /* Fetch ACL */
914 char a
[AFSOPAQUEMAX
];
916 i
= EXTRACT_32BITS(bp
);
917 bp
+= sizeof(int32_t);
919 strncpy(a
, (char *) bp
, min(AFSOPAQUEMAX
, i
));
921 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
924 case 137: /* Create file */
925 case 141: /* MakeDir */
929 case 151: /* Get root volume */
930 printf(" root volume");
933 case 153: /* Get time */
939 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
943 * Otherwise, just print out the return code
945 TRUNC(sizeof(int32_t));
946 i
= (int) EXTRACT_32BITS(bp
);
947 bp
+= sizeof(int32_t);
949 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
951 printf(" strange fs reply of type %d", rxh
->type
);
961 * Print out an AFS ACL string. An AFS ACL is a string that has the
964 * <positive> <negative>
968 * "positive" and "negative" are integers which contain the number of
969 * positive and negative ACL's in the string. The uid/aclbits pair are
970 * ASCII strings containing the UID/PTS record and and a ascii number
971 * representing a logical OR of all the ACL permission bits
975 acl_print(u_char
*s
, u_char
*end
)
981 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
990 * This wacky order preserves the order used by the "fs" command
993 #define ACLOUT(acl) \
994 if (acl & PRSFS_READ) \
996 if (acl & PRSFS_LOOKUP) \
998 if (acl & PRSFS_INSERT) \
1000 if (acl & PRSFS_DELETE) \
1002 if (acl & PRSFS_WRITE) \
1004 if (acl & PRSFS_LOCK) \
1006 if (acl & PRSFS_ADMINISTER) \
1009 for (i
= 0; i
< pos
; i
++) {
1010 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1013 printf(" +{%s ", user
);
1020 for (i
= 0; i
< neg
; i
++) {
1021 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1024 printf(" -{%s ", user
);
1035 * Handle calls to the AFS callback service
1039 cb_print(register const u_char
*bp
, int length
)
1044 if (length
<= sizeof(struct rx_header
))
1047 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1052 * Print out the afs call we're invoking. The table used here was
1053 * gleaned from fsint/afscbint.xg
1056 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1058 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1060 bp
+= sizeof(struct rx_header
) + 4;
1063 * Print out the afs call we're invoking. The table used here was
1064 * gleaned from fsint/afscbint.xg
1068 case 204: /* Callback */
1072 j
= EXTRACT_32BITS(bp
);
1073 bp
+= sizeof(int32_t);
1075 for (i
= 0; i
< j
; i
++) {
1084 j
= EXTRACT_32BITS(bp
);
1085 bp
+= sizeof(int32_t);
1090 for (i
= 0; i
< j
; i
++) {
1096 t
= EXTRACT_32BITS(bp
);
1097 bp
+= sizeof(int32_t);
1098 tok2str(cb_types
, "type %d", t
);
1117 * Handle replies to the AFS Callback Service
1121 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1123 struct rx_header
*rxh
;
1125 if (length
<= sizeof(struct rx_header
))
1128 rxh
= (struct rx_header
*) bp
;
1131 * Print out the afs call we're invoking. The table used here was
1132 * gleaned from fsint/afscbint.xg
1135 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1137 bp
+= sizeof(struct rx_header
);
1140 * If it was a data packet, interpret the response.
1143 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1145 case 213: /* InitCallBackState3 */
1153 * Otherwise, just print out the return code
1166 * Handle calls to the AFS protection database server
1170 prot_print(register const u_char
*bp
, int length
)
1176 if (length
<= sizeof(struct rx_header
))
1179 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1184 * Print out the afs call we're invoking. The table used here was
1185 * gleaned from ptserver/ptint.xg
1188 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1192 if (is_ubik(pt_op
)) {
1193 ubik_print(bp
, length
);
1197 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1200 * Decode some of the arguments to the PT calls
1203 bp
+= sizeof(struct rx_header
) + 4;
1206 case 500: /* I New User */
1213 case 501: /* Where is it */
1214 case 506: /* Delete */
1215 case 508: /* Get CPS */
1216 case 512: /* List entry */
1217 case 514: /* List elements */
1218 case 517: /* List owned */
1219 case 518: /* Get CPS2 */
1220 case 519: /* Get host CPS */
1224 case 502: /* Dump entry */
1228 case 503: /* Add to group */
1229 case 507: /* Remove from group */
1230 case 515: /* Is a member of? */
1236 case 504: /* Name to ID */
1240 j
= EXTRACT_32BITS(bp
);
1241 bp
+= sizeof(int32_t);
1244 * Who designed this chicken-shit protocol?
1246 * Each character is stored as a 32-bit
1250 for (i
= 0; i
< j
; i
++) {
1257 case 505: /* Id to name */
1262 i
= EXTRACT_32BITS(bp
);
1263 bp
+= sizeof(int32_t);
1264 for (j
= 0; j
< i
; j
++)
1270 case 509: /* New entry */
1277 case 511: /* Set max */
1283 case 513: /* Change entry */
1292 case 520: /* Update entry */
1309 * Handle replies to the AFS protection service
1313 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1315 struct rx_header
*rxh
;
1319 if (length
< sizeof(struct rx_header
))
1322 rxh
= (struct rx_header
*) bp
;
1325 * Print out the afs call we're invoking. The table used here was
1326 * gleaned from ptserver/ptint.xg. Check to see if it's a
1327 * Ubik call, however.
1332 if (is_ubik(opcode
)) {
1333 ubik_reply_print(bp
, length
, opcode
);
1337 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1339 bp
+= sizeof(struct rx_header
);
1342 * If it was a data packet, interpret the response
1345 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1347 case 504: /* Name to ID */
1352 i
= EXTRACT_32BITS(bp
);
1353 bp
+= sizeof(int32_t);
1354 for (j
= 0; j
< i
; j
++)
1360 case 505: /* ID to name */
1364 j
= EXTRACT_32BITS(bp
);
1365 bp
+= sizeof(int32_t);
1368 * Who designed this chicken-shit protocol?
1370 * Each character is stored as a 32-bit
1374 for (i
= 0; i
< j
; i
++) {
1381 case 508: /* Get CPS */
1382 case 514: /* List elements */
1383 case 517: /* List owned */
1384 case 518: /* Get CPS2 */
1385 case 519: /* Get host CPS */
1389 j
= EXTRACT_32BITS(bp
);
1390 bp
+= sizeof(int32_t);
1391 for (i
= 0; i
< j
; i
++) {
1398 case 510: /* List max */
1409 * Otherwise, just print out the return code
1422 * Handle calls to the AFS volume location database service
1426 vldb_print(register const u_char
*bp
, int length
)
1432 if (length
<= sizeof(struct rx_header
))
1435 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1440 * Print out the afs call we're invoking. The table used here was
1441 * gleaned from vlserver/vldbint.xg
1444 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1448 if (is_ubik(vldb_op
)) {
1449 ubik_print(bp
, length
);
1452 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1455 * Decode some of the arguments to the VLDB calls
1458 bp
+= sizeof(struct rx_header
) + 4;
1461 case 501: /* Create new volume */
1462 case 517: /* Create entry N */
1465 case 502: /* Delete entry */
1466 case 503: /* Get entry by ID */
1467 case 507: /* Update entry */
1468 case 508: /* Set lock */
1469 case 509: /* Release lock */
1470 case 518: /* Get entry by ID N */
1473 TRUNC(sizeof(int32_t));
1474 i
= EXTRACT_32BITS(bp
);
1475 bp
+= sizeof(int32_t);
1477 printf(" type %s", voltype
[i
]);
1479 case 504: /* Get entry by name */
1480 case 519: /* Get entry by name N */
1481 case 524: /* Update entry by name */
1482 case 527: /* Get entry by name U */
1485 case 505: /* Get new vol id */
1489 case 506: /* Replace entry */
1490 case 520: /* Replace entry N */
1493 TRUNC(sizeof(int32_t));
1494 i
= EXTRACT_32BITS(bp
);
1495 bp
+= sizeof(int32_t);
1497 printf(" type %s", voltype
[i
]);
1500 case 510: /* List entry */
1501 case 521: /* List entry N */
1516 * Handle replies to the AFS volume location database service
1520 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1522 struct rx_header
*rxh
;
1526 if (length
< sizeof(struct rx_header
))
1529 rxh
= (struct rx_header
*) bp
;
1532 * Print out the afs call we're invoking. The table used here was
1533 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1534 * Ubik call, however.
1539 if (is_ubik(opcode
)) {
1540 ubik_reply_print(bp
, length
, opcode
);
1544 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1546 bp
+= sizeof(struct rx_header
);
1549 * If it was a data packet, interpret the response
1552 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1554 case 510: /* List entry */
1557 printf(" nextindex");
1559 case 503: /* Get entry by id */
1560 case 504: /* Get entry by name */
1561 { unsigned long nservers
, j
;
1563 TRUNC(sizeof(int32_t));
1564 bp
+= sizeof(int32_t);
1565 printf(" numservers");
1566 TRUNC(sizeof(int32_t));
1567 nservers
= EXTRACT_32BITS(bp
);
1568 bp
+= sizeof(int32_t);
1569 printf(" %lu", nservers
);
1571 for (i
= 0; i
< 8; i
++) {
1572 TRUNC(sizeof(int32_t));
1575 inet_ntoa(*((struct in_addr
*) bp
)));
1576 bp
+= sizeof(int32_t);
1578 printf(" partitions");
1579 for (i
= 0; i
< 8; i
++) {
1580 TRUNC(sizeof(int32_t));
1581 j
= EXTRACT_32BITS(bp
);
1582 if (i
< nservers
&& j
<= 26)
1583 printf(" %c", 'a' + (int)j
);
1584 else if (i
< nservers
)
1586 bp
+= sizeof(int32_t);
1588 TRUNC(8 * sizeof(int32_t));
1589 bp
+= 8 * sizeof(int32_t);
1598 case 505: /* Get new volume ID */
1602 case 521: /* List entry */
1603 case 529: /* List entry U */
1606 printf(" nextindex");
1608 case 518: /* Get entry by ID N */
1609 case 519: /* Get entry by name N */
1610 { unsigned long nservers
, j
;
1612 printf(" numservers");
1613 TRUNC(sizeof(int32_t));
1614 nservers
= EXTRACT_32BITS(bp
);
1615 bp
+= sizeof(int32_t);
1616 printf(" %lu", nservers
);
1618 for (i
= 0; i
< 13; i
++) {
1619 TRUNC(sizeof(int32_t));
1622 inet_ntoa(*((struct in_addr
*) bp
)));
1623 bp
+= sizeof(int32_t);
1625 printf(" partitions");
1626 for (i
= 0; i
< 13; i
++) {
1627 TRUNC(sizeof(int32_t));
1628 j
= EXTRACT_32BITS(bp
);
1629 if (i
< nservers
&& j
<= 26)
1630 printf(" %c", 'a' + (int)j
);
1631 else if (i
< nservers
)
1633 bp
+= sizeof(int32_t);
1635 TRUNC(13 * sizeof(int32_t));
1636 bp
+= 13 * sizeof(int32_t);
1645 case 526: /* Get entry by ID U */
1646 case 527: /* Get entry by name U */
1647 { unsigned long nservers
, j
;
1649 printf(" numservers");
1650 TRUNC(sizeof(int32_t));
1651 nservers
= EXTRACT_32BITS(bp
);
1652 bp
+= sizeof(int32_t);
1653 printf(" %lu", nservers
);
1655 for (i
= 0; i
< 13; i
++) {
1666 printf(" partitions");
1667 for (i
= 0; i
< 13; i
++) {
1668 TRUNC(sizeof(int32_t));
1669 j
= EXTRACT_32BITS(bp
);
1670 if (i
< nservers
&& j
<= 26)
1671 printf(" %c", 'a' + (int)j
);
1672 else if (i
< nservers
)
1674 bp
+= sizeof(int32_t);
1676 TRUNC(13 * sizeof(int32_t));
1677 bp
+= 13 * sizeof(int32_t);
1691 * Otherwise, just print out the return code
1704 * Handle calls to the AFS Kerberos Authentication service
1708 kauth_print(register const u_char
*bp
, int length
)
1713 if (length
<= sizeof(struct rx_header
))
1716 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1721 * Print out the afs call we're invoking. The table used here was
1722 * gleaned from kauth/kauth.rg
1725 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1729 if (is_ubik(kauth_op
)) {
1730 ubik_print(bp
, length
);
1735 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1738 * Decode some of the arguments to the KA calls
1741 bp
+= sizeof(struct rx_header
) + 4;
1744 case 1: /* Authenticate old */;
1745 case 21: /* Authenticate */
1746 case 22: /* Authenticate-V2 */
1747 case 2: /* Change PW */
1748 case 5: /* Set fields */
1749 case 6: /* Create user */
1750 case 7: /* Delete user */
1751 case 8: /* Get entry */
1752 case 14: /* Unlock */
1753 case 15: /* Lock status */
1754 printf(" principal");
1758 case 3: /* GetTicket-old */
1759 case 23: /* GetTicket */
1766 TRUNC(sizeof(int32_t));
1767 i
= (int) EXTRACT_32BITS(bp
);
1768 bp
+= sizeof(int32_t);
1771 printf(" principal");
1776 case 4: /* Set Password */
1777 printf(" principal");
1783 case 12: /* Get password */
1794 printf(" [|kauth]");
1798 * Handle replies to the AFS Kerberos Authentication Service
1802 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1804 struct rx_header
*rxh
;
1806 if (length
<= sizeof(struct rx_header
))
1809 rxh
= (struct rx_header
*) bp
;
1812 * Print out the afs call we're invoking. The table used here was
1813 * gleaned from kauth/kauth.rg
1818 if (is_ubik(opcode
)) {
1819 ubik_reply_print(bp
, length
, opcode
);
1823 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1825 bp
+= sizeof(struct rx_header
);
1828 * If it was a data packet, interpret the response.
1831 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1832 /* Well, no, not really. Leave this for later */
1836 * Otherwise, just print out the return code
1845 printf(" [|kauth]");
1849 * Handle calls to the AFS Volume location service
1853 vol_print(register const u_char
*bp
, int length
)
1857 if (length
<= sizeof(struct rx_header
))
1860 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1865 * Print out the afs call we're invoking. The table used here was
1866 * gleaned from volser/volint.xg
1869 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1871 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1874 * Normally there would be a switch statement here to decode the
1875 * arguments to the AFS call, but since I don't have access to
1876 * an AFS server (yet) and I'm not an AFS admin, I can't
1877 * test any of these calls. Leave this blank for now.
1887 * Handle replies to the AFS Volume Service
1891 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1893 struct rx_header
*rxh
;
1895 if (length
<= sizeof(struct rx_header
))
1898 rxh
= (struct rx_header
*) bp
;
1901 * Print out the afs call we're invoking. The table used here was
1902 * gleaned from volser/volint.xg
1905 printf(" vol reply %s", tok2str(vol_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
1931 * Handle calls to the AFS BOS service
1935 bos_print(register const u_char
*bp
, int length
)
1940 if (length
<= sizeof(struct rx_header
))
1943 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1948 * Print out the afs call we're invoking. The table used here was
1949 * gleaned from bozo/bosint.xg
1952 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1954 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
1957 * Decode some of the arguments to the BOS calls
1960 bp
+= sizeof(struct rx_header
) + 4;
1963 case 80: /* Create B node */
1966 printf(" instance");
1969 case 81: /* Delete B node */
1970 case 83: /* Get status */
1971 case 85: /* Get instance info */
1972 case 87: /* Add super user */
1973 case 88: /* Delete super user */
1974 case 93: /* Set cell name */
1975 case 96: /* Add cell host */
1976 case 97: /* Delete cell host */
1977 case 104: /* Restart */
1978 case 106: /* Uninstall */
1979 case 108: /* Exec */
1980 case 112: /* Getlog */
1981 case 114: /* Get instance strings */
1984 case 82: /* Set status */
1985 case 98: /* Set T status */
1990 case 86: /* Get instance parm */
1995 case 84: /* Enumerate instance */
1996 case 89: /* List super users */
1997 case 90: /* List keys */
1998 case 91: /* Add key */
1999 case 92: /* Delete key */
2000 case 95: /* Get cell host */
2003 case 105: /* Install */
2023 * Handle replies to the AFS BOS Service
2027 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2029 struct rx_header
*rxh
;
2031 if (length
<= sizeof(struct rx_header
))
2034 rxh
= (struct rx_header
*) bp
;
2037 * Print out the afs call we're invoking. The table used here was
2038 * gleaned from volser/volint.xg
2041 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2043 bp
+= sizeof(struct rx_header
);
2046 * If it was a data packet, interpret the response.
2049 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2050 /* Well, no, not really. Leave this for later */
2054 * Otherwise, just print out the return code
2067 * Check to see if this is a Ubik opcode.
2071 is_ubik(u_int32_t opcode
)
2073 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2074 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2081 * Handle Ubik opcodes to any one of the replicated database services
2085 ubik_print(register const u_char
*bp
, int length
)
2091 * Print out the afs call we're invoking. The table used here was
2092 * gleaned from ubik/ubik_int.xg
2095 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2097 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2100 * Decode some of the arguments to the Ubik calls
2103 bp
+= sizeof(struct rx_header
) + 4;
2106 case 10000: /* Beacon */
2108 temp
= EXTRACT_32BITS(bp
);
2109 bp
+= sizeof(int32_t);
2110 printf(" syncsite %s", temp
? "yes" : "no");
2111 printf(" votestart");
2113 printf(" dbversion");
2118 case 10003: /* Get sync site */
2122 case 20000: /* Begin */
2123 case 20001: /* Commit */
2124 case 20007: /* Abort */
2125 case 20008: /* Release locks */
2126 case 20010: /* Writev */
2130 case 20002: /* Lock */
2139 temp
= EXTRACT_32BITS(bp
);
2140 bp
+= sizeof(int32_t);
2141 tok2str(ubik_lock_types
, "type %d", temp
);
2143 case 20003: /* Write */
2151 case 20005: /* Get file */
2155 case 20006: /* Send file */
2160 printf(" dbversion");
2163 case 20009: /* Truncate */
2171 case 20012: /* Set version */
2174 printf(" oldversion");
2176 printf(" newversion");
2190 * Handle Ubik replies to any one of the replicated database services
2194 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2196 struct rx_header
*rxh
;
2198 if (length
< sizeof(struct rx_header
))
2201 rxh
= (struct rx_header
*) bp
;
2204 * Print out the ubik call we're invoking. This table was gleaned
2205 * from ubik/ubik_int.xg
2208 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2210 bp
+= sizeof(struct rx_header
);
2213 * If it was a data packet, print out the arguments to the Ubik calls
2216 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2218 case 10000: /* Beacon */
2221 case 20004: /* Get version */
2222 printf(" dbversion");
2230 * Otherwise, print out "yes" it it was a beacon packet (because
2231 * that's how yes votes are returned, go figure), otherwise
2232 * just print out the error code.
2237 case 10000: /* Beacon */
2238 printf(" vote yes until");
2253 * Handle RX ACK packets.
2257 rx_ack_print(register const u_char
*bp
, int length
)
2259 struct rx_ackPacket
*rxa
;
2262 if (length
< sizeof(struct rx_header
))
2265 bp
+= sizeof(struct rx_header
);
2268 * This may seem a little odd .... the rx_ackPacket structure
2269 * contains an array of individual packet acknowledgements
2270 * (used for selective ack/nack), but since it's variable in size,
2271 * we don't want to truncate based on the size of the whole
2272 * rx_ackPacket structure.
2275 TRUNC(sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2277 rxa
= (struct rx_ackPacket
*) bp
;
2278 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2281 * Print out a few useful things from the ack packet structure
2285 printf(" bufspace %d maxskew %d",
2286 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2287 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2289 printf(" first %d serial %d reason %s",
2290 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2291 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2294 * Okay, now we print out the ack array. The way _this_ works
2295 * is that we start at "first", and step through the ack array.
2296 * If we have a contiguous range of acks/nacks, try to
2297 * collapse them into a range.
2299 * If you're really clever, you might have noticed that this
2300 * doesn't seem quite correct. Specifically, due to structure
2301 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2302 * yield the start of the ack array (because RX_MAXACKS is 255
2303 * and the structure will likely get padded to a 2 or 4 byte
2304 * boundary). However, this is the way it's implemented inside
2305 * of AFS - the start of the extra fields are at
2306 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2307 * the exact start of the ack array. Sigh. That's why we aren't
2308 * using bp, but instead use rxa->acks[]. But nAcks gets added
2309 * to bp after this, so bp ends up at the right spot. Go figure.
2312 if (rxa
->nAcks
!= 0) {
2317 * Sigh, this is gross, but it seems to work to collapse
2321 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2322 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2325 * I figured this deserved _some_ explanation.
2326 * First, print "acked" and the packet seq
2327 * number if this is the first time we've
2328 * seen an acked packet.
2333 rxa
->firstPacket
+ i
);
2338 * Otherwise, if the there is a skip in
2339 * the range (such as an nacked packet in
2340 * the middle of some acked packets),
2341 * then print the current packet number
2342 * seperated from the last number by
2346 else if (last
!= i
- 1) {
2347 printf(",%d", rxa
->firstPacket
+ i
);
2352 * We always set last to the value of
2353 * the last ack we saw. Conversely, start
2354 * is set to the value of the first ack
2355 * we saw in a range.
2361 * Okay, this bit a code gets executed when
2362 * we hit a nack ... in _this_ case we
2363 * want to print out the range of packets
2364 * that were acked, so we need to print
2365 * the _previous_ packet number seperated
2366 * from the first by a dash (-). Since we
2367 * already printed the first packet above,
2368 * just print the final packet. Don't
2369 * do this if there will be a single-length
2372 } else if (last
== i
- 1 && start
!= last
)
2373 printf("-%d", rxa
->firstPacket
+ i
- 1);
2376 * So, what's going on here? We ran off the end of the
2377 * ack list, and if we got a range we need to finish it up.
2378 * So we need to determine if the last packet in the list
2379 * was an ack (if so, then last will be set to it) and
2380 * we need to see if the last range didn't start with the
2381 * last packet (because if it _did_, then that would mean
2382 * that the packet number has already been printed and
2383 * we don't need to print it again).
2386 if (last
== i
- 1 && start
!= last
)
2387 printf("-%d", rxa
->firstPacket
+ i
- 1);
2390 * Same as above, just without comments
2393 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2394 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2396 printf(" nacked %d",
2397 rxa
->firstPacket
+ i
);
2399 } else if (last
!= i
- 1) {
2400 printf(",%d", rxa
->firstPacket
+ i
);
2404 } else if (last
== i
- 1 && start
!= last
)
2405 printf("-%d", rxa
->firstPacket
+ i
- 1);
2407 if (last
== i
- 1 && start
!= last
)
2408 printf("-%d", rxa
->firstPacket
+ i
- 1);
2415 * These are optional fields; depending on your version of AFS,
2416 * you may or may not see them
2419 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2435 printf(" maxpackets");