]>
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.29 2002-04-30 06:45:08 guy Exp $";
47 #ifdef TIME_WITH_SYS_TIME
50 #include <sys/param.h>
52 #include <sys/types.h>
53 #include <sys/socket.h>
54 #include <netinet/in.h>
55 #include <arpa/inet.h>
57 #include "interface.h"
58 #include "addrtoname.h"
65 static struct tok rx_types
[] = {
66 { RX_PACKET_TYPE_DATA
, "data" },
67 { RX_PACKET_TYPE_ACK
, "ack" },
68 { RX_PACKET_TYPE_BUSY
, "busy" },
69 { RX_PACKET_TYPE_ABORT
, "abort" },
70 { RX_PACKET_TYPE_ACKALL
, "ackall" },
71 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
72 { RX_PACKET_TYPE_RESPONSE
, "response" },
73 { RX_PACKET_TYPE_DEBUG
, "debug" },
74 { RX_PACKET_TYPE_PARAMS
, "params" },
75 { RX_PACKET_TYPE_VERSION
, "version" },
79 static struct double_tok
{
80 int flag
; /* Rx flag */
81 int packetType
; /* Packet type */
82 char *s
; /* Flag string */
84 { RX_CLIENT_INITIATED
, 0, "client-init" },
85 { RX_REQUEST_ACK
, 0, "req-ack" },
86 { RX_LAST_PACKET
, 0, "last-pckt" },
87 { RX_MORE_PACKETS
, 0, "more-pckts" },
88 { RX_FREE_PACKET
, 0, "free-pckt" },
89 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
90 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
93 static struct tok fs_req
[] = {
94 { 130, "fetch-data" },
96 { 132, "fetch-status" },
97 { 133, "store-data" },
99 { 135, "store-status" },
100 { 136, "remove-file" },
101 { 137, "create-file" },
107 { 143, "oldsetlock" },
108 { 144, "oldextlock" },
109 { 145, "oldrellock" },
110 { 146, "get-stats" },
112 { 148, "get-vlinfo" },
113 { 149, "get-vlstats" },
114 { 150, "set-vlstats" },
115 { 151, "get-rootvl" },
116 { 152, "check-token" },
118 { 154, "nget-vlinfo" },
119 { 155, "bulk-stat" },
123 { 159, "xstat-ver" },
124 { 160, "get-xstat" },
125 { 161, "dfs-lookup" },
126 { 162, "dfs-flushcps" },
127 { 163, "dfs-symlink" },
128 { 220, "residency" },
132 static struct tok cb_req
[] = {
141 { 212, "whoareyou" },
143 { 214, "probeuuid" },
144 { 215, "getsrvprefs" },
145 { 216, "getcellservdb" },
146 { 217, "getlocalcell" },
147 { 218, "getcacheconf" },
151 static struct tok pt_req
[] = {
153 { 501, "where-is-it" },
154 { 502, "dump-entry" },
155 { 503, "add-to-group" },
156 { 504, "name-to-id" },
157 { 505, "id-to-name" },
159 { 507, "remove-from-group" },
161 { 509, "new-entry" },
164 { 512, "list-entry" },
165 { 513, "change-entry" },
166 { 514, "list-elements" },
167 { 515, "same-mbr-of" },
168 { 516, "set-fld-sentry" },
169 { 517, "list-owned" },
171 { 519, "get-host-cps" },
172 { 520, "update-entry" },
173 { 521, "list-entries" },
177 static struct tok vldb_req
[] = {
178 { 501, "create-entry" },
179 { 502, "delete-entry" },
180 { 503, "get-entry-by-id" },
181 { 504, "get-entry-by-name" },
182 { 505, "get-new-volume-id" },
183 { 506, "replace-entry" },
184 { 507, "update-entry" },
186 { 509, "releaselock" },
187 { 510, "list-entry" },
188 { 511, "list-attrib" },
189 { 512, "linked-list" },
190 { 513, "get-stats" },
192 { 515, "get-addrs" },
193 { 516, "change-addr" },
194 { 517, "create-entry-n" },
195 { 518, "get-entry-by-id-n" },
196 { 519, "get-entry-by-name-n" },
197 { 520, "replace-entry-n" },
198 { 521, "list-entry-n" },
199 { 522, "list-attrib-n" },
200 { 523, "linked-list-n" },
201 { 524, "update-entry-by-name" },
202 { 525, "create-entry-u" },
203 { 526, "get-entry-by-id-u" },
204 { 527, "get-entry-by-name-u" },
205 { 528, "replace-entry-u" },
206 { 529, "list-entry-u" },
207 { 530, "list-attrib-u" },
208 { 531, "linked-list-u" },
210 { 533, "get-addrs-u" },
211 { 534, "list-attrib-n2" },
215 static struct tok kauth_req
[] = {
217 { 21, "authenticate" },
218 { 22, "authenticate-v2" },
220 { 3, "get-ticket-old" },
221 { 23, "get-ticket" },
224 { 6, "create-user" },
225 { 7, "delete-user" },
231 { 13, "get-random-key" },
233 { 15, "lock-status" },
237 static struct tok vol_req
[] = {
238 { 100, "create-volume" },
239 { 101, "delete-volume" },
242 { 104, "end-trans" },
244 { 106, "set-flags" },
245 { 107, "get-flags" },
246 { 108, "trans-create" },
248 { 110, "get-nth-volume" },
249 { 111, "set-forwarding" },
251 { 113, "get-status" },
252 { 114, "sig-restore" },
253 { 115, "list-partitions" },
254 { 116, "list-volumes" },
255 { 117, "set-id-types" },
257 { 119, "partition-info" },
259 { 121, "list-one-volume" },
262 { 124, "x-list-volumes" },
263 { 125, "x-list-one-volume" },
265 { 127, "x-list-partitions" },
266 { 128, "forward-multiple" },
270 static struct tok bos_req
[] = {
271 { 80, "create-bnode" },
272 { 81, "delete-bnode" },
273 { 82, "set-status" },
274 { 83, "get-status" },
275 { 84, "enumerate-instance" },
276 { 85, "get-instance-info" },
277 { 86, "get-instance-parm" },
278 { 87, "add-superuser" },
279 { 88, "delete-superuser" },
280 { 89, "list-superusers" },
283 { 92, "delete-key" },
284 { 93, "set-cell-name" },
285 { 94, "get-cell-name" },
286 { 95, "get-cell-host" },
287 { 96, "add-cell-host" },
288 { 97, "delete-cell-host" },
289 { 98, "set-t-status" },
290 { 99, "shutdown-all" },
291 { 100, "restart-all" },
292 { 101, "startup-all" },
293 { 102, "set-noauth-flag" },
296 { 105, "start-bozo-install" },
297 { 106, "uninstall" },
298 { 107, "get-dates" },
301 { 110, "set-restart-time" },
302 { 111, "get-restart-time" },
303 { 112, "start-bozo-log" },
305 { 114, "get-instance-strings" },
306 { 115, "get-restricted" },
307 { 116, "set-restricted" },
311 static struct tok ubik_req
[] = {
312 { 10000, "vote-beacon" },
313 { 10001, "vote-debug-old" },
314 { 10002, "vote-sdebug-old" },
315 { 10003, "vote-getsyncsite" },
316 { 10004, "vote-debug" },
317 { 10005, "vote-sdebug" },
318 { 20000, "disk-begin" },
319 { 20001, "disk-commit" },
320 { 20002, "disk-lock" },
321 { 20003, "disk-write" },
322 { 20004, "disk-getversion" },
323 { 20005, "disk-getfile" },
324 { 20006, "disk-sendfile" },
325 { 20007, "disk-abort" },
326 { 20008, "disk-releaselocks" },
327 { 20009, "disk-truncate" },
328 { 20010, "disk-probe" },
329 { 20011, "disk-writev" },
330 { 20012, "disk-interfaceaddr" },
331 { 20013, "disk-setversion" },
335 #define VOTE_LOW 10000
336 #define VOTE_HIGH 10005
337 #define DISK_LOW 20000
338 #define DISK_HIGH 20013
340 static struct tok cb_types
[] = {
347 static struct tok ubik_lock_types
[] = {
354 static char *voltype
[] = { "read-write", "read-only", "backup" };
356 static struct tok afs_fs_errors
[] = {
357 { 101, "salvage volume" },
358 { 102, "no such vnode" },
359 { 103, "no such volume" },
360 { 104, "volume exist" },
361 { 105, "no service" },
362 { 106, "volume offline" },
363 { 107, "voline online" },
365 { 109, "diskquota exceeded" },
366 { 110, "volume busy" },
367 { 111, "volume moved" },
368 { 112, "AFS IO error" },
369 { -100, "restarting fileserver" },
374 * Reasons for acknowledging a packet
377 static struct tok rx_ack_reasons
[] = {
378 { 1, "ack requested" },
379 { 2, "duplicate packet" },
380 { 3, "out of sequence" },
381 { 4, "exceeds window" },
382 { 5, "no buffer space" },
384 { 7, "ping response" },
390 * Cache entries we keep around so we can figure out the RX opcode
391 * numbers for replies. This allows us to make sense of RX reply packets.
394 struct rx_cache_entry
{
395 u_int32_t callnum
; /* Call number (net order) */
396 struct in_addr client
; /* client IP address (net order) */
397 struct in_addr server
; /* server IP address (net order) */
398 int dport
; /* server port (host order) */
399 u_short serviceId
; /* Service identifier (net order) */
400 u_int32_t opcode
; /* RX opcode (host order) */
403 #define RX_CACHE_SIZE 64
405 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
407 static int rx_cache_next
= 0;
408 static int rx_cache_hint
= 0;
409 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
410 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
413 static void ack_print(const u_char
*, int);
414 static void fs_print(const u_char
*, int);
415 static void fs_reply_print(const u_char
*, int, int32_t);
416 static void acl_print(u_char
*, int, u_char
*);
417 static void cb_print(const u_char
*, int);
418 static void cb_reply_print(const u_char
*, int, int32_t);
419 static void prot_print(const u_char
*, int);
420 static void prot_reply_print(const u_char
*, int, int32_t);
421 static void vldb_print(const u_char
*, int);
422 static void vldb_reply_print(const u_char
*, int, int32_t);
423 static void kauth_print(const u_char
*, int);
424 static void kauth_reply_print(const u_char
*, int, int32_t);
425 static void vol_print(const u_char
*, int);
426 static void vol_reply_print(const u_char
*, int, int32_t);
427 static void bos_print(const u_char
*, int);
428 static void bos_reply_print(const u_char
*, int, int32_t);
429 static void ubik_print(const u_char
*, int);
430 static void ubik_reply_print(const u_char
*, int, int32_t);
432 static void rx_ack_print(const u_char
*, int);
434 static int is_ubik(u_int32_t
);
437 * Handle the rx-level packet. See if we know what port it's going to so
438 * we can peek at the afs call inside
442 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
445 register struct rx_header
*rxh
;
449 if (snapend
- bp
< sizeof (struct rx_header
)) {
450 printf(" [|rx] (%d)", length
);
454 rxh
= (struct rx_header
*) bp
;
456 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
462 printf(" cid %08x call# %d",
463 (int) EXTRACT_32BITS(&rxh
->cid
),
464 (int) EXTRACT_32BITS(&rxh
->callNumber
));
466 printf(" seq %d ser %d",
467 (int) EXTRACT_32BITS(&rxh
->seq
),
468 (int) EXTRACT_32BITS(&rxh
->serial
));
471 printf(" secindex %d serviceid %hu",
472 (int) rxh
->securityIndex
,
473 EXTRACT_16BITS(&rxh
->serviceId
));
476 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
477 if (rxh
->flags
& rx_flags
[i
].flag
&&
478 (!rx_flags
[i
].packetType
||
479 rxh
->type
== rx_flags
[i
].packetType
)) {
486 printf("<%s>", rx_flags
[i
].s
);
492 * Try to handle AFS calls that we know about. Check the destination
493 * port and make sure it's a data packet. Also, make sure the
494 * seq number is 1 (because otherwise it's a continuation packet,
495 * and we can't interpret that). Also, seems that reply packets
496 * do not have the client-init flag set, so we check for that
500 if (rxh
->type
== RX_PACKET_TYPE_ACK
)
501 ack_print(bp
, length
);
502 else if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
503 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
504 rxh
->flags
& RX_CLIENT_INITIATED
) {
507 * Insert this call into the call cache table, so we
508 * have a chance to print out replies
511 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
514 case FS_RX_PORT
: /* AFS file service */
515 fs_print(bp
, length
);
517 case CB_RX_PORT
: /* AFS callback service */
518 cb_print(bp
, length
);
520 case PROT_RX_PORT
: /* AFS protection service */
521 prot_print(bp
, length
);
523 case VLDB_RX_PORT
: /* AFS VLDB service */
524 vldb_print(bp
, length
);
526 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
527 kauth_print(bp
, length
);
529 case VOL_RX_PORT
: /* AFS Volume service */
530 vol_print(bp
, length
);
532 case BOS_RX_PORT
: /* AFS BOS service */
533 bos_print(bp
, length
);
540 * If it's a reply (client-init is _not_ set, but seq is one)
541 * then look it up in the cache. If we find it, call the reply
542 * printing functions Note that we handle abort packets here,
543 * because printing out the return code can be useful at times.
546 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
547 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
548 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
549 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
550 rx_cache_find(rxh
, (const struct ip
*) bp2
,
554 case FS_RX_PORT
: /* AFS file service */
555 fs_reply_print(bp
, length
, opcode
);
557 case CB_RX_PORT
: /* AFS callback service */
558 cb_reply_print(bp
, length
, opcode
);
560 case PROT_RX_PORT
: /* AFS PT service */
561 prot_reply_print(bp
, length
, opcode
);
563 case VLDB_RX_PORT
: /* AFS VLDB service */
564 vldb_reply_print(bp
, length
, opcode
);
566 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
567 kauth_reply_print(bp
, length
, opcode
);
569 case VOL_RX_PORT
: /* AFS Volume service */
570 vol_reply_print(bp
, length
, opcode
);
572 case BOS_RX_PORT
: /* AFS BOS service */
573 bos_reply_print(bp
, length
, opcode
);
580 * If it's an RX ack packet, then use the appropriate ack decoding
581 * function (there isn't any service-specific information in the
582 * ack packet, so we can use one for all AFS services)
585 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
586 rx_ack_print(bp
, length
);
589 printf(" (%d)", length
);
593 * Insert an entry into the cache. Taken from print-nfs.c
597 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
600 struct rx_cache_entry
*rxent
;
601 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
603 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
606 rxent
= &rx_cache
[rx_cache_next
];
608 if (++rx_cache_next
>= RX_CACHE_SIZE
)
611 rxent
->callnum
= rxh
->callNumber
;
612 rxent
->client
= ip
->ip_src
;
613 rxent
->server
= ip
->ip_dst
;
614 rxent
->dport
= dport
;
615 rxent
->serviceId
= rxh
->serviceId
;
616 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
620 * Lookup an entry in the cache. Also taken from print-nfs.c
622 * Note that because this is a reply, we're looking at the _source_
627 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
631 struct rx_cache_entry
*rxent
;
632 u_int32_t clip
= ip
->ip_dst
.s_addr
;
633 u_int32_t sip
= ip
->ip_src
.s_addr
;
635 /* Start the search where we last left off */
639 rxent
= &rx_cache
[i
];
640 if (rxent
->callnum
== rxh
->callNumber
&&
641 rxent
->client
.s_addr
== clip
&&
642 rxent
->server
.s_addr
== sip
&&
643 rxent
->serviceId
== rxh
->serviceId
&&
644 rxent
->dport
== sport
) {
646 /* We got a match! */
649 *opcode
= rxent
->opcode
;
652 if (++i
> RX_CACHE_SIZE
)
654 } while (i
!= rx_cache_hint
);
656 /* Our search failed */
661 * These extrememly grody macros handle the printing of various AFS stuff.
664 #define FIDOUT() { unsigned long n1, n2, n3; \
665 TCHECK2(bp[0], sizeof(int32_t) * 3); \
666 n1 = EXTRACT_32BITS(bp); \
667 bp += sizeof(int32_t); \
668 n2 = EXTRACT_32BITS(bp); \
669 bp += sizeof(int32_t); \
670 n3 = EXTRACT_32BITS(bp); \
671 bp += sizeof(int32_t); \
672 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
675 #define STROUT(MAX) { unsigned int i; \
676 TCHECK2(bp[0], sizeof(int32_t)); \
677 i = EXTRACT_32BITS(bp); \
680 bp += sizeof(int32_t); \
682 if (fn_printn(bp, i, snapend)) \
685 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
688 #define INTOUT() { int i; \
689 TCHECK2(bp[0], sizeof(int32_t)); \
690 i = (int) EXTRACT_32BITS(bp); \
691 bp += sizeof(int32_t); \
695 #define UINTOUT() { unsigned long i; \
696 TCHECK2(bp[0], sizeof(int32_t)); \
697 i = EXTRACT_32BITS(bp); \
698 bp += sizeof(int32_t); \
702 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
703 TCHECK2(bp[0], sizeof(int32_t)); \
704 t = (time_t) EXTRACT_32BITS(bp); \
705 bp += sizeof(int32_t); \
706 tm = localtime(&t); \
707 strftime(str, 256, "%Y/%m/%d %T", tm); \
708 printf(" %s", str); \
711 #define STOREATTROUT() { unsigned long mask, i; \
712 TCHECK2(bp[0], (sizeof(int32_t)*6)); \
713 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
714 if (mask) printf (" StoreStatus"); \
715 if (mask & 1) { printf(" date"); DATEOUT(); } \
716 else bp += sizeof(int32_t); \
717 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
718 if (mask & 2) printf(" owner %lu", i); \
719 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
720 if (mask & 4) printf(" group %lu", i); \
721 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
722 if (mask & 8) printf(" mode %lo", i & 07777); \
723 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
724 if (mask & 16) printf(" segsize %lu", i); \
725 /* undocumented in 3.3 docu */ \
726 if (mask & 1024) printf(" fsync"); \
729 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
730 TCHECK2(bp[0], sizeof(int32_t) * 2); \
731 epoch = EXTRACT_32BITS(bp); \
732 bp += sizeof(int32_t); \
733 counter = EXTRACT_32BITS(bp); \
734 bp += sizeof(int32_t); \
735 printf(" %d.%d", epoch, counter); \
738 #define AFSUUIDOUT() {u_int32_t temp; int i; \
739 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
740 temp = EXTRACT_32BITS(bp); \
741 bp += sizeof(u_int32_t); \
742 printf(" %08x", temp); \
743 temp = EXTRACT_32BITS(bp); \
744 bp += sizeof(u_int32_t); \
745 printf("%04x", temp); \
746 temp = EXTRACT_32BITS(bp); \
747 bp += sizeof(u_int32_t); \
748 printf("%04x", temp); \
749 for (i = 0; i < 8; i++) { \
750 temp = EXTRACT_32BITS(bp); \
751 bp += sizeof(u_int32_t); \
752 printf("%02x", (unsigned char) temp); \
757 * This is the sickest one of all
760 #define VECOUT(MAX) { u_char *sp; \
761 u_char s[AFSNAMEMAX]; \
763 if ((MAX) + 1 > sizeof(s)) \
765 TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
767 for (k = 0; k < (MAX); k++) { \
768 *sp++ = (u_char) EXTRACT_32BITS(bp); \
769 bp += sizeof(int32_t); \
778 ack_print(register const u_char
*bp
, int length
)
786 if (length
<= sizeof(struct rx_header
))
789 bp
+= sizeof(struct rx_header
);
792 * Packets < firstPacket are implicitly acknowledged and may
793 * be discarded by the sender.
795 * Packets >= firstPacket+nAcks are implicitly NOT acknowledged.
797 * No packets with sequence numbers >= firstPacket should be
798 * discarded by the sender (they may thrown out at any time by
801 #define RX_ACK_REASONS "RDOXSprn"
802 /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space,
803 * Ping, ping_Response, No_{progress, particular_reason}.
806 struct rx_ackPacket
{
807 u_short bufferSpace
; /* Skip! */
808 u_short maxSkew
; /* Skip! */
810 u_long previousPacket
; /* Obsolete! */
811 u_long serial
; /* Serial that prompted the ack, */
812 u_char reason
; /* and the reason why. */
814 u_char acks
[RX_MAXACKS
]; /* Selective acks (not a bitmap). */
817 #define RX_ACK_TYPE_NACK 0
819 TCHECK2(bp
[0], 8); /* bufferSpace and maxSkew */
821 printf(" fir %u", (unsigned)EXTRACT_32BITS(bp
));
823 TCHECK2(bp
[0], 8); /* previousPacket and serial */
825 printf(" %u", (unsigned)EXTRACT_32BITS(bp
));
828 printf("%c", RX_ACK_REASONS
[(*bp
- 1) & 07u]);
829 bp
+= 1; /* reason */
834 for (i
= 0; i
< nAcks
; i
++) {
836 putchar(*bp
== RX_ACK_TYPE_NACK
? '-' : '*');
847 * Handle calls to the AFS file service (fs)
851 fs_print(register const u_char
*bp
, int length
)
856 if (length
<= sizeof(struct rx_header
))
859 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
864 * Print out the afs call we're invoking. The table used here was
865 * gleaned from fsint/afsint.xg
868 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
870 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
873 * Print out arguments to some of the AFS calls. This stuff is
877 bp
+= sizeof(struct rx_header
) + 4;
880 * Sigh. This is gross. Ritchie forgive me.
884 case 130: /* Fetch data */
891 case 131: /* Fetch ACL */
892 case 132: /* Fetch Status */
893 case 143: /* Old set lock */
894 case 144: /* Old extend lock */
895 case 145: /* Old release lock */
896 case 156: /* Set lock */
897 case 157: /* Extend lock */
898 case 158: /* Release lock */
901 case 135: /* Store status */
905 case 133: /* Store data */
915 case 134: /* Store ACL */
917 char a
[AFSOPAQUEMAX
+1];
920 i
= EXTRACT_32BITS(bp
);
921 bp
+= sizeof(int32_t);
923 i
= min(AFSOPAQUEMAX
, i
);
924 strncpy(a
, (char *) bp
, i
);
926 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
929 case 137: /* Create file */
930 case 141: /* MakeDir */
935 case 136: /* Remove file */
936 case 142: /* Remove directory */
940 case 138: /* Rename file */
948 case 139: /* Symlink */
960 case 148: /* Get volume info */
963 case 149: /* Get volume stats */
964 case 150: /* Set volume stats */
968 case 154: /* New get volume info */
972 case 155: /* Bulk stat */
976 j
= EXTRACT_32BITS(bp
);
977 bp
+= sizeof(int32_t);
979 for (i
= 0; i
< j
; i
++) {
998 * Handle replies to the AFS file service
1002 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1005 struct rx_header
*rxh
;
1007 if (length
<= sizeof(struct rx_header
))
1010 rxh
= (struct rx_header
*) bp
;
1013 * Print out the afs call we're invoking. The table used here was
1014 * gleaned from fsint/afsint.xg
1017 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
1019 bp
+= sizeof(struct rx_header
);
1022 * If it was a data packet, interpret the response
1025 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
1027 case 131: /* Fetch ACL */
1029 char a
[AFSOPAQUEMAX
+1];
1031 i
= EXTRACT_32BITS(bp
);
1032 bp
+= sizeof(int32_t);
1034 i
= min(AFSOPAQUEMAX
, i
);
1035 strncpy(a
, (char *) bp
, i
);
1037 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1040 case 137: /* Create file */
1041 case 141: /* MakeDir */
1045 case 151: /* Get root volume */
1046 printf(" root volume");
1049 case 153: /* Get time */
1055 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1059 * Otherwise, just print out the return code
1061 TCHECK2(bp
[0], sizeof(int32_t));
1062 i
= (int) EXTRACT_32BITS(bp
);
1063 bp
+= sizeof(int32_t);
1065 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
1067 printf(" strange fs reply of type %d", rxh
->type
);
1077 * Print out an AFS ACL string. An AFS ACL is a string that has the
1080 * <positive> <negative>
1084 * "positive" and "negative" are integers which contain the number of
1085 * positive and negative ACL's in the string. The uid/aclbits pair are
1086 * ASCII strings containing the UID/PTS record and and a ascii number
1087 * representing a logical OR of all the ACL permission bits
1091 acl_print(u_char
*s
, int maxsize
, u_char
*end
)
1097 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1100 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1109 * This wacky order preserves the order used by the "fs" command
1112 #define ACLOUT(acl) \
1113 if (acl & PRSFS_READ) \
1115 if (acl & PRSFS_LOOKUP) \
1117 if (acl & PRSFS_INSERT) \
1119 if (acl & PRSFS_DELETE) \
1121 if (acl & PRSFS_WRITE) \
1123 if (acl & PRSFS_LOCK) \
1125 if (acl & PRSFS_ADMINISTER) \
1128 for (i
= 0; i
< pos
; i
++) {
1129 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1133 fn_print((u_char
*)user
, NULL
);
1141 for (i
= 0; i
< neg
; i
++) {
1142 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1146 fn_print((u_char
*)user
, NULL
);
1162 * Handle calls to the AFS callback service
1166 cb_print(register const u_char
*bp
, int length
)
1171 if (length
<= sizeof(struct rx_header
))
1174 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1179 * Print out the afs call we're invoking. The table used here was
1180 * gleaned from fsint/afscbint.xg
1183 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1185 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1187 bp
+= sizeof(struct rx_header
) + 4;
1190 * Print out the afs call we're invoking. The table used here was
1191 * gleaned from fsint/afscbint.xg
1195 case 204: /* Callback */
1199 j
= EXTRACT_32BITS(bp
);
1200 bp
+= sizeof(int32_t);
1202 for (i
= 0; i
< j
; i
++) {
1211 j
= EXTRACT_32BITS(bp
);
1212 bp
+= sizeof(int32_t);
1217 for (i
= 0; i
< j
; i
++) {
1223 t
= EXTRACT_32BITS(bp
);
1224 bp
+= sizeof(int32_t);
1225 tok2str(cb_types
, "type %d", t
);
1244 * Handle replies to the AFS Callback Service
1248 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1250 struct rx_header
*rxh
;
1252 if (length
<= sizeof(struct rx_header
))
1255 rxh
= (struct rx_header
*) bp
;
1258 * Print out the afs call we're invoking. The table used here was
1259 * gleaned from fsint/afscbint.xg
1262 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1264 bp
+= sizeof(struct rx_header
);
1267 * If it was a data packet, interpret the response.
1270 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1272 case 213: /* InitCallBackState3 */
1280 * Otherwise, just print out the return code
1293 * Handle calls to the AFS protection database server
1297 prot_print(register const u_char
*bp
, int length
)
1302 if (length
<= sizeof(struct rx_header
))
1305 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1310 * Print out the afs call we're invoking. The table used here was
1311 * gleaned from ptserver/ptint.xg
1314 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1318 if (is_ubik(pt_op
)) {
1319 ubik_print(bp
, length
);
1323 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1326 * Decode some of the arguments to the PT calls
1329 bp
+= sizeof(struct rx_header
) + 4;
1332 case 500: /* I New User */
1339 case 501: /* Where is it */
1340 case 506: /* Delete */
1341 case 508: /* Get CPS */
1342 case 512: /* List entry */
1343 case 514: /* List elements */
1344 case 517: /* List owned */
1345 case 518: /* Get CPS2 */
1346 case 519: /* Get host CPS */
1350 case 502: /* Dump entry */
1354 case 503: /* Add to group */
1355 case 507: /* Remove from group */
1356 case 515: /* Is a member of? */
1362 case 504: /* Name to ID */
1366 j
= EXTRACT_32BITS(bp
);
1367 bp
+= sizeof(int32_t);
1370 * Who designed this chicken-shit protocol?
1372 * Each character is stored as a 32-bit
1376 for (i
= 0; i
< j
; i
++) {
1383 case 505: /* Id to name */
1388 i
= EXTRACT_32BITS(bp
);
1389 bp
+= sizeof(int32_t);
1390 for (j
= 0; j
< i
; j
++)
1396 case 509: /* New entry */
1403 case 511: /* Set max */
1409 case 513: /* Change entry */
1418 case 520: /* Update entry */
1435 * Handle replies to the AFS protection service
1439 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1441 struct rx_header
*rxh
;
1444 if (length
< sizeof(struct rx_header
))
1447 rxh
= (struct rx_header
*) bp
;
1450 * Print out the afs call we're invoking. The table used here was
1451 * gleaned from ptserver/ptint.xg. Check to see if it's a
1452 * Ubik call, however.
1457 if (is_ubik(opcode
)) {
1458 ubik_reply_print(bp
, length
, opcode
);
1462 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1464 bp
+= sizeof(struct rx_header
);
1467 * If it was a data packet, interpret the response
1470 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1472 case 504: /* Name to ID */
1477 i
= EXTRACT_32BITS(bp
);
1478 bp
+= sizeof(int32_t);
1479 for (j
= 0; j
< i
; j
++)
1485 case 505: /* ID to name */
1489 j
= EXTRACT_32BITS(bp
);
1490 bp
+= sizeof(int32_t);
1493 * Who designed this chicken-shit protocol?
1495 * Each character is stored as a 32-bit
1499 for (i
= 0; i
< j
; i
++) {
1506 case 508: /* Get CPS */
1507 case 514: /* List elements */
1508 case 517: /* List owned */
1509 case 518: /* Get CPS2 */
1510 case 519: /* Get host CPS */
1514 j
= EXTRACT_32BITS(bp
);
1515 bp
+= sizeof(int32_t);
1516 for (i
= 0; i
< j
; i
++) {
1523 case 510: /* List max */
1534 * Otherwise, just print out the return code
1547 * Handle calls to the AFS volume location database service
1551 vldb_print(register const u_char
*bp
, int length
)
1556 if (length
<= sizeof(struct rx_header
))
1559 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1564 * Print out the afs call we're invoking. The table used here was
1565 * gleaned from vlserver/vldbint.xg
1568 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1572 if (is_ubik(vldb_op
)) {
1573 ubik_print(bp
, length
);
1576 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1579 * Decode some of the arguments to the VLDB calls
1582 bp
+= sizeof(struct rx_header
) + 4;
1585 case 501: /* Create new volume */
1586 case 517: /* Create entry N */
1589 case 502: /* Delete entry */
1590 case 503: /* Get entry by ID */
1591 case 507: /* Update entry */
1592 case 508: /* Set lock */
1593 case 509: /* Release lock */
1594 case 518: /* Get entry by ID N */
1597 TCHECK2(bp
[0], sizeof(int32_t));
1598 i
= EXTRACT_32BITS(bp
);
1599 bp
+= sizeof(int32_t);
1601 printf(" type %s", voltype
[i
]);
1603 case 504: /* Get entry by name */
1604 case 519: /* Get entry by name N */
1605 case 524: /* Update entry by name */
1606 case 527: /* Get entry by name U */
1609 case 505: /* Get new vol id */
1613 case 506: /* Replace entry */
1614 case 520: /* Replace entry N */
1617 TCHECK2(bp
[0], sizeof(int32_t));
1618 i
= EXTRACT_32BITS(bp
);
1619 bp
+= sizeof(int32_t);
1621 printf(" type %s", voltype
[i
]);
1624 case 510: /* List entry */
1625 case 521: /* List entry N */
1640 * Handle replies to the AFS volume location database service
1644 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1646 struct rx_header
*rxh
;
1649 if (length
< sizeof(struct rx_header
))
1652 rxh
= (struct rx_header
*) bp
;
1655 * Print out the afs call we're invoking. The table used here was
1656 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1657 * Ubik call, however.
1662 if (is_ubik(opcode
)) {
1663 ubik_reply_print(bp
, length
, opcode
);
1667 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1669 bp
+= sizeof(struct rx_header
);
1672 * If it was a data packet, interpret the response
1675 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1677 case 510: /* List entry */
1680 printf(" nextindex");
1682 case 503: /* Get entry by id */
1683 case 504: /* Get entry by name */
1684 { unsigned long nservers
, j
;
1686 TCHECK2(bp
[0], sizeof(int32_t));
1687 bp
+= sizeof(int32_t);
1688 printf(" numservers");
1689 TCHECK2(bp
[0], sizeof(int32_t));
1690 nservers
= EXTRACT_32BITS(bp
);
1691 bp
+= sizeof(int32_t);
1692 printf(" %lu", nservers
);
1694 for (i
= 0; i
< 8; i
++) {
1695 TCHECK2(bp
[0], sizeof(int32_t));
1698 inet_ntoa(*((struct in_addr
*) bp
)));
1699 bp
+= sizeof(int32_t);
1701 printf(" partitions");
1702 for (i
= 0; i
< 8; i
++) {
1703 TCHECK2(bp
[0], sizeof(int32_t));
1704 j
= EXTRACT_32BITS(bp
);
1705 if (i
< nservers
&& j
<= 26)
1706 printf(" %c", 'a' + (int)j
);
1707 else if (i
< nservers
)
1709 bp
+= sizeof(int32_t);
1711 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1712 bp
+= 8 * sizeof(int32_t);
1721 case 505: /* Get new volume ID */
1725 case 521: /* List entry */
1726 case 529: /* List entry U */
1729 printf(" nextindex");
1731 case 518: /* Get entry by ID N */
1732 case 519: /* Get entry by name N */
1733 { unsigned long nservers
, j
;
1735 printf(" numservers");
1736 TCHECK2(bp
[0], sizeof(int32_t));
1737 nservers
= EXTRACT_32BITS(bp
);
1738 bp
+= sizeof(int32_t);
1739 printf(" %lu", nservers
);
1741 for (i
= 0; i
< 13; i
++) {
1742 TCHECK2(bp
[0], sizeof(int32_t));
1745 inet_ntoa(*((struct in_addr
*) bp
)));
1746 bp
+= sizeof(int32_t);
1748 printf(" partitions");
1749 for (i
= 0; i
< 13; i
++) {
1750 TCHECK2(bp
[0], sizeof(int32_t));
1751 j
= EXTRACT_32BITS(bp
);
1752 if (i
< nservers
&& j
<= 26)
1753 printf(" %c", 'a' + (int)j
);
1754 else if (i
< nservers
)
1756 bp
+= sizeof(int32_t);
1758 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1759 bp
+= 13 * sizeof(int32_t);
1768 case 526: /* Get entry by ID U */
1769 case 527: /* Get entry by name U */
1770 { unsigned long nservers
, j
;
1772 printf(" numservers");
1773 TCHECK2(bp
[0], sizeof(int32_t));
1774 nservers
= EXTRACT_32BITS(bp
);
1775 bp
+= sizeof(int32_t);
1776 printf(" %lu", nservers
);
1778 for (i
= 0; i
< 13; i
++) {
1787 TCHECK2(bp
[0], 4 * 13);
1789 printf(" partitions");
1790 for (i
= 0; i
< 13; i
++) {
1791 TCHECK2(bp
[0], sizeof(int32_t));
1792 j
= EXTRACT_32BITS(bp
);
1793 if (i
< nservers
&& j
<= 26)
1794 printf(" %c", 'a' + (int)j
);
1795 else if (i
< nservers
)
1797 bp
+= sizeof(int32_t);
1799 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1800 bp
+= 13 * sizeof(int32_t);
1814 * Otherwise, just print out the return code
1827 * Handle calls to the AFS Kerberos Authentication service
1831 kauth_print(register const u_char
*bp
, int length
)
1835 if (length
<= sizeof(struct rx_header
))
1838 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1843 * Print out the afs call we're invoking. The table used here was
1844 * gleaned from kauth/kauth.rg
1847 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1851 if (is_ubik(kauth_op
)) {
1852 ubik_print(bp
, length
);
1857 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1860 * Decode some of the arguments to the KA calls
1863 bp
+= sizeof(struct rx_header
) + 4;
1866 case 1: /* Authenticate old */;
1867 case 21: /* Authenticate */
1868 case 22: /* Authenticate-V2 */
1869 case 2: /* Change PW */
1870 case 5: /* Set fields */
1871 case 6: /* Create user */
1872 case 7: /* Delete user */
1873 case 8: /* Get entry */
1874 case 14: /* Unlock */
1875 case 15: /* Lock status */
1876 printf(" principal");
1880 case 3: /* GetTicket-old */
1881 case 23: /* GetTicket */
1888 TCHECK2(bp
[0], sizeof(int32_t));
1889 i
= (int) EXTRACT_32BITS(bp
);
1890 bp
+= sizeof(int32_t);
1893 printf(" principal");
1898 case 4: /* Set Password */
1899 printf(" principal");
1905 case 12: /* Get password */
1916 printf(" [|kauth]");
1920 * Handle replies to the AFS Kerberos Authentication Service
1924 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1926 struct rx_header
*rxh
;
1928 if (length
<= sizeof(struct rx_header
))
1931 rxh
= (struct rx_header
*) bp
;
1934 * Print out the afs call we're invoking. The table used here was
1935 * gleaned from kauth/kauth.rg
1940 if (is_ubik(opcode
)) {
1941 ubik_reply_print(bp
, length
, opcode
);
1945 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1947 bp
+= sizeof(struct rx_header
);
1950 * If it was a data packet, interpret the response.
1953 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1954 /* Well, no, not really. Leave this for later */
1958 * Otherwise, just print out the return code
1967 printf(" [|kauth]");
1971 * Handle calls to the AFS Volume location service
1975 vol_print(register const u_char
*bp
, int length
)
1979 if (length
<= sizeof(struct rx_header
))
1982 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1987 * Print out the afs call we're invoking. The table used here was
1988 * gleaned from volser/volint.xg
1991 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1993 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1996 * Normally there would be a switch statement here to decode the
1997 * arguments to the AFS call, but since I don't have access to
1998 * an AFS server (yet) and I'm not an AFS admin, I can't
1999 * test any of these calls. Leave this blank for now.
2009 * Handle replies to the AFS Volume Service
2013 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2015 struct rx_header
*rxh
;
2017 if (length
<= sizeof(struct rx_header
))
2020 rxh
= (struct rx_header
*) bp
;
2023 * Print out the afs call we're invoking. The table used here was
2024 * gleaned from volser/volint.xg
2027 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
2029 bp
+= sizeof(struct rx_header
);
2032 * If it was a data packet, interpret the response.
2035 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2036 /* Well, no, not really. Leave this for later */
2040 * Otherwise, just print out the return code
2053 * Handle calls to the AFS BOS service
2057 bos_print(register const u_char
*bp
, int length
)
2061 if (length
<= sizeof(struct rx_header
))
2064 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
2069 * Print out the afs call we're invoking. The table used here was
2070 * gleaned from bozo/bosint.xg
2073 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2075 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2078 * Decode some of the arguments to the BOS calls
2081 bp
+= sizeof(struct rx_header
) + 4;
2084 case 80: /* Create B node */
2087 printf(" instance");
2090 case 81: /* Delete B node */
2091 case 83: /* Get status */
2092 case 85: /* Get instance info */
2093 case 87: /* Add super user */
2094 case 88: /* Delete super user */
2095 case 93: /* Set cell name */
2096 case 96: /* Add cell host */
2097 case 97: /* Delete cell host */
2098 case 104: /* Restart */
2099 case 106: /* Uninstall */
2100 case 108: /* Exec */
2101 case 112: /* Getlog */
2102 case 114: /* Get instance strings */
2105 case 82: /* Set status */
2106 case 98: /* Set T status */
2111 case 86: /* Get instance parm */
2116 case 84: /* Enumerate instance */
2117 case 89: /* List super users */
2118 case 90: /* List keys */
2119 case 91: /* Add key */
2120 case 92: /* Delete key */
2121 case 95: /* Get cell host */
2124 case 105: /* Install */
2144 * Handle replies to the AFS BOS Service
2148 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2150 struct rx_header
*rxh
;
2152 if (length
<= sizeof(struct rx_header
))
2155 rxh
= (struct rx_header
*) bp
;
2158 * Print out the afs call we're invoking. The table used here was
2159 * gleaned from volser/volint.xg
2162 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2164 bp
+= sizeof(struct rx_header
);
2167 * If it was a data packet, interpret the response.
2170 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2171 /* Well, no, not really. Leave this for later */
2175 * Otherwise, just print out the return code
2188 * Check to see if this is a Ubik opcode.
2192 is_ubik(u_int32_t opcode
)
2194 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2195 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2202 * Handle Ubik opcodes to any one of the replicated database services
2206 ubik_print(register const u_char
*bp
, int length
)
2212 * Print out the afs call we're invoking. The table used here was
2213 * gleaned from ubik/ubik_int.xg
2216 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2218 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2221 * Decode some of the arguments to the Ubik calls
2224 bp
+= sizeof(struct rx_header
) + 4;
2227 case 10000: /* Beacon */
2229 temp
= EXTRACT_32BITS(bp
);
2230 bp
+= sizeof(int32_t);
2231 printf(" syncsite %s", temp
? "yes" : "no");
2232 printf(" votestart");
2234 printf(" dbversion");
2239 case 10003: /* Get sync site */
2243 case 20000: /* Begin */
2244 case 20001: /* Commit */
2245 case 20007: /* Abort */
2246 case 20008: /* Release locks */
2247 case 20010: /* Writev */
2251 case 20002: /* Lock */
2260 temp
= EXTRACT_32BITS(bp
);
2261 bp
+= sizeof(int32_t);
2262 tok2str(ubik_lock_types
, "type %d", temp
);
2264 case 20003: /* Write */
2272 case 20005: /* Get file */
2276 case 20006: /* Send file */
2281 printf(" dbversion");
2284 case 20009: /* Truncate */
2292 case 20012: /* Set version */
2295 printf(" oldversion");
2297 printf(" newversion");
2311 * Handle Ubik replies to any one of the replicated database services
2315 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2317 struct rx_header
*rxh
;
2319 if (length
< sizeof(struct rx_header
))
2322 rxh
= (struct rx_header
*) bp
;
2325 * Print out the ubik call we're invoking. This table was gleaned
2326 * from ubik/ubik_int.xg
2329 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2331 bp
+= sizeof(struct rx_header
);
2334 * If it was a data packet, print out the arguments to the Ubik calls
2337 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2339 case 10000: /* Beacon */
2342 case 20004: /* Get version */
2343 printf(" dbversion");
2351 * Otherwise, print out "yes" it it was a beacon packet (because
2352 * that's how yes votes are returned, go figure), otherwise
2353 * just print out the error code.
2358 case 10000: /* Beacon */
2359 printf(" vote yes until");
2374 * Handle RX ACK packets.
2378 rx_ack_print(register const u_char
*bp
, int length
)
2380 struct rx_ackPacket
*rxa
;
2383 if (length
< sizeof(struct rx_header
))
2386 bp
+= sizeof(struct rx_header
);
2389 * This may seem a little odd .... the rx_ackPacket structure
2390 * contains an array of individual packet acknowledgements
2391 * (used for selective ack/nack), but since it's variable in size,
2392 * we don't want to truncate based on the size of the whole
2393 * rx_ackPacket structure.
2396 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2398 rxa
= (struct rx_ackPacket
*) bp
;
2399 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2402 * Print out a few useful things from the ack packet structure
2406 printf(" bufspace %d maxskew %d",
2407 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2408 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2410 printf(" first %d serial %d reason %s",
2411 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2412 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2415 * Okay, now we print out the ack array. The way _this_ works
2416 * is that we start at "first", and step through the ack array.
2417 * If we have a contiguous range of acks/nacks, try to
2418 * collapse them into a range.
2420 * If you're really clever, you might have noticed that this
2421 * doesn't seem quite correct. Specifically, due to structure
2422 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2423 * yield the start of the ack array (because RX_MAXACKS is 255
2424 * and the structure will likely get padded to a 2 or 4 byte
2425 * boundary). However, this is the way it's implemented inside
2426 * of AFS - the start of the extra fields are at
2427 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2428 * the exact start of the ack array. Sigh. That's why we aren't
2429 * using bp, but instead use rxa->acks[]. But nAcks gets added
2430 * to bp after this, so bp ends up at the right spot. Go figure.
2433 if (rxa
->nAcks
!= 0) {
2435 TCHECK2(bp
[0], rxa
->nAcks
);
2438 * Sigh, this is gross, but it seems to work to collapse
2442 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2443 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2446 * I figured this deserved _some_ explanation.
2447 * First, print "acked" and the packet seq
2448 * number if this is the first time we've
2449 * seen an acked packet.
2454 rxa
->firstPacket
+ i
);
2459 * Otherwise, if the there is a skip in
2460 * the range (such as an nacked packet in
2461 * the middle of some acked packets),
2462 * then print the current packet number
2463 * seperated from the last number by
2467 else if (last
!= i
- 1) {
2468 printf(",%d", rxa
->firstPacket
+ i
);
2473 * We always set last to the value of
2474 * the last ack we saw. Conversely, start
2475 * is set to the value of the first ack
2476 * we saw in a range.
2482 * Okay, this bit a code gets executed when
2483 * we hit a nack ... in _this_ case we
2484 * want to print out the range of packets
2485 * that were acked, so we need to print
2486 * the _previous_ packet number seperated
2487 * from the first by a dash (-). Since we
2488 * already printed the first packet above,
2489 * just print the final packet. Don't
2490 * do this if there will be a single-length
2493 } else if (last
== i
- 1 && start
!= last
)
2494 printf("-%d", rxa
->firstPacket
+ i
- 1);
2497 * So, what's going on here? We ran off the end of the
2498 * ack list, and if we got a range we need to finish it up.
2499 * So we need to determine if the last packet in the list
2500 * was an ack (if so, then last will be set to it) and
2501 * we need to see if the last range didn't start with the
2502 * last packet (because if it _did_, then that would mean
2503 * that the packet number has already been printed and
2504 * we don't need to print it again).
2507 if (last
== i
- 1 && start
!= last
)
2508 printf("-%d", rxa
->firstPacket
+ i
- 1);
2511 * Same as above, just without comments
2514 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2515 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2517 printf(" nacked %d",
2518 rxa
->firstPacket
+ i
);
2520 } else if (last
!= i
- 1) {
2521 printf(",%d", rxa
->firstPacket
+ i
);
2525 } else if (last
== i
- 1 && start
!= last
)
2526 printf("-%d", rxa
->firstPacket
+ i
- 1);
2528 if (last
== i
- 1 && start
!= last
)
2529 printf("-%d", rxa
->firstPacket
+ i
- 1);
2536 * These are optional fields; depending on your version of AFS,
2537 * you may or may not see them
2540 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2556 printf(" maxpackets");