]>
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.27 2001-10-20 07:41:55 itojun Exp $";
48 #include <sys/param.h>
50 #include <sys/types.h>
51 #include <sys/socket.h>
52 #include <netinet/in.h>
53 #include <arpa/inet.h>
55 #include "interface.h"
56 #include "addrtoname.h"
63 static struct tok rx_types
[] = {
64 { RX_PACKET_TYPE_DATA
, "data" },
65 { RX_PACKET_TYPE_ACK
, "ack" },
66 { RX_PACKET_TYPE_BUSY
, "busy" },
67 { RX_PACKET_TYPE_ABORT
, "abort" },
68 { RX_PACKET_TYPE_ACKALL
, "ackall" },
69 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
70 { RX_PACKET_TYPE_RESPONSE
, "response" },
71 { RX_PACKET_TYPE_DEBUG
, "debug" },
72 { RX_PACKET_TYPE_PARAMS
, "params" },
73 { RX_PACKET_TYPE_VERSION
, "version" },
77 static struct double_tok
{
78 int flag
; /* Rx flag */
79 int packetType
; /* Packet type */
80 char *s
; /* Flag string */
82 { RX_CLIENT_INITIATED
, 0, "client-init" },
83 { RX_REQUEST_ACK
, 0, "req-ack" },
84 { RX_LAST_PACKET
, 0, "last-pckt" },
85 { RX_MORE_PACKETS
, 0, "more-pckts" },
86 { RX_FREE_PACKET
, 0, "free-pckt" },
87 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
88 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
91 static struct tok fs_req
[] = {
92 { 130, "fetch-data" },
94 { 132, "fetch-status" },
95 { 133, "store-data" },
97 { 135, "store-status" },
98 { 136, "remove-file" },
99 { 137, "create-file" },
105 { 143, "oldsetlock" },
106 { 144, "oldextlock" },
107 { 145, "oldrellock" },
108 { 146, "get-stats" },
110 { 148, "get-vlinfo" },
111 { 149, "get-vlstats" },
112 { 150, "set-vlstats" },
113 { 151, "get-rootvl" },
114 { 152, "check-token" },
116 { 154, "nget-vlinfo" },
117 { 155, "bulk-stat" },
121 { 159, "xstat-ver" },
122 { 160, "get-xstat" },
123 { 161, "dfs-lookup" },
124 { 162, "dfs-flushcps" },
125 { 163, "dfs-symlink" },
126 { 220, "residency" },
130 static struct tok cb_req
[] = {
139 { 212, "whoareyou" },
141 { 214, "probeuuid" },
142 { 215, "getsrvprefs" },
143 { 216, "getcellservdb" },
144 { 217, "getlocalcell" },
145 { 218, "getcacheconf" },
149 static struct tok pt_req
[] = {
151 { 501, "where-is-it" },
152 { 502, "dump-entry" },
153 { 503, "add-to-group" },
154 { 504, "name-to-id" },
155 { 505, "id-to-name" },
157 { 507, "remove-from-group" },
159 { 509, "new-entry" },
162 { 512, "list-entry" },
163 { 513, "change-entry" },
164 { 514, "list-elements" },
165 { 515, "same-mbr-of" },
166 { 516, "set-fld-sentry" },
167 { 517, "list-owned" },
169 { 519, "get-host-cps" },
170 { 520, "update-entry" },
171 { 521, "list-entries" },
175 static struct tok vldb_req
[] = {
176 { 501, "create-entry" },
177 { 502, "delete-entry" },
178 { 503, "get-entry-by-id" },
179 { 504, "get-entry-by-name" },
180 { 505, "get-new-volume-id" },
181 { 506, "replace-entry" },
182 { 507, "update-entry" },
184 { 509, "releaselock" },
185 { 510, "list-entry" },
186 { 511, "list-attrib" },
187 { 512, "linked-list" },
188 { 513, "get-stats" },
190 { 515, "get-addrs" },
191 { 516, "change-addr" },
192 { 517, "create-entry-n" },
193 { 518, "get-entry-by-id-n" },
194 { 519, "get-entry-by-name-n" },
195 { 520, "replace-entry-n" },
196 { 521, "list-entry-n" },
197 { 522, "list-attrib-n" },
198 { 523, "linked-list-n" },
199 { 524, "update-entry-by-name" },
200 { 525, "create-entry-u" },
201 { 526, "get-entry-by-id-u" },
202 { 527, "get-entry-by-name-u" },
203 { 528, "replace-entry-u" },
204 { 529, "list-entry-u" },
205 { 530, "list-attrib-u" },
206 { 531, "linked-list-u" },
208 { 533, "get-addrs-u" },
209 { 534, "list-attrib-n2" },
213 static struct tok kauth_req
[] = {
215 { 21, "authenticate" },
216 { 22, "authenticate-v2" },
218 { 3, "get-ticket-old" },
219 { 23, "get-ticket" },
222 { 6, "create-user" },
223 { 7, "delete-user" },
229 { 13, "get-random-key" },
231 { 15, "lock-status" },
235 static struct tok vol_req
[] = {
236 { 100, "create-volume" },
237 { 101, "delete-volume" },
240 { 104, "end-trans" },
242 { 106, "set-flags" },
243 { 107, "get-flags" },
244 { 108, "trans-create" },
246 { 110, "get-nth-volume" },
247 { 111, "set-forwarding" },
249 { 113, "get-status" },
250 { 114, "sig-restore" },
251 { 115, "list-partitions" },
252 { 116, "list-volumes" },
253 { 117, "set-id-types" },
255 { 119, "partition-info" },
257 { 121, "list-one-volume" },
260 { 124, "x-list-volumes" },
261 { 125, "x-list-one-volume" },
263 { 127, "x-list-partitions" },
264 { 128, "forward-multiple" },
268 static struct tok bos_req
[] = {
269 { 80, "create-bnode" },
270 { 81, "delete-bnode" },
271 { 82, "set-status" },
272 { 83, "get-status" },
273 { 84, "enumerate-instance" },
274 { 85, "get-instance-info" },
275 { 86, "get-instance-parm" },
276 { 87, "add-superuser" },
277 { 88, "delete-superuser" },
278 { 89, "list-superusers" },
281 { 92, "delete-key" },
282 { 93, "set-cell-name" },
283 { 94, "get-cell-name" },
284 { 95, "get-cell-host" },
285 { 96, "add-cell-host" },
286 { 97, "delete-cell-host" },
287 { 98, "set-t-status" },
288 { 99, "shutdown-all" },
289 { 100, "restart-all" },
290 { 101, "startup-all" },
291 { 102, "set-noauth-flag" },
294 { 105, "start-bozo-install" },
295 { 106, "uninstall" },
296 { 107, "get-dates" },
299 { 110, "set-restart-time" },
300 { 111, "get-restart-time" },
301 { 112, "start-bozo-log" },
303 { 114, "get-instance-strings" },
304 { 115, "get-restricted" },
305 { 116, "set-restricted" },
309 static struct tok ubik_req
[] = {
310 { 10000, "vote-beacon" },
311 { 10001, "vote-debug-old" },
312 { 10002, "vote-sdebug-old" },
313 { 10003, "vote-getsyncsite" },
314 { 10004, "vote-debug" },
315 { 10005, "vote-sdebug" },
316 { 20000, "disk-begin" },
317 { 20001, "disk-commit" },
318 { 20002, "disk-lock" },
319 { 20003, "disk-write" },
320 { 20004, "disk-getversion" },
321 { 20005, "disk-getfile" },
322 { 20006, "disk-sendfile" },
323 { 20007, "disk-abort" },
324 { 20008, "disk-releaselocks" },
325 { 20009, "disk-truncate" },
326 { 20010, "disk-probe" },
327 { 20011, "disk-writev" },
328 { 20012, "disk-interfaceaddr" },
329 { 20013, "disk-setversion" },
333 #define VOTE_LOW 10000
334 #define VOTE_HIGH 10005
335 #define DISK_LOW 20000
336 #define DISK_HIGH 20013
338 static struct tok cb_types
[] = {
345 static struct tok ubik_lock_types
[] = {
352 static char *voltype
[] = { "read-write", "read-only", "backup" };
354 static struct tok afs_fs_errors
[] = {
355 { 101, "salvage volume" },
356 { 102, "no such vnode" },
357 { 103, "no such volume" },
358 { 104, "volume exist" },
359 { 105, "no service" },
360 { 106, "volume offline" },
361 { 107, "voline online" },
363 { 109, "diskquota exceeded" },
364 { 110, "volume busy" },
365 { 111, "volume moved" },
366 { 112, "AFS IO error" },
367 { -100, "restarting fileserver" },
372 * Reasons for acknowledging a packet
375 static struct tok rx_ack_reasons
[] = {
376 { 1, "ack requested" },
377 { 2, "duplicate packet" },
378 { 3, "out of sequence" },
379 { 4, "exceeds window" },
380 { 5, "no buffer space" },
382 { 7, "ping response" },
388 * Cache entries we keep around so we can figure out the RX opcode
389 * numbers for replies. This allows us to make sense of RX reply packets.
392 struct rx_cache_entry
{
393 u_int32_t callnum
; /* Call number (net order) */
394 struct in_addr client
; /* client IP address (net order) */
395 struct in_addr server
; /* server IP address (net order) */
396 int dport
; /* server port (host order) */
397 u_short serviceId
; /* Service identifier (net order) */
398 u_int32_t opcode
; /* RX opcode (host order) */
401 #define RX_CACHE_SIZE 64
403 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
405 static int rx_cache_next
= 0;
406 static int rx_cache_hint
= 0;
407 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
408 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
411 static void ack_print(const u_char
*, int);
412 static void fs_print(const u_char
*, int);
413 static void fs_reply_print(const u_char
*, int, int32_t);
414 static void acl_print(u_char
*, int, u_char
*);
415 static void cb_print(const u_char
*, int);
416 static void cb_reply_print(const u_char
*, int, int32_t);
417 static void prot_print(const u_char
*, int);
418 static void prot_reply_print(const u_char
*, int, int32_t);
419 static void vldb_print(const u_char
*, int);
420 static void vldb_reply_print(const u_char
*, int, int32_t);
421 static void kauth_print(const u_char
*, int);
422 static void kauth_reply_print(const u_char
*, int, int32_t);
423 static void vol_print(const u_char
*, int);
424 static void vol_reply_print(const u_char
*, int, int32_t);
425 static void bos_print(const u_char
*, int);
426 static void bos_reply_print(const u_char
*, int, int32_t);
427 static void ubik_print(const u_char
*, int);
428 static void ubik_reply_print(const u_char
*, int, int32_t);
430 static void rx_ack_print(const u_char
*, int);
432 static int is_ubik(u_int32_t
);
435 * Handle the rx-level packet. See if we know what port it's going to so
436 * we can peek at the afs call inside
440 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
443 register struct rx_header
*rxh
;
447 if (snapend
- bp
< sizeof (struct rx_header
)) {
448 printf(" [|rx] (%d)", length
);
452 rxh
= (struct rx_header
*) bp
;
454 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
460 printf(" cid %08x call# %d",
461 (int) EXTRACT_32BITS(&rxh
->cid
),
462 (int) EXTRACT_32BITS(&rxh
->callNumber
));
464 printf(" seq %d ser %d",
465 (int) EXTRACT_32BITS(&rxh
->seq
),
466 (int) EXTRACT_32BITS(&rxh
->serial
));
469 printf(" secindex %d serviceid %hu",
470 (int) rxh
->securityIndex
,
471 EXTRACT_16BITS(&rxh
->serviceId
));
474 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
475 if (rxh
->flags
& rx_flags
[i
].flag
&&
476 (!rx_flags
[i
].packetType
||
477 rxh
->type
== rx_flags
[i
].packetType
)) {
484 printf("<%s>", rx_flags
[i
].s
);
490 * Try to handle AFS calls that we know about. Check the destination
491 * port and make sure it's a data packet. Also, make sure the
492 * seq number is 1 (because otherwise it's a continuation packet,
493 * and we can't interpret that). Also, seems that reply packets
494 * do not have the client-init flag set, so we check for that
498 if (rxh
->type
== RX_PACKET_TYPE_ACK
)
499 ack_print(bp
, length
);
500 else if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
501 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
502 rxh
->flags
& RX_CLIENT_INITIATED
) {
505 * Insert this call into the call cache table, so we
506 * have a chance to print out replies
509 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
512 case FS_RX_PORT
: /* AFS file service */
513 fs_print(bp
, length
);
515 case CB_RX_PORT
: /* AFS callback service */
516 cb_print(bp
, length
);
518 case PROT_RX_PORT
: /* AFS protection service */
519 prot_print(bp
, length
);
521 case VLDB_RX_PORT
: /* AFS VLDB service */
522 vldb_print(bp
, length
);
524 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
525 kauth_print(bp
, length
);
527 case VOL_RX_PORT
: /* AFS Volume service */
528 vol_print(bp
, length
);
530 case BOS_RX_PORT
: /* AFS BOS service */
531 bos_print(bp
, length
);
538 * If it's a reply (client-init is _not_ set, but seq is one)
539 * then look it up in the cache. If we find it, call the reply
540 * printing functions Note that we handle abort packets here,
541 * because printing out the return code can be useful at times.
544 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
545 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
546 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
547 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
548 rx_cache_find(rxh
, (const struct ip
*) bp2
,
552 case FS_RX_PORT
: /* AFS file service */
553 fs_reply_print(bp
, length
, opcode
);
555 case CB_RX_PORT
: /* AFS callback service */
556 cb_reply_print(bp
, length
, opcode
);
558 case PROT_RX_PORT
: /* AFS PT service */
559 prot_reply_print(bp
, length
, opcode
);
561 case VLDB_RX_PORT
: /* AFS VLDB service */
562 vldb_reply_print(bp
, length
, opcode
);
564 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
565 kauth_reply_print(bp
, length
, opcode
);
567 case VOL_RX_PORT
: /* AFS Volume service */
568 vol_reply_print(bp
, length
, opcode
);
570 case BOS_RX_PORT
: /* AFS BOS service */
571 bos_reply_print(bp
, length
, opcode
);
578 * If it's an RX ack packet, then use the appropriate ack decoding
579 * function (there isn't any service-specific information in the
580 * ack packet, so we can use one for all AFS services)
583 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
584 rx_ack_print(bp
, length
);
587 printf(" (%d)", length
);
591 * Insert an entry into the cache. Taken from print-nfs.c
595 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
598 struct rx_cache_entry
*rxent
;
599 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
601 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
604 rxent
= &rx_cache
[rx_cache_next
];
606 if (++rx_cache_next
>= RX_CACHE_SIZE
)
609 rxent
->callnum
= rxh
->callNumber
;
610 rxent
->client
= ip
->ip_src
;
611 rxent
->server
= ip
->ip_dst
;
612 rxent
->dport
= dport
;
613 rxent
->serviceId
= rxh
->serviceId
;
614 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
618 * Lookup an entry in the cache. Also taken from print-nfs.c
620 * Note that because this is a reply, we're looking at the _source_
625 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
629 struct rx_cache_entry
*rxent
;
630 u_int32_t clip
= ip
->ip_dst
.s_addr
;
631 u_int32_t sip
= ip
->ip_src
.s_addr
;
633 /* Start the search where we last left off */
637 rxent
= &rx_cache
[i
];
638 if (rxent
->callnum
== rxh
->callNumber
&&
639 rxent
->client
.s_addr
== clip
&&
640 rxent
->server
.s_addr
== sip
&&
641 rxent
->serviceId
== rxh
->serviceId
&&
642 rxent
->dport
== sport
) {
644 /* We got a match! */
647 *opcode
= rxent
->opcode
;
650 if (++i
> RX_CACHE_SIZE
)
652 } while (i
!= rx_cache_hint
);
654 /* Our search failed */
659 * These extrememly grody macros handle the printing of various AFS stuff.
662 #define FIDOUT() { unsigned long n1, n2, n3; \
663 TCHECK2(bp[0], sizeof(int32_t) * 3); \
664 n1 = EXTRACT_32BITS(bp); \
665 bp += sizeof(int32_t); \
666 n2 = EXTRACT_32BITS(bp); \
667 bp += sizeof(int32_t); \
668 n3 = EXTRACT_32BITS(bp); \
669 bp += sizeof(int32_t); \
670 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
673 #define STROUT(MAX) { unsigned int i; \
674 TCHECK2(bp[0], sizeof(int32_t)); \
675 i = EXTRACT_32BITS(bp); \
678 bp += sizeof(int32_t); \
680 if (fn_printn(bp, i, snapend)) \
683 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
686 #define INTOUT() { int i; \
687 TCHECK2(bp[0], sizeof(int32_t)); \
688 i = (int) EXTRACT_32BITS(bp); \
689 bp += sizeof(int32_t); \
693 #define UINTOUT() { unsigned long i; \
694 TCHECK2(bp[0], sizeof(int32_t)); \
695 i = EXTRACT_32BITS(bp); \
696 bp += sizeof(int32_t); \
700 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
701 TCHECK2(bp[0], sizeof(int32_t)); \
702 t = (time_t) EXTRACT_32BITS(bp); \
703 bp += sizeof(int32_t); \
704 tm = localtime(&t); \
705 strftime(str, 256, "%Y/%m/%d %T", tm); \
706 printf(" %s", str); \
709 #define STOREATTROUT() { unsigned long mask, i; \
710 TCHECK2(bp[0], (sizeof(int32_t)*6)); \
711 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
712 if (mask) printf (" StoreStatus"); \
713 if (mask & 1) { printf(" date"); DATEOUT(); } \
714 else bp += sizeof(int32_t); \
715 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
716 if (mask & 2) printf(" owner %lu", i); \
717 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
718 if (mask & 4) printf(" group %lu", i); \
719 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
720 if (mask & 8) printf(" mode %lo", i & 07777); \
721 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
722 if (mask & 16) printf(" segsize %lu", i); \
723 /* undocumented in 3.3 docu */ \
724 if (mask & 1024) printf(" fsync"); \
727 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
728 TCHECK2(bp[0], sizeof(int32_t) * 2); \
729 epoch = EXTRACT_32BITS(bp); \
730 bp += sizeof(int32_t); \
731 counter = EXTRACT_32BITS(bp); \
732 bp += sizeof(int32_t); \
733 printf(" %d.%d", epoch, counter); \
736 #define AFSUUIDOUT() {u_int32_t temp; int i; \
737 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
738 temp = EXTRACT_32BITS(bp); \
739 bp += sizeof(u_int32_t); \
740 printf(" %08x", temp); \
741 temp = EXTRACT_32BITS(bp); \
742 bp += sizeof(u_int32_t); \
743 printf("%04x", temp); \
744 temp = EXTRACT_32BITS(bp); \
745 bp += sizeof(u_int32_t); \
746 printf("%04x", temp); \
747 for (i = 0; i < 8; i++) { \
748 temp = EXTRACT_32BITS(bp); \
749 bp += sizeof(u_int32_t); \
750 printf("%02x", (unsigned char) temp); \
755 * This is the sickest one of all
758 #define VECOUT(MAX) { char *sp; \
759 char s[AFSNAMEMAX]; \
761 if ((MAX) + 1 > sizeof(s)) \
763 TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
765 for (k = 0; k < (MAX); k++) { \
766 *sp++ = (char) EXTRACT_32BITS(bp); \
767 bp += sizeof(int32_t); \
776 ack_print(register const u_char
*bp
, int length
)
784 if (length
<= sizeof(struct rx_header
))
787 bp
+= sizeof(struct rx_header
);
790 * Packets < firstPacket are implicitly acknowledged and may
791 * be discarded by the sender.
793 * Packets >= firstPacket+nAcks are implicitly NOT acknowledged.
795 * No packets with sequence numbers >= firstPacket should be
796 * discarded by the sender (they may thrown out at any time by
799 #define RX_ACK_REASONS "RDOXSprn"
800 /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space,
801 * Ping, ping_Response, No_{progress, particular_reason}.
804 struct rx_ackPacket
{
805 u_short bufferSpace
; /* Skip! */
806 u_short maxSkew
; /* Skip! */
808 u_long previousPacket
; /* Obsolete! */
809 u_long serial
; /* Serial that prompted the ack, */
810 u_char reason
; /* and the reason why. */
812 u_char acks
[RX_MAXACKS
]; /* Selective acks (not a bitmap). */
815 #define RX_ACK_TYPE_NACK 0
817 TCHECK2(bp
[0], 8); /* bufferSpace and maxSkew */
819 printf(" fir %u", (unsigned)EXTRACT_32BITS(bp
));
821 TCHECK2(bp
[0], 8); /* previousPacket and serial */
823 printf(" %u", (unsigned)EXTRACT_32BITS(bp
));
826 printf("%c", RX_ACK_REASONS
[(*bp
- 1) & 07u]);
827 bp
+= 1; /* reason */
832 for (i
= 0; i
< nAcks
; i
++) {
834 putchar(*bp
== RX_ACK_TYPE_NACK
? '-' : '*');
845 * Handle calls to the AFS file service (fs)
849 fs_print(register const u_char
*bp
, int length
)
854 if (length
<= sizeof(struct rx_header
))
857 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
862 * Print out the afs call we're invoking. The table used here was
863 * gleaned from fsint/afsint.xg
866 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
868 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
871 * Print out arguments to some of the AFS calls. This stuff is
875 bp
+= sizeof(struct rx_header
) + 4;
878 * Sigh. This is gross. Ritchie forgive me.
882 case 130: /* Fetch data */
889 case 131: /* Fetch ACL */
890 case 132: /* Fetch Status */
891 case 143: /* Old set lock */
892 case 144: /* Old extend lock */
893 case 145: /* Old release lock */
894 case 156: /* Set lock */
895 case 157: /* Extend lock */
896 case 158: /* Release lock */
899 case 135: /* Store status */
903 case 133: /* Store data */
913 case 134: /* Store ACL */
915 char a
[AFSOPAQUEMAX
+1];
918 i
= EXTRACT_32BITS(bp
);
919 bp
+= sizeof(int32_t);
921 i
= min(AFSOPAQUEMAX
, i
);
922 strncpy(a
, (char *) bp
, i
);
924 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
927 case 137: /* Create file */
928 case 141: /* MakeDir */
933 case 136: /* Remove file */
934 case 142: /* Remove directory */
938 case 138: /* Rename file */
946 case 139: /* Symlink */
958 case 148: /* Get volume info */
961 case 149: /* Get volume stats */
962 case 150: /* Set volume stats */
966 case 154: /* New get volume info */
970 case 155: /* Bulk stat */
974 j
= EXTRACT_32BITS(bp
);
975 bp
+= sizeof(int32_t);
977 for (i
= 0; i
< j
; i
++) {
996 * Handle replies to the AFS file service
1000 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1003 struct rx_header
*rxh
;
1005 if (length
<= sizeof(struct rx_header
))
1008 rxh
= (struct rx_header
*) bp
;
1011 * Print out the afs call we're invoking. The table used here was
1012 * gleaned from fsint/afsint.xg
1015 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
1017 bp
+= sizeof(struct rx_header
);
1020 * If it was a data packet, interpret the response
1023 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
1025 case 131: /* Fetch ACL */
1027 char a
[AFSOPAQUEMAX
+1];
1029 i
= EXTRACT_32BITS(bp
);
1030 bp
+= sizeof(int32_t);
1032 i
= min(AFSOPAQUEMAX
, i
);
1033 strncpy(a
, (char *) bp
, i
);
1035 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1038 case 137: /* Create file */
1039 case 141: /* MakeDir */
1043 case 151: /* Get root volume */
1044 printf(" root volume");
1047 case 153: /* Get time */
1053 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1057 * Otherwise, just print out the return code
1059 TCHECK2(bp
[0], sizeof(int32_t));
1060 i
= (int) EXTRACT_32BITS(bp
);
1061 bp
+= sizeof(int32_t);
1063 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
1065 printf(" strange fs reply of type %d", rxh
->type
);
1075 * Print out an AFS ACL string. An AFS ACL is a string that has the
1078 * <positive> <negative>
1082 * "positive" and "negative" are integers which contain the number of
1083 * positive and negative ACL's in the string. The uid/aclbits pair are
1084 * ASCII strings containing the UID/PTS record and and a ascii number
1085 * representing a logical OR of all the ACL permission bits
1089 acl_print(u_char
*s
, int maxsize
, u_char
*end
)
1095 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1098 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1107 * This wacky order preserves the order used by the "fs" command
1110 #define ACLOUT(acl) \
1111 if (acl & PRSFS_READ) \
1113 if (acl & PRSFS_LOOKUP) \
1115 if (acl & PRSFS_INSERT) \
1117 if (acl & PRSFS_DELETE) \
1119 if (acl & PRSFS_WRITE) \
1121 if (acl & PRSFS_LOCK) \
1123 if (acl & PRSFS_ADMINISTER) \
1126 for (i
= 0; i
< pos
; i
++) {
1127 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1131 fn_print(user
, NULL
);
1139 for (i
= 0; i
< neg
; i
++) {
1140 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1144 fn_print(user
, NULL
);
1160 * Handle calls to the AFS callback service
1164 cb_print(register const u_char
*bp
, int length
)
1169 if (length
<= sizeof(struct rx_header
))
1172 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1177 * Print out the afs call we're invoking. The table used here was
1178 * gleaned from fsint/afscbint.xg
1181 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1183 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1185 bp
+= sizeof(struct rx_header
) + 4;
1188 * Print out the afs call we're invoking. The table used here was
1189 * gleaned from fsint/afscbint.xg
1193 case 204: /* Callback */
1197 j
= EXTRACT_32BITS(bp
);
1198 bp
+= sizeof(int32_t);
1200 for (i
= 0; i
< j
; i
++) {
1209 j
= EXTRACT_32BITS(bp
);
1210 bp
+= sizeof(int32_t);
1215 for (i
= 0; i
< j
; i
++) {
1221 t
= EXTRACT_32BITS(bp
);
1222 bp
+= sizeof(int32_t);
1223 tok2str(cb_types
, "type %d", t
);
1242 * Handle replies to the AFS Callback Service
1246 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1248 struct rx_header
*rxh
;
1250 if (length
<= sizeof(struct rx_header
))
1253 rxh
= (struct rx_header
*) bp
;
1256 * Print out the afs call we're invoking. The table used here was
1257 * gleaned from fsint/afscbint.xg
1260 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1262 bp
+= sizeof(struct rx_header
);
1265 * If it was a data packet, interpret the response.
1268 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1270 case 213: /* InitCallBackState3 */
1278 * Otherwise, just print out the return code
1291 * Handle calls to the AFS protection database server
1295 prot_print(register const u_char
*bp
, int length
)
1300 if (length
<= sizeof(struct rx_header
))
1303 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1308 * Print out the afs call we're invoking. The table used here was
1309 * gleaned from ptserver/ptint.xg
1312 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1316 if (is_ubik(pt_op
)) {
1317 ubik_print(bp
, length
);
1321 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1324 * Decode some of the arguments to the PT calls
1327 bp
+= sizeof(struct rx_header
) + 4;
1330 case 500: /* I New User */
1337 case 501: /* Where is it */
1338 case 506: /* Delete */
1339 case 508: /* Get CPS */
1340 case 512: /* List entry */
1341 case 514: /* List elements */
1342 case 517: /* List owned */
1343 case 518: /* Get CPS2 */
1344 case 519: /* Get host CPS */
1348 case 502: /* Dump entry */
1352 case 503: /* Add to group */
1353 case 507: /* Remove from group */
1354 case 515: /* Is a member of? */
1360 case 504: /* Name to ID */
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 505: /* Id to name */
1386 i
= EXTRACT_32BITS(bp
);
1387 bp
+= sizeof(int32_t);
1388 for (j
= 0; j
< i
; j
++)
1394 case 509: /* New entry */
1401 case 511: /* Set max */
1407 case 513: /* Change entry */
1416 case 520: /* Update entry */
1433 * Handle replies to the AFS protection service
1437 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1439 struct rx_header
*rxh
;
1442 if (length
< sizeof(struct rx_header
))
1445 rxh
= (struct rx_header
*) bp
;
1448 * Print out the afs call we're invoking. The table used here was
1449 * gleaned from ptserver/ptint.xg. Check to see if it's a
1450 * Ubik call, however.
1455 if (is_ubik(opcode
)) {
1456 ubik_reply_print(bp
, length
, opcode
);
1460 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1462 bp
+= sizeof(struct rx_header
);
1465 * If it was a data packet, interpret the response
1468 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1470 case 504: /* Name to ID */
1475 i
= EXTRACT_32BITS(bp
);
1476 bp
+= sizeof(int32_t);
1477 for (j
= 0; j
< i
; j
++)
1483 case 505: /* ID to name */
1487 j
= EXTRACT_32BITS(bp
);
1488 bp
+= sizeof(int32_t);
1491 * Who designed this chicken-shit protocol?
1493 * Each character is stored as a 32-bit
1497 for (i
= 0; i
< j
; i
++) {
1504 case 508: /* Get CPS */
1505 case 514: /* List elements */
1506 case 517: /* List owned */
1507 case 518: /* Get CPS2 */
1508 case 519: /* Get host CPS */
1512 j
= EXTRACT_32BITS(bp
);
1513 bp
+= sizeof(int32_t);
1514 for (i
= 0; i
< j
; i
++) {
1521 case 510: /* List max */
1532 * Otherwise, just print out the return code
1545 * Handle calls to the AFS volume location database service
1549 vldb_print(register const u_char
*bp
, int length
)
1554 if (length
<= sizeof(struct rx_header
))
1557 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1562 * Print out the afs call we're invoking. The table used here was
1563 * gleaned from vlserver/vldbint.xg
1566 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1570 if (is_ubik(vldb_op
)) {
1571 ubik_print(bp
, length
);
1574 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1577 * Decode some of the arguments to the VLDB calls
1580 bp
+= sizeof(struct rx_header
) + 4;
1583 case 501: /* Create new volume */
1584 case 517: /* Create entry N */
1587 case 502: /* Delete entry */
1588 case 503: /* Get entry by ID */
1589 case 507: /* Update entry */
1590 case 508: /* Set lock */
1591 case 509: /* Release lock */
1592 case 518: /* Get entry by ID N */
1595 TCHECK2(bp
[0], sizeof(int32_t));
1596 i
= EXTRACT_32BITS(bp
);
1597 bp
+= sizeof(int32_t);
1599 printf(" type %s", voltype
[i
]);
1601 case 504: /* Get entry by name */
1602 case 519: /* Get entry by name N */
1603 case 524: /* Update entry by name */
1604 case 527: /* Get entry by name U */
1607 case 505: /* Get new vol id */
1611 case 506: /* Replace entry */
1612 case 520: /* Replace entry N */
1615 TCHECK2(bp
[0], sizeof(int32_t));
1616 i
= EXTRACT_32BITS(bp
);
1617 bp
+= sizeof(int32_t);
1619 printf(" type %s", voltype
[i
]);
1622 case 510: /* List entry */
1623 case 521: /* List entry N */
1638 * Handle replies to the AFS volume location database service
1642 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1644 struct rx_header
*rxh
;
1647 if (length
< sizeof(struct rx_header
))
1650 rxh
= (struct rx_header
*) bp
;
1653 * Print out the afs call we're invoking. The table used here was
1654 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1655 * Ubik call, however.
1660 if (is_ubik(opcode
)) {
1661 ubik_reply_print(bp
, length
, opcode
);
1665 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1667 bp
+= sizeof(struct rx_header
);
1670 * If it was a data packet, interpret the response
1673 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1675 case 510: /* List entry */
1678 printf(" nextindex");
1680 case 503: /* Get entry by id */
1681 case 504: /* Get entry by name */
1682 { unsigned long nservers
, j
;
1684 TCHECK2(bp
[0], sizeof(int32_t));
1685 bp
+= sizeof(int32_t);
1686 printf(" numservers");
1687 TCHECK2(bp
[0], sizeof(int32_t));
1688 nservers
= EXTRACT_32BITS(bp
);
1689 bp
+= sizeof(int32_t);
1690 printf(" %lu", nservers
);
1692 for (i
= 0; i
< 8; i
++) {
1693 TCHECK2(bp
[0], sizeof(int32_t));
1696 inet_ntoa(*((struct in_addr
*) bp
)));
1697 bp
+= sizeof(int32_t);
1699 printf(" partitions");
1700 for (i
= 0; i
< 8; i
++) {
1701 TCHECK2(bp
[0], sizeof(int32_t));
1702 j
= EXTRACT_32BITS(bp
);
1703 if (i
< nservers
&& j
<= 26)
1704 printf(" %c", 'a' + (int)j
);
1705 else if (i
< nservers
)
1707 bp
+= sizeof(int32_t);
1709 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1710 bp
+= 8 * sizeof(int32_t);
1719 case 505: /* Get new volume ID */
1723 case 521: /* List entry */
1724 case 529: /* List entry U */
1727 printf(" nextindex");
1729 case 518: /* Get entry by ID N */
1730 case 519: /* Get entry by name N */
1731 { unsigned long nservers
, j
;
1733 printf(" numservers");
1734 TCHECK2(bp
[0], sizeof(int32_t));
1735 nservers
= EXTRACT_32BITS(bp
);
1736 bp
+= sizeof(int32_t);
1737 printf(" %lu", nservers
);
1739 for (i
= 0; i
< 13; i
++) {
1740 TCHECK2(bp
[0], sizeof(int32_t));
1743 inet_ntoa(*((struct in_addr
*) bp
)));
1744 bp
+= sizeof(int32_t);
1746 printf(" partitions");
1747 for (i
= 0; i
< 13; i
++) {
1748 TCHECK2(bp
[0], sizeof(int32_t));
1749 j
= EXTRACT_32BITS(bp
);
1750 if (i
< nservers
&& j
<= 26)
1751 printf(" %c", 'a' + (int)j
);
1752 else if (i
< nservers
)
1754 bp
+= sizeof(int32_t);
1756 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1757 bp
+= 13 * sizeof(int32_t);
1766 case 526: /* Get entry by ID U */
1767 case 527: /* Get entry by name U */
1768 { unsigned long nservers
, j
;
1770 printf(" numservers");
1771 TCHECK2(bp
[0], sizeof(int32_t));
1772 nservers
= EXTRACT_32BITS(bp
);
1773 bp
+= sizeof(int32_t);
1774 printf(" %lu", nservers
);
1776 for (i
= 0; i
< 13; i
++) {
1785 TCHECK2(bp
[0], 4 * 13);
1787 printf(" partitions");
1788 for (i
= 0; i
< 13; i
++) {
1789 TCHECK2(bp
[0], sizeof(int32_t));
1790 j
= EXTRACT_32BITS(bp
);
1791 if (i
< nservers
&& j
<= 26)
1792 printf(" %c", 'a' + (int)j
);
1793 else if (i
< nservers
)
1795 bp
+= sizeof(int32_t);
1797 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1798 bp
+= 13 * sizeof(int32_t);
1812 * Otherwise, just print out the return code
1825 * Handle calls to the AFS Kerberos Authentication service
1829 kauth_print(register const u_char
*bp
, int length
)
1833 if (length
<= sizeof(struct rx_header
))
1836 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1841 * Print out the afs call we're invoking. The table used here was
1842 * gleaned from kauth/kauth.rg
1845 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1849 if (is_ubik(kauth_op
)) {
1850 ubik_print(bp
, length
);
1855 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1858 * Decode some of the arguments to the KA calls
1861 bp
+= sizeof(struct rx_header
) + 4;
1864 case 1: /* Authenticate old */;
1865 case 21: /* Authenticate */
1866 case 22: /* Authenticate-V2 */
1867 case 2: /* Change PW */
1868 case 5: /* Set fields */
1869 case 6: /* Create user */
1870 case 7: /* Delete user */
1871 case 8: /* Get entry */
1872 case 14: /* Unlock */
1873 case 15: /* Lock status */
1874 printf(" principal");
1878 case 3: /* GetTicket-old */
1879 case 23: /* GetTicket */
1886 TCHECK2(bp
[0], sizeof(int32_t));
1887 i
= (int) EXTRACT_32BITS(bp
);
1888 bp
+= sizeof(int32_t);
1891 printf(" principal");
1896 case 4: /* Set Password */
1897 printf(" principal");
1903 case 12: /* Get password */
1914 printf(" [|kauth]");
1918 * Handle replies to the AFS Kerberos Authentication Service
1922 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1924 struct rx_header
*rxh
;
1926 if (length
<= sizeof(struct rx_header
))
1929 rxh
= (struct rx_header
*) bp
;
1932 * Print out the afs call we're invoking. The table used here was
1933 * gleaned from kauth/kauth.rg
1938 if (is_ubik(opcode
)) {
1939 ubik_reply_print(bp
, length
, opcode
);
1943 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1945 bp
+= sizeof(struct rx_header
);
1948 * If it was a data packet, interpret the response.
1951 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1952 /* Well, no, not really. Leave this for later */
1956 * Otherwise, just print out the return code
1965 printf(" [|kauth]");
1969 * Handle calls to the AFS Volume location service
1973 vol_print(register const u_char
*bp
, int length
)
1977 if (length
<= sizeof(struct rx_header
))
1980 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1985 * Print out the afs call we're invoking. The table used here was
1986 * gleaned from volser/volint.xg
1989 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1991 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1994 * Normally there would be a switch statement here to decode the
1995 * arguments to the AFS call, but since I don't have access to
1996 * an AFS server (yet) and I'm not an AFS admin, I can't
1997 * test any of these calls. Leave this blank for now.
2007 * Handle replies to the AFS Volume Service
2011 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2013 struct rx_header
*rxh
;
2015 if (length
<= sizeof(struct rx_header
))
2018 rxh
= (struct rx_header
*) bp
;
2021 * Print out the afs call we're invoking. The table used here was
2022 * gleaned from volser/volint.xg
2025 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
2027 bp
+= sizeof(struct rx_header
);
2030 * If it was a data packet, interpret the response.
2033 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2034 /* Well, no, not really. Leave this for later */
2038 * Otherwise, just print out the return code
2051 * Handle calls to the AFS BOS service
2055 bos_print(register const u_char
*bp
, int length
)
2059 if (length
<= sizeof(struct rx_header
))
2062 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
2067 * Print out the afs call we're invoking. The table used here was
2068 * gleaned from bozo/bosint.xg
2071 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2073 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2076 * Decode some of the arguments to the BOS calls
2079 bp
+= sizeof(struct rx_header
) + 4;
2082 case 80: /* Create B node */
2085 printf(" instance");
2088 case 81: /* Delete B node */
2089 case 83: /* Get status */
2090 case 85: /* Get instance info */
2091 case 87: /* Add super user */
2092 case 88: /* Delete super user */
2093 case 93: /* Set cell name */
2094 case 96: /* Add cell host */
2095 case 97: /* Delete cell host */
2096 case 104: /* Restart */
2097 case 106: /* Uninstall */
2098 case 108: /* Exec */
2099 case 112: /* Getlog */
2100 case 114: /* Get instance strings */
2103 case 82: /* Set status */
2104 case 98: /* Set T status */
2109 case 86: /* Get instance parm */
2114 case 84: /* Enumerate instance */
2115 case 89: /* List super users */
2116 case 90: /* List keys */
2117 case 91: /* Add key */
2118 case 92: /* Delete key */
2119 case 95: /* Get cell host */
2122 case 105: /* Install */
2142 * Handle replies to the AFS BOS Service
2146 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2148 struct rx_header
*rxh
;
2150 if (length
<= sizeof(struct rx_header
))
2153 rxh
= (struct rx_header
*) bp
;
2156 * Print out the afs call we're invoking. The table used here was
2157 * gleaned from volser/volint.xg
2160 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2162 bp
+= sizeof(struct rx_header
);
2165 * If it was a data packet, interpret the response.
2168 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2169 /* Well, no, not really. Leave this for later */
2173 * Otherwise, just print out the return code
2186 * Check to see if this is a Ubik opcode.
2190 is_ubik(u_int32_t opcode
)
2192 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2193 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2200 * Handle Ubik opcodes to any one of the replicated database services
2204 ubik_print(register const u_char
*bp
, int length
)
2210 * Print out the afs call we're invoking. The table used here was
2211 * gleaned from ubik/ubik_int.xg
2214 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2216 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2219 * Decode some of the arguments to the Ubik calls
2222 bp
+= sizeof(struct rx_header
) + 4;
2225 case 10000: /* Beacon */
2227 temp
= EXTRACT_32BITS(bp
);
2228 bp
+= sizeof(int32_t);
2229 printf(" syncsite %s", temp
? "yes" : "no");
2230 printf(" votestart");
2232 printf(" dbversion");
2237 case 10003: /* Get sync site */
2241 case 20000: /* Begin */
2242 case 20001: /* Commit */
2243 case 20007: /* Abort */
2244 case 20008: /* Release locks */
2245 case 20010: /* Writev */
2249 case 20002: /* Lock */
2258 temp
= EXTRACT_32BITS(bp
);
2259 bp
+= sizeof(int32_t);
2260 tok2str(ubik_lock_types
, "type %d", temp
);
2262 case 20003: /* Write */
2270 case 20005: /* Get file */
2274 case 20006: /* Send file */
2279 printf(" dbversion");
2282 case 20009: /* Truncate */
2290 case 20012: /* Set version */
2293 printf(" oldversion");
2295 printf(" newversion");
2309 * Handle Ubik replies to any one of the replicated database services
2313 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2315 struct rx_header
*rxh
;
2317 if (length
< sizeof(struct rx_header
))
2320 rxh
= (struct rx_header
*) bp
;
2323 * Print out the ubik call we're invoking. This table was gleaned
2324 * from ubik/ubik_int.xg
2327 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2329 bp
+= sizeof(struct rx_header
);
2332 * If it was a data packet, print out the arguments to the Ubik calls
2335 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2337 case 10000: /* Beacon */
2340 case 20004: /* Get version */
2341 printf(" dbversion");
2349 * Otherwise, print out "yes" it it was a beacon packet (because
2350 * that's how yes votes are returned, go figure), otherwise
2351 * just print out the error code.
2356 case 10000: /* Beacon */
2357 printf(" vote yes until");
2372 * Handle RX ACK packets.
2376 rx_ack_print(register const u_char
*bp
, int length
)
2378 struct rx_ackPacket
*rxa
;
2381 if (length
< sizeof(struct rx_header
))
2384 bp
+= sizeof(struct rx_header
);
2387 * This may seem a little odd .... the rx_ackPacket structure
2388 * contains an array of individual packet acknowledgements
2389 * (used for selective ack/nack), but since it's variable in size,
2390 * we don't want to truncate based on the size of the whole
2391 * rx_ackPacket structure.
2394 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2396 rxa
= (struct rx_ackPacket
*) bp
;
2397 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2400 * Print out a few useful things from the ack packet structure
2404 printf(" bufspace %d maxskew %d",
2405 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2406 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2408 printf(" first %d serial %d reason %s",
2409 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2410 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2413 * Okay, now we print out the ack array. The way _this_ works
2414 * is that we start at "first", and step through the ack array.
2415 * If we have a contiguous range of acks/nacks, try to
2416 * collapse them into a range.
2418 * If you're really clever, you might have noticed that this
2419 * doesn't seem quite correct. Specifically, due to structure
2420 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2421 * yield the start of the ack array (because RX_MAXACKS is 255
2422 * and the structure will likely get padded to a 2 or 4 byte
2423 * boundary). However, this is the way it's implemented inside
2424 * of AFS - the start of the extra fields are at
2425 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2426 * the exact start of the ack array. Sigh. That's why we aren't
2427 * using bp, but instead use rxa->acks[]. But nAcks gets added
2428 * to bp after this, so bp ends up at the right spot. Go figure.
2431 if (rxa
->nAcks
!= 0) {
2433 TCHECK2(bp
[0], rxa
->nAcks
);
2436 * Sigh, this is gross, but it seems to work to collapse
2440 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2441 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2444 * I figured this deserved _some_ explanation.
2445 * First, print "acked" and the packet seq
2446 * number if this is the first time we've
2447 * seen an acked packet.
2452 rxa
->firstPacket
+ i
);
2457 * Otherwise, if the there is a skip in
2458 * the range (such as an nacked packet in
2459 * the middle of some acked packets),
2460 * then print the current packet number
2461 * seperated from the last number by
2465 else if (last
!= i
- 1) {
2466 printf(",%d", rxa
->firstPacket
+ i
);
2471 * We always set last to the value of
2472 * the last ack we saw. Conversely, start
2473 * is set to the value of the first ack
2474 * we saw in a range.
2480 * Okay, this bit a code gets executed when
2481 * we hit a nack ... in _this_ case we
2482 * want to print out the range of packets
2483 * that were acked, so we need to print
2484 * the _previous_ packet number seperated
2485 * from the first by a dash (-). Since we
2486 * already printed the first packet above,
2487 * just print the final packet. Don't
2488 * do this if there will be a single-length
2491 } else if (last
== i
- 1 && start
!= last
)
2492 printf("-%d", rxa
->firstPacket
+ i
- 1);
2495 * So, what's going on here? We ran off the end of the
2496 * ack list, and if we got a range we need to finish it up.
2497 * So we need to determine if the last packet in the list
2498 * was an ack (if so, then last will be set to it) and
2499 * we need to see if the last range didn't start with the
2500 * last packet (because if it _did_, then that would mean
2501 * that the packet number has already been printed and
2502 * we don't need to print it again).
2505 if (last
== i
- 1 && start
!= last
)
2506 printf("-%d", rxa
->firstPacket
+ i
- 1);
2509 * Same as above, just without comments
2512 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2513 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2515 printf(" nacked %d",
2516 rxa
->firstPacket
+ i
);
2518 } else if (last
!= i
- 1) {
2519 printf(",%d", rxa
->firstPacket
+ i
);
2523 } else if (last
== i
- 1 && start
!= last
)
2524 printf("-%d", rxa
->firstPacket
+ i
- 1);
2526 if (last
== i
- 1 && start
!= last
)
2527 printf("-%d", rxa
->firstPacket
+ i
- 1);
2534 * These are optional fields; depending on your version of AFS,
2535 * you may or may not see them
2538 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2554 printf(" maxpackets");