2 * Copyright: (c) 2000 United States Government as represented by the
3 * Secretary of the Navy. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
15 * 3. The names of the authors may not be used to endorse or promote
16 * products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 /* \summary: AFS RX printer */
27 * This code unmangles RX packets. RX is the mutant form of RPC that AFS
28 * uses to communicate between clients and servers.
30 * In this code, I mainly concern myself with decoding the AFS calls, not
31 * with the guts of RX, per se.
33 * Bah. If I never look at rx_packet.h again, it will be too soon.
35 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
45 #include "netdissect-stdinc.h"
47 #include "netdissect.h"
48 #include "addrtoname.h"
53 #define FS_RX_PORT 7000
54 #define CB_RX_PORT 7001
55 #define PROT_RX_PORT 7002
56 #define VLDB_RX_PORT 7003
57 #define KAUTH_RX_PORT 7004
58 #define VOL_RX_PORT 7005
59 #define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
60 #define BOS_RX_PORT 7007
62 #define AFSNAMEMAX 256
63 #define AFSOPAQUEMAX 1024
67 #define BOSNAMEMAX 256
69 #define PRSFS_READ 1 /* Read files */
70 #define PRSFS_WRITE 2 /* Write files */
71 #define PRSFS_INSERT 4 /* Insert files into a directory */
72 #define PRSFS_LOOKUP 8 /* Lookup files into a directory */
73 #define PRSFS_DELETE 16 /* Delete files */
74 #define PRSFS_LOCK 32 /* Lock files */
75 #define PRSFS_ADMINISTER 64 /* Change ACL's */
80 nd_uint32_t callNumber
;
84 #define RX_PACKET_TYPE_DATA 1
85 #define RX_PACKET_TYPE_ACK 2
86 #define RX_PACKET_TYPE_BUSY 3
87 #define RX_PACKET_TYPE_ABORT 4
88 #define RX_PACKET_TYPE_ACKALL 5
89 #define RX_PACKET_TYPE_CHALLENGE 6
90 #define RX_PACKET_TYPE_RESPONSE 7
91 #define RX_PACKET_TYPE_DEBUG 8
92 #define RX_PACKET_TYPE_PARAMS 9
93 #define RX_PACKET_TYPE_VERSION 13
95 #define RX_CLIENT_INITIATED 1
96 #define RX_REQUEST_ACK 2
97 #define RX_LAST_PACKET 4
98 #define RX_MORE_PACKETS 8
99 #define RX_FREE_PACKET 16
100 #define RX_SLOW_START_OK 32
101 #define RX_JUMBO_PACKET 32
102 nd_uint8_t userStatus
;
103 nd_uint8_t securityIndex
;
104 nd_uint16_t spare
; /* How clever: even though the AFS */
105 nd_uint16_t serviceId
; /* header files indicate that the */
106 }; /* serviceId is first, it's really */
107 /* encoded _after_ the spare field */
108 /* I wasted a day figuring that out! */
110 #define NUM_RX_FLAGS 7
112 #define RX_MAXACKS 255
114 struct rx_ackPacket
{
115 nd_uint16_t bufferSpace
; /* Number of packet buffers available */
116 nd_uint16_t maxSkew
; /* Max diff between ack'd packet and */
117 /* highest packet received */
118 nd_uint32_t firstPacket
; /* The first packet in ack list */
119 nd_uint32_t previousPacket
; /* Previous packet recv'd (obsolete) */
120 nd_uint32_t serial
; /* # of packet that prompted the ack */
121 nd_uint8_t reason
; /* Reason for acknowledgement */
122 nd_uint8_t nAcks
; /* Number of acknowledgements */
123 /* Followed by nAcks acknowledgments */
125 uint8_t acks
[RX_MAXACKS
]; /* Up to RX_MAXACKS acknowledgements */
130 * Values for the acks array
133 #define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
134 #define RX_ACK_TYPE_ACK 1 /* I have this packet */
136 static const struct tok rx_types
[] = {
137 { RX_PACKET_TYPE_DATA
, "data" },
138 { RX_PACKET_TYPE_ACK
, "ack" },
139 { RX_PACKET_TYPE_BUSY
, "busy" },
140 { RX_PACKET_TYPE_ABORT
, "abort" },
141 { RX_PACKET_TYPE_ACKALL
, "ackall" },
142 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
143 { RX_PACKET_TYPE_RESPONSE
, "response" },
144 { RX_PACKET_TYPE_DEBUG
, "debug" },
145 { RX_PACKET_TYPE_PARAMS
, "params" },
146 { RX_PACKET_TYPE_VERSION
, "version" },
150 static const struct double_tok
{
151 uint32_t flag
; /* Rx flag */
152 uint32_t packetType
; /* Packet type */
153 const char *s
; /* Flag string */
155 { RX_CLIENT_INITIATED
, 0, "client-init" },
156 { RX_REQUEST_ACK
, 0, "req-ack" },
157 { RX_LAST_PACKET
, 0, "last-pckt" },
158 { RX_MORE_PACKETS
, 0, "more-pckts" },
159 { RX_FREE_PACKET
, 0, "free-pckt" },
160 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
161 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
164 static const struct tok fs_req
[] = {
165 { 130, "fetch-data" },
166 { 131, "fetch-acl" },
167 { 132, "fetch-status" },
168 { 133, "store-data" },
169 { 134, "store-acl" },
170 { 135, "store-status" },
171 { 136, "remove-file" },
172 { 137, "create-file" },
178 { 143, "oldsetlock" },
179 { 144, "oldextlock" },
180 { 145, "oldrellock" },
181 { 146, "get-stats" },
183 { 148, "get-vlinfo" },
184 { 149, "get-vlstats" },
185 { 150, "set-vlstats" },
186 { 151, "get-rootvl" },
187 { 152, "check-token" },
189 { 154, "nget-vlinfo" },
190 { 155, "bulk-stat" },
194 { 159, "xstat-ver" },
195 { 160, "get-xstat" },
196 { 161, "dfs-lookup" },
197 { 162, "dfs-flushcps" },
198 { 163, "dfs-symlink" },
199 { 220, "residency" },
200 { 65536, "inline-bulk-status" },
201 { 65537, "fetch-data-64" },
202 { 65538, "store-data-64" },
203 { 65539, "give-up-all-cbs" },
204 { 65540, "get-caps" },
205 { 65541, "cb-rx-conn-addr" },
209 static const struct tok cb_req
[] = {
218 { 212, "whoareyou" },
220 { 214, "probeuuid" },
221 { 215, "getsrvprefs" },
222 { 216, "getcellservdb" },
223 { 217, "getlocalcell" },
224 { 218, "getcacheconf" },
225 { 65536, "getce64" },
226 { 65537, "getcellbynum" },
227 { 65538, "tellmeaboutyourself" },
231 static const struct tok pt_req
[] = {
233 { 501, "where-is-it" },
234 { 502, "dump-entry" },
235 { 503, "add-to-group" },
236 { 504, "name-to-id" },
237 { 505, "id-to-name" },
239 { 507, "remove-from-group" },
241 { 509, "new-entry" },
244 { 512, "list-entry" },
245 { 513, "change-entry" },
246 { 514, "list-elements" },
247 { 515, "same-mbr-of" },
248 { 516, "set-fld-sentry" },
249 { 517, "list-owned" },
251 { 519, "get-host-cps" },
252 { 520, "update-entry" },
253 { 521, "list-entries" },
254 { 530, "list-super-groups" },
258 static const struct tok vldb_req
[] = {
259 { 501, "create-entry" },
260 { 502, "delete-entry" },
261 { 503, "get-entry-by-id" },
262 { 504, "get-entry-by-name" },
263 { 505, "get-new-volume-id" },
264 { 506, "replace-entry" },
265 { 507, "update-entry" },
267 { 509, "releaselock" },
268 { 510, "list-entry" },
269 { 511, "list-attrib" },
270 { 512, "linked-list" },
271 { 513, "get-stats" },
273 { 515, "get-addrs" },
274 { 516, "change-addr" },
275 { 517, "create-entry-n" },
276 { 518, "get-entry-by-id-n" },
277 { 519, "get-entry-by-name-n" },
278 { 520, "replace-entry-n" },
279 { 521, "list-entry-n" },
280 { 522, "list-attrib-n" },
281 { 523, "linked-list-n" },
282 { 524, "update-entry-by-name" },
283 { 525, "create-entry-u" },
284 { 526, "get-entry-by-id-u" },
285 { 527, "get-entry-by-name-u" },
286 { 528, "replace-entry-u" },
287 { 529, "list-entry-u" },
288 { 530, "list-attrib-u" },
289 { 531, "linked-list-u" },
291 { 533, "get-addrs-u" },
292 { 534, "list-attrib-n2" },
296 static const struct tok kauth_req
[] = {
298 { 21, "authenticate" },
299 { 22, "authenticate-v2" },
301 { 3, "get-ticket-old" },
302 { 23, "get-ticket" },
305 { 6, "create-user" },
306 { 7, "delete-user" },
312 { 13, "get-random-key" },
314 { 15, "lock-status" },
318 static const struct tok vol_req
[] = {
319 { 100, "create-volume" },
320 { 101, "delete-volume" },
323 { 104, "end-trans" },
325 { 106, "set-flags" },
326 { 107, "get-flags" },
327 { 108, "trans-create" },
329 { 110, "get-nth-volume" },
330 { 111, "set-forwarding" },
332 { 113, "get-status" },
333 { 114, "sig-restore" },
334 { 115, "list-partitions" },
335 { 116, "list-volumes" },
336 { 117, "set-id-types" },
338 { 119, "partition-info" },
340 { 121, "list-one-volume" },
343 { 124, "x-list-volumes" },
344 { 125, "x-list-one-volume" },
346 { 127, "x-list-partitions" },
347 { 128, "forward-multiple" },
348 { 65536, "convert-ro" },
349 { 65537, "get-size" },
350 { 65538, "dump-v2" },
354 static const struct tok bos_req
[] = {
355 { 80, "create-bnode" },
356 { 81, "delete-bnode" },
357 { 82, "set-status" },
358 { 83, "get-status" },
359 { 84, "enumerate-instance" },
360 { 85, "get-instance-info" },
361 { 86, "get-instance-parm" },
362 { 87, "add-superuser" },
363 { 88, "delete-superuser" },
364 { 89, "list-superusers" },
367 { 92, "delete-key" },
368 { 93, "set-cell-name" },
369 { 94, "get-cell-name" },
370 { 95, "get-cell-host" },
371 { 96, "add-cell-host" },
372 { 97, "delete-cell-host" },
373 { 98, "set-t-status" },
374 { 99, "shutdown-all" },
375 { 100, "restart-all" },
376 { 101, "startup-all" },
377 { 102, "set-noauth-flag" },
380 { 105, "start-bozo-install" },
381 { 106, "uninstall" },
382 { 107, "get-dates" },
385 { 110, "set-restart-time" },
386 { 111, "get-restart-time" },
387 { 112, "start-bozo-log" },
389 { 114, "get-instance-strings" },
390 { 115, "get-restricted" },
391 { 116, "set-restricted" },
395 static const struct tok ubik_req
[] = {
396 { 10000, "vote-beacon" },
397 { 10001, "vote-debug-old" },
398 { 10002, "vote-sdebug-old" },
399 { 10003, "vote-getsyncsite" },
400 { 10004, "vote-debug" },
401 { 10005, "vote-sdebug" },
402 { 10006, "vote-xdebug" },
403 { 10007, "vote-xsdebug" },
404 { 20000, "disk-begin" },
405 { 20001, "disk-commit" },
406 { 20002, "disk-lock" },
407 { 20003, "disk-write" },
408 { 20004, "disk-getversion" },
409 { 20005, "disk-getfile" },
410 { 20006, "disk-sendfile" },
411 { 20007, "disk-abort" },
412 { 20008, "disk-releaselocks" },
413 { 20009, "disk-truncate" },
414 { 20010, "disk-probe" },
415 { 20011, "disk-writev" },
416 { 20012, "disk-interfaceaddr" },
417 { 20013, "disk-setversion" },
421 #define VOTE_LOW 10000
422 #define VOTE_HIGH 10007
423 #define DISK_LOW 20000
424 #define DISK_HIGH 20013
426 static const struct tok cb_types
[] = {
433 static const struct tok ubik_lock_types
[] = {
440 static const char *voltype
[] = { "read-write", "read-only", "backup" };
442 static const struct tok afs_fs_errors
[] = {
443 { 101, "salvage volume" },
444 { 102, "no such vnode" },
445 { 103, "no such volume" },
446 { 104, "volume exist" },
447 { 105, "no service" },
448 { 106, "volume offline" },
449 { 107, "voline online" },
451 { 109, "diskquota exceeded" },
452 { 110, "volume busy" },
453 { 111, "volume moved" },
454 { 112, "AFS IO error" },
455 { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */
460 * Reasons for acknowledging a packet
463 static const struct tok rx_ack_reasons
[] = {
464 { 1, "ack requested" },
465 { 2, "duplicate packet" },
466 { 3, "out of sequence" },
467 { 4, "exceeds window" },
468 { 5, "no buffer space" },
470 { 7, "ping response" },
477 * Cache entries we keep around so we can figure out the RX opcode
478 * numbers for replies. This allows us to make sense of RX reply packets.
481 struct rx_cache_entry
{
482 uint32_t callnum
; /* Call number (net order) */
483 struct in_addr client
; /* client IP address (net order) */
484 struct in_addr server
; /* server IP address (net order) */
485 u_int dport
; /* server port (host order) */
486 uint16_t serviceId
; /* Service identifier (net order) */
487 uint32_t opcode
; /* RX opcode (host order) */
490 #define RX_CACHE_SIZE 64
492 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
494 static uint32_t rx_cache_next
= 0;
495 static uint32_t rx_cache_hint
= 0;
496 static void rx_cache_insert(netdissect_options
*, const u_char
*, const struct ip
*, u_int
);
497 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
498 uint32_t, uint32_t *);
500 static void fs_print(netdissect_options
*, const u_char
*, u_int
);
501 static void fs_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
502 static void acl_print(netdissect_options
*, u_char
*, int, u_char
*);
503 static void cb_print(netdissect_options
*, const u_char
*, u_int
);
504 static void cb_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
505 static void prot_print(netdissect_options
*, const u_char
*, u_int
);
506 static void prot_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
507 static void vldb_print(netdissect_options
*, const u_char
*, u_int
);
508 static void vldb_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
509 static void kauth_print(netdissect_options
*, const u_char
*, u_int
);
510 static void kauth_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
511 static void vol_print(netdissect_options
*, const u_char
*, u_int
);
512 static void vol_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
513 static void bos_print(netdissect_options
*, const u_char
*, u_int
);
514 static void bos_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
515 static void ubik_print(netdissect_options
*, const u_char
*);
516 static void ubik_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
518 static void rx_ack_print(netdissect_options
*, const u_char
*, u_int
);
520 static int is_ubik(uint32_t);
523 * Handle the rx-level packet. See if we know what port it's going to so
524 * we can peek at the afs call inside
528 rx_print(netdissect_options
*ndo
,
529 const u_char
*bp
, u_int length
, u_int sport
, u_int dport
,
532 const struct rx_header
*rxh
;
537 ndo
->ndo_protocol
= "rx";
538 if (!ND_TTEST_LEN(bp
, sizeof(struct rx_header
))) {
539 ND_PRINT(" [|rx] (%u)", length
);
543 rxh
= (const struct rx_header
*) bp
;
545 type
= EXTRACT_U_1(rxh
->type
);
546 ND_PRINT(" rx %s", tok2str(rx_types
, "type %u", type
));
548 flags
= EXTRACT_U_1(rxh
->flags
);
549 if (ndo
->ndo_vflag
) {
552 if (ndo
->ndo_vflag
> 1)
553 ND_PRINT(" cid %08x call# %u",
554 EXTRACT_BE_U_4(rxh
->cid
),
555 EXTRACT_BE_U_4(rxh
->callNumber
));
557 ND_PRINT(" seq %u ser %u",
558 EXTRACT_BE_U_4(rxh
->seq
),
559 EXTRACT_BE_U_4(rxh
->serial
));
561 if (ndo
->ndo_vflag
> 2)
562 ND_PRINT(" secindex %u serviceid %hu",
563 EXTRACT_U_1(rxh
->securityIndex
),
564 EXTRACT_BE_U_2(rxh
->serviceId
));
566 if (ndo
->ndo_vflag
> 1)
567 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
568 if (flags
& rx_flags
[i
].flag
&&
569 (!rx_flags
[i
].packetType
||
570 type
== rx_flags
[i
].packetType
)) {
577 ND_PRINT("<%s>", rx_flags
[i
].s
);
583 * Try to handle AFS calls that we know about. Check the destination
584 * port and make sure it's a data packet. Also, make sure the
585 * seq number is 1 (because otherwise it's a continuation packet,
586 * and we can't interpret that). Also, seems that reply packets
587 * do not have the client-init flag set, so we check for that
591 if (type
== RX_PACKET_TYPE_DATA
&&
592 EXTRACT_BE_U_4(rxh
->seq
) == 1 &&
593 flags
& RX_CLIENT_INITIATED
) {
596 * Insert this call into the call cache table, so we
597 * have a chance to print out replies
600 rx_cache_insert(ndo
, bp
, (const struct ip
*) bp2
, dport
);
603 case FS_RX_PORT
: /* AFS file service */
604 fs_print(ndo
, bp
, length
);
606 case CB_RX_PORT
: /* AFS callback service */
607 cb_print(ndo
, bp
, length
);
609 case PROT_RX_PORT
: /* AFS protection service */
610 prot_print(ndo
, bp
, length
);
612 case VLDB_RX_PORT
: /* AFS VLDB service */
613 vldb_print(ndo
, bp
, length
);
615 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
616 kauth_print(ndo
, bp
, length
);
618 case VOL_RX_PORT
: /* AFS Volume service */
619 vol_print(ndo
, bp
, length
);
621 case BOS_RX_PORT
: /* AFS BOS service */
622 bos_print(ndo
, bp
, length
);
629 * If it's a reply (client-init is _not_ set, but seq is one)
630 * then look it up in the cache. If we find it, call the reply
631 * printing functions Note that we handle abort packets here,
632 * because printing out the return code can be useful at times.
635 } else if (((type
== RX_PACKET_TYPE_DATA
&&
636 EXTRACT_BE_U_4(rxh
->seq
) == 1) ||
637 type
== RX_PACKET_TYPE_ABORT
) &&
638 (flags
& RX_CLIENT_INITIATED
) == 0 &&
639 rx_cache_find(rxh
, (const struct ip
*) bp2
,
643 case FS_RX_PORT
: /* AFS file service */
644 fs_reply_print(ndo
, bp
, length
, opcode
);
646 case CB_RX_PORT
: /* AFS callback service */
647 cb_reply_print(ndo
, bp
, length
, opcode
);
649 case PROT_RX_PORT
: /* AFS PT service */
650 prot_reply_print(ndo
, bp
, length
, opcode
);
652 case VLDB_RX_PORT
: /* AFS VLDB service */
653 vldb_reply_print(ndo
, bp
, length
, opcode
);
655 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
656 kauth_reply_print(ndo
, bp
, length
, opcode
);
658 case VOL_RX_PORT
: /* AFS Volume service */
659 vol_reply_print(ndo
, bp
, length
, opcode
);
661 case BOS_RX_PORT
: /* AFS BOS service */
662 bos_reply_print(ndo
, bp
, length
, opcode
);
669 * If it's an RX ack packet, then use the appropriate ack decoding
670 * function (there isn't any service-specific information in the
671 * ack packet, so we can use one for all AFS services)
674 } else if (type
== RX_PACKET_TYPE_ACK
)
675 rx_ack_print(ndo
, bp
, length
);
678 ND_PRINT(" (%u)", length
);
682 * Insert an entry into the cache. Taken from print-nfs.c
686 rx_cache_insert(netdissect_options
*ndo
,
687 const u_char
*bp
, const struct ip
*ip
, u_int dport
)
689 struct rx_cache_entry
*rxent
;
690 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
692 if (!ND_TTEST_4(bp
+ sizeof(struct rx_header
)))
695 rxent
= &rx_cache
[rx_cache_next
];
697 if (++rx_cache_next
>= RX_CACHE_SIZE
)
700 rxent
->callnum
= EXTRACT_BE_U_4(rxh
->callNumber
);
701 UNALIGNED_MEMCPY(&rxent
->client
, ip
->ip_src
, sizeof(uint32_t));
702 UNALIGNED_MEMCPY(&rxent
->server
, ip
->ip_dst
, sizeof(uint32_t));
703 rxent
->dport
= dport
;
704 rxent
->serviceId
= EXTRACT_BE_U_4(rxh
->serviceId
);
705 rxent
->opcode
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
709 * Lookup an entry in the cache. Also taken from print-nfs.c
711 * Note that because this is a reply, we're looking at the _source_
716 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, u_int sport
,
720 struct rx_cache_entry
*rxent
;
724 UNALIGNED_MEMCPY(&clip
, ip
->ip_dst
, sizeof(uint32_t));
725 UNALIGNED_MEMCPY(&sip
, ip
->ip_src
, sizeof(uint32_t));
727 /* Start the search where we last left off */
731 rxent
= &rx_cache
[i
];
732 if (rxent
->callnum
== EXTRACT_BE_U_4(rxh
->callNumber
) &&
733 rxent
->client
.s_addr
== clip
&&
734 rxent
->server
.s_addr
== sip
&&
735 rxent
->serviceId
== EXTRACT_BE_U_4(rxh
->serviceId
) &&
736 rxent
->dport
== sport
) {
738 /* We got a match! */
741 *opcode
= rxent
->opcode
;
744 if (++i
>= RX_CACHE_SIZE
)
746 } while (i
!= rx_cache_hint
);
748 /* Our search failed */
753 * These extrememly grody macros handle the printing of various AFS stuff.
756 #define FIDOUT() { uint32_t n1, n2, n3; \
757 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 3); \
758 n1 = EXTRACT_BE_U_4(bp); \
759 bp += sizeof(uint32_t); \
760 n2 = EXTRACT_BE_U_4(bp); \
761 bp += sizeof(uint32_t); \
762 n3 = EXTRACT_BE_U_4(bp); \
763 bp += sizeof(uint32_t); \
764 ND_PRINT(" fid %u/%u/%u", n1, n2, n3); \
767 #define STROUT(MAX) { uint32_t _i; \
768 ND_TCHECK_LEN(bp, sizeof(uint32_t)); \
769 _i = EXTRACT_BE_U_4(bp); \
772 bp += sizeof(uint32_t); \
774 if (fn_printn(ndo, bp, _i, ndo->ndo_snapend)) \
777 bp += ((_i + sizeof(uint32_t) - 1) / sizeof(uint32_t)) * sizeof(uint32_t); \
780 #define INTOUT() { int32_t _i; \
782 _i = EXTRACT_BE_S_4(bp); \
783 bp += sizeof(int32_t); \
784 ND_PRINT(" %d", _i); \
787 #define UINTOUT() { uint32_t _i; \
789 _i = EXTRACT_BE_U_4(bp); \
790 bp += sizeof(uint32_t); \
791 ND_PRINT(" %u", _i); \
794 #define UINT64OUT() { uint64_t _i; \
795 ND_TCHECK_LEN(bp, sizeof(uint64_t)); \
796 _i = EXTRACT_BE_U_8(bp); \
797 bp += sizeof(uint64_t); \
798 ND_PRINT(" %" PRIu64, _i); \
801 #define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \
803 _t = (time_t) EXTRACT_BE_S_4(bp); \
804 bp += sizeof(int32_t); \
805 tm = localtime(&_t); \
806 strftime(str, 256, "%Y/%m/%d %H:%M:%S", tm); \
807 ND_PRINT(" %s", str); \
810 #define STOREATTROUT() { uint32_t mask, _i; \
811 ND_TCHECK_LEN(bp, (sizeof(uint32_t) * 6)); \
812 mask = EXTRACT_BE_U_4(bp); bp += sizeof(uint32_t); \
813 if (mask) ND_PRINT(" StoreStatus"); \
814 if (mask & 1) { ND_PRINT(" date"); DATEOUT(); } \
815 else bp += sizeof(uint32_t); \
816 _i = EXTRACT_BE_U_4(bp); bp += sizeof(uint32_t); \
817 if (mask & 2) ND_PRINT(" owner %u", _i); \
818 _i = EXTRACT_BE_U_4(bp); bp += sizeof(uint32_t); \
819 if (mask & 4) ND_PRINT(" group %u", _i); \
820 _i = EXTRACT_BE_U_4(bp); bp += sizeof(uint32_t); \
821 if (mask & 8) ND_PRINT(" mode %o", _i & 07777); \
822 _i = EXTRACT_BE_U_4(bp); bp += sizeof(uint32_t); \
823 if (mask & 16) ND_PRINT(" segsize %u", _i); \
824 /* undocumented in 3.3 docu */ \
825 if (mask & 1024) ND_PRINT(" fsync"); \
828 #define UBIK_VERSIONOUT() {uint32_t epoch; uint32_t counter; \
829 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 2); \
830 epoch = EXTRACT_BE_U_4(bp); \
831 bp += sizeof(uint32_t); \
832 counter = EXTRACT_BE_U_4(bp); \
833 bp += sizeof(uint32_t); \
834 ND_PRINT(" %u.%u", epoch, counter); \
837 #define AFSUUIDOUT() {uint32_t temp; int _i; \
838 ND_TCHECK_LEN(bp, 11 * sizeof(uint32_t)); \
839 temp = EXTRACT_BE_U_4(bp); \
840 bp += sizeof(uint32_t); \
841 ND_PRINT(" %08x", temp); \
842 temp = EXTRACT_BE_U_4(bp); \
843 bp += sizeof(uint32_t); \
844 ND_PRINT("%04x", temp); \
845 temp = EXTRACT_BE_U_4(bp); \
846 bp += sizeof(uint32_t); \
847 ND_PRINT("%04x", temp); \
848 for (_i = 0; _i < 8; _i++) { \
849 temp = EXTRACT_BE_U_4(bp); \
850 bp += sizeof(uint32_t); \
851 ND_PRINT("%02x", (unsigned char) temp); \
856 * This is the sickest one of all
859 #define VECOUT(MAX) { u_char *sp; \
860 u_char s[AFSNAMEMAX]; \
862 if ((MAX) + 1 > sizeof(s)) \
864 ND_TCHECK_LEN(bp, (MAX) * sizeof(uint32_t)); \
866 for (k = 0; k < (MAX); k++) { \
867 *sp++ = (u_char) EXTRACT_BE_U_4(bp); \
868 bp += sizeof(uint32_t); \
872 fn_print(ndo, s, NULL); \
876 #define DESTSERVEROUT() { uint32_t n1, n2, n3; \
877 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 3); \
878 n1 = EXTRACT_BE_U_4(bp); \
879 bp += sizeof(uint32_t); \
880 n2 = EXTRACT_BE_U_4(bp); \
881 bp += sizeof(uint32_t); \
882 n3 = EXTRACT_BE_U_4(bp); \
883 bp += sizeof(uint32_t); \
884 ND_PRINT(" server %u:%u:%u", n1, n2, n3); \
888 * Handle calls to the AFS file service (fs)
892 fs_print(netdissect_options
*ndo
,
893 const u_char
*bp
, u_int length
)
898 if (length
<= sizeof(struct rx_header
))
902 * Print out the afs call we're invoking. The table used here was
903 * gleaned from fsint/afsint.xg
906 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
907 fs_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
909 ND_PRINT(" fs call %s", tok2str(fs_req
, "op#%u", fs_op
));
912 * Print out arguments to some of the AFS calls. This stuff is
916 bp
+= sizeof(struct rx_header
) + 4;
919 * Sigh. This is gross. Ritchie forgive me.
923 case 130: /* Fetch data */
930 case 131: /* Fetch ACL */
931 case 132: /* Fetch Status */
932 case 143: /* Old set lock */
933 case 144: /* Old extend lock */
934 case 145: /* Old release lock */
935 case 156: /* Set lock */
936 case 157: /* Extend lock */
937 case 158: /* Release lock */
940 case 135: /* Store status */
944 case 133: /* Store data */
954 case 134: /* Store ACL */
956 char a
[AFSOPAQUEMAX
+1];
959 i
= EXTRACT_BE_U_4(bp
);
960 bp
+= sizeof(uint32_t);
961 ND_TCHECK_LEN(bp
, i
);
962 i
= min(AFSOPAQUEMAX
, i
);
963 strncpy(a
, (const char *) bp
, i
);
965 acl_print(ndo
, (u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
968 case 137: /* Create file */
969 case 141: /* MakeDir */
974 case 136: /* Remove file */
975 case 142: /* Remove directory */
979 case 138: /* Rename file */
987 case 139: /* Symlink */
990 ND_PRINT(" link to");
996 ND_PRINT(" link to");
999 case 148: /* Get volume info */
1002 case 149: /* Get volume stats */
1003 case 150: /* Set volume stats */
1007 case 154: /* New get volume info */
1008 ND_PRINT(" volname");
1011 case 155: /* Bulk stat */
1012 case 65536: /* Inline bulk stat */
1016 j
= EXTRACT_BE_U_4(bp
);
1017 bp
+= sizeof(uint32_t);
1019 for (i
= 0; i
< j
; i
++) {
1025 ND_PRINT(" <none!>");
1027 case 65537: /* Fetch data 64 */
1029 ND_PRINT(" offset");
1031 ND_PRINT(" length");
1034 case 65538: /* Store data 64 */
1037 ND_PRINT(" offset");
1039 ND_PRINT(" length");
1044 case 65541: /* CallBack rx conn address */
1058 * Handle replies to the AFS file service
1062 fs_reply_print(netdissect_options
*ndo
,
1063 const u_char
*bp
, u_int length
, uint32_t opcode
)
1066 const struct rx_header
*rxh
;
1069 if (length
<= sizeof(struct rx_header
))
1072 rxh
= (const struct rx_header
*) bp
;
1075 * Print out the afs call we're invoking. The table used here was
1076 * gleaned from fsint/afsint.xg
1079 ND_PRINT(" fs reply %s", tok2str(fs_req
, "op#%u", opcode
));
1081 type
= EXTRACT_U_1(rxh
->type
);
1082 bp
+= sizeof(struct rx_header
);
1085 * If it was a data packet, interpret the response
1088 if (type
== RX_PACKET_TYPE_DATA
) {
1090 case 131: /* Fetch ACL */
1092 char a
[AFSOPAQUEMAX
+1];
1094 i
= EXTRACT_BE_U_4(bp
);
1095 bp
+= sizeof(uint32_t);
1096 ND_TCHECK_LEN(bp
, i
);
1097 i
= min(AFSOPAQUEMAX
, i
);
1098 strncpy(a
, (const char *) bp
, i
);
1100 acl_print(ndo
, (u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1103 case 137: /* Create file */
1104 case 141: /* MakeDir */
1108 case 151: /* Get root volume */
1109 ND_PRINT(" root volume");
1112 case 153: /* Get time */
1118 } else if (type
== RX_PACKET_TYPE_ABORT
) {
1120 * Otherwise, just print out the return code
1125 errcode
= EXTRACT_BE_S_4(bp
);
1126 bp
+= sizeof(int32_t);
1128 ND_PRINT(" error %s", tok2str(afs_fs_errors
, "#%d", errcode
));
1130 ND_PRINT(" strange fs reply of type %u", type
);
1140 * Print out an AFS ACL string. An AFS ACL is a string that has the
1143 * <positive> <negative>
1147 * "positive" and "negative" are integers which contain the number of
1148 * positive and negative ACL's in the string. The uid/aclbits pair are
1149 * ASCII strings containing the UID/PTS record and an ASCII number
1150 * representing a logical OR of all the ACL permission bits
1154 acl_print(netdissect_options
*ndo
,
1155 u_char
*s
, int maxsize
, u_char
*end
)
1162 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1163 (*ndo
->ndo_error
)(ndo
, S_ERR_ND_MEM_ALLOC
, "acl_print: malloc");
1165 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1174 * This wacky order preserves the order used by the "fs" command
1177 #define ACLOUT(acl) \
1178 ND_PRINT("%s%s%s%s%s%s%s", \
1179 acl & PRSFS_READ ? "r" : "", \
1180 acl & PRSFS_LOOKUP ? "l" : "", \
1181 acl & PRSFS_INSERT ? "i" : "", \
1182 acl & PRSFS_DELETE ? "d" : "", \
1183 acl & PRSFS_WRITE ? "w" : "", \
1184 acl & PRSFS_LOCK ? "k" : "", \
1185 acl & PRSFS_ADMINISTER ? "a" : "");
1187 for (i
= 0; i
< pos
; i
++) {
1188 nd_snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1189 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1193 fn_print(ndo
, (u_char
*)user
, NULL
);
1201 for (i
= 0; i
< neg
; i
++) {
1202 nd_snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1203 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1207 fn_print(ndo
, (u_char
*)user
, NULL
);
1223 * Handle calls to the AFS callback service
1227 cb_print(netdissect_options
*ndo
,
1228 const u_char
*bp
, u_int length
)
1233 if (length
<= sizeof(struct rx_header
))
1237 * Print out the afs call we're invoking. The table used here was
1238 * gleaned from fsint/afscbint.xg
1241 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
1242 cb_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
1244 ND_PRINT(" cb call %s", tok2str(cb_req
, "op#%u", cb_op
));
1246 bp
+= sizeof(struct rx_header
) + 4;
1249 * Print out the afs call we're invoking. The table used here was
1250 * gleaned from fsint/afscbint.xg
1254 case 204: /* Callback */
1258 j
= EXTRACT_BE_U_4(bp
);
1259 bp
+= sizeof(uint32_t);
1261 for (i
= 0; i
< j
; i
++) {
1268 ND_PRINT(" <none!>");
1271 j
= EXTRACT_BE_U_4(bp
);
1272 bp
+= sizeof(uint32_t);
1277 for (i
= 0; i
< j
; i
++) {
1280 ND_PRINT(" expires");
1283 t
= EXTRACT_BE_U_4(bp
);
1284 bp
+= sizeof(uint32_t);
1285 tok2str(cb_types
, "type %u", t
);
1289 ND_PRINT(" afsuuid");
1304 * Handle replies to the AFS Callback Service
1308 cb_reply_print(netdissect_options
*ndo
,
1309 const u_char
*bp
, u_int length
, uint32_t opcode
)
1311 const struct rx_header
*rxh
;
1314 if (length
<= sizeof(struct rx_header
))
1317 rxh
= (const struct rx_header
*) bp
;
1320 * Print out the afs call we're invoking. The table used here was
1321 * gleaned from fsint/afscbint.xg
1324 ND_PRINT(" cb reply %s", tok2str(cb_req
, "op#%u", opcode
));
1326 type
= EXTRACT_U_1(rxh
->type
);
1327 bp
+= sizeof(struct rx_header
);
1330 * If it was a data packet, interpret the response.
1333 if (type
== RX_PACKET_TYPE_DATA
)
1335 case 213: /* InitCallBackState3 */
1343 * Otherwise, just print out the return code
1345 ND_PRINT(" errcode");
1356 * Handle calls to the AFS protection database server
1360 prot_print(netdissect_options
*ndo
,
1361 const u_char
*bp
, u_int length
)
1366 if (length
<= sizeof(struct rx_header
))
1370 * Print out the afs call we're invoking. The table used here was
1371 * gleaned from ptserver/ptint.xg
1374 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
1375 pt_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
1379 if (is_ubik(pt_op
)) {
1380 ubik_print(ndo
, bp
);
1384 ND_PRINT(" call %s", tok2str(pt_req
, "op#%u", pt_op
));
1387 * Decode some of the arguments to the PT calls
1390 bp
+= sizeof(struct rx_header
) + 4;
1393 case 500: /* I New User */
1400 case 501: /* Where is it */
1401 case 506: /* Delete */
1402 case 508: /* Get CPS */
1403 case 512: /* List entry */
1404 case 514: /* List elements */
1405 case 517: /* List owned */
1406 case 518: /* Get CPS2 */
1407 case 519: /* Get host CPS */
1408 case 530: /* List super groups */
1412 case 502: /* Dump entry */
1416 case 503: /* Add to group */
1417 case 507: /* Remove from group */
1418 case 515: /* Is a member of? */
1424 case 504: /* Name to ID */
1428 j
= EXTRACT_BE_U_4(bp
);
1429 bp
+= sizeof(uint32_t);
1432 * Who designed this chicken-shit protocol?
1434 * Each character is stored as a 32-bit
1438 for (i
= 0; i
< j
; i
++) {
1442 ND_PRINT(" <none!>");
1445 case 505: /* Id to name */
1450 i
= EXTRACT_BE_U_4(bp
);
1451 bp
+= sizeof(uint32_t);
1452 for (j
= 0; j
< i
; j
++)
1455 ND_PRINT(" <none!>");
1458 case 509: /* New entry */
1465 case 511: /* Set max */
1471 case 513: /* Change entry */
1480 case 520: /* Update entry */
1497 * Handle replies to the AFS protection service
1501 prot_reply_print(netdissect_options
*ndo
,
1502 const u_char
*bp
, u_int length
, uint32_t opcode
)
1504 const struct rx_header
*rxh
;
1508 if (length
< sizeof(struct rx_header
))
1511 rxh
= (const struct rx_header
*) bp
;
1514 * Print out the afs call we're invoking. The table used here was
1515 * gleaned from ptserver/ptint.xg. Check to see if it's a
1516 * Ubik call, however.
1521 if (is_ubik(opcode
)) {
1522 ubik_reply_print(ndo
, bp
, length
, opcode
);
1526 ND_PRINT(" reply %s", tok2str(pt_req
, "op#%u", opcode
));
1528 type
= EXTRACT_U_1(rxh
->type
);
1529 bp
+= sizeof(struct rx_header
);
1532 * If it was a data packet, interpret the response
1535 if (type
== RX_PACKET_TYPE_DATA
)
1537 case 504: /* Name to ID */
1542 i
= EXTRACT_BE_U_4(bp
);
1543 bp
+= sizeof(uint32_t);
1544 for (j
= 0; j
< i
; j
++)
1547 ND_PRINT(" <none!>");
1550 case 505: /* ID to name */
1554 j
= EXTRACT_BE_U_4(bp
);
1555 bp
+= sizeof(uint32_t);
1558 * Who designed this chicken-shit protocol?
1560 * Each character is stored as a 32-bit
1564 for (i
= 0; i
< j
; i
++) {
1568 ND_PRINT(" <none!>");
1571 case 508: /* Get CPS */
1572 case 514: /* List elements */
1573 case 517: /* List owned */
1574 case 518: /* Get CPS2 */
1575 case 519: /* Get host CPS */
1579 j
= EXTRACT_BE_U_4(bp
);
1580 bp
+= sizeof(uint32_t);
1581 for (i
= 0; i
< j
; i
++) {
1585 ND_PRINT(" <none!>");
1588 case 510: /* List max */
1589 ND_PRINT(" maxuid");
1591 ND_PRINT(" maxgid");
1599 * Otherwise, just print out the return code
1601 ND_PRINT(" errcode");
1612 * Handle calls to the AFS volume location database service
1616 vldb_print(netdissect_options
*ndo
,
1617 const u_char
*bp
, u_int length
)
1622 if (length
<= sizeof(struct rx_header
))
1626 * Print out the afs call we're invoking. The table used here was
1627 * gleaned from vlserver/vldbint.xg
1630 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
1631 vldb_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
1635 if (is_ubik(vldb_op
)) {
1636 ubik_print(ndo
, bp
);
1639 ND_PRINT(" call %s", tok2str(vldb_req
, "op#%u", vldb_op
));
1642 * Decode some of the arguments to the VLDB calls
1645 bp
+= sizeof(struct rx_header
) + 4;
1648 case 501: /* Create new volume */
1649 case 517: /* Create entry N */
1652 case 502: /* Delete entry */
1653 case 503: /* Get entry by ID */
1654 case 507: /* Update entry */
1655 case 508: /* Set lock */
1656 case 509: /* Release lock */
1657 case 518: /* Get entry by ID N */
1661 i
= EXTRACT_BE_U_4(bp
);
1662 bp
+= sizeof(uint32_t);
1664 ND_PRINT(" type %s", voltype
[i
]);
1666 case 504: /* Get entry by name */
1667 case 519: /* Get entry by name N */
1668 case 524: /* Update entry by name */
1669 case 527: /* Get entry by name U */
1672 case 505: /* Get new vol id */
1676 case 506: /* Replace entry */
1677 case 520: /* Replace entry N */
1681 i
= EXTRACT_BE_U_4(bp
);
1682 bp
+= sizeof(uint32_t);
1684 ND_PRINT(" type %s", voltype
[i
]);
1687 case 510: /* List entry */
1688 case 521: /* List entry N */
1699 ND_PRINT(" [|vldb]");
1703 * Handle replies to the AFS volume location database service
1707 vldb_reply_print(netdissect_options
*ndo
,
1708 const u_char
*bp
, u_int length
, uint32_t opcode
)
1710 const struct rx_header
*rxh
;
1714 if (length
< sizeof(struct rx_header
))
1717 rxh
= (const struct rx_header
*) bp
;
1720 * Print out the afs call we're invoking. The table used here was
1721 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1722 * Ubik call, however.
1727 if (is_ubik(opcode
)) {
1728 ubik_reply_print(ndo
, bp
, length
, opcode
);
1732 ND_PRINT(" reply %s", tok2str(vldb_req
, "op#%u", opcode
));
1734 type
= EXTRACT_U_1(rxh
->type
);
1735 bp
+= sizeof(struct rx_header
);
1738 * If it was a data packet, interpret the response
1741 if (type
== RX_PACKET_TYPE_DATA
)
1743 case 510: /* List entry */
1746 ND_PRINT(" nextindex");
1748 case 503: /* Get entry by id */
1749 case 504: /* Get entry by name */
1750 { uint32_t nservers
, j
;
1753 bp
+= sizeof(uint32_t);
1754 ND_PRINT(" numservers");
1756 nservers
= EXTRACT_BE_U_4(bp
);
1757 bp
+= sizeof(uint32_t);
1758 ND_PRINT(" %u", nservers
);
1759 ND_PRINT(" servers");
1760 for (i
= 0; i
< 8; i
++) {
1764 intoa(EXTRACT_IPV4_TO_NETWORK_ORDER(bp
)));
1765 bp
+= sizeof(nd_ipv4
);
1767 ND_PRINT(" partitions");
1768 for (i
= 0; i
< 8; i
++) {
1770 j
= EXTRACT_BE_U_4(bp
);
1771 if (i
< nservers
&& j
<= 26)
1772 ND_PRINT(" %c", 'a' + j
);
1773 else if (i
< nservers
)
1775 bp
+= sizeof(uint32_t);
1777 ND_TCHECK_LEN(bp
, 8 * sizeof(uint32_t));
1778 bp
+= 8 * sizeof(uint32_t);
1783 ND_PRINT(" backup");
1787 case 505: /* Get new volume ID */
1788 ND_PRINT(" newvol");
1791 case 521: /* List entry */
1792 case 529: /* List entry U */
1795 ND_PRINT(" nextindex");
1797 case 518: /* Get entry by ID N */
1798 case 519: /* Get entry by name N */
1799 { uint32_t nservers
, j
;
1801 ND_PRINT(" numservers");
1803 nservers
= EXTRACT_BE_U_4(bp
);
1804 bp
+= sizeof(uint32_t);
1805 ND_PRINT(" %u", nservers
);
1806 ND_PRINT(" servers");
1807 for (i
= 0; i
< 13; i
++) {
1811 intoa(EXTRACT_IPV4_TO_NETWORK_ORDER(bp
)));
1812 bp
+= sizeof(nd_ipv4
);
1814 ND_PRINT(" partitions");
1815 for (i
= 0; i
< 13; i
++) {
1817 j
= EXTRACT_BE_U_4(bp
);
1818 if (i
< nservers
&& j
<= 26)
1819 ND_PRINT(" %c", 'a' + j
);
1820 else if (i
< nservers
)
1822 bp
+= sizeof(uint32_t);
1824 ND_TCHECK_LEN(bp
, 13 * sizeof(uint32_t));
1825 bp
+= 13 * sizeof(uint32_t);
1830 ND_PRINT(" backup");
1834 case 526: /* Get entry by ID U */
1835 case 527: /* Get entry by name U */
1836 { uint32_t nservers
, j
;
1838 ND_PRINT(" numservers");
1840 nservers
= EXTRACT_BE_U_4(bp
);
1841 bp
+= sizeof(uint32_t);
1842 ND_PRINT(" %u", nservers
);
1843 ND_PRINT(" servers");
1844 for (i
= 0; i
< 13; i
++) {
1846 ND_PRINT(" afsuuid");
1849 ND_TCHECK_LEN(bp
, 44);
1853 ND_TCHECK_LEN(bp
, 4 * 13);
1855 ND_PRINT(" partitions");
1856 for (i
= 0; i
< 13; i
++) {
1858 j
= EXTRACT_BE_U_4(bp
);
1859 if (i
< nservers
&& j
<= 26)
1860 ND_PRINT(" %c", 'a' + j
);
1861 else if (i
< nservers
)
1863 bp
+= sizeof(uint32_t);
1865 ND_TCHECK_LEN(bp
, 13 * sizeof(uint32_t));
1866 bp
+= 13 * sizeof(uint32_t);
1871 ND_PRINT(" backup");
1880 * Otherwise, just print out the return code
1882 ND_PRINT(" errcode");
1889 ND_PRINT(" [|vldb]");
1893 * Handle calls to the AFS Kerberos Authentication service
1897 kauth_print(netdissect_options
*ndo
,
1898 const u_char
*bp
, u_int length
)
1902 if (length
<= sizeof(struct rx_header
))
1906 * Print out the afs call we're invoking. The table used here was
1907 * gleaned from kauth/kauth.rg
1910 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
1911 kauth_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
1915 if (is_ubik(kauth_op
)) {
1916 ubik_print(ndo
, bp
);
1921 ND_PRINT(" call %s", tok2str(kauth_req
, "op#%u", kauth_op
));
1924 * Decode some of the arguments to the KA calls
1927 bp
+= sizeof(struct rx_header
) + 4;
1930 case 1: /* Authenticate old */
1931 case 21: /* Authenticate */
1932 case 22: /* Authenticate-V2 */
1933 case 2: /* Change PW */
1934 case 5: /* Set fields */
1935 case 6: /* Create user */
1936 case 7: /* Delete user */
1937 case 8: /* Get entry */
1938 case 14: /* Unlock */
1939 case 15: /* Lock status */
1940 ND_PRINT(" principal");
1944 case 3: /* GetTicket-old */
1945 case 23: /* GetTicket */
1950 ND_PRINT(" domain");
1953 i
= EXTRACT_BE_U_4(bp
);
1954 bp
+= sizeof(uint32_t);
1955 ND_TCHECK_LEN(bp
, i
);
1957 ND_PRINT(" principal");
1962 case 4: /* Set Password */
1963 ND_PRINT(" principal");
1969 case 12: /* Get password */
1980 ND_PRINT(" [|kauth]");
1984 * Handle replies to the AFS Kerberos Authentication Service
1988 kauth_reply_print(netdissect_options
*ndo
,
1989 const u_char
*bp
, u_int length
, uint32_t opcode
)
1991 const struct rx_header
*rxh
;
1994 if (length
<= sizeof(struct rx_header
))
1997 rxh
= (const struct rx_header
*) bp
;
2000 * Print out the afs call we're invoking. The table used here was
2001 * gleaned from kauth/kauth.rg
2006 if (is_ubik(opcode
)) {
2007 ubik_reply_print(ndo
, bp
, length
, opcode
);
2011 ND_PRINT(" reply %s", tok2str(kauth_req
, "op#%u", opcode
));
2013 type
= EXTRACT_U_1(rxh
->type
);
2014 bp
+= sizeof(struct rx_header
);
2017 * If it was a data packet, interpret the response.
2020 if (type
== RX_PACKET_TYPE_DATA
)
2021 /* Well, no, not really. Leave this for later */
2025 * Otherwise, just print out the return code
2027 ND_PRINT(" errcode");
2034 ND_PRINT(" [|kauth]");
2038 * Handle calls to the AFS Volume location service
2042 vol_print(netdissect_options
*ndo
,
2043 const u_char
*bp
, u_int length
)
2047 if (length
<= sizeof(struct rx_header
))
2051 * Print out the afs call we're invoking. The table used here was
2052 * gleaned from volser/volint.xg
2055 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
2056 vol_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
2058 ND_PRINT(" vol call %s", tok2str(vol_req
, "op#%u", vol_op
));
2060 bp
+= sizeof(struct rx_header
) + 4;
2063 case 100: /* Create volume */
2064 ND_PRINT(" partition");
2070 ND_PRINT(" parent");
2073 case 101: /* Delete volume */
2074 case 107: /* Get flags */
2078 case 102: /* Restore */
2079 ND_PRINT(" totrans");
2084 case 103: /* Forward */
2085 ND_PRINT(" fromtrans");
2087 ND_PRINT(" fromdate");
2090 ND_PRINT(" desttrans");
2093 case 104: /* End trans */
2097 case 105: /* Clone */
2100 ND_PRINT(" purgevol");
2102 ND_PRINT(" newtype");
2104 ND_PRINT(" newname");
2107 case 106: /* Set flags */
2113 case 108: /* Trans create */
2116 ND_PRINT(" partition");
2121 case 109: /* Dump */
2122 case 655537: /* Get size */
2123 ND_PRINT(" fromtrans");
2125 ND_PRINT(" fromdate");
2128 case 110: /* Get n-th volume */
2132 case 111: /* Set forwarding */
2135 ND_PRINT(" newsite");
2138 case 112: /* Get name */
2139 case 113: /* Get status */
2142 case 114: /* Signal restore */
2149 ND_PRINT(" cloneid");
2152 case 116: /* List volumes */
2153 ND_PRINT(" partition");
2158 case 117: /* Set id types */
2169 ND_PRINT(" backup");
2172 case 119: /* Partition info */
2176 case 120: /* Reclone */
2180 case 121: /* List one volume */
2181 case 122: /* Nuke volume */
2182 case 124: /* Extended List volumes */
2183 case 125: /* Extended List one volume */
2184 case 65536: /* Convert RO to RW volume */
2185 ND_PRINT(" partid");
2190 case 123: /* Set date */
2196 case 126: /* Set info */
2200 case 128: /* Forward multiple */
2201 ND_PRINT(" fromtrans");
2203 ND_PRINT(" fromdate");
2208 j
= EXTRACT_BE_U_4(bp
);
2209 bp
+= sizeof(uint32_t);
2210 for (i
= 0; i
< j
; i
++) {
2216 ND_PRINT(" <none!>");
2219 case 65538: /* Dump version 2 */
2220 ND_PRINT(" fromtrans");
2222 ND_PRINT(" fromdate");
2233 ND_PRINT(" [|vol]");
2237 * Handle replies to the AFS Volume Service
2241 vol_reply_print(netdissect_options
*ndo
,
2242 const u_char
*bp
, u_int length
, uint32_t opcode
)
2244 const struct rx_header
*rxh
;
2247 if (length
<= sizeof(struct rx_header
))
2250 rxh
= (const struct rx_header
*) bp
;
2253 * Print out the afs call we're invoking. The table used here was
2254 * gleaned from volser/volint.xg
2257 ND_PRINT(" vol reply %s", tok2str(vol_req
, "op#%u", opcode
));
2259 type
= EXTRACT_U_1(rxh
->type
);
2260 bp
+= sizeof(struct rx_header
);
2263 * If it was a data packet, interpret the response.
2266 if (type
== RX_PACKET_TYPE_DATA
) {
2268 case 100: /* Create volume */
2274 case 104: /* End transaction */
2277 case 105: /* Clone */
2278 ND_PRINT(" newvol");
2281 case 107: /* Get flags */
2284 case 108: /* Transaction create */
2288 case 110: /* Get n-th volume */
2289 ND_PRINT(" volume");
2291 ND_PRINT(" partition");
2294 case 112: /* Get name */
2297 case 113: /* Get status */
2300 ND_PRINT(" nextuniq");
2304 ND_PRINT(" parentid");
2308 ND_PRINT(" backup");
2310 ND_PRINT(" restore");
2312 ND_PRINT(" maxquota");
2314 ND_PRINT(" minquota");
2318 ND_PRINT(" create");
2320 ND_PRINT(" access");
2322 ND_PRINT(" update");
2324 ND_PRINT(" expire");
2326 ND_PRINT(" backup");
2331 case 115: /* Old list partitions */
2333 case 116: /* List volumes */
2334 case 121: /* List one volume */
2338 j
= EXTRACT_BE_U_4(bp
);
2339 bp
+= sizeof(uint32_t);
2340 for (i
= 0; i
< j
; i
++) {
2346 bp
+= sizeof(uint32_t) * 21;
2351 ND_PRINT(" <none!>");
2361 * Otherwise, just print out the return code
2363 ND_PRINT(" errcode");
2370 ND_PRINT(" [|vol]");
2374 * Handle calls to the AFS BOS service
2378 bos_print(netdissect_options
*ndo
,
2379 const u_char
*bp
, u_int length
)
2383 if (length
<= sizeof(struct rx_header
))
2387 * Print out the afs call we're invoking. The table used here was
2388 * gleaned from bozo/bosint.xg
2391 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
2392 bos_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
2394 ND_PRINT(" bos call %s", tok2str(bos_req
, "op#%u", bos_op
));
2397 * Decode some of the arguments to the BOS calls
2400 bp
+= sizeof(struct rx_header
) + 4;
2403 case 80: /* Create B node */
2406 ND_PRINT(" instance");
2409 case 81: /* Delete B node */
2410 case 83: /* Get status */
2411 case 85: /* Get instance info */
2412 case 87: /* Add super user */
2413 case 88: /* Delete super user */
2414 case 93: /* Set cell name */
2415 case 96: /* Add cell host */
2416 case 97: /* Delete cell host */
2417 case 104: /* Restart */
2418 case 106: /* Uninstall */
2419 case 108: /* Exec */
2420 case 112: /* Getlog */
2421 case 114: /* Get instance strings */
2424 case 82: /* Set status */
2425 case 98: /* Set T status */
2427 ND_PRINT(" status");
2430 case 86: /* Get instance parm */
2435 case 84: /* Enumerate instance */
2436 case 89: /* List super users */
2437 case 90: /* List keys */
2438 case 91: /* Add key */
2439 case 92: /* Delete key */
2440 case 95: /* Get cell host */
2443 case 105: /* Install */
2459 ND_PRINT(" [|bos]");
2463 * Handle replies to the AFS BOS Service
2467 bos_reply_print(netdissect_options
*ndo
,
2468 const u_char
*bp
, u_int length
, uint32_t opcode
)
2470 const struct rx_header
*rxh
;
2473 if (length
<= sizeof(struct rx_header
))
2476 rxh
= (const struct rx_header
*) bp
;
2479 * Print out the afs call we're invoking. The table used here was
2480 * gleaned from volser/volint.xg
2483 ND_PRINT(" bos reply %s", tok2str(bos_req
, "op#%u", opcode
));
2485 type
= EXTRACT_U_1(rxh
->type
);
2486 bp
+= sizeof(struct rx_header
);
2489 * If it was a data packet, interpret the response.
2492 if (type
== RX_PACKET_TYPE_DATA
)
2493 /* Well, no, not really. Leave this for later */
2497 * Otherwise, just print out the return code
2499 ND_PRINT(" errcode");
2506 ND_PRINT(" [|bos]");
2510 * Check to see if this is a Ubik opcode.
2514 is_ubik(uint32_t opcode
)
2516 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2517 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2524 * Handle Ubik opcodes to any one of the replicated database services
2528 ubik_print(netdissect_options
*ndo
,
2535 * Print out the afs call we're invoking. The table used here was
2536 * gleaned from ubik/ubik_int.xg
2539 /* Every function that calls this function first makes a bounds check
2540 * for (sizeof(rx_header) + 4) bytes, so long as it remains this way
2541 * the line below will not over-read.
2543 ubik_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
2545 ND_PRINT(" ubik call %s", tok2str(ubik_req
, "op#%u", ubik_op
));
2548 * Decode some of the arguments to the Ubik calls
2551 bp
+= sizeof(struct rx_header
) + 4;
2554 case 10000: /* Beacon */
2556 temp
= EXTRACT_BE_U_4(bp
);
2557 bp
+= sizeof(uint32_t);
2558 ND_PRINT(" syncsite %s", temp
? "yes" : "no");
2559 ND_PRINT(" votestart");
2561 ND_PRINT(" dbversion");
2566 case 10003: /* Get sync site */
2570 case 20000: /* Begin */
2571 case 20001: /* Commit */
2572 case 20007: /* Abort */
2573 case 20008: /* Release locks */
2574 case 20010: /* Writev */
2578 case 20002: /* Lock */
2585 ND_PRINT(" length");
2588 temp
= EXTRACT_BE_U_4(bp
);
2589 bp
+= sizeof(uint32_t);
2590 tok2str(ubik_lock_types
, "type %u", temp
);
2592 case 20003: /* Write */
2600 case 20005: /* Get file */
2604 case 20006: /* Send file */
2607 ND_PRINT(" length");
2609 ND_PRINT(" dbversion");
2612 case 20009: /* Truncate */
2617 ND_PRINT(" length");
2620 case 20012: /* Set version */
2623 ND_PRINT(" oldversion");
2625 ND_PRINT(" newversion");
2635 ND_PRINT(" [|ubik]");
2639 * Handle Ubik replies to any one of the replicated database services
2643 ubik_reply_print(netdissect_options
*ndo
,
2644 const u_char
*bp
, u_int length
, uint32_t opcode
)
2646 const struct rx_header
*rxh
;
2649 if (length
< sizeof(struct rx_header
))
2652 rxh
= (const struct rx_header
*) bp
;
2655 * Print out the ubik call we're invoking. This table was gleaned
2656 * from ubik/ubik_int.xg
2659 ND_PRINT(" ubik reply %s", tok2str(ubik_req
, "op#%u", opcode
));
2661 type
= EXTRACT_U_1(rxh
->type
);
2662 bp
+= sizeof(struct rx_header
);
2665 * If it was a data packet, print out the arguments to the Ubik calls
2668 if (type
== RX_PACKET_TYPE_DATA
)
2670 case 10000: /* Beacon */
2671 ND_PRINT(" vote no");
2673 case 20004: /* Get version */
2674 ND_PRINT(" dbversion");
2682 * Otherwise, print out "yes" it it was a beacon packet (because
2683 * that's how yes votes are returned, go figure), otherwise
2684 * just print out the error code.
2689 case 10000: /* Beacon */
2690 ND_PRINT(" vote yes until");
2694 ND_PRINT(" errcode");
2701 ND_PRINT(" [|ubik]");
2705 * Handle RX ACK packets.
2709 rx_ack_print(netdissect_options
*ndo
,
2710 const u_char
*bp
, u_int length
)
2712 const struct rx_ackPacket
*rxa
;
2715 uint32_t firstPacket
;
2717 if (length
< sizeof(struct rx_header
))
2720 bp
+= sizeof(struct rx_header
);
2722 ND_TCHECK_LEN(bp
, sizeof(struct rx_ackPacket
));
2724 rxa
= (const struct rx_ackPacket
*) bp
;
2725 bp
+= sizeof(struct rx_ackPacket
);
2728 * Print out a few useful things from the ack packet structure
2731 if (ndo
->ndo_vflag
> 2)
2732 ND_PRINT(" bufspace %u maxskew %u",
2733 EXTRACT_BE_U_2(rxa
->bufferSpace
),
2734 EXTRACT_BE_U_2(rxa
->maxSkew
));
2736 firstPacket
= EXTRACT_BE_U_4(rxa
->firstPacket
);
2737 ND_PRINT(" first %u serial %u reason %s",
2738 firstPacket
, EXTRACT_BE_U_4(rxa
->serial
),
2739 tok2str(rx_ack_reasons
, "#%u", EXTRACT_U_1(rxa
->reason
)));
2742 * Okay, now we print out the ack array. The way _this_ works
2743 * is that we start at "first", and step through the ack array.
2744 * If we have a contiguous range of acks/nacks, try to
2745 * collapse them into a range.
2747 * If you're really clever, you might have noticed that this
2748 * doesn't seem quite correct. Specifically, due to structure
2749 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2750 * yield the start of the ack array (because RX_MAXACKS is 255
2751 * and the structure will likely get padded to a 2 or 4 byte
2752 * boundary). However, this is the way it's implemented inside
2753 * of AFS - the start of the extra fields are at
2754 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2755 * the exact start of the ack array. Sigh. That's why we aren't
2756 * using bp, but instead use rxa->acks[]. But nAcks gets added
2757 * to bp after this, so bp ends up at the right spot. Go figure.
2760 nAcks
= EXTRACT_U_1(rxa
->nAcks
);
2763 ND_TCHECK_LEN(bp
, nAcks
);
2766 * Sigh, this is gross, but it seems to work to collapse
2770 for (i
= 0, start
= last
= -2; i
< nAcks
; i
++)
2771 if (EXTRACT_U_1(bp
+ i
) == RX_ACK_TYPE_ACK
) {
2774 * I figured this deserved _some_ explanation.
2775 * First, print "acked" and the packet seq
2776 * number if this is the first time we've
2777 * seen an acked packet.
2781 ND_PRINT(" acked %u", firstPacket
+ i
);
2786 * Otherwise, if there is a skip in
2787 * the range (such as an nacked packet in
2788 * the middle of some acked packets),
2789 * then print the current packet number
2790 * seperated from the last number by
2794 else if (last
!= i
- 1) {
2795 ND_PRINT(",%u", firstPacket
+ i
);
2800 * We always set last to the value of
2801 * the last ack we saw. Conversely, start
2802 * is set to the value of the first ack
2803 * we saw in a range.
2809 * Okay, this bit a code gets executed when
2810 * we hit a nack ... in _this_ case we
2811 * want to print out the range of packets
2812 * that were acked, so we need to print
2813 * the _previous_ packet number seperated
2814 * from the first by a dash (-). Since we
2815 * already printed the first packet above,
2816 * just print the final packet. Don't
2817 * do this if there will be a single-length
2820 } else if (last
== i
- 1 && start
!= last
)
2821 ND_PRINT("-%u", firstPacket
+ i
- 1);
2824 * So, what's going on here? We ran off the end of the
2825 * ack list, and if we got a range we need to finish it up.
2826 * So we need to determine if the last packet in the list
2827 * was an ack (if so, then last will be set to it) and
2828 * we need to see if the last range didn't start with the
2829 * last packet (because if it _did_, then that would mean
2830 * that the packet number has already been printed and
2831 * we don't need to print it again).
2834 if (last
== i
- 1 && start
!= last
)
2835 ND_PRINT("-%u", firstPacket
+ i
- 1);
2838 * Same as above, just without comments
2841 for (i
= 0, start
= last
= -2; i
< nAcks
; i
++)
2842 if (EXTRACT_U_1(bp
+ i
) == RX_ACK_TYPE_NACK
) {
2844 ND_PRINT(" nacked %u", firstPacket
+ i
);
2846 } else if (last
!= i
- 1) {
2847 ND_PRINT(",%u", firstPacket
+ i
);
2851 } else if (last
== i
- 1 && start
!= last
)
2852 ND_PRINT("-%u", firstPacket
+ i
- 1);
2854 if (last
== i
- 1 && start
!= last
)
2855 ND_PRINT("-%u", firstPacket
+ i
- 1);
2864 * These are optional fields; depending on your version of AFS,
2865 * you may or may not see them
2868 #define TRUNCRET(n) if (ndo->ndo_snapend - bp + 1 <= n) return;
2870 if (ndo
->ndo_vflag
> 1) {
2876 ND_PRINT(" maxmtu");
2884 ND_PRINT(" maxpackets");
2891 ND_PRINT(" [|ack]");