]>
The Tcpdump Group git mirrors - tcpdump/blob - print-rx.c
2 * Copyright: (c) 2000 United States Government as represented by the
3 * Secretary of the Navy. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
15 * 3. The names of the authors may not be used to endorse or promote
16 * products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 * This code unmangles RX packets. RX is the mutant form of RPC that AFS
25 * uses to communicate between clients and servers.
27 * In this code, I mainly concern myself with decoding the AFS calls, not
28 * with the guts of RX, per se.
30 * Bah. If I never look at rx_packet.h again, it will be too soon.
32 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
36 static const char rcsid
[] =
37 "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.34 2002-09-05 21:25:46 guy Exp $";
47 #include <tcpdump-stdinc.h>
49 #include "interface.h"
50 #include "addrtoname.h"
57 static struct tok rx_types
[] = {
58 { RX_PACKET_TYPE_DATA
, "data" },
59 { RX_PACKET_TYPE_ACK
, "ack" },
60 { RX_PACKET_TYPE_BUSY
, "busy" },
61 { RX_PACKET_TYPE_ABORT
, "abort" },
62 { RX_PACKET_TYPE_ACKALL
, "ackall" },
63 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
64 { RX_PACKET_TYPE_RESPONSE
, "response" },
65 { RX_PACKET_TYPE_DEBUG
, "debug" },
66 { RX_PACKET_TYPE_PARAMS
, "params" },
67 { RX_PACKET_TYPE_VERSION
, "version" },
71 static struct double_tok
{
72 int flag
; /* Rx flag */
73 int packetType
; /* Packet type */
74 const char *s
; /* Flag string */
76 { RX_CLIENT_INITIATED
, 0, "client-init" },
77 { RX_REQUEST_ACK
, 0, "req-ack" },
78 { RX_LAST_PACKET
, 0, "last-pckt" },
79 { RX_MORE_PACKETS
, 0, "more-pckts" },
80 { RX_FREE_PACKET
, 0, "free-pckt" },
81 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
82 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
85 static struct tok fs_req
[] = {
86 { 130, "fetch-data" },
88 { 132, "fetch-status" },
89 { 133, "store-data" },
91 { 135, "store-status" },
92 { 136, "remove-file" },
93 { 137, "create-file" },
99 { 143, "oldsetlock" },
100 { 144, "oldextlock" },
101 { 145, "oldrellock" },
102 { 146, "get-stats" },
104 { 148, "get-vlinfo" },
105 { 149, "get-vlstats" },
106 { 150, "set-vlstats" },
107 { 151, "get-rootvl" },
108 { 152, "check-token" },
110 { 154, "nget-vlinfo" },
111 { 155, "bulk-stat" },
115 { 159, "xstat-ver" },
116 { 160, "get-xstat" },
117 { 161, "dfs-lookup" },
118 { 162, "dfs-flushcps" },
119 { 163, "dfs-symlink" },
120 { 220, "residency" },
124 static struct tok cb_req
[] = {
133 { 212, "whoareyou" },
135 { 214, "probeuuid" },
136 { 215, "getsrvprefs" },
137 { 216, "getcellservdb" },
138 { 217, "getlocalcell" },
139 { 218, "getcacheconf" },
143 static struct tok pt_req
[] = {
145 { 501, "where-is-it" },
146 { 502, "dump-entry" },
147 { 503, "add-to-group" },
148 { 504, "name-to-id" },
149 { 505, "id-to-name" },
151 { 507, "remove-from-group" },
153 { 509, "new-entry" },
156 { 512, "list-entry" },
157 { 513, "change-entry" },
158 { 514, "list-elements" },
159 { 515, "same-mbr-of" },
160 { 516, "set-fld-sentry" },
161 { 517, "list-owned" },
163 { 519, "get-host-cps" },
164 { 520, "update-entry" },
165 { 521, "list-entries" },
169 static struct tok vldb_req
[] = {
170 { 501, "create-entry" },
171 { 502, "delete-entry" },
172 { 503, "get-entry-by-id" },
173 { 504, "get-entry-by-name" },
174 { 505, "get-new-volume-id" },
175 { 506, "replace-entry" },
176 { 507, "update-entry" },
178 { 509, "releaselock" },
179 { 510, "list-entry" },
180 { 511, "list-attrib" },
181 { 512, "linked-list" },
182 { 513, "get-stats" },
184 { 515, "get-addrs" },
185 { 516, "change-addr" },
186 { 517, "create-entry-n" },
187 { 518, "get-entry-by-id-n" },
188 { 519, "get-entry-by-name-n" },
189 { 520, "replace-entry-n" },
190 { 521, "list-entry-n" },
191 { 522, "list-attrib-n" },
192 { 523, "linked-list-n" },
193 { 524, "update-entry-by-name" },
194 { 525, "create-entry-u" },
195 { 526, "get-entry-by-id-u" },
196 { 527, "get-entry-by-name-u" },
197 { 528, "replace-entry-u" },
198 { 529, "list-entry-u" },
199 { 530, "list-attrib-u" },
200 { 531, "linked-list-u" },
202 { 533, "get-addrs-u" },
203 { 534, "list-attrib-n2" },
207 static struct tok kauth_req
[] = {
209 { 21, "authenticate" },
210 { 22, "authenticate-v2" },
212 { 3, "get-ticket-old" },
213 { 23, "get-ticket" },
216 { 6, "create-user" },
217 { 7, "delete-user" },
223 { 13, "get-random-key" },
225 { 15, "lock-status" },
229 static struct tok vol_req
[] = {
230 { 100, "create-volume" },
231 { 101, "delete-volume" },
234 { 104, "end-trans" },
236 { 106, "set-flags" },
237 { 107, "get-flags" },
238 { 108, "trans-create" },
240 { 110, "get-nth-volume" },
241 { 111, "set-forwarding" },
243 { 113, "get-status" },
244 { 114, "sig-restore" },
245 { 115, "list-partitions" },
246 { 116, "list-volumes" },
247 { 117, "set-id-types" },
249 { 119, "partition-info" },
251 { 121, "list-one-volume" },
254 { 124, "x-list-volumes" },
255 { 125, "x-list-one-volume" },
257 { 127, "x-list-partitions" },
258 { 128, "forward-multiple" },
262 static struct tok bos_req
[] = {
263 { 80, "create-bnode" },
264 { 81, "delete-bnode" },
265 { 82, "set-status" },
266 { 83, "get-status" },
267 { 84, "enumerate-instance" },
268 { 85, "get-instance-info" },
269 { 86, "get-instance-parm" },
270 { 87, "add-superuser" },
271 { 88, "delete-superuser" },
272 { 89, "list-superusers" },
275 { 92, "delete-key" },
276 { 93, "set-cell-name" },
277 { 94, "get-cell-name" },
278 { 95, "get-cell-host" },
279 { 96, "add-cell-host" },
280 { 97, "delete-cell-host" },
281 { 98, "set-t-status" },
282 { 99, "shutdown-all" },
283 { 100, "restart-all" },
284 { 101, "startup-all" },
285 { 102, "set-noauth-flag" },
288 { 105, "start-bozo-install" },
289 { 106, "uninstall" },
290 { 107, "get-dates" },
293 { 110, "set-restart-time" },
294 { 111, "get-restart-time" },
295 { 112, "start-bozo-log" },
297 { 114, "get-instance-strings" },
298 { 115, "get-restricted" },
299 { 116, "set-restricted" },
303 static struct tok ubik_req
[] = {
304 { 10000, "vote-beacon" },
305 { 10001, "vote-debug-old" },
306 { 10002, "vote-sdebug-old" },
307 { 10003, "vote-getsyncsite" },
308 { 10004, "vote-debug" },
309 { 10005, "vote-sdebug" },
310 { 20000, "disk-begin" },
311 { 20001, "disk-commit" },
312 { 20002, "disk-lock" },
313 { 20003, "disk-write" },
314 { 20004, "disk-getversion" },
315 { 20005, "disk-getfile" },
316 { 20006, "disk-sendfile" },
317 { 20007, "disk-abort" },
318 { 20008, "disk-releaselocks" },
319 { 20009, "disk-truncate" },
320 { 20010, "disk-probe" },
321 { 20011, "disk-writev" },
322 { 20012, "disk-interfaceaddr" },
323 { 20013, "disk-setversion" },
327 #define VOTE_LOW 10000
328 #define VOTE_HIGH 10005
329 #define DISK_LOW 20000
330 #define DISK_HIGH 20013
332 static struct tok cb_types
[] = {
339 static struct tok ubik_lock_types
[] = {
346 static const char *voltype
[] = { "read-write", "read-only", "backup" };
348 static struct tok afs_fs_errors
[] = {
349 { 101, "salvage volume" },
350 { 102, "no such vnode" },
351 { 103, "no such volume" },
352 { 104, "volume exist" },
353 { 105, "no service" },
354 { 106, "volume offline" },
355 { 107, "voline online" },
357 { 109, "diskquota exceeded" },
358 { 110, "volume busy" },
359 { 111, "volume moved" },
360 { 112, "AFS IO error" },
361 { -100, "restarting fileserver" },
366 * Reasons for acknowledging a packet
369 static struct tok rx_ack_reasons
[] = {
370 { 1, "ack requested" },
371 { 2, "duplicate packet" },
372 { 3, "out of sequence" },
373 { 4, "exceeds window" },
374 { 5, "no buffer space" },
376 { 7, "ping response" },
382 * Cache entries we keep around so we can figure out the RX opcode
383 * numbers for replies. This allows us to make sense of RX reply packets.
386 struct rx_cache_entry
{
387 u_int32_t callnum
; /* Call number (net order) */
388 struct in_addr client
; /* client IP address (net order) */
389 struct in_addr server
; /* server IP address (net order) */
390 int dport
; /* server port (host order) */
391 u_short serviceId
; /* Service identifier (net order) */
392 u_int32_t opcode
; /* RX opcode (host order) */
395 #define RX_CACHE_SIZE 64
397 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
399 static int rx_cache_next
= 0;
400 static int rx_cache_hint
= 0;
401 static void rx_cache_insert(const u_char
*, const struct ip
*, int);
402 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
405 static void ack_print(const u_char
*, int);
406 static void fs_print(const u_char
*, int);
407 static void fs_reply_print(const u_char
*, int, int32_t);
408 static void acl_print(u_char
*, int, u_char
*);
409 static void cb_print(const u_char
*, int);
410 static void cb_reply_print(const u_char
*, int, int32_t);
411 static void prot_print(const u_char
*, int);
412 static void prot_reply_print(const u_char
*, int, int32_t);
413 static void vldb_print(const u_char
*, int);
414 static void vldb_reply_print(const u_char
*, int, int32_t);
415 static void kauth_print(const u_char
*, int);
416 static void kauth_reply_print(const u_char
*, int, int32_t);
417 static void vol_print(const u_char
*, int);
418 static void vol_reply_print(const u_char
*, int, int32_t);
419 static void bos_print(const u_char
*, int);
420 static void bos_reply_print(const u_char
*, int, int32_t);
421 static void ubik_print(const u_char
*);
422 static void ubik_reply_print(const u_char
*, int, int32_t);
424 static void rx_ack_print(const u_char
*, int);
426 static int is_ubik(u_int32_t
);
429 * Handle the rx-level packet. See if we know what port it's going to so
430 * we can peek at the afs call inside
434 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
437 register struct rx_header
*rxh
;
441 if (snapend
- bp
< (int)sizeof (struct rx_header
)) {
442 printf(" [|rx] (%d)", length
);
446 rxh
= (struct rx_header
*) bp
;
448 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
454 printf(" cid %08x call# %d",
455 (int) EXTRACT_32BITS(&rxh
->cid
),
456 (int) EXTRACT_32BITS(&rxh
->callNumber
));
458 printf(" seq %d ser %d",
459 (int) EXTRACT_32BITS(&rxh
->seq
),
460 (int) EXTRACT_32BITS(&rxh
->serial
));
463 printf(" secindex %d serviceid %hu",
464 (int) rxh
->securityIndex
,
465 EXTRACT_16BITS(&rxh
->serviceId
));
468 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
469 if (rxh
->flags
& rx_flags
[i
].flag
&&
470 (!rx_flags
[i
].packetType
||
471 rxh
->type
== rx_flags
[i
].packetType
)) {
478 printf("<%s>", rx_flags
[i
].s
);
484 * Try to handle AFS calls that we know about. Check the destination
485 * port and make sure it's a data packet. Also, make sure the
486 * seq number is 1 (because otherwise it's a continuation packet,
487 * and we can't interpret that). Also, seems that reply packets
488 * do not have the client-init flag set, so we check for that
492 if (rxh
->type
== RX_PACKET_TYPE_ACK
)
493 ack_print(bp
, length
);
494 else if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
495 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
496 rxh
->flags
& RX_CLIENT_INITIATED
) {
499 * Insert this call into the call cache table, so we
500 * have a chance to print out replies
503 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
);
506 case FS_RX_PORT
: /* AFS file service */
507 fs_print(bp
, length
);
509 case CB_RX_PORT
: /* AFS callback service */
510 cb_print(bp
, length
);
512 case PROT_RX_PORT
: /* AFS protection service */
513 prot_print(bp
, length
);
515 case VLDB_RX_PORT
: /* AFS VLDB service */
516 vldb_print(bp
, length
);
518 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
519 kauth_print(bp
, length
);
521 case VOL_RX_PORT
: /* AFS Volume service */
522 vol_print(bp
, length
);
524 case BOS_RX_PORT
: /* AFS BOS service */
525 bos_print(bp
, length
);
532 * If it's a reply (client-init is _not_ set, but seq is one)
533 * then look it up in the cache. If we find it, call the reply
534 * printing functions Note that we handle abort packets here,
535 * because printing out the return code can be useful at times.
538 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
539 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
540 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
541 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
542 rx_cache_find(rxh
, (const struct ip
*) bp2
,
546 case FS_RX_PORT
: /* AFS file service */
547 fs_reply_print(bp
, length
, opcode
);
549 case CB_RX_PORT
: /* AFS callback service */
550 cb_reply_print(bp
, length
, opcode
);
552 case PROT_RX_PORT
: /* AFS PT service */
553 prot_reply_print(bp
, length
, opcode
);
555 case VLDB_RX_PORT
: /* AFS VLDB service */
556 vldb_reply_print(bp
, length
, opcode
);
558 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
559 kauth_reply_print(bp
, length
, opcode
);
561 case VOL_RX_PORT
: /* AFS Volume service */
562 vol_reply_print(bp
, length
, opcode
);
564 case BOS_RX_PORT
: /* AFS BOS service */
565 bos_reply_print(bp
, length
, opcode
);
572 * If it's an RX ack packet, then use the appropriate ack decoding
573 * function (there isn't any service-specific information in the
574 * ack packet, so we can use one for all AFS services)
577 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
578 rx_ack_print(bp
, length
);
581 printf(" (%d)", length
);
585 * Insert an entry into the cache. Taken from print-nfs.c
589 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
)
591 struct rx_cache_entry
*rxent
;
592 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
594 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t)))
597 rxent
= &rx_cache
[rx_cache_next
];
599 if (++rx_cache_next
>= RX_CACHE_SIZE
)
602 rxent
->callnum
= rxh
->callNumber
;
603 rxent
->client
= ip
->ip_src
;
604 rxent
->server
= ip
->ip_dst
;
605 rxent
->dport
= dport
;
606 rxent
->serviceId
= rxh
->serviceId
;
607 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
611 * Lookup an entry in the cache. Also taken from print-nfs.c
613 * Note that because this is a reply, we're looking at the _source_
618 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
622 struct rx_cache_entry
*rxent
;
623 u_int32_t clip
= ip
->ip_dst
.s_addr
;
624 u_int32_t sip
= ip
->ip_src
.s_addr
;
626 /* Start the search where we last left off */
630 rxent
= &rx_cache
[i
];
631 if (rxent
->callnum
== rxh
->callNumber
&&
632 rxent
->client
.s_addr
== clip
&&
633 rxent
->server
.s_addr
== sip
&&
634 rxent
->serviceId
== rxh
->serviceId
&&
635 rxent
->dport
== sport
) {
637 /* We got a match! */
640 *opcode
= rxent
->opcode
;
643 if (++i
> RX_CACHE_SIZE
)
645 } while (i
!= rx_cache_hint
);
647 /* Our search failed */
652 * These extrememly grody macros handle the printing of various AFS stuff.
655 #define FIDOUT() { unsigned long n1, n2, n3; \
656 TCHECK2(bp[0], sizeof(int32_t) * 3); \
657 n1 = EXTRACT_32BITS(bp); \
658 bp += sizeof(int32_t); \
659 n2 = EXTRACT_32BITS(bp); \
660 bp += sizeof(int32_t); \
661 n3 = EXTRACT_32BITS(bp); \
662 bp += sizeof(int32_t); \
663 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
666 #define STROUT(MAX) { unsigned int i; \
667 TCHECK2(bp[0], sizeof(int32_t)); \
668 i = EXTRACT_32BITS(bp); \
671 bp += sizeof(int32_t); \
673 if (fn_printn(bp, i, snapend)) \
676 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
679 #define INTOUT() { int i; \
680 TCHECK2(bp[0], sizeof(int32_t)); \
681 i = (int) EXTRACT_32BITS(bp); \
682 bp += sizeof(int32_t); \
686 #define UINTOUT() { unsigned long i; \
687 TCHECK2(bp[0], sizeof(int32_t)); \
688 i = EXTRACT_32BITS(bp); \
689 bp += sizeof(int32_t); \
693 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
694 TCHECK2(bp[0], sizeof(int32_t)); \
695 t = (time_t) EXTRACT_32BITS(bp); \
696 bp += sizeof(int32_t); \
697 tm = localtime(&t); \
698 strftime(str, 256, "%Y/%m/%d %T", tm); \
699 printf(" %s", str); \
702 #define STOREATTROUT() { unsigned long mask, i; \
703 TCHECK2(bp[0], (sizeof(int32_t)*6)); \
704 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
705 if (mask) printf (" StoreStatus"); \
706 if (mask & 1) { printf(" date"); DATEOUT(); } \
707 else bp += sizeof(int32_t); \
708 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
709 if (mask & 2) printf(" owner %lu", i); \
710 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
711 if (mask & 4) printf(" group %lu", i); \
712 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
713 if (mask & 8) printf(" mode %lo", i & 07777); \
714 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
715 if (mask & 16) printf(" segsize %lu", i); \
716 /* undocumented in 3.3 docu */ \
717 if (mask & 1024) printf(" fsync"); \
720 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
721 TCHECK2(bp[0], sizeof(int32_t) * 2); \
722 epoch = EXTRACT_32BITS(bp); \
723 bp += sizeof(int32_t); \
724 counter = EXTRACT_32BITS(bp); \
725 bp += sizeof(int32_t); \
726 printf(" %d.%d", epoch, counter); \
729 #define AFSUUIDOUT() {u_int32_t temp; int i; \
730 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
731 temp = EXTRACT_32BITS(bp); \
732 bp += sizeof(u_int32_t); \
733 printf(" %08x", temp); \
734 temp = EXTRACT_32BITS(bp); \
735 bp += sizeof(u_int32_t); \
736 printf("%04x", temp); \
737 temp = EXTRACT_32BITS(bp); \
738 bp += sizeof(u_int32_t); \
739 printf("%04x", temp); \
740 for (i = 0; i < 8; i++) { \
741 temp = EXTRACT_32BITS(bp); \
742 bp += sizeof(u_int32_t); \
743 printf("%02x", (unsigned char) temp); \
748 * This is the sickest one of all
751 #define VECOUT(MAX) { u_char *sp; \
752 u_char s[AFSNAMEMAX]; \
754 if ((MAX) + 1 > sizeof(s)) \
756 TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
758 for (k = 0; k < (MAX); k++) { \
759 *sp++ = (u_char) EXTRACT_32BITS(bp); \
760 bp += sizeof(int32_t); \
769 ack_print(register const u_char
*bp
, int length
)
777 if (length
<= (int)sizeof(struct rx_header
))
780 bp
+= sizeof(struct rx_header
);
783 * Packets < firstPacket are implicitly acknowledged and may
784 * be discarded by the sender.
786 * Packets >= firstPacket+nAcks are implicitly NOT acknowledged.
788 * No packets with sequence numbers >= firstPacket should be
789 * discarded by the sender (they may thrown out at any time by
792 #define RX_ACK_REASONS "RDOXSprn"
793 /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space,
794 * Ping, ping_Response, No_{progress, particular_reason}.
797 struct rx_ackPacket
{
798 u_short bufferSpace
; /* Skip! */
799 u_short maxSkew
; /* Skip! */
801 u_long previousPacket
; /* Obsolete! */
802 u_long serial
; /* Serial that prompted the ack, */
803 u_char reason
; /* and the reason why. */
805 u_char acks
[RX_MAXACKS
]; /* Selective acks (not a bitmap). */
808 #define RX_ACK_TYPE_NACK 0
810 TCHECK2(bp
[0], 8); /* bufferSpace and maxSkew */
812 printf(" fir %u", (unsigned)EXTRACT_32BITS(bp
));
814 TCHECK2(bp
[0], 8); /* previousPacket and serial */
816 printf(" %u", (unsigned)EXTRACT_32BITS(bp
));
819 printf("%c", RX_ACK_REASONS
[(*bp
- 1) & 07u]);
820 bp
+= 1; /* reason */
825 for (i
= 0; i
< nAcks
; i
++) {
827 putchar(*bp
== RX_ACK_TYPE_NACK
? '-' : '*');
838 * Handle calls to the AFS file service (fs)
842 fs_print(register const u_char
*bp
, int length
)
847 if (length
<= (int)sizeof(struct rx_header
))
850 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
855 * Print out the afs call we're invoking. The table used here was
856 * gleaned from fsint/afsint.xg
859 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
861 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
864 * Print out arguments to some of the AFS calls. This stuff is
868 bp
+= sizeof(struct rx_header
) + 4;
871 * Sigh. This is gross. Ritchie forgive me.
875 case 130: /* Fetch data */
882 case 131: /* Fetch ACL */
883 case 132: /* Fetch Status */
884 case 143: /* Old set lock */
885 case 144: /* Old extend lock */
886 case 145: /* Old release lock */
887 case 156: /* Set lock */
888 case 157: /* Extend lock */
889 case 158: /* Release lock */
892 case 135: /* Store status */
896 case 133: /* Store data */
906 case 134: /* Store ACL */
908 char a
[AFSOPAQUEMAX
+1];
911 i
= EXTRACT_32BITS(bp
);
912 bp
+= sizeof(int32_t);
914 i
= min(AFSOPAQUEMAX
, i
);
915 strncpy(a
, (char *) bp
, i
);
917 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
920 case 137: /* Create file */
921 case 141: /* MakeDir */
926 case 136: /* Remove file */
927 case 142: /* Remove directory */
931 case 138: /* Rename file */
939 case 139: /* Symlink */
951 case 148: /* Get volume info */
954 case 149: /* Get volume stats */
955 case 150: /* Set volume stats */
959 case 154: /* New get volume info */
963 case 155: /* Bulk stat */
967 j
= EXTRACT_32BITS(bp
);
968 bp
+= sizeof(int32_t);
970 for (i
= 0; i
< j
; i
++) {
989 * Handle replies to the AFS file service
993 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
996 struct rx_header
*rxh
;
998 if (length
<= (int)sizeof(struct rx_header
))
1001 rxh
= (struct rx_header
*) bp
;
1004 * Print out the afs call we're invoking. The table used here was
1005 * gleaned from fsint/afsint.xg
1008 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
1010 bp
+= sizeof(struct rx_header
);
1013 * If it was a data packet, interpret the response
1016 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
1018 case 131: /* Fetch ACL */
1020 char a
[AFSOPAQUEMAX
+1];
1022 i
= EXTRACT_32BITS(bp
);
1023 bp
+= sizeof(int32_t);
1025 i
= min(AFSOPAQUEMAX
, i
);
1026 strncpy(a
, (char *) bp
, i
);
1028 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1031 case 137: /* Create file */
1032 case 141: /* MakeDir */
1036 case 151: /* Get root volume */
1037 printf(" root volume");
1040 case 153: /* Get time */
1046 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1050 * Otherwise, just print out the return code
1052 TCHECK2(bp
[0], sizeof(int32_t));
1053 i
= (int) EXTRACT_32BITS(bp
);
1054 bp
+= sizeof(int32_t);
1056 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
1058 printf(" strange fs reply of type %d", rxh
->type
);
1068 * Print out an AFS ACL string. An AFS ACL is a string that has the
1071 * <positive> <negative>
1075 * "positive" and "negative" are integers which contain the number of
1076 * positive and negative ACL's in the string. The uid/aclbits pair are
1077 * ASCII strings containing the UID/PTS record and and a ascii number
1078 * representing a logical OR of all the ACL permission bits
1082 acl_print(u_char
*s
, int maxsize
, u_char
*end
)
1088 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1091 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1100 * This wacky order preserves the order used by the "fs" command
1103 #define ACLOUT(acl) \
1104 if (acl & PRSFS_READ) \
1106 if (acl & PRSFS_LOOKUP) \
1108 if (acl & PRSFS_INSERT) \
1110 if (acl & PRSFS_DELETE) \
1112 if (acl & PRSFS_WRITE) \
1114 if (acl & PRSFS_LOCK) \
1116 if (acl & PRSFS_ADMINISTER) \
1119 for (i
= 0; i
< pos
; i
++) {
1120 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1124 fn_print((u_char
*)user
, NULL
);
1132 for (i
= 0; i
< neg
; i
++) {
1133 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1137 fn_print((u_char
*)user
, NULL
);
1153 * Handle calls to the AFS callback service
1157 cb_print(register const u_char
*bp
, int length
)
1162 if (length
<= (int)sizeof(struct rx_header
))
1165 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1170 * Print out the afs call we're invoking. The table used here was
1171 * gleaned from fsint/afscbint.xg
1174 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1176 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1178 bp
+= sizeof(struct rx_header
) + 4;
1181 * Print out the afs call we're invoking. The table used here was
1182 * gleaned from fsint/afscbint.xg
1186 case 204: /* Callback */
1190 j
= EXTRACT_32BITS(bp
);
1191 bp
+= sizeof(int32_t);
1193 for (i
= 0; i
< j
; i
++) {
1202 j
= EXTRACT_32BITS(bp
);
1203 bp
+= sizeof(int32_t);
1208 for (i
= 0; i
< j
; i
++) {
1214 t
= EXTRACT_32BITS(bp
);
1215 bp
+= sizeof(int32_t);
1216 tok2str(cb_types
, "type %d", t
);
1235 * Handle replies to the AFS Callback Service
1239 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1241 struct rx_header
*rxh
;
1243 if (length
<= (int)sizeof(struct rx_header
))
1246 rxh
= (struct rx_header
*) bp
;
1249 * Print out the afs call we're invoking. The table used here was
1250 * gleaned from fsint/afscbint.xg
1253 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1255 bp
+= sizeof(struct rx_header
);
1258 * If it was a data packet, interpret the response.
1261 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1263 case 213: /* InitCallBackState3 */
1271 * Otherwise, just print out the return code
1284 * Handle calls to the AFS protection database server
1288 prot_print(register const u_char
*bp
, int length
)
1293 if (length
<= (int)sizeof(struct rx_header
))
1296 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1301 * Print out the afs call we're invoking. The table used here was
1302 * gleaned from ptserver/ptint.xg
1305 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1309 if (is_ubik(pt_op
)) {
1314 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1317 * Decode some of the arguments to the PT calls
1320 bp
+= sizeof(struct rx_header
) + 4;
1323 case 500: /* I New User */
1330 case 501: /* Where is it */
1331 case 506: /* Delete */
1332 case 508: /* Get CPS */
1333 case 512: /* List entry */
1334 case 514: /* List elements */
1335 case 517: /* List owned */
1336 case 518: /* Get CPS2 */
1337 case 519: /* Get host CPS */
1341 case 502: /* Dump entry */
1345 case 503: /* Add to group */
1346 case 507: /* Remove from group */
1347 case 515: /* Is a member of? */
1353 case 504: /* Name to ID */
1357 j
= EXTRACT_32BITS(bp
);
1358 bp
+= sizeof(int32_t);
1361 * Who designed this chicken-shit protocol?
1363 * Each character is stored as a 32-bit
1367 for (i
= 0; i
< j
; i
++) {
1374 case 505: /* Id to name */
1379 i
= EXTRACT_32BITS(bp
);
1380 bp
+= sizeof(int32_t);
1381 for (j
= 0; j
< i
; j
++)
1387 case 509: /* New entry */
1394 case 511: /* Set max */
1400 case 513: /* Change entry */
1409 case 520: /* Update entry */
1426 * Handle replies to the AFS protection service
1430 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1432 struct rx_header
*rxh
;
1435 if (length
< (int)sizeof(struct rx_header
))
1438 rxh
= (struct rx_header
*) bp
;
1441 * Print out the afs call we're invoking. The table used here was
1442 * gleaned from ptserver/ptint.xg. Check to see if it's a
1443 * Ubik call, however.
1448 if (is_ubik(opcode
)) {
1449 ubik_reply_print(bp
, length
, opcode
);
1453 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1455 bp
+= sizeof(struct rx_header
);
1458 * If it was a data packet, interpret the response
1461 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1463 case 504: /* Name to ID */
1468 i
= EXTRACT_32BITS(bp
);
1469 bp
+= sizeof(int32_t);
1470 for (j
= 0; j
< i
; j
++)
1476 case 505: /* ID to name */
1480 j
= EXTRACT_32BITS(bp
);
1481 bp
+= sizeof(int32_t);
1484 * Who designed this chicken-shit protocol?
1486 * Each character is stored as a 32-bit
1490 for (i
= 0; i
< j
; i
++) {
1497 case 508: /* Get CPS */
1498 case 514: /* List elements */
1499 case 517: /* List owned */
1500 case 518: /* Get CPS2 */
1501 case 519: /* Get host CPS */
1505 j
= EXTRACT_32BITS(bp
);
1506 bp
+= sizeof(int32_t);
1507 for (i
= 0; i
< j
; i
++) {
1514 case 510: /* List max */
1525 * Otherwise, just print out the return code
1538 * Handle calls to the AFS volume location database service
1542 vldb_print(register const u_char
*bp
, int length
)
1547 if (length
<= (int)sizeof(struct rx_header
))
1550 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1555 * Print out the afs call we're invoking. The table used here was
1556 * gleaned from vlserver/vldbint.xg
1559 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1563 if (is_ubik(vldb_op
)) {
1567 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1570 * Decode some of the arguments to the VLDB calls
1573 bp
+= sizeof(struct rx_header
) + 4;
1576 case 501: /* Create new volume */
1577 case 517: /* Create entry N */
1580 case 502: /* Delete entry */
1581 case 503: /* Get entry by ID */
1582 case 507: /* Update entry */
1583 case 508: /* Set lock */
1584 case 509: /* Release lock */
1585 case 518: /* Get entry by ID N */
1588 TCHECK2(bp
[0], sizeof(int32_t));
1589 i
= EXTRACT_32BITS(bp
);
1590 bp
+= sizeof(int32_t);
1592 printf(" type %s", voltype
[i
]);
1594 case 504: /* Get entry by name */
1595 case 519: /* Get entry by name N */
1596 case 524: /* Update entry by name */
1597 case 527: /* Get entry by name U */
1600 case 505: /* Get new vol id */
1604 case 506: /* Replace entry */
1605 case 520: /* Replace entry N */
1608 TCHECK2(bp
[0], sizeof(int32_t));
1609 i
= EXTRACT_32BITS(bp
);
1610 bp
+= sizeof(int32_t);
1612 printf(" type %s", voltype
[i
]);
1615 case 510: /* List entry */
1616 case 521: /* List entry N */
1631 * Handle replies to the AFS volume location database service
1635 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1637 struct rx_header
*rxh
;
1640 if (length
< (int)sizeof(struct rx_header
))
1643 rxh
= (struct rx_header
*) bp
;
1646 * Print out the afs call we're invoking. The table used here was
1647 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1648 * Ubik call, however.
1653 if (is_ubik(opcode
)) {
1654 ubik_reply_print(bp
, length
, opcode
);
1658 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1660 bp
+= sizeof(struct rx_header
);
1663 * If it was a data packet, interpret the response
1666 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1668 case 510: /* List entry */
1671 printf(" nextindex");
1673 case 503: /* Get entry by id */
1674 case 504: /* Get entry by name */
1675 { unsigned long nservers
, j
;
1677 TCHECK2(bp
[0], sizeof(int32_t));
1678 bp
+= sizeof(int32_t);
1679 printf(" numservers");
1680 TCHECK2(bp
[0], sizeof(int32_t));
1681 nservers
= EXTRACT_32BITS(bp
);
1682 bp
+= sizeof(int32_t);
1683 printf(" %lu", nservers
);
1685 for (i
= 0; i
< 8; i
++) {
1686 TCHECK2(bp
[0], sizeof(int32_t));
1689 intoa(((struct in_addr
*) bp
)->s_addr
));
1690 bp
+= sizeof(int32_t);
1692 printf(" partitions");
1693 for (i
= 0; i
< 8; i
++) {
1694 TCHECK2(bp
[0], sizeof(int32_t));
1695 j
= EXTRACT_32BITS(bp
);
1696 if (i
< nservers
&& j
<= 26)
1697 printf(" %c", 'a' + (int)j
);
1698 else if (i
< nservers
)
1700 bp
+= sizeof(int32_t);
1702 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1703 bp
+= 8 * sizeof(int32_t);
1712 case 505: /* Get new volume ID */
1716 case 521: /* List entry */
1717 case 529: /* List entry U */
1720 printf(" nextindex");
1722 case 518: /* Get entry by ID N */
1723 case 519: /* Get entry by name N */
1724 { unsigned long nservers
, j
;
1726 printf(" numservers");
1727 TCHECK2(bp
[0], sizeof(int32_t));
1728 nservers
= EXTRACT_32BITS(bp
);
1729 bp
+= sizeof(int32_t);
1730 printf(" %lu", nservers
);
1732 for (i
= 0; i
< 13; i
++) {
1733 TCHECK2(bp
[0], sizeof(int32_t));
1736 intoa(((struct in_addr
*) bp
)->s_addr
));
1737 bp
+= sizeof(int32_t);
1739 printf(" partitions");
1740 for (i
= 0; i
< 13; i
++) {
1741 TCHECK2(bp
[0], sizeof(int32_t));
1742 j
= EXTRACT_32BITS(bp
);
1743 if (i
< nservers
&& j
<= 26)
1744 printf(" %c", 'a' + (int)j
);
1745 else if (i
< nservers
)
1747 bp
+= sizeof(int32_t);
1749 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1750 bp
+= 13 * sizeof(int32_t);
1759 case 526: /* Get entry by ID U */
1760 case 527: /* Get entry by name U */
1761 { unsigned long nservers
, j
;
1763 printf(" numservers");
1764 TCHECK2(bp
[0], sizeof(int32_t));
1765 nservers
= EXTRACT_32BITS(bp
);
1766 bp
+= sizeof(int32_t);
1767 printf(" %lu", nservers
);
1769 for (i
= 0; i
< 13; i
++) {
1778 TCHECK2(bp
[0], 4 * 13);
1780 printf(" partitions");
1781 for (i
= 0; i
< 13; i
++) {
1782 TCHECK2(bp
[0], sizeof(int32_t));
1783 j
= EXTRACT_32BITS(bp
);
1784 if (i
< nservers
&& j
<= 26)
1785 printf(" %c", 'a' + (int)j
);
1786 else if (i
< nservers
)
1788 bp
+= sizeof(int32_t);
1790 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1791 bp
+= 13 * sizeof(int32_t);
1805 * Otherwise, just print out the return code
1818 * Handle calls to the AFS Kerberos Authentication service
1822 kauth_print(register const u_char
*bp
, int length
)
1826 if (length
<= (int)sizeof(struct rx_header
))
1829 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1834 * Print out the afs call we're invoking. The table used here was
1835 * gleaned from kauth/kauth.rg
1838 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1842 if (is_ubik(kauth_op
)) {
1848 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1851 * Decode some of the arguments to the KA calls
1854 bp
+= sizeof(struct rx_header
) + 4;
1857 case 1: /* Authenticate old */;
1858 case 21: /* Authenticate */
1859 case 22: /* Authenticate-V2 */
1860 case 2: /* Change PW */
1861 case 5: /* Set fields */
1862 case 6: /* Create user */
1863 case 7: /* Delete user */
1864 case 8: /* Get entry */
1865 case 14: /* Unlock */
1866 case 15: /* Lock status */
1867 printf(" principal");
1871 case 3: /* GetTicket-old */
1872 case 23: /* GetTicket */
1879 TCHECK2(bp
[0], sizeof(int32_t));
1880 i
= (int) EXTRACT_32BITS(bp
);
1881 bp
+= sizeof(int32_t);
1884 printf(" principal");
1889 case 4: /* Set Password */
1890 printf(" principal");
1896 case 12: /* Get password */
1907 printf(" [|kauth]");
1911 * Handle replies to the AFS Kerberos Authentication Service
1915 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1917 struct rx_header
*rxh
;
1919 if (length
<= (int)sizeof(struct rx_header
))
1922 rxh
= (struct rx_header
*) bp
;
1925 * Print out the afs call we're invoking. The table used here was
1926 * gleaned from kauth/kauth.rg
1931 if (is_ubik(opcode
)) {
1932 ubik_reply_print(bp
, length
, opcode
);
1936 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1938 bp
+= sizeof(struct rx_header
);
1941 * If it was a data packet, interpret the response.
1944 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1945 /* Well, no, not really. Leave this for later */
1949 * Otherwise, just print out the return code
1958 printf(" [|kauth]");
1962 * Handle calls to the AFS Volume location service
1966 vol_print(register const u_char
*bp
, int length
)
1970 if (length
<= (int)sizeof(struct rx_header
))
1973 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1978 * Print out the afs call we're invoking. The table used here was
1979 * gleaned from volser/volint.xg
1982 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1984 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1987 * Normally there would be a switch statement here to decode the
1988 * arguments to the AFS call, but since I don't have access to
1989 * an AFS server (yet) and I'm not an AFS admin, I can't
1990 * test any of these calls. Leave this blank for now.
2000 * Handle replies to the AFS Volume Service
2004 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2006 struct rx_header
*rxh
;
2008 if (length
<= (int)sizeof(struct rx_header
))
2011 rxh
= (struct rx_header
*) bp
;
2014 * Print out the afs call we're invoking. The table used here was
2015 * gleaned from volser/volint.xg
2018 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
2020 bp
+= sizeof(struct rx_header
);
2023 * If it was a data packet, interpret the response.
2026 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2027 /* Well, no, not really. Leave this for later */
2031 * Otherwise, just print out the return code
2044 * Handle calls to the AFS BOS service
2048 bos_print(register const u_char
*bp
, int length
)
2052 if (length
<= (int)sizeof(struct rx_header
))
2055 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
2060 * Print out the afs call we're invoking. The table used here was
2061 * gleaned from bozo/bosint.xg
2064 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2066 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2069 * Decode some of the arguments to the BOS calls
2072 bp
+= sizeof(struct rx_header
) + 4;
2075 case 80: /* Create B node */
2078 printf(" instance");
2081 case 81: /* Delete B node */
2082 case 83: /* Get status */
2083 case 85: /* Get instance info */
2084 case 87: /* Add super user */
2085 case 88: /* Delete super user */
2086 case 93: /* Set cell name */
2087 case 96: /* Add cell host */
2088 case 97: /* Delete cell host */
2089 case 104: /* Restart */
2090 case 106: /* Uninstall */
2091 case 108: /* Exec */
2092 case 112: /* Getlog */
2093 case 114: /* Get instance strings */
2096 case 82: /* Set status */
2097 case 98: /* Set T status */
2102 case 86: /* Get instance parm */
2107 case 84: /* Enumerate instance */
2108 case 89: /* List super users */
2109 case 90: /* List keys */
2110 case 91: /* Add key */
2111 case 92: /* Delete key */
2112 case 95: /* Get cell host */
2115 case 105: /* Install */
2135 * Handle replies to the AFS BOS Service
2139 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2141 struct rx_header
*rxh
;
2143 if (length
<= (int)sizeof(struct rx_header
))
2146 rxh
= (struct rx_header
*) bp
;
2149 * Print out the afs call we're invoking. The table used here was
2150 * gleaned from volser/volint.xg
2153 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2155 bp
+= sizeof(struct rx_header
);
2158 * If it was a data packet, interpret the response.
2161 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2162 /* Well, no, not really. Leave this for later */
2166 * Otherwise, just print out the return code
2179 * Check to see if this is a Ubik opcode.
2183 is_ubik(u_int32_t opcode
)
2185 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2186 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2193 * Handle Ubik opcodes to any one of the replicated database services
2197 ubik_print(register const u_char
*bp
)
2203 * Print out the afs call we're invoking. The table used here was
2204 * gleaned from ubik/ubik_int.xg
2207 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2209 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2212 * Decode some of the arguments to the Ubik calls
2215 bp
+= sizeof(struct rx_header
) + 4;
2218 case 10000: /* Beacon */
2220 temp
= EXTRACT_32BITS(bp
);
2221 bp
+= sizeof(int32_t);
2222 printf(" syncsite %s", temp
? "yes" : "no");
2223 printf(" votestart");
2225 printf(" dbversion");
2230 case 10003: /* Get sync site */
2234 case 20000: /* Begin */
2235 case 20001: /* Commit */
2236 case 20007: /* Abort */
2237 case 20008: /* Release locks */
2238 case 20010: /* Writev */
2242 case 20002: /* Lock */
2251 temp
= EXTRACT_32BITS(bp
);
2252 bp
+= sizeof(int32_t);
2253 tok2str(ubik_lock_types
, "type %d", temp
);
2255 case 20003: /* Write */
2263 case 20005: /* Get file */
2267 case 20006: /* Send file */
2272 printf(" dbversion");
2275 case 20009: /* Truncate */
2283 case 20012: /* Set version */
2286 printf(" oldversion");
2288 printf(" newversion");
2302 * Handle Ubik replies to any one of the replicated database services
2306 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2308 struct rx_header
*rxh
;
2310 if (length
< (int)sizeof(struct rx_header
))
2313 rxh
= (struct rx_header
*) bp
;
2316 * Print out the ubik call we're invoking. This table was gleaned
2317 * from ubik/ubik_int.xg
2320 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2322 bp
+= sizeof(struct rx_header
);
2325 * If it was a data packet, print out the arguments to the Ubik calls
2328 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2330 case 10000: /* Beacon */
2333 case 20004: /* Get version */
2334 printf(" dbversion");
2342 * Otherwise, print out "yes" it it was a beacon packet (because
2343 * that's how yes votes are returned, go figure), otherwise
2344 * just print out the error code.
2349 case 10000: /* Beacon */
2350 printf(" vote yes until");
2365 * Handle RX ACK packets.
2369 rx_ack_print(register const u_char
*bp
, int length
)
2371 struct rx_ackPacket
*rxa
;
2374 if (length
< (int)sizeof(struct rx_header
))
2377 bp
+= sizeof(struct rx_header
);
2380 * This may seem a little odd .... the rx_ackPacket structure
2381 * contains an array of individual packet acknowledgements
2382 * (used for selective ack/nack), but since it's variable in size,
2383 * we don't want to truncate based on the size of the whole
2384 * rx_ackPacket structure.
2387 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2389 rxa
= (struct rx_ackPacket
*) bp
;
2390 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2393 * Print out a few useful things from the ack packet structure
2397 printf(" bufspace %d maxskew %d",
2398 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2399 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2401 printf(" first %d serial %d reason %s",
2402 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2403 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2406 * Okay, now we print out the ack array. The way _this_ works
2407 * is that we start at "first", and step through the ack array.
2408 * If we have a contiguous range of acks/nacks, try to
2409 * collapse them into a range.
2411 * If you're really clever, you might have noticed that this
2412 * doesn't seem quite correct. Specifically, due to structure
2413 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2414 * yield the start of the ack array (because RX_MAXACKS is 255
2415 * and the structure will likely get padded to a 2 or 4 byte
2416 * boundary). However, this is the way it's implemented inside
2417 * of AFS - the start of the extra fields are at
2418 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2419 * the exact start of the ack array. Sigh. That's why we aren't
2420 * using bp, but instead use rxa->acks[]. But nAcks gets added
2421 * to bp after this, so bp ends up at the right spot. Go figure.
2424 if (rxa
->nAcks
!= 0) {
2426 TCHECK2(bp
[0], rxa
->nAcks
);
2429 * Sigh, this is gross, but it seems to work to collapse
2433 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2434 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2437 * I figured this deserved _some_ explanation.
2438 * First, print "acked" and the packet seq
2439 * number if this is the first time we've
2440 * seen an acked packet.
2445 rxa
->firstPacket
+ i
);
2450 * Otherwise, if the there is a skip in
2451 * the range (such as an nacked packet in
2452 * the middle of some acked packets),
2453 * then print the current packet number
2454 * seperated from the last number by
2458 else if (last
!= i
- 1) {
2459 printf(",%d", rxa
->firstPacket
+ i
);
2464 * We always set last to the value of
2465 * the last ack we saw. Conversely, start
2466 * is set to the value of the first ack
2467 * we saw in a range.
2473 * Okay, this bit a code gets executed when
2474 * we hit a nack ... in _this_ case we
2475 * want to print out the range of packets
2476 * that were acked, so we need to print
2477 * the _previous_ packet number seperated
2478 * from the first by a dash (-). Since we
2479 * already printed the first packet above,
2480 * just print the final packet. Don't
2481 * do this if there will be a single-length
2484 } else if (last
== i
- 1 && start
!= last
)
2485 printf("-%d", rxa
->firstPacket
+ i
- 1);
2488 * So, what's going on here? We ran off the end of the
2489 * ack list, and if we got a range we need to finish it up.
2490 * So we need to determine if the last packet in the list
2491 * was an ack (if so, then last will be set to it) and
2492 * we need to see if the last range didn't start with the
2493 * last packet (because if it _did_, then that would mean
2494 * that the packet number has already been printed and
2495 * we don't need to print it again).
2498 if (last
== i
- 1 && start
!= last
)
2499 printf("-%d", rxa
->firstPacket
+ i
- 1);
2502 * Same as above, just without comments
2505 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2506 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2508 printf(" nacked %d",
2509 rxa
->firstPacket
+ i
);
2511 } else if (last
!= i
- 1) {
2512 printf(",%d", rxa
->firstPacket
+ i
);
2516 } else if (last
== i
- 1 && start
!= last
)
2517 printf("-%d", rxa
->firstPacket
+ i
- 1);
2519 if (last
== i
- 1 && start
!= last
)
2520 printf("-%d", rxa
->firstPacket
+ i
- 1);
2527 * These are optional fields; depending on your version of AFS,
2528 * you may or may not see them
2531 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2547 printf(" maxpackets");