]>
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>
42 #include <tcpdump-stdinc.h>
44 #include "interface.h"
45 #include "addrtoname.h"
50 #define FS_RX_PORT 7000
51 #define CB_RX_PORT 7001
52 #define PROT_RX_PORT 7002
53 #define VLDB_RX_PORT 7003
54 #define KAUTH_RX_PORT 7004
55 #define VOL_RX_PORT 7005
56 #define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
57 #define BOS_RX_PORT 7007
59 #define AFSNAMEMAX 256
60 #define AFSOPAQUEMAX 1024
64 #define BOSNAMEMAX 256
66 #define PRSFS_READ 1 /* Read files */
67 #define PRSFS_WRITE 2 /* Write files */
68 #define PRSFS_INSERT 4 /* Insert files into a directory */
69 #define PRSFS_LOOKUP 8 /* Lookup files into a directory */
70 #define PRSFS_DELETE 16 /* Delete files */
71 #define PRSFS_LOCK 32 /* Lock files */
72 #define PRSFS_ADMINISTER 64 /* Change ACL's */
81 #define RX_PACKET_TYPE_DATA 1
82 #define RX_PACKET_TYPE_ACK 2
83 #define RX_PACKET_TYPE_BUSY 3
84 #define RX_PACKET_TYPE_ABORT 4
85 #define RX_PACKET_TYPE_ACKALL 5
86 #define RX_PACKET_TYPE_CHALLENGE 6
87 #define RX_PACKET_TYPE_RESPONSE 7
88 #define RX_PACKET_TYPE_DEBUG 8
89 #define RX_PACKET_TYPE_PARAMS 9
90 #define RX_PACKET_TYPE_VERSION 13
92 #define RX_CLIENT_INITIATED 1
93 #define RX_REQUEST_ACK 2
94 #define RX_LAST_PACKET 4
95 #define RX_MORE_PACKETS 8
96 #define RX_FREE_PACKET 16
97 #define RX_SLOW_START_OK 32
98 #define RX_JUMBO_PACKET 32
100 u_int8_t securityIndex
;
101 u_int16_t spare
; /* How clever: even though the AFS */
102 u_int16_t serviceId
; /* header files indicate that the */
103 }; /* serviceId is first, it's really */
104 /* encoded _after_ the spare field */
105 /* I wasted a day figuring that out! */
107 #define NUM_RX_FLAGS 7
109 #define RX_MAXACKS 255
111 struct rx_ackPacket
{
112 u_int16_t bufferSpace
; /* Number of packet buffers available */
113 u_int16_t maxSkew
; /* Max diff between ack'd packet and */
114 /* highest packet received */
115 u_int32_t firstPacket
; /* The first packet in ack list */
116 u_int32_t previousPacket
; /* Previous packet recv'd (obsolete) */
117 u_int32_t serial
; /* # of packet that prompted the ack */
118 u_int8_t reason
; /* Reason for acknowledgement */
119 u_int8_t nAcks
; /* Number of acknowledgements */
120 u_int8_t acks
[RX_MAXACKS
]; /* Up to RX_MAXACKS acknowledgements */
124 * Values for the acks array
127 #define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
128 #define RX_ACK_TYPE_ACK 1 /* I have this packet */
130 static const struct tok rx_types
[] = {
131 { RX_PACKET_TYPE_DATA
, "data" },
132 { RX_PACKET_TYPE_ACK
, "ack" },
133 { RX_PACKET_TYPE_BUSY
, "busy" },
134 { RX_PACKET_TYPE_ABORT
, "abort" },
135 { RX_PACKET_TYPE_ACKALL
, "ackall" },
136 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
137 { RX_PACKET_TYPE_RESPONSE
, "response" },
138 { RX_PACKET_TYPE_DEBUG
, "debug" },
139 { RX_PACKET_TYPE_PARAMS
, "params" },
140 { RX_PACKET_TYPE_VERSION
, "version" },
144 static const struct double_tok
{
145 int flag
; /* Rx flag */
146 int packetType
; /* Packet type */
147 const char *s
; /* Flag string */
149 { RX_CLIENT_INITIATED
, 0, "client-init" },
150 { RX_REQUEST_ACK
, 0, "req-ack" },
151 { RX_LAST_PACKET
, 0, "last-pckt" },
152 { RX_MORE_PACKETS
, 0, "more-pckts" },
153 { RX_FREE_PACKET
, 0, "free-pckt" },
154 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
155 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
158 static const struct tok fs_req
[] = {
159 { 130, "fetch-data" },
160 { 131, "fetch-acl" },
161 { 132, "fetch-status" },
162 { 133, "store-data" },
163 { 134, "store-acl" },
164 { 135, "store-status" },
165 { 136, "remove-file" },
166 { 137, "create-file" },
172 { 143, "oldsetlock" },
173 { 144, "oldextlock" },
174 { 145, "oldrellock" },
175 { 146, "get-stats" },
177 { 148, "get-vlinfo" },
178 { 149, "get-vlstats" },
179 { 150, "set-vlstats" },
180 { 151, "get-rootvl" },
181 { 152, "check-token" },
183 { 154, "nget-vlinfo" },
184 { 155, "bulk-stat" },
188 { 159, "xstat-ver" },
189 { 160, "get-xstat" },
190 { 161, "dfs-lookup" },
191 { 162, "dfs-flushcps" },
192 { 163, "dfs-symlink" },
193 { 220, "residency" },
194 { 65536, "inline-bulk-status" },
195 { 65537, "fetch-data-64" },
196 { 65538, "store-data-64" },
197 { 65539, "give-up-all-cbs" },
198 { 65540, "get-caps" },
199 { 65541, "cb-rx-conn-addr" },
203 static const struct tok cb_req
[] = {
212 { 212, "whoareyou" },
214 { 214, "probeuuid" },
215 { 215, "getsrvprefs" },
216 { 216, "getcellservdb" },
217 { 217, "getlocalcell" },
218 { 218, "getcacheconf" },
219 { 65536, "getce64" },
220 { 65537, "getcellbynum" },
221 { 65538, "tellmeaboutyourself" },
225 static const struct tok pt_req
[] = {
227 { 501, "where-is-it" },
228 { 502, "dump-entry" },
229 { 503, "add-to-group" },
230 { 504, "name-to-id" },
231 { 505, "id-to-name" },
233 { 507, "remove-from-group" },
235 { 509, "new-entry" },
238 { 512, "list-entry" },
239 { 513, "change-entry" },
240 { 514, "list-elements" },
241 { 515, "same-mbr-of" },
242 { 516, "set-fld-sentry" },
243 { 517, "list-owned" },
245 { 519, "get-host-cps" },
246 { 520, "update-entry" },
247 { 521, "list-entries" },
248 { 530, "list-super-groups" },
252 static const struct tok vldb_req
[] = {
253 { 501, "create-entry" },
254 { 502, "delete-entry" },
255 { 503, "get-entry-by-id" },
256 { 504, "get-entry-by-name" },
257 { 505, "get-new-volume-id" },
258 { 506, "replace-entry" },
259 { 507, "update-entry" },
261 { 509, "releaselock" },
262 { 510, "list-entry" },
263 { 511, "list-attrib" },
264 { 512, "linked-list" },
265 { 513, "get-stats" },
267 { 515, "get-addrs" },
268 { 516, "change-addr" },
269 { 517, "create-entry-n" },
270 { 518, "get-entry-by-id-n" },
271 { 519, "get-entry-by-name-n" },
272 { 520, "replace-entry-n" },
273 { 521, "list-entry-n" },
274 { 522, "list-attrib-n" },
275 { 523, "linked-list-n" },
276 { 524, "update-entry-by-name" },
277 { 525, "create-entry-u" },
278 { 526, "get-entry-by-id-u" },
279 { 527, "get-entry-by-name-u" },
280 { 528, "replace-entry-u" },
281 { 529, "list-entry-u" },
282 { 530, "list-attrib-u" },
283 { 531, "linked-list-u" },
285 { 533, "get-addrs-u" },
286 { 534, "list-attrib-n2" },
290 static const struct tok kauth_req
[] = {
292 { 21, "authenticate" },
293 { 22, "authenticate-v2" },
295 { 3, "get-ticket-old" },
296 { 23, "get-ticket" },
299 { 6, "create-user" },
300 { 7, "delete-user" },
306 { 13, "get-random-key" },
308 { 15, "lock-status" },
312 static const struct tok vol_req
[] = {
313 { 100, "create-volume" },
314 { 101, "delete-volume" },
317 { 104, "end-trans" },
319 { 106, "set-flags" },
320 { 107, "get-flags" },
321 { 108, "trans-create" },
323 { 110, "get-nth-volume" },
324 { 111, "set-forwarding" },
326 { 113, "get-status" },
327 { 114, "sig-restore" },
328 { 115, "list-partitions" },
329 { 116, "list-volumes" },
330 { 117, "set-id-types" },
332 { 119, "partition-info" },
334 { 121, "list-one-volume" },
337 { 124, "x-list-volumes" },
338 { 125, "x-list-one-volume" },
340 { 127, "x-list-partitions" },
341 { 128, "forward-multiple" },
342 { 65536, "convert-ro" },
343 { 65537, "get-size" },
344 { 65538, "dump-v2" },
348 static const struct tok bos_req
[] = {
349 { 80, "create-bnode" },
350 { 81, "delete-bnode" },
351 { 82, "set-status" },
352 { 83, "get-status" },
353 { 84, "enumerate-instance" },
354 { 85, "get-instance-info" },
355 { 86, "get-instance-parm" },
356 { 87, "add-superuser" },
357 { 88, "delete-superuser" },
358 { 89, "list-superusers" },
361 { 92, "delete-key" },
362 { 93, "set-cell-name" },
363 { 94, "get-cell-name" },
364 { 95, "get-cell-host" },
365 { 96, "add-cell-host" },
366 { 97, "delete-cell-host" },
367 { 98, "set-t-status" },
368 { 99, "shutdown-all" },
369 { 100, "restart-all" },
370 { 101, "startup-all" },
371 { 102, "set-noauth-flag" },
374 { 105, "start-bozo-install" },
375 { 106, "uninstall" },
376 { 107, "get-dates" },
379 { 110, "set-restart-time" },
380 { 111, "get-restart-time" },
381 { 112, "start-bozo-log" },
383 { 114, "get-instance-strings" },
384 { 115, "get-restricted" },
385 { 116, "set-restricted" },
389 static const struct tok ubik_req
[] = {
390 { 10000, "vote-beacon" },
391 { 10001, "vote-debug-old" },
392 { 10002, "vote-sdebug-old" },
393 { 10003, "vote-getsyncsite" },
394 { 10004, "vote-debug" },
395 { 10005, "vote-sdebug" },
396 { 10006, "vote-xdebug" },
397 { 10007, "vote-xsdebug" },
398 { 20000, "disk-begin" },
399 { 20001, "disk-commit" },
400 { 20002, "disk-lock" },
401 { 20003, "disk-write" },
402 { 20004, "disk-getversion" },
403 { 20005, "disk-getfile" },
404 { 20006, "disk-sendfile" },
405 { 20007, "disk-abort" },
406 { 20008, "disk-releaselocks" },
407 { 20009, "disk-truncate" },
408 { 20010, "disk-probe" },
409 { 20011, "disk-writev" },
410 { 20012, "disk-interfaceaddr" },
411 { 20013, "disk-setversion" },
415 #define VOTE_LOW 10000
416 #define VOTE_HIGH 10007
417 #define DISK_LOW 20000
418 #define DISK_HIGH 20013
420 static const struct tok cb_types
[] = {
427 static const struct tok ubik_lock_types
[] = {
434 static const char *voltype
[] = { "read-write", "read-only", "backup" };
436 static const struct tok afs_fs_errors
[] = {
437 { 101, "salvage volume" },
438 { 102, "no such vnode" },
439 { 103, "no such volume" },
440 { 104, "volume exist" },
441 { 105, "no service" },
442 { 106, "volume offline" },
443 { 107, "voline online" },
445 { 109, "diskquota exceeded" },
446 { 110, "volume busy" },
447 { 111, "volume moved" },
448 { 112, "AFS IO error" },
449 { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */
454 * Reasons for acknowledging a packet
457 static const struct tok rx_ack_reasons
[] = {
458 { 1, "ack requested" },
459 { 2, "duplicate packet" },
460 { 3, "out of sequence" },
461 { 4, "exceeds window" },
462 { 5, "no buffer space" },
464 { 7, "ping response" },
471 * Cache entries we keep around so we can figure out the RX opcode
472 * numbers for replies. This allows us to make sense of RX reply packets.
475 struct rx_cache_entry
{
476 u_int32_t callnum
; /* Call number (net order) */
477 struct in_addr client
; /* client IP address (net order) */
478 struct in_addr server
; /* server IP address (net order) */
479 int dport
; /* server port (host order) */
480 u_short serviceId
; /* Service identifier (net order) */
481 u_int32_t opcode
; /* RX opcode (host order) */
484 #define RX_CACHE_SIZE 64
486 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
488 static int rx_cache_next
= 0;
489 static int rx_cache_hint
= 0;
490 static void rx_cache_insert(const u_char
*, const struct ip
*, int);
491 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
494 static void fs_print(const u_char
*, int);
495 static void fs_reply_print(const u_char
*, int, int32_t);
496 static void acl_print(u_char
*, int, u_char
*);
497 static void cb_print(const u_char
*, int);
498 static void cb_reply_print(const u_char
*, int, int32_t);
499 static void prot_print(const u_char
*, int);
500 static void prot_reply_print(const u_char
*, int, int32_t);
501 static void vldb_print(const u_char
*, int);
502 static void vldb_reply_print(const u_char
*, int, int32_t);
503 static void kauth_print(const u_char
*, int);
504 static void kauth_reply_print(const u_char
*, int, int32_t);
505 static void vol_print(const u_char
*, int);
506 static void vol_reply_print(const u_char
*, int, int32_t);
507 static void bos_print(const u_char
*, int);
508 static void bos_reply_print(const u_char
*, int, int32_t);
509 static void ubik_print(const u_char
*);
510 static void ubik_reply_print(const u_char
*, int, int32_t);
512 static void rx_ack_print(const u_char
*, int);
514 static int is_ubik(u_int32_t
);
517 * Handle the rx-level packet. See if we know what port it's going to so
518 * we can peek at the afs call inside
522 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
525 register struct rx_header
*rxh
;
529 if (snapend
- bp
< (int)sizeof (struct rx_header
)) {
530 printf(" [|rx] (%d)", length
);
534 rxh
= (struct rx_header
*) bp
;
536 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
542 printf(" cid %08x call# %d",
543 (int) EXTRACT_32BITS(&rxh
->cid
),
544 (int) EXTRACT_32BITS(&rxh
->callNumber
));
546 printf(" seq %d ser %d",
547 (int) EXTRACT_32BITS(&rxh
->seq
),
548 (int) EXTRACT_32BITS(&rxh
->serial
));
551 printf(" secindex %d serviceid %hu",
552 (int) rxh
->securityIndex
,
553 EXTRACT_16BITS(&rxh
->serviceId
));
556 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
557 if (rxh
->flags
& rx_flags
[i
].flag
&&
558 (!rx_flags
[i
].packetType
||
559 rxh
->type
== rx_flags
[i
].packetType
)) {
566 printf("<%s>", rx_flags
[i
].s
);
572 * Try to handle AFS calls that we know about. Check the destination
573 * port and make sure it's a data packet. Also, make sure the
574 * seq number is 1 (because otherwise it's a continuation packet,
575 * and we can't interpret that). Also, seems that reply packets
576 * do not have the client-init flag set, so we check for that
580 if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
581 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
582 rxh
->flags
& RX_CLIENT_INITIATED
) {
585 * Insert this call into the call cache table, so we
586 * have a chance to print out replies
589 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
);
592 case FS_RX_PORT
: /* AFS file service */
593 fs_print(bp
, length
);
595 case CB_RX_PORT
: /* AFS callback service */
596 cb_print(bp
, length
);
598 case PROT_RX_PORT
: /* AFS protection service */
599 prot_print(bp
, length
);
601 case VLDB_RX_PORT
: /* AFS VLDB service */
602 vldb_print(bp
, length
);
604 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
605 kauth_print(bp
, length
);
607 case VOL_RX_PORT
: /* AFS Volume service */
608 vol_print(bp
, length
);
610 case BOS_RX_PORT
: /* AFS BOS service */
611 bos_print(bp
, length
);
618 * If it's a reply (client-init is _not_ set, but seq is one)
619 * then look it up in the cache. If we find it, call the reply
620 * printing functions Note that we handle abort packets here,
621 * because printing out the return code can be useful at times.
624 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
625 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
626 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
627 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
628 rx_cache_find(rxh
, (const struct ip
*) bp2
,
632 case FS_RX_PORT
: /* AFS file service */
633 fs_reply_print(bp
, length
, opcode
);
635 case CB_RX_PORT
: /* AFS callback service */
636 cb_reply_print(bp
, length
, opcode
);
638 case PROT_RX_PORT
: /* AFS PT service */
639 prot_reply_print(bp
, length
, opcode
);
641 case VLDB_RX_PORT
: /* AFS VLDB service */
642 vldb_reply_print(bp
, length
, opcode
);
644 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
645 kauth_reply_print(bp
, length
, opcode
);
647 case VOL_RX_PORT
: /* AFS Volume service */
648 vol_reply_print(bp
, length
, opcode
);
650 case BOS_RX_PORT
: /* AFS BOS service */
651 bos_reply_print(bp
, length
, opcode
);
658 * If it's an RX ack packet, then use the appropriate ack decoding
659 * function (there isn't any service-specific information in the
660 * ack packet, so we can use one for all AFS services)
663 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
664 rx_ack_print(bp
, length
);
667 printf(" (%d)", length
);
671 * Insert an entry into the cache. Taken from print-nfs.c
675 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
)
677 struct rx_cache_entry
*rxent
;
678 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
680 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t)))
683 rxent
= &rx_cache
[rx_cache_next
];
685 if (++rx_cache_next
>= RX_CACHE_SIZE
)
688 rxent
->callnum
= rxh
->callNumber
;
689 rxent
->client
= ip
->ip_src
;
690 rxent
->server
= ip
->ip_dst
;
691 rxent
->dport
= dport
;
692 rxent
->serviceId
= rxh
->serviceId
;
693 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
697 * Lookup an entry in the cache. Also taken from print-nfs.c
699 * Note that because this is a reply, we're looking at the _source_
704 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
708 struct rx_cache_entry
*rxent
;
709 u_int32_t clip
= ip
->ip_dst
.s_addr
;
710 u_int32_t sip
= ip
->ip_src
.s_addr
;
712 /* Start the search where we last left off */
716 rxent
= &rx_cache
[i
];
717 if (rxent
->callnum
== rxh
->callNumber
&&
718 rxent
->client
.s_addr
== clip
&&
719 rxent
->server
.s_addr
== sip
&&
720 rxent
->serviceId
== rxh
->serviceId
&&
721 rxent
->dport
== sport
) {
723 /* We got a match! */
726 *opcode
= rxent
->opcode
;
729 if (++i
>= RX_CACHE_SIZE
)
731 } while (i
!= rx_cache_hint
);
733 /* Our search failed */
738 * These extrememly grody macros handle the printing of various AFS stuff.
741 #define FIDOUT() { unsigned long n1, n2, n3; \
742 TCHECK2(bp[0], sizeof(int32_t) * 3); \
743 n1 = EXTRACT_32BITS(bp); \
744 bp += sizeof(int32_t); \
745 n2 = EXTRACT_32BITS(bp); \
746 bp += sizeof(int32_t); \
747 n3 = EXTRACT_32BITS(bp); \
748 bp += sizeof(int32_t); \
749 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
752 #define STROUT(MAX) { unsigned int i; \
753 TCHECK2(bp[0], sizeof(int32_t)); \
754 i = EXTRACT_32BITS(bp); \
757 bp += sizeof(int32_t); \
759 if (fn_printn(bp, i, snapend)) \
762 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
765 #define INTOUT() { int i; \
766 TCHECK2(bp[0], sizeof(int32_t)); \
767 i = (int) EXTRACT_32BITS(bp); \
768 bp += sizeof(int32_t); \
772 #define UINTOUT() { unsigned long i; \
773 TCHECK2(bp[0], sizeof(int32_t)); \
774 i = EXTRACT_32BITS(bp); \
775 bp += sizeof(int32_t); \
779 #define UINT64OUT() { u_int64_t i; \
780 TCHECK2(bp[0], sizeof(u_int64_t)); \
781 i = EXTRACT_64BITS(bp); \
782 bp += sizeof(u_int64_t); \
783 printf(" %" PRIu64, i); \
786 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
787 TCHECK2(bp[0], sizeof(int32_t)); \
788 t = (time_t) EXTRACT_32BITS(bp); \
789 bp += sizeof(int32_t); \
790 tm = localtime(&t); \
791 strftime(str, 256, "%Y/%m/%d %T", tm); \
792 printf(" %s", str); \
795 #define STOREATTROUT() { unsigned long mask, i; \
796 TCHECK2(bp[0], (sizeof(int32_t)*6)); \
797 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
798 if (mask) printf (" StoreStatus"); \
799 if (mask & 1) { printf(" date"); DATEOUT(); } \
800 else bp += sizeof(int32_t); \
801 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
802 if (mask & 2) printf(" owner %lu", i); \
803 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
804 if (mask & 4) printf(" group %lu", i); \
805 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
806 if (mask & 8) printf(" mode %lo", i & 07777); \
807 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
808 if (mask & 16) printf(" segsize %lu", i); \
809 /* undocumented in 3.3 docu */ \
810 if (mask & 1024) printf(" fsync"); \
813 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
814 TCHECK2(bp[0], sizeof(int32_t) * 2); \
815 epoch = EXTRACT_32BITS(bp); \
816 bp += sizeof(int32_t); \
817 counter = EXTRACT_32BITS(bp); \
818 bp += sizeof(int32_t); \
819 printf(" %d.%d", epoch, counter); \
822 #define AFSUUIDOUT() {u_int32_t temp; int i; \
823 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
824 temp = EXTRACT_32BITS(bp); \
825 bp += sizeof(u_int32_t); \
826 printf(" %08x", temp); \
827 temp = EXTRACT_32BITS(bp); \
828 bp += sizeof(u_int32_t); \
829 printf("%04x", temp); \
830 temp = EXTRACT_32BITS(bp); \
831 bp += sizeof(u_int32_t); \
832 printf("%04x", temp); \
833 for (i = 0; i < 8; i++) { \
834 temp = EXTRACT_32BITS(bp); \
835 bp += sizeof(u_int32_t); \
836 printf("%02x", (unsigned char) temp); \
841 * This is the sickest one of all
844 #define VECOUT(MAX) { u_char *sp; \
845 u_char s[AFSNAMEMAX]; \
847 if ((MAX) + 1 > sizeof(s)) \
849 TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
851 for (k = 0; k < (MAX); k++) { \
852 *sp++ = (u_char) EXTRACT_32BITS(bp); \
853 bp += sizeof(int32_t); \
861 #define DESTSERVEROUT() { unsigned long n1, n2, n3; \
862 TCHECK2(bp[0], sizeof(int32_t) * 3); \
863 n1 = EXTRACT_32BITS(bp); \
864 bp += sizeof(int32_t); \
865 n2 = EXTRACT_32BITS(bp); \
866 bp += sizeof(int32_t); \
867 n3 = EXTRACT_32BITS(bp); \
868 bp += sizeof(int32_t); \
869 printf(" server %d:%d:%d", (int) n1, (int) n2, (int) n3); \
873 * Handle calls to the AFS file service (fs)
877 fs_print(register const u_char
*bp
, int length
)
882 if (length
<= (int)sizeof(struct rx_header
))
885 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
890 * Print out the afs call we're invoking. The table used here was
891 * gleaned from fsint/afsint.xg
894 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
896 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
899 * Print out arguments to some of the AFS calls. This stuff is
903 bp
+= sizeof(struct rx_header
) + 4;
906 * Sigh. This is gross. Ritchie forgive me.
910 case 130: /* Fetch data */
917 case 131: /* Fetch ACL */
918 case 132: /* Fetch Status */
919 case 143: /* Old set lock */
920 case 144: /* Old extend lock */
921 case 145: /* Old release lock */
922 case 156: /* Set lock */
923 case 157: /* Extend lock */
924 case 158: /* Release lock */
927 case 135: /* Store status */
931 case 133: /* Store data */
941 case 134: /* Store ACL */
943 char a
[AFSOPAQUEMAX
+1];
946 i
= EXTRACT_32BITS(bp
);
947 bp
+= sizeof(int32_t);
949 i
= min(AFSOPAQUEMAX
, i
);
950 strncpy(a
, (char *) bp
, i
);
952 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
955 case 137: /* Create file */
956 case 141: /* MakeDir */
961 case 136: /* Remove file */
962 case 142: /* Remove directory */
966 case 138: /* Rename file */
974 case 139: /* Symlink */
986 case 148: /* Get volume info */
989 case 149: /* Get volume stats */
990 case 150: /* Set volume stats */
994 case 154: /* New get volume info */
998 case 155: /* Bulk stat */
999 case 65536: /* Inline bulk stat */
1003 j
= EXTRACT_32BITS(bp
);
1004 bp
+= sizeof(int32_t);
1006 for (i
= 0; i
< j
; i
++) {
1014 case 65537: /* Fetch data 64 */
1021 case 65538: /* Store data 64 */
1031 case 65541: /* CallBack rx conn address */
1045 * Handle replies to the AFS file service
1049 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1052 struct rx_header
*rxh
;
1054 if (length
<= (int)sizeof(struct rx_header
))
1057 rxh
= (struct rx_header
*) bp
;
1060 * Print out the afs call we're invoking. The table used here was
1061 * gleaned from fsint/afsint.xg
1064 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
1066 bp
+= sizeof(struct rx_header
);
1069 * If it was a data packet, interpret the response
1072 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
1074 case 131: /* Fetch ACL */
1076 char a
[AFSOPAQUEMAX
+1];
1078 i
= EXTRACT_32BITS(bp
);
1079 bp
+= sizeof(int32_t);
1081 i
= min(AFSOPAQUEMAX
, i
);
1082 strncpy(a
, (char *) bp
, i
);
1084 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1087 case 137: /* Create file */
1088 case 141: /* MakeDir */
1092 case 151: /* Get root volume */
1093 printf(" root volume");
1096 case 153: /* Get time */
1102 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1106 * Otherwise, just print out the return code
1108 TCHECK2(bp
[0], sizeof(int32_t));
1109 i
= (int) EXTRACT_32BITS(bp
);
1110 bp
+= sizeof(int32_t);
1112 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
1114 printf(" strange fs reply of type %d", rxh
->type
);
1124 * Print out an AFS ACL string. An AFS ACL is a string that has the
1127 * <positive> <negative>
1131 * "positive" and "negative" are integers which contain the number of
1132 * positive and negative ACL's in the string. The uid/aclbits pair are
1133 * ASCII strings containing the UID/PTS record and and a ascii number
1134 * representing a logical OR of all the ACL permission bits
1138 acl_print(u_char
*s
, int maxsize
, u_char
*end
)
1145 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1148 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1157 * This wacky order preserves the order used by the "fs" command
1160 #define ACLOUT(acl) \
1161 if (acl & PRSFS_READ) \
1163 if (acl & PRSFS_LOOKUP) \
1165 if (acl & PRSFS_INSERT) \
1167 if (acl & PRSFS_DELETE) \
1169 if (acl & PRSFS_WRITE) \
1171 if (acl & PRSFS_LOCK) \
1173 if (acl & PRSFS_ADMINISTER) \
1176 for (i
= 0; i
< pos
; i
++) {
1177 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1178 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1182 fn_print((u_char
*)user
, NULL
);
1190 for (i
= 0; i
< neg
; i
++) {
1191 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1192 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1196 fn_print((u_char
*)user
, NULL
);
1212 * Handle calls to the AFS callback service
1216 cb_print(register const u_char
*bp
, int length
)
1221 if (length
<= (int)sizeof(struct rx_header
))
1224 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1229 * Print out the afs call we're invoking. The table used here was
1230 * gleaned from fsint/afscbint.xg
1233 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1235 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1237 bp
+= sizeof(struct rx_header
) + 4;
1240 * Print out the afs call we're invoking. The table used here was
1241 * gleaned from fsint/afscbint.xg
1245 case 204: /* Callback */
1249 j
= EXTRACT_32BITS(bp
);
1250 bp
+= sizeof(int32_t);
1252 for (i
= 0; i
< j
; i
++) {
1261 j
= EXTRACT_32BITS(bp
);
1262 bp
+= sizeof(int32_t);
1267 for (i
= 0; i
< j
; i
++) {
1273 t
= EXTRACT_32BITS(bp
);
1274 bp
+= sizeof(int32_t);
1275 tok2str(cb_types
, "type %d", t
);
1294 * Handle replies to the AFS Callback Service
1298 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1300 struct rx_header
*rxh
;
1302 if (length
<= (int)sizeof(struct rx_header
))
1305 rxh
= (struct rx_header
*) bp
;
1308 * Print out the afs call we're invoking. The table used here was
1309 * gleaned from fsint/afscbint.xg
1312 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1314 bp
+= sizeof(struct rx_header
);
1317 * If it was a data packet, interpret the response.
1320 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1322 case 213: /* InitCallBackState3 */
1330 * Otherwise, just print out the return code
1343 * Handle calls to the AFS protection database server
1347 prot_print(register const u_char
*bp
, int length
)
1352 if (length
<= (int)sizeof(struct rx_header
))
1355 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1360 * Print out the afs call we're invoking. The table used here was
1361 * gleaned from ptserver/ptint.xg
1364 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1368 if (is_ubik(pt_op
)) {
1373 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1376 * Decode some of the arguments to the PT calls
1379 bp
+= sizeof(struct rx_header
) + 4;
1382 case 500: /* I New User */
1389 case 501: /* Where is it */
1390 case 506: /* Delete */
1391 case 508: /* Get CPS */
1392 case 512: /* List entry */
1393 case 514: /* List elements */
1394 case 517: /* List owned */
1395 case 518: /* Get CPS2 */
1396 case 519: /* Get host CPS */
1397 case 530: /* List super groups */
1401 case 502: /* Dump entry */
1405 case 503: /* Add to group */
1406 case 507: /* Remove from group */
1407 case 515: /* Is a member of? */
1413 case 504: /* Name to ID */
1417 j
= EXTRACT_32BITS(bp
);
1418 bp
+= sizeof(int32_t);
1421 * Who designed this chicken-shit protocol?
1423 * Each character is stored as a 32-bit
1427 for (i
= 0; i
< j
; i
++) {
1434 case 505: /* Id to name */
1439 i
= EXTRACT_32BITS(bp
);
1440 bp
+= sizeof(int32_t);
1441 for (j
= 0; j
< i
; j
++)
1447 case 509: /* New entry */
1454 case 511: /* Set max */
1460 case 513: /* Change entry */
1469 case 520: /* Update entry */
1486 * Handle replies to the AFS protection service
1490 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1492 struct rx_header
*rxh
;
1495 if (length
< (int)sizeof(struct rx_header
))
1498 rxh
= (struct rx_header
*) bp
;
1501 * Print out the afs call we're invoking. The table used here was
1502 * gleaned from ptserver/ptint.xg. Check to see if it's a
1503 * Ubik call, however.
1508 if (is_ubik(opcode
)) {
1509 ubik_reply_print(bp
, length
, opcode
);
1513 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1515 bp
+= sizeof(struct rx_header
);
1518 * If it was a data packet, interpret the response
1521 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1523 case 504: /* Name to ID */
1528 i
= EXTRACT_32BITS(bp
);
1529 bp
+= sizeof(int32_t);
1530 for (j
= 0; j
< i
; j
++)
1536 case 505: /* ID to name */
1540 j
= EXTRACT_32BITS(bp
);
1541 bp
+= sizeof(int32_t);
1544 * Who designed this chicken-shit protocol?
1546 * Each character is stored as a 32-bit
1550 for (i
= 0; i
< j
; i
++) {
1557 case 508: /* Get CPS */
1558 case 514: /* List elements */
1559 case 517: /* List owned */
1560 case 518: /* Get CPS2 */
1561 case 519: /* Get host CPS */
1565 j
= EXTRACT_32BITS(bp
);
1566 bp
+= sizeof(int32_t);
1567 for (i
= 0; i
< j
; i
++) {
1574 case 510: /* List max */
1585 * Otherwise, just print out the return code
1598 * Handle calls to the AFS volume location database service
1602 vldb_print(register const u_char
*bp
, int length
)
1607 if (length
<= (int)sizeof(struct rx_header
))
1610 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1615 * Print out the afs call we're invoking. The table used here was
1616 * gleaned from vlserver/vldbint.xg
1619 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1623 if (is_ubik(vldb_op
)) {
1627 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1630 * Decode some of the arguments to the VLDB calls
1633 bp
+= sizeof(struct rx_header
) + 4;
1636 case 501: /* Create new volume */
1637 case 517: /* Create entry N */
1640 case 502: /* Delete entry */
1641 case 503: /* Get entry by ID */
1642 case 507: /* Update entry */
1643 case 508: /* Set lock */
1644 case 509: /* Release lock */
1645 case 518: /* Get entry by ID N */
1648 TCHECK2(bp
[0], sizeof(int32_t));
1649 i
= EXTRACT_32BITS(bp
);
1650 bp
+= sizeof(int32_t);
1652 printf(" type %s", voltype
[i
]);
1654 case 504: /* Get entry by name */
1655 case 519: /* Get entry by name N */
1656 case 524: /* Update entry by name */
1657 case 527: /* Get entry by name U */
1660 case 505: /* Get new vol id */
1664 case 506: /* Replace entry */
1665 case 520: /* Replace entry N */
1668 TCHECK2(bp
[0], sizeof(int32_t));
1669 i
= EXTRACT_32BITS(bp
);
1670 bp
+= sizeof(int32_t);
1672 printf(" type %s", voltype
[i
]);
1675 case 510: /* List entry */
1676 case 521: /* List entry N */
1691 * Handle replies to the AFS volume location database service
1695 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1697 struct rx_header
*rxh
;
1700 if (length
< (int)sizeof(struct rx_header
))
1703 rxh
= (struct rx_header
*) bp
;
1706 * Print out the afs call we're invoking. The table used here was
1707 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1708 * Ubik call, however.
1713 if (is_ubik(opcode
)) {
1714 ubik_reply_print(bp
, length
, opcode
);
1718 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1720 bp
+= sizeof(struct rx_header
);
1723 * If it was a data packet, interpret the response
1726 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1728 case 510: /* List entry */
1731 printf(" nextindex");
1733 case 503: /* Get entry by id */
1734 case 504: /* Get entry by name */
1735 { unsigned long nservers
, j
;
1737 TCHECK2(bp
[0], sizeof(int32_t));
1738 bp
+= sizeof(int32_t);
1739 printf(" numservers");
1740 TCHECK2(bp
[0], sizeof(int32_t));
1741 nservers
= EXTRACT_32BITS(bp
);
1742 bp
+= sizeof(int32_t);
1743 printf(" %lu", nservers
);
1745 for (i
= 0; i
< 8; i
++) {
1746 TCHECK2(bp
[0], sizeof(int32_t));
1749 intoa(((struct in_addr
*) bp
)->s_addr
));
1750 bp
+= sizeof(int32_t);
1752 printf(" partitions");
1753 for (i
= 0; i
< 8; i
++) {
1754 TCHECK2(bp
[0], sizeof(int32_t));
1755 j
= EXTRACT_32BITS(bp
);
1756 if (i
< nservers
&& j
<= 26)
1757 printf(" %c", 'a' + (int)j
);
1758 else if (i
< nservers
)
1760 bp
+= sizeof(int32_t);
1762 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1763 bp
+= 8 * sizeof(int32_t);
1772 case 505: /* Get new volume ID */
1776 case 521: /* List entry */
1777 case 529: /* List entry U */
1780 printf(" nextindex");
1782 case 518: /* Get entry by ID N */
1783 case 519: /* Get entry by name N */
1784 { unsigned long nservers
, j
;
1786 printf(" numservers");
1787 TCHECK2(bp
[0], sizeof(int32_t));
1788 nservers
= EXTRACT_32BITS(bp
);
1789 bp
+= sizeof(int32_t);
1790 printf(" %lu", nservers
);
1792 for (i
= 0; i
< 13; i
++) {
1793 TCHECK2(bp
[0], sizeof(int32_t));
1796 intoa(((struct in_addr
*) bp
)->s_addr
));
1797 bp
+= sizeof(int32_t);
1799 printf(" partitions");
1800 for (i
= 0; i
< 13; i
++) {
1801 TCHECK2(bp
[0], sizeof(int32_t));
1802 j
= EXTRACT_32BITS(bp
);
1803 if (i
< nservers
&& j
<= 26)
1804 printf(" %c", 'a' + (int)j
);
1805 else if (i
< nservers
)
1807 bp
+= sizeof(int32_t);
1809 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1810 bp
+= 13 * sizeof(int32_t);
1819 case 526: /* Get entry by ID U */
1820 case 527: /* Get entry by name U */
1821 { unsigned long nservers
, j
;
1823 printf(" numservers");
1824 TCHECK2(bp
[0], sizeof(int32_t));
1825 nservers
= EXTRACT_32BITS(bp
);
1826 bp
+= sizeof(int32_t);
1827 printf(" %lu", nservers
);
1829 for (i
= 0; i
< 13; i
++) {
1838 TCHECK2(bp
[0], 4 * 13);
1840 printf(" partitions");
1841 for (i
= 0; i
< 13; i
++) {
1842 TCHECK2(bp
[0], sizeof(int32_t));
1843 j
= EXTRACT_32BITS(bp
);
1844 if (i
< nservers
&& j
<= 26)
1845 printf(" %c", 'a' + (int)j
);
1846 else if (i
< nservers
)
1848 bp
+= sizeof(int32_t);
1850 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1851 bp
+= 13 * sizeof(int32_t);
1865 * Otherwise, just print out the return code
1878 * Handle calls to the AFS Kerberos Authentication service
1882 kauth_print(register const u_char
*bp
, int length
)
1886 if (length
<= (int)sizeof(struct rx_header
))
1889 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1894 * Print out the afs call we're invoking. The table used here was
1895 * gleaned from kauth/kauth.rg
1898 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1902 if (is_ubik(kauth_op
)) {
1908 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1911 * Decode some of the arguments to the KA calls
1914 bp
+= sizeof(struct rx_header
) + 4;
1917 case 1: /* Authenticate old */;
1918 case 21: /* Authenticate */
1919 case 22: /* Authenticate-V2 */
1920 case 2: /* Change PW */
1921 case 5: /* Set fields */
1922 case 6: /* Create user */
1923 case 7: /* Delete user */
1924 case 8: /* Get entry */
1925 case 14: /* Unlock */
1926 case 15: /* Lock status */
1927 printf(" principal");
1931 case 3: /* GetTicket-old */
1932 case 23: /* GetTicket */
1939 TCHECK2(bp
[0], sizeof(int32_t));
1940 i
= (int) EXTRACT_32BITS(bp
);
1941 bp
+= sizeof(int32_t);
1944 printf(" principal");
1949 case 4: /* Set Password */
1950 printf(" principal");
1956 case 12: /* Get password */
1967 printf(" [|kauth]");
1971 * Handle replies to the AFS Kerberos Authentication Service
1975 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1977 struct rx_header
*rxh
;
1979 if (length
<= (int)sizeof(struct rx_header
))
1982 rxh
= (struct rx_header
*) bp
;
1985 * Print out the afs call we're invoking. The table used here was
1986 * gleaned from kauth/kauth.rg
1991 if (is_ubik(opcode
)) {
1992 ubik_reply_print(bp
, length
, opcode
);
1996 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1998 bp
+= sizeof(struct rx_header
);
2001 * If it was a data packet, interpret the response.
2004 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2005 /* Well, no, not really. Leave this for later */
2009 * Otherwise, just print out the return code
2018 printf(" [|kauth]");
2022 * Handle calls to the AFS Volume location service
2026 vol_print(register const u_char
*bp
, int length
)
2030 if (length
<= (int)sizeof(struct rx_header
))
2033 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
2038 * Print out the afs call we're invoking. The table used here was
2039 * gleaned from volser/volint.xg
2042 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2044 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
2046 bp
+= sizeof(struct rx_header
) + 4;
2049 case 100: /* Create volume */
2050 printf(" partition");
2059 case 101: /* Delete volume */
2060 case 107: /* Get flags */
2064 case 102: /* Restore */
2070 case 103: /* Forward */
2071 printf(" fromtrans");
2073 printf(" fromdate");
2076 printf(" desttrans");
2079 case 104: /* End trans */
2083 case 105: /* Clone */
2086 printf(" purgevol");
2093 case 106: /* Set flags */
2099 case 108: /* Trans create */
2102 printf(" partition");
2107 case 109: /* Dump */
2108 case 655537: /* Get size */
2109 printf(" fromtrans");
2111 printf(" fromdate");
2114 case 110: /* Get n-th volume */
2118 case 111: /* Set forwarding */
2124 case 112: /* Get name */
2125 case 113: /* Get status */
2128 case 114: /* Signal restore */
2138 case 116: /* List volumes */
2139 printf(" partition");
2144 case 117: /* Set id types */
2158 case 119: /* Partition info */
2162 case 120: /* Reclone */
2166 case 121: /* List one volume */
2167 case 122: /* Nuke volume */
2168 case 124: /* Extended List volumes */
2169 case 125: /* Extended List one volume */
2170 case 65536: /* Convert RO to RW volume */
2176 case 123: /* Set date */
2182 case 126: /* Set info */
2186 case 128: /* Forward multiple */
2187 printf(" fromtrans");
2189 printf(" fromdate");
2194 j
= EXTRACT_32BITS(bp
);
2195 bp
+= sizeof(int32_t);
2196 for (i
= 0; i
< j
; i
++) {
2205 case 65538: /* Dump version 2 */
2206 printf(" fromtrans");
2208 printf(" fromdate");
2223 * Handle replies to the AFS Volume Service
2227 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2229 struct rx_header
*rxh
;
2231 if (length
<= (int)sizeof(struct rx_header
))
2234 rxh
= (struct rx_header
*) bp
;
2237 * Print out the afs call we're invoking. The table used here was
2238 * gleaned from volser/volint.xg
2241 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
2243 bp
+= sizeof(struct rx_header
);
2246 * If it was a data packet, interpret the response.
2249 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
2251 case 100: /* Create volume */
2257 case 104: /* End transaction */
2260 case 105: /* Clone */
2264 case 107: /* Get flags */
2267 case 108: /* Transaction create */
2271 case 110: /* Get n-th volume */
2274 printf(" partition");
2277 case 112: /* Get name */
2280 case 113: /* Get status */
2283 printf(" nextuniq");
2287 printf(" parentid");
2295 printf(" maxquota");
2297 printf(" minquota");
2314 case 115: /* Old list partitions */
2316 case 116: /* List volumes */
2317 case 121: /* List one volume */
2321 j
= EXTRACT_32BITS(bp
);
2322 bp
+= sizeof(int32_t);
2323 for (i
= 0; i
< j
; i
++) {
2329 bp
+= sizeof(int32_t) * 21;
2344 * Otherwise, just print out the return code
2357 * Handle calls to the AFS BOS service
2361 bos_print(register const u_char
*bp
, int length
)
2365 if (length
<= (int)sizeof(struct rx_header
))
2368 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
2373 * Print out the afs call we're invoking. The table used here was
2374 * gleaned from bozo/bosint.xg
2377 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2379 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2382 * Decode some of the arguments to the BOS calls
2385 bp
+= sizeof(struct rx_header
) + 4;
2388 case 80: /* Create B node */
2391 printf(" instance");
2394 case 81: /* Delete B node */
2395 case 83: /* Get status */
2396 case 85: /* Get instance info */
2397 case 87: /* Add super user */
2398 case 88: /* Delete super user */
2399 case 93: /* Set cell name */
2400 case 96: /* Add cell host */
2401 case 97: /* Delete cell host */
2402 case 104: /* Restart */
2403 case 106: /* Uninstall */
2404 case 108: /* Exec */
2405 case 112: /* Getlog */
2406 case 114: /* Get instance strings */
2409 case 82: /* Set status */
2410 case 98: /* Set T status */
2415 case 86: /* Get instance parm */
2420 case 84: /* Enumerate instance */
2421 case 89: /* List super users */
2422 case 90: /* List keys */
2423 case 91: /* Add key */
2424 case 92: /* Delete key */
2425 case 95: /* Get cell host */
2428 case 105: /* Install */
2448 * Handle replies to the AFS BOS Service
2452 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2454 struct rx_header
*rxh
;
2456 if (length
<= (int)sizeof(struct rx_header
))
2459 rxh
= (struct rx_header
*) bp
;
2462 * Print out the afs call we're invoking. The table used here was
2463 * gleaned from volser/volint.xg
2466 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2468 bp
+= sizeof(struct rx_header
);
2471 * If it was a data packet, interpret the response.
2474 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2475 /* Well, no, not really. Leave this for later */
2479 * Otherwise, just print out the return code
2492 * Check to see if this is a Ubik opcode.
2496 is_ubik(u_int32_t opcode
)
2498 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2499 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2506 * Handle Ubik opcodes to any one of the replicated database services
2510 ubik_print(register const u_char
*bp
)
2516 * Print out the afs call we're invoking. The table used here was
2517 * gleaned from ubik/ubik_int.xg
2520 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2522 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2525 * Decode some of the arguments to the Ubik calls
2528 bp
+= sizeof(struct rx_header
) + 4;
2531 case 10000: /* Beacon */
2533 temp
= EXTRACT_32BITS(bp
);
2534 bp
+= sizeof(int32_t);
2535 printf(" syncsite %s", temp
? "yes" : "no");
2536 printf(" votestart");
2538 printf(" dbversion");
2543 case 10003: /* Get sync site */
2547 case 20000: /* Begin */
2548 case 20001: /* Commit */
2549 case 20007: /* Abort */
2550 case 20008: /* Release locks */
2551 case 20010: /* Writev */
2555 case 20002: /* Lock */
2564 temp
= EXTRACT_32BITS(bp
);
2565 bp
+= sizeof(int32_t);
2566 tok2str(ubik_lock_types
, "type %d", temp
);
2568 case 20003: /* Write */
2576 case 20005: /* Get file */
2580 case 20006: /* Send file */
2585 printf(" dbversion");
2588 case 20009: /* Truncate */
2596 case 20012: /* Set version */
2599 printf(" oldversion");
2601 printf(" newversion");
2615 * Handle Ubik replies to any one of the replicated database services
2619 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2621 struct rx_header
*rxh
;
2623 if (length
< (int)sizeof(struct rx_header
))
2626 rxh
= (struct rx_header
*) bp
;
2629 * Print out the ubik call we're invoking. This table was gleaned
2630 * from ubik/ubik_int.xg
2633 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2635 bp
+= sizeof(struct rx_header
);
2638 * If it was a data packet, print out the arguments to the Ubik calls
2641 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2643 case 10000: /* Beacon */
2646 case 20004: /* Get version */
2647 printf(" dbversion");
2655 * Otherwise, print out "yes" it it was a beacon packet (because
2656 * that's how yes votes are returned, go figure), otherwise
2657 * just print out the error code.
2662 case 10000: /* Beacon */
2663 printf(" vote yes until");
2678 * Handle RX ACK packets.
2682 rx_ack_print(register const u_char
*bp
, int length
)
2684 struct rx_ackPacket
*rxa
;
2686 u_int32_t firstPacket
;
2688 if (length
< (int)sizeof(struct rx_header
))
2691 bp
+= sizeof(struct rx_header
);
2694 * This may seem a little odd .... the rx_ackPacket structure
2695 * contains an array of individual packet acknowledgements
2696 * (used for selective ack/nack), but since it's variable in size,
2697 * we don't want to truncate based on the size of the whole
2698 * rx_ackPacket structure.
2701 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2703 rxa
= (struct rx_ackPacket
*) bp
;
2704 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2707 * Print out a few useful things from the ack packet structure
2711 printf(" bufspace %d maxskew %d",
2712 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2713 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2715 firstPacket
= EXTRACT_32BITS(&rxa
->firstPacket
);
2716 printf(" first %d serial %d reason %s",
2717 firstPacket
, EXTRACT_32BITS(&rxa
->serial
),
2718 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2721 * Okay, now we print out the ack array. The way _this_ works
2722 * is that we start at "first", and step through the ack array.
2723 * If we have a contiguous range of acks/nacks, try to
2724 * collapse them into a range.
2726 * If you're really clever, you might have noticed that this
2727 * doesn't seem quite correct. Specifically, due to structure
2728 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2729 * yield the start of the ack array (because RX_MAXACKS is 255
2730 * and the structure will likely get padded to a 2 or 4 byte
2731 * boundary). However, this is the way it's implemented inside
2732 * of AFS - the start of the extra fields are at
2733 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2734 * the exact start of the ack array. Sigh. That's why we aren't
2735 * using bp, but instead use rxa->acks[]. But nAcks gets added
2736 * to bp after this, so bp ends up at the right spot. Go figure.
2739 if (rxa
->nAcks
!= 0) {
2741 TCHECK2(bp
[0], rxa
->nAcks
);
2744 * Sigh, this is gross, but it seems to work to collapse
2748 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2749 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2752 * I figured this deserved _some_ explanation.
2753 * First, print "acked" and the packet seq
2754 * number if this is the first time we've
2755 * seen an acked packet.
2765 * Otherwise, if the there is a skip in
2766 * the range (such as an nacked packet in
2767 * the middle of some acked packets),
2768 * then print the current packet number
2769 * seperated from the last number by
2773 else if (last
!= i
- 1) {
2774 printf(",%d", firstPacket
+ i
);
2779 * We always set last to the value of
2780 * the last ack we saw. Conversely, start
2781 * is set to the value of the first ack
2782 * we saw in a range.
2788 * Okay, this bit a code gets executed when
2789 * we hit a nack ... in _this_ case we
2790 * want to print out the range of packets
2791 * that were acked, so we need to print
2792 * the _previous_ packet number seperated
2793 * from the first by a dash (-). Since we
2794 * already printed the first packet above,
2795 * just print the final packet. Don't
2796 * do this if there will be a single-length
2799 } else if (last
== i
- 1 && start
!= last
)
2800 printf("-%d", firstPacket
+ i
- 1);
2803 * So, what's going on here? We ran off the end of the
2804 * ack list, and if we got a range we need to finish it up.
2805 * So we need to determine if the last packet in the list
2806 * was an ack (if so, then last will be set to it) and
2807 * we need to see if the last range didn't start with the
2808 * last packet (because if it _did_, then that would mean
2809 * that the packet number has already been printed and
2810 * we don't need to print it again).
2813 if (last
== i
- 1 && start
!= last
)
2814 printf("-%d", firstPacket
+ i
- 1);
2817 * Same as above, just without comments
2820 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2821 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2823 printf(" nacked %d",
2826 } else if (last
!= i
- 1) {
2827 printf(",%d", firstPacket
+ i
);
2831 } else if (last
== i
- 1 && start
!= last
)
2832 printf("-%d", firstPacket
+ i
- 1);
2834 if (last
== i
- 1 && start
!= last
)
2835 printf("-%d", firstPacket
+ i
- 1);
2842 * These are optional fields; depending on your version of AFS,
2843 * you may or may not see them
2846 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2862 printf(" maxpackets");