]> The Tcpdump Group git mirrors - tcpdump/blob - print-rx.c
*** empty log message ***
[tcpdump] / print-rx.c
1 /*
2 * This code unmangles RX packets. RX is the mutant form of RPC that AFS
3 * uses to communicate between clients and servers.
4 *
5 * In this code, I mainly concern myself with decoding the AFS calls, not
6 * with the guts of RX, per se.
7 *
8 * Bah. If I never look at rx_packet.h again, it will be too soon.
9 *
10 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
11 *
12 */
13
14 #ifndef lint
15 static char rcsid[] =
16 "@(#) $Id: print-rx.c,v 1.1 1999-11-17 05:45:58 assar Exp $";
17 #endif
18
19 #include <sys/param.h>
20 #include <sys/time.h>
21 #include <sys/types.h>
22 #include <sys/socket.h>
23 #include <stdio.h>
24 #include <netinet/in.h>
25 #include <netinet/in_systm.h>
26 #include <netinet/ip.h>
27
28 #include "interface.h"
29 #include "addrtoname.h"
30
31 #undef NOERROR /* Solaris sucks */
32 #include <arpa/nameser.h>
33
34 #include "rx.h"
35
36 static struct tok rx_types[] = {
37 { RX_PACKET_TYPE_DATA, "data" },
38 { RX_PACKET_TYPE_ACK, "ack" },
39 { RX_PACKET_TYPE_BUSY, "busy" },
40 { RX_PACKET_TYPE_ABORT, "abort" },
41 { RX_PACKET_TYPE_ACKALL, "ackall" },
42 { RX_PACKET_TYPE_CHALLENGE, "challenge" },
43 { RX_PACKET_TYPE_RESPONSE, "response" },
44 { RX_PACKET_TYPE_DEBUG, "debug" },
45 { RX_PACKET_TYPE_PARAMS, "params" },
46 { RX_PACKET_TYPE_VERSION, "version" },
47 { 0, NULL },
48 };
49
50 static struct tok rx_flags[] = {
51 { RX_CLIENT_INITIATED, "client-init" },
52 { RX_REQUEST_ACK, "req-ack" },
53 { RX_LAST_PACKET, "last-pckt" },
54 { RX_MORE_PACKETS, "more-pckts" },
55 { RX_FREE_PACKET, "free-pckt" }
56 };
57
58 static struct tok fs_req[] = {
59 { 130, "fetch-data" },
60 { 131, "fetch-acl" },
61 { 132, "fetch-status" },
62 { 133, "store-data" },
63 { 134, "store-acl" },
64 { 135, "store-status" },
65 { 136, "remove-file" },
66 { 137, "create-file" },
67 { 138, "rename" },
68 { 139, "symlink" },
69 { 140, "link" },
70 { 141, "makedir" },
71 { 142, "rmdir" },
72 { 143, "oldsetlock" },
73 { 144, "oldextlock" },
74 { 145, "oldrellock" },
75 { 146, "get-stats" },
76 { 147, "give-cbs" },
77 { 148, "get-vlinfo" },
78 { 149, "get-vlstats" },
79 { 150, "set-vlstats" },
80 { 151, "get-rootvl" },
81 { 152, "check-token" },
82 { 153, "get-time" },
83 { 154, "nget-vlinfo" },
84 { 155, "bulk-stat" },
85 { 156, "setlock" },
86 { 157, "extlock" },
87 { 158, "rellock" },
88 { 159, "xstat-ver" },
89 { 160, "get-xstat" },
90 { 161, "dfs-lookup" },
91 { 162, "dfs-flushcps" },
92 { 163, "dfs-symlink" },
93 { 0, NULL },
94 };
95
96 static struct tok cb_req[] = {
97 { 204, "callback" },
98 { 205, "initcb" },
99 { 206, "probe" },
100 { 207, "getlock" },
101 { 208, "getce" },
102 { 209, "xstatver" },
103 { 210, "getxstat" },
104 { 211, "initcb2" },
105 { 212, "whoareyou" },
106 { 213, "initcb3" },
107 { 214, "probeuuid" },
108 { 0, NULL },
109 };
110
111 static struct tok pt_req[] = {
112 { 500, "new-user" },
113 { 501, "where-is-it" },
114 { 502, "dump-entry" },
115 { 503, "add-to-group" },
116 { 504, "name-to-id" },
117 { 505, "id-to-name" },
118 { 506, "delete" },
119 { 507, "remove-from-group" },
120 { 508, "get-cps" },
121 { 509, "new-entry" },
122 { 510, "list-max" },
123 { 511, "set-max" },
124 { 512, "list-entry" },
125 { 513, "change-entry" },
126 { 514, "list-elements" },
127 { 515, "same-mbr-of" },
128 { 516, "set-fld-sentry" },
129 { 517, "list-owned" },
130 { 518, "get-cps2" },
131 { 519, "get-host-cps" },
132 { 520, "update-entry" },
133 { 0, NULL },
134 };
135
136 static struct tok vldb_req[] = {
137 { 501, "create-entry" },
138 { 502, "delete-entry" },
139 { 503, "get-entry-by-id" },
140 { 504, "get-entry-by-name" },
141 { 505, "get-new-volume-id" },
142 { 506, "replace-entry" },
143 { 507, "update-entry" },
144 { 508, "setlock" },
145 { 509, "releaselock" },
146 { 510, "list-entry" },
147 { 511, "list-attrib" },
148 { 512, "linked-list" },
149 { 513, "get-stats" },
150 { 514, "probe" },
151 { 515, "get-addrs" },
152 { 516, "change-addr" },
153 { 517, "create-entry-n" },
154 { 518, "get-entry-by-id-n" },
155 { 519, "get-entry-by-name-n" },
156 { 520, "replace-entry-n" },
157 { 521, "list-entry-n" },
158 { 522, "list-attrib-n" },
159 { 523, "linked-list-n" },
160 { 524, "update-entry-by-name" },
161 { 525, "create-entry-u" },
162 { 526, "get-entry-by-id-u" },
163 { 527, "get-entry-by-name-u" },
164 { 528, "replace-entry-u" },
165 { 529, "list-entry-u" },
166 { 530, "list-attrib-u" },
167 { 531, "linked-list-u" },
168 { 532, "regaddr" },
169 { 533, "get-addrs-u" },
170 { 0, NULL },
171 };
172
173 static struct tok kauth_req[] = {
174 { 1, "auth-old" },
175 { 21, "authenticate" },
176 { 22, "authenticate-v2" },
177 { 2, "change-pw" },
178 { 3, "get-ticket-old" },
179 { 23, "get-ticket" },
180 { 4, "set-pw" },
181 { 5, "set-fields" },
182 { 6, "create-user" },
183 { 7, "delete-user" },
184 { 8, "get-entry" },
185 { 9, "list-entry" },
186 { 10, "get-stats" },
187 { 11, "debug" },
188 { 12, "get-pw" },
189 { 13, "get-random-key" },
190 { 14, "unlock" },
191 { 15, "lock-status" },
192 { 0, NULL },
193 };
194
195 static struct tok vol_req[] = {
196 { 100, "create-volume" },
197 { 101, "delete-volume" },
198 { 102, "restore" },
199 { 103, "forward" },
200 { 104, "end-trans" },
201 { 105, "clone" },
202 { 106, "set-flags" },
203 { 107, "get-flags" },
204 { 108, "trans-create" },
205 { 109, "dump" },
206 { 110, "get-nth-volume" },
207 { 111, "set-forwarding" },
208 { 112, "get-name" },
209 { 113, "get-status" },
210 { 114, "sig-restore" },
211 { 115, "list-partitions" },
212 { 116, "list-volumes" },
213 { 117, "set-id-types" },
214 { 118, "monitor" },
215 { 119, "partition-info" },
216 { 120, "reclone" },
217 { 121, "list-one-volume" },
218 { 122, "nuke" },
219 { 123, "set-date" },
220 { 124, "x-list-volumes" },
221 { 125, "x-list-one-volume" },
222 { 126, "set-info" },
223 { 127, "x-list-partitions" },
224 { 128, "forward-multiple" },
225 { 0, NULL },
226 };
227
228 static struct tok bos_req[] = {
229 { 80, "create-bnode" },
230 { 81, "delete-bnode" },
231 { 82, "set-status" },
232 { 83, "get-status" },
233 { 84, "enumerate-instance" },
234 { 85, "get-instance-info" },
235 { 86, "get-instance-parm" },
236 { 87, "add-superuser" },
237 { 88, "delete-superuser" },
238 { 89, "list-superusers" },
239 { 90, "list-keys" },
240 { 91, "add-key" },
241 { 92, "delete-key" },
242 { 93, "set-cell-name" },
243 { 94, "get-cell-name" },
244 { 95, "get-cell-host" },
245 { 96, "add-cell-host" },
246 { 97, "delete-cell-host" },
247 { 98, "set-t-status" },
248 { 99, "shutdown-all" },
249 { 100, "restart-all" },
250 { 101, "startup-all" },
251 { 102, "set-noauth-flag" },
252 { 103, "re-bozo" },
253 { 104, "restart" },
254 { 105, "start-bozo-install" },
255 { 106, "uninstall" },
256 { 107, "get-dates" },
257 { 108, "exec" },
258 { 109, "prune" },
259 { 110, "set-restart-time" },
260 { 111, "get-restart-time" },
261 { 112, "start-bozo-log" },
262 { 113, "wait-all" },
263 { 114, "get-instance-strings" },
264 { 0, NULL },
265 };
266
267 static struct tok ubik_req[] = {
268 { 10000, "vote-beacon" },
269 { 10001, "vote-debug-old" },
270 { 10002, "vote-sdebug-old" },
271 { 10003, "vote-getsyncsite" },
272 { 10004, "vote-debug" },
273 { 10005, "vote-sdebug" },
274 { 20000, "disk-begin" },
275 { 20001, "disk-commit" },
276 { 20002, "disk-lock" },
277 { 20003, "disk-write" },
278 { 20004, "disk-getversion" },
279 { 20005, "disk-getfile" },
280 { 20006, "disk-sendfile" },
281 { 20007, "disk-abort" },
282 { 20008, "disk-releaselocks" },
283 { 20009, "disk-truncate" },
284 { 20010, "disk-probe" },
285 { 20011, "disk-writev" },
286 { 20012, "disk-interfaceaddr" },
287 { 20013, "disk-setversion" },
288 { 0, NULL },
289 };
290
291 #define VOTE_LOW 10000
292 #define VOTE_HIGH 10005
293 #define DISK_LOW 20000
294 #define DISK_HIGH 20013
295
296 static struct tok cb_types[] = {
297 { 1, "exclusive" },
298 { 2, "shared" },
299 { 3, "dropped" },
300 { 0, NULL },
301 };
302
303 static struct tok ubik_lock_types[] = {
304 { 1, "read" },
305 { 2, "write" },
306 { 3, "wait" },
307 { 0, NULL },
308 };
309
310 static char *voltype[] = { "read-write", "read-only", "backup" };
311
312 /*
313 * Cache entries we keep around so we can figure out the RX opcode
314 * numbers for replies. This allows us to make sense of RX reply packets.
315 */
316
317 struct rx_cache_entry {
318 u_int32_t callnum; /* Call number (net order) */
319 struct in_addr client; /* client IP address (net order) */
320 struct in_addr server; /* server IP address (net order) */
321 int dport; /* server port (host order) */
322 u_short serviceId; /* Service identifier (net order) */
323 u_int32_t opcode; /* RX opcode (host order) */
324 };
325
326 #define RX_CACHE_SIZE 64
327
328 static struct rx_cache_entry rx_cache[RX_CACHE_SIZE];
329
330 static int rx_cache_next = 0;
331 static int rx_cache_hint = 0;
332 static void rx_cache_insert(const u_char *, const struct ip *, int, int);
333 static int rx_cache_find(const struct rx_header *, const struct ip *,
334 int, int32_t *);
335
336 static void fs_print(const u_char *, int);
337 static void fs_reply_print(const u_char *, int, int32_t);
338 static void acl_print(u_char *, u_char *);
339 static void cb_print(const u_char *, int);
340 static void cb_reply_print(const u_char *, int, int32_t);
341 static void prot_print(const u_char *, int);
342 static void prot_reply_print(const u_char *, int, int32_t);
343 static void vldb_print(const u_char *, int);
344 static void vldb_reply_print(const u_char *, int, int32_t);
345 static void kauth_print(const u_char *, int);
346 static void kauth_reply_print(const u_char *, int, int32_t);
347 static void vol_print(const u_char *, int);
348 static void vol_reply_print(const u_char *, int, int32_t);
349 static void bos_print(const u_char *, int);
350 static void bos_reply_print(const u_char *, int, int32_t);
351 static void ubik_print(const u_char *, int);
352 static void ubik_reply_print(const u_char *, int, int32_t);
353
354 static int is_ubik(u_int32_t);
355
356 /*
357 * Handle the rx-level packet. See if we know what port it's going to so
358 * we can peek at the afs call inside
359 */
360
361 void
362 rx_print(register const u_char *bp, int length, int sport, int dport,
363 u_char *bp2)
364 {
365 register struct rx_header *rxh;
366 int i;
367 int32_t opcode;
368
369 if (snapend - bp < sizeof (struct rx_header)) {
370 printf(" [|rx] (%d)", length);
371 return;
372 }
373
374 rxh = (struct rx_header *) bp;
375
376 printf(" rx %s", tok2str(rx_types, "type %d", rxh->type));
377
378 if (vflag > 1) {
379 int firstflag = 0;
380 printf(" cid %08x call# %d seq %d ser %d",
381 (int) ntohl(rxh->cid),
382 (int) ntohl(rxh->callNumber),
383 (int) ntohl(rxh->seq),
384 (int) ntohl(rxh->serial));
385 if (vflag > 2)
386 printf(" secindex %d serviceid %hu",
387 (int) rxh->securityIndex,
388 ntohs(rxh->serviceId));
389 for (i = 0; i < NUM_RX_FLAGS; i++) {
390 if (rxh->flags & rx_flags[i].v) {
391 if (!firstflag) {
392 firstflag = 1;
393 printf(" ");
394 } else {
395 printf(",");
396 }
397 printf("<%s>", rx_flags[i].s);
398 }
399 }
400 }
401
402 /*
403 * Try to handle AFS calls that we know about. Check the destination
404 * port and make sure it's a data packet. Also, make sure the
405 * seq number is 1 (because otherwise it's a continuation packet,
406 * and we can't interpret that). Also, seems that reply packets
407 * do not have the client-init flag set, so we check for that
408 * as well.
409 */
410
411 if (rxh->type == RX_PACKET_TYPE_DATA && ntohl(rxh->seq) == 1 &&
412 rxh->flags & RX_CLIENT_INITIATED) {
413
414 /*
415 * Insert this call into the call cache table, so we
416 * have a chance to print out replies
417 */
418
419 rx_cache_insert(bp, (const struct ip *) bp2, dport, length);
420
421 switch (dport) {
422 case FS_RX_PORT: /* AFS file service */
423 fs_print(bp, length);
424 break;
425 case CB_RX_PORT: /* AFS callback service */
426 cb_print(bp, length);
427 break;
428 case PROT_RX_PORT: /* AFS protection service */
429 prot_print(bp, length);
430 break;
431 case VLDB_RX_PORT: /* AFS VLDB service */
432 vldb_print(bp, length);
433 break;
434 case KAUTH_RX_PORT: /* AFS Kerberos auth service */
435 kauth_print(bp, length);
436 break;
437 case VOL_RX_PORT: /* AFS Volume service */
438 vol_print(bp, length);
439 break;
440 case BOS_RX_PORT: /* AFS BOS service */
441 bos_print(bp, length);
442 break;
443 default:
444 ;
445 }
446
447 /*
448 * If it's a reply (client-init is _not_ set, but seq is one)
449 * then look it up in the cache. If we find it, call the reply
450 * printing functions Note that we handle abort packets here,
451 * because printing out the return code can be useful at times.
452 */
453
454 } else if (((rxh->type == RX_PACKET_TYPE_DATA &&
455 ntohl(rxh->seq) == 1) ||
456 rxh->type == RX_PACKET_TYPE_ABORT) &&
457 (rxh->flags & RX_CLIENT_INITIATED) == 0 &&
458 rx_cache_find(rxh, (const struct ip *) bp2,
459 sport, &opcode)) {
460
461 switch (sport) {
462 case FS_RX_PORT: /* AFS file service */
463 fs_reply_print(bp, length, opcode);
464 break;
465 case CB_RX_PORT: /* AFS callback service */
466 cb_reply_print(bp, length, opcode);
467 break;
468 case PROT_RX_PORT: /* AFS PT service */
469 prot_reply_print(bp, length, opcode);
470 break;
471 case VLDB_RX_PORT: /* AFS VLDB service */
472 vldb_reply_print(bp, length, opcode);
473 break;
474 case KAUTH_RX_PORT: /* AFS Kerberos auth service */
475 kauth_reply_print(bp, length, opcode);
476 break;
477 case VOL_RX_PORT: /* AFS Volume service */
478 vol_reply_print(bp, length, opcode);
479 break;
480 case BOS_RX_PORT: /* AFS BOS service */
481 bos_reply_print(bp, length, opcode);
482 break;
483 default:
484 ;
485 }
486 }
487
488
489 printf(" (%d)", length);
490 }
491
492 /*
493 * Insert an entry into the cache. Taken from print-nfs.c
494 */
495
496 static void
497 rx_cache_insert(const u_char *bp, const struct ip *ip, int dport,
498 int length)
499 {
500 struct rx_cache_entry *rxent;
501 const struct rx_header *rxh = (const struct rx_header *) bp;
502
503 if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t))
504 return;
505
506 rxent = &rx_cache[rx_cache_next];
507
508 if (++rx_cache_next >= RX_CACHE_SIZE)
509 rx_cache_next = 0;
510
511 rxent->callnum = rxh->callNumber;
512 rxent->client = ip->ip_src;
513 rxent->server = ip->ip_dst;
514 rxent->dport = dport;
515 rxent->serviceId = rxh->serviceId;
516 rxent->opcode = ntohl(*((int *) (bp + sizeof(struct rx_header))));
517 }
518
519 /*
520 * Lookup an entry in the cache. Also taken from print-nfs.c
521 *
522 * Note that because this is a reply, we're looking at the _source_
523 * port.
524 */
525
526 static int
527 rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
528 int32_t *opcode)
529 {
530 int i;
531 struct rx_cache_entry *rxent;
532 u_int32_t clip = ip->ip_dst.s_addr;
533 u_int32_t sip = ip->ip_src.s_addr;
534
535 /* Start the search where we last left off */
536
537 i = rx_cache_hint;
538 do {
539 rxent = &rx_cache[i];
540 if (rxent->callnum == rxh->callNumber &&
541 rxent->client.s_addr == clip &&
542 rxent->server.s_addr == sip &&
543 rxent->serviceId == rxh->serviceId &&
544 rxent->dport == sport) {
545
546 /* We got a match! */
547
548 rx_cache_hint = i;
549 *opcode = rxent->opcode;
550 return(1);
551 }
552 if (++i > RX_CACHE_SIZE)
553 i = 0;
554 } while (i != rx_cache_hint);
555
556 /* Our search failed */
557 return(0);
558 }
559
560 /*
561 * These extrememly grody macros handle the printing of various AFS stuff.
562 */
563
564 #define TRUNC(n) if (snapend - bp + 1 <= n) goto trunc;
565 #define FIDOUT() { unsigned long n1, n2, n3; \
566 TRUNC(sizeof(int32_t) * 3); \
567 n1 = ntohl(*((int *) bp)); \
568 bp += sizeof(int32_t); \
569 n2 = ntohl(*((int *) bp)); \
570 bp += sizeof(int32_t); \
571 n3 = ntohl(*((int *) bp)); \
572 bp += sizeof(int32_t); \
573 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
574 }
575
576 #define STROUT(MAX) { int i; \
577 TRUNC(sizeof(int32_t)); \
578 i = (int) ntohl(*((int *) bp)); \
579 bp += sizeof(int32_t); \
580 TRUNC(i); \
581 strncpy(s, bp, min(MAX, i)); \
582 s[i] = '\0'; \
583 printf(" \"%s\"", s); \
584 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
585 }
586
587 #define INTOUT() { int i; \
588 TRUNC(sizeof(int32_t)); \
589 i = (int) ntohl(*((int *) bp)); \
590 bp += sizeof(int32_t); \
591 printf(" %d", i); \
592 }
593
594 #define UINTOUT() { unsigned long i; \
595 TRUNC(sizeof(int32_t)); \
596 i = ntohl(*((int *) bp)); \
597 bp += sizeof(int32_t); \
598 printf(" %lu", i); \
599 }
600
601 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
602 TRUNC(sizeof(int32_t)); \
603 t = (time_t) ntohl(*((int *) bp)); \
604 bp += sizeof(int32_t); \
605 tm = localtime(&t); \
606 strftime(str, 256, "%D %T", tm); \
607 printf(" %s", str); \
608 }
609
610 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
611 TRUNC(sizeof(int32_t) * 2); \
612 epoch = ntohl(*((int *) bp)); \
613 bp += sizeof(int32_t); \
614 counter = ntohl(*((int *) bp)); \
615 bp += sizeof(int32_t); \
616 printf(" %d.%d", epoch, counter); \
617 }
618
619 #define AFSUUIDOUT() {u_int32_t temp; int i; \
620 TRUNC(11*sizeof(u_int32_t)); \
621 temp = ntohl(*((int *) bp)); \
622 bp += sizeof(u_int32_t); \
623 printf(" %08x", temp); \
624 temp = ntohl(*((int *) bp)); \
625 bp += sizeof(u_int32_t); \
626 printf("%04x", temp); \
627 temp = ntohl(*((int *) bp)); \
628 bp += sizeof(u_int32_t); \
629 printf("%04x", temp); \
630 for (i = 0; i < 8; i++) { \
631 temp = ntohl(*((int *) bp)); \
632 bp += sizeof(u_int32_t); \
633 printf("%02x", (unsigned char) temp); \
634 } \
635 }
636
637 /*
638 * This is the sickest one of all
639 */
640
641 #define VECOUT(MAX) { char *sp; \
642 int k; \
643 TRUNC(MAX * sizeof(int32_t)); \
644 sp = s; \
645 for (k = 0; k < MAX; k++) { \
646 *sp++ = (char) ntohl(*((int *) bp)); \
647 bp += sizeof(int32_t); \
648 } \
649 s[MAX] = '\0'; \
650 printf(" \"%s\"", s); \
651 }
652
653 /*
654 * Handle calls to the AFS file service (fs)
655 */
656
657 void
658 fs_print(register const u_char *bp, int length)
659 {
660 int fs_op;
661 unsigned long i;
662 char s[AFSNAMEMAX];
663
664 if (length <= sizeof(struct rx_header))
665 return;
666
667 if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) {
668 goto trunc;
669 }
670
671 /*
672 * Print out the afs call we're invoking. The table used here was
673 * gleaned from fsint/afsint.xg
674 */
675
676 fs_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
677
678 printf(" fs call %s", tok2str(fs_req, "op#%d", fs_op));
679
680 /*
681 * Print out arguments to some of the AFS calls. This stuff is
682 * all from afsint.xg
683 */
684
685 bp += sizeof(struct rx_header) + 4;
686
687 /*
688 * Sigh. This is gross. Ritchie forgive me.
689 */
690
691 switch (fs_op) {
692 case 130: /* Fetch data */
693 FIDOUT();
694 printf(" offset");
695 UINTOUT();
696 printf(" length");
697 UINTOUT();
698 break;
699 case 131: /* Fetch ACL */
700 case 132: /* Fetch Status */
701 case 135: /* Store status */
702 case 143: /* Old set lock */
703 case 144: /* Old extend lock */
704 case 145: /* Old release lock */
705 case 156: /* Set lock */
706 case 157: /* Extend lock */
707 case 158: /* Release lock */
708 FIDOUT();
709 break;
710 case 133: /* Store data */
711 FIDOUT();
712 TRUNC(sizeof(int32_t)*6); /* Skip past this */
713 bp += sizeof(int32_t) * 6;
714 printf(" offset");
715 UINTOUT();
716 printf(" length");
717 UINTOUT();
718 printf(" flen");
719 UINTOUT();
720 break;
721 case 134: /* Store ACL */
722 {
723 int a[AFSOPAQUEMAX];
724 FIDOUT();
725 TRUNC(4);
726 i = ntohl(*((int *) bp));
727 bp += sizeof(int32_t);
728 TRUNC(i);
729 strncpy(a, bp, min(AFSOPAQUEMAX, i));
730 a[i] = '\0';
731 acl_print((u_char *) a, (u_char *) a + i);
732 break;
733 }
734 case 136: /* Remove file */
735 case 137: /* Create file */
736 case 141: /* MakeDir */
737 case 142: /* Remove directory */
738 FIDOUT();
739 STROUT(AFSNAMEMAX);
740 break;
741 case 138: /* Rename file */
742 printf(" old");
743 FIDOUT();
744 STROUT(AFSNAMEMAX);
745 printf(" new");
746 FIDOUT();
747 STROUT(AFSNAMEMAX);
748 break;
749 case 139: /* Symlink */
750 FIDOUT();
751 STROUT(AFSNAMEMAX);
752 printf(" link to");
753 STROUT(AFSNAMEMAX);
754 break;
755 case 140: /* Link */
756 FIDOUT();
757 STROUT(AFSNAMEMAX);
758 printf(" link to");
759 FIDOUT();
760 break;
761 case 148: /* Get volume info */
762 STROUT(AFSNAMEMAX);
763 break;
764 case 149: /* Get volume stats */
765 case 150: /* Set volume stats */
766 printf(" volid");
767 UINTOUT();
768 break;
769 case 154: /* New get volume info */
770 printf(" volname");
771 STROUT(AFSNAMEMAX);
772 break;
773 case 155: /* Bulk stat */
774 {
775 unsigned long j;
776 TRUNC(4);
777 j = ntohl(*((int *) bp));
778 bp += sizeof(int32_t);
779
780 for (i = 0; i < j; i++) {
781 FIDOUT();
782 if (i != j - 1)
783 printf(",");
784 }
785 if (j == 0)
786 printf(" <none!>");
787 }
788 default:
789 ;
790 }
791
792 return;
793
794 trunc:
795 printf(" [|fs]");
796 }
797
798 /*
799 * Handle replies to the AFS file service
800 */
801
802 static void
803 fs_reply_print(register const u_char *bp, int length, int32_t opcode)
804 {
805 unsigned long i;
806 char s[AFSNAMEMAX];
807 struct rx_header *rxh;
808
809 if (length <= sizeof(struct rx_header))
810 return;
811
812 rxh = (struct rx_header *) bp;
813
814 /*
815 * Print out the afs call we're invoking. The table used here was
816 * gleaned from fsint/afsint.xg
817 */
818
819 printf(" fs reply %s", tok2str(fs_req, "op#%d", opcode));
820
821 bp += sizeof(struct rx_header);
822
823 /*
824 * If it was a data packet, interpret the response
825 */
826
827 if (rxh->type == RX_PACKET_TYPE_DATA)
828 switch (opcode) {
829 case 131: /* Fetch ACL */
830 {
831 int a[AFSOPAQUEMAX];
832 TRUNC(4);
833 i = ntohl(*((int *) bp));
834 bp += sizeof(int32_t);
835 TRUNC(i);
836 strncpy(a, bp, min(AFSOPAQUEMAX, i));
837 a[i] = '\0';
838 acl_print((u_char *) a, (u_char *) a + i);
839 break;
840 }
841 case 137: /* Create file */
842 case 141: /* MakeDir */
843 printf(" new");
844 FIDOUT();
845 break;
846 case 151: /* Get root volume */
847 printf(" root volume");
848 STROUT(AFSNAMEMAX);
849 break;
850 case 153: /* Get time */
851 DATEOUT();
852 break;
853 default:
854 ;
855 }
856 else {
857 /*
858 * Otherwise, just print out the return code
859 */
860 printf(" errcode");
861 INTOUT();
862 }
863
864 return;
865
866 trunc:
867 printf(" [|fs]");
868 }
869
870 /*
871 * Print out an AFS ACL string. An AFS ACL is a string that has the
872 * following format:
873 *
874 * <positive> <negative>
875 * <uid1> <aclbits1>
876 * ....
877 *
878 * "positive" and "negative" are integers which contain the number of
879 * positive and negative ACL's in the string. The uid/aclbits pair are
880 * ASCII strings containing the UID/PTS record and and a ascii number
881 * representing a logical OR of all the ACL permission bits
882 */
883
884 static void
885 acl_print(u_char *s, u_char *end)
886 {
887 int pos, neg, acl;
888 int n, i;
889 char user[128];
890
891 if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2)
892 return;
893
894 s += n;
895
896 if (s > end)
897 return;
898
899 /*
900 * This wacky order preserves the order used by the "fs" command
901 */
902
903 #define ACLOUT(acl) \
904 if (acl & PRSFS_READ) \
905 printf("r"); \
906 if (acl & PRSFS_LOOKUP) \
907 printf("l"); \
908 if (acl & PRSFS_INSERT) \
909 printf("i"); \
910 if (acl & PRSFS_DELETE) \
911 printf("d"); \
912 if (acl & PRSFS_WRITE) \
913 printf("w"); \
914 if (acl & PRSFS_LOCK) \
915 printf("k"); \
916 if (acl & PRSFS_ADMINISTER) \
917 printf("a");
918
919 for (i = 0; i < pos; i++) {
920 if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2)
921 return;
922 s += n;
923 printf(" +{%s ", user);
924 ACLOUT(acl);
925 printf("}");
926 if (s > end)
927 return;
928 }
929
930 for (i = 0; i < neg; i++) {
931 if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2)
932 return;
933 s += n;
934 printf(" -{%s ", user);
935 ACLOUT(acl);
936 printf("}");
937 if (s > end)
938 return;
939 }
940 }
941
942 #undef ACLOUT
943
944 /*
945 * Handle calls to the AFS callback service
946 */
947
948 static void
949 cb_print(register const u_char *bp, int length)
950 {
951 int cb_op;
952 unsigned long i;
953
954 if (length <= sizeof(struct rx_header))
955 return;
956
957 if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) {
958 goto trunc;
959 }
960
961 /*
962 * Print out the afs call we're invoking. The table used here was
963 * gleaned from fsint/afscbint.xg
964 */
965
966 cb_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
967
968 printf(" cb call %s", tok2str(cb_req, "op#%d", cb_op));
969
970 bp += sizeof(struct rx_header) + 4;
971
972 /*
973 * Print out the afs call we're invoking. The table used here was
974 * gleaned from fsint/afscbint.xg
975 */
976
977 switch (cb_op) {
978 case 204: /* Callback */
979 {
980 unsigned long j, t;
981 TRUNC(4);
982 j = ntohl(*((int *) bp));
983 bp += sizeof(int32_t);
984
985 for (i = 0; i < j; i++) {
986 FIDOUT();
987 if (i != j - 1)
988 printf(",");
989 }
990
991 if (j == 0)
992 printf(" <none!>");
993
994 j = ntohl(*((int *) bp));
995 bp += sizeof(int32_t);
996
997 if (j != 0)
998 printf(";");
999
1000 for (i = 0; i < j; i++) {
1001 printf(" ver");
1002 INTOUT();
1003 printf(" expires");
1004 DATEOUT();
1005 TRUNC(4);
1006 t = ntohl(*((int *) bp));
1007 bp += sizeof(int32_t);
1008 tok2str(cb_types, "type %d", t);
1009 }
1010 }
1011 default:
1012 ;
1013 }
1014
1015 return;
1016
1017 trunc:
1018 printf(" [|cb]");
1019 }
1020
1021 /*
1022 * Handle replies to the AFS Callback Service
1023 */
1024
1025 static void
1026 cb_reply_print(register const u_char *bp, int length, int32_t opcode)
1027 {
1028 unsigned long i;
1029 char s[AFSNAMEMAX];
1030 struct rx_header *rxh;
1031
1032 if (length <= sizeof(struct rx_header))
1033 return;
1034
1035 rxh = (struct rx_header *) bp;
1036
1037 /*
1038 * Print out the afs call we're invoking. The table used here was
1039 * gleaned from fsint/afscbint.xg
1040 */
1041
1042 printf(" cb reply %s", tok2str(cb_req, "op#%d", opcode));
1043
1044 bp += sizeof(struct rx_header);
1045
1046 /*
1047 * If it was a data packet, interpret the response.
1048 */
1049
1050 if (rxh->type == RX_PACKET_TYPE_DATA)
1051 /* Well, no, not really. Leave this for later */
1052 ;
1053 else {
1054 /*
1055 * Otherwise, just print out the return code
1056 */
1057 printf(" errcode");
1058 INTOUT();
1059 }
1060
1061 return;
1062
1063 trunc:
1064 printf(" [|cb]");
1065 }
1066
1067 /*
1068 * Handle calls to the AFS protection database server
1069 */
1070
1071 static void
1072 prot_print(register const u_char *bp, int length)
1073 {
1074 int pt_op;
1075 unsigned long i;
1076 char s[AFSNAMEMAX];
1077
1078 if (length <= sizeof(struct rx_header))
1079 return;
1080
1081 if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) {
1082 goto trunc;
1083 }
1084
1085 /*
1086 * Print out the afs call we're invoking. The table used here was
1087 * gleaned from ptserver/ptint.xg
1088 */
1089
1090 pt_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
1091
1092 printf(" pt");
1093
1094 if (is_ubik(pt_op)) {
1095 ubik_print(bp, length);
1096 return;
1097 }
1098
1099 printf(" call %s", tok2str(pt_req, "op#%d", pt_op));
1100
1101 /*
1102 * Decode some of the arguments to the PT calls
1103 */
1104
1105 bp += sizeof(struct rx_header) + 4;
1106
1107 switch (pt_op) {
1108 case 500: /* I New User */
1109 STROUT(PRNAMEMAX);
1110 printf(" id");
1111 INTOUT();
1112 printf(" oldid");
1113 INTOUT();
1114 break;
1115 case 501: /* Where is it */
1116 case 506: /* Delete */
1117 case 508: /* Get CPS */
1118 case 512: /* List entry */
1119 case 514: /* List elements */
1120 case 517: /* List owned */
1121 case 518: /* Get CPS2 */
1122 case 519: /* Get host CPS */
1123 printf(" id");
1124 INTOUT();
1125 break;
1126 case 502: /* Dump entry */
1127 printf(" pos");
1128 INTOUT();
1129 break;
1130 case 503: /* Add to group */
1131 case 507: /* Remove from group */
1132 case 515: /* Is a member of? */
1133 printf(" uid");
1134 INTOUT();
1135 printf(" gid");
1136 INTOUT();
1137 break;
1138 case 504: /* Name to ID */
1139 {
1140 unsigned long j;
1141 TRUNC(4);
1142 j = ntohl(*((int *) bp));
1143 bp += sizeof(int32_t);
1144
1145 /*
1146 * Who designed this chicken-shit protocol?
1147 *
1148 * Each character is stored as a 32-bit
1149 * integer!
1150 */
1151
1152 for (i = 0; i < j; i++) {
1153 VECOUT(PRNAMEMAX);
1154 }
1155 if (j == 0)
1156 printf(" <none!>");
1157 }
1158 break;
1159 case 505: /* Id to name */
1160 {
1161 unsigned long j;
1162 printf(" ids:");
1163 TRUNC(4);
1164 i = ntohl(*((int *) bp));
1165 bp += sizeof(int32_t);
1166 for (j = 0; j < i; j++)
1167 INTOUT();
1168 if (j == 0)
1169 printf(" <none!>");
1170 }
1171 break;
1172 case 509: /* New entry */
1173 STROUT(PRNAMEMAX);
1174 printf(" flag");
1175 INTOUT();
1176 printf(" oid");
1177 INTOUT();
1178 break;
1179 case 511: /* Set max */
1180 printf(" id");
1181 INTOUT();
1182 printf(" gflag");
1183 INTOUT();
1184 break;
1185 case 513: /* Change entry */
1186 printf(" id");
1187 INTOUT();
1188 STROUT(PRNAMEMAX);
1189 printf(" oldid");
1190 INTOUT();
1191 printf(" newid");
1192 INTOUT();
1193 break;
1194 case 520: /* Update entry */
1195 printf(" id");
1196 INTOUT();
1197 STROUT(PRNAMEMAX);
1198 break;
1199 default:
1200 ;
1201 }
1202
1203
1204 return;
1205
1206 trunc:
1207 printf(" [|pt]");
1208 }
1209
1210 /*
1211 * Handle replies to the AFS protection service
1212 */
1213
1214 static void
1215 prot_reply_print(register const u_char *bp, int length, int32_t opcode)
1216 {
1217 struct rx_header *rxh;
1218 unsigned long i;
1219 char s[AFSNAMEMAX];
1220
1221 if (length < sizeof(struct rx_header))
1222 return;
1223
1224 rxh = (struct rx_header *) bp;
1225
1226 /*
1227 * Print out the afs call we're invoking. The table used here was
1228 * gleaned from ptserver/ptint.xg. Check to see if it's a
1229 * Ubik call, however.
1230 */
1231
1232 printf(" pt");
1233
1234 if (is_ubik(opcode)) {
1235 ubik_reply_print(bp, length, opcode);
1236 return;
1237 }
1238
1239 printf(" reply %s", tok2str(pt_req, "op#%d", opcode));
1240
1241 bp += sizeof(struct rx_header);
1242
1243 /*
1244 * If it was a data packet, interpret the response
1245 */
1246
1247 if (rxh->type == RX_PACKET_TYPE_DATA)
1248 switch (opcode) {
1249 case 504: /* Name to ID */
1250 {
1251 unsigned long j;
1252 printf(" ids:");
1253 TRUNC(4);
1254 i = ntohl(*((int *) bp));
1255 bp += sizeof(int32_t);
1256 for (j = 0; j < i; j++)
1257 INTOUT();
1258 if (j == 0)
1259 printf(" <none!>");
1260 }
1261 break;
1262 case 505: /* ID to name */
1263 {
1264 unsigned long j;
1265 TRUNC(4);
1266 j = ntohl(*((int *) bp));
1267 bp += sizeof(int32_t);
1268
1269 /*
1270 * Who designed this chicken-shit protocol?
1271 *
1272 * Each character is stored as a 32-bit
1273 * integer!
1274 */
1275
1276 for (i = 0; i < j; i++) {
1277 VECOUT(PRNAMEMAX);
1278 }
1279 if (j == 0)
1280 printf(" <none!>");
1281 }
1282 break;
1283 case 508: /* Get CPS */
1284 case 514: /* List elements */
1285 case 517: /* List owned */
1286 case 518: /* Get CPS2 */
1287 case 519: /* Get host CPS */
1288 {
1289 unsigned long j;
1290 TRUNC(4);
1291 j = ntohl(*((int *) bp));
1292 bp += sizeof(int32_t);
1293 for (i = 0; i < j; i++) {
1294 INTOUT();
1295 }
1296 if (j == 0)
1297 printf(" <none!>");
1298 }
1299 break;
1300 case 510: /* List max */
1301 printf(" maxuid");
1302 INTOUT();
1303 printf(" maxgid");
1304 INTOUT();
1305 break;
1306 default:
1307 ;
1308 }
1309 else {
1310 /*
1311 * Otherwise, just print out the return code
1312 */
1313 printf(" errcode");
1314 INTOUT();
1315 }
1316
1317 return;
1318
1319 trunc:
1320 printf(" [|pt]");
1321 }
1322
1323 /*
1324 * Handle calls to the AFS volume location database service
1325 */
1326
1327 static void
1328 vldb_print(register const u_char *bp, int length)
1329 {
1330 int vldb_op;
1331 unsigned long i;
1332 char s[AFSNAMEMAX];
1333
1334 if (length <= sizeof(struct rx_header))
1335 return;
1336
1337 if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) {
1338 goto trunc;
1339 }
1340
1341 /*
1342 * Print out the afs call we're invoking. The table used here was
1343 * gleaned from vlserver/vldbint.xg
1344 */
1345
1346 vldb_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
1347
1348 printf(" vldb");
1349
1350 if (is_ubik(vldb_op)) {
1351 ubik_print(bp, length);
1352 return;
1353 }
1354 printf(" call %s", tok2str(vldb_req, "op#%d", vldb_op));
1355
1356 /*
1357 * Decode some of the arguments to the VLDB calls
1358 */
1359
1360 bp += sizeof(struct rx_header) + 4;
1361
1362 switch (vldb_op) {
1363 case 501: /* Create new volume */
1364 case 517: /* Create entry N */
1365 VECOUT(VLNAMEMAX);
1366 break;
1367 case 502: /* Delete entry */
1368 case 503: /* Get entry by ID */
1369 case 507: /* Update entry */
1370 case 508: /* Set lock */
1371 case 509: /* Release lock */
1372 case 518: /* Get entry by ID N */
1373 printf(" volid");
1374 INTOUT();
1375 TRUNC(sizeof(int32_t));
1376 i = ntohl(*((int *) bp));
1377 bp += sizeof(int32_t);
1378 if (i <= 2)
1379 printf(" type %s", voltype[i]);
1380 break;
1381 case 504: /* Get entry by name */
1382 case 519: /* Get entry by name N */
1383 case 524: /* Update entry by name */
1384 case 527: /* Get entry by name U */
1385 STROUT(VLNAMEMAX);
1386 break;
1387 case 505: /* Get new vol id */
1388 printf(" bump");
1389 INTOUT();
1390 break;
1391 case 506: /* Replace entry */
1392 case 520: /* Replace entry N */
1393 printf(" volid");
1394 INTOUT();
1395 TRUNC(sizeof(int32_t));
1396 i = ntohl(*((int *) bp));
1397 bp += sizeof(int32_t);
1398 if (i <= 2)
1399 printf(" type %s", voltype[i]);
1400 VECOUT(VLNAMEMAX);
1401 break;
1402 case 510: /* List entry */
1403 case 521: /* List entry N */
1404 printf(" index");
1405 INTOUT();
1406 break;
1407 default:
1408 ;
1409 }
1410
1411 return;
1412
1413 trunc:
1414 printf(" [|vldb]");
1415 }
1416
1417 /*
1418 * Handle replies to the AFS volume location database service
1419 */
1420
1421 static void
1422 vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
1423 {
1424 struct rx_header *rxh;
1425 unsigned long i;
1426 char s[AFSNAMEMAX];
1427
1428 if (length < sizeof(struct rx_header))
1429 return;
1430
1431 rxh = (struct rx_header *) bp;
1432
1433 /*
1434 * Print out the afs call we're invoking. The table used here was
1435 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1436 * Ubik call, however.
1437 */
1438
1439 printf(" vldb");
1440
1441 if (is_ubik(opcode)) {
1442 ubik_reply_print(bp, length, opcode);
1443 return;
1444 }
1445
1446 printf(" reply %s", tok2str(vldb_req, "op#%d", opcode));
1447
1448 bp += sizeof(struct rx_header);
1449
1450 /*
1451 * If it was a data packet, interpret the response
1452 */
1453
1454 if (rxh->type == RX_PACKET_TYPE_DATA)
1455 switch (opcode) {
1456 case 510: /* List entry */
1457 printf(" count");
1458 INTOUT();
1459 printf(" nextindex");
1460 INTOUT();
1461 case 503: /* Get entry by id */
1462 case 504: /* Get entry by name */
1463 { unsigned long nservers, j;
1464 VECOUT(VLNAMEMAX);
1465 TRUNC(sizeof(int32_t));
1466 bp += sizeof(int32_t);
1467 printf(" numservers");
1468 TRUNC(sizeof(int32_t));
1469 nservers = ntohl(*((int *) bp));
1470 bp += sizeof(int32_t);
1471 printf(" %d", nservers);
1472 printf(" servers");
1473 for (i = 0; i < 8; i++) {
1474 TRUNC(sizeof(int32_t));
1475 if (i < nservers)
1476 printf(" %s",
1477 inet_ntoa(*((struct in_addr *) bp)));
1478 bp += sizeof(int32_t);
1479 }
1480 printf(" partitions");
1481 for (i = 0; i < 8; i++) {
1482 TRUNC(sizeof(int32_t));
1483 j = ntohl(*((int *) bp));
1484 if (i < nservers && j <= 26)
1485 printf(" %c", 'a' + j);
1486 else if (i < nservers)
1487 printf(" %d", j);
1488 bp += sizeof(int32_t);
1489 }
1490 TRUNC(8 * sizeof(int32_t));
1491 bp += 8 * sizeof(int32_t);
1492 printf(" rwvol");
1493 UINTOUT();
1494 printf(" rovol");
1495 UINTOUT();
1496 printf(" backup");
1497 UINTOUT();
1498 }
1499 break;
1500 case 505: /* Get new volume ID */
1501 printf(" newvol");
1502 UINTOUT();
1503 break;
1504 case 521: /* List entry */
1505 case 529: /* List entry U */
1506 printf(" count");
1507 INTOUT();
1508 printf(" nextindex");
1509 INTOUT();
1510 case 518: /* Get entry by ID N */
1511 case 519: /* Get entry by name N */
1512 { unsigned long nservers, j;
1513 VECOUT(VLNAMEMAX);
1514 printf(" numservers");
1515 TRUNC(sizeof(int32_t));
1516 nservers = ntohl(*((int *) bp));
1517 bp += sizeof(int32_t);
1518 printf(" %d", nservers);
1519 printf(" servers");
1520 for (i = 0; i < 13; i++) {
1521 TRUNC(sizeof(int32_t));
1522 if (i < nservers)
1523 printf(" %s",
1524 inet_ntoa(*((struct in_addr *) bp)));
1525 bp += sizeof(int32_t);
1526 }
1527 printf(" partitions");
1528 for (i = 0; i < 13; i++) {
1529 TRUNC(sizeof(int32_t));
1530 j = ntohl(*((int *) bp));
1531 if (i < nservers && j <= 26)
1532 printf(" %c", 'a' + j);
1533 else if (i < nservers)
1534 printf(" %d", j);
1535 bp += sizeof(int32_t);
1536 }
1537 TRUNC(13 * sizeof(int32_t));
1538 bp += 13 * sizeof(int32_t);
1539 printf(" rwvol");
1540 UINTOUT();
1541 printf(" rovol");
1542 UINTOUT();
1543 printf(" backup");
1544 UINTOUT();
1545 }
1546 break;
1547 case 526: /* Get entry by ID U */
1548 case 527: /* Get entry by name U */
1549 { unsigned long nservers, j;
1550 VECOUT(VLNAMEMAX);
1551 printf(" numservers");
1552 TRUNC(sizeof(int32_t));
1553 nservers = ntohl(*((int *) bp));
1554 bp += sizeof(int32_t);
1555 printf(" %d", nservers);
1556 printf(" servers");
1557 for (i = 0; i < 13; i++) {
1558 if (i < nservers) {
1559 printf(" afsuuid");
1560 AFSUUIDOUT();
1561 } else {
1562 TRUNC(44);
1563 bp += 44;
1564 }
1565 }
1566 TRUNC(4 * 13);
1567 bp += 4 * 13;
1568 printf(" partitions");
1569 for (i = 0; i < 13; i++) {
1570 TRUNC(sizeof(int32_t));
1571 j = ntohl(*((int *) bp));
1572 if (i < nservers && j <= 26)
1573 printf(" %c", 'a' + j);
1574 else if (i < nservers)
1575 printf(" %d", j);
1576 bp += sizeof(int32_t);
1577 }
1578 TRUNC(13 * sizeof(int32_t));
1579 bp += 13 * sizeof(int32_t);
1580 printf(" rwvol");
1581 UINTOUT();
1582 printf(" rovol");
1583 UINTOUT();
1584 printf(" backup");
1585 UINTOUT();
1586 }
1587 default:
1588 ;
1589 }
1590
1591 else {
1592 /*
1593 * Otherwise, just print out the return code
1594 */
1595 printf(" errcode");
1596 INTOUT();
1597 }
1598
1599 return;
1600
1601 trunc:
1602 printf(" [|vldb]");
1603 }
1604
1605 /*
1606 * Handle calls to the AFS Kerberos Authentication service
1607 */
1608
1609 static void
1610 kauth_print(register const u_char *bp, int length)
1611 {
1612 int kauth_op;
1613 char s[AFSNAMEMAX];
1614
1615 if (length <= sizeof(struct rx_header))
1616 return;
1617
1618 if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) {
1619 goto trunc;
1620 }
1621
1622 /*
1623 * Print out the afs call we're invoking. The table used here was
1624 * gleaned from kauth/kauth.rg
1625 */
1626
1627 kauth_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
1628
1629 printf(" kauth");
1630
1631 if (is_ubik(kauth_op)) {
1632 ubik_print(bp, length);
1633 return;
1634 }
1635
1636
1637 printf(" call %s", tok2str(kauth_req, "op#%d", kauth_op));
1638
1639 /*
1640 * Decode some of the arguments to the KA calls
1641 */
1642
1643 bp += sizeof(struct rx_header) + 4;
1644
1645 switch (kauth_op) {
1646 case 1: /* Authenticate old */;
1647 case 21: /* Authenticate */
1648 case 22: /* Authenticate-V2 */
1649 case 2: /* Change PW */
1650 case 5: /* Set fields */
1651 case 6: /* Create user */
1652 case 7: /* Delete user */
1653 case 8: /* Get entry */
1654 case 14: /* Unlock */
1655 case 15: /* Lock status */
1656 printf(" principal");
1657 STROUT(KANAMEMAX);
1658 STROUT(KANAMEMAX);
1659 break;
1660 case 3: /* GetTicket-old */
1661 case 23: /* GetTicket */
1662 {
1663 int i;
1664 printf(" kvno");
1665 INTOUT();
1666 printf(" domain");
1667 STROUT(KANAMEMAX);
1668 TRUNC(sizeof(int32_t));
1669 i = (int) ntohl(*((int *) bp));
1670 bp += sizeof(int32_t);
1671 TRUNC(i);
1672 bp += i;
1673 printf(" principal");
1674 STROUT(KANAMEMAX);
1675 STROUT(KANAMEMAX);
1676 break;
1677 }
1678 case 4: /* Set Password */
1679 printf(" principal");
1680 STROUT(KANAMEMAX);
1681 STROUT(KANAMEMAX);
1682 printf(" kvno");
1683 INTOUT();
1684 break;
1685 case 12: /* Get password */
1686 printf(" name");
1687 STROUT(KANAMEMAX);
1688 break;
1689 default:
1690 ;
1691 }
1692
1693 return;
1694
1695 trunc:
1696 printf(" [|kauth]");
1697 }
1698
1699 /*
1700 * Handle replies to the AFS Kerberos Authentication Service
1701 */
1702
1703 static void
1704 kauth_reply_print(register const u_char *bp, int length, int32_t opcode)
1705 {
1706 unsigned long i;
1707 char s[AFSNAMEMAX];
1708 struct rx_header *rxh;
1709
1710 if (length <= sizeof(struct rx_header))
1711 return;
1712
1713 rxh = (struct rx_header *) bp;
1714
1715 /*
1716 * Print out the afs call we're invoking. The table used here was
1717 * gleaned from kauth/kauth.rg
1718 */
1719
1720 printf(" kauth");
1721
1722 if (is_ubik(opcode)) {
1723 ubik_reply_print(bp, length, opcode);
1724 return;
1725 }
1726
1727 printf(" reply %s", tok2str(kauth_req, "op#%d", opcode));
1728
1729 bp += sizeof(struct rx_header);
1730
1731 /*
1732 * If it was a data packet, interpret the response.
1733 */
1734
1735 if (rxh->type == RX_PACKET_TYPE_DATA)
1736 /* Well, no, not really. Leave this for later */
1737 ;
1738 else {
1739 /*
1740 * Otherwise, just print out the return code
1741 */
1742 printf(" errcode");
1743 INTOUT();
1744 }
1745
1746 return;
1747
1748 trunc:
1749 printf(" [|kauth]");
1750 }
1751
1752 /*
1753 * Handle calls to the AFS Volume location service
1754 */
1755
1756 static void
1757 vol_print(register const u_char *bp, int length)
1758 {
1759 int vol_op;
1760
1761 if (length <= sizeof(struct rx_header))
1762 return;
1763
1764 if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) {
1765 goto trunc;
1766 }
1767
1768 /*
1769 * Print out the afs call we're invoking. The table used here was
1770 * gleaned from volser/volint.xg
1771 */
1772
1773 vol_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
1774
1775 printf(" vol call %s", tok2str(vol_req, "op#%d", vol_op));
1776
1777 /*
1778 * Normally there would be a switch statement here to decode the
1779 * arguments to the AFS call, but since I don't have access to
1780 * an AFS server (yet) and I'm not an AFS admin, I can't
1781 * test any of these calls. Leave this blank for now.
1782 */
1783
1784 return;
1785
1786 trunc:
1787 printf(" [|vol]");
1788 }
1789
1790 /*
1791 * Handle replies to the AFS Volume Service
1792 */
1793
1794 static void
1795 vol_reply_print(register const u_char *bp, int length, int32_t opcode)
1796 {
1797 unsigned long i;
1798 char s[AFSNAMEMAX];
1799 struct rx_header *rxh;
1800
1801 if (length <= sizeof(struct rx_header))
1802 return;
1803
1804 rxh = (struct rx_header *) bp;
1805
1806 /*
1807 * Print out the afs call we're invoking. The table used here was
1808 * gleaned from volser/volint.xg
1809 */
1810
1811 printf(" vol reply %s", tok2str(vol_req, "op#%d", opcode));
1812
1813 bp += sizeof(struct rx_header);
1814
1815 /*
1816 * If it was a data packet, interpret the response.
1817 */
1818
1819 if (rxh->type == RX_PACKET_TYPE_DATA)
1820 /* Well, no, not really. Leave this for later */
1821 ;
1822 else {
1823 /*
1824 * Otherwise, just print out the return code
1825 */
1826 printf(" errcode");
1827 INTOUT();
1828 }
1829
1830 return;
1831
1832 trunc:
1833 printf(" [|vol]");
1834 }
1835
1836 /*
1837 * Handle calls to the AFS BOS service
1838 */
1839
1840 static void
1841 bos_print(register const u_char *bp, int length)
1842 {
1843 int bos_op;
1844 char s[BOSNAMEMAX];
1845
1846 if (length <= sizeof(struct rx_header))
1847 return;
1848
1849 if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) {
1850 goto trunc;
1851 }
1852
1853 /*
1854 * Print out the afs call we're invoking. The table used here was
1855 * gleaned from bozo/bosint.xg
1856 */
1857
1858 bos_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
1859
1860 printf(" bos call %s", tok2str(bos_req, "op#%d", bos_op));
1861
1862 /*
1863 * Decode some of the arguments to the BOS calls
1864 */
1865
1866 bp += sizeof(struct rx_header) + 4;
1867
1868 switch (bos_op) {
1869 case 80: /* Create B node */
1870 printf(" type");
1871 STROUT(BOSNAMEMAX);
1872 printf(" instance");
1873 STROUT(BOSNAMEMAX);
1874 break;
1875 case 81: /* Delete B node */
1876 case 83: /* Get status */
1877 case 85: /* Get instance info */
1878 case 87: /* Add super user */
1879 case 88: /* Delete super user */
1880 case 93: /* Set cell name */
1881 case 96: /* Add cell host */
1882 case 97: /* Delete cell host */
1883 case 104: /* Restart */
1884 case 106: /* Uninstall */
1885 case 108: /* Exec */
1886 case 112: /* Getlog */
1887 case 114: /* Get instance strings */
1888 STROUT(BOSNAMEMAX);
1889 break;
1890 case 82: /* Set status */
1891 case 98: /* Set T status */
1892 STROUT(BOSNAMEMAX);
1893 printf(" status");
1894 INTOUT();
1895 break;
1896 case 86: /* Get instance parm */
1897 STROUT(BOSNAMEMAX);
1898 printf(" num");
1899 INTOUT();
1900 break;
1901 case 84: /* Enumerate instance */
1902 case 89: /* List super users */
1903 case 90: /* List keys */
1904 case 91: /* Add key */
1905 case 92: /* Delete key */
1906 case 95: /* Get cell host */
1907 INTOUT();
1908 break;
1909 case 105: /* Install */
1910 STROUT(BOSNAMEMAX);
1911 printf(" size");
1912 INTOUT();
1913 printf(" flags");
1914 INTOUT();
1915 printf(" date");
1916 INTOUT();
1917 break;
1918 default:
1919 ;
1920 }
1921
1922 return;
1923
1924 trunc:
1925 printf(" [|bos]");
1926 }
1927
1928 /*
1929 * Handle replies to the AFS BOS Service
1930 */
1931
1932 static void
1933 bos_reply_print(register const u_char *bp, int length, int32_t opcode)
1934 {
1935 unsigned long i;
1936 char s[AFSNAMEMAX];
1937 struct rx_header *rxh;
1938
1939 if (length <= sizeof(struct rx_header))
1940 return;
1941
1942 rxh = (struct rx_header *) bp;
1943
1944 /*
1945 * Print out the afs call we're invoking. The table used here was
1946 * gleaned from volser/volint.xg
1947 */
1948
1949 printf(" bos reply %s", tok2str(bos_req, "op#%d", opcode));
1950
1951 bp += sizeof(struct rx_header);
1952
1953 /*
1954 * If it was a data packet, interpret the response.
1955 */
1956
1957 if (rxh->type == RX_PACKET_TYPE_DATA)
1958 /* Well, no, not really. Leave this for later */
1959 ;
1960 else {
1961 /*
1962 * Otherwise, just print out the return code
1963 */
1964 printf(" errcode");
1965 INTOUT();
1966 }
1967
1968 return;
1969
1970 trunc:
1971 printf(" [|bos]");
1972 }
1973
1974 /*
1975 * Check to see if this is a Ubik opcode.
1976 */
1977
1978 static int
1979 is_ubik(u_int32_t opcode)
1980 {
1981 if ((opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
1982 (opcode >= DISK_LOW && opcode <= DISK_HIGH))
1983 return(1);
1984 else
1985 return(0);
1986 }
1987
1988 /*
1989 * Handle Ubik opcodes to any one of the replicated database services
1990 */
1991
1992 static void
1993 ubik_print(register const u_char *bp, int length)
1994 {
1995 int ubik_op;
1996 int32_t temp;
1997
1998 /*
1999 * Print out the afs call we're invoking. The table used here was
2000 * gleaned from ubik/ubik_int.xg
2001 */
2002
2003 ubik_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
2004
2005 printf(" ubik call %s", tok2str(ubik_req, "op#%d", ubik_op));
2006
2007 /*
2008 * Decode some of the arguments to the Ubik calls
2009 */
2010
2011 bp += sizeof(struct rx_header) + 4;
2012
2013 switch (ubik_op) {
2014 case 10000: /* Beacon */
2015 TRUNC(4);
2016 temp = ntohl(*((int *) bp));
2017 bp += sizeof(int32_t);
2018 printf(" syncsite %s", temp ? "yes" : "no");
2019 printf(" votestart");
2020 DATEOUT();
2021 printf(" dbversion");
2022 UBIK_VERSIONOUT();
2023 printf(" tid");
2024 UBIK_VERSIONOUT();
2025 break;
2026 case 10003: /* Get sync site */
2027 printf(" site");
2028 UINTOUT();
2029 break;
2030 case 20000: /* Begin */
2031 case 20001: /* Commit */
2032 case 20007: /* Abort */
2033 case 20008: /* Release locks */
2034 case 20010: /* Writev */
2035 printf(" tid");
2036 UBIK_VERSIONOUT();
2037 break;
2038 case 20002: /* Lock */
2039 printf(" tid");
2040 UBIK_VERSIONOUT();
2041 printf(" file");
2042 INTOUT();
2043 printf(" pos");
2044 INTOUT();
2045 printf(" length");
2046 INTOUT();
2047 temp = ntohl(*((int *) bp));
2048 bp += sizeof(int32_t);
2049 tok2str(ubik_lock_types, "type %d", temp);
2050 break;
2051 case 20003: /* Write */
2052 printf(" tid");
2053 UBIK_VERSIONOUT();
2054 printf(" file");
2055 INTOUT();
2056 printf(" pos");
2057 INTOUT();
2058 break;
2059 case 20005: /* Get file */
2060 printf(" file");
2061 INTOUT();
2062 break;
2063 case 20006: /* Send file */
2064 printf(" file");
2065 INTOUT();
2066 printf(" length");
2067 INTOUT();
2068 printf(" dbversion");
2069 UBIK_VERSIONOUT();
2070 break;
2071 case 20009: /* Truncate */
2072 printf(" tid");
2073 UBIK_VERSIONOUT();
2074 printf(" file");
2075 INTOUT();
2076 printf(" length");
2077 INTOUT();
2078 break;
2079 case 20012: /* Set version */
2080 printf(" tid");
2081 UBIK_VERSIONOUT();
2082 printf(" oldversion");
2083 UBIK_VERSIONOUT();
2084 printf(" newversion");
2085 UBIK_VERSIONOUT();
2086 break;
2087 default:
2088 ;
2089 }
2090
2091 return;
2092
2093 trunc:
2094 printf(" [|ubik]");
2095 }
2096
2097 /*
2098 * Handle Ubik replies to any one of the replicated database services
2099 */
2100
2101 static void
2102 ubik_reply_print(register const u_char *bp, int length, int32_t opcode)
2103 {
2104 struct rx_header *rxh;
2105
2106 if (length < sizeof(struct rx_header))
2107 return;
2108
2109 rxh = (struct rx_header *) bp;
2110
2111 /*
2112 * Print out the ubik call we're invoking. This table was gleaned
2113 * from ubik/ubik_int.xg
2114 */
2115
2116 printf(" ubik reply %s", tok2str(ubik_req, "op#%d", opcode));
2117
2118 bp += sizeof(struct rx_header);
2119
2120 /*
2121 * If it was a data packet, print out the arguments to the Ubik calls
2122 */
2123
2124 if (rxh->type == RX_PACKET_TYPE_DATA)
2125 switch (opcode) {
2126 case 10000: /* Beacon */
2127 printf(" vote no");
2128 break;
2129 case 20004: /* Get version */
2130 printf(" dbversion");
2131 UBIK_VERSIONOUT();
2132 break;
2133 default:
2134 ;
2135 }
2136
2137 /*
2138 * Otherwise, print out "yes" it it was a beacon packet (because
2139 * that's how yes votes are returned, go figure), otherwise
2140 * just print out the error code.
2141 */
2142
2143 else
2144 switch (opcode) {
2145 case 10000: /* Beacon */
2146 printf(" vote yes until");
2147 DATEOUT();
2148 break;
2149 default:
2150 printf(" errcode");
2151 INTOUT();
2152 }
2153
2154 return;
2155
2156 trunc:
2157 printf(" [|ubik]");
2158 }