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 AFSOPAQUEMAX 1024
63 #define AFSNAMEMAX 256 /* Must be >= PRNAMEMAX + 1, VLNAMEMAX + 1, and 32 + 1 */
67 #define BOSNAMEMAX 256
68 #define USERNAMEMAX 1024 /* AFSOPAQUEMAX was used for this; does it need to be this big? */
70 #define PRSFS_READ 1 /* Read files */
71 #define PRSFS_WRITE 2 /* Write files */
72 #define PRSFS_INSERT 4 /* Insert files into a directory */
73 #define PRSFS_LOOKUP 8 /* Lookup files into a directory */
74 #define PRSFS_DELETE 16 /* Delete files */
75 #define PRSFS_LOCK 32 /* Lock files */
76 #define PRSFS_ADMINISTER 64 /* Change ACL's */
81 nd_uint32_t callNumber
;
85 #define RX_PACKET_TYPE_DATA 1
86 #define RX_PACKET_TYPE_ACK 2
87 #define RX_PACKET_TYPE_BUSY 3
88 #define RX_PACKET_TYPE_ABORT 4
89 #define RX_PACKET_TYPE_ACKALL 5
90 #define RX_PACKET_TYPE_CHALLENGE 6
91 #define RX_PACKET_TYPE_RESPONSE 7
92 #define RX_PACKET_TYPE_DEBUG 8
93 #define RX_PACKET_TYPE_PARAMS 9
94 #define RX_PACKET_TYPE_VERSION 13
96 #define RX_CLIENT_INITIATED 1
97 #define RX_REQUEST_ACK 2
98 #define RX_LAST_PACKET 4
99 #define RX_MORE_PACKETS 8
100 #define RX_FREE_PACKET 16
101 #define RX_SLOW_START_OK 32
102 #define RX_JUMBO_PACKET 32
103 nd_uint8_t userStatus
;
104 nd_uint8_t securityIndex
;
105 nd_uint16_t spare
; /* How clever: even though the AFS */
106 nd_uint16_t serviceId
; /* header files indicate that the */
107 }; /* serviceId is first, it's really */
108 /* encoded _after_ the spare field */
109 /* I wasted a day figuring that out! */
111 #define NUM_RX_FLAGS 7
113 #define RX_MAXACKS 255
115 struct rx_ackPacket
{
116 nd_uint16_t bufferSpace
; /* Number of packet buffers available */
117 nd_uint16_t maxSkew
; /* Max diff between ack'd packet and */
118 /* highest packet received */
119 nd_uint32_t firstPacket
; /* The first packet in ack list */
120 nd_uint32_t previousPacket
; /* Previous packet recv'd (obsolete) */
121 nd_uint32_t serial
; /* # of packet that prompted the ack */
122 nd_uint8_t reason
; /* Reason for acknowledgement */
123 nd_uint8_t nAcks
; /* Number of acknowledgements */
124 /* Followed by nAcks acknowledgments */
126 uint8_t acks
[RX_MAXACKS
]; /* Up to RX_MAXACKS acknowledgements */
131 * Values for the acks array
134 #define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
135 #define RX_ACK_TYPE_ACK 1 /* I have this packet */
137 static const struct tok rx_types
[] = {
138 { RX_PACKET_TYPE_DATA
, "data" },
139 { RX_PACKET_TYPE_ACK
, "ack" },
140 { RX_PACKET_TYPE_BUSY
, "busy" },
141 { RX_PACKET_TYPE_ABORT
, "abort" },
142 { RX_PACKET_TYPE_ACKALL
, "ackall" },
143 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
144 { RX_PACKET_TYPE_RESPONSE
, "response" },
145 { RX_PACKET_TYPE_DEBUG
, "debug" },
146 { RX_PACKET_TYPE_PARAMS
, "params" },
147 { RX_PACKET_TYPE_VERSION
, "version" },
151 static const struct double_tok
{
152 uint32_t flag
; /* Rx flag */
153 uint32_t packetType
; /* Packet type */
154 const char *s
; /* Flag string */
156 { RX_CLIENT_INITIATED
, 0, "client-init" },
157 { RX_REQUEST_ACK
, 0, "req-ack" },
158 { RX_LAST_PACKET
, 0, "last-pckt" },
159 { RX_MORE_PACKETS
, 0, "more-pckts" },
160 { RX_FREE_PACKET
, 0, "free-pckt" },
161 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
162 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
165 static const struct tok fs_req
[] = {
166 { 130, "fetch-data" },
167 { 131, "fetch-acl" },
168 { 132, "fetch-status" },
169 { 133, "store-data" },
170 { 134, "store-acl" },
171 { 135, "store-status" },
172 { 136, "remove-file" },
173 { 137, "create-file" },
179 { 143, "oldsetlock" },
180 { 144, "oldextlock" },
181 { 145, "oldrellock" },
182 { 146, "get-stats" },
184 { 148, "get-vlinfo" },
185 { 149, "get-vlstats" },
186 { 150, "set-vlstats" },
187 { 151, "get-rootvl" },
188 { 152, "check-token" },
190 { 154, "nget-vlinfo" },
191 { 155, "bulk-stat" },
195 { 159, "xstat-ver" },
196 { 160, "get-xstat" },
197 { 161, "dfs-lookup" },
198 { 162, "dfs-flushcps" },
199 { 163, "dfs-symlink" },
200 { 220, "residency" },
201 { 65536, "inline-bulk-status" },
202 { 65537, "fetch-data-64" },
203 { 65538, "store-data-64" },
204 { 65539, "give-up-all-cbs" },
205 { 65540, "get-caps" },
206 { 65541, "cb-rx-conn-addr" },
210 static const struct tok cb_req
[] = {
219 { 212, "whoareyou" },
221 { 214, "probeuuid" },
222 { 215, "getsrvprefs" },
223 { 216, "getcellservdb" },
224 { 217, "getlocalcell" },
225 { 218, "getcacheconf" },
226 { 65536, "getce64" },
227 { 65537, "getcellbynum" },
228 { 65538, "tellmeaboutyourself" },
232 static const struct tok pt_req
[] = {
234 { 501, "where-is-it" },
235 { 502, "dump-entry" },
236 { 503, "add-to-group" },
237 { 504, "name-to-id" },
238 { 505, "id-to-name" },
240 { 507, "remove-from-group" },
242 { 509, "new-entry" },
245 { 512, "list-entry" },
246 { 513, "change-entry" },
247 { 514, "list-elements" },
248 { 515, "same-mbr-of" },
249 { 516, "set-fld-sentry" },
250 { 517, "list-owned" },
252 { 519, "get-host-cps" },
253 { 520, "update-entry" },
254 { 521, "list-entries" },
255 { 530, "list-super-groups" },
259 static const struct tok vldb_req
[] = {
260 { 501, "create-entry" },
261 { 502, "delete-entry" },
262 { 503, "get-entry-by-id" },
263 { 504, "get-entry-by-name" },
264 { 505, "get-new-volume-id" },
265 { 506, "replace-entry" },
266 { 507, "update-entry" },
268 { 509, "releaselock" },
269 { 510, "list-entry" },
270 { 511, "list-attrib" },
271 { 512, "linked-list" },
272 { 513, "get-stats" },
274 { 515, "get-addrs" },
275 { 516, "change-addr" },
276 { 517, "create-entry-n" },
277 { 518, "get-entry-by-id-n" },
278 { 519, "get-entry-by-name-n" },
279 { 520, "replace-entry-n" },
280 { 521, "list-entry-n" },
281 { 522, "list-attrib-n" },
282 { 523, "linked-list-n" },
283 { 524, "update-entry-by-name" },
284 { 525, "create-entry-u" },
285 { 526, "get-entry-by-id-u" },
286 { 527, "get-entry-by-name-u" },
287 { 528, "replace-entry-u" },
288 { 529, "list-entry-u" },
289 { 530, "list-attrib-u" },
290 { 531, "linked-list-u" },
292 { 533, "get-addrs-u" },
293 { 534, "list-attrib-n2" },
297 static const struct tok kauth_req
[] = {
299 { 21, "authenticate" },
300 { 22, "authenticate-v2" },
302 { 3, "get-ticket-old" },
303 { 23, "get-ticket" },
306 { 6, "create-user" },
307 { 7, "delete-user" },
313 { 13, "get-random-key" },
315 { 15, "lock-status" },
319 static const struct tok vol_req
[] = {
320 { 100, "create-volume" },
321 { 101, "delete-volume" },
324 { 104, "end-trans" },
326 { 106, "set-flags" },
327 { 107, "get-flags" },
328 { 108, "trans-create" },
330 { 110, "get-nth-volume" },
331 { 111, "set-forwarding" },
333 { 113, "get-status" },
334 { 114, "sig-restore" },
335 { 115, "list-partitions" },
336 { 116, "list-volumes" },
337 { 117, "set-id-types" },
339 { 119, "partition-info" },
341 { 121, "list-one-volume" },
344 { 124, "x-list-volumes" },
345 { 125, "x-list-one-volume" },
347 { 127, "x-list-partitions" },
348 { 128, "forward-multiple" },
349 { 65536, "convert-ro" },
350 { 65537, "get-size" },
351 { 65538, "dump-v2" },
355 static const struct tok bos_req
[] = {
356 { 80, "create-bnode" },
357 { 81, "delete-bnode" },
358 { 82, "set-status" },
359 { 83, "get-status" },
360 { 84, "enumerate-instance" },
361 { 85, "get-instance-info" },
362 { 86, "get-instance-parm" },
363 { 87, "add-superuser" },
364 { 88, "delete-superuser" },
365 { 89, "list-superusers" },
368 { 92, "delete-key" },
369 { 93, "set-cell-name" },
370 { 94, "get-cell-name" },
371 { 95, "get-cell-host" },
372 { 96, "add-cell-host" },
373 { 97, "delete-cell-host" },
374 { 98, "set-t-status" },
375 { 99, "shutdown-all" },
376 { 100, "restart-all" },
377 { 101, "startup-all" },
378 { 102, "set-noauth-flag" },
381 { 105, "start-bozo-install" },
382 { 106, "uninstall" },
383 { 107, "get-dates" },
386 { 110, "set-restart-time" },
387 { 111, "get-restart-time" },
388 { 112, "start-bozo-log" },
390 { 114, "get-instance-strings" },
391 { 115, "get-restricted" },
392 { 116, "set-restricted" },
396 static const struct tok ubik_req
[] = {
397 { 10000, "vote-beacon" },
398 { 10001, "vote-debug-old" },
399 { 10002, "vote-sdebug-old" },
400 { 10003, "vote-getsyncsite" },
401 { 10004, "vote-debug" },
402 { 10005, "vote-sdebug" },
403 { 10006, "vote-xdebug" },
404 { 10007, "vote-xsdebug" },
405 { 20000, "disk-begin" },
406 { 20001, "disk-commit" },
407 { 20002, "disk-lock" },
408 { 20003, "disk-write" },
409 { 20004, "disk-getversion" },
410 { 20005, "disk-getfile" },
411 { 20006, "disk-sendfile" },
412 { 20007, "disk-abort" },
413 { 20008, "disk-releaselocks" },
414 { 20009, "disk-truncate" },
415 { 20010, "disk-probe" },
416 { 20011, "disk-writev" },
417 { 20012, "disk-interfaceaddr" },
418 { 20013, "disk-setversion" },
422 #define VOTE_LOW 10000
423 #define VOTE_HIGH 10007
424 #define DISK_LOW 20000
425 #define DISK_HIGH 20013
427 static const struct tok cb_types
[] = {
434 static const struct tok ubik_lock_types
[] = {
441 static const char *voltype
[] = { "read-write", "read-only", "backup" };
443 static const struct tok afs_fs_errors
[] = {
444 { 101, "salvage volume" },
445 { 102, "no such vnode" },
446 { 103, "no such volume" },
447 { 104, "volume exist" },
448 { 105, "no service" },
449 { 106, "volume offline" },
450 { 107, "voline online" },
452 { 109, "diskquota exceeded" },
453 { 110, "volume busy" },
454 { 111, "volume moved" },
455 { 112, "AFS IO error" },
456 { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */
461 * Reasons for acknowledging a packet
464 static const struct tok rx_ack_reasons
[] = {
465 { 1, "ack requested" },
466 { 2, "duplicate packet" },
467 { 3, "out of sequence" },
468 { 4, "exceeds window" },
469 { 5, "no buffer space" },
471 { 7, "ping response" },
478 * Cache entries we keep around so we can figure out the RX opcode
479 * numbers for replies. This allows us to make sense of RX reply packets.
482 struct rx_cache_entry
{
483 uint32_t callnum
; /* Call number (net order) */
484 uint32_t client
; /* client IP address (net order) */
485 uint32_t server
; /* server IP address (net order) */
486 uint16_t dport
; /* server UDP port (host order) */
487 uint16_t serviceId
; /* Service identifier (net order) */
488 uint32_t opcode
; /* RX opcode (host order) */
491 #define RX_CACHE_SIZE 64
493 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
495 static uint32_t rx_cache_next
= 0;
496 static uint32_t rx_cache_hint
= 0;
497 static void rx_cache_insert(netdissect_options
*, const u_char
*, const struct ip
*, uint16_t);
498 static int rx_cache_find(netdissect_options
*, const struct rx_header
*,
499 const struct ip
*, uint16_t, uint32_t *);
501 static void fs_print(netdissect_options
*, const u_char
*, u_int
);
502 static void fs_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
503 static void acl_print(netdissect_options
*, u_char
*, u_char
*);
504 static void cb_print(netdissect_options
*, const u_char
*, u_int
);
505 static void cb_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
506 static void prot_print(netdissect_options
*, const u_char
*, u_int
);
507 static void prot_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
508 static void vldb_print(netdissect_options
*, const u_char
*, u_int
);
509 static void vldb_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
510 static void kauth_print(netdissect_options
*, const u_char
*, u_int
);
511 static void kauth_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
512 static void vol_print(netdissect_options
*, const u_char
*, u_int
);
513 static void vol_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
514 static void bos_print(netdissect_options
*, const u_char
*, u_int
);
515 static void bos_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
516 static void ubik_print(netdissect_options
*, const u_char
*);
517 static void ubik_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
519 static void rx_ack_print(netdissect_options
*, const u_char
*, u_int
);
521 static int is_ubik(uint32_t);
524 * Handle the rx-level packet. See if we know what port it's going to so
525 * we can peek at the afs call inside
529 rx_print(netdissect_options
*ndo
,
530 const u_char
*bp
, u_int length
, uint16_t sport
, uint16_t dport
,
533 const struct rx_header
*rxh
;
538 ndo
->ndo_protocol
= "rx";
539 if (!ND_TTEST_LEN(bp
, sizeof(struct rx_header
))) {
540 ND_PRINT(" [|rx] (%u)", length
);
544 rxh
= (const struct rx_header
*) bp
;
546 type
= GET_U_1(rxh
->type
);
547 ND_PRINT(" rx %s", tok2str(rx_types
, "type %u", type
));
549 flags
= GET_U_1(rxh
->flags
);
550 if (ndo
->ndo_vflag
) {
553 if (ndo
->ndo_vflag
> 1)
554 ND_PRINT(" cid %08x call# %u",
555 GET_BE_U_4(rxh
->cid
),
556 GET_BE_U_4(rxh
->callNumber
));
558 ND_PRINT(" seq %u ser %u",
559 GET_BE_U_4(rxh
->seq
),
560 GET_BE_U_4(rxh
->serial
));
562 if (ndo
->ndo_vflag
> 2)
563 ND_PRINT(" secindex %u serviceid %hu",
564 GET_U_1(rxh
->securityIndex
),
565 GET_BE_U_2(rxh
->serviceId
));
567 if (ndo
->ndo_vflag
> 1)
568 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
569 if (flags
& rx_flags
[i
].flag
&&
570 (!rx_flags
[i
].packetType
||
571 type
== rx_flags
[i
].packetType
)) {
578 ND_PRINT("<%s>", rx_flags
[i
].s
);
584 * Try to handle AFS calls that we know about. Check the destination
585 * port and make sure it's a data packet. Also, make sure the
586 * seq number is 1 (because otherwise it's a continuation packet,
587 * and we can't interpret that). Also, seems that reply packets
588 * do not have the client-init flag set, so we check for that
592 if (type
== RX_PACKET_TYPE_DATA
&&
593 GET_BE_U_4(rxh
->seq
) == 1 &&
594 flags
& RX_CLIENT_INITIATED
) {
597 * Insert this call into the call cache table, so we
598 * have a chance to print out replies
601 rx_cache_insert(ndo
, bp
, (const struct ip
*) bp2
, dport
);
604 case FS_RX_PORT
: /* AFS file service */
605 fs_print(ndo
, bp
, length
);
607 case CB_RX_PORT
: /* AFS callback service */
608 cb_print(ndo
, bp
, length
);
610 case PROT_RX_PORT
: /* AFS protection service */
611 prot_print(ndo
, bp
, length
);
613 case VLDB_RX_PORT
: /* AFS VLDB service */
614 vldb_print(ndo
, bp
, length
);
616 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
617 kauth_print(ndo
, bp
, length
);
619 case VOL_RX_PORT
: /* AFS Volume service */
620 vol_print(ndo
, bp
, length
);
622 case BOS_RX_PORT
: /* AFS BOS service */
623 bos_print(ndo
, bp
, length
);
630 * If it's a reply (client-init is _not_ set, but seq is one)
631 * then look it up in the cache. If we find it, call the reply
632 * printing functions Note that we handle abort packets here,
633 * because printing out the return code can be useful at times.
636 } else if (((type
== RX_PACKET_TYPE_DATA
&&
637 GET_BE_U_4(rxh
->seq
) == 1) ||
638 type
== RX_PACKET_TYPE_ABORT
) &&
639 (flags
& RX_CLIENT_INITIATED
) == 0 &&
640 rx_cache_find(ndo
, rxh
, (const struct ip
*) bp2
,
644 case FS_RX_PORT
: /* AFS file service */
645 fs_reply_print(ndo
, bp
, length
, opcode
);
647 case CB_RX_PORT
: /* AFS callback service */
648 cb_reply_print(ndo
, bp
, length
, opcode
);
650 case PROT_RX_PORT
: /* AFS PT service */
651 prot_reply_print(ndo
, bp
, length
, opcode
);
653 case VLDB_RX_PORT
: /* AFS VLDB service */
654 vldb_reply_print(ndo
, bp
, length
, opcode
);
656 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
657 kauth_reply_print(ndo
, bp
, length
, opcode
);
659 case VOL_RX_PORT
: /* AFS Volume service */
660 vol_reply_print(ndo
, bp
, length
, opcode
);
662 case BOS_RX_PORT
: /* AFS BOS service */
663 bos_reply_print(ndo
, bp
, length
, opcode
);
670 * If it's an RX ack packet, then use the appropriate ack decoding
671 * function (there isn't any service-specific information in the
672 * ack packet, so we can use one for all AFS services)
675 } else if (type
== RX_PACKET_TYPE_ACK
)
676 rx_ack_print(ndo
, bp
, length
);
679 ND_PRINT(" (%u)", length
);
683 * Insert an entry into the cache. Taken from print-nfs.c
687 rx_cache_insert(netdissect_options
*ndo
,
688 const u_char
*bp
, const struct ip
*ip
, uint16_t dport
)
690 struct rx_cache_entry
*rxent
;
691 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
693 if (!ND_TTEST_4(bp
+ sizeof(struct rx_header
)))
696 rxent
= &rx_cache
[rx_cache_next
];
698 if (++rx_cache_next
>= RX_CACHE_SIZE
)
701 rxent
->callnum
= GET_BE_U_4(rxh
->callNumber
);
702 rxent
->client
= GET_IPV4_TO_NETWORK_ORDER(ip
->ip_src
);
703 rxent
->server
= GET_IPV4_TO_NETWORK_ORDER(ip
->ip_dst
);
704 rxent
->dport
= dport
;
705 rxent
->serviceId
= GET_BE_U_2(rxh
->serviceId
);
706 rxent
->opcode
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
710 * Lookup an entry in the cache. Also taken from print-nfs.c
712 * Note that because this is a reply, we're looking at the _source_
717 rx_cache_find(netdissect_options
*ndo
, const struct rx_header
*rxh
,
718 const struct ip
*ip
, uint16_t sport
, uint32_t *opcode
)
721 struct rx_cache_entry
*rxent
;
725 clip
= GET_IPV4_TO_NETWORK_ORDER(ip
->ip_dst
);
726 sip
= GET_IPV4_TO_NETWORK_ORDER(ip
->ip_src
);
728 /* Start the search where we last left off */
732 rxent
= &rx_cache
[i
];
733 if (rxent
->callnum
== GET_BE_U_4(rxh
->callNumber
) &&
734 rxent
->client
== clip
&&
735 rxent
->server
== sip
&&
736 rxent
->serviceId
== GET_BE_U_2(rxh
->serviceId
) &&
737 rxent
->dport
== sport
) {
739 /* We got a match! */
742 *opcode
= rxent
->opcode
;
745 if (++i
>= RX_CACHE_SIZE
)
747 } while (i
!= rx_cache_hint
);
749 /* Our search failed */
754 * These extremely grody macros handle the printing of various AFS stuff.
757 #define FIDOUT() { uint32_t n1, n2, n3; \
758 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 3); \
759 n1 = GET_BE_U_4(bp); \
760 bp += sizeof(uint32_t); \
761 n2 = GET_BE_U_4(bp); \
762 bp += sizeof(uint32_t); \
763 n3 = GET_BE_U_4(bp); \
764 bp += sizeof(uint32_t); \
765 ND_PRINT(" fid %u/%u/%u", n1, n2, n3); \
768 #define STROUT(MAX) { uint32_t _i; \
769 _i = GET_BE_U_4(bp); \
772 bp += sizeof(uint32_t); \
774 if (nd_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; \
781 _i = GET_BE_S_4(bp); \
782 bp += sizeof(int32_t); \
783 ND_PRINT(" %d", _i); \
786 #define UINTOUT() { uint32_t _i; \
787 _i = GET_BE_U_4(bp); \
788 bp += sizeof(uint32_t); \
789 ND_PRINT(" %u", _i); \
792 #define UINT64OUT() { uint64_t _i; \
793 _i = GET_BE_U_8(bp); \
794 bp += sizeof(uint64_t); \
795 ND_PRINT(" %" PRIu64, _i); \
798 #define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \
799 _t = (time_t) GET_BE_S_4(bp); \
800 bp += sizeof(int32_t); \
801 tm = localtime(&_t); \
802 strftime(str, 256, "%Y/%m/%d %H:%M:%S", tm); \
803 ND_PRINT(" %s", str); \
806 #define STOREATTROUT() { uint32_t mask, _i; \
807 ND_TCHECK_LEN(bp, (sizeof(uint32_t) * 6)); \
808 mask = GET_BE_U_4(bp); bp += sizeof(uint32_t); \
809 if (mask) ND_PRINT(" StoreStatus"); \
810 if (mask & 1) { ND_PRINT(" date"); DATEOUT(); } \
811 else bp += sizeof(uint32_t); \
812 _i = GET_BE_U_4(bp); bp += sizeof(uint32_t); \
813 if (mask & 2) ND_PRINT(" owner %u", _i); \
814 _i = GET_BE_U_4(bp); bp += sizeof(uint32_t); \
815 if (mask & 4) ND_PRINT(" group %u", _i); \
816 _i = GET_BE_U_4(bp); bp += sizeof(uint32_t); \
817 if (mask & 8) ND_PRINT(" mode %o", _i & 07777); \
818 _i = GET_BE_U_4(bp); bp += sizeof(uint32_t); \
819 if (mask & 16) ND_PRINT(" segsize %u", _i); \
820 /* undocumented in 3.3 docu */ \
821 if (mask & 1024) ND_PRINT(" fsync"); \
824 #define UBIK_VERSIONOUT() {uint32_t epoch; uint32_t counter; \
825 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 2); \
826 epoch = GET_BE_U_4(bp); \
827 bp += sizeof(uint32_t); \
828 counter = GET_BE_U_4(bp); \
829 bp += sizeof(uint32_t); \
830 ND_PRINT(" %u.%u", epoch, counter); \
833 #define AFSUUIDOUT() {uint32_t temp; int _i; \
834 ND_TCHECK_LEN(bp, 11 * sizeof(uint32_t)); \
835 temp = GET_BE_U_4(bp); \
836 bp += sizeof(uint32_t); \
837 ND_PRINT(" %08x", temp); \
838 temp = GET_BE_U_4(bp); \
839 bp += sizeof(uint32_t); \
840 ND_PRINT("%04x", temp); \
841 temp = GET_BE_U_4(bp); \
842 bp += sizeof(uint32_t); \
843 ND_PRINT("%04x", temp); \
844 for (_i = 0; _i < 8; _i++) { \
845 temp = GET_BE_U_4(bp); \
846 bp += sizeof(uint32_t); \
847 ND_PRINT("%02x", (unsigned char) temp); \
852 * This is the sickest one of all
853 * MAX is expected to be a constant here
856 #define VECOUT(MAX) { u_char *sp; \
857 u_char s[(MAX) + 1]; \
859 ND_TCHECK_LEN(bp, (MAX) * sizeof(uint32_t)); \
861 for (k = 0; k < (MAX); k++) { \
862 *sp++ = (u_char) GET_BE_U_4(bp); \
863 bp += sizeof(uint32_t); \
867 fn_print_str(ndo, s); \
871 #define DESTSERVEROUT() { uint32_t n1, n2, n3; \
872 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 3); \
873 n1 = GET_BE_U_4(bp); \
874 bp += sizeof(uint32_t); \
875 n2 = GET_BE_U_4(bp); \
876 bp += sizeof(uint32_t); \
877 n3 = GET_BE_U_4(bp); \
878 bp += sizeof(uint32_t); \
879 ND_PRINT(" server %u:%u:%u", n1, n2, n3); \
883 * Handle calls to the AFS file service (fs)
887 fs_print(netdissect_options
*ndo
,
888 const u_char
*bp
, u_int length
)
893 if (length
<= sizeof(struct rx_header
))
897 * Print out the afs call we're invoking. The table used here was
898 * gleaned from fsint/afsint.xg
901 fs_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
903 ND_PRINT(" fs call %s", tok2str(fs_req
, "op#%u", fs_op
));
906 * Print out arguments to some of the AFS calls. This stuff is
910 bp
+= sizeof(struct rx_header
) + 4;
913 * Sigh. This is gross. Ritchie forgive me.
917 case 130: /* Fetch data */
924 case 131: /* Fetch ACL */
925 case 132: /* Fetch Status */
926 case 143: /* Old set lock */
927 case 144: /* Old extend lock */
928 case 145: /* Old release lock */
929 case 156: /* Set lock */
930 case 157: /* Extend lock */
931 case 158: /* Release lock */
934 case 135: /* Store status */
938 case 133: /* Store data */
948 case 134: /* Store ACL */
950 char a
[AFSOPAQUEMAX
+1];
953 bp
+= sizeof(uint32_t);
954 ND_TCHECK_LEN(bp
, i
);
955 i
= ND_MIN(AFSOPAQUEMAX
, i
);
956 strncpy(a
, (const char *) bp
, i
);
958 acl_print(ndo
, (u_char
*) a
, (u_char
*) a
+ i
);
961 case 137: /* Create file */
962 case 141: /* MakeDir */
967 case 136: /* Remove file */
968 case 142: /* Remove directory */
972 case 138: /* Rename file */
980 case 139: /* Symlink */
983 ND_PRINT(" link to");
989 ND_PRINT(" link to");
992 case 148: /* Get volume info */
995 case 149: /* Get volume stats */
996 case 150: /* Set volume stats */
1000 case 154: /* New get volume info */
1001 ND_PRINT(" volname");
1004 case 155: /* Bulk stat */
1005 case 65536: /* Inline bulk stat */
1009 bp
+= sizeof(uint32_t);
1011 for (i
= 0; i
< j
; i
++) {
1017 ND_PRINT(" <none!>");
1020 case 65537: /* Fetch data 64 */
1022 ND_PRINT(" offset");
1024 ND_PRINT(" length");
1027 case 65538: /* Store data 64 */
1030 ND_PRINT(" offset");
1032 ND_PRINT(" length");
1037 case 65541: /* CallBack rx conn address */
1051 * Handle replies to the AFS file service
1055 fs_reply_print(netdissect_options
*ndo
,
1056 const u_char
*bp
, u_int length
, uint32_t opcode
)
1059 const struct rx_header
*rxh
;
1062 if (length
<= sizeof(struct rx_header
))
1065 rxh
= (const struct rx_header
*) bp
;
1068 * Print out the afs call we're invoking. The table used here was
1069 * gleaned from fsint/afsint.xg
1072 ND_PRINT(" fs reply %s", tok2str(fs_req
, "op#%u", opcode
));
1074 type
= GET_U_1(rxh
->type
);
1075 bp
+= sizeof(struct rx_header
);
1078 * If it was a data packet, interpret the response
1081 if (type
== RX_PACKET_TYPE_DATA
) {
1083 case 131: /* Fetch ACL */
1085 char a
[AFSOPAQUEMAX
+1];
1087 bp
+= sizeof(uint32_t);
1088 ND_TCHECK_LEN(bp
, i
);
1089 i
= ND_MIN(AFSOPAQUEMAX
, i
);
1090 strncpy(a
, (const char *) bp
, i
);
1092 acl_print(ndo
, (u_char
*) a
, (u_char
*) a
+ i
);
1095 case 137: /* Create file */
1096 case 141: /* MakeDir */
1100 case 151: /* Get root volume */
1101 ND_PRINT(" root volume");
1104 case 153: /* Get time */
1110 } else if (type
== RX_PACKET_TYPE_ABORT
) {
1112 * Otherwise, just print out the return code
1116 errcode
= GET_BE_S_4(bp
);
1117 bp
+= sizeof(int32_t);
1119 ND_PRINT(" error %s", tok2str(afs_fs_errors
, "#%d", errcode
));
1121 ND_PRINT(" strange fs reply of type %u", type
);
1131 * Print out an AFS ACL string. An AFS ACL is a string that has the
1134 * <positive> <negative>
1138 * "positive" and "negative" are integers which contain the number of
1139 * positive and negative ACL's in the string. The uid/aclbits pair are
1140 * ASCII strings containing the UID/PTS record and an ASCII number
1141 * representing a logical OR of all the ACL permission bits
1144 #define NUMSTRINGIFY(x) XSTRINGIFY(x)
1147 acl_print(netdissect_options
*ndo
,
1148 u_char
*s
, u_char
*end
)
1152 char user
[USERNAMEMAX
+1];
1154 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1163 * This wacky order preserves the order used by the "fs" command
1166 #define ACLOUT(acl) \
1167 ND_PRINT("%s%s%s%s%s%s%s", \
1168 acl & PRSFS_READ ? "r" : "", \
1169 acl & PRSFS_LOOKUP ? "l" : "", \
1170 acl & PRSFS_INSERT ? "i" : "", \
1171 acl & PRSFS_DELETE ? "d" : "", \
1172 acl & PRSFS_WRITE ? "w" : "", \
1173 acl & PRSFS_LOCK ? "k" : "", \
1174 acl & PRSFS_ADMINISTER ? "a" : "");
1176 for (i
= 0; i
< pos
; i
++) {
1177 if (sscanf((char *) s
, "%" NUMSTRINGIFY(USERNAMEMAX
) "s %d\n%n", user
, &acl
, &n
) != 2)
1181 fn_print_str(ndo
, (u_char
*)user
);
1189 for (i
= 0; i
< neg
; i
++) {
1190 if (sscanf((char *) s
, "%" NUMSTRINGIFY(USERNAMEMAX
) "s %d\n%n", user
, &acl
, &n
) != 2)
1194 fn_print_str(ndo
, (u_char
*)user
);
1206 * Handle calls to the AFS callback service
1210 cb_print(netdissect_options
*ndo
,
1211 const u_char
*bp
, u_int length
)
1216 if (length
<= sizeof(struct rx_header
))
1220 * Print out the afs call we're invoking. The table used here was
1221 * gleaned from fsint/afscbint.xg
1224 cb_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
1226 ND_PRINT(" cb call %s", tok2str(cb_req
, "op#%u", cb_op
));
1228 bp
+= sizeof(struct rx_header
) + 4;
1231 * Print out the afs call we're invoking. The table used here was
1232 * gleaned from fsint/afscbint.xg
1236 case 204: /* Callback */
1240 bp
+= sizeof(uint32_t);
1242 for (i
= 0; i
< j
; i
++) {
1249 ND_PRINT(" <none!>");
1252 bp
+= sizeof(uint32_t);
1257 for (i
= 0; i
< j
; i
++) {
1260 ND_PRINT(" expires");
1263 bp
+= sizeof(uint32_t);
1264 tok2str(cb_types
, "type %u", t
);
1269 ND_PRINT(" afsuuid");
1284 * Handle replies to the AFS Callback Service
1288 cb_reply_print(netdissect_options
*ndo
,
1289 const u_char
*bp
, u_int length
, uint32_t opcode
)
1291 const struct rx_header
*rxh
;
1294 if (length
<= sizeof(struct rx_header
))
1297 rxh
= (const struct rx_header
*) bp
;
1300 * Print out the afs call we're invoking. The table used here was
1301 * gleaned from fsint/afscbint.xg
1304 ND_PRINT(" cb reply %s", tok2str(cb_req
, "op#%u", opcode
));
1306 type
= GET_U_1(rxh
->type
);
1307 bp
+= sizeof(struct rx_header
);
1310 * If it was a data packet, interpret the response.
1313 if (type
== RX_PACKET_TYPE_DATA
)
1315 case 213: /* InitCallBackState3 */
1323 * Otherwise, just print out the return code
1325 ND_PRINT(" errcode");
1336 * Handle calls to the AFS protection database server
1340 prot_print(netdissect_options
*ndo
,
1341 const u_char
*bp
, u_int length
)
1346 if (length
<= sizeof(struct rx_header
))
1350 * Print out the afs call we're invoking. The table used here was
1351 * gleaned from ptserver/ptint.xg
1354 pt_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
1358 if (is_ubik(pt_op
)) {
1359 ubik_print(ndo
, bp
);
1363 ND_PRINT(" call %s", tok2str(pt_req
, "op#%u", pt_op
));
1366 * Decode some of the arguments to the PT calls
1369 bp
+= sizeof(struct rx_header
) + 4;
1372 case 500: /* I New User */
1379 case 501: /* Where is it */
1380 case 506: /* Delete */
1381 case 508: /* Get CPS */
1382 case 512: /* List entry */
1383 case 514: /* List elements */
1384 case 517: /* List owned */
1385 case 518: /* Get CPS2 */
1386 case 519: /* Get host CPS */
1387 case 530: /* List super groups */
1391 case 502: /* Dump entry */
1395 case 503: /* Add to group */
1396 case 507: /* Remove from group */
1397 case 515: /* Is a member of? */
1403 case 504: /* Name to ID */
1407 bp
+= sizeof(uint32_t);
1410 * Who designed this chicken-shit protocol?
1412 * Each character is stored as a 32-bit
1416 for (i
= 0; i
< j
; i
++) {
1420 ND_PRINT(" <none!>");
1423 case 505: /* Id to name */
1428 bp
+= sizeof(uint32_t);
1429 for (j
= 0; j
< i
; j
++)
1432 ND_PRINT(" <none!>");
1435 case 509: /* New entry */
1442 case 511: /* Set max */
1448 case 513: /* Change entry */
1457 case 520: /* Update entry */
1474 * Handle replies to the AFS protection service
1478 prot_reply_print(netdissect_options
*ndo
,
1479 const u_char
*bp
, u_int length
, uint32_t opcode
)
1481 const struct rx_header
*rxh
;
1485 if (length
< sizeof(struct rx_header
))
1488 rxh
= (const struct rx_header
*) bp
;
1491 * Print out the afs call we're invoking. The table used here was
1492 * gleaned from ptserver/ptint.xg. Check to see if it's a
1493 * Ubik call, however.
1498 if (is_ubik(opcode
)) {
1499 ubik_reply_print(ndo
, bp
, length
, opcode
);
1503 ND_PRINT(" reply %s", tok2str(pt_req
, "op#%u", opcode
));
1505 type
= GET_U_1(rxh
->type
);
1506 bp
+= sizeof(struct rx_header
);
1509 * If it was a data packet, interpret the response
1512 if (type
== RX_PACKET_TYPE_DATA
)
1514 case 504: /* Name to ID */
1519 bp
+= sizeof(uint32_t);
1520 for (j
= 0; j
< i
; j
++)
1523 ND_PRINT(" <none!>");
1526 case 505: /* ID to name */
1530 bp
+= sizeof(uint32_t);
1533 * Who designed this chicken-shit protocol?
1535 * Each character is stored as a 32-bit
1539 for (i
= 0; i
< j
; i
++) {
1543 ND_PRINT(" <none!>");
1546 case 508: /* Get CPS */
1547 case 514: /* List elements */
1548 case 517: /* List owned */
1549 case 518: /* Get CPS2 */
1550 case 519: /* Get host CPS */
1554 bp
+= sizeof(uint32_t);
1555 for (i
= 0; i
< j
; i
++) {
1559 ND_PRINT(" <none!>");
1562 case 510: /* List max */
1563 ND_PRINT(" maxuid");
1565 ND_PRINT(" maxgid");
1573 * Otherwise, just print out the return code
1575 ND_PRINT(" errcode");
1586 * Handle calls to the AFS volume location database service
1590 vldb_print(netdissect_options
*ndo
,
1591 const u_char
*bp
, u_int length
)
1596 if (length
<= sizeof(struct rx_header
))
1600 * Print out the afs call we're invoking. The table used here was
1601 * gleaned from vlserver/vldbint.xg
1604 vldb_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
1608 if (is_ubik(vldb_op
)) {
1609 ubik_print(ndo
, bp
);
1612 ND_PRINT(" call %s", tok2str(vldb_req
, "op#%u", vldb_op
));
1615 * Decode some of the arguments to the VLDB calls
1618 bp
+= sizeof(struct rx_header
) + 4;
1621 case 501: /* Create new volume */
1622 case 517: /* Create entry N */
1625 case 502: /* Delete entry */
1626 case 503: /* Get entry by ID */
1627 case 507: /* Update entry */
1628 case 508: /* Set lock */
1629 case 509: /* Release lock */
1630 case 518: /* Get entry by ID N */
1634 bp
+= sizeof(uint32_t);
1636 ND_PRINT(" type %s", voltype
[i
]);
1638 case 504: /* Get entry by name */
1639 case 519: /* Get entry by name N */
1640 case 524: /* Update entry by name */
1641 case 527: /* Get entry by name U */
1644 case 505: /* Get new vol id */
1648 case 506: /* Replace entry */
1649 case 520: /* Replace entry N */
1653 bp
+= sizeof(uint32_t);
1655 ND_PRINT(" type %s", voltype
[i
]);
1658 case 510: /* List entry */
1659 case 521: /* List entry N */
1670 ND_PRINT(" [|vldb]");
1674 * Handle replies to the AFS volume location database service
1678 vldb_reply_print(netdissect_options
*ndo
,
1679 const u_char
*bp
, u_int length
, uint32_t opcode
)
1681 const struct rx_header
*rxh
;
1685 if (length
< sizeof(struct rx_header
))
1688 rxh
= (const struct rx_header
*) bp
;
1691 * Print out the afs call we're invoking. The table used here was
1692 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1693 * Ubik call, however.
1698 if (is_ubik(opcode
)) {
1699 ubik_reply_print(ndo
, bp
, length
, opcode
);
1703 ND_PRINT(" reply %s", tok2str(vldb_req
, "op#%u", opcode
));
1705 type
= GET_U_1(rxh
->type
);
1706 bp
+= sizeof(struct rx_header
);
1709 * If it was a data packet, interpret the response
1712 if (type
== RX_PACKET_TYPE_DATA
)
1714 case 510: /* List entry */
1717 ND_PRINT(" nextindex");
1720 case 503: /* Get entry by id */
1721 case 504: /* Get entry by name */
1722 { uint32_t nservers
, j
;
1725 bp
+= sizeof(uint32_t);
1726 ND_PRINT(" numservers");
1727 nservers
= GET_BE_U_4(bp
);
1728 bp
+= sizeof(uint32_t);
1729 ND_PRINT(" %u", nservers
);
1730 ND_PRINT(" servers");
1731 for (i
= 0; i
< 8; i
++) {
1735 intoa(GET_IPV4_TO_NETWORK_ORDER(bp
)));
1736 bp
+= sizeof(nd_ipv4
);
1738 ND_PRINT(" partitions");
1739 for (i
= 0; i
< 8; i
++) {
1741 if (i
< nservers
&& j
<= 26)
1742 ND_PRINT(" %c", 'a' + j
);
1743 else if (i
< nservers
)
1745 bp
+= sizeof(uint32_t);
1747 ND_TCHECK_LEN(bp
, 8 * sizeof(uint32_t));
1748 bp
+= 8 * sizeof(uint32_t);
1753 ND_PRINT(" backup");
1757 case 505: /* Get new volume ID */
1758 ND_PRINT(" newvol");
1761 case 521: /* List entry */
1762 case 529: /* List entry U */
1765 ND_PRINT(" nextindex");
1768 case 518: /* Get entry by ID N */
1769 case 519: /* Get entry by name N */
1770 { uint32_t nservers
, j
;
1772 ND_PRINT(" numservers");
1773 nservers
= GET_BE_U_4(bp
);
1774 bp
+= sizeof(uint32_t);
1775 ND_PRINT(" %u", nservers
);
1776 ND_PRINT(" servers");
1777 for (i
= 0; i
< 13; i
++) {
1781 intoa(GET_IPV4_TO_NETWORK_ORDER(bp
)));
1782 bp
+= sizeof(nd_ipv4
);
1784 ND_PRINT(" partitions");
1785 for (i
= 0; i
< 13; i
++) {
1787 if (i
< nservers
&& j
<= 26)
1788 ND_PRINT(" %c", 'a' + j
);
1789 else if (i
< nservers
)
1791 bp
+= sizeof(uint32_t);
1793 ND_TCHECK_LEN(bp
, 13 * sizeof(uint32_t));
1794 bp
+= 13 * sizeof(uint32_t);
1799 ND_PRINT(" backup");
1803 case 526: /* Get entry by ID U */
1804 case 527: /* Get entry by name U */
1805 { uint32_t nservers
, j
;
1807 ND_PRINT(" numservers");
1808 nservers
= GET_BE_U_4(bp
);
1809 bp
+= sizeof(uint32_t);
1810 ND_PRINT(" %u", nservers
);
1811 ND_PRINT(" servers");
1812 for (i
= 0; i
< 13; i
++) {
1814 ND_PRINT(" afsuuid");
1817 ND_TCHECK_LEN(bp
, 44);
1821 ND_TCHECK_LEN(bp
, 4 * 13);
1823 ND_PRINT(" partitions");
1824 for (i
= 0; i
< 13; i
++) {
1826 if (i
< nservers
&& j
<= 26)
1827 ND_PRINT(" %c", 'a' + j
);
1828 else if (i
< nservers
)
1830 bp
+= sizeof(uint32_t);
1832 ND_TCHECK_LEN(bp
, 13 * sizeof(uint32_t));
1833 bp
+= 13 * sizeof(uint32_t);
1838 ND_PRINT(" backup");
1847 * Otherwise, just print out the return code
1849 ND_PRINT(" errcode");
1856 ND_PRINT(" [|vldb]");
1860 * Handle calls to the AFS Kerberos Authentication service
1864 kauth_print(netdissect_options
*ndo
,
1865 const u_char
*bp
, u_int length
)
1869 if (length
<= sizeof(struct rx_header
))
1873 * Print out the afs call we're invoking. The table used here was
1874 * gleaned from kauth/kauth.rg
1877 kauth_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
1881 if (is_ubik(kauth_op
)) {
1882 ubik_print(ndo
, bp
);
1887 ND_PRINT(" call %s", tok2str(kauth_req
, "op#%u", kauth_op
));
1890 * Decode some of the arguments to the KA calls
1893 bp
+= sizeof(struct rx_header
) + 4;
1896 case 1: /* Authenticate old */
1897 case 21: /* Authenticate */
1898 case 22: /* Authenticate-V2 */
1899 case 2: /* Change PW */
1900 case 5: /* Set fields */
1901 case 6: /* Create user */
1902 case 7: /* Delete user */
1903 case 8: /* Get entry */
1904 case 14: /* Unlock */
1905 case 15: /* Lock status */
1906 ND_PRINT(" principal");
1910 case 3: /* GetTicket-old */
1911 case 23: /* GetTicket */
1916 ND_PRINT(" domain");
1919 bp
+= sizeof(uint32_t);
1920 ND_TCHECK_LEN(bp
, i
);
1922 ND_PRINT(" principal");
1927 case 4: /* Set Password */
1928 ND_PRINT(" principal");
1934 case 12: /* Get password */
1945 ND_PRINT(" [|kauth]");
1949 * Handle replies to the AFS Kerberos Authentication Service
1953 kauth_reply_print(netdissect_options
*ndo
,
1954 const u_char
*bp
, u_int length
, uint32_t opcode
)
1956 const struct rx_header
*rxh
;
1959 if (length
<= sizeof(struct rx_header
))
1962 rxh
= (const struct rx_header
*) bp
;
1965 * Print out the afs call we're invoking. The table used here was
1966 * gleaned from kauth/kauth.rg
1971 if (is_ubik(opcode
)) {
1972 ubik_reply_print(ndo
, bp
, length
, opcode
);
1976 ND_PRINT(" reply %s", tok2str(kauth_req
, "op#%u", opcode
));
1978 type
= GET_U_1(rxh
->type
);
1979 bp
+= sizeof(struct rx_header
);
1982 * If it was a data packet, interpret the response.
1985 if (type
== RX_PACKET_TYPE_DATA
)
1986 /* Well, no, not really. Leave this for later */
1990 * Otherwise, just print out the return code
1992 ND_PRINT(" errcode");
1998 * Handle calls to the AFS Volume location service
2002 vol_print(netdissect_options
*ndo
,
2003 const u_char
*bp
, u_int length
)
2007 if (length
<= sizeof(struct rx_header
))
2011 * Print out the afs call we're invoking. The table used here was
2012 * gleaned from volser/volint.xg
2015 vol_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
2017 ND_PRINT(" vol call %s", tok2str(vol_req
, "op#%u", vol_op
));
2019 bp
+= sizeof(struct rx_header
) + 4;
2022 case 100: /* Create volume */
2023 ND_PRINT(" partition");
2029 ND_PRINT(" parent");
2032 case 101: /* Delete volume */
2033 case 107: /* Get flags */
2037 case 102: /* Restore */
2038 ND_PRINT(" totrans");
2043 case 103: /* Forward */
2044 ND_PRINT(" fromtrans");
2046 ND_PRINT(" fromdate");
2049 ND_PRINT(" desttrans");
2052 case 104: /* End trans */
2056 case 105: /* Clone */
2059 ND_PRINT(" purgevol");
2061 ND_PRINT(" newtype");
2063 ND_PRINT(" newname");
2066 case 106: /* Set flags */
2072 case 108: /* Trans create */
2075 ND_PRINT(" partition");
2080 case 109: /* Dump */
2081 case 655537: /* Get size */
2082 ND_PRINT(" fromtrans");
2084 ND_PRINT(" fromdate");
2087 case 110: /* Get n-th volume */
2091 case 111: /* Set forwarding */
2094 ND_PRINT(" newsite");
2097 case 112: /* Get name */
2098 case 113: /* Get status */
2101 case 114: /* Signal restore */
2108 ND_PRINT(" cloneid");
2111 case 116: /* List volumes */
2112 ND_PRINT(" partition");
2117 case 117: /* Set id types */
2128 ND_PRINT(" backup");
2131 case 119: /* Partition info */
2135 case 120: /* Reclone */
2139 case 121: /* List one volume */
2140 case 122: /* Nuke volume */
2141 case 124: /* Extended List volumes */
2142 case 125: /* Extended List one volume */
2143 case 65536: /* Convert RO to RW volume */
2144 ND_PRINT(" partid");
2149 case 123: /* Set date */
2155 case 126: /* Set info */
2159 case 128: /* Forward multiple */
2160 ND_PRINT(" fromtrans");
2162 ND_PRINT(" fromdate");
2167 bp
+= sizeof(uint32_t);
2168 for (i
= 0; i
< j
; i
++) {
2174 ND_PRINT(" <none!>");
2177 case 65538: /* Dump version 2 */
2178 ND_PRINT(" fromtrans");
2180 ND_PRINT(" fromdate");
2191 ND_PRINT(" [|vol]");
2195 * Handle replies to the AFS Volume Service
2199 vol_reply_print(netdissect_options
*ndo
,
2200 const u_char
*bp
, u_int length
, uint32_t opcode
)
2202 const struct rx_header
*rxh
;
2205 if (length
<= sizeof(struct rx_header
))
2208 rxh
= (const struct rx_header
*) bp
;
2211 * Print out the afs call we're invoking. The table used here was
2212 * gleaned from volser/volint.xg
2215 ND_PRINT(" vol reply %s", tok2str(vol_req
, "op#%u", opcode
));
2217 type
= GET_U_1(rxh
->type
);
2218 bp
+= sizeof(struct rx_header
);
2221 * If it was a data packet, interpret the response.
2224 if (type
== RX_PACKET_TYPE_DATA
) {
2226 case 100: /* Create volume */
2232 case 104: /* End transaction */
2235 case 105: /* Clone */
2236 ND_PRINT(" newvol");
2239 case 107: /* Get flags */
2242 case 108: /* Transaction create */
2246 case 110: /* Get n-th volume */
2247 ND_PRINT(" volume");
2249 ND_PRINT(" partition");
2252 case 112: /* Get name */
2255 case 113: /* Get status */
2258 ND_PRINT(" nextuniq");
2262 ND_PRINT(" parentid");
2266 ND_PRINT(" backup");
2268 ND_PRINT(" restore");
2270 ND_PRINT(" maxquota");
2272 ND_PRINT(" minquota");
2276 ND_PRINT(" create");
2278 ND_PRINT(" access");
2280 ND_PRINT(" update");
2282 ND_PRINT(" expire");
2284 ND_PRINT(" backup");
2289 case 115: /* Old list partitions */
2291 case 116: /* List volumes */
2292 case 121: /* List one volume */
2296 bp
+= sizeof(uint32_t);
2297 for (i
= 0; i
< j
; i
++) {
2303 bp
+= sizeof(uint32_t) * 21;
2308 ND_PRINT(" <none!>");
2318 * Otherwise, just print out the return code
2320 ND_PRINT(" errcode");
2327 ND_PRINT(" [|vol]");
2331 * Handle calls to the AFS BOS service
2335 bos_print(netdissect_options
*ndo
,
2336 const u_char
*bp
, u_int length
)
2340 if (length
<= sizeof(struct rx_header
))
2344 * Print out the afs call we're invoking. The table used here was
2345 * gleaned from bozo/bosint.xg
2348 bos_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
2350 ND_PRINT(" bos call %s", tok2str(bos_req
, "op#%u", bos_op
));
2353 * Decode some of the arguments to the BOS calls
2356 bp
+= sizeof(struct rx_header
) + 4;
2359 case 80: /* Create B node */
2362 ND_PRINT(" instance");
2365 case 81: /* Delete B node */
2366 case 83: /* Get status */
2367 case 85: /* Get instance info */
2368 case 87: /* Add super user */
2369 case 88: /* Delete super user */
2370 case 93: /* Set cell name */
2371 case 96: /* Add cell host */
2372 case 97: /* Delete cell host */
2373 case 104: /* Restart */
2374 case 106: /* Uninstall */
2375 case 108: /* Exec */
2376 case 112: /* Getlog */
2377 case 114: /* Get instance strings */
2380 case 82: /* Set status */
2381 case 98: /* Set T status */
2383 ND_PRINT(" status");
2386 case 86: /* Get instance parm */
2391 case 84: /* Enumerate instance */
2392 case 89: /* List super users */
2393 case 90: /* List keys */
2394 case 91: /* Add key */
2395 case 92: /* Delete key */
2396 case 95: /* Get cell host */
2399 case 105: /* Install */
2415 ND_PRINT(" [|bos]");
2419 * Handle replies to the AFS BOS Service
2423 bos_reply_print(netdissect_options
*ndo
,
2424 const u_char
*bp
, u_int length
, uint32_t opcode
)
2426 const struct rx_header
*rxh
;
2429 if (length
<= sizeof(struct rx_header
))
2432 rxh
= (const struct rx_header
*) bp
;
2435 * Print out the afs call we're invoking. The table used here was
2436 * gleaned from volser/volint.xg
2439 ND_PRINT(" bos reply %s", tok2str(bos_req
, "op#%u", opcode
));
2441 type
= GET_U_1(rxh
->type
);
2442 bp
+= sizeof(struct rx_header
);
2445 * If it was a data packet, interpret the response.
2448 if (type
== RX_PACKET_TYPE_DATA
)
2449 /* Well, no, not really. Leave this for later */
2453 * Otherwise, just print out the return code
2455 ND_PRINT(" errcode");
2461 * Check to see if this is a Ubik opcode.
2465 is_ubik(uint32_t opcode
)
2467 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2468 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2475 * Handle Ubik opcodes to any one of the replicated database services
2479 ubik_print(netdissect_options
*ndo
,
2486 * Print out the afs call we're invoking. The table used here was
2487 * gleaned from ubik/ubik_int.xg
2490 /* Every function that calls this function first makes a bounds check
2491 * for (sizeof(rx_header) + 4) bytes, so long as it remains this way
2492 * the line below will not over-read.
2494 ubik_op
= GET_BE_U_4(bp
+ sizeof(struct rx_header
));
2496 ND_PRINT(" ubik call %s", tok2str(ubik_req
, "op#%u", ubik_op
));
2499 * Decode some of the arguments to the Ubik calls
2502 bp
+= sizeof(struct rx_header
) + 4;
2505 case 10000: /* Beacon */
2506 temp
= GET_BE_U_4(bp
);
2507 bp
+= sizeof(uint32_t);
2508 ND_PRINT(" syncsite %s", temp
? "yes" : "no");
2509 ND_PRINT(" votestart");
2511 ND_PRINT(" dbversion");
2516 case 10003: /* Get sync site */
2520 case 20000: /* Begin */
2521 case 20001: /* Commit */
2522 case 20007: /* Abort */
2523 case 20008: /* Release locks */
2524 case 20010: /* Writev */
2528 case 20002: /* Lock */
2535 ND_PRINT(" length");
2537 temp
= GET_BE_U_4(bp
);
2538 bp
+= sizeof(uint32_t);
2539 tok2str(ubik_lock_types
, "type %u", temp
);
2541 case 20003: /* Write */
2549 case 20005: /* Get file */
2553 case 20006: /* Send file */
2556 ND_PRINT(" length");
2558 ND_PRINT(" dbversion");
2561 case 20009: /* Truncate */
2566 ND_PRINT(" length");
2569 case 20012: /* Set version */
2572 ND_PRINT(" oldversion");
2574 ND_PRINT(" newversion");
2584 ND_PRINT(" [|ubik]");
2588 * Handle Ubik replies to any one of the replicated database services
2592 ubik_reply_print(netdissect_options
*ndo
,
2593 const u_char
*bp
, u_int length
, uint32_t opcode
)
2595 const struct rx_header
*rxh
;
2598 if (length
< sizeof(struct rx_header
))
2601 rxh
= (const struct rx_header
*) bp
;
2604 * Print out the ubik call we're invoking. This table was gleaned
2605 * from ubik/ubik_int.xg
2608 ND_PRINT(" ubik reply %s", tok2str(ubik_req
, "op#%u", opcode
));
2610 type
= GET_U_1(rxh
->type
);
2611 bp
+= sizeof(struct rx_header
);
2614 * If it was a data packet, print out the arguments to the Ubik calls
2617 if (type
== RX_PACKET_TYPE_DATA
)
2619 case 10000: /* Beacon */
2620 ND_PRINT(" vote no");
2622 case 20004: /* Get version */
2623 ND_PRINT(" dbversion");
2631 * Otherwise, print out "yes" if it was a beacon packet (because
2632 * that's how yes votes are returned, go figure), otherwise
2633 * just print out the error code.
2638 case 10000: /* Beacon */
2639 ND_PRINT(" vote yes until");
2643 ND_PRINT(" errcode");
2650 ND_PRINT(" [|ubik]");
2654 * Handle RX ACK packets.
2658 rx_ack_print(netdissect_options
*ndo
,
2659 const u_char
*bp
, u_int length
)
2661 const struct rx_ackPacket
*rxa
;
2664 uint32_t firstPacket
;
2666 if (length
< sizeof(struct rx_header
))
2669 bp
+= sizeof(struct rx_header
);
2671 ND_TCHECK_LEN(bp
, sizeof(struct rx_ackPacket
));
2673 rxa
= (const struct rx_ackPacket
*) bp
;
2674 bp
+= sizeof(struct rx_ackPacket
);
2677 * Print out a few useful things from the ack packet structure
2680 if (ndo
->ndo_vflag
> 2)
2681 ND_PRINT(" bufspace %u maxskew %u",
2682 GET_BE_U_2(rxa
->bufferSpace
),
2683 GET_BE_U_2(rxa
->maxSkew
));
2685 firstPacket
= GET_BE_U_4(rxa
->firstPacket
);
2686 ND_PRINT(" first %u serial %u reason %s",
2687 firstPacket
, GET_BE_U_4(rxa
->serial
),
2688 tok2str(rx_ack_reasons
, "#%u", GET_U_1(rxa
->reason
)));
2691 * Okay, now we print out the ack array. The way _this_ works
2692 * is that we start at "first", and step through the ack array.
2693 * If we have a contiguous range of acks/nacks, try to
2694 * collapse them into a range.
2696 * If you're really clever, you might have noticed that this
2697 * doesn't seem quite correct. Specifically, due to structure
2698 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2699 * yield the start of the ack array (because RX_MAXACKS is 255
2700 * and the structure will likely get padded to a 2 or 4 byte
2701 * boundary). However, this is the way it's implemented inside
2702 * of AFS - the start of the extra fields are at
2703 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2704 * the exact start of the ack array. Sigh. That's why we aren't
2705 * using bp, but instead use rxa->acks[]. But nAcks gets added
2706 * to bp after this, so bp ends up at the right spot. Go figure.
2709 nAcks
= GET_U_1(rxa
->nAcks
);
2712 ND_TCHECK_LEN(bp
, nAcks
);
2715 * Sigh, this is gross, but it seems to work to collapse
2719 for (i
= 0, start
= last
= -2; i
< nAcks
; i
++)
2720 if (GET_U_1(bp
+ i
) == RX_ACK_TYPE_ACK
) {
2723 * I figured this deserved _some_ explanation.
2724 * First, print "acked" and the packet seq
2725 * number if this is the first time we've
2726 * seen an acked packet.
2730 ND_PRINT(" acked %u", firstPacket
+ i
);
2735 * Otherwise, if there is a skip in
2736 * the range (such as an nacked packet in
2737 * the middle of some acked packets),
2738 * then print the current packet number
2739 * separated from the last number by
2743 else if (last
!= i
- 1) {
2744 ND_PRINT(",%u", firstPacket
+ i
);
2749 * We always set last to the value of
2750 * the last ack we saw. Conversely, start
2751 * is set to the value of the first ack
2752 * we saw in a range.
2758 * Okay, this bit a code gets executed when
2759 * we hit a nack ... in _this_ case we
2760 * want to print out the range of packets
2761 * that were acked, so we need to print
2762 * the _previous_ packet number separated
2763 * from the first by a dash (-). Since we
2764 * already printed the first packet above,
2765 * just print the final packet. Don't
2766 * do this if there will be a single-length
2769 } else if (last
== i
- 1 && start
!= last
)
2770 ND_PRINT("-%u", firstPacket
+ i
- 1);
2773 * So, what's going on here? We ran off the end of the
2774 * ack list, and if we got a range we need to finish it up.
2775 * So we need to determine if the last packet in the list
2776 * was an ack (if so, then last will be set to it) and
2777 * we need to see if the last range didn't start with the
2778 * last packet (because if it _did_, then that would mean
2779 * that the packet number has already been printed and
2780 * we don't need to print it again).
2783 if (last
== i
- 1 && start
!= last
)
2784 ND_PRINT("-%u", firstPacket
+ i
- 1);
2787 * Same as above, just without comments
2790 for (i
= 0, start
= last
= -2; i
< nAcks
; i
++)
2791 if (GET_U_1(bp
+ i
) == RX_ACK_TYPE_NACK
) {
2793 ND_PRINT(" nacked %u", firstPacket
+ i
);
2795 } else if (last
!= i
- 1) {
2796 ND_PRINT(",%u", firstPacket
+ i
);
2800 } else if (last
== i
- 1 && start
!= last
)
2801 ND_PRINT("-%u", firstPacket
+ i
- 1);
2803 if (last
== i
- 1 && start
!= last
)
2804 ND_PRINT("-%u", firstPacket
+ i
- 1);
2813 * These are optional fields; depending on your version of AFS,
2814 * you may or may not see them
2817 #define TRUNCRET(n) if (ndo->ndo_snapend - bp + 1 <= n) return;
2819 if (ndo
->ndo_vflag
> 1) {
2825 ND_PRINT(" maxmtu");
2833 ND_PRINT(" maxpackets");
2840 ND_PRINT(" [|ack]");