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