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 * This code unmangles RX packets. RX is the mutant form of RPC that AFS
25 * uses to communicate between clients and servers.
27 * In this code, I mainly concern myself with decoding the AFS calls, not
28 * with the guts of RX, per se.
30 * Bah. If I never look at rx_packet.h again, it will be too soon.
32 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
35 #include <sys/cdefs.h>
37 __RCSID("$NetBSD: print-rx.c,v 1.5 2014/11/20 03:05:03 christos Exp $");
40 #define NETDISSECT_REWORKED
48 #include <tcpdump-stdinc.h>
50 #include "interface.h"
51 #include "addrtoname.h"
56 #define FS_RX_PORT 7000
57 #define CB_RX_PORT 7001
58 #define PROT_RX_PORT 7002
59 #define VLDB_RX_PORT 7003
60 #define KAUTH_RX_PORT 7004
61 #define VOL_RX_PORT 7005
62 #define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
63 #define BOS_RX_PORT 7007
65 #define AFSNAMEMAX 256
66 #define AFSOPAQUEMAX 1024
70 #define BOSNAMEMAX 256
72 #define PRSFS_READ 1 /* Read files */
73 #define PRSFS_WRITE 2 /* Write files */
74 #define PRSFS_INSERT 4 /* Insert files into a directory */
75 #define PRSFS_LOOKUP 8 /* Lookup files into a directory */
76 #define PRSFS_DELETE 16 /* Delete files */
77 #define PRSFS_LOCK 32 /* Lock files */
78 #define PRSFS_ADMINISTER 64 /* Change ACL's */
87 #define RX_PACKET_TYPE_DATA 1
88 #define RX_PACKET_TYPE_ACK 2
89 #define RX_PACKET_TYPE_BUSY 3
90 #define RX_PACKET_TYPE_ABORT 4
91 #define RX_PACKET_TYPE_ACKALL 5
92 #define RX_PACKET_TYPE_CHALLENGE 6
93 #define RX_PACKET_TYPE_RESPONSE 7
94 #define RX_PACKET_TYPE_DEBUG 8
95 #define RX_PACKET_TYPE_PARAMS 9
96 #define RX_PACKET_TYPE_VERSION 13
98 #define RX_CLIENT_INITIATED 1
99 #define RX_REQUEST_ACK 2
100 #define RX_LAST_PACKET 4
101 #define RX_MORE_PACKETS 8
102 #define RX_FREE_PACKET 16
103 #define RX_SLOW_START_OK 32
104 #define RX_JUMBO_PACKET 32
106 uint8_t securityIndex
;
107 uint16_t spare
; /* How clever: even though the AFS */
108 uint16_t serviceId
; /* header files indicate that the */
109 }; /* serviceId is first, it's really */
110 /* encoded _after_ the spare field */
111 /* I wasted a day figuring that out! */
113 #define NUM_RX_FLAGS 7
115 #define RX_MAXACKS 255
117 struct rx_ackPacket
{
118 uint16_t bufferSpace
; /* Number of packet buffers available */
119 uint16_t maxSkew
; /* Max diff between ack'd packet and */
120 /* highest packet received */
121 uint32_t firstPacket
; /* The first packet in ack list */
122 uint32_t previousPacket
; /* Previous packet recv'd (obsolete) */
123 uint32_t serial
; /* # of packet that prompted the ack */
124 uint8_t reason
; /* Reason for acknowledgement */
125 uint8_t nAcks
; /* Number of acknowledgements */
126 uint8_t acks
[RX_MAXACKS
]; /* Up to RX_MAXACKS acknowledgements */
130 * Values for the acks array
133 #define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
134 #define RX_ACK_TYPE_ACK 1 /* I have this packet */
136 static const struct tok rx_types
[] = {
137 { RX_PACKET_TYPE_DATA
, "data" },
138 { RX_PACKET_TYPE_ACK
, "ack" },
139 { RX_PACKET_TYPE_BUSY
, "busy" },
140 { RX_PACKET_TYPE_ABORT
, "abort" },
141 { RX_PACKET_TYPE_ACKALL
, "ackall" },
142 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
143 { RX_PACKET_TYPE_RESPONSE
, "response" },
144 { RX_PACKET_TYPE_DEBUG
, "debug" },
145 { RX_PACKET_TYPE_PARAMS
, "params" },
146 { RX_PACKET_TYPE_VERSION
, "version" },
150 static const struct double_tok
{
151 int flag
; /* Rx flag */
152 int packetType
; /* Packet type */
153 const char *s
; /* Flag string */
155 { RX_CLIENT_INITIATED
, 0, "client-init" },
156 { RX_REQUEST_ACK
, 0, "req-ack" },
157 { RX_LAST_PACKET
, 0, "last-pckt" },
158 { RX_MORE_PACKETS
, 0, "more-pckts" },
159 { RX_FREE_PACKET
, 0, "free-pckt" },
160 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
161 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
164 static const struct tok fs_req
[] = {
165 { 130, "fetch-data" },
166 { 131, "fetch-acl" },
167 { 132, "fetch-status" },
168 { 133, "store-data" },
169 { 134, "store-acl" },
170 { 135, "store-status" },
171 { 136, "remove-file" },
172 { 137, "create-file" },
178 { 143, "oldsetlock" },
179 { 144, "oldextlock" },
180 { 145, "oldrellock" },
181 { 146, "get-stats" },
183 { 148, "get-vlinfo" },
184 { 149, "get-vlstats" },
185 { 150, "set-vlstats" },
186 { 151, "get-rootvl" },
187 { 152, "check-token" },
189 { 154, "nget-vlinfo" },
190 { 155, "bulk-stat" },
194 { 159, "xstat-ver" },
195 { 160, "get-xstat" },
196 { 161, "dfs-lookup" },
197 { 162, "dfs-flushcps" },
198 { 163, "dfs-symlink" },
199 { 220, "residency" },
200 { 65536, "inline-bulk-status" },
201 { 65537, "fetch-data-64" },
202 { 65538, "store-data-64" },
203 { 65539, "give-up-all-cbs" },
204 { 65540, "get-caps" },
205 { 65541, "cb-rx-conn-addr" },
209 static const struct tok cb_req
[] = {
218 { 212, "whoareyou" },
220 { 214, "probeuuid" },
221 { 215, "getsrvprefs" },
222 { 216, "getcellservdb" },
223 { 217, "getlocalcell" },
224 { 218, "getcacheconf" },
225 { 65536, "getce64" },
226 { 65537, "getcellbynum" },
227 { 65538, "tellmeaboutyourself" },
231 static const struct tok pt_req
[] = {
233 { 501, "where-is-it" },
234 { 502, "dump-entry" },
235 { 503, "add-to-group" },
236 { 504, "name-to-id" },
237 { 505, "id-to-name" },
239 { 507, "remove-from-group" },
241 { 509, "new-entry" },
244 { 512, "list-entry" },
245 { 513, "change-entry" },
246 { 514, "list-elements" },
247 { 515, "same-mbr-of" },
248 { 516, "set-fld-sentry" },
249 { 517, "list-owned" },
251 { 519, "get-host-cps" },
252 { 520, "update-entry" },
253 { 521, "list-entries" },
254 { 530, "list-super-groups" },
258 static const struct tok vldb_req
[] = {
259 { 501, "create-entry" },
260 { 502, "delete-entry" },
261 { 503, "get-entry-by-id" },
262 { 504, "get-entry-by-name" },
263 { 505, "get-new-volume-id" },
264 { 506, "replace-entry" },
265 { 507, "update-entry" },
267 { 509, "releaselock" },
268 { 510, "list-entry" },
269 { 511, "list-attrib" },
270 { 512, "linked-list" },
271 { 513, "get-stats" },
273 { 515, "get-addrs" },
274 { 516, "change-addr" },
275 { 517, "create-entry-n" },
276 { 518, "get-entry-by-id-n" },
277 { 519, "get-entry-by-name-n" },
278 { 520, "replace-entry-n" },
279 { 521, "list-entry-n" },
280 { 522, "list-attrib-n" },
281 { 523, "linked-list-n" },
282 { 524, "update-entry-by-name" },
283 { 525, "create-entry-u" },
284 { 526, "get-entry-by-id-u" },
285 { 527, "get-entry-by-name-u" },
286 { 528, "replace-entry-u" },
287 { 529, "list-entry-u" },
288 { 530, "list-attrib-u" },
289 { 531, "linked-list-u" },
291 { 533, "get-addrs-u" },
292 { 534, "list-attrib-n2" },
296 static const struct tok kauth_req
[] = {
298 { 21, "authenticate" },
299 { 22, "authenticate-v2" },
301 { 3, "get-ticket-old" },
302 { 23, "get-ticket" },
305 { 6, "create-user" },
306 { 7, "delete-user" },
312 { 13, "get-random-key" },
314 { 15, "lock-status" },
318 static const struct tok vol_req
[] = {
319 { 100, "create-volume" },
320 { 101, "delete-volume" },
323 { 104, "end-trans" },
325 { 106, "set-flags" },
326 { 107, "get-flags" },
327 { 108, "trans-create" },
329 { 110, "get-nth-volume" },
330 { 111, "set-forwarding" },
332 { 113, "get-status" },
333 { 114, "sig-restore" },
334 { 115, "list-partitions" },
335 { 116, "list-volumes" },
336 { 117, "set-id-types" },
338 { 119, "partition-info" },
340 { 121, "list-one-volume" },
343 { 124, "x-list-volumes" },
344 { 125, "x-list-one-volume" },
346 { 127, "x-list-partitions" },
347 { 128, "forward-multiple" },
348 { 65536, "convert-ro" },
349 { 65537, "get-size" },
350 { 65538, "dump-v2" },
354 static const struct tok bos_req
[] = {
355 { 80, "create-bnode" },
356 { 81, "delete-bnode" },
357 { 82, "set-status" },
358 { 83, "get-status" },
359 { 84, "enumerate-instance" },
360 { 85, "get-instance-info" },
361 { 86, "get-instance-parm" },
362 { 87, "add-superuser" },
363 { 88, "delete-superuser" },
364 { 89, "list-superusers" },
367 { 92, "delete-key" },
368 { 93, "set-cell-name" },
369 { 94, "get-cell-name" },
370 { 95, "get-cell-host" },
371 { 96, "add-cell-host" },
372 { 97, "delete-cell-host" },
373 { 98, "set-t-status" },
374 { 99, "shutdown-all" },
375 { 100, "restart-all" },
376 { 101, "startup-all" },
377 { 102, "set-noauth-flag" },
380 { 105, "start-bozo-install" },
381 { 106, "uninstall" },
382 { 107, "get-dates" },
385 { 110, "set-restart-time" },
386 { 111, "get-restart-time" },
387 { 112, "start-bozo-log" },
389 { 114, "get-instance-strings" },
390 { 115, "get-restricted" },
391 { 116, "set-restricted" },
395 static const struct tok ubik_req
[] = {
396 { 10000, "vote-beacon" },
397 { 10001, "vote-debug-old" },
398 { 10002, "vote-sdebug-old" },
399 { 10003, "vote-getsyncsite" },
400 { 10004, "vote-debug" },
401 { 10005, "vote-sdebug" },
402 { 10006, "vote-xdebug" },
403 { 10007, "vote-xsdebug" },
404 { 20000, "disk-begin" },
405 { 20001, "disk-commit" },
406 { 20002, "disk-lock" },
407 { 20003, "disk-write" },
408 { 20004, "disk-getversion" },
409 { 20005, "disk-getfile" },
410 { 20006, "disk-sendfile" },
411 { 20007, "disk-abort" },
412 { 20008, "disk-releaselocks" },
413 { 20009, "disk-truncate" },
414 { 20010, "disk-probe" },
415 { 20011, "disk-writev" },
416 { 20012, "disk-interfaceaddr" },
417 { 20013, "disk-setversion" },
421 #define VOTE_LOW 10000
422 #define VOTE_HIGH 10007
423 #define DISK_LOW 20000
424 #define DISK_HIGH 20013
426 static const struct tok cb_types
[] = {
433 static const struct tok ubik_lock_types
[] = {
440 static const char *voltype
[] = { "read-write", "read-only", "backup" };
442 static const struct tok afs_fs_errors
[] = {
443 { 101, "salvage volume" },
444 { 102, "no such vnode" },
445 { 103, "no such volume" },
446 { 104, "volume exist" },
447 { 105, "no service" },
448 { 106, "volume offline" },
449 { 107, "voline online" },
451 { 109, "diskquota exceeded" },
452 { 110, "volume busy" },
453 { 111, "volume moved" },
454 { 112, "AFS IO error" },
455 { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */
460 * Reasons for acknowledging a packet
463 static const struct tok rx_ack_reasons
[] = {
464 { 1, "ack requested" },
465 { 2, "duplicate packet" },
466 { 3, "out of sequence" },
467 { 4, "exceeds window" },
468 { 5, "no buffer space" },
470 { 7, "ping response" },
477 * Cache entries we keep around so we can figure out the RX opcode
478 * numbers for replies. This allows us to make sense of RX reply packets.
481 struct rx_cache_entry
{
482 uint32_t callnum
; /* Call number (net order) */
483 struct in_addr client
; /* client IP address (net order) */
484 struct in_addr server
; /* server IP address (net order) */
485 int dport
; /* server port (host order) */
486 u_short serviceId
; /* Service identifier (net order) */
487 uint32_t opcode
; /* RX opcode (host order) */
490 #define RX_CACHE_SIZE 64
492 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
494 static int rx_cache_next
= 0;
495 static int rx_cache_hint
= 0;
496 static void rx_cache_insert(netdissect_options
*, const u_char
*, const struct ip
*, int);
497 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
500 static void fs_print(netdissect_options
*, const u_char
*, int);
501 static void fs_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
502 static void acl_print(netdissect_options
*, u_char
*, int, u_char
*);
503 static void cb_print(netdissect_options
*, const u_char
*, int);
504 static void cb_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
505 static void prot_print(netdissect_options
*, const u_char
*, int);
506 static void prot_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
507 static void vldb_print(netdissect_options
*, const u_char
*, int);
508 static void vldb_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
509 static void kauth_print(netdissect_options
*, const u_char
*, int);
510 static void kauth_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
511 static void vol_print(netdissect_options
*, const u_char
*, int);
512 static void vol_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
513 static void bos_print(netdissect_options
*, const u_char
*, int);
514 static void bos_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
515 static void ubik_print(netdissect_options
*, const u_char
*);
516 static void ubik_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
518 static void rx_ack_print(netdissect_options
*, const u_char
*, int);
520 static int is_ubik(uint32_t);
523 * Handle the rx-level packet. See if we know what port it's going to so
524 * we can peek at the afs call inside
528 rx_print(netdissect_options
*ndo
,
529 register const u_char
*bp
, int length
, int sport
, int dport
,
532 register struct rx_header
*rxh
;
536 if (ndo
->ndo_snapend
- bp
< (int)sizeof (struct rx_header
)) {
537 ND_PRINT((ndo
, " [|rx] (%d)", length
));
541 rxh
= (struct rx_header
*) bp
;
543 ND_PRINT((ndo
, " rx %s", tok2str(rx_types
, "type %d", rxh
->type
)));
545 if (ndo
->ndo_vflag
) {
548 if (ndo
->ndo_vflag
> 1)
549 ND_PRINT((ndo
, " cid %08x call# %d",
550 (int) EXTRACT_32BITS(&rxh
->cid
),
551 (int) EXTRACT_32BITS(&rxh
->callNumber
)));
553 ND_PRINT((ndo
, " seq %d ser %d",
554 (int) EXTRACT_32BITS(&rxh
->seq
),
555 (int) EXTRACT_32BITS(&rxh
->serial
)));
557 if (ndo
->ndo_vflag
> 2)
558 ND_PRINT((ndo
, " secindex %d serviceid %hu",
559 (int) rxh
->securityIndex
,
560 EXTRACT_16BITS(&rxh
->serviceId
)));
562 if (ndo
->ndo_vflag
> 1)
563 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
564 if (rxh
->flags
& rx_flags
[i
].flag
&&
565 (!rx_flags
[i
].packetType
||
566 rxh
->type
== rx_flags
[i
].packetType
)) {
569 ND_PRINT((ndo
, " "));
571 ND_PRINT((ndo
, ","));
573 ND_PRINT((ndo
, "<%s>", rx_flags
[i
].s
));
579 * Try to handle AFS calls that we know about. Check the destination
580 * port and make sure it's a data packet. Also, make sure the
581 * seq number is 1 (because otherwise it's a continuation packet,
582 * and we can't interpret that). Also, seems that reply packets
583 * do not have the client-init flag set, so we check for that
587 if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
588 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
589 rxh
->flags
& RX_CLIENT_INITIATED
) {
592 * Insert this call into the call cache table, so we
593 * have a chance to print out replies
596 rx_cache_insert(ndo
, bp
, (const struct ip
*) bp2
, dport
);
599 case FS_RX_PORT
: /* AFS file service */
600 fs_print(ndo
, bp
, length
);
602 case CB_RX_PORT
: /* AFS callback service */
603 cb_print(ndo
, bp
, length
);
605 case PROT_RX_PORT
: /* AFS protection service */
606 prot_print(ndo
, bp
, length
);
608 case VLDB_RX_PORT
: /* AFS VLDB service */
609 vldb_print(ndo
, bp
, length
);
611 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
612 kauth_print(ndo
, bp
, length
);
614 case VOL_RX_PORT
: /* AFS Volume service */
615 vol_print(ndo
, bp
, length
);
617 case BOS_RX_PORT
: /* AFS BOS service */
618 bos_print(ndo
, bp
, length
);
625 * If it's a reply (client-init is _not_ set, but seq is one)
626 * then look it up in the cache. If we find it, call the reply
627 * printing functions Note that we handle abort packets here,
628 * because printing out the return code can be useful at times.
631 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
632 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
633 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
634 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
635 rx_cache_find(rxh
, (const struct ip
*) bp2
,
639 case FS_RX_PORT
: /* AFS file service */
640 fs_reply_print(ndo
, bp
, length
, opcode
);
642 case CB_RX_PORT
: /* AFS callback service */
643 cb_reply_print(ndo
, bp
, length
, opcode
);
645 case PROT_RX_PORT
: /* AFS PT service */
646 prot_reply_print(ndo
, bp
, length
, opcode
);
648 case VLDB_RX_PORT
: /* AFS VLDB service */
649 vldb_reply_print(ndo
, bp
, length
, opcode
);
651 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
652 kauth_reply_print(ndo
, bp
, length
, opcode
);
654 case VOL_RX_PORT
: /* AFS Volume service */
655 vol_reply_print(ndo
, bp
, length
, opcode
);
657 case BOS_RX_PORT
: /* AFS BOS service */
658 bos_reply_print(ndo
, bp
, length
, opcode
);
665 * If it's an RX ack packet, then use the appropriate ack decoding
666 * function (there isn't any service-specific information in the
667 * ack packet, so we can use one for all AFS services)
670 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
671 rx_ack_print(ndo
, bp
, length
);
674 ND_PRINT((ndo
, " (%d)", length
));
678 * Insert an entry into the cache. Taken from print-nfs.c
682 rx_cache_insert(netdissect_options
*ndo
,
683 const u_char
*bp
, const struct ip
*ip
, int dport
)
685 struct rx_cache_entry
*rxent
;
686 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
688 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t)))
691 rxent
= &rx_cache
[rx_cache_next
];
693 if (++rx_cache_next
>= RX_CACHE_SIZE
)
696 rxent
->callnum
= rxh
->callNumber
;
697 rxent
->client
= ip
->ip_src
;
698 rxent
->server
= ip
->ip_dst
;
699 rxent
->dport
= dport
;
700 rxent
->serviceId
= rxh
->serviceId
;
701 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
705 * Lookup an entry in the cache. Also taken from print-nfs.c
707 * Note that because this is a reply, we're looking at the _source_
712 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
716 struct rx_cache_entry
*rxent
;
717 uint32_t clip
= ip
->ip_dst
.s_addr
;
718 uint32_t sip
= ip
->ip_src
.s_addr
;
720 /* Start the search where we last left off */
724 rxent
= &rx_cache
[i
];
725 if (rxent
->callnum
== rxh
->callNumber
&&
726 rxent
->client
.s_addr
== clip
&&
727 rxent
->server
.s_addr
== sip
&&
728 rxent
->serviceId
== rxh
->serviceId
&&
729 rxent
->dport
== sport
) {
731 /* We got a match! */
734 *opcode
= rxent
->opcode
;
737 if (++i
>= RX_CACHE_SIZE
)
739 } while (i
!= rx_cache_hint
);
741 /* Our search failed */
746 * These extrememly grody macros handle the printing of various AFS stuff.
749 #define FIDOUT() { unsigned long n1, n2, n3; \
750 ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
751 n1 = EXTRACT_32BITS(bp); \
752 bp += sizeof(int32_t); \
753 n2 = EXTRACT_32BITS(bp); \
754 bp += sizeof(int32_t); \
755 n3 = EXTRACT_32BITS(bp); \
756 bp += sizeof(int32_t); \
757 ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \
760 #define STROUT(MAX) { unsigned int i; \
761 ND_TCHECK2(bp[0], sizeof(int32_t)); \
762 i = EXTRACT_32BITS(bp); \
765 bp += sizeof(int32_t); \
766 ND_PRINT((ndo, " \"")); \
767 if (fn_printn(ndo, bp, i, ndo->ndo_snapend)) \
769 ND_PRINT((ndo, "\"")); \
770 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
773 #define INTOUT() { int i; \
774 ND_TCHECK2(bp[0], sizeof(int32_t)); \
775 i = (int) EXTRACT_32BITS(bp); \
776 bp += sizeof(int32_t); \
777 ND_PRINT((ndo, " %d", i)); \
780 #define UINTOUT() { unsigned long i; \
781 ND_TCHECK2(bp[0], sizeof(int32_t)); \
782 i = EXTRACT_32BITS(bp); \
783 bp += sizeof(int32_t); \
784 ND_PRINT((ndo, " %lu", i)); \
787 #define UINT64OUT() { uint64_t i; \
788 ND_TCHECK2(bp[0], sizeof(uint64_t)); \
789 i = EXTRACT_64BITS(bp); \
790 bp += sizeof(uint64_t); \
791 ND_PRINT((ndo, " %" PRIu64, i)); \
794 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
795 ND_TCHECK2(bp[0], sizeof(int32_t)); \
796 t = (time_t) EXTRACT_32BITS(bp); \
797 bp += sizeof(int32_t); \
798 tm = localtime(&t); \
799 strftime(str, 256, "%Y/%m/%d %T", tm); \
800 ND_PRINT((ndo, " %s", str)); \
803 #define STOREATTROUT() { unsigned long mask, i; \
804 ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \
805 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
806 if (mask) ND_PRINT((ndo, " StoreStatus")); \
807 if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \
808 else bp += sizeof(int32_t); \
809 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
810 if (mask & 2) ND_PRINT((ndo, " owner %lu", i)); \
811 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
812 if (mask & 4) ND_PRINT((ndo, " group %lu", i)); \
813 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
814 if (mask & 8) ND_PRINT((ndo, " mode %lo", i & 07777)); \
815 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
816 if (mask & 16) ND_PRINT((ndo, " segsize %lu", i)); \
817 /* undocumented in 3.3 docu */ \
818 if (mask & 1024) ND_PRINT((ndo, " fsync")); \
821 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
822 ND_TCHECK2(bp[0], sizeof(int32_t) * 2); \
823 epoch = EXTRACT_32BITS(bp); \
824 bp += sizeof(int32_t); \
825 counter = EXTRACT_32BITS(bp); \
826 bp += sizeof(int32_t); \
827 ND_PRINT((ndo, " %d.%d", epoch, counter)); \
830 #define AFSUUIDOUT() {uint32_t temp; int i; \
831 ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \
832 temp = EXTRACT_32BITS(bp); \
833 bp += sizeof(uint32_t); \
834 ND_PRINT((ndo, " %08x", temp)); \
835 temp = EXTRACT_32BITS(bp); \
836 bp += sizeof(uint32_t); \
837 ND_PRINT((ndo, "%04x", temp)); \
838 temp = EXTRACT_32BITS(bp); \
839 bp += sizeof(uint32_t); \
840 ND_PRINT((ndo, "%04x", temp)); \
841 for (i = 0; i < 8; i++) { \
842 temp = EXTRACT_32BITS(bp); \
843 bp += sizeof(uint32_t); \
844 ND_PRINT((ndo, "%02x", (unsigned char) temp)); \
849 * This is the sickest one of all
852 #define VECOUT(MAX) { u_char *sp; \
853 u_char s[AFSNAMEMAX]; \
855 if ((MAX) + 1 > sizeof(s)) \
857 ND_TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
859 for (k = 0; k < (MAX); k++) { \
860 *sp++ = (u_char) EXTRACT_32BITS(bp); \
861 bp += sizeof(int32_t); \
864 ND_PRINT((ndo, " \"")); \
865 fn_print(ndo, s, NULL); \
866 ND_PRINT((ndo, "\"")); \
869 #define DESTSERVEROUT() { unsigned long n1, n2, n3; \
870 ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
871 n1 = EXTRACT_32BITS(bp); \
872 bp += sizeof(int32_t); \
873 n2 = EXTRACT_32BITS(bp); \
874 bp += sizeof(int32_t); \
875 n3 = EXTRACT_32BITS(bp); \
876 bp += sizeof(int32_t); \
877 ND_PRINT((ndo, " server %d:%d:%d", (int) n1, (int) n2, (int) n3)); \
881 * Handle calls to the AFS file service (fs)
885 fs_print(netdissect_options
*ndo
,
886 register const u_char
*bp
, int length
)
891 if (length
<= (int)sizeof(struct rx_header
))
894 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
899 * Print out the afs call we're invoking. The table used here was
900 * gleaned from fsint/afsint.xg
903 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
905 ND_PRINT((ndo
, " fs call %s", tok2str(fs_req
, "op#%d", fs_op
)));
908 * Print out arguments to some of the AFS calls. This stuff is
912 bp
+= sizeof(struct rx_header
) + 4;
915 * Sigh. This is gross. Ritchie forgive me.
919 case 130: /* Fetch data */
921 ND_PRINT((ndo
, " offset"));
923 ND_PRINT((ndo
, " length"));
926 case 131: /* Fetch ACL */
927 case 132: /* Fetch Status */
928 case 143: /* Old set lock */
929 case 144: /* Old extend lock */
930 case 145: /* Old release lock */
931 case 156: /* Set lock */
932 case 157: /* Extend lock */
933 case 158: /* Release lock */
936 case 135: /* Store status */
940 case 133: /* Store data */
943 ND_PRINT((ndo
, " offset"));
945 ND_PRINT((ndo
, " length"));
947 ND_PRINT((ndo
, " flen"));
950 case 134: /* Store ACL */
952 char a
[AFSOPAQUEMAX
+1];
954 ND_TCHECK2(bp
[0], 4);
955 i
= EXTRACT_32BITS(bp
);
956 bp
+= sizeof(int32_t);
957 ND_TCHECK2(bp
[0], i
);
958 i
= min(AFSOPAQUEMAX
, i
);
959 strncpy(a
, (char *) bp
, i
);
961 acl_print(ndo
, (u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
964 case 137: /* Create file */
965 case 141: /* MakeDir */
970 case 136: /* Remove file */
971 case 142: /* Remove directory */
975 case 138: /* Rename file */
976 ND_PRINT((ndo
, " old"));
979 ND_PRINT((ndo
, " new"));
983 case 139: /* Symlink */
986 ND_PRINT((ndo
, " link to"));
992 ND_PRINT((ndo
, " link to"));
995 case 148: /* Get volume info */
998 case 149: /* Get volume stats */
999 case 150: /* Set volume stats */
1000 ND_PRINT((ndo
, " volid"));
1003 case 154: /* New get volume info */
1004 ND_PRINT((ndo
, " volname"));
1007 case 155: /* Bulk stat */
1008 case 65536: /* Inline bulk stat */
1011 ND_TCHECK2(bp
[0], 4);
1012 j
= EXTRACT_32BITS(bp
);
1013 bp
+= sizeof(int32_t);
1015 for (i
= 0; i
< j
; i
++) {
1018 ND_PRINT((ndo
, ","));
1021 ND_PRINT((ndo
, " <none!>"));
1023 case 65537: /* Fetch data 64 */
1025 ND_PRINT((ndo
, " offset"));
1027 ND_PRINT((ndo
, " length"));
1030 case 65538: /* Store data 64 */
1033 ND_PRINT((ndo
, " offset"));
1035 ND_PRINT((ndo
, " length"));
1037 ND_PRINT((ndo
, " flen"));
1040 case 65541: /* CallBack rx conn address */
1041 ND_PRINT((ndo
, " addr"));
1050 ND_PRINT((ndo
, " [|fs]"));
1054 * Handle replies to the AFS file service
1058 fs_reply_print(netdissect_options
*ndo
,
1059 register const u_char
*bp
, int length
, int32_t opcode
)
1062 struct rx_header
*rxh
;
1064 if (length
<= (int)sizeof(struct rx_header
))
1067 rxh
= (struct rx_header
*) bp
;
1070 * Print out the afs call we're invoking. The table used here was
1071 * gleaned from fsint/afsint.xg
1074 ND_PRINT((ndo
, " fs reply %s", tok2str(fs_req
, "op#%d", opcode
)));
1076 bp
+= sizeof(struct rx_header
);
1079 * If it was a data packet, interpret the response
1082 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
1084 case 131: /* Fetch ACL */
1086 char a
[AFSOPAQUEMAX
+1];
1087 ND_TCHECK2(bp
[0], 4);
1088 i
= EXTRACT_32BITS(bp
);
1089 bp
+= sizeof(int32_t);
1090 ND_TCHECK2(bp
[0], i
);
1091 i
= min(AFSOPAQUEMAX
, i
);
1092 strncpy(a
, (char *) bp
, i
);
1094 acl_print(ndo
, (u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1097 case 137: /* Create file */
1098 case 141: /* MakeDir */
1099 ND_PRINT((ndo
, " new"));
1102 case 151: /* Get root volume */
1103 ND_PRINT((ndo
, " root volume"));
1106 case 153: /* Get time */
1112 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1116 * Otherwise, just print out the return code
1118 ND_TCHECK2(bp
[0], sizeof(int32_t));
1119 i
= (int) EXTRACT_32BITS(bp
);
1120 bp
+= sizeof(int32_t);
1122 ND_PRINT((ndo
, " error %s", tok2str(afs_fs_errors
, "#%d", i
)));
1124 ND_PRINT((ndo
, " strange fs reply of type %d", rxh
->type
));
1130 ND_PRINT((ndo
, " [|fs]"));
1134 * Print out an AFS ACL string. An AFS ACL is a string that has the
1137 * <positive> <negative>
1141 * "positive" and "negative" are integers which contain the number of
1142 * positive and negative ACL's in the string. The uid/aclbits pair are
1143 * ASCII strings containing the UID/PTS record and and a ascii number
1144 * representing a logical OR of all the ACL permission bits
1148 acl_print(netdissect_options
*ndo
,
1149 u_char
*s
, int maxsize
, u_char
*end
)
1156 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1159 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1168 * This wacky order preserves the order used by the "fs" command
1171 #define ACLOUT(acl) \
1172 ND_PRINT((ndo, "%s%s%s%s%s%s%s", \
1173 acl & PRSFS_READ ? "r" : "", \
1174 acl & PRSFS_LOOKUP ? "l" : "", \
1175 acl & PRSFS_INSERT ? "i" : "", \
1176 acl & PRSFS_DELETE ? "d" : "", \
1177 acl & PRSFS_WRITE ? "w" : "", \
1178 acl & PRSFS_LOCK ? "k" : "", \
1179 acl & PRSFS_ADMINISTER ? "a" : ""));
1181 for (i
= 0; i
< pos
; i
++) {
1182 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1183 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1186 ND_PRINT((ndo
, " +{"));
1187 fn_print(ndo
, (u_char
*)user
, NULL
);
1188 ND_PRINT((ndo
, " "));
1190 ND_PRINT((ndo
, "}"));
1195 for (i
= 0; i
< neg
; i
++) {
1196 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1197 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1200 ND_PRINT((ndo
, " -{"));
1201 fn_print(ndo
, (u_char
*)user
, NULL
);
1202 ND_PRINT((ndo
, " "));
1204 ND_PRINT((ndo
, "}"));
1217 * Handle calls to the AFS callback service
1221 cb_print(netdissect_options
*ndo
,
1222 register const u_char
*bp
, int length
)
1227 if (length
<= (int)sizeof(struct rx_header
))
1230 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1235 * Print out the afs call we're invoking. The table used here was
1236 * gleaned from fsint/afscbint.xg
1239 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1241 ND_PRINT((ndo
, " cb call %s", tok2str(cb_req
, "op#%d", cb_op
)));
1243 bp
+= sizeof(struct rx_header
) + 4;
1246 * Print out the afs call we're invoking. The table used here was
1247 * gleaned from fsint/afscbint.xg
1251 case 204: /* Callback */
1254 ND_TCHECK2(bp
[0], 4);
1255 j
= EXTRACT_32BITS(bp
);
1256 bp
+= sizeof(int32_t);
1258 for (i
= 0; i
< j
; i
++) {
1261 ND_PRINT((ndo
, ","));
1265 ND_PRINT((ndo
, " <none!>"));
1267 j
= EXTRACT_32BITS(bp
);
1268 bp
+= sizeof(int32_t);
1271 ND_PRINT((ndo
, ";"));
1273 for (i
= 0; i
< j
; i
++) {
1274 ND_PRINT((ndo
, " ver"));
1276 ND_PRINT((ndo
, " expires"));
1278 ND_TCHECK2(bp
[0], 4);
1279 t
= EXTRACT_32BITS(bp
);
1280 bp
+= sizeof(int32_t);
1281 tok2str(cb_types
, "type %d", t
);
1285 ND_PRINT((ndo
, " afsuuid"));
1296 ND_PRINT((ndo
, " [|cb]"));
1300 * Handle replies to the AFS Callback Service
1304 cb_reply_print(netdissect_options
*ndo
,
1305 register const u_char
*bp
, int length
, int32_t opcode
)
1307 struct rx_header
*rxh
;
1309 if (length
<= (int)sizeof(struct rx_header
))
1312 rxh
= (struct rx_header
*) bp
;
1315 * Print out the afs call we're invoking. The table used here was
1316 * gleaned from fsint/afscbint.xg
1319 ND_PRINT((ndo
, " cb reply %s", tok2str(cb_req
, "op#%d", opcode
)));
1321 bp
+= sizeof(struct rx_header
);
1324 * If it was a data packet, interpret the response.
1327 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1329 case 213: /* InitCallBackState3 */
1337 * Otherwise, just print out the return code
1339 ND_PRINT((ndo
, " errcode"));
1346 ND_PRINT((ndo
, " [|cb]"));
1350 * Handle calls to the AFS protection database server
1354 prot_print(netdissect_options
*ndo
,
1355 register const u_char
*bp
, int length
)
1360 if (length
<= (int)sizeof(struct rx_header
))
1363 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1368 * Print out the afs call we're invoking. The table used here was
1369 * gleaned from ptserver/ptint.xg
1372 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1374 ND_PRINT((ndo
, " pt"));
1376 if (is_ubik(pt_op
)) {
1377 ubik_print(ndo
, bp
);
1381 ND_PRINT((ndo
, " call %s", tok2str(pt_req
, "op#%d", pt_op
)));
1384 * Decode some of the arguments to the PT calls
1387 bp
+= sizeof(struct rx_header
) + 4;
1390 case 500: /* I New User */
1392 ND_PRINT((ndo
, " id"));
1394 ND_PRINT((ndo
, " oldid"));
1397 case 501: /* Where is it */
1398 case 506: /* Delete */
1399 case 508: /* Get CPS */
1400 case 512: /* List entry */
1401 case 514: /* List elements */
1402 case 517: /* List owned */
1403 case 518: /* Get CPS2 */
1404 case 519: /* Get host CPS */
1405 case 530: /* List super groups */
1406 ND_PRINT((ndo
, " id"));
1409 case 502: /* Dump entry */
1410 ND_PRINT((ndo
, " pos"));
1413 case 503: /* Add to group */
1414 case 507: /* Remove from group */
1415 case 515: /* Is a member of? */
1416 ND_PRINT((ndo
, " uid"));
1418 ND_PRINT((ndo
, " gid"));
1421 case 504: /* Name to ID */
1424 ND_TCHECK2(bp
[0], 4);
1425 j
= EXTRACT_32BITS(bp
);
1426 bp
+= sizeof(int32_t);
1429 * Who designed this chicken-shit protocol?
1431 * Each character is stored as a 32-bit
1435 for (i
= 0; i
< j
; i
++) {
1439 ND_PRINT((ndo
, " <none!>"));
1442 case 505: /* Id to name */
1445 ND_PRINT((ndo
, " ids:"));
1446 ND_TCHECK2(bp
[0], 4);
1447 i
= EXTRACT_32BITS(bp
);
1448 bp
+= sizeof(int32_t);
1449 for (j
= 0; j
< i
; j
++)
1452 ND_PRINT((ndo
, " <none!>"));
1455 case 509: /* New entry */
1457 ND_PRINT((ndo
, " flag"));
1459 ND_PRINT((ndo
, " oid"));
1462 case 511: /* Set max */
1463 ND_PRINT((ndo
, " id"));
1465 ND_PRINT((ndo
, " gflag"));
1468 case 513: /* Change entry */
1469 ND_PRINT((ndo
, " id"));
1472 ND_PRINT((ndo
, " oldid"));
1474 ND_PRINT((ndo
, " newid"));
1477 case 520: /* Update entry */
1478 ND_PRINT((ndo
, " id"));
1490 ND_PRINT((ndo
, " [|pt]"));
1494 * Handle replies to the AFS protection service
1498 prot_reply_print(netdissect_options
*ndo
,
1499 register const u_char
*bp
, int length
, int32_t opcode
)
1501 struct rx_header
*rxh
;
1504 if (length
< (int)sizeof(struct rx_header
))
1507 rxh
= (struct rx_header
*) bp
;
1510 * Print out the afs call we're invoking. The table used here was
1511 * gleaned from ptserver/ptint.xg. Check to see if it's a
1512 * Ubik call, however.
1515 ND_PRINT((ndo
, " pt"));
1517 if (is_ubik(opcode
)) {
1518 ubik_reply_print(ndo
, bp
, length
, opcode
);
1522 ND_PRINT((ndo
, " reply %s", tok2str(pt_req
, "op#%d", opcode
)));
1524 bp
+= sizeof(struct rx_header
);
1527 * If it was a data packet, interpret the response
1530 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1532 case 504: /* Name to ID */
1535 ND_PRINT((ndo
, " ids:"));
1536 ND_TCHECK2(bp
[0], 4);
1537 i
= EXTRACT_32BITS(bp
);
1538 bp
+= sizeof(int32_t);
1539 for (j
= 0; j
< i
; j
++)
1542 ND_PRINT((ndo
, " <none!>"));
1545 case 505: /* ID to name */
1548 ND_TCHECK2(bp
[0], 4);
1549 j
= EXTRACT_32BITS(bp
);
1550 bp
+= sizeof(int32_t);
1553 * Who designed this chicken-shit protocol?
1555 * Each character is stored as a 32-bit
1559 for (i
= 0; i
< j
; i
++) {
1563 ND_PRINT((ndo
, " <none!>"));
1566 case 508: /* Get CPS */
1567 case 514: /* List elements */
1568 case 517: /* List owned */
1569 case 518: /* Get CPS2 */
1570 case 519: /* Get host CPS */
1573 ND_TCHECK2(bp
[0], 4);
1574 j
= EXTRACT_32BITS(bp
);
1575 bp
+= sizeof(int32_t);
1576 for (i
= 0; i
< j
; i
++) {
1580 ND_PRINT((ndo
, " <none!>"));
1583 case 510: /* List max */
1584 ND_PRINT((ndo
, " maxuid"));
1586 ND_PRINT((ndo
, " maxgid"));
1594 * Otherwise, just print out the return code
1596 ND_PRINT((ndo
, " errcode"));
1603 ND_PRINT((ndo
, " [|pt]"));
1607 * Handle calls to the AFS volume location database service
1611 vldb_print(netdissect_options
*ndo
,
1612 register const u_char
*bp
, int length
)
1617 if (length
<= (int)sizeof(struct rx_header
))
1620 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1625 * Print out the afs call we're invoking. The table used here was
1626 * gleaned from vlserver/vldbint.xg
1629 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1631 ND_PRINT((ndo
, " vldb"));
1633 if (is_ubik(vldb_op
)) {
1634 ubik_print(ndo
, bp
);
1637 ND_PRINT((ndo
, " call %s", tok2str(vldb_req
, "op#%d", vldb_op
)));
1640 * Decode some of the arguments to the VLDB calls
1643 bp
+= sizeof(struct rx_header
) + 4;
1646 case 501: /* Create new volume */
1647 case 517: /* Create entry N */
1650 case 502: /* Delete entry */
1651 case 503: /* Get entry by ID */
1652 case 507: /* Update entry */
1653 case 508: /* Set lock */
1654 case 509: /* Release lock */
1655 case 518: /* Get entry by ID N */
1656 ND_PRINT((ndo
, " volid"));
1658 ND_TCHECK2(bp
[0], sizeof(int32_t));
1659 i
= EXTRACT_32BITS(bp
);
1660 bp
+= sizeof(int32_t);
1662 ND_PRINT((ndo
, " type %s", voltype
[i
]));
1664 case 504: /* Get entry by name */
1665 case 519: /* Get entry by name N */
1666 case 524: /* Update entry by name */
1667 case 527: /* Get entry by name U */
1670 case 505: /* Get new vol id */
1671 ND_PRINT((ndo
, " bump"));
1674 case 506: /* Replace entry */
1675 case 520: /* Replace entry N */
1676 ND_PRINT((ndo
, " volid"));
1678 ND_TCHECK2(bp
[0], sizeof(int32_t));
1679 i
= EXTRACT_32BITS(bp
);
1680 bp
+= sizeof(int32_t);
1682 ND_PRINT((ndo
, " type %s", voltype
[i
]));
1685 case 510: /* List entry */
1686 case 521: /* List entry N */
1687 ND_PRINT((ndo
, " index"));
1697 ND_PRINT((ndo
, " [|vldb]"));
1701 * Handle replies to the AFS volume location database service
1705 vldb_reply_print(netdissect_options
*ndo
,
1706 register const u_char
*bp
, int length
, int32_t opcode
)
1708 struct rx_header
*rxh
;
1711 if (length
< (int)sizeof(struct rx_header
))
1714 rxh
= (struct rx_header
*) bp
;
1717 * Print out the afs call we're invoking. The table used here was
1718 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1719 * Ubik call, however.
1722 ND_PRINT((ndo
, " vldb"));
1724 if (is_ubik(opcode
)) {
1725 ubik_reply_print(ndo
, bp
, length
, opcode
);
1729 ND_PRINT((ndo
, " reply %s", tok2str(vldb_req
, "op#%d", opcode
)));
1731 bp
+= sizeof(struct rx_header
);
1734 * If it was a data packet, interpret the response
1737 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1739 case 510: /* List entry */
1740 ND_PRINT((ndo
, " count"));
1742 ND_PRINT((ndo
, " nextindex"));
1744 case 503: /* Get entry by id */
1745 case 504: /* Get entry by name */
1746 { unsigned long nservers
, j
;
1748 ND_TCHECK2(bp
[0], sizeof(int32_t));
1749 bp
+= sizeof(int32_t);
1750 ND_PRINT((ndo
, " numservers"));
1751 ND_TCHECK2(bp
[0], sizeof(int32_t));
1752 nservers
= EXTRACT_32BITS(bp
);
1753 bp
+= sizeof(int32_t);
1754 ND_PRINT((ndo
, " %lu", nservers
));
1755 ND_PRINT((ndo
, " servers"));
1756 for (i
= 0; i
< 8; i
++) {
1757 ND_TCHECK2(bp
[0], sizeof(int32_t));
1759 ND_PRINT((ndo
, " %s",
1760 intoa(((struct in_addr
*) bp
)->s_addr
)));
1761 bp
+= sizeof(int32_t);
1763 ND_PRINT((ndo
, " partitions"));
1764 for (i
= 0; i
< 8; i
++) {
1765 ND_TCHECK2(bp
[0], sizeof(int32_t));
1766 j
= EXTRACT_32BITS(bp
);
1767 if (i
< nservers
&& j
<= 26)
1768 ND_PRINT((ndo
, " %c", 'a' + (int)j
));
1769 else if (i
< nservers
)
1770 ND_PRINT((ndo
, " %lu", j
));
1771 bp
+= sizeof(int32_t);
1773 ND_TCHECK2(bp
[0], 8 * sizeof(int32_t));
1774 bp
+= 8 * sizeof(int32_t);
1775 ND_PRINT((ndo
, " rwvol"));
1777 ND_PRINT((ndo
, " rovol"));
1779 ND_PRINT((ndo
, " backup"));
1783 case 505: /* Get new volume ID */
1784 ND_PRINT((ndo
, " newvol"));
1787 case 521: /* List entry */
1788 case 529: /* List entry U */
1789 ND_PRINT((ndo
, " count"));
1791 ND_PRINT((ndo
, " nextindex"));
1793 case 518: /* Get entry by ID N */
1794 case 519: /* Get entry by name N */
1795 { unsigned long nservers
, j
;
1797 ND_PRINT((ndo
, " numservers"));
1798 ND_TCHECK2(bp
[0], sizeof(int32_t));
1799 nservers
= EXTRACT_32BITS(bp
);
1800 bp
+= sizeof(int32_t);
1801 ND_PRINT((ndo
, " %lu", nservers
));
1802 ND_PRINT((ndo
, " servers"));
1803 for (i
= 0; i
< 13; i
++) {
1804 ND_TCHECK2(bp
[0], sizeof(int32_t));
1806 ND_PRINT((ndo
, " %s",
1807 intoa(((struct in_addr
*) bp
)->s_addr
)));
1808 bp
+= sizeof(int32_t);
1810 ND_PRINT((ndo
, " partitions"));
1811 for (i
= 0; i
< 13; i
++) {
1812 ND_TCHECK2(bp
[0], sizeof(int32_t));
1813 j
= EXTRACT_32BITS(bp
);
1814 if (i
< nservers
&& j
<= 26)
1815 ND_PRINT((ndo
, " %c", 'a' + (int)j
));
1816 else if (i
< nservers
)
1817 ND_PRINT((ndo
, " %lu", j
));
1818 bp
+= sizeof(int32_t);
1820 ND_TCHECK2(bp
[0], 13 * sizeof(int32_t));
1821 bp
+= 13 * sizeof(int32_t);
1822 ND_PRINT((ndo
, " rwvol"));
1824 ND_PRINT((ndo
, " rovol"));
1826 ND_PRINT((ndo
, " backup"));
1830 case 526: /* Get entry by ID U */
1831 case 527: /* Get entry by name U */
1832 { unsigned long nservers
, j
;
1834 ND_PRINT((ndo
, " numservers"));
1835 ND_TCHECK2(bp
[0], sizeof(int32_t));
1836 nservers
= EXTRACT_32BITS(bp
);
1837 bp
+= sizeof(int32_t);
1838 ND_PRINT((ndo
, " %lu", nservers
));
1839 ND_PRINT((ndo
, " servers"));
1840 for (i
= 0; i
< 13; i
++) {
1842 ND_PRINT((ndo
, " afsuuid"));
1845 ND_TCHECK2(bp
[0], 44);
1849 ND_TCHECK2(bp
[0], 4 * 13);
1851 ND_PRINT((ndo
, " partitions"));
1852 for (i
= 0; i
< 13; i
++) {
1853 ND_TCHECK2(bp
[0], sizeof(int32_t));
1854 j
= EXTRACT_32BITS(bp
);
1855 if (i
< nservers
&& j
<= 26)
1856 ND_PRINT((ndo
, " %c", 'a' + (int)j
));
1857 else if (i
< nservers
)
1858 ND_PRINT((ndo
, " %lu", j
));
1859 bp
+= sizeof(int32_t);
1861 ND_TCHECK2(bp
[0], 13 * sizeof(int32_t));
1862 bp
+= 13 * sizeof(int32_t);
1863 ND_PRINT((ndo
, " rwvol"));
1865 ND_PRINT((ndo
, " rovol"));
1867 ND_PRINT((ndo
, " backup"));
1876 * Otherwise, just print out the return code
1878 ND_PRINT((ndo
, " errcode"));
1885 ND_PRINT((ndo
, " [|vldb]"));
1889 * Handle calls to the AFS Kerberos Authentication service
1893 kauth_print(netdissect_options
*ndo
,
1894 register const u_char
*bp
, int length
)
1898 if (length
<= (int)sizeof(struct rx_header
))
1901 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1906 * Print out the afs call we're invoking. The table used here was
1907 * gleaned from kauth/kauth.rg
1910 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1912 ND_PRINT((ndo
, " kauth"));
1914 if (is_ubik(kauth_op
)) {
1915 ubik_print(ndo
, bp
);
1920 ND_PRINT((ndo
, " call %s", tok2str(kauth_req
, "op#%d", kauth_op
)));
1923 * Decode some of the arguments to the KA calls
1926 bp
+= sizeof(struct rx_header
) + 4;
1929 case 1: /* Authenticate old */;
1930 case 21: /* Authenticate */
1931 case 22: /* Authenticate-V2 */
1932 case 2: /* Change PW */
1933 case 5: /* Set fields */
1934 case 6: /* Create user */
1935 case 7: /* Delete user */
1936 case 8: /* Get entry */
1937 case 14: /* Unlock */
1938 case 15: /* Lock status */
1939 ND_PRINT((ndo
, " principal"));
1943 case 3: /* GetTicket-old */
1944 case 23: /* GetTicket */
1947 ND_PRINT((ndo
, " kvno"));
1949 ND_PRINT((ndo
, " domain"));
1951 ND_TCHECK2(bp
[0], sizeof(int32_t));
1952 i
= (int) EXTRACT_32BITS(bp
);
1953 bp
+= sizeof(int32_t);
1954 ND_TCHECK2(bp
[0], i
);
1956 ND_PRINT((ndo
, " principal"));
1961 case 4: /* Set Password */
1962 ND_PRINT((ndo
, " principal"));
1965 ND_PRINT((ndo
, " kvno"));
1968 case 12: /* Get password */
1969 ND_PRINT((ndo
, " name"));
1979 ND_PRINT((ndo
, " [|kauth]"));
1983 * Handle replies to the AFS Kerberos Authentication Service
1987 kauth_reply_print(netdissect_options
*ndo
,
1988 register const u_char
*bp
, int length
, int32_t opcode
)
1990 struct rx_header
*rxh
;
1992 if (length
<= (int)sizeof(struct rx_header
))
1995 rxh
= (struct rx_header
*) bp
;
1998 * Print out the afs call we're invoking. The table used here was
1999 * gleaned from kauth/kauth.rg
2002 ND_PRINT((ndo
, " kauth"));
2004 if (is_ubik(opcode
)) {
2005 ubik_reply_print(ndo
, bp
, length
, opcode
);
2009 ND_PRINT((ndo
, " reply %s", tok2str(kauth_req
, "op#%d", opcode
)));
2011 bp
+= sizeof(struct rx_header
);
2014 * If it was a data packet, interpret the response.
2017 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2018 /* Well, no, not really. Leave this for later */
2022 * Otherwise, just print out the return code
2024 ND_PRINT((ndo
, " errcode"));
2031 ND_PRINT((ndo
, " [|kauth]"));
2035 * Handle calls to the AFS Volume location service
2039 vol_print(netdissect_options
*ndo
,
2040 register const u_char
*bp
, int length
)
2044 if (length
<= (int)sizeof(struct rx_header
))
2047 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
2052 * Print out the afs call we're invoking. The table used here was
2053 * gleaned from volser/volint.xg
2056 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2058 ND_PRINT((ndo
, " vol call %s", tok2str(vol_req
, "op#%d", vol_op
)));
2060 bp
+= sizeof(struct rx_header
) + 4;
2063 case 100: /* Create volume */
2064 ND_PRINT((ndo
, " partition"));
2066 ND_PRINT((ndo
, " name"));
2068 ND_PRINT((ndo
, " type"));
2070 ND_PRINT((ndo
, " parent"));
2073 case 101: /* Delete volume */
2074 case 107: /* Get flags */
2075 ND_PRINT((ndo
, " trans"));
2078 case 102: /* Restore */
2079 ND_PRINT((ndo
, " totrans"));
2081 ND_PRINT((ndo
, " flags"));
2084 case 103: /* Forward */
2085 ND_PRINT((ndo
, " fromtrans"));
2087 ND_PRINT((ndo
, " fromdate"));
2090 ND_PRINT((ndo
, " desttrans"));
2093 case 104: /* End trans */
2094 ND_PRINT((ndo
, " trans"));
2097 case 105: /* Clone */
2098 ND_PRINT((ndo
, " trans"));
2100 ND_PRINT((ndo
, " purgevol"));
2102 ND_PRINT((ndo
, " newtype"));
2104 ND_PRINT((ndo
, " newname"));
2107 case 106: /* Set flags */
2108 ND_PRINT((ndo
, " trans"));
2110 ND_PRINT((ndo
, " flags"));
2113 case 108: /* Trans create */
2114 ND_PRINT((ndo
, " vol"));
2116 ND_PRINT((ndo
, " partition"));
2118 ND_PRINT((ndo
, " flags"));
2121 case 109: /* Dump */
2122 case 655537: /* Get size */
2123 ND_PRINT((ndo
, " fromtrans"));
2125 ND_PRINT((ndo
, " fromdate"));
2128 case 110: /* Get n-th volume */
2129 ND_PRINT((ndo
, " index"));
2132 case 111: /* Set forwarding */
2133 ND_PRINT((ndo
, " tid"));
2135 ND_PRINT((ndo
, " newsite"));
2138 case 112: /* Get name */
2139 case 113: /* Get status */
2140 ND_PRINT((ndo
, " tid"));
2142 case 114: /* Signal restore */
2143 ND_PRINT((ndo
, " name"));
2145 ND_PRINT((ndo
, " type"));
2147 ND_PRINT((ndo
, " pid"));
2149 ND_PRINT((ndo
, " cloneid"));
2152 case 116: /* List volumes */
2153 ND_PRINT((ndo
, " partition"));
2155 ND_PRINT((ndo
, " flags"));
2158 case 117: /* Set id types */
2159 ND_PRINT((ndo
, " tid"));
2161 ND_PRINT((ndo
, " name"));
2163 ND_PRINT((ndo
, " type"));
2165 ND_PRINT((ndo
, " pid"));
2167 ND_PRINT((ndo
, " clone"));
2169 ND_PRINT((ndo
, " backup"));
2172 case 119: /* Partition info */
2173 ND_PRINT((ndo
, " name"));
2176 case 120: /* Reclone */
2177 ND_PRINT((ndo
, " tid"));
2180 case 121: /* List one volume */
2181 case 122: /* Nuke volume */
2182 case 124: /* Extended List volumes */
2183 case 125: /* Extended List one volume */
2184 case 65536: /* Convert RO to RW volume */
2185 ND_PRINT((ndo
, " partid"));
2187 ND_PRINT((ndo
, " volid"));
2190 case 123: /* Set date */
2191 ND_PRINT((ndo
, " tid"));
2193 ND_PRINT((ndo
, " date"));
2196 case 126: /* Set info */
2197 ND_PRINT((ndo
, " tid"));
2200 case 128: /* Forward multiple */
2201 ND_PRINT((ndo
, " fromtrans"));
2203 ND_PRINT((ndo
, " fromdate"));
2207 ND_TCHECK2(bp
[0], 4);
2208 j
= EXTRACT_32BITS(bp
);
2209 bp
+= sizeof(int32_t);
2210 for (i
= 0; i
< j
; i
++) {
2213 ND_PRINT((ndo
, ","));
2216 ND_PRINT((ndo
, " <none!>"));
2219 case 65538: /* Dump version 2 */
2220 ND_PRINT((ndo
, " fromtrans"));
2222 ND_PRINT((ndo
, " fromdate"));
2224 ND_PRINT((ndo
, " flags"));
2233 ND_PRINT((ndo
, " [|vol]"));
2237 * Handle replies to the AFS Volume Service
2241 vol_reply_print(netdissect_options
*ndo
,
2242 register const u_char
*bp
, int length
, int32_t opcode
)
2244 struct rx_header
*rxh
;
2246 if (length
<= (int)sizeof(struct rx_header
))
2249 rxh
= (struct rx_header
*) bp
;
2252 * Print out the afs call we're invoking. The table used here was
2253 * gleaned from volser/volint.xg
2256 ND_PRINT((ndo
, " vol reply %s", tok2str(vol_req
, "op#%d", opcode
)));
2258 bp
+= sizeof(struct rx_header
);
2261 * If it was a data packet, interpret the response.
2264 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
2266 case 100: /* Create volume */
2267 ND_PRINT((ndo
, " volid"));
2269 ND_PRINT((ndo
, " trans"));
2272 case 104: /* End transaction */
2275 case 105: /* Clone */
2276 ND_PRINT((ndo
, " newvol"));
2279 case 107: /* Get flags */
2282 case 108: /* Transaction create */
2283 ND_PRINT((ndo
, " trans"));
2286 case 110: /* Get n-th volume */
2287 ND_PRINT((ndo
, " volume"));
2289 ND_PRINT((ndo
, " partition"));
2292 case 112: /* Get name */
2295 case 113: /* Get status */
2296 ND_PRINT((ndo
, " volid"));
2298 ND_PRINT((ndo
, " nextuniq"));
2300 ND_PRINT((ndo
, " type"));
2302 ND_PRINT((ndo
, " parentid"));
2304 ND_PRINT((ndo
, " clone"));
2306 ND_PRINT((ndo
, " backup"));
2308 ND_PRINT((ndo
, " restore"));
2310 ND_PRINT((ndo
, " maxquota"));
2312 ND_PRINT((ndo
, " minquota"));
2314 ND_PRINT((ndo
, " owner"));
2316 ND_PRINT((ndo
, " create"));
2318 ND_PRINT((ndo
, " access"));
2320 ND_PRINT((ndo
, " update"));
2322 ND_PRINT((ndo
, " expire"));
2324 ND_PRINT((ndo
, " backup"));
2326 ND_PRINT((ndo
, " copy"));
2329 case 115: /* Old list partitions */
2331 case 116: /* List volumes */
2332 case 121: /* List one volume */
2335 ND_TCHECK2(bp
[0], 4);
2336 j
= EXTRACT_32BITS(bp
);
2337 bp
+= sizeof(int32_t);
2338 for (i
= 0; i
< j
; i
++) {
2339 ND_PRINT((ndo
, " name"));
2341 ND_PRINT((ndo
, " volid"));
2343 ND_PRINT((ndo
, " type"));
2344 bp
+= sizeof(int32_t) * 21;
2346 ND_PRINT((ndo
, ","));
2349 ND_PRINT((ndo
, " <none!>"));
2359 * Otherwise, just print out the return code
2361 ND_PRINT((ndo
, " errcode"));
2368 ND_PRINT((ndo
, " [|vol]"));
2372 * Handle calls to the AFS BOS service
2376 bos_print(netdissect_options
*ndo
,
2377 register const u_char
*bp
, int length
)
2381 if (length
<= (int)sizeof(struct rx_header
))
2384 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
2389 * Print out the afs call we're invoking. The table used here was
2390 * gleaned from bozo/bosint.xg
2393 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2395 ND_PRINT((ndo
, " bos call %s", tok2str(bos_req
, "op#%d", bos_op
)));
2398 * Decode some of the arguments to the BOS calls
2401 bp
+= sizeof(struct rx_header
) + 4;
2404 case 80: /* Create B node */
2405 ND_PRINT((ndo
, " type"));
2407 ND_PRINT((ndo
, " instance"));
2410 case 81: /* Delete B node */
2411 case 83: /* Get status */
2412 case 85: /* Get instance info */
2413 case 87: /* Add super user */
2414 case 88: /* Delete super user */
2415 case 93: /* Set cell name */
2416 case 96: /* Add cell host */
2417 case 97: /* Delete cell host */
2418 case 104: /* Restart */
2419 case 106: /* Uninstall */
2420 case 108: /* Exec */
2421 case 112: /* Getlog */
2422 case 114: /* Get instance strings */
2425 case 82: /* Set status */
2426 case 98: /* Set T status */
2428 ND_PRINT((ndo
, " status"));
2431 case 86: /* Get instance parm */
2433 ND_PRINT((ndo
, " num"));
2436 case 84: /* Enumerate instance */
2437 case 89: /* List super users */
2438 case 90: /* List keys */
2439 case 91: /* Add key */
2440 case 92: /* Delete key */
2441 case 95: /* Get cell host */
2444 case 105: /* Install */
2446 ND_PRINT((ndo
, " size"));
2448 ND_PRINT((ndo
, " flags"));
2450 ND_PRINT((ndo
, " date"));
2460 ND_PRINT((ndo
, " [|bos]"));
2464 * Handle replies to the AFS BOS Service
2468 bos_reply_print(netdissect_options
*ndo
,
2469 register const u_char
*bp
, int length
, int32_t opcode
)
2471 struct rx_header
*rxh
;
2473 if (length
<= (int)sizeof(struct rx_header
))
2476 rxh
= (struct rx_header
*) bp
;
2479 * Print out the afs call we're invoking. The table used here was
2480 * gleaned from volser/volint.xg
2483 ND_PRINT((ndo
, " bos reply %s", tok2str(bos_req
, "op#%d", opcode
)));
2485 bp
+= sizeof(struct rx_header
);
2488 * If it was a data packet, interpret the response.
2491 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2492 /* Well, no, not really. Leave this for later */
2496 * Otherwise, just print out the return code
2498 ND_PRINT((ndo
, " errcode"));
2505 ND_PRINT((ndo
, " [|bos]"));
2509 * Check to see if this is a Ubik opcode.
2513 is_ubik(uint32_t opcode
)
2515 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2516 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2523 * Handle Ubik opcodes to any one of the replicated database services
2527 ubik_print(netdissect_options
*ndo
,
2528 register const u_char
*bp
)
2534 * Print out the afs call we're invoking. The table used here was
2535 * gleaned from ubik/ubik_int.xg
2538 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2540 ND_PRINT((ndo
, " ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
)));
2543 * Decode some of the arguments to the Ubik calls
2546 bp
+= sizeof(struct rx_header
) + 4;
2549 case 10000: /* Beacon */
2550 ND_TCHECK2(bp
[0], 4);
2551 temp
= EXTRACT_32BITS(bp
);
2552 bp
+= sizeof(int32_t);
2553 ND_PRINT((ndo
, " syncsite %s", temp
? "yes" : "no"));
2554 ND_PRINT((ndo
, " votestart"));
2556 ND_PRINT((ndo
, " dbversion"));
2558 ND_PRINT((ndo
, " tid"));
2561 case 10003: /* Get sync site */
2562 ND_PRINT((ndo
, " site"));
2565 case 20000: /* Begin */
2566 case 20001: /* Commit */
2567 case 20007: /* Abort */
2568 case 20008: /* Release locks */
2569 case 20010: /* Writev */
2570 ND_PRINT((ndo
, " tid"));
2573 case 20002: /* Lock */
2574 ND_PRINT((ndo
, " tid"));
2576 ND_PRINT((ndo
, " file"));
2578 ND_PRINT((ndo
, " pos"));
2580 ND_PRINT((ndo
, " length"));
2582 temp
= EXTRACT_32BITS(bp
);
2583 bp
+= sizeof(int32_t);
2584 tok2str(ubik_lock_types
, "type %d", temp
);
2586 case 20003: /* Write */
2587 ND_PRINT((ndo
, " tid"));
2589 ND_PRINT((ndo
, " file"));
2591 ND_PRINT((ndo
, " pos"));
2594 case 20005: /* Get file */
2595 ND_PRINT((ndo
, " file"));
2598 case 20006: /* Send file */
2599 ND_PRINT((ndo
, " file"));
2601 ND_PRINT((ndo
, " length"));
2603 ND_PRINT((ndo
, " dbversion"));
2606 case 20009: /* Truncate */
2607 ND_PRINT((ndo
, " tid"));
2609 ND_PRINT((ndo
, " file"));
2611 ND_PRINT((ndo
, " length"));
2614 case 20012: /* Set version */
2615 ND_PRINT((ndo
, " tid"));
2617 ND_PRINT((ndo
, " oldversion"));
2619 ND_PRINT((ndo
, " newversion"));
2629 ND_PRINT((ndo
, " [|ubik]"));
2633 * Handle Ubik replies to any one of the replicated database services
2637 ubik_reply_print(netdissect_options
*ndo
,
2638 register const u_char
*bp
, int length
, int32_t opcode
)
2640 struct rx_header
*rxh
;
2642 if (length
< (int)sizeof(struct rx_header
))
2645 rxh
= (struct rx_header
*) bp
;
2648 * Print out the ubik call we're invoking. This table was gleaned
2649 * from ubik/ubik_int.xg
2652 ND_PRINT((ndo
, " ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
)));
2654 bp
+= sizeof(struct rx_header
);
2657 * If it was a data packet, print out the arguments to the Ubik calls
2660 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2662 case 10000: /* Beacon */
2663 ND_PRINT((ndo
, " vote no"));
2665 case 20004: /* Get version */
2666 ND_PRINT((ndo
, " dbversion"));
2674 * Otherwise, print out "yes" it it was a beacon packet (because
2675 * that's how yes votes are returned, go figure), otherwise
2676 * just print out the error code.
2681 case 10000: /* Beacon */
2682 ND_PRINT((ndo
, " vote yes until"));
2686 ND_PRINT((ndo
, " errcode"));
2693 ND_PRINT((ndo
, " [|ubik]"));
2697 * Handle RX ACK packets.
2701 rx_ack_print(netdissect_options
*ndo
,
2702 register const u_char
*bp
, int length
)
2704 struct rx_ackPacket
*rxa
;
2706 uint32_t firstPacket
;
2708 if (length
< (int)sizeof(struct rx_header
))
2711 bp
+= sizeof(struct rx_header
);
2714 * This may seem a little odd .... the rx_ackPacket structure
2715 * contains an array of individual packet acknowledgements
2716 * (used for selective ack/nack), but since it's variable in size,
2717 * we don't want to truncate based on the size of the whole
2718 * rx_ackPacket structure.
2721 ND_TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2723 rxa
= (struct rx_ackPacket
*) bp
;
2724 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2727 * Print out a few useful things from the ack packet structure
2730 if (ndo
->ndo_vflag
> 2)
2731 ND_PRINT((ndo
, " bufspace %d maxskew %d",
2732 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2733 (int) EXTRACT_16BITS(&rxa
->maxSkew
)));
2735 firstPacket
= EXTRACT_32BITS(&rxa
->firstPacket
);
2736 ND_PRINT((ndo
, " first %d serial %d reason %s",
2737 firstPacket
, EXTRACT_32BITS(&rxa
->serial
),
2738 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
)));
2741 * Okay, now we print out the ack array. The way _this_ works
2742 * is that we start at "first", and step through the ack array.
2743 * If we have a contiguous range of acks/nacks, try to
2744 * collapse them into a range.
2746 * If you're really clever, you might have noticed that this
2747 * doesn't seem quite correct. Specifically, due to structure
2748 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2749 * yield the start of the ack array (because RX_MAXACKS is 255
2750 * and the structure will likely get padded to a 2 or 4 byte
2751 * boundary). However, this is the way it's implemented inside
2752 * of AFS - the start of the extra fields are at
2753 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2754 * the exact start of the ack array. Sigh. That's why we aren't
2755 * using bp, but instead use rxa->acks[]. But nAcks gets added
2756 * to bp after this, so bp ends up at the right spot. Go figure.
2759 if (rxa
->nAcks
!= 0) {
2761 ND_TCHECK2(bp
[0], rxa
->nAcks
);
2764 * Sigh, this is gross, but it seems to work to collapse
2768 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2769 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2772 * I figured this deserved _some_ explanation.
2773 * First, print "acked" and the packet seq
2774 * number if this is the first time we've
2775 * seen an acked packet.
2779 ND_PRINT((ndo
, " acked %d", firstPacket
+ i
));
2784 * Otherwise, if there is a skip in
2785 * the range (such as an nacked packet in
2786 * the middle of some acked packets),
2787 * then print the current packet number
2788 * seperated from the last number by
2792 else if (last
!= i
- 1) {
2793 ND_PRINT((ndo
, ",%d", firstPacket
+ i
));
2798 * We always set last to the value of
2799 * the last ack we saw. Conversely, start
2800 * is set to the value of the first ack
2801 * we saw in a range.
2807 * Okay, this bit a code gets executed when
2808 * we hit a nack ... in _this_ case we
2809 * want to print out the range of packets
2810 * that were acked, so we need to print
2811 * the _previous_ packet number seperated
2812 * from the first by a dash (-). Since we
2813 * already printed the first packet above,
2814 * just print the final packet. Don't
2815 * do this if there will be a single-length
2818 } else if (last
== i
- 1 && start
!= last
)
2819 ND_PRINT((ndo
, "-%d", firstPacket
+ i
- 1));
2822 * So, what's going on here? We ran off the end of the
2823 * ack list, and if we got a range we need to finish it up.
2824 * So we need to determine if the last packet in the list
2825 * was an ack (if so, then last will be set to it) and
2826 * we need to see if the last range didn't start with the
2827 * last packet (because if it _did_, then that would mean
2828 * that the packet number has already been printed and
2829 * we don't need to print it again).
2832 if (last
== i
- 1 && start
!= last
)
2833 ND_PRINT((ndo
, "-%d", firstPacket
+ i
- 1));
2836 * Same as above, just without comments
2839 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2840 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2842 ND_PRINT((ndo
, " nacked %d", firstPacket
+ i
));
2844 } else if (last
!= i
- 1) {
2845 ND_PRINT((ndo
, ",%d", firstPacket
+ i
));
2849 } else if (last
== i
- 1 && start
!= last
)
2850 ND_PRINT((ndo
, "-%d", firstPacket
+ i
- 1));
2852 if (last
== i
- 1 && start
!= last
)
2853 ND_PRINT((ndo
, "-%d", firstPacket
+ i
- 1));
2860 * These are optional fields; depending on your version of AFS,
2861 * you may or may not see them
2864 #define TRUNCRET(n) if (ndo->ndo_snapend - bp + 1 <= n) return;
2866 if (ndo
->ndo_vflag
> 1) {
2868 ND_PRINT((ndo
, " ifmtu"));
2872 ND_PRINT((ndo
, " maxmtu"));
2876 ND_PRINT((ndo
, " rwind"));
2880 ND_PRINT((ndo
, " maxpackets"));
2887 ND_PRINT((ndo
, " [|ack]"));