]>
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.33 2002-09-05 00:00:19 guy Exp $";
47 #include <tcpdump-stdinc.h>
49 #include "interface.h"
50 #include "addrtoname.h"
57 static struct tok rx_types
[] = {
58 { RX_PACKET_TYPE_DATA
, "data" },
59 { RX_PACKET_TYPE_ACK
, "ack" },
60 { RX_PACKET_TYPE_BUSY
, "busy" },
61 { RX_PACKET_TYPE_ABORT
, "abort" },
62 { RX_PACKET_TYPE_ACKALL
, "ackall" },
63 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
64 { RX_PACKET_TYPE_RESPONSE
, "response" },
65 { RX_PACKET_TYPE_DEBUG
, "debug" },
66 { RX_PACKET_TYPE_PARAMS
, "params" },
67 { RX_PACKET_TYPE_VERSION
, "version" },
71 static struct double_tok
{
72 int flag
; /* Rx flag */
73 int packetType
; /* Packet type */
74 const char *s
; /* Flag string */
76 { RX_CLIENT_INITIATED
, 0, "client-init" },
77 { RX_REQUEST_ACK
, 0, "req-ack" },
78 { RX_LAST_PACKET
, 0, "last-pckt" },
79 { RX_MORE_PACKETS
, 0, "more-pckts" },
80 { RX_FREE_PACKET
, 0, "free-pckt" },
81 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
82 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
85 static struct tok fs_req
[] = {
86 { 130, "fetch-data" },
88 { 132, "fetch-status" },
89 { 133, "store-data" },
91 { 135, "store-status" },
92 { 136, "remove-file" },
93 { 137, "create-file" },
99 { 143, "oldsetlock" },
100 { 144, "oldextlock" },
101 { 145, "oldrellock" },
102 { 146, "get-stats" },
104 { 148, "get-vlinfo" },
105 { 149, "get-vlstats" },
106 { 150, "set-vlstats" },
107 { 151, "get-rootvl" },
108 { 152, "check-token" },
110 { 154, "nget-vlinfo" },
111 { 155, "bulk-stat" },
115 { 159, "xstat-ver" },
116 { 160, "get-xstat" },
117 { 161, "dfs-lookup" },
118 { 162, "dfs-flushcps" },
119 { 163, "dfs-symlink" },
120 { 220, "residency" },
124 static struct tok cb_req
[] = {
133 { 212, "whoareyou" },
135 { 214, "probeuuid" },
136 { 215, "getsrvprefs" },
137 { 216, "getcellservdb" },
138 { 217, "getlocalcell" },
139 { 218, "getcacheconf" },
143 static struct tok pt_req
[] = {
145 { 501, "where-is-it" },
146 { 502, "dump-entry" },
147 { 503, "add-to-group" },
148 { 504, "name-to-id" },
149 { 505, "id-to-name" },
151 { 507, "remove-from-group" },
153 { 509, "new-entry" },
156 { 512, "list-entry" },
157 { 513, "change-entry" },
158 { 514, "list-elements" },
159 { 515, "same-mbr-of" },
160 { 516, "set-fld-sentry" },
161 { 517, "list-owned" },
163 { 519, "get-host-cps" },
164 { 520, "update-entry" },
165 { 521, "list-entries" },
169 static struct tok vldb_req
[] = {
170 { 501, "create-entry" },
171 { 502, "delete-entry" },
172 { 503, "get-entry-by-id" },
173 { 504, "get-entry-by-name" },
174 { 505, "get-new-volume-id" },
175 { 506, "replace-entry" },
176 { 507, "update-entry" },
178 { 509, "releaselock" },
179 { 510, "list-entry" },
180 { 511, "list-attrib" },
181 { 512, "linked-list" },
182 { 513, "get-stats" },
184 { 515, "get-addrs" },
185 { 516, "change-addr" },
186 { 517, "create-entry-n" },
187 { 518, "get-entry-by-id-n" },
188 { 519, "get-entry-by-name-n" },
189 { 520, "replace-entry-n" },
190 { 521, "list-entry-n" },
191 { 522, "list-attrib-n" },
192 { 523, "linked-list-n" },
193 { 524, "update-entry-by-name" },
194 { 525, "create-entry-u" },
195 { 526, "get-entry-by-id-u" },
196 { 527, "get-entry-by-name-u" },
197 { 528, "replace-entry-u" },
198 { 529, "list-entry-u" },
199 { 530, "list-attrib-u" },
200 { 531, "linked-list-u" },
202 { 533, "get-addrs-u" },
203 { 534, "list-attrib-n2" },
207 static struct tok kauth_req
[] = {
209 { 21, "authenticate" },
210 { 22, "authenticate-v2" },
212 { 3, "get-ticket-old" },
213 { 23, "get-ticket" },
216 { 6, "create-user" },
217 { 7, "delete-user" },
223 { 13, "get-random-key" },
225 { 15, "lock-status" },
229 static struct tok vol_req
[] = {
230 { 100, "create-volume" },
231 { 101, "delete-volume" },
234 { 104, "end-trans" },
236 { 106, "set-flags" },
237 { 107, "get-flags" },
238 { 108, "trans-create" },
240 { 110, "get-nth-volume" },
241 { 111, "set-forwarding" },
243 { 113, "get-status" },
244 { 114, "sig-restore" },
245 { 115, "list-partitions" },
246 { 116, "list-volumes" },
247 { 117, "set-id-types" },
249 { 119, "partition-info" },
251 { 121, "list-one-volume" },
254 { 124, "x-list-volumes" },
255 { 125, "x-list-one-volume" },
257 { 127, "x-list-partitions" },
258 { 128, "forward-multiple" },
262 static struct tok bos_req
[] = {
263 { 80, "create-bnode" },
264 { 81, "delete-bnode" },
265 { 82, "set-status" },
266 { 83, "get-status" },
267 { 84, "enumerate-instance" },
268 { 85, "get-instance-info" },
269 { 86, "get-instance-parm" },
270 { 87, "add-superuser" },
271 { 88, "delete-superuser" },
272 { 89, "list-superusers" },
275 { 92, "delete-key" },
276 { 93, "set-cell-name" },
277 { 94, "get-cell-name" },
278 { 95, "get-cell-host" },
279 { 96, "add-cell-host" },
280 { 97, "delete-cell-host" },
281 { 98, "set-t-status" },
282 { 99, "shutdown-all" },
283 { 100, "restart-all" },
284 { 101, "startup-all" },
285 { 102, "set-noauth-flag" },
288 { 105, "start-bozo-install" },
289 { 106, "uninstall" },
290 { 107, "get-dates" },
293 { 110, "set-restart-time" },
294 { 111, "get-restart-time" },
295 { 112, "start-bozo-log" },
297 { 114, "get-instance-strings" },
298 { 115, "get-restricted" },
299 { 116, "set-restricted" },
303 static struct tok ubik_req
[] = {
304 { 10000, "vote-beacon" },
305 { 10001, "vote-debug-old" },
306 { 10002, "vote-sdebug-old" },
307 { 10003, "vote-getsyncsite" },
308 { 10004, "vote-debug" },
309 { 10005, "vote-sdebug" },
310 { 20000, "disk-begin" },
311 { 20001, "disk-commit" },
312 { 20002, "disk-lock" },
313 { 20003, "disk-write" },
314 { 20004, "disk-getversion" },
315 { 20005, "disk-getfile" },
316 { 20006, "disk-sendfile" },
317 { 20007, "disk-abort" },
318 { 20008, "disk-releaselocks" },
319 { 20009, "disk-truncate" },
320 { 20010, "disk-probe" },
321 { 20011, "disk-writev" },
322 { 20012, "disk-interfaceaddr" },
323 { 20013, "disk-setversion" },
327 #define VOTE_LOW 10000
328 #define VOTE_HIGH 10005
329 #define DISK_LOW 20000
330 #define DISK_HIGH 20013
332 static struct tok cb_types
[] = {
339 static struct tok ubik_lock_types
[] = {
346 static const char *voltype
[] = { "read-write", "read-only", "backup" };
348 static struct tok afs_fs_errors
[] = {
349 { 101, "salvage volume" },
350 { 102, "no such vnode" },
351 { 103, "no such volume" },
352 { 104, "volume exist" },
353 { 105, "no service" },
354 { 106, "volume offline" },
355 { 107, "voline online" },
357 { 109, "diskquota exceeded" },
358 { 110, "volume busy" },
359 { 111, "volume moved" },
360 { 112, "AFS IO error" },
361 { -100, "restarting fileserver" },
366 * Reasons for acknowledging a packet
369 static struct tok rx_ack_reasons
[] = {
370 { 1, "ack requested" },
371 { 2, "duplicate packet" },
372 { 3, "out of sequence" },
373 { 4, "exceeds window" },
374 { 5, "no buffer space" },
376 { 7, "ping response" },
382 * Cache entries we keep around so we can figure out the RX opcode
383 * numbers for replies. This allows us to make sense of RX reply packets.
386 struct rx_cache_entry
{
387 u_int32_t callnum
; /* Call number (net order) */
388 struct in_addr client
; /* client IP address (net order) */
389 struct in_addr server
; /* server IP address (net order) */
390 int dport
; /* server port (host order) */
391 u_short serviceId
; /* Service identifier (net order) */
392 u_int32_t opcode
; /* RX opcode (host order) */
395 #define RX_CACHE_SIZE 64
397 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
399 static int rx_cache_next
= 0;
400 static int rx_cache_hint
= 0;
401 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
402 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
405 static void ack_print(const u_char
*, int);
406 static void fs_print(const u_char
*, int);
407 static void fs_reply_print(const u_char
*, int, int32_t);
408 static void acl_print(u_char
*, int, u_char
*);
409 static void cb_print(const u_char
*, int);
410 static void cb_reply_print(const u_char
*, int, int32_t);
411 static void prot_print(const u_char
*, int);
412 static void prot_reply_print(const u_char
*, int, int32_t);
413 static void vldb_print(const u_char
*, int);
414 static void vldb_reply_print(const u_char
*, int, int32_t);
415 static void kauth_print(const u_char
*, int);
416 static void kauth_reply_print(const u_char
*, int, int32_t);
417 static void vol_print(const u_char
*, int);
418 static void vol_reply_print(const u_char
*, int, int32_t);
419 static void bos_print(const u_char
*, int);
420 static void bos_reply_print(const u_char
*, int, int32_t);
421 static void ubik_print(const u_char
*, int);
422 static void ubik_reply_print(const u_char
*, int, int32_t);
424 static void rx_ack_print(const u_char
*, int);
426 static int is_ubik(u_int32_t
);
429 * Handle the rx-level packet. See if we know what port it's going to so
430 * we can peek at the afs call inside
434 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
437 register struct rx_header
*rxh
;
441 if (snapend
- bp
< (int)sizeof (struct rx_header
)) {
442 printf(" [|rx] (%d)", length
);
446 rxh
= (struct rx_header
*) bp
;
448 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
454 printf(" cid %08x call# %d",
455 (int) EXTRACT_32BITS(&rxh
->cid
),
456 (int) EXTRACT_32BITS(&rxh
->callNumber
));
458 printf(" seq %d ser %d",
459 (int) EXTRACT_32BITS(&rxh
->seq
),
460 (int) EXTRACT_32BITS(&rxh
->serial
));
463 printf(" secindex %d serviceid %hu",
464 (int) rxh
->securityIndex
,
465 EXTRACT_16BITS(&rxh
->serviceId
));
468 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
469 if (rxh
->flags
& rx_flags
[i
].flag
&&
470 (!rx_flags
[i
].packetType
||
471 rxh
->type
== rx_flags
[i
].packetType
)) {
478 printf("<%s>", rx_flags
[i
].s
);
484 * Try to handle AFS calls that we know about. Check the destination
485 * port and make sure it's a data packet. Also, make sure the
486 * seq number is 1 (because otherwise it's a continuation packet,
487 * and we can't interpret that). Also, seems that reply packets
488 * do not have the client-init flag set, so we check for that
492 if (rxh
->type
== RX_PACKET_TYPE_ACK
)
493 ack_print(bp
, length
);
494 else if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
495 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
496 rxh
->flags
& RX_CLIENT_INITIATED
) {
499 * Insert this call into the call cache table, so we
500 * have a chance to print out replies
503 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
506 case FS_RX_PORT
: /* AFS file service */
507 fs_print(bp
, length
);
509 case CB_RX_PORT
: /* AFS callback service */
510 cb_print(bp
, length
);
512 case PROT_RX_PORT
: /* AFS protection service */
513 prot_print(bp
, length
);
515 case VLDB_RX_PORT
: /* AFS VLDB service */
516 vldb_print(bp
, length
);
518 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
519 kauth_print(bp
, length
);
521 case VOL_RX_PORT
: /* AFS Volume service */
522 vol_print(bp
, length
);
524 case BOS_RX_PORT
: /* AFS BOS service */
525 bos_print(bp
, length
);
532 * If it's a reply (client-init is _not_ set, but seq is one)
533 * then look it up in the cache. If we find it, call the reply
534 * printing functions Note that we handle abort packets here,
535 * because printing out the return code can be useful at times.
538 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
539 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
540 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
541 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
542 rx_cache_find(rxh
, (const struct ip
*) bp2
,
546 case FS_RX_PORT
: /* AFS file service */
547 fs_reply_print(bp
, length
, opcode
);
549 case CB_RX_PORT
: /* AFS callback service */
550 cb_reply_print(bp
, length
, opcode
);
552 case PROT_RX_PORT
: /* AFS PT service */
553 prot_reply_print(bp
, length
, opcode
);
555 case VLDB_RX_PORT
: /* AFS VLDB service */
556 vldb_reply_print(bp
, length
, opcode
);
558 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
559 kauth_reply_print(bp
, length
, opcode
);
561 case VOL_RX_PORT
: /* AFS Volume service */
562 vol_reply_print(bp
, length
, opcode
);
564 case BOS_RX_PORT
: /* AFS BOS service */
565 bos_reply_print(bp
, length
, opcode
);
572 * If it's an RX ack packet, then use the appropriate ack decoding
573 * function (there isn't any service-specific information in the
574 * ack packet, so we can use one for all AFS services)
577 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
578 rx_ack_print(bp
, length
);
581 printf(" (%d)", length
);
585 * Insert an entry into the cache. Taken from print-nfs.c
589 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
592 struct rx_cache_entry
*rxent
;
593 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
595 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t)))
598 rxent
= &rx_cache
[rx_cache_next
];
600 if (++rx_cache_next
>= RX_CACHE_SIZE
)
603 rxent
->callnum
= rxh
->callNumber
;
604 rxent
->client
= ip
->ip_src
;
605 rxent
->server
= ip
->ip_dst
;
606 rxent
->dport
= dport
;
607 rxent
->serviceId
= rxh
->serviceId
;
608 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
612 * Lookup an entry in the cache. Also taken from print-nfs.c
614 * Note that because this is a reply, we're looking at the _source_
619 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
623 struct rx_cache_entry
*rxent
;
624 u_int32_t clip
= ip
->ip_dst
.s_addr
;
625 u_int32_t sip
= ip
->ip_src
.s_addr
;
627 /* Start the search where we last left off */
631 rxent
= &rx_cache
[i
];
632 if (rxent
->callnum
== rxh
->callNumber
&&
633 rxent
->client
.s_addr
== clip
&&
634 rxent
->server
.s_addr
== sip
&&
635 rxent
->serviceId
== rxh
->serviceId
&&
636 rxent
->dport
== sport
) {
638 /* We got a match! */
641 *opcode
= rxent
->opcode
;
644 if (++i
> RX_CACHE_SIZE
)
646 } while (i
!= rx_cache_hint
);
648 /* Our search failed */
653 * These extrememly grody macros handle the printing of various AFS stuff.
656 #define FIDOUT() { unsigned long n1, n2, n3; \
657 TCHECK2(bp[0], sizeof(int32_t) * 3); \
658 n1 = EXTRACT_32BITS(bp); \
659 bp += sizeof(int32_t); \
660 n2 = EXTRACT_32BITS(bp); \
661 bp += sizeof(int32_t); \
662 n3 = EXTRACT_32BITS(bp); \
663 bp += sizeof(int32_t); \
664 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
667 #define STROUT(MAX) { unsigned int i; \
668 TCHECK2(bp[0], sizeof(int32_t)); \
669 i = EXTRACT_32BITS(bp); \
672 bp += sizeof(int32_t); \
674 if (fn_printn(bp, i, snapend)) \
677 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
680 #define INTOUT() { int i; \
681 TCHECK2(bp[0], sizeof(int32_t)); \
682 i = (int) EXTRACT_32BITS(bp); \
683 bp += sizeof(int32_t); \
687 #define UINTOUT() { unsigned long i; \
688 TCHECK2(bp[0], sizeof(int32_t)); \
689 i = EXTRACT_32BITS(bp); \
690 bp += sizeof(int32_t); \
694 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
695 TCHECK2(bp[0], sizeof(int32_t)); \
696 t = (time_t) EXTRACT_32BITS(bp); \
697 bp += sizeof(int32_t); \
698 tm = localtime(&t); \
699 strftime(str, 256, "%Y/%m/%d %T", tm); \
700 printf(" %s", str); \
703 #define STOREATTROUT() { unsigned long mask, i; \
704 TCHECK2(bp[0], (sizeof(int32_t)*6)); \
705 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
706 if (mask) printf (" StoreStatus"); \
707 if (mask & 1) { printf(" date"); DATEOUT(); } \
708 else bp += sizeof(int32_t); \
709 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
710 if (mask & 2) printf(" owner %lu", i); \
711 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
712 if (mask & 4) printf(" group %lu", i); \
713 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
714 if (mask & 8) printf(" mode %lo", i & 07777); \
715 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
716 if (mask & 16) printf(" segsize %lu", i); \
717 /* undocumented in 3.3 docu */ \
718 if (mask & 1024) printf(" fsync"); \
721 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
722 TCHECK2(bp[0], sizeof(int32_t) * 2); \
723 epoch = EXTRACT_32BITS(bp); \
724 bp += sizeof(int32_t); \
725 counter = EXTRACT_32BITS(bp); \
726 bp += sizeof(int32_t); \
727 printf(" %d.%d", epoch, counter); \
730 #define AFSUUIDOUT() {u_int32_t temp; int i; \
731 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
732 temp = EXTRACT_32BITS(bp); \
733 bp += sizeof(u_int32_t); \
734 printf(" %08x", temp); \
735 temp = EXTRACT_32BITS(bp); \
736 bp += sizeof(u_int32_t); \
737 printf("%04x", temp); \
738 temp = EXTRACT_32BITS(bp); \
739 bp += sizeof(u_int32_t); \
740 printf("%04x", temp); \
741 for (i = 0; i < 8; i++) { \
742 temp = EXTRACT_32BITS(bp); \
743 bp += sizeof(u_int32_t); \
744 printf("%02x", (unsigned char) temp); \
749 * This is the sickest one of all
752 #define VECOUT(MAX) { u_char *sp; \
753 u_char s[AFSNAMEMAX]; \
755 if ((MAX) + 1 > sizeof(s)) \
757 TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
759 for (k = 0; k < (MAX); k++) { \
760 *sp++ = (u_char) EXTRACT_32BITS(bp); \
761 bp += sizeof(int32_t); \
770 ack_print(register const u_char
*bp
, int length
)
778 if (length
<= (int)sizeof(struct rx_header
))
781 bp
+= sizeof(struct rx_header
);
784 * Packets < firstPacket are implicitly acknowledged and may
785 * be discarded by the sender.
787 * Packets >= firstPacket+nAcks are implicitly NOT acknowledged.
789 * No packets with sequence numbers >= firstPacket should be
790 * discarded by the sender (they may thrown out at any time by
793 #define RX_ACK_REASONS "RDOXSprn"
794 /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space,
795 * Ping, ping_Response, No_{progress, particular_reason}.
798 struct rx_ackPacket
{
799 u_short bufferSpace
; /* Skip! */
800 u_short maxSkew
; /* Skip! */
802 u_long previousPacket
; /* Obsolete! */
803 u_long serial
; /* Serial that prompted the ack, */
804 u_char reason
; /* and the reason why. */
806 u_char acks
[RX_MAXACKS
]; /* Selective acks (not a bitmap). */
809 #define RX_ACK_TYPE_NACK 0
811 TCHECK2(bp
[0], 8); /* bufferSpace and maxSkew */
813 printf(" fir %u", (unsigned)EXTRACT_32BITS(bp
));
815 TCHECK2(bp
[0], 8); /* previousPacket and serial */
817 printf(" %u", (unsigned)EXTRACT_32BITS(bp
));
820 printf("%c", RX_ACK_REASONS
[(*bp
- 1) & 07u]);
821 bp
+= 1; /* reason */
826 for (i
= 0; i
< nAcks
; i
++) {
828 putchar(*bp
== RX_ACK_TYPE_NACK
? '-' : '*');
839 * Handle calls to the AFS file service (fs)
843 fs_print(register const u_char
*bp
, int length
)
848 if (length
<= (int)sizeof(struct rx_header
))
851 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
856 * Print out the afs call we're invoking. The table used here was
857 * gleaned from fsint/afsint.xg
860 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
862 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
865 * Print out arguments to some of the AFS calls. This stuff is
869 bp
+= sizeof(struct rx_header
) + 4;
872 * Sigh. This is gross. Ritchie forgive me.
876 case 130: /* Fetch data */
883 case 131: /* Fetch ACL */
884 case 132: /* Fetch Status */
885 case 143: /* Old set lock */
886 case 144: /* Old extend lock */
887 case 145: /* Old release lock */
888 case 156: /* Set lock */
889 case 157: /* Extend lock */
890 case 158: /* Release lock */
893 case 135: /* Store status */
897 case 133: /* Store data */
907 case 134: /* Store ACL */
909 char a
[AFSOPAQUEMAX
+1];
912 i
= EXTRACT_32BITS(bp
);
913 bp
+= sizeof(int32_t);
915 i
= min(AFSOPAQUEMAX
, i
);
916 strncpy(a
, (char *) bp
, i
);
918 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
921 case 137: /* Create file */
922 case 141: /* MakeDir */
927 case 136: /* Remove file */
928 case 142: /* Remove directory */
932 case 138: /* Rename file */
940 case 139: /* Symlink */
952 case 148: /* Get volume info */
955 case 149: /* Get volume stats */
956 case 150: /* Set volume stats */
960 case 154: /* New get volume info */
964 case 155: /* Bulk stat */
968 j
= EXTRACT_32BITS(bp
);
969 bp
+= sizeof(int32_t);
971 for (i
= 0; i
< j
; i
++) {
990 * Handle replies to the AFS file service
994 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
997 struct rx_header
*rxh
;
999 if (length
<= (int)sizeof(struct rx_header
))
1002 rxh
= (struct rx_header
*) bp
;
1005 * Print out the afs call we're invoking. The table used here was
1006 * gleaned from fsint/afsint.xg
1009 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
1011 bp
+= sizeof(struct rx_header
);
1014 * If it was a data packet, interpret the response
1017 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
1019 case 131: /* Fetch ACL */
1021 char a
[AFSOPAQUEMAX
+1];
1023 i
= EXTRACT_32BITS(bp
);
1024 bp
+= sizeof(int32_t);
1026 i
= min(AFSOPAQUEMAX
, i
);
1027 strncpy(a
, (char *) bp
, i
);
1029 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1032 case 137: /* Create file */
1033 case 141: /* MakeDir */
1037 case 151: /* Get root volume */
1038 printf(" root volume");
1041 case 153: /* Get time */
1047 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1051 * Otherwise, just print out the return code
1053 TCHECK2(bp
[0], sizeof(int32_t));
1054 i
= (int) EXTRACT_32BITS(bp
);
1055 bp
+= sizeof(int32_t);
1057 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
1059 printf(" strange fs reply of type %d", rxh
->type
);
1069 * Print out an AFS ACL string. An AFS ACL is a string that has the
1072 * <positive> <negative>
1076 * "positive" and "negative" are integers which contain the number of
1077 * positive and negative ACL's in the string. The uid/aclbits pair are
1078 * ASCII strings containing the UID/PTS record and and a ascii number
1079 * representing a logical OR of all the ACL permission bits
1083 acl_print(u_char
*s
, int maxsize
, u_char
*end
)
1089 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1092 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1101 * This wacky order preserves the order used by the "fs" command
1104 #define ACLOUT(acl) \
1105 if (acl & PRSFS_READ) \
1107 if (acl & PRSFS_LOOKUP) \
1109 if (acl & PRSFS_INSERT) \
1111 if (acl & PRSFS_DELETE) \
1113 if (acl & PRSFS_WRITE) \
1115 if (acl & PRSFS_LOCK) \
1117 if (acl & PRSFS_ADMINISTER) \
1120 for (i
= 0; i
< pos
; i
++) {
1121 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1125 fn_print((u_char
*)user
, NULL
);
1133 for (i
= 0; i
< neg
; i
++) {
1134 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1138 fn_print((u_char
*)user
, NULL
);
1154 * Handle calls to the AFS callback service
1158 cb_print(register const u_char
*bp
, int length
)
1163 if (length
<= (int)sizeof(struct rx_header
))
1166 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1171 * Print out the afs call we're invoking. The table used here was
1172 * gleaned from fsint/afscbint.xg
1175 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1177 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1179 bp
+= sizeof(struct rx_header
) + 4;
1182 * Print out the afs call we're invoking. The table used here was
1183 * gleaned from fsint/afscbint.xg
1187 case 204: /* Callback */
1191 j
= EXTRACT_32BITS(bp
);
1192 bp
+= sizeof(int32_t);
1194 for (i
= 0; i
< j
; i
++) {
1203 j
= EXTRACT_32BITS(bp
);
1204 bp
+= sizeof(int32_t);
1209 for (i
= 0; i
< j
; i
++) {
1215 t
= EXTRACT_32BITS(bp
);
1216 bp
+= sizeof(int32_t);
1217 tok2str(cb_types
, "type %d", t
);
1236 * Handle replies to the AFS Callback Service
1240 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1242 struct rx_header
*rxh
;
1244 if (length
<= (int)sizeof(struct rx_header
))
1247 rxh
= (struct rx_header
*) bp
;
1250 * Print out the afs call we're invoking. The table used here was
1251 * gleaned from fsint/afscbint.xg
1254 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1256 bp
+= sizeof(struct rx_header
);
1259 * If it was a data packet, interpret the response.
1262 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1264 case 213: /* InitCallBackState3 */
1272 * Otherwise, just print out the return code
1285 * Handle calls to the AFS protection database server
1289 prot_print(register const u_char
*bp
, int length
)
1294 if (length
<= (int)sizeof(struct rx_header
))
1297 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1302 * Print out the afs call we're invoking. The table used here was
1303 * gleaned from ptserver/ptint.xg
1306 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1310 if (is_ubik(pt_op
)) {
1311 ubik_print(bp
, length
);
1315 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1318 * Decode some of the arguments to the PT calls
1321 bp
+= sizeof(struct rx_header
) + 4;
1324 case 500: /* I New User */
1331 case 501: /* Where is it */
1332 case 506: /* Delete */
1333 case 508: /* Get CPS */
1334 case 512: /* List entry */
1335 case 514: /* List elements */
1336 case 517: /* List owned */
1337 case 518: /* Get CPS2 */
1338 case 519: /* Get host CPS */
1342 case 502: /* Dump entry */
1346 case 503: /* Add to group */
1347 case 507: /* Remove from group */
1348 case 515: /* Is a member of? */
1354 case 504: /* Name to ID */
1358 j
= EXTRACT_32BITS(bp
);
1359 bp
+= sizeof(int32_t);
1362 * Who designed this chicken-shit protocol?
1364 * Each character is stored as a 32-bit
1368 for (i
= 0; i
< j
; i
++) {
1375 case 505: /* Id to name */
1380 i
= EXTRACT_32BITS(bp
);
1381 bp
+= sizeof(int32_t);
1382 for (j
= 0; j
< i
; j
++)
1388 case 509: /* New entry */
1395 case 511: /* Set max */
1401 case 513: /* Change entry */
1410 case 520: /* Update entry */
1427 * Handle replies to the AFS protection service
1431 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1433 struct rx_header
*rxh
;
1436 if (length
< (int)sizeof(struct rx_header
))
1439 rxh
= (struct rx_header
*) bp
;
1442 * Print out the afs call we're invoking. The table used here was
1443 * gleaned from ptserver/ptint.xg. Check to see if it's a
1444 * Ubik call, however.
1449 if (is_ubik(opcode
)) {
1450 ubik_reply_print(bp
, length
, opcode
);
1454 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1456 bp
+= sizeof(struct rx_header
);
1459 * If it was a data packet, interpret the response
1462 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1464 case 504: /* Name to ID */
1469 i
= EXTRACT_32BITS(bp
);
1470 bp
+= sizeof(int32_t);
1471 for (j
= 0; j
< i
; j
++)
1477 case 505: /* ID to name */
1481 j
= EXTRACT_32BITS(bp
);
1482 bp
+= sizeof(int32_t);
1485 * Who designed this chicken-shit protocol?
1487 * Each character is stored as a 32-bit
1491 for (i
= 0; i
< j
; i
++) {
1498 case 508: /* Get CPS */
1499 case 514: /* List elements */
1500 case 517: /* List owned */
1501 case 518: /* Get CPS2 */
1502 case 519: /* Get host CPS */
1506 j
= EXTRACT_32BITS(bp
);
1507 bp
+= sizeof(int32_t);
1508 for (i
= 0; i
< j
; i
++) {
1515 case 510: /* List max */
1526 * Otherwise, just print out the return code
1539 * Handle calls to the AFS volume location database service
1543 vldb_print(register const u_char
*bp
, int length
)
1548 if (length
<= (int)sizeof(struct rx_header
))
1551 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1556 * Print out the afs call we're invoking. The table used here was
1557 * gleaned from vlserver/vldbint.xg
1560 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1564 if (is_ubik(vldb_op
)) {
1565 ubik_print(bp
, length
);
1568 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1571 * Decode some of the arguments to the VLDB calls
1574 bp
+= sizeof(struct rx_header
) + 4;
1577 case 501: /* Create new volume */
1578 case 517: /* Create entry N */
1581 case 502: /* Delete entry */
1582 case 503: /* Get entry by ID */
1583 case 507: /* Update entry */
1584 case 508: /* Set lock */
1585 case 509: /* Release lock */
1586 case 518: /* Get entry by ID N */
1589 TCHECK2(bp
[0], sizeof(int32_t));
1590 i
= EXTRACT_32BITS(bp
);
1591 bp
+= sizeof(int32_t);
1593 printf(" type %s", voltype
[i
]);
1595 case 504: /* Get entry by name */
1596 case 519: /* Get entry by name N */
1597 case 524: /* Update entry by name */
1598 case 527: /* Get entry by name U */
1601 case 505: /* Get new vol id */
1605 case 506: /* Replace entry */
1606 case 520: /* Replace entry N */
1609 TCHECK2(bp
[0], sizeof(int32_t));
1610 i
= EXTRACT_32BITS(bp
);
1611 bp
+= sizeof(int32_t);
1613 printf(" type %s", voltype
[i
]);
1616 case 510: /* List entry */
1617 case 521: /* List entry N */
1632 * Handle replies to the AFS volume location database service
1636 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1638 struct rx_header
*rxh
;
1641 if (length
< (int)sizeof(struct rx_header
))
1644 rxh
= (struct rx_header
*) bp
;
1647 * Print out the afs call we're invoking. The table used here was
1648 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1649 * Ubik call, however.
1654 if (is_ubik(opcode
)) {
1655 ubik_reply_print(bp
, length
, opcode
);
1659 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1661 bp
+= sizeof(struct rx_header
);
1664 * If it was a data packet, interpret the response
1667 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1669 case 510: /* List entry */
1672 printf(" nextindex");
1674 case 503: /* Get entry by id */
1675 case 504: /* Get entry by name */
1676 { unsigned long nservers
, j
;
1678 TCHECK2(bp
[0], sizeof(int32_t));
1679 bp
+= sizeof(int32_t);
1680 printf(" numservers");
1681 TCHECK2(bp
[0], sizeof(int32_t));
1682 nservers
= EXTRACT_32BITS(bp
);
1683 bp
+= sizeof(int32_t);
1684 printf(" %lu", nservers
);
1686 for (i
= 0; i
< 8; i
++) {
1687 TCHECK2(bp
[0], sizeof(int32_t));
1690 intoa(((struct in_addr
*) bp
)->s_addr
));
1691 bp
+= sizeof(int32_t);
1693 printf(" partitions");
1694 for (i
= 0; i
< 8; i
++) {
1695 TCHECK2(bp
[0], sizeof(int32_t));
1696 j
= EXTRACT_32BITS(bp
);
1697 if (i
< nservers
&& j
<= 26)
1698 printf(" %c", 'a' + (int)j
);
1699 else if (i
< nservers
)
1701 bp
+= sizeof(int32_t);
1703 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1704 bp
+= 8 * sizeof(int32_t);
1713 case 505: /* Get new volume ID */
1717 case 521: /* List entry */
1718 case 529: /* List entry U */
1721 printf(" nextindex");
1723 case 518: /* Get entry by ID N */
1724 case 519: /* Get entry by name N */
1725 { unsigned long nservers
, j
;
1727 printf(" numservers");
1728 TCHECK2(bp
[0], sizeof(int32_t));
1729 nservers
= EXTRACT_32BITS(bp
);
1730 bp
+= sizeof(int32_t);
1731 printf(" %lu", nservers
);
1733 for (i
= 0; i
< 13; i
++) {
1734 TCHECK2(bp
[0], sizeof(int32_t));
1737 intoa(((struct in_addr
*) bp
)->s_addr
));
1738 bp
+= sizeof(int32_t);
1740 printf(" partitions");
1741 for (i
= 0; i
< 13; i
++) {
1742 TCHECK2(bp
[0], sizeof(int32_t));
1743 j
= EXTRACT_32BITS(bp
);
1744 if (i
< nservers
&& j
<= 26)
1745 printf(" %c", 'a' + (int)j
);
1746 else if (i
< nservers
)
1748 bp
+= sizeof(int32_t);
1750 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1751 bp
+= 13 * sizeof(int32_t);
1760 case 526: /* Get entry by ID U */
1761 case 527: /* Get entry by name U */
1762 { unsigned long nservers
, j
;
1764 printf(" numservers");
1765 TCHECK2(bp
[0], sizeof(int32_t));
1766 nservers
= EXTRACT_32BITS(bp
);
1767 bp
+= sizeof(int32_t);
1768 printf(" %lu", nservers
);
1770 for (i
= 0; i
< 13; i
++) {
1779 TCHECK2(bp
[0], 4 * 13);
1781 printf(" partitions");
1782 for (i
= 0; i
< 13; i
++) {
1783 TCHECK2(bp
[0], sizeof(int32_t));
1784 j
= EXTRACT_32BITS(bp
);
1785 if (i
< nservers
&& j
<= 26)
1786 printf(" %c", 'a' + (int)j
);
1787 else if (i
< nservers
)
1789 bp
+= sizeof(int32_t);
1791 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1792 bp
+= 13 * sizeof(int32_t);
1806 * Otherwise, just print out the return code
1819 * Handle calls to the AFS Kerberos Authentication service
1823 kauth_print(register const u_char
*bp
, int length
)
1827 if (length
<= (int)sizeof(struct rx_header
))
1830 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1835 * Print out the afs call we're invoking. The table used here was
1836 * gleaned from kauth/kauth.rg
1839 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1843 if (is_ubik(kauth_op
)) {
1844 ubik_print(bp
, length
);
1849 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1852 * Decode some of the arguments to the KA calls
1855 bp
+= sizeof(struct rx_header
) + 4;
1858 case 1: /* Authenticate old */;
1859 case 21: /* Authenticate */
1860 case 22: /* Authenticate-V2 */
1861 case 2: /* Change PW */
1862 case 5: /* Set fields */
1863 case 6: /* Create user */
1864 case 7: /* Delete user */
1865 case 8: /* Get entry */
1866 case 14: /* Unlock */
1867 case 15: /* Lock status */
1868 printf(" principal");
1872 case 3: /* GetTicket-old */
1873 case 23: /* GetTicket */
1880 TCHECK2(bp
[0], sizeof(int32_t));
1881 i
= (int) EXTRACT_32BITS(bp
);
1882 bp
+= sizeof(int32_t);
1885 printf(" principal");
1890 case 4: /* Set Password */
1891 printf(" principal");
1897 case 12: /* Get password */
1908 printf(" [|kauth]");
1912 * Handle replies to the AFS Kerberos Authentication Service
1916 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1918 struct rx_header
*rxh
;
1920 if (length
<= (int)sizeof(struct rx_header
))
1923 rxh
= (struct rx_header
*) bp
;
1926 * Print out the afs call we're invoking. The table used here was
1927 * gleaned from kauth/kauth.rg
1932 if (is_ubik(opcode
)) {
1933 ubik_reply_print(bp
, length
, opcode
);
1937 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1939 bp
+= sizeof(struct rx_header
);
1942 * If it was a data packet, interpret the response.
1945 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1946 /* Well, no, not really. Leave this for later */
1950 * Otherwise, just print out the return code
1959 printf(" [|kauth]");
1963 * Handle calls to the AFS Volume location service
1967 vol_print(register const u_char
*bp
, int length
)
1971 if (length
<= (int)sizeof(struct rx_header
))
1974 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1979 * Print out the afs call we're invoking. The table used here was
1980 * gleaned from volser/volint.xg
1983 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1985 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1988 * Normally there would be a switch statement here to decode the
1989 * arguments to the AFS call, but since I don't have access to
1990 * an AFS server (yet) and I'm not an AFS admin, I can't
1991 * test any of these calls. Leave this blank for now.
2001 * Handle replies to the AFS Volume Service
2005 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2007 struct rx_header
*rxh
;
2009 if (length
<= (int)sizeof(struct rx_header
))
2012 rxh
= (struct rx_header
*) bp
;
2015 * Print out the afs call we're invoking. The table used here was
2016 * gleaned from volser/volint.xg
2019 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
2021 bp
+= sizeof(struct rx_header
);
2024 * If it was a data packet, interpret the response.
2027 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2028 /* Well, no, not really. Leave this for later */
2032 * Otherwise, just print out the return code
2045 * Handle calls to the AFS BOS service
2049 bos_print(register const u_char
*bp
, int length
)
2053 if (length
<= (int)sizeof(struct rx_header
))
2056 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
2061 * Print out the afs call we're invoking. The table used here was
2062 * gleaned from bozo/bosint.xg
2065 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2067 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2070 * Decode some of the arguments to the BOS calls
2073 bp
+= sizeof(struct rx_header
) + 4;
2076 case 80: /* Create B node */
2079 printf(" instance");
2082 case 81: /* Delete B node */
2083 case 83: /* Get status */
2084 case 85: /* Get instance info */
2085 case 87: /* Add super user */
2086 case 88: /* Delete super user */
2087 case 93: /* Set cell name */
2088 case 96: /* Add cell host */
2089 case 97: /* Delete cell host */
2090 case 104: /* Restart */
2091 case 106: /* Uninstall */
2092 case 108: /* Exec */
2093 case 112: /* Getlog */
2094 case 114: /* Get instance strings */
2097 case 82: /* Set status */
2098 case 98: /* Set T status */
2103 case 86: /* Get instance parm */
2108 case 84: /* Enumerate instance */
2109 case 89: /* List super users */
2110 case 90: /* List keys */
2111 case 91: /* Add key */
2112 case 92: /* Delete key */
2113 case 95: /* Get cell host */
2116 case 105: /* Install */
2136 * Handle replies to the AFS BOS Service
2140 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2142 struct rx_header
*rxh
;
2144 if (length
<= (int)sizeof(struct rx_header
))
2147 rxh
= (struct rx_header
*) bp
;
2150 * Print out the afs call we're invoking. The table used here was
2151 * gleaned from volser/volint.xg
2154 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2156 bp
+= sizeof(struct rx_header
);
2159 * If it was a data packet, interpret the response.
2162 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2163 /* Well, no, not really. Leave this for later */
2167 * Otherwise, just print out the return code
2180 * Check to see if this is a Ubik opcode.
2184 is_ubik(u_int32_t opcode
)
2186 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2187 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2194 * Handle Ubik opcodes to any one of the replicated database services
2198 ubik_print(register const u_char
*bp
, int length
)
2204 * Print out the afs call we're invoking. The table used here was
2205 * gleaned from ubik/ubik_int.xg
2208 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2210 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2213 * Decode some of the arguments to the Ubik calls
2216 bp
+= sizeof(struct rx_header
) + 4;
2219 case 10000: /* Beacon */
2221 temp
= EXTRACT_32BITS(bp
);
2222 bp
+= sizeof(int32_t);
2223 printf(" syncsite %s", temp
? "yes" : "no");
2224 printf(" votestart");
2226 printf(" dbversion");
2231 case 10003: /* Get sync site */
2235 case 20000: /* Begin */
2236 case 20001: /* Commit */
2237 case 20007: /* Abort */
2238 case 20008: /* Release locks */
2239 case 20010: /* Writev */
2243 case 20002: /* Lock */
2252 temp
= EXTRACT_32BITS(bp
);
2253 bp
+= sizeof(int32_t);
2254 tok2str(ubik_lock_types
, "type %d", temp
);
2256 case 20003: /* Write */
2264 case 20005: /* Get file */
2268 case 20006: /* Send file */
2273 printf(" dbversion");
2276 case 20009: /* Truncate */
2284 case 20012: /* Set version */
2287 printf(" oldversion");
2289 printf(" newversion");
2303 * Handle Ubik replies to any one of the replicated database services
2307 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2309 struct rx_header
*rxh
;
2311 if (length
< (int)sizeof(struct rx_header
))
2314 rxh
= (struct rx_header
*) bp
;
2317 * Print out the ubik call we're invoking. This table was gleaned
2318 * from ubik/ubik_int.xg
2321 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2323 bp
+= sizeof(struct rx_header
);
2326 * If it was a data packet, print out the arguments to the Ubik calls
2329 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2331 case 10000: /* Beacon */
2334 case 20004: /* Get version */
2335 printf(" dbversion");
2343 * Otherwise, print out "yes" it it was a beacon packet (because
2344 * that's how yes votes are returned, go figure), otherwise
2345 * just print out the error code.
2350 case 10000: /* Beacon */
2351 printf(" vote yes until");
2366 * Handle RX ACK packets.
2370 rx_ack_print(register const u_char
*bp
, int length
)
2372 struct rx_ackPacket
*rxa
;
2375 if (length
< (int)sizeof(struct rx_header
))
2378 bp
+= sizeof(struct rx_header
);
2381 * This may seem a little odd .... the rx_ackPacket structure
2382 * contains an array of individual packet acknowledgements
2383 * (used for selective ack/nack), but since it's variable in size,
2384 * we don't want to truncate based on the size of the whole
2385 * rx_ackPacket structure.
2388 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2390 rxa
= (struct rx_ackPacket
*) bp
;
2391 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2394 * Print out a few useful things from the ack packet structure
2398 printf(" bufspace %d maxskew %d",
2399 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2400 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2402 printf(" first %d serial %d reason %s",
2403 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2404 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2407 * Okay, now we print out the ack array. The way _this_ works
2408 * is that we start at "first", and step through the ack array.
2409 * If we have a contiguous range of acks/nacks, try to
2410 * collapse them into a range.
2412 * If you're really clever, you might have noticed that this
2413 * doesn't seem quite correct. Specifically, due to structure
2414 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2415 * yield the start of the ack array (because RX_MAXACKS is 255
2416 * and the structure will likely get padded to a 2 or 4 byte
2417 * boundary). However, this is the way it's implemented inside
2418 * of AFS - the start of the extra fields are at
2419 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2420 * the exact start of the ack array. Sigh. That's why we aren't
2421 * using bp, but instead use rxa->acks[]. But nAcks gets added
2422 * to bp after this, so bp ends up at the right spot. Go figure.
2425 if (rxa
->nAcks
!= 0) {
2427 TCHECK2(bp
[0], rxa
->nAcks
);
2430 * Sigh, this is gross, but it seems to work to collapse
2434 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2435 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2438 * I figured this deserved _some_ explanation.
2439 * First, print "acked" and the packet seq
2440 * number if this is the first time we've
2441 * seen an acked packet.
2446 rxa
->firstPacket
+ i
);
2451 * Otherwise, if the there is a skip in
2452 * the range (such as an nacked packet in
2453 * the middle of some acked packets),
2454 * then print the current packet number
2455 * seperated from the last number by
2459 else if (last
!= i
- 1) {
2460 printf(",%d", rxa
->firstPacket
+ i
);
2465 * We always set last to the value of
2466 * the last ack we saw. Conversely, start
2467 * is set to the value of the first ack
2468 * we saw in a range.
2474 * Okay, this bit a code gets executed when
2475 * we hit a nack ... in _this_ case we
2476 * want to print out the range of packets
2477 * that were acked, so we need to print
2478 * the _previous_ packet number seperated
2479 * from the first by a dash (-). Since we
2480 * already printed the first packet above,
2481 * just print the final packet. Don't
2482 * do this if there will be a single-length
2485 } else if (last
== i
- 1 && start
!= last
)
2486 printf("-%d", rxa
->firstPacket
+ i
- 1);
2489 * So, what's going on here? We ran off the end of the
2490 * ack list, and if we got a range we need to finish it up.
2491 * So we need to determine if the last packet in the list
2492 * was an ack (if so, then last will be set to it) and
2493 * we need to see if the last range didn't start with the
2494 * last packet (because if it _did_, then that would mean
2495 * that the packet number has already been printed and
2496 * we don't need to print it again).
2499 if (last
== i
- 1 && start
!= last
)
2500 printf("-%d", rxa
->firstPacket
+ i
- 1);
2503 * Same as above, just without comments
2506 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2507 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2509 printf(" nacked %d",
2510 rxa
->firstPacket
+ i
);
2512 } else if (last
!= i
- 1) {
2513 printf(",%d", rxa
->firstPacket
+ i
);
2517 } else if (last
== i
- 1 && start
!= last
)
2518 printf("-%d", rxa
->firstPacket
+ i
- 1);
2520 if (last
== i
- 1 && start
!= last
)
2521 printf("-%d", rxa
->firstPacket
+ i
- 1);
2528 * These are optional fields; depending on your version of AFS,
2529 * you may or may not see them
2532 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2548 printf(" maxpackets");