]>
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.31 2002-08-01 08:53:27 risso Exp $";
47 #ifdef TIME_WITH_SYS_TIME
50 #include <tcpdump-stdinc.h>
52 #include "interface.h"
53 #include "addrtoname.h"
60 static struct tok rx_types
[] = {
61 { RX_PACKET_TYPE_DATA
, "data" },
62 { RX_PACKET_TYPE_ACK
, "ack" },
63 { RX_PACKET_TYPE_BUSY
, "busy" },
64 { RX_PACKET_TYPE_ABORT
, "abort" },
65 { RX_PACKET_TYPE_ACKALL
, "ackall" },
66 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
67 { RX_PACKET_TYPE_RESPONSE
, "response" },
68 { RX_PACKET_TYPE_DEBUG
, "debug" },
69 { RX_PACKET_TYPE_PARAMS
, "params" },
70 { RX_PACKET_TYPE_VERSION
, "version" },
74 static struct double_tok
{
75 int flag
; /* Rx flag */
76 int packetType
; /* Packet type */
77 char *s
; /* Flag string */
79 { RX_CLIENT_INITIATED
, 0, "client-init" },
80 { RX_REQUEST_ACK
, 0, "req-ack" },
81 { RX_LAST_PACKET
, 0, "last-pckt" },
82 { RX_MORE_PACKETS
, 0, "more-pckts" },
83 { RX_FREE_PACKET
, 0, "free-pckt" },
84 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
85 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
88 static struct tok fs_req
[] = {
89 { 130, "fetch-data" },
91 { 132, "fetch-status" },
92 { 133, "store-data" },
94 { 135, "store-status" },
95 { 136, "remove-file" },
96 { 137, "create-file" },
102 { 143, "oldsetlock" },
103 { 144, "oldextlock" },
104 { 145, "oldrellock" },
105 { 146, "get-stats" },
107 { 148, "get-vlinfo" },
108 { 149, "get-vlstats" },
109 { 150, "set-vlstats" },
110 { 151, "get-rootvl" },
111 { 152, "check-token" },
113 { 154, "nget-vlinfo" },
114 { 155, "bulk-stat" },
118 { 159, "xstat-ver" },
119 { 160, "get-xstat" },
120 { 161, "dfs-lookup" },
121 { 162, "dfs-flushcps" },
122 { 163, "dfs-symlink" },
123 { 220, "residency" },
127 static struct tok cb_req
[] = {
136 { 212, "whoareyou" },
138 { 214, "probeuuid" },
139 { 215, "getsrvprefs" },
140 { 216, "getcellservdb" },
141 { 217, "getlocalcell" },
142 { 218, "getcacheconf" },
146 static struct tok pt_req
[] = {
148 { 501, "where-is-it" },
149 { 502, "dump-entry" },
150 { 503, "add-to-group" },
151 { 504, "name-to-id" },
152 { 505, "id-to-name" },
154 { 507, "remove-from-group" },
156 { 509, "new-entry" },
159 { 512, "list-entry" },
160 { 513, "change-entry" },
161 { 514, "list-elements" },
162 { 515, "same-mbr-of" },
163 { 516, "set-fld-sentry" },
164 { 517, "list-owned" },
166 { 519, "get-host-cps" },
167 { 520, "update-entry" },
168 { 521, "list-entries" },
172 static struct tok vldb_req
[] = {
173 { 501, "create-entry" },
174 { 502, "delete-entry" },
175 { 503, "get-entry-by-id" },
176 { 504, "get-entry-by-name" },
177 { 505, "get-new-volume-id" },
178 { 506, "replace-entry" },
179 { 507, "update-entry" },
181 { 509, "releaselock" },
182 { 510, "list-entry" },
183 { 511, "list-attrib" },
184 { 512, "linked-list" },
185 { 513, "get-stats" },
187 { 515, "get-addrs" },
188 { 516, "change-addr" },
189 { 517, "create-entry-n" },
190 { 518, "get-entry-by-id-n" },
191 { 519, "get-entry-by-name-n" },
192 { 520, "replace-entry-n" },
193 { 521, "list-entry-n" },
194 { 522, "list-attrib-n" },
195 { 523, "linked-list-n" },
196 { 524, "update-entry-by-name" },
197 { 525, "create-entry-u" },
198 { 526, "get-entry-by-id-u" },
199 { 527, "get-entry-by-name-u" },
200 { 528, "replace-entry-u" },
201 { 529, "list-entry-u" },
202 { 530, "list-attrib-u" },
203 { 531, "linked-list-u" },
205 { 533, "get-addrs-u" },
206 { 534, "list-attrib-n2" },
210 static struct tok kauth_req
[] = {
212 { 21, "authenticate" },
213 { 22, "authenticate-v2" },
215 { 3, "get-ticket-old" },
216 { 23, "get-ticket" },
219 { 6, "create-user" },
220 { 7, "delete-user" },
226 { 13, "get-random-key" },
228 { 15, "lock-status" },
232 static struct tok vol_req
[] = {
233 { 100, "create-volume" },
234 { 101, "delete-volume" },
237 { 104, "end-trans" },
239 { 106, "set-flags" },
240 { 107, "get-flags" },
241 { 108, "trans-create" },
243 { 110, "get-nth-volume" },
244 { 111, "set-forwarding" },
246 { 113, "get-status" },
247 { 114, "sig-restore" },
248 { 115, "list-partitions" },
249 { 116, "list-volumes" },
250 { 117, "set-id-types" },
252 { 119, "partition-info" },
254 { 121, "list-one-volume" },
257 { 124, "x-list-volumes" },
258 { 125, "x-list-one-volume" },
260 { 127, "x-list-partitions" },
261 { 128, "forward-multiple" },
265 static struct tok bos_req
[] = {
266 { 80, "create-bnode" },
267 { 81, "delete-bnode" },
268 { 82, "set-status" },
269 { 83, "get-status" },
270 { 84, "enumerate-instance" },
271 { 85, "get-instance-info" },
272 { 86, "get-instance-parm" },
273 { 87, "add-superuser" },
274 { 88, "delete-superuser" },
275 { 89, "list-superusers" },
278 { 92, "delete-key" },
279 { 93, "set-cell-name" },
280 { 94, "get-cell-name" },
281 { 95, "get-cell-host" },
282 { 96, "add-cell-host" },
283 { 97, "delete-cell-host" },
284 { 98, "set-t-status" },
285 { 99, "shutdown-all" },
286 { 100, "restart-all" },
287 { 101, "startup-all" },
288 { 102, "set-noauth-flag" },
291 { 105, "start-bozo-install" },
292 { 106, "uninstall" },
293 { 107, "get-dates" },
296 { 110, "set-restart-time" },
297 { 111, "get-restart-time" },
298 { 112, "start-bozo-log" },
300 { 114, "get-instance-strings" },
301 { 115, "get-restricted" },
302 { 116, "set-restricted" },
306 static struct tok ubik_req
[] = {
307 { 10000, "vote-beacon" },
308 { 10001, "vote-debug-old" },
309 { 10002, "vote-sdebug-old" },
310 { 10003, "vote-getsyncsite" },
311 { 10004, "vote-debug" },
312 { 10005, "vote-sdebug" },
313 { 20000, "disk-begin" },
314 { 20001, "disk-commit" },
315 { 20002, "disk-lock" },
316 { 20003, "disk-write" },
317 { 20004, "disk-getversion" },
318 { 20005, "disk-getfile" },
319 { 20006, "disk-sendfile" },
320 { 20007, "disk-abort" },
321 { 20008, "disk-releaselocks" },
322 { 20009, "disk-truncate" },
323 { 20010, "disk-probe" },
324 { 20011, "disk-writev" },
325 { 20012, "disk-interfaceaddr" },
326 { 20013, "disk-setversion" },
330 #define VOTE_LOW 10000
331 #define VOTE_HIGH 10005
332 #define DISK_LOW 20000
333 #define DISK_HIGH 20013
335 static struct tok cb_types
[] = {
342 static struct tok ubik_lock_types
[] = {
349 static char *voltype
[] = { "read-write", "read-only", "backup" };
351 static struct tok afs_fs_errors
[] = {
352 { 101, "salvage volume" },
353 { 102, "no such vnode" },
354 { 103, "no such volume" },
355 { 104, "volume exist" },
356 { 105, "no service" },
357 { 106, "volume offline" },
358 { 107, "voline online" },
360 { 109, "diskquota exceeded" },
361 { 110, "volume busy" },
362 { 111, "volume moved" },
363 { 112, "AFS IO error" },
364 { -100, "restarting fileserver" },
369 * Reasons for acknowledging a packet
372 static struct tok rx_ack_reasons
[] = {
373 { 1, "ack requested" },
374 { 2, "duplicate packet" },
375 { 3, "out of sequence" },
376 { 4, "exceeds window" },
377 { 5, "no buffer space" },
379 { 7, "ping response" },
385 * Cache entries we keep around so we can figure out the RX opcode
386 * numbers for replies. This allows us to make sense of RX reply packets.
389 struct rx_cache_entry
{
390 u_int32_t callnum
; /* Call number (net order) */
391 struct in_addr client
; /* client IP address (net order) */
392 struct in_addr server
; /* server IP address (net order) */
393 int dport
; /* server port (host order) */
394 u_short serviceId
; /* Service identifier (net order) */
395 u_int32_t opcode
; /* RX opcode (host order) */
398 #define RX_CACHE_SIZE 64
400 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
402 static int rx_cache_next
= 0;
403 static int rx_cache_hint
= 0;
404 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
405 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
408 static void ack_print(const u_char
*, int);
409 static void fs_print(const u_char
*, int);
410 static void fs_reply_print(const u_char
*, int, int32_t);
411 static void acl_print(u_char
*, int, u_char
*);
412 static void cb_print(const u_char
*, int);
413 static void cb_reply_print(const u_char
*, int, int32_t);
414 static void prot_print(const u_char
*, int);
415 static void prot_reply_print(const u_char
*, int, int32_t);
416 static void vldb_print(const u_char
*, int);
417 static void vldb_reply_print(const u_char
*, int, int32_t);
418 static void kauth_print(const u_char
*, int);
419 static void kauth_reply_print(const u_char
*, int, int32_t);
420 static void vol_print(const u_char
*, int);
421 static void vol_reply_print(const u_char
*, int, int32_t);
422 static void bos_print(const u_char
*, int);
423 static void bos_reply_print(const u_char
*, int, int32_t);
424 static void ubik_print(const u_char
*, int);
425 static void ubik_reply_print(const u_char
*, int, int32_t);
427 static void rx_ack_print(const u_char
*, int);
429 static int is_ubik(u_int32_t
);
432 * Handle the rx-level packet. See if we know what port it's going to so
433 * we can peek at the afs call inside
437 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
440 register struct rx_header
*rxh
;
444 if (snapend
- bp
< sizeof (struct rx_header
)) {
445 printf(" [|rx] (%d)", length
);
449 rxh
= (struct rx_header
*) bp
;
451 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
457 printf(" cid %08x call# %d",
458 (int) EXTRACT_32BITS(&rxh
->cid
),
459 (int) EXTRACT_32BITS(&rxh
->callNumber
));
461 printf(" seq %d ser %d",
462 (int) EXTRACT_32BITS(&rxh
->seq
),
463 (int) EXTRACT_32BITS(&rxh
->serial
));
466 printf(" secindex %d serviceid %hu",
467 (int) rxh
->securityIndex
,
468 EXTRACT_16BITS(&rxh
->serviceId
));
471 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
472 if (rxh
->flags
& rx_flags
[i
].flag
&&
473 (!rx_flags
[i
].packetType
||
474 rxh
->type
== rx_flags
[i
].packetType
)) {
481 printf("<%s>", rx_flags
[i
].s
);
487 * Try to handle AFS calls that we know about. Check the destination
488 * port and make sure it's a data packet. Also, make sure the
489 * seq number is 1 (because otherwise it's a continuation packet,
490 * and we can't interpret that). Also, seems that reply packets
491 * do not have the client-init flag set, so we check for that
495 if (rxh
->type
== RX_PACKET_TYPE_ACK
)
496 ack_print(bp
, length
);
497 else if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
498 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
499 rxh
->flags
& RX_CLIENT_INITIATED
) {
502 * Insert this call into the call cache table, so we
503 * have a chance to print out replies
506 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
509 case FS_RX_PORT
: /* AFS file service */
510 fs_print(bp
, length
);
512 case CB_RX_PORT
: /* AFS callback service */
513 cb_print(bp
, length
);
515 case PROT_RX_PORT
: /* AFS protection service */
516 prot_print(bp
, length
);
518 case VLDB_RX_PORT
: /* AFS VLDB service */
519 vldb_print(bp
, length
);
521 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
522 kauth_print(bp
, length
);
524 case VOL_RX_PORT
: /* AFS Volume service */
525 vol_print(bp
, length
);
527 case BOS_RX_PORT
: /* AFS BOS service */
528 bos_print(bp
, length
);
535 * If it's a reply (client-init is _not_ set, but seq is one)
536 * then look it up in the cache. If we find it, call the reply
537 * printing functions Note that we handle abort packets here,
538 * because printing out the return code can be useful at times.
541 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
542 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
543 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
544 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
545 rx_cache_find(rxh
, (const struct ip
*) bp2
,
549 case FS_RX_PORT
: /* AFS file service */
550 fs_reply_print(bp
, length
, opcode
);
552 case CB_RX_PORT
: /* AFS callback service */
553 cb_reply_print(bp
, length
, opcode
);
555 case PROT_RX_PORT
: /* AFS PT service */
556 prot_reply_print(bp
, length
, opcode
);
558 case VLDB_RX_PORT
: /* AFS VLDB service */
559 vldb_reply_print(bp
, length
, opcode
);
561 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
562 kauth_reply_print(bp
, length
, opcode
);
564 case VOL_RX_PORT
: /* AFS Volume service */
565 vol_reply_print(bp
, length
, opcode
);
567 case BOS_RX_PORT
: /* AFS BOS service */
568 bos_reply_print(bp
, length
, opcode
);
575 * If it's an RX ack packet, then use the appropriate ack decoding
576 * function (there isn't any service-specific information in the
577 * ack packet, so we can use one for all AFS services)
580 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
581 rx_ack_print(bp
, length
);
584 printf(" (%d)", length
);
588 * Insert an entry into the cache. Taken from print-nfs.c
592 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
595 struct rx_cache_entry
*rxent
;
596 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
598 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
601 rxent
= &rx_cache
[rx_cache_next
];
603 if (++rx_cache_next
>= RX_CACHE_SIZE
)
606 rxent
->callnum
= rxh
->callNumber
;
607 rxent
->client
= ip
->ip_src
;
608 rxent
->server
= ip
->ip_dst
;
609 rxent
->dport
= dport
;
610 rxent
->serviceId
= rxh
->serviceId
;
611 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
615 * Lookup an entry in the cache. Also taken from print-nfs.c
617 * Note that because this is a reply, we're looking at the _source_
622 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
626 struct rx_cache_entry
*rxent
;
627 u_int32_t clip
= ip
->ip_dst
.s_addr
;
628 u_int32_t sip
= ip
->ip_src
.s_addr
;
630 /* Start the search where we last left off */
634 rxent
= &rx_cache
[i
];
635 if (rxent
->callnum
== rxh
->callNumber
&&
636 rxent
->client
.s_addr
== clip
&&
637 rxent
->server
.s_addr
== sip
&&
638 rxent
->serviceId
== rxh
->serviceId
&&
639 rxent
->dport
== sport
) {
641 /* We got a match! */
644 *opcode
= rxent
->opcode
;
647 if (++i
> RX_CACHE_SIZE
)
649 } while (i
!= rx_cache_hint
);
651 /* Our search failed */
656 * These extrememly grody macros handle the printing of various AFS stuff.
659 #define FIDOUT() { unsigned long n1, n2, n3; \
660 TCHECK2(bp[0], sizeof(int32_t) * 3); \
661 n1 = EXTRACT_32BITS(bp); \
662 bp += sizeof(int32_t); \
663 n2 = EXTRACT_32BITS(bp); \
664 bp += sizeof(int32_t); \
665 n3 = EXTRACT_32BITS(bp); \
666 bp += sizeof(int32_t); \
667 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
670 #define STROUT(MAX) { unsigned int i; \
671 TCHECK2(bp[0], sizeof(int32_t)); \
672 i = EXTRACT_32BITS(bp); \
675 bp += sizeof(int32_t); \
677 if (fn_printn(bp, i, snapend)) \
680 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
683 #define INTOUT() { int i; \
684 TCHECK2(bp[0], sizeof(int32_t)); \
685 i = (int) EXTRACT_32BITS(bp); \
686 bp += sizeof(int32_t); \
690 #define UINTOUT() { unsigned long i; \
691 TCHECK2(bp[0], sizeof(int32_t)); \
692 i = EXTRACT_32BITS(bp); \
693 bp += sizeof(int32_t); \
697 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
698 TCHECK2(bp[0], sizeof(int32_t)); \
699 t = (time_t) EXTRACT_32BITS(bp); \
700 bp += sizeof(int32_t); \
701 tm = localtime(&t); \
702 strftime(str, 256, "%Y/%m/%d %T", tm); \
703 printf(" %s", str); \
706 #define STOREATTROUT() { unsigned long mask, i; \
707 TCHECK2(bp[0], (sizeof(int32_t)*6)); \
708 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
709 if (mask) printf (" StoreStatus"); \
710 if (mask & 1) { printf(" date"); DATEOUT(); } \
711 else bp += sizeof(int32_t); \
712 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
713 if (mask & 2) printf(" owner %lu", i); \
714 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
715 if (mask & 4) printf(" group %lu", i); \
716 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
717 if (mask & 8) printf(" mode %lo", i & 07777); \
718 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
719 if (mask & 16) printf(" segsize %lu", i); \
720 /* undocumented in 3.3 docu */ \
721 if (mask & 1024) printf(" fsync"); \
724 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
725 TCHECK2(bp[0], sizeof(int32_t) * 2); \
726 epoch = EXTRACT_32BITS(bp); \
727 bp += sizeof(int32_t); \
728 counter = EXTRACT_32BITS(bp); \
729 bp += sizeof(int32_t); \
730 printf(" %d.%d", epoch, counter); \
733 #define AFSUUIDOUT() {u_int32_t temp; int i; \
734 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
735 temp = EXTRACT_32BITS(bp); \
736 bp += sizeof(u_int32_t); \
737 printf(" %08x", temp); \
738 temp = EXTRACT_32BITS(bp); \
739 bp += sizeof(u_int32_t); \
740 printf("%04x", temp); \
741 temp = EXTRACT_32BITS(bp); \
742 bp += sizeof(u_int32_t); \
743 printf("%04x", temp); \
744 for (i = 0; i < 8; i++) { \
745 temp = EXTRACT_32BITS(bp); \
746 bp += sizeof(u_int32_t); \
747 printf("%02x", (unsigned char) temp); \
752 * This is the sickest one of all
755 #define VECOUT(MAX) { u_char *sp; \
756 u_char s[AFSNAMEMAX]; \
758 if ((MAX) + 1 > sizeof(s)) \
760 TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
762 for (k = 0; k < (MAX); k++) { \
763 *sp++ = (u_char) EXTRACT_32BITS(bp); \
764 bp += sizeof(int32_t); \
773 ack_print(register const u_char
*bp
, int length
)
781 if (length
<= sizeof(struct rx_header
))
784 bp
+= sizeof(struct rx_header
);
787 * Packets < firstPacket are implicitly acknowledged and may
788 * be discarded by the sender.
790 * Packets >= firstPacket+nAcks are implicitly NOT acknowledged.
792 * No packets with sequence numbers >= firstPacket should be
793 * discarded by the sender (they may thrown out at any time by
796 #define RX_ACK_REASONS "RDOXSprn"
797 /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space,
798 * Ping, ping_Response, No_{progress, particular_reason}.
801 struct rx_ackPacket
{
802 u_short bufferSpace
; /* Skip! */
803 u_short maxSkew
; /* Skip! */
805 u_long previousPacket
; /* Obsolete! */
806 u_long serial
; /* Serial that prompted the ack, */
807 u_char reason
; /* and the reason why. */
809 u_char acks
[RX_MAXACKS
]; /* Selective acks (not a bitmap). */
812 #define RX_ACK_TYPE_NACK 0
814 TCHECK2(bp
[0], 8); /* bufferSpace and maxSkew */
816 printf(" fir %u", (unsigned)EXTRACT_32BITS(bp
));
818 TCHECK2(bp
[0], 8); /* previousPacket and serial */
820 printf(" %u", (unsigned)EXTRACT_32BITS(bp
));
823 printf("%c", RX_ACK_REASONS
[(*bp
- 1) & 07u]);
824 bp
+= 1; /* reason */
829 for (i
= 0; i
< nAcks
; i
++) {
831 putchar(*bp
== RX_ACK_TYPE_NACK
? '-' : '*');
842 * Handle calls to the AFS file service (fs)
846 fs_print(register const u_char
*bp
, int length
)
851 if (length
<= sizeof(struct rx_header
))
854 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
859 * Print out the afs call we're invoking. The table used here was
860 * gleaned from fsint/afsint.xg
863 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
865 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
868 * Print out arguments to some of the AFS calls. This stuff is
872 bp
+= sizeof(struct rx_header
) + 4;
875 * Sigh. This is gross. Ritchie forgive me.
879 case 130: /* Fetch data */
886 case 131: /* Fetch ACL */
887 case 132: /* Fetch Status */
888 case 143: /* Old set lock */
889 case 144: /* Old extend lock */
890 case 145: /* Old release lock */
891 case 156: /* Set lock */
892 case 157: /* Extend lock */
893 case 158: /* Release lock */
896 case 135: /* Store status */
900 case 133: /* Store data */
910 case 134: /* Store ACL */
912 char a
[AFSOPAQUEMAX
+1];
915 i
= EXTRACT_32BITS(bp
);
916 bp
+= sizeof(int32_t);
918 i
= min(AFSOPAQUEMAX
, i
);
919 strncpy(a
, (char *) bp
, i
);
921 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
924 case 137: /* Create file */
925 case 141: /* MakeDir */
930 case 136: /* Remove file */
931 case 142: /* Remove directory */
935 case 138: /* Rename file */
943 case 139: /* Symlink */
955 case 148: /* Get volume info */
958 case 149: /* Get volume stats */
959 case 150: /* Set volume stats */
963 case 154: /* New get volume info */
967 case 155: /* Bulk stat */
971 j
= EXTRACT_32BITS(bp
);
972 bp
+= sizeof(int32_t);
974 for (i
= 0; i
< j
; i
++) {
993 * Handle replies to the AFS file service
997 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1000 struct rx_header
*rxh
;
1002 if (length
<= sizeof(struct rx_header
))
1005 rxh
= (struct rx_header
*) bp
;
1008 * Print out the afs call we're invoking. The table used here was
1009 * gleaned from fsint/afsint.xg
1012 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
1014 bp
+= sizeof(struct rx_header
);
1017 * If it was a data packet, interpret the response
1020 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
1022 case 131: /* Fetch ACL */
1024 char a
[AFSOPAQUEMAX
+1];
1026 i
= EXTRACT_32BITS(bp
);
1027 bp
+= sizeof(int32_t);
1029 i
= min(AFSOPAQUEMAX
, i
);
1030 strncpy(a
, (char *) bp
, i
);
1032 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1035 case 137: /* Create file */
1036 case 141: /* MakeDir */
1040 case 151: /* Get root volume */
1041 printf(" root volume");
1044 case 153: /* Get time */
1050 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1054 * Otherwise, just print out the return code
1056 TCHECK2(bp
[0], sizeof(int32_t));
1057 i
= (int) EXTRACT_32BITS(bp
);
1058 bp
+= sizeof(int32_t);
1060 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
1062 printf(" strange fs reply of type %d", rxh
->type
);
1072 * Print out an AFS ACL string. An AFS ACL is a string that has the
1075 * <positive> <negative>
1079 * "positive" and "negative" are integers which contain the number of
1080 * positive and negative ACL's in the string. The uid/aclbits pair are
1081 * ASCII strings containing the UID/PTS record and and a ascii number
1082 * representing a logical OR of all the ACL permission bits
1086 acl_print(u_char
*s
, int maxsize
, u_char
*end
)
1092 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1095 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1104 * This wacky order preserves the order used by the "fs" command
1107 #define ACLOUT(acl) \
1108 if (acl & PRSFS_READ) \
1110 if (acl & PRSFS_LOOKUP) \
1112 if (acl & PRSFS_INSERT) \
1114 if (acl & PRSFS_DELETE) \
1116 if (acl & PRSFS_WRITE) \
1118 if (acl & PRSFS_LOCK) \
1120 if (acl & PRSFS_ADMINISTER) \
1123 for (i
= 0; i
< pos
; i
++) {
1124 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1128 fn_print((u_char
*)user
, NULL
);
1136 for (i
= 0; i
< neg
; i
++) {
1137 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1141 fn_print((u_char
*)user
, NULL
);
1157 * Handle calls to the AFS callback service
1161 cb_print(register const u_char
*bp
, int length
)
1166 if (length
<= sizeof(struct rx_header
))
1169 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1174 * Print out the afs call we're invoking. The table used here was
1175 * gleaned from fsint/afscbint.xg
1178 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1180 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1182 bp
+= sizeof(struct rx_header
) + 4;
1185 * Print out the afs call we're invoking. The table used here was
1186 * gleaned from fsint/afscbint.xg
1190 case 204: /* Callback */
1194 j
= EXTRACT_32BITS(bp
);
1195 bp
+= sizeof(int32_t);
1197 for (i
= 0; i
< j
; i
++) {
1206 j
= EXTRACT_32BITS(bp
);
1207 bp
+= sizeof(int32_t);
1212 for (i
= 0; i
< j
; i
++) {
1218 t
= EXTRACT_32BITS(bp
);
1219 bp
+= sizeof(int32_t);
1220 tok2str(cb_types
, "type %d", t
);
1239 * Handle replies to the AFS Callback Service
1243 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1245 struct rx_header
*rxh
;
1247 if (length
<= sizeof(struct rx_header
))
1250 rxh
= (struct rx_header
*) bp
;
1253 * Print out the afs call we're invoking. The table used here was
1254 * gleaned from fsint/afscbint.xg
1257 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1259 bp
+= sizeof(struct rx_header
);
1262 * If it was a data packet, interpret the response.
1265 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1267 case 213: /* InitCallBackState3 */
1275 * Otherwise, just print out the return code
1288 * Handle calls to the AFS protection database server
1292 prot_print(register const u_char
*bp
, int length
)
1297 if (length
<= sizeof(struct rx_header
))
1300 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1305 * Print out the afs call we're invoking. The table used here was
1306 * gleaned from ptserver/ptint.xg
1309 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1313 if (is_ubik(pt_op
)) {
1314 ubik_print(bp
, length
);
1318 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1321 * Decode some of the arguments to the PT calls
1324 bp
+= sizeof(struct rx_header
) + 4;
1327 case 500: /* I New User */
1334 case 501: /* Where is it */
1335 case 506: /* Delete */
1336 case 508: /* Get CPS */
1337 case 512: /* List entry */
1338 case 514: /* List elements */
1339 case 517: /* List owned */
1340 case 518: /* Get CPS2 */
1341 case 519: /* Get host CPS */
1345 case 502: /* Dump entry */
1349 case 503: /* Add to group */
1350 case 507: /* Remove from group */
1351 case 515: /* Is a member of? */
1357 case 504: /* Name to ID */
1361 j
= EXTRACT_32BITS(bp
);
1362 bp
+= sizeof(int32_t);
1365 * Who designed this chicken-shit protocol?
1367 * Each character is stored as a 32-bit
1371 for (i
= 0; i
< j
; i
++) {
1378 case 505: /* Id to name */
1383 i
= EXTRACT_32BITS(bp
);
1384 bp
+= sizeof(int32_t);
1385 for (j
= 0; j
< i
; j
++)
1391 case 509: /* New entry */
1398 case 511: /* Set max */
1404 case 513: /* Change entry */
1413 case 520: /* Update entry */
1430 * Handle replies to the AFS protection service
1434 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1436 struct rx_header
*rxh
;
1439 if (length
< sizeof(struct rx_header
))
1442 rxh
= (struct rx_header
*) bp
;
1445 * Print out the afs call we're invoking. The table used here was
1446 * gleaned from ptserver/ptint.xg. Check to see if it's a
1447 * Ubik call, however.
1452 if (is_ubik(opcode
)) {
1453 ubik_reply_print(bp
, length
, opcode
);
1457 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1459 bp
+= sizeof(struct rx_header
);
1462 * If it was a data packet, interpret the response
1465 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1467 case 504: /* Name to ID */
1472 i
= EXTRACT_32BITS(bp
);
1473 bp
+= sizeof(int32_t);
1474 for (j
= 0; j
< i
; j
++)
1480 case 505: /* ID to name */
1484 j
= EXTRACT_32BITS(bp
);
1485 bp
+= sizeof(int32_t);
1488 * Who designed this chicken-shit protocol?
1490 * Each character is stored as a 32-bit
1494 for (i
= 0; i
< j
; i
++) {
1501 case 508: /* Get CPS */
1502 case 514: /* List elements */
1503 case 517: /* List owned */
1504 case 518: /* Get CPS2 */
1505 case 519: /* Get host CPS */
1509 j
= EXTRACT_32BITS(bp
);
1510 bp
+= sizeof(int32_t);
1511 for (i
= 0; i
< j
; i
++) {
1518 case 510: /* List max */
1529 * Otherwise, just print out the return code
1542 * Handle calls to the AFS volume location database service
1546 vldb_print(register const u_char
*bp
, int length
)
1551 if (length
<= sizeof(struct rx_header
))
1554 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1559 * Print out the afs call we're invoking. The table used here was
1560 * gleaned from vlserver/vldbint.xg
1563 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1567 if (is_ubik(vldb_op
)) {
1568 ubik_print(bp
, length
);
1571 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1574 * Decode some of the arguments to the VLDB calls
1577 bp
+= sizeof(struct rx_header
) + 4;
1580 case 501: /* Create new volume */
1581 case 517: /* Create entry N */
1584 case 502: /* Delete entry */
1585 case 503: /* Get entry by ID */
1586 case 507: /* Update entry */
1587 case 508: /* Set lock */
1588 case 509: /* Release lock */
1589 case 518: /* Get entry by ID N */
1592 TCHECK2(bp
[0], sizeof(int32_t));
1593 i
= EXTRACT_32BITS(bp
);
1594 bp
+= sizeof(int32_t);
1596 printf(" type %s", voltype
[i
]);
1598 case 504: /* Get entry by name */
1599 case 519: /* Get entry by name N */
1600 case 524: /* Update entry by name */
1601 case 527: /* Get entry by name U */
1604 case 505: /* Get new vol id */
1608 case 506: /* Replace entry */
1609 case 520: /* Replace entry N */
1612 TCHECK2(bp
[0], sizeof(int32_t));
1613 i
= EXTRACT_32BITS(bp
);
1614 bp
+= sizeof(int32_t);
1616 printf(" type %s", voltype
[i
]);
1619 case 510: /* List entry */
1620 case 521: /* List entry N */
1635 * Handle replies to the AFS volume location database service
1639 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1641 struct rx_header
*rxh
;
1644 if (length
< sizeof(struct rx_header
))
1647 rxh
= (struct rx_header
*) bp
;
1650 * Print out the afs call we're invoking. The table used here was
1651 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1652 * Ubik call, however.
1657 if (is_ubik(opcode
)) {
1658 ubik_reply_print(bp
, length
, opcode
);
1662 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1664 bp
+= sizeof(struct rx_header
);
1667 * If it was a data packet, interpret the response
1670 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1672 case 510: /* List entry */
1675 printf(" nextindex");
1677 case 503: /* Get entry by id */
1678 case 504: /* Get entry by name */
1679 { unsigned long nservers
, j
;
1681 TCHECK2(bp
[0], sizeof(int32_t));
1682 bp
+= sizeof(int32_t);
1683 printf(" numservers");
1684 TCHECK2(bp
[0], sizeof(int32_t));
1685 nservers
= EXTRACT_32BITS(bp
);
1686 bp
+= sizeof(int32_t);
1687 printf(" %lu", nservers
);
1689 for (i
= 0; i
< 8; i
++) {
1690 TCHECK2(bp
[0], sizeof(int32_t));
1693 inet_ntoa(*((struct in_addr
*) bp
)));
1694 bp
+= sizeof(int32_t);
1696 printf(" partitions");
1697 for (i
= 0; i
< 8; i
++) {
1698 TCHECK2(bp
[0], sizeof(int32_t));
1699 j
= EXTRACT_32BITS(bp
);
1700 if (i
< nservers
&& j
<= 26)
1701 printf(" %c", 'a' + (int)j
);
1702 else if (i
< nservers
)
1704 bp
+= sizeof(int32_t);
1706 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1707 bp
+= 8 * sizeof(int32_t);
1716 case 505: /* Get new volume ID */
1720 case 521: /* List entry */
1721 case 529: /* List entry U */
1724 printf(" nextindex");
1726 case 518: /* Get entry by ID N */
1727 case 519: /* Get entry by name N */
1728 { unsigned long nservers
, j
;
1730 printf(" numservers");
1731 TCHECK2(bp
[0], sizeof(int32_t));
1732 nservers
= EXTRACT_32BITS(bp
);
1733 bp
+= sizeof(int32_t);
1734 printf(" %lu", nservers
);
1736 for (i
= 0; i
< 13; i
++) {
1737 TCHECK2(bp
[0], sizeof(int32_t));
1740 inet_ntoa(*((struct in_addr
*) bp
)));
1741 bp
+= sizeof(int32_t);
1743 printf(" partitions");
1744 for (i
= 0; i
< 13; i
++) {
1745 TCHECK2(bp
[0], sizeof(int32_t));
1746 j
= EXTRACT_32BITS(bp
);
1747 if (i
< nservers
&& j
<= 26)
1748 printf(" %c", 'a' + (int)j
);
1749 else if (i
< nservers
)
1751 bp
+= sizeof(int32_t);
1753 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1754 bp
+= 13 * sizeof(int32_t);
1763 case 526: /* Get entry by ID U */
1764 case 527: /* Get entry by name U */
1765 { unsigned long nservers
, j
;
1767 printf(" numservers");
1768 TCHECK2(bp
[0], sizeof(int32_t));
1769 nservers
= EXTRACT_32BITS(bp
);
1770 bp
+= sizeof(int32_t);
1771 printf(" %lu", nservers
);
1773 for (i
= 0; i
< 13; i
++) {
1782 TCHECK2(bp
[0], 4 * 13);
1784 printf(" partitions");
1785 for (i
= 0; i
< 13; i
++) {
1786 TCHECK2(bp
[0], sizeof(int32_t));
1787 j
= EXTRACT_32BITS(bp
);
1788 if (i
< nservers
&& j
<= 26)
1789 printf(" %c", 'a' + (int)j
);
1790 else if (i
< nservers
)
1792 bp
+= sizeof(int32_t);
1794 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1795 bp
+= 13 * sizeof(int32_t);
1809 * Otherwise, just print out the return code
1822 * Handle calls to the AFS Kerberos Authentication service
1826 kauth_print(register const u_char
*bp
, int length
)
1830 if (length
<= sizeof(struct rx_header
))
1833 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1838 * Print out the afs call we're invoking. The table used here was
1839 * gleaned from kauth/kauth.rg
1842 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1846 if (is_ubik(kauth_op
)) {
1847 ubik_print(bp
, length
);
1852 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1855 * Decode some of the arguments to the KA calls
1858 bp
+= sizeof(struct rx_header
) + 4;
1861 case 1: /* Authenticate old */;
1862 case 21: /* Authenticate */
1863 case 22: /* Authenticate-V2 */
1864 case 2: /* Change PW */
1865 case 5: /* Set fields */
1866 case 6: /* Create user */
1867 case 7: /* Delete user */
1868 case 8: /* Get entry */
1869 case 14: /* Unlock */
1870 case 15: /* Lock status */
1871 printf(" principal");
1875 case 3: /* GetTicket-old */
1876 case 23: /* GetTicket */
1883 TCHECK2(bp
[0], sizeof(int32_t));
1884 i
= (int) EXTRACT_32BITS(bp
);
1885 bp
+= sizeof(int32_t);
1888 printf(" principal");
1893 case 4: /* Set Password */
1894 printf(" principal");
1900 case 12: /* Get password */
1911 printf(" [|kauth]");
1915 * Handle replies to the AFS Kerberos Authentication Service
1919 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1921 struct rx_header
*rxh
;
1923 if (length
<= sizeof(struct rx_header
))
1926 rxh
= (struct rx_header
*) bp
;
1929 * Print out the afs call we're invoking. The table used here was
1930 * gleaned from kauth/kauth.rg
1935 if (is_ubik(opcode
)) {
1936 ubik_reply_print(bp
, length
, opcode
);
1940 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1942 bp
+= sizeof(struct rx_header
);
1945 * If it was a data packet, interpret the response.
1948 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1949 /* Well, no, not really. Leave this for later */
1953 * Otherwise, just print out the return code
1962 printf(" [|kauth]");
1966 * Handle calls to the AFS Volume location service
1970 vol_print(register const u_char
*bp
, int length
)
1974 if (length
<= sizeof(struct rx_header
))
1977 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1982 * Print out the afs call we're invoking. The table used here was
1983 * gleaned from volser/volint.xg
1986 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1988 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1991 * Normally there would be a switch statement here to decode the
1992 * arguments to the AFS call, but since I don't have access to
1993 * an AFS server (yet) and I'm not an AFS admin, I can't
1994 * test any of these calls. Leave this blank for now.
2004 * Handle replies to the AFS Volume Service
2008 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2010 struct rx_header
*rxh
;
2012 if (length
<= sizeof(struct rx_header
))
2015 rxh
= (struct rx_header
*) bp
;
2018 * Print out the afs call we're invoking. The table used here was
2019 * gleaned from volser/volint.xg
2022 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
2024 bp
+= sizeof(struct rx_header
);
2027 * If it was a data packet, interpret the response.
2030 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2031 /* Well, no, not really. Leave this for later */
2035 * Otherwise, just print out the return code
2048 * Handle calls to the AFS BOS service
2052 bos_print(register const u_char
*bp
, int length
)
2056 if (length
<= sizeof(struct rx_header
))
2059 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
2064 * Print out the afs call we're invoking. The table used here was
2065 * gleaned from bozo/bosint.xg
2068 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2070 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2073 * Decode some of the arguments to the BOS calls
2076 bp
+= sizeof(struct rx_header
) + 4;
2079 case 80: /* Create B node */
2082 printf(" instance");
2085 case 81: /* Delete B node */
2086 case 83: /* Get status */
2087 case 85: /* Get instance info */
2088 case 87: /* Add super user */
2089 case 88: /* Delete super user */
2090 case 93: /* Set cell name */
2091 case 96: /* Add cell host */
2092 case 97: /* Delete cell host */
2093 case 104: /* Restart */
2094 case 106: /* Uninstall */
2095 case 108: /* Exec */
2096 case 112: /* Getlog */
2097 case 114: /* Get instance strings */
2100 case 82: /* Set status */
2101 case 98: /* Set T status */
2106 case 86: /* Get instance parm */
2111 case 84: /* Enumerate instance */
2112 case 89: /* List super users */
2113 case 90: /* List keys */
2114 case 91: /* Add key */
2115 case 92: /* Delete key */
2116 case 95: /* Get cell host */
2119 case 105: /* Install */
2139 * Handle replies to the AFS BOS Service
2143 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2145 struct rx_header
*rxh
;
2147 if (length
<= sizeof(struct rx_header
))
2150 rxh
= (struct rx_header
*) bp
;
2153 * Print out the afs call we're invoking. The table used here was
2154 * gleaned from volser/volint.xg
2157 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2159 bp
+= sizeof(struct rx_header
);
2162 * If it was a data packet, interpret the response.
2165 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2166 /* Well, no, not really. Leave this for later */
2170 * Otherwise, just print out the return code
2183 * Check to see if this is a Ubik opcode.
2187 is_ubik(u_int32_t opcode
)
2189 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2190 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2197 * Handle Ubik opcodes to any one of the replicated database services
2201 ubik_print(register const u_char
*bp
, int length
)
2207 * Print out the afs call we're invoking. The table used here was
2208 * gleaned from ubik/ubik_int.xg
2211 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2213 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2216 * Decode some of the arguments to the Ubik calls
2219 bp
+= sizeof(struct rx_header
) + 4;
2222 case 10000: /* Beacon */
2224 temp
= EXTRACT_32BITS(bp
);
2225 bp
+= sizeof(int32_t);
2226 printf(" syncsite %s", temp
? "yes" : "no");
2227 printf(" votestart");
2229 printf(" dbversion");
2234 case 10003: /* Get sync site */
2238 case 20000: /* Begin */
2239 case 20001: /* Commit */
2240 case 20007: /* Abort */
2241 case 20008: /* Release locks */
2242 case 20010: /* Writev */
2246 case 20002: /* Lock */
2255 temp
= EXTRACT_32BITS(bp
);
2256 bp
+= sizeof(int32_t);
2257 tok2str(ubik_lock_types
, "type %d", temp
);
2259 case 20003: /* Write */
2267 case 20005: /* Get file */
2271 case 20006: /* Send file */
2276 printf(" dbversion");
2279 case 20009: /* Truncate */
2287 case 20012: /* Set version */
2290 printf(" oldversion");
2292 printf(" newversion");
2306 * Handle Ubik replies to any one of the replicated database services
2310 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2312 struct rx_header
*rxh
;
2314 if (length
< sizeof(struct rx_header
))
2317 rxh
= (struct rx_header
*) bp
;
2320 * Print out the ubik call we're invoking. This table was gleaned
2321 * from ubik/ubik_int.xg
2324 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2326 bp
+= sizeof(struct rx_header
);
2329 * If it was a data packet, print out the arguments to the Ubik calls
2332 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2334 case 10000: /* Beacon */
2337 case 20004: /* Get version */
2338 printf(" dbversion");
2346 * Otherwise, print out "yes" it it was a beacon packet (because
2347 * that's how yes votes are returned, go figure), otherwise
2348 * just print out the error code.
2353 case 10000: /* Beacon */
2354 printf(" vote yes until");
2369 * Handle RX ACK packets.
2373 rx_ack_print(register const u_char
*bp
, int length
)
2375 struct rx_ackPacket
*rxa
;
2378 if (length
< sizeof(struct rx_header
))
2381 bp
+= sizeof(struct rx_header
);
2384 * This may seem a little odd .... the rx_ackPacket structure
2385 * contains an array of individual packet acknowledgements
2386 * (used for selective ack/nack), but since it's variable in size,
2387 * we don't want to truncate based on the size of the whole
2388 * rx_ackPacket structure.
2391 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2393 rxa
= (struct rx_ackPacket
*) bp
;
2394 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2397 * Print out a few useful things from the ack packet structure
2401 printf(" bufspace %d maxskew %d",
2402 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2403 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2405 printf(" first %d serial %d reason %s",
2406 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2407 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2410 * Okay, now we print out the ack array. The way _this_ works
2411 * is that we start at "first", and step through the ack array.
2412 * If we have a contiguous range of acks/nacks, try to
2413 * collapse them into a range.
2415 * If you're really clever, you might have noticed that this
2416 * doesn't seem quite correct. Specifically, due to structure
2417 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2418 * yield the start of the ack array (because RX_MAXACKS is 255
2419 * and the structure will likely get padded to a 2 or 4 byte
2420 * boundary). However, this is the way it's implemented inside
2421 * of AFS - the start of the extra fields are at
2422 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2423 * the exact start of the ack array. Sigh. That's why we aren't
2424 * using bp, but instead use rxa->acks[]. But nAcks gets added
2425 * to bp after this, so bp ends up at the right spot. Go figure.
2428 if (rxa
->nAcks
!= 0) {
2430 TCHECK2(bp
[0], rxa
->nAcks
);
2433 * Sigh, this is gross, but it seems to work to collapse
2437 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2438 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2441 * I figured this deserved _some_ explanation.
2442 * First, print "acked" and the packet seq
2443 * number if this is the first time we've
2444 * seen an acked packet.
2449 rxa
->firstPacket
+ i
);
2454 * Otherwise, if the there is a skip in
2455 * the range (such as an nacked packet in
2456 * the middle of some acked packets),
2457 * then print the current packet number
2458 * seperated from the last number by
2462 else if (last
!= i
- 1) {
2463 printf(",%d", rxa
->firstPacket
+ i
);
2468 * We always set last to the value of
2469 * the last ack we saw. Conversely, start
2470 * is set to the value of the first ack
2471 * we saw in a range.
2477 * Okay, this bit a code gets executed when
2478 * we hit a nack ... in _this_ case we
2479 * want to print out the range of packets
2480 * that were acked, so we need to print
2481 * the _previous_ packet number seperated
2482 * from the first by a dash (-). Since we
2483 * already printed the first packet above,
2484 * just print the final packet. Don't
2485 * do this if there will be a single-length
2488 } else if (last
== i
- 1 && start
!= last
)
2489 printf("-%d", rxa
->firstPacket
+ i
- 1);
2492 * So, what's going on here? We ran off the end of the
2493 * ack list, and if we got a range we need to finish it up.
2494 * So we need to determine if the last packet in the list
2495 * was an ack (if so, then last will be set to it) and
2496 * we need to see if the last range didn't start with the
2497 * last packet (because if it _did_, then that would mean
2498 * that the packet number has already been printed and
2499 * we don't need to print it again).
2502 if (last
== i
- 1 && start
!= last
)
2503 printf("-%d", rxa
->firstPacket
+ i
- 1);
2506 * Same as above, just without comments
2509 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2510 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2512 printf(" nacked %d",
2513 rxa
->firstPacket
+ i
);
2515 } else if (last
!= i
- 1) {
2516 printf(",%d", rxa
->firstPacket
+ i
);
2520 } else if (last
== i
- 1 && start
!= last
)
2521 printf("-%d", rxa
->firstPacket
+ i
- 1);
2523 if (last
== i
- 1 && start
!= last
)
2524 printf("-%d", rxa
->firstPacket
+ i
- 1);
2531 * These are optional fields; depending on your version of AFS,
2532 * you may or may not see them
2535 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2551 printf(" maxpackets");