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>
42 #include "netdissect-stdinc.h"
44 #include "netdissect.h"
45 #include "addrtoname.h"
50 #define FS_RX_PORT 7000
51 #define CB_RX_PORT 7001
52 #define PROT_RX_PORT 7002
53 #define VLDB_RX_PORT 7003
54 #define KAUTH_RX_PORT 7004
55 #define VOL_RX_PORT 7005
56 #define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
57 #define BOS_RX_PORT 7007
59 #define AFSOPAQUEMAX 1024
60 #define AFSNAMEMAX 256 /* Must be >= PRNAMEMAX + 1, VLNAMEMAX + 1, and 32 + 1 */
64 #define BOSNAMEMAX 256
65 #define USERNAMEMAX 1024 /* AFSOPAQUEMAX was used for this; does it need to be this big? */
67 #define PRSFS_READ 1 /* Read files */
68 #define PRSFS_WRITE 2 /* Write files */
69 #define PRSFS_INSERT 4 /* Insert files into a directory */
70 #define PRSFS_LOOKUP 8 /* Lookup files into a directory */
71 #define PRSFS_DELETE 16 /* Delete files */
72 #define PRSFS_LOCK 32 /* Lock files */
73 #define PRSFS_ADMINISTER 64 /* Change ACL's */
78 nd_uint32_t callNumber
;
82 #define RX_PACKET_TYPE_DATA 1
83 #define RX_PACKET_TYPE_ACK 2
84 #define RX_PACKET_TYPE_BUSY 3
85 #define RX_PACKET_TYPE_ABORT 4
86 #define RX_PACKET_TYPE_ACKALL 5
87 #define RX_PACKET_TYPE_CHALLENGE 6
88 #define RX_PACKET_TYPE_RESPONSE 7
89 #define RX_PACKET_TYPE_DEBUG 8
90 #define RX_PACKET_TYPE_PARAMS 9
91 #define RX_PACKET_TYPE_VERSION 13
93 #define RX_CLIENT_INITIATED 1
94 #define RX_REQUEST_ACK 2
95 #define RX_LAST_PACKET 4
96 #define RX_MORE_PACKETS 8
97 #define RX_FREE_PACKET 16
98 #define RX_SLOW_START_OK 32
99 #define RX_JUMBO_PACKET 32
100 nd_uint8_t userStatus
;
101 nd_uint8_t securityIndex
;
102 nd_uint16_t spare
; /* How clever: even though the AFS */
103 nd_uint16_t serviceId
; /* header files indicate that the */
104 }; /* serviceId is first, it's really */
105 /* encoded _after_ the spare field */
106 /* I wasted a day figuring that out! */
108 #define NUM_RX_FLAGS 7
110 #define RX_MAXACKS 255
112 struct rx_ackPacket
{
113 nd_uint16_t bufferSpace
; /* Number of packet buffers available */
114 nd_uint16_t maxSkew
; /* Max diff between ack'd packet and */
115 /* highest packet received */
116 nd_uint32_t firstPacket
; /* The first packet in ack list */
117 nd_uint32_t previousPacket
; /* Previous packet recv'd (obsolete) */
118 nd_uint32_t serial
; /* # of packet that prompted the ack */
119 nd_uint8_t reason
; /* Reason for acknowledgement */
120 nd_uint8_t nAcks
; /* Number of acknowledgements */
121 /* Followed by nAcks acknowledgments */
123 uint8_t acks
[RX_MAXACKS
]; /* Up to RX_MAXACKS acknowledgements */
128 * Values for the acks array
131 #define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
132 #define RX_ACK_TYPE_ACK 1 /* I have this packet */
134 static const struct tok rx_types
[] = {
135 { RX_PACKET_TYPE_DATA
, "data" },
136 { RX_PACKET_TYPE_ACK
, "ack" },
137 { RX_PACKET_TYPE_BUSY
, "busy" },
138 { RX_PACKET_TYPE_ABORT
, "abort" },
139 { RX_PACKET_TYPE_ACKALL
, "ackall" },
140 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
141 { RX_PACKET_TYPE_RESPONSE
, "response" },
142 { RX_PACKET_TYPE_DEBUG
, "debug" },
143 { RX_PACKET_TYPE_PARAMS
, "params" },
144 { RX_PACKET_TYPE_VERSION
, "version" },
148 static const struct double_tok
{
149 uint32_t flag
; /* Rx flag */
150 uint32_t packetType
; /* Packet type */
151 const char *s
; /* Flag string */
153 { RX_CLIENT_INITIATED
, 0, "client-init" },
154 { RX_REQUEST_ACK
, 0, "req-ack" },
155 { RX_LAST_PACKET
, 0, "last-pckt" },
156 { RX_MORE_PACKETS
, 0, "more-pckts" },
157 { RX_FREE_PACKET
, 0, "free-pckt" },
158 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
159 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
162 static const struct tok fs_req
[] = {
163 { 130, "fetch-data" },
164 { 131, "fetch-acl" },
165 { 132, "fetch-status" },
166 { 133, "store-data" },
167 { 134, "store-acl" },
168 { 135, "store-status" },
169 { 136, "remove-file" },
170 { 137, "create-file" },
176 { 143, "oldsetlock" },
177 { 144, "oldextlock" },
178 { 145, "oldrellock" },
179 { 146, "get-stats" },
181 { 148, "get-vlinfo" },
182 { 149, "get-vlstats" },
183 { 150, "set-vlstats" },
184 { 151, "get-rootvl" },
185 { 152, "check-token" },
187 { 154, "nget-vlinfo" },
188 { 155, "bulk-stat" },
192 { 159, "xstat-ver" },
193 { 160, "get-xstat" },
194 { 161, "dfs-lookup" },
195 { 162, "dfs-flushcps" },
196 { 163, "dfs-symlink" },
197 { 220, "residency" },
198 { 65536, "inline-bulk-status" },
199 { 65537, "fetch-data-64" },
200 { 65538, "store-data-64" },
201 { 65539, "give-up-all-cbs" },
202 { 65540, "get-caps" },
203 { 65541, "cb-rx-conn-addr" },
207 static const struct tok cb_req
[] = {
216 { 212, "whoareyou" },
218 { 214, "probeuuid" },
219 { 215, "getsrvprefs" },
220 { 216, "getcellservdb" },
221 { 217, "getlocalcell" },
222 { 218, "getcacheconf" },
223 { 65536, "getce64" },
224 { 65537, "getcellbynum" },
225 { 65538, "tellmeaboutyourself" },
229 static const struct tok pt_req
[] = {
231 { 501, "where-is-it" },
232 { 502, "dump-entry" },
233 { 503, "add-to-group" },
234 { 504, "name-to-id" },
235 { 505, "id-to-name" },
237 { 507, "remove-from-group" },
239 { 509, "new-entry" },
242 { 512, "list-entry" },
243 { 513, "change-entry" },
244 { 514, "list-elements" },
245 { 515, "same-mbr-of" },
246 { 516, "set-fld-sentry" },
247 { 517, "list-owned" },
249 { 519, "get-host-cps" },
250 { 520, "update-entry" },
251 { 521, "list-entries" },
252 { 530, "list-super-groups" },
256 static const struct tok vldb_req
[] = {
257 { 501, "create-entry" },
258 { 502, "delete-entry" },
259 { 503, "get-entry-by-id" },
260 { 504, "get-entry-by-name" },
261 { 505, "get-new-volume-id" },
262 { 506, "replace-entry" },
263 { 507, "update-entry" },
265 { 509, "releaselock" },
266 { 510, "list-entry" },
267 { 511, "list-attrib" },
268 { 512, "linked-list" },
269 { 513, "get-stats" },
271 { 515, "get-addrs" },
272 { 516, "change-addr" },
273 { 517, "create-entry-n" },
274 { 518, "get-entry-by-id-n" },
275 { 519, "get-entry-by-name-n" },
276 { 520, "replace-entry-n" },
277 { 521, "list-entry-n" },
278 { 522, "list-attrib-n" },
279 { 523, "linked-list-n" },
280 { 524, "update-entry-by-name" },
281 { 525, "create-entry-u" },
282 { 526, "get-entry-by-id-u" },
283 { 527, "get-entry-by-name-u" },
284 { 528, "replace-entry-u" },
285 { 529, "list-entry-u" },
286 { 530, "list-attrib-u" },
287 { 531, "linked-list-u" },
289 { 533, "get-addrs-u" },
290 { 534, "list-attrib-n2" },
294 static const struct tok kauth_req
[] = {
296 { 21, "authenticate" },
297 { 22, "authenticate-v2" },
299 { 3, "get-ticket-old" },
300 { 23, "get-ticket" },
303 { 6, "create-user" },
304 { 7, "delete-user" },
310 { 13, "get-random-key" },
312 { 15, "lock-status" },
316 static const struct tok vol_req
[] = {
317 { 100, "create-volume" },
318 { 101, "delete-volume" },
321 { 104, "end-trans" },
323 { 106, "set-flags" },
324 { 107, "get-flags" },
325 { 108, "trans-create" },
327 { 110, "get-nth-volume" },
328 { 111, "set-forwarding" },
330 { 113, "get-status" },
331 { 114, "sig-restore" },
332 { 115, "list-partitions" },
333 { 116, "list-volumes" },
334 { 117, "set-id-types" },
336 { 119, "partition-info" },
338 { 121, "list-one-volume" },
341 { 124, "x-list-volumes" },
342 { 125, "x-list-one-volume" },
344 { 127, "x-list-partitions" },
345 { 128, "forward-multiple" },
346 { 65536, "convert-ro" },
347 { 65537, "get-size" },
348 { 65538, "dump-v2" },
352 static const struct tok bos_req
[] = {
353 { 80, "create-bnode" },
354 { 81, "delete-bnode" },
355 { 82, "set-status" },
356 { 83, "get-status" },
357 { 84, "enumerate-instance" },
358 { 85, "get-instance-info" },
359 { 86, "get-instance-parm" },
360 { 87, "add-superuser" },
361 { 88, "delete-superuser" },
362 { 89, "list-superusers" },
365 { 92, "delete-key" },
366 { 93, "set-cell-name" },
367 { 94, "get-cell-name" },
368 { 95, "get-cell-host" },
369 { 96, "add-cell-host" },
370 { 97, "delete-cell-host" },
371 { 98, "set-t-status" },
372 { 99, "shutdown-all" },
373 { 100, "restart-all" },
374 { 101, "startup-all" },
375 { 102, "set-noauth-flag" },
378 { 105, "start-bozo-install" },
379 { 106, "uninstall" },
380 { 107, "get-dates" },
383 { 110, "set-restart-time" },
384 { 111, "get-restart-time" },
385 { 112, "start-bozo-log" },
387 { 114, "get-instance-strings" },
388 { 115, "get-restricted" },
389 { 116, "set-restricted" },
393 static const struct tok ubik_req
[] = {
394 { 10000, "vote-beacon" },
395 { 10001, "vote-debug-old" },
396 { 10002, "vote-sdebug-old" },
397 { 10003, "vote-getsyncsite" },
398 { 10004, "vote-debug" },
399 { 10005, "vote-sdebug" },
400 { 10006, "vote-xdebug" },
401 { 10007, "vote-xsdebug" },
402 { 20000, "disk-begin" },
403 { 20001, "disk-commit" },
404 { 20002, "disk-lock" },
405 { 20003, "disk-write" },
406 { 20004, "disk-getversion" },
407 { 20005, "disk-getfile" },
408 { 20006, "disk-sendfile" },
409 { 20007, "disk-abort" },
410 { 20008, "disk-releaselocks" },
411 { 20009, "disk-truncate" },
412 { 20010, "disk-probe" },
413 { 20011, "disk-writev" },
414 { 20012, "disk-interfaceaddr" },
415 { 20013, "disk-setversion" },
419 #define VOTE_LOW 10000
420 #define VOTE_HIGH 10007
421 #define DISK_LOW 20000
422 #define DISK_HIGH 20013
424 static const struct tok cb_types
[] = {
431 static const struct tok ubik_lock_types
[] = {
438 static const char *voltype
[] = { "read-write", "read-only", "backup" };
440 static const struct tok afs_fs_errors
[] = {
441 { 101, "salvage volume" },
442 { 102, "no such vnode" },
443 { 103, "no such volume" },
444 { 104, "volume exist" },
445 { 105, "no service" },
446 { 106, "volume offline" },
447 { 107, "voline online" },
449 { 109, "diskquota exceeded" },
450 { 110, "volume busy" },
451 { 111, "volume moved" },
452 { 112, "AFS IO error" },
453 { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */
458 * Reasons for acknowledging a packet
461 static const struct tok rx_ack_reasons
[] = {
462 { 1, "ack requested" },
463 { 2, "duplicate packet" },
464 { 3, "out of sequence" },
465 { 4, "exceeds window" },
466 { 5, "no buffer space" },
468 { 7, "ping response" },
475 * Cache entries we keep around so we can figure out the RX opcode
476 * numbers for replies. This allows us to make sense of RX reply packets.
479 struct rx_cache_entry
{
480 uint32_t callnum
; /* Call number (net order) */
481 uint32_t client
; /* client IP address (net order) */
482 uint32_t server
; /* server IP address (net order) */
483 uint16_t dport
; /* server UDP port (host order) */
484 uint16_t serviceId
; /* Service identifier (net order) */
485 uint32_t opcode
; /* RX opcode (host order) */
488 #define RX_CACHE_SIZE 64
490 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
492 static uint32_t rx_cache_next
= 0;
493 static uint32_t rx_cache_hint
= 0;
494 static void rx_cache_insert(netdissect_options
*, const u_char
*, const struct ip
*, uint16_t);
495 static int rx_cache_find(netdissect_options
*, const struct rx_header
*,
496 const struct ip
*, uint16_t, uint32_t *);
498 static void fs_print(netdissect_options
*, const u_char
*, u_int
);
499 static void fs_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
500 static void acl_print(netdissect_options
*, u_char
*, const u_char
*);
501 static void cb_print(netdissect_options
*, const u_char
*, u_int
);
502 static void cb_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
503 static void prot_print(netdissect_options
*, const u_char
*, u_int
);
504 static void prot_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
505 static void vldb_print(netdissect_options
*, const u_char
*, u_int
);
506 static void vldb_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
507 static void kauth_print(netdissect_options
*, const u_char
*, u_int
);
508 static void kauth_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
509 static void vol_print(netdissect_options
*, const u_char
*, u_int
);
510 static void vol_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
511 static void bos_print(netdissect_options
*, const u_char
*, u_int
);
512 static void bos_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
513 static void ubik_print(netdissect_options
*, const u_char
*);
514 static void ubik_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
516 static void rx_ack_print(netdissect_options
*, const u_char
*, u_int
);
518 static int is_ubik(uint32_t);
521 * Handle the rx-level packet. See if we know what port it's going to so
522 * we can peek at the afs call inside
526 rx_print(netdissect_options
*ndo
,
527 const u_char
*bp
, u_int length
, uint16_t sport
, uint16_t dport
,
530 const struct rx_header
*rxh
;
535 ndo
->ndo_protocol
= "rx";
536 if (!ND_TTEST_LEN(bp
, sizeof(struct rx_header
))) {
537 ND_PRINT(" [|rx] (%u)", length
);
541 rxh
= (const struct rx_header
*) bp
;
543 type
= GET_U_1(rxh
->type
);
544 ND_PRINT(" rx %s", tok2str(rx_types
, "type %u", type
));
546 flags
= GET_U_1(rxh
->flags
);
547 if (ndo
->ndo_vflag
) {
550 if (ndo
->ndo_vflag
> 1)
551 ND_PRINT(" cid %08x call# %u",
552 GET_BE_U_4(rxh
->cid
),
553 GET_BE_U_4(rxh
->callNumber
));
555 ND_PRINT(" seq %u ser %u",
556 GET_BE_U_4(rxh
->seq
),
557 GET_BE_U_4(rxh
->serial
));
559 if (ndo
->ndo_vflag
> 2)
560 ND_PRINT(" secindex %u serviceid %hu",
561 GET_U_1(rxh
->securityIndex
),
562 GET_BE_U_2(rxh
->serviceId
));
564 if (ndo
->ndo_vflag
> 1)
565 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
566 if (flags
& rx_flags
[i
].flag
&&
567 (!rx_flags
[i
].packetType
||
568 type
== rx_flags
[i
].packetType
)) {
575 ND_PRINT("<%s>", rx_flags
[i
].s
);
581 * Try to handle AFS calls that we know about. Check the destination
582 * port and make sure it's a data packet. Also, make sure the
583 * seq number is 1 (because otherwise it's a continuation packet,
584 * and we can't interpret that). Also, seems that reply packets
585 * do not have the client-init flag set, so we check for that
589 if (type
== RX_PACKET_TYPE_DATA
&&
590 GET_BE_U_4(rxh
->seq
) == 1 &&
591 flags
& RX_CLIENT_INITIATED
) {
594 * Insert this call into the call cache table, so we
595 * have a chance to print out replies
598 rx_cache_insert(ndo
, bp
, (const struct ip
*) bp2
, dport
);
601 case FS_RX_PORT
: /* AFS file service */
602 fs_print(ndo
, bp
, length
);
604 case CB_RX_PORT
: /* AFS callback service */
605 cb_print(ndo
, bp
, length
);
607 case PROT_RX_PORT
: /* AFS protection service */
608 prot_print(ndo
, bp
, length
);
610 case VLDB_RX_PORT
: /* AFS VLDB service */
611 vldb_print(ndo
, bp
, length
);
613 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
614 kauth_print(ndo
, bp
, length
);
616 case VOL_RX_PORT
: /* AFS Volume service */
617 vol_print(ndo
, bp
, length
);
619 case BOS_RX_PORT
: /* AFS BOS service */
620 bos_print(ndo
, bp
, length
);
627 * If it's a reply (client-init is _not_ set, but seq is one)
628 * then look it up in the cache. If we find it, call the reply
629 * printing functions Note that we handle abort packets here,
630 * because printing out the return code can be useful at times.
633 } else if (((type
== RX_PACKET_TYPE_DATA
&&
634 GET_BE_U_4(rxh
->seq
) == 1) ||
635 type
== RX_PACKET_TYPE_ABORT
) &&
636 (flags
& RX_CLIENT_INITIATED
) == 0 &&
637 rx_cache_find(ndo
, rxh
, (const struct ip
*) bp2
,
641 case FS_RX_PORT
: /* AFS file service */
642 fs_reply_print(ndo
, bp
, length
, opcode
);
644 case CB_RX_PORT
: /* AFS callback service */
645 cb_reply_print(ndo
, bp
, length
, opcode
);
647 case PROT_RX_PORT
: /* AFS PT service */
648 prot_reply_print(ndo
, bp
, length
, opcode
);
650 case VLDB_RX_PORT
: /* AFS VLDB service */
651 vldb_reply_print(ndo
, bp
, length
, opcode
);
653 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
654 kauth_reply_print(ndo
, bp
, length
, opcode
);
656 case VOL_RX_PORT
: /* AFS Volume service */
657 vol_reply_print(ndo
, bp
, length
, opcode
);
659 case BOS_RX_PORT
: /* AFS BOS service */
660 bos_reply_print(ndo
, bp
, length
, opcode
);
667 * If it's an RX ack packet, then use the appropriate ack decoding
668 * function (there isn't any service-specific information in the
669 * ack packet, so we can use one for all AFS services)
672 } else if (type
== RX_PACKET_TYPE_ACK
)
673 rx_ack_print(ndo
, bp
, length
);
676 ND_PRINT(" (%u)", length
);
680 * Insert an entry into the cache. Taken from print-nfs.c
684 rx_cache_insert(netdissect_options
*ndo
,
685 const u_char
*bp
, const struct ip
*ip
, uint16_t dport
)
687 struct rx_cache_entry
*rxent
;
688 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
690 if (!ND_TTEST_4(bp
+ sizeof(struct rx_header
)))
693 rxent
= &rx_cache
[rx_cache_next
];
695 if (++rx_cache_next
>= RX_CACHE_SIZE
)
698 rxent
->callnum
= GET_BE_U_4(rxh
->callNumber
);
699 rxent
->client
= GET_IPV4_TO_NETWORK_ORDER(ip
->ip_src
);
700 rxent
->server
= GET_IPV4_TO_NETWORK_ORDER(ip
->ip_dst
);
701 rxent
->dport
= dport
;
702 rxent
->serviceId
= GET_BE_U_2(rxh
->serviceId
);
703 rxent
->opcode
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
707 * Lookup an entry in the cache. Also taken from print-nfs.c
709 * Note that because this is a reply, we're looking at the _source_
714 rx_cache_find(netdissect_options
*ndo
, const struct rx_header
*rxh
,
715 const struct ip
*ip
, uint16_t sport
, uint32_t *opcode
)
718 struct rx_cache_entry
*rxent
;
722 clip
= GET_IPV4_TO_NETWORK_ORDER(ip
->ip_dst
);
723 sip
= GET_IPV4_TO_NETWORK_ORDER(ip
->ip_src
);
725 /* Start the search where we last left off */
729 rxent
= &rx_cache
[i
];
730 if (rxent
->callnum
== GET_BE_U_4(rxh
->callNumber
) &&
731 rxent
->client
== clip
&&
732 rxent
->server
== sip
&&
733 rxent
->serviceId
== GET_BE_U_2(rxh
->serviceId
) &&
734 rxent
->dport
== sport
) {
736 /* We got a match! */
739 *opcode
= rxent
->opcode
;
742 if (++i
>= RX_CACHE_SIZE
)
744 } while (i
!= rx_cache_hint
);
746 /* Our search failed */
751 * These extremely grody macros handle the printing of various AFS stuff.
754 #define FIDOUT() { uint32_t n1, n2, n3; \
755 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 3); \
756 n1 = GET_BE_U_4(bp); \
757 bp += sizeof(uint32_t); \
758 n2 = GET_BE_U_4(bp); \
759 bp += sizeof(uint32_t); \
760 n3 = GET_BE_U_4(bp); \
761 bp += sizeof(uint32_t); \
762 ND_PRINT(" fid %u/%u/%u", n1, n2, n3); \
765 #define STROUT(MAX) { uint32_t _i; \
766 _i = GET_BE_U_4(bp); \
769 bp += sizeof(uint32_t); \
771 if (nd_printn(ndo, bp, _i, ndo->ndo_snapend)) \
774 bp += ((_i + sizeof(uint32_t) - 1) / sizeof(uint32_t)) * sizeof(uint32_t); \
777 #define INTOUT() { int32_t _i; \
778 _i = GET_BE_S_4(bp); \
779 bp += sizeof(int32_t); \
780 ND_PRINT(" %d", _i); \
783 #define UINTOUT() { uint32_t _i; \
784 _i = GET_BE_U_4(bp); \
785 bp += sizeof(uint32_t); \
786 ND_PRINT(" %u", _i); \
789 #define UINT64OUT() { uint64_t _i; \
790 _i = GET_BE_U_8(bp); \
791 bp += sizeof(uint64_t); \
792 ND_PRINT(" %" PRIu64, _i); \
795 #define DATEOUT() { time_t _t; char str[256]; \
796 _t = (time_t) GET_BE_S_4(bp); \
797 bp += sizeof(int32_t); \
799 nd_format_time(str, sizeof(str), \
800 "%Y-%m-%d %H:%M:%S", localtime(&_t))); \
803 #define STOREATTROUT() { uint32_t mask, _i; \
804 ND_TCHECK_LEN(bp, (sizeof(uint32_t) * 6)); \
805 mask = GET_BE_U_4(bp); bp += sizeof(uint32_t); \
806 if (mask) ND_PRINT(" StoreStatus"); \
807 if (mask & 1) { ND_PRINT(" date"); DATEOUT(); } \
808 else bp += sizeof(uint32_t); \
809 _i = GET_BE_U_4(bp); bp += sizeof(uint32_t); \
810 if (mask & 2) ND_PRINT(" owner %u", _i); \
811 _i = GET_BE_U_4(bp); bp += sizeof(uint32_t); \
812 if (mask & 4) ND_PRINT(" group %u", _i); \
813 _i = GET_BE_U_4(bp); bp += sizeof(uint32_t); \
814 if (mask & 8) ND_PRINT(" mode %o", _i & 07777); \
815 _i = GET_BE_U_4(bp); bp += sizeof(uint32_t); \
816 if (mask & 16) ND_PRINT(" segsize %u", _i); \
817 /* undocumented in 3.3 docu */ \
818 if (mask & 1024) ND_PRINT(" fsync"); \
821 #define UBIK_VERSIONOUT() {uint32_t epoch; uint32_t counter; \
822 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 2); \
823 epoch = GET_BE_U_4(bp); \
824 bp += sizeof(uint32_t); \
825 counter = GET_BE_U_4(bp); \
826 bp += sizeof(uint32_t); \
827 ND_PRINT(" %u.%u", epoch, counter); \
830 #define AFSUUIDOUT() {uint32_t temp; int _i; \
831 ND_TCHECK_LEN(bp, 11 * sizeof(uint32_t)); \
832 temp = GET_BE_U_4(bp); \
833 bp += sizeof(uint32_t); \
834 ND_PRINT(" %08x", temp); \
835 temp = GET_BE_U_4(bp); \
836 bp += sizeof(uint32_t); \
837 ND_PRINT("%04x", temp); \
838 temp = GET_BE_U_4(bp); \
839 bp += sizeof(uint32_t); \
840 ND_PRINT("%04x", temp); \
841 for (_i = 0; _i < 8; _i++) { \
842 temp = GET_BE_U_4(bp); \
843 bp += sizeof(uint32_t); \
844 ND_PRINT("%02x", (unsigned char) temp); \
849 * This is the sickest one of all
850 * MAX is expected to be a constant here
853 #define VECOUT(MAX) { u_char *sp; \
854 u_char s[(MAX) + 1]; \
856 ND_TCHECK_LEN(bp, (MAX) * sizeof(uint32_t)); \
858 for (k = 0; k < (MAX); k++) { \
859 *sp++ = (u_char) GET_BE_U_4(bp); \
860 bp += sizeof(uint32_t); \
864 fn_print_str(ndo, s); \
868 #define DESTSERVEROUT() { uint32_t n1, n2, n3; \
869 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 3); \
870 n1 = GET_BE_U_4(bp); \
871 bp += sizeof(uint32_t); \
872 n2 = GET_BE_U_4(bp); \
873 bp += sizeof(uint32_t); \
874 n3 = GET_BE_U_4(bp); \
875 bp += sizeof(uint32_t); \
876 ND_PRINT(" server %u:%u:%u", n1, n2, n3); \
880 * Handle calls to the AFS file service (fs)
884 fs_print(netdissect_options
*ndo
,
885 const u_char
*bp
, u_int length
)
890 if (length
<= sizeof(struct rx_header
))
894 * Print out the afs call we're invoking. The table used here was
895 * gleaned from fsint/afsint.xg
898 fs_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
900 ND_PRINT(" fs call %s", tok2str(fs_req
, "op#%u", fs_op
));
903 * Print out arguments to some of the AFS calls. This stuff is
907 bp
+= sizeof(struct rx_header
) + 4;
910 * Sigh. This is gross. Ritchie forgive me.
914 case 130: /* Fetch data */
921 case 131: /* Fetch ACL */
922 case 132: /* Fetch Status */
923 case 143: /* Old set lock */
924 case 144: /* Old extend lock */
925 case 145: /* Old release lock */
926 case 156: /* Set lock */
927 case 157: /* Extend lock */
928 case 158: /* Release lock */
931 case 135: /* Store status */
935 case 133: /* Store data */
945 case 134: /* Store ACL */
947 char a
[AFSOPAQUEMAX
+1];
950 bp
+= sizeof(uint32_t);
951 ND_TCHECK_LEN(bp
, i
);
952 i
= ND_MIN(AFSOPAQUEMAX
, i
);
953 strncpy(a
, (const char *) bp
, i
);
955 acl_print(ndo
, (u_char
*) a
, (u_char
*) a
+ i
);
958 case 137: /* Create file */
959 case 141: /* MakeDir */
964 case 136: /* Remove file */
965 case 142: /* Remove directory */
969 case 138: /* Rename file */
977 case 139: /* Symlink */
980 ND_PRINT(" link to");
986 ND_PRINT(" link to");
989 case 148: /* Get volume info */
992 case 149: /* Get volume stats */
993 case 150: /* Set volume stats */
997 case 154: /* New get volume info */
998 ND_PRINT(" volname");
1001 case 155: /* Bulk stat */
1002 case 65536: /* Inline bulk stat */
1006 bp
+= sizeof(uint32_t);
1008 for (i
= 0; i
< j
; i
++) {
1014 ND_PRINT(" <none!>");
1017 case 65537: /* Fetch data 64 */
1019 ND_PRINT(" offset");
1021 ND_PRINT(" length");
1024 case 65538: /* Store data 64 */
1027 ND_PRINT(" offset");
1029 ND_PRINT(" length");
1034 case 65541: /* CallBack rx conn address */
1048 * Handle replies to the AFS file service
1052 fs_reply_print(netdissect_options
*ndo
,
1053 const u_char
*bp
, u_int length
, uint32_t opcode
)
1056 const struct rx_header
*rxh
;
1059 if (length
<= sizeof(struct rx_header
))
1062 rxh
= (const struct rx_header
*) bp
;
1065 * Print out the afs call we're invoking. The table used here was
1066 * gleaned from fsint/afsint.xg
1069 ND_PRINT(" fs reply %s", tok2str(fs_req
, "op#%u", opcode
));
1071 type
= GET_U_1(rxh
->type
);
1072 bp
+= sizeof(struct rx_header
);
1075 * If it was a data packet, interpret the response
1078 if (type
== RX_PACKET_TYPE_DATA
) {
1080 case 131: /* Fetch ACL */
1082 char a
[AFSOPAQUEMAX
+1];
1084 bp
+= sizeof(uint32_t);
1085 ND_TCHECK_LEN(bp
, i
);
1086 i
= ND_MIN(AFSOPAQUEMAX
, i
);
1087 strncpy(a
, (const char *) bp
, i
);
1089 acl_print(ndo
, (u_char
*) a
, (u_char
*) a
+ i
);
1092 case 137: /* Create file */
1093 case 141: /* MakeDir */
1097 case 151: /* Get root volume */
1098 ND_PRINT(" root volume");
1101 case 153: /* Get time */
1107 } else if (type
== RX_PACKET_TYPE_ABORT
) {
1109 * Otherwise, just print out the return code
1113 errcode
= GET_BE_S_4(bp
);
1114 bp
+= sizeof(int32_t);
1116 ND_PRINT(" error %s", tok2str(afs_fs_errors
, "#%d", errcode
));
1118 ND_PRINT(" strange fs reply of type %u", type
);
1128 * Print out an AFS ACL string. An AFS ACL is a string that has the
1131 * <positive> <negative>
1135 * "positive" and "negative" are integers which contain the number of
1136 * positive and negative ACL's in the string. The uid/aclbits pair are
1137 * ASCII strings containing the UID/PTS record and an ASCII number
1138 * representing a logical OR of all the ACL permission bits
1141 #define XSTRINGIFY(x) #x
1142 #define NUMSTRINGIFY(x) XSTRINGIFY(x)
1145 acl_print(netdissect_options
*ndo
,
1146 u_char
*s
, const u_char
*end
)
1150 char user
[USERNAMEMAX
+1];
1152 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1161 * This wacky order preserves the order used by the "fs" command
1164 #define ACLOUT(acl) \
1165 ND_PRINT("%s%s%s%s%s%s%s", \
1166 acl & PRSFS_READ ? "r" : "", \
1167 acl & PRSFS_LOOKUP ? "l" : "", \
1168 acl & PRSFS_INSERT ? "i" : "", \
1169 acl & PRSFS_DELETE ? "d" : "", \
1170 acl & PRSFS_WRITE ? "w" : "", \
1171 acl & PRSFS_LOCK ? "k" : "", \
1172 acl & PRSFS_ADMINISTER ? "a" : "");
1174 for (i
= 0; i
< pos
; i
++) {
1175 if (sscanf((char *) s
, "%" NUMSTRINGIFY(USERNAMEMAX
) "s %d\n%n", user
, &acl
, &n
) != 2)
1179 fn_print_str(ndo
, (u_char
*)user
);
1187 for (i
= 0; i
< neg
; i
++) {
1188 if (sscanf((char *) s
, "%" NUMSTRINGIFY(USERNAMEMAX
) "s %d\n%n", user
, &acl
, &n
) != 2)
1192 fn_print_str(ndo
, (u_char
*)user
);
1204 * Handle calls to the AFS callback service
1208 cb_print(netdissect_options
*ndo
,
1209 const u_char
*bp
, u_int length
)
1214 if (length
<= sizeof(struct rx_header
))
1218 * Print out the afs call we're invoking. The table used here was
1219 * gleaned from fsint/afscbint.xg
1222 cb_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
1224 ND_PRINT(" cb call %s", tok2str(cb_req
, "op#%u", cb_op
));
1226 bp
+= sizeof(struct rx_header
) + 4;
1229 * Print out the afs call we're invoking. The table used here was
1230 * gleaned from fsint/afscbint.xg
1234 case 204: /* Callback */
1238 bp
+= sizeof(uint32_t);
1240 for (i
= 0; i
< j
; i
++) {
1247 ND_PRINT(" <none!>");
1250 bp
+= sizeof(uint32_t);
1255 for (i
= 0; i
< j
; i
++) {
1258 ND_PRINT(" expires");
1261 bp
+= sizeof(uint32_t);
1262 tok2str(cb_types
, "type %u", t
);
1267 ND_PRINT(" afsuuid");
1282 * Handle replies to the AFS Callback Service
1286 cb_reply_print(netdissect_options
*ndo
,
1287 const u_char
*bp
, u_int length
, uint32_t opcode
)
1289 const struct rx_header
*rxh
;
1292 if (length
<= sizeof(struct rx_header
))
1295 rxh
= (const struct rx_header
*) bp
;
1298 * Print out the afs call we're invoking. The table used here was
1299 * gleaned from fsint/afscbint.xg
1302 ND_PRINT(" cb reply %s", tok2str(cb_req
, "op#%u", opcode
));
1304 type
= GET_U_1(rxh
->type
);
1305 bp
+= sizeof(struct rx_header
);
1308 * If it was a data packet, interpret the response.
1311 if (type
== RX_PACKET_TYPE_DATA
)
1313 case 213: /* InitCallBackState3 */
1321 * Otherwise, just print out the return code
1323 ND_PRINT(" errcode");
1334 * Handle calls to the AFS protection database server
1338 prot_print(netdissect_options
*ndo
,
1339 const u_char
*bp
, u_int length
)
1344 if (length
<= sizeof(struct rx_header
))
1348 * Print out the afs call we're invoking. The table used here was
1349 * gleaned from ptserver/ptint.xg
1352 pt_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
1356 if (is_ubik(pt_op
)) {
1357 ubik_print(ndo
, bp
);
1361 ND_PRINT(" call %s", tok2str(pt_req
, "op#%u", pt_op
));
1364 * Decode some of the arguments to the PT calls
1367 bp
+= sizeof(struct rx_header
) + 4;
1370 case 500: /* I New User */
1377 case 501: /* Where is it */
1378 case 506: /* Delete */
1379 case 508: /* Get CPS */
1380 case 512: /* List entry */
1381 case 514: /* List elements */
1382 case 517: /* List owned */
1383 case 518: /* Get CPS2 */
1384 case 519: /* Get host CPS */
1385 case 530: /* List super groups */
1389 case 502: /* Dump entry */
1393 case 503: /* Add to group */
1394 case 507: /* Remove from group */
1395 case 515: /* Is a member of? */
1401 case 504: /* Name to ID */
1405 bp
+= sizeof(uint32_t);
1408 * Who designed this chicken-shit protocol?
1410 * Each character is stored as a 32-bit
1414 for (i
= 0; i
< j
; i
++) {
1418 ND_PRINT(" <none!>");
1421 case 505: /* Id to name */
1426 bp
+= sizeof(uint32_t);
1427 for (j
= 0; j
< i
; j
++)
1430 ND_PRINT(" <none!>");
1433 case 509: /* New entry */
1440 case 511: /* Set max */
1446 case 513: /* Change entry */
1455 case 520: /* Update entry */
1472 * Handle replies to the AFS protection service
1476 prot_reply_print(netdissect_options
*ndo
,
1477 const u_char
*bp
, u_int length
, uint32_t opcode
)
1479 const struct rx_header
*rxh
;
1483 if (length
< sizeof(struct rx_header
))
1486 rxh
= (const struct rx_header
*) bp
;
1489 * Print out the afs call we're invoking. The table used here was
1490 * gleaned from ptserver/ptint.xg. Check to see if it's a
1491 * Ubik call, however.
1496 if (is_ubik(opcode
)) {
1497 ubik_reply_print(ndo
, bp
, length
, opcode
);
1501 ND_PRINT(" reply %s", tok2str(pt_req
, "op#%u", opcode
));
1503 type
= GET_U_1(rxh
->type
);
1504 bp
+= sizeof(struct rx_header
);
1507 * If it was a data packet, interpret the response
1510 if (type
== RX_PACKET_TYPE_DATA
)
1512 case 504: /* Name to ID */
1517 bp
+= sizeof(uint32_t);
1518 for (j
= 0; j
< i
; j
++)
1521 ND_PRINT(" <none!>");
1524 case 505: /* ID to name */
1528 bp
+= sizeof(uint32_t);
1531 * Who designed this chicken-shit protocol?
1533 * Each character is stored as a 32-bit
1537 for (i
= 0; i
< j
; i
++) {
1541 ND_PRINT(" <none!>");
1544 case 508: /* Get CPS */
1545 case 514: /* List elements */
1546 case 517: /* List owned */
1547 case 518: /* Get CPS2 */
1548 case 519: /* Get host CPS */
1552 bp
+= sizeof(uint32_t);
1553 for (i
= 0; i
< j
; i
++) {
1557 ND_PRINT(" <none!>");
1560 case 510: /* List max */
1561 ND_PRINT(" maxuid");
1563 ND_PRINT(" maxgid");
1571 * Otherwise, just print out the return code
1573 ND_PRINT(" errcode");
1584 * Handle calls to the AFS volume location database service
1588 vldb_print(netdissect_options
*ndo
,
1589 const u_char
*bp
, u_int length
)
1594 if (length
<= sizeof(struct rx_header
))
1598 * Print out the afs call we're invoking. The table used here was
1599 * gleaned from vlserver/vldbint.xg
1602 vldb_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
1606 if (is_ubik(vldb_op
)) {
1607 ubik_print(ndo
, bp
);
1610 ND_PRINT(" call %s", tok2str(vldb_req
, "op#%u", vldb_op
));
1613 * Decode some of the arguments to the VLDB calls
1616 bp
+= sizeof(struct rx_header
) + 4;
1619 case 501: /* Create new volume */
1620 case 517: /* Create entry N */
1623 case 502: /* Delete entry */
1624 case 503: /* Get entry by ID */
1625 case 507: /* Update entry */
1626 case 508: /* Set lock */
1627 case 509: /* Release lock */
1628 case 518: /* Get entry by ID N */
1632 bp
+= sizeof(uint32_t);
1634 ND_PRINT(" type %s", voltype
[i
]);
1636 case 504: /* Get entry by name */
1637 case 519: /* Get entry by name N */
1638 case 524: /* Update entry by name */
1639 case 527: /* Get entry by name U */
1642 case 505: /* Get new vol id */
1646 case 506: /* Replace entry */
1647 case 520: /* Replace entry N */
1651 bp
+= sizeof(uint32_t);
1653 ND_PRINT(" type %s", voltype
[i
]);
1656 case 510: /* List entry */
1657 case 521: /* List entry N */
1668 ND_PRINT(" [|vldb]");
1672 * Handle replies to the AFS volume location database service
1676 vldb_reply_print(netdissect_options
*ndo
,
1677 const u_char
*bp
, u_int length
, uint32_t opcode
)
1679 const struct rx_header
*rxh
;
1683 if (length
< sizeof(struct rx_header
))
1686 rxh
= (const struct rx_header
*) bp
;
1689 * Print out the afs call we're invoking. The table used here was
1690 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1691 * Ubik call, however.
1696 if (is_ubik(opcode
)) {
1697 ubik_reply_print(ndo
, bp
, length
, opcode
);
1701 ND_PRINT(" reply %s", tok2str(vldb_req
, "op#%u", opcode
));
1703 type
= GET_U_1(rxh
->type
);
1704 bp
+= sizeof(struct rx_header
);
1707 * If it was a data packet, interpret the response
1710 if (type
== RX_PACKET_TYPE_DATA
)
1712 case 510: /* List entry */
1715 ND_PRINT(" nextindex");
1718 case 503: /* Get entry by id */
1719 case 504: /* Get entry by name */
1720 { uint32_t nservers
, j
;
1723 bp
+= sizeof(uint32_t);
1724 ND_PRINT(" numservers");
1725 nservers
= GET_BE_U_4(bp
);
1726 bp
+= sizeof(uint32_t);
1727 ND_PRINT(" %u", nservers
);
1728 ND_PRINT(" servers");
1729 for (i
= 0; i
< 8; i
++) {
1733 intoa(GET_IPV4_TO_NETWORK_ORDER(bp
)));
1734 bp
+= sizeof(nd_ipv4
);
1736 ND_PRINT(" partitions");
1737 for (i
= 0; i
< 8; i
++) {
1739 if (i
< nservers
&& j
<= 26)
1740 ND_PRINT(" %c", 'a' + j
);
1741 else if (i
< nservers
)
1743 bp
+= sizeof(uint32_t);
1745 ND_TCHECK_LEN(bp
, 8 * sizeof(uint32_t));
1746 bp
+= 8 * sizeof(uint32_t);
1751 ND_PRINT(" backup");
1755 case 505: /* Get new volume ID */
1756 ND_PRINT(" newvol");
1759 case 521: /* List entry */
1760 case 529: /* List entry U */
1763 ND_PRINT(" nextindex");
1766 case 518: /* Get entry by ID N */
1767 case 519: /* Get entry by name N */
1768 { uint32_t nservers
, j
;
1770 ND_PRINT(" numservers");
1771 nservers
= GET_BE_U_4(bp
);
1772 bp
+= sizeof(uint32_t);
1773 ND_PRINT(" %u", nservers
);
1774 ND_PRINT(" servers");
1775 for (i
= 0; i
< 13; i
++) {
1779 intoa(GET_IPV4_TO_NETWORK_ORDER(bp
)));
1780 bp
+= sizeof(nd_ipv4
);
1782 ND_PRINT(" partitions");
1783 for (i
= 0; i
< 13; i
++) {
1785 if (i
< nservers
&& j
<= 26)
1786 ND_PRINT(" %c", 'a' + j
);
1787 else if (i
< nservers
)
1789 bp
+= sizeof(uint32_t);
1791 ND_TCHECK_LEN(bp
, 13 * sizeof(uint32_t));
1792 bp
+= 13 * sizeof(uint32_t);
1797 ND_PRINT(" backup");
1801 case 526: /* Get entry by ID U */
1802 case 527: /* Get entry by name U */
1803 { uint32_t nservers
, j
;
1805 ND_PRINT(" numservers");
1806 nservers
= GET_BE_U_4(bp
);
1807 bp
+= sizeof(uint32_t);
1808 ND_PRINT(" %u", nservers
);
1809 ND_PRINT(" servers");
1810 for (i
= 0; i
< 13; i
++) {
1812 ND_PRINT(" afsuuid");
1815 ND_TCHECK_LEN(bp
, 44);
1819 ND_TCHECK_LEN(bp
, 4 * 13);
1821 ND_PRINT(" partitions");
1822 for (i
= 0; i
< 13; i
++) {
1824 if (i
< nservers
&& j
<= 26)
1825 ND_PRINT(" %c", 'a' + j
);
1826 else if (i
< nservers
)
1828 bp
+= sizeof(uint32_t);
1830 ND_TCHECK_LEN(bp
, 13 * sizeof(uint32_t));
1831 bp
+= 13 * sizeof(uint32_t);
1836 ND_PRINT(" backup");
1845 * Otherwise, just print out the return code
1847 ND_PRINT(" errcode");
1854 ND_PRINT(" [|vldb]");
1858 * Handle calls to the AFS Kerberos Authentication service
1862 kauth_print(netdissect_options
*ndo
,
1863 const u_char
*bp
, u_int length
)
1867 if (length
<= sizeof(struct rx_header
))
1871 * Print out the afs call we're invoking. The table used here was
1872 * gleaned from kauth/kauth.rg
1875 kauth_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
1879 if (is_ubik(kauth_op
)) {
1880 ubik_print(ndo
, bp
);
1885 ND_PRINT(" call %s", tok2str(kauth_req
, "op#%u", kauth_op
));
1888 * Decode some of the arguments to the KA calls
1891 bp
+= sizeof(struct rx_header
) + 4;
1894 case 1: /* Authenticate old */
1895 case 21: /* Authenticate */
1896 case 22: /* Authenticate-V2 */
1897 case 2: /* Change PW */
1898 case 5: /* Set fields */
1899 case 6: /* Create user */
1900 case 7: /* Delete user */
1901 case 8: /* Get entry */
1902 case 14: /* Unlock */
1903 case 15: /* Lock status */
1904 ND_PRINT(" principal");
1908 case 3: /* GetTicket-old */
1909 case 23: /* GetTicket */
1914 ND_PRINT(" domain");
1917 bp
+= sizeof(uint32_t);
1918 ND_TCHECK_LEN(bp
, i
);
1920 ND_PRINT(" principal");
1925 case 4: /* Set Password */
1926 ND_PRINT(" principal");
1932 case 12: /* Get password */
1943 ND_PRINT(" [|kauth]");
1947 * Handle replies to the AFS Kerberos Authentication Service
1951 kauth_reply_print(netdissect_options
*ndo
,
1952 const u_char
*bp
, u_int length
, uint32_t opcode
)
1954 const struct rx_header
*rxh
;
1957 if (length
<= sizeof(struct rx_header
))
1960 rxh
= (const struct rx_header
*) bp
;
1963 * Print out the afs call we're invoking. The table used here was
1964 * gleaned from kauth/kauth.rg
1969 if (is_ubik(opcode
)) {
1970 ubik_reply_print(ndo
, bp
, length
, opcode
);
1974 ND_PRINT(" reply %s", tok2str(kauth_req
, "op#%u", opcode
));
1976 type
= GET_U_1(rxh
->type
);
1977 bp
+= sizeof(struct rx_header
);
1980 * If it was a data packet, interpret the response.
1983 if (type
== RX_PACKET_TYPE_DATA
)
1984 /* Well, no, not really. Leave this for later */
1988 * Otherwise, just print out the return code
1990 ND_PRINT(" errcode");
1996 * Handle calls to the AFS Volume location service
2000 vol_print(netdissect_options
*ndo
,
2001 const u_char
*bp
, u_int length
)
2005 if (length
<= sizeof(struct rx_header
))
2009 * Print out the afs call we're invoking. The table used here was
2010 * gleaned from volser/volint.xg
2013 vol_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
2015 ND_PRINT(" vol call %s", tok2str(vol_req
, "op#%u", vol_op
));
2017 bp
+= sizeof(struct rx_header
) + 4;
2020 case 100: /* Create volume */
2021 ND_PRINT(" partition");
2027 ND_PRINT(" parent");
2030 case 101: /* Delete volume */
2031 case 107: /* Get flags */
2035 case 102: /* Restore */
2036 ND_PRINT(" totrans");
2041 case 103: /* Forward */
2042 ND_PRINT(" fromtrans");
2044 ND_PRINT(" fromdate");
2047 ND_PRINT(" desttrans");
2050 case 104: /* End trans */
2054 case 105: /* Clone */
2057 ND_PRINT(" purgevol");
2059 ND_PRINT(" newtype");
2061 ND_PRINT(" newname");
2064 case 106: /* Set flags */
2070 case 108: /* Trans create */
2073 ND_PRINT(" partition");
2078 case 109: /* Dump */
2079 case 655537: /* Get size */
2080 ND_PRINT(" fromtrans");
2082 ND_PRINT(" fromdate");
2085 case 110: /* Get n-th volume */
2089 case 111: /* Set forwarding */
2092 ND_PRINT(" newsite");
2095 case 112: /* Get name */
2096 case 113: /* Get status */
2099 case 114: /* Signal restore */
2106 ND_PRINT(" cloneid");
2109 case 116: /* List volumes */
2110 ND_PRINT(" partition");
2115 case 117: /* Set id types */
2126 ND_PRINT(" backup");
2129 case 119: /* Partition info */
2133 case 120: /* Reclone */
2137 case 121: /* List one volume */
2138 case 122: /* Nuke volume */
2139 case 124: /* Extended List volumes */
2140 case 125: /* Extended List one volume */
2141 case 65536: /* Convert RO to RW volume */
2142 ND_PRINT(" partid");
2147 case 123: /* Set date */
2153 case 126: /* Set info */
2157 case 128: /* Forward multiple */
2158 ND_PRINT(" fromtrans");
2160 ND_PRINT(" fromdate");
2165 bp
+= sizeof(uint32_t);
2166 for (i
= 0; i
< j
; i
++) {
2172 ND_PRINT(" <none!>");
2175 case 65538: /* Dump version 2 */
2176 ND_PRINT(" fromtrans");
2178 ND_PRINT(" fromdate");
2189 ND_PRINT(" [|vol]");
2193 * Handle replies to the AFS Volume Service
2197 vol_reply_print(netdissect_options
*ndo
,
2198 const u_char
*bp
, u_int length
, uint32_t opcode
)
2200 const struct rx_header
*rxh
;
2203 if (length
<= sizeof(struct rx_header
))
2206 rxh
= (const struct rx_header
*) bp
;
2209 * Print out the afs call we're invoking. The table used here was
2210 * gleaned from volser/volint.xg
2213 ND_PRINT(" vol reply %s", tok2str(vol_req
, "op#%u", opcode
));
2215 type
= GET_U_1(rxh
->type
);
2216 bp
+= sizeof(struct rx_header
);
2219 * If it was a data packet, interpret the response.
2222 if (type
== RX_PACKET_TYPE_DATA
) {
2224 case 100: /* Create volume */
2230 case 104: /* End transaction */
2233 case 105: /* Clone */
2234 ND_PRINT(" newvol");
2237 case 107: /* Get flags */
2240 case 108: /* Transaction create */
2244 case 110: /* Get n-th volume */
2245 ND_PRINT(" volume");
2247 ND_PRINT(" partition");
2250 case 112: /* Get name */
2253 case 113: /* Get status */
2256 ND_PRINT(" nextuniq");
2260 ND_PRINT(" parentid");
2264 ND_PRINT(" backup");
2266 ND_PRINT(" restore");
2268 ND_PRINT(" maxquota");
2270 ND_PRINT(" minquota");
2274 ND_PRINT(" create");
2276 ND_PRINT(" access");
2278 ND_PRINT(" update");
2280 ND_PRINT(" expire");
2282 ND_PRINT(" backup");
2287 case 115: /* Old list partitions */
2289 case 116: /* List volumes */
2290 case 121: /* List one volume */
2294 bp
+= sizeof(uint32_t);
2295 for (i
= 0; i
< j
; i
++) {
2301 bp
+= sizeof(uint32_t) * 21;
2306 ND_PRINT(" <none!>");
2316 * Otherwise, just print out the return code
2318 ND_PRINT(" errcode");
2325 ND_PRINT(" [|vol]");
2329 * Handle calls to the AFS BOS service
2333 bos_print(netdissect_options
*ndo
,
2334 const u_char
*bp
, u_int length
)
2338 if (length
<= sizeof(struct rx_header
))
2342 * Print out the afs call we're invoking. The table used here was
2343 * gleaned from bozo/bosint.xg
2346 bos_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
2348 ND_PRINT(" bos call %s", tok2str(bos_req
, "op#%u", bos_op
));
2351 * Decode some of the arguments to the BOS calls
2354 bp
+= sizeof(struct rx_header
) + 4;
2357 case 80: /* Create B node */
2360 ND_PRINT(" instance");
2363 case 81: /* Delete B node */
2364 case 83: /* Get status */
2365 case 85: /* Get instance info */
2366 case 87: /* Add super user */
2367 case 88: /* Delete super user */
2368 case 93: /* Set cell name */
2369 case 96: /* Add cell host */
2370 case 97: /* Delete cell host */
2371 case 104: /* Restart */
2372 case 106: /* Uninstall */
2373 case 108: /* Exec */
2374 case 112: /* Getlog */
2375 case 114: /* Get instance strings */
2378 case 82: /* Set status */
2379 case 98: /* Set T status */
2381 ND_PRINT(" status");
2384 case 86: /* Get instance parm */
2389 case 84: /* Enumerate instance */
2390 case 89: /* List super users */
2391 case 90: /* List keys */
2392 case 91: /* Add key */
2393 case 92: /* Delete key */
2394 case 95: /* Get cell host */
2397 case 105: /* Install */
2413 ND_PRINT(" [|bos]");
2417 * Handle replies to the AFS BOS Service
2421 bos_reply_print(netdissect_options
*ndo
,
2422 const u_char
*bp
, u_int length
, uint32_t opcode
)
2424 const struct rx_header
*rxh
;
2427 if (length
<= sizeof(struct rx_header
))
2430 rxh
= (const struct rx_header
*) bp
;
2433 * Print out the afs call we're invoking. The table used here was
2434 * gleaned from volser/volint.xg
2437 ND_PRINT(" bos reply %s", tok2str(bos_req
, "op#%u", opcode
));
2439 type
= GET_U_1(rxh
->type
);
2440 bp
+= sizeof(struct rx_header
);
2443 * If it was a data packet, interpret the response.
2446 if (type
== RX_PACKET_TYPE_DATA
)
2447 /* Well, no, not really. Leave this for later */
2451 * Otherwise, just print out the return code
2453 ND_PRINT(" errcode");
2459 * Check to see if this is a Ubik opcode.
2463 is_ubik(uint32_t opcode
)
2465 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2466 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2473 * Handle Ubik opcodes to any one of the replicated database services
2477 ubik_print(netdissect_options
*ndo
,
2484 * Print out the afs call we're invoking. The table used here was
2485 * gleaned from ubik/ubik_int.xg
2488 /* Every function that calls this function first makes a bounds check
2489 * for (sizeof(rx_header) + 4) bytes, so long as it remains this way
2490 * the line below will not over-read.
2492 ubik_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
2494 ND_PRINT(" ubik call %s", tok2str(ubik_req
, "op#%u", ubik_op
));
2497 * Decode some of the arguments to the Ubik calls
2500 bp
+= sizeof(struct rx_header
) + 4;
2503 case 10000: /* Beacon */
2504 temp
= GET_BE_U_4(bp
);
2505 bp
+= sizeof(uint32_t);
2506 ND_PRINT(" syncsite %s", temp
? "yes" : "no");
2507 ND_PRINT(" votestart");
2509 ND_PRINT(" dbversion");
2514 case 10003: /* Get sync site */
2518 case 20000: /* Begin */
2519 case 20001: /* Commit */
2520 case 20007: /* Abort */
2521 case 20008: /* Release locks */
2522 case 20010: /* Writev */
2526 case 20002: /* Lock */
2533 ND_PRINT(" length");
2535 temp
= GET_BE_U_4(bp
);
2536 bp
+= sizeof(uint32_t);
2537 tok2str(ubik_lock_types
, "type %u", temp
);
2539 case 20003: /* Write */
2547 case 20005: /* Get file */
2551 case 20006: /* Send file */
2554 ND_PRINT(" length");
2556 ND_PRINT(" dbversion");
2559 case 20009: /* Truncate */
2564 ND_PRINT(" length");
2567 case 20012: /* Set version */
2570 ND_PRINT(" oldversion");
2572 ND_PRINT(" newversion");
2582 ND_PRINT(" [|ubik]");
2586 * Handle Ubik replies to any one of the replicated database services
2590 ubik_reply_print(netdissect_options
*ndo
,
2591 const u_char
*bp
, u_int length
, uint32_t opcode
)
2593 const struct rx_header
*rxh
;
2596 if (length
< sizeof(struct rx_header
))
2599 rxh
= (const struct rx_header
*) bp
;
2602 * Print out the ubik call we're invoking. This table was gleaned
2603 * from ubik/ubik_int.xg
2606 ND_PRINT(" ubik reply %s", tok2str(ubik_req
, "op#%u", opcode
));
2608 type
= GET_U_1(rxh
->type
);
2609 bp
+= sizeof(struct rx_header
);
2612 * If it was a data packet, print out the arguments to the Ubik calls
2615 if (type
== RX_PACKET_TYPE_DATA
)
2617 case 10000: /* Beacon */
2618 ND_PRINT(" vote no");
2620 case 20004: /* Get version */
2621 ND_PRINT(" dbversion");
2629 * Otherwise, print out "yes" if it was a beacon packet (because
2630 * that's how yes votes are returned, go figure), otherwise
2631 * just print out the error code.
2636 case 10000: /* Beacon */
2637 ND_PRINT(" vote yes until");
2641 ND_PRINT(" errcode");
2648 ND_PRINT(" [|ubik]");
2652 * Handle RX ACK packets.
2656 rx_ack_print(netdissect_options
*ndo
,
2657 const u_char
*bp
, u_int length
)
2659 const struct rx_ackPacket
*rxa
;
2662 uint32_t firstPacket
;
2664 if (length
< sizeof(struct rx_header
))
2667 bp
+= sizeof(struct rx_header
);
2669 ND_TCHECK_LEN(bp
, sizeof(struct rx_ackPacket
));
2671 rxa
= (const struct rx_ackPacket
*) bp
;
2672 bp
+= sizeof(struct rx_ackPacket
);
2675 * Print out a few useful things from the ack packet structure
2678 if (ndo
->ndo_vflag
> 2)
2679 ND_PRINT(" bufspace %u maxskew %u",
2680 GET_BE_U_2(rxa
->bufferSpace
),
2681 GET_BE_U_2(rxa
->maxSkew
));
2683 firstPacket
= GET_BE_U_4(rxa
->firstPacket
);
2684 ND_PRINT(" first %u serial %u reason %s",
2685 firstPacket
, GET_BE_U_4(rxa
->serial
),
2686 tok2str(rx_ack_reasons
, "#%u", GET_U_1(rxa
->reason
)));
2689 * Okay, now we print out the ack array. The way _this_ works
2690 * is that we start at "first", and step through the ack array.
2691 * If we have a contiguous range of acks/nacks, try to
2692 * collapse them into a range.
2694 * If you're really clever, you might have noticed that this
2695 * doesn't seem quite correct. Specifically, due to structure
2696 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2697 * yield the start of the ack array (because RX_MAXACKS is 255
2698 * and the structure will likely get padded to a 2 or 4 byte
2699 * boundary). However, this is the way it's implemented inside
2700 * of AFS - the start of the extra fields are at
2701 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2702 * the exact start of the ack array. Sigh. That's why we aren't
2703 * using bp, but instead use rxa->acks[]. But nAcks gets added
2704 * to bp after this, so bp ends up at the right spot. Go figure.
2707 nAcks
= GET_U_1(rxa
->nAcks
);
2710 ND_TCHECK_LEN(bp
, nAcks
);
2713 * Sigh, this is gross, but it seems to work to collapse
2717 for (i
= 0, start
= last
= -2; i
< nAcks
; i
++)
2718 if (GET_U_1(bp
+ i
) == RX_ACK_TYPE_ACK
) {
2721 * I figured this deserved _some_ explanation.
2722 * First, print "acked" and the packet seq
2723 * number if this is the first time we've
2724 * seen an acked packet.
2728 ND_PRINT(" acked %u", firstPacket
+ i
);
2733 * Otherwise, if there is a skip in
2734 * the range (such as an nacked packet in
2735 * the middle of some acked packets),
2736 * then print the current packet number
2737 * separated from the last number by
2741 else if (last
!= i
- 1) {
2742 ND_PRINT(",%u", firstPacket
+ i
);
2747 * We always set last to the value of
2748 * the last ack we saw. Conversely, start
2749 * is set to the value of the first ack
2750 * we saw in a range.
2756 * Okay, this bit a code gets executed when
2757 * we hit a nack ... in _this_ case we
2758 * want to print out the range of packets
2759 * that were acked, so we need to print
2760 * the _previous_ packet number separated
2761 * from the first by a dash (-). Since we
2762 * already printed the first packet above,
2763 * just print the final packet. Don't
2764 * do this if there will be a single-length
2767 } else if (last
== i
- 1 && start
!= last
)
2768 ND_PRINT("-%u", firstPacket
+ i
- 1);
2771 * So, what's going on here? We ran off the end of the
2772 * ack list, and if we got a range we need to finish it up.
2773 * So we need to determine if the last packet in the list
2774 * was an ack (if so, then last will be set to it) and
2775 * we need to see if the last range didn't start with the
2776 * last packet (because if it _did_, then that would mean
2777 * that the packet number has already been printed and
2778 * we don't need to print it again).
2781 if (last
== i
- 1 && start
!= last
)
2782 ND_PRINT("-%u", firstPacket
+ i
- 1);
2785 * Same as above, just without comments
2788 for (i
= 0, start
= last
= -2; i
< nAcks
; i
++)
2789 if (GET_U_1(bp
+ i
) == RX_ACK_TYPE_NACK
) {
2791 ND_PRINT(" nacked %u", firstPacket
+ i
);
2793 } else if (last
!= i
- 1) {
2794 ND_PRINT(",%u", firstPacket
+ i
);
2798 } else if (last
== i
- 1 && start
!= last
)
2799 ND_PRINT("-%u", firstPacket
+ i
- 1);
2801 if (last
== i
- 1 && start
!= last
)
2802 ND_PRINT("-%u", firstPacket
+ i
- 1);
2811 * These are optional fields; depending on your version of AFS,
2812 * you may or may not see them
2815 #define TRUNCRET(n) if (ndo->ndo_snapend - bp + 1 <= n) return;
2817 if (ndo
->ndo_vflag
> 1) {
2823 ND_PRINT(" maxmtu");
2831 ND_PRINT(" maxpackets");
2838 ND_PRINT(" [|ack]");