2 * Copyright: (c) 2000 United States Government as represented by the
3 * Secretary of the Navy. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
15 * 3. The names of the authors may not be used to endorse or promote
16 * products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 /* \summary: AFS RX printer */
27 * This code unmangles RX packets. RX is the mutant form of RPC that AFS
28 * uses to communicate between clients and servers.
30 * In this code, I mainly concern myself with decoding the AFS calls, not
31 * with the guts of RX, per se.
33 * Bah. If I never look at rx_packet.h again, it will be too soon.
35 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
45 #include <netdissect-stdinc.h>
47 #include "netdissect.h"
48 #include "addrtoname.h"
53 #define FS_RX_PORT 7000
54 #define CB_RX_PORT 7001
55 #define PROT_RX_PORT 7002
56 #define VLDB_RX_PORT 7003
57 #define KAUTH_RX_PORT 7004
58 #define VOL_RX_PORT 7005
59 #define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
60 #define BOS_RX_PORT 7007
62 #define AFSNAMEMAX 256
63 #define AFSOPAQUEMAX 1024
67 #define BOSNAMEMAX 256
69 #define PRSFS_READ 1 /* Read files */
70 #define PRSFS_WRITE 2 /* Write files */
71 #define PRSFS_INSERT 4 /* Insert files into a directory */
72 #define PRSFS_LOOKUP 8 /* Lookup files into a directory */
73 #define PRSFS_DELETE 16 /* Delete files */
74 #define PRSFS_LOCK 32 /* Lock files */
75 #define PRSFS_ADMINISTER 64 /* Change ACL's */
80 nd_uint32_t callNumber
;
84 #define RX_PACKET_TYPE_DATA 1
85 #define RX_PACKET_TYPE_ACK 2
86 #define RX_PACKET_TYPE_BUSY 3
87 #define RX_PACKET_TYPE_ABORT 4
88 #define RX_PACKET_TYPE_ACKALL 5
89 #define RX_PACKET_TYPE_CHALLENGE 6
90 #define RX_PACKET_TYPE_RESPONSE 7
91 #define RX_PACKET_TYPE_DEBUG 8
92 #define RX_PACKET_TYPE_PARAMS 9
93 #define RX_PACKET_TYPE_VERSION 13
95 #define RX_CLIENT_INITIATED 1
96 #define RX_REQUEST_ACK 2
97 #define RX_LAST_PACKET 4
98 #define RX_MORE_PACKETS 8
99 #define RX_FREE_PACKET 16
100 #define RX_SLOW_START_OK 32
101 #define RX_JUMBO_PACKET 32
102 nd_uint8_t userStatus
;
103 nd_uint8_t securityIndex
;
104 nd_uint16_t spare
; /* How clever: even though the AFS */
105 nd_uint16_t serviceId
; /* header files indicate that the */
106 }; /* serviceId is first, it's really */
107 /* encoded _after_ the spare field */
108 /* I wasted a day figuring that out! */
110 #define NUM_RX_FLAGS 7
112 #define RX_MAXACKS 255
114 struct rx_ackPacket
{
115 nd_uint16_t bufferSpace
; /* Number of packet buffers available */
116 nd_uint16_t maxSkew
; /* Max diff between ack'd packet and */
117 /* highest packet received */
118 nd_uint32_t firstPacket
; /* The first packet in ack list */
119 nd_uint32_t previousPacket
; /* Previous packet recv'd (obsolete) */
120 nd_uint32_t serial
; /* # of packet that prompted the ack */
121 nd_uint8_t reason
; /* Reason for acknowledgement */
122 nd_uint8_t nAcks
; /* Number of acknowledgements */
123 /* Followed by nAcks acknowledgments */
125 uint8_t acks
[RX_MAXACKS
]; /* Up to RX_MAXACKS acknowledgements */
130 * Values for the acks array
133 #define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
134 #define RX_ACK_TYPE_ACK 1 /* I have this packet */
136 static const struct tok rx_types
[] = {
137 { RX_PACKET_TYPE_DATA
, "data" },
138 { RX_PACKET_TYPE_ACK
, "ack" },
139 { RX_PACKET_TYPE_BUSY
, "busy" },
140 { RX_PACKET_TYPE_ABORT
, "abort" },
141 { RX_PACKET_TYPE_ACKALL
, "ackall" },
142 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
143 { RX_PACKET_TYPE_RESPONSE
, "response" },
144 { RX_PACKET_TYPE_DEBUG
, "debug" },
145 { RX_PACKET_TYPE_PARAMS
, "params" },
146 { RX_PACKET_TYPE_VERSION
, "version" },
150 static const struct double_tok
{
151 uint32_t flag
; /* Rx flag */
152 uint32_t packetType
; /* Packet type */
153 const char *s
; /* Flag string */
155 { RX_CLIENT_INITIATED
, 0, "client-init" },
156 { RX_REQUEST_ACK
, 0, "req-ack" },
157 { RX_LAST_PACKET
, 0, "last-pckt" },
158 { RX_MORE_PACKETS
, 0, "more-pckts" },
159 { RX_FREE_PACKET
, 0, "free-pckt" },
160 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
161 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
164 static const struct tok fs_req
[] = {
165 { 130, "fetch-data" },
166 { 131, "fetch-acl" },
167 { 132, "fetch-status" },
168 { 133, "store-data" },
169 { 134, "store-acl" },
170 { 135, "store-status" },
171 { 136, "remove-file" },
172 { 137, "create-file" },
178 { 143, "oldsetlock" },
179 { 144, "oldextlock" },
180 { 145, "oldrellock" },
181 { 146, "get-stats" },
183 { 148, "get-vlinfo" },
184 { 149, "get-vlstats" },
185 { 150, "set-vlstats" },
186 { 151, "get-rootvl" },
187 { 152, "check-token" },
189 { 154, "nget-vlinfo" },
190 { 155, "bulk-stat" },
194 { 159, "xstat-ver" },
195 { 160, "get-xstat" },
196 { 161, "dfs-lookup" },
197 { 162, "dfs-flushcps" },
198 { 163, "dfs-symlink" },
199 { 220, "residency" },
200 { 65536, "inline-bulk-status" },
201 { 65537, "fetch-data-64" },
202 { 65538, "store-data-64" },
203 { 65539, "give-up-all-cbs" },
204 { 65540, "get-caps" },
205 { 65541, "cb-rx-conn-addr" },
209 static const struct tok cb_req
[] = {
218 { 212, "whoareyou" },
220 { 214, "probeuuid" },
221 { 215, "getsrvprefs" },
222 { 216, "getcellservdb" },
223 { 217, "getlocalcell" },
224 { 218, "getcacheconf" },
225 { 65536, "getce64" },
226 { 65537, "getcellbynum" },
227 { 65538, "tellmeaboutyourself" },
231 static const struct tok pt_req
[] = {
233 { 501, "where-is-it" },
234 { 502, "dump-entry" },
235 { 503, "add-to-group" },
236 { 504, "name-to-id" },
237 { 505, "id-to-name" },
239 { 507, "remove-from-group" },
241 { 509, "new-entry" },
244 { 512, "list-entry" },
245 { 513, "change-entry" },
246 { 514, "list-elements" },
247 { 515, "same-mbr-of" },
248 { 516, "set-fld-sentry" },
249 { 517, "list-owned" },
251 { 519, "get-host-cps" },
252 { 520, "update-entry" },
253 { 521, "list-entries" },
254 { 530, "list-super-groups" },
258 static const struct tok vldb_req
[] = {
259 { 501, "create-entry" },
260 { 502, "delete-entry" },
261 { 503, "get-entry-by-id" },
262 { 504, "get-entry-by-name" },
263 { 505, "get-new-volume-id" },
264 { 506, "replace-entry" },
265 { 507, "update-entry" },
267 { 509, "releaselock" },
268 { 510, "list-entry" },
269 { 511, "list-attrib" },
270 { 512, "linked-list" },
271 { 513, "get-stats" },
273 { 515, "get-addrs" },
274 { 516, "change-addr" },
275 { 517, "create-entry-n" },
276 { 518, "get-entry-by-id-n" },
277 { 519, "get-entry-by-name-n" },
278 { 520, "replace-entry-n" },
279 { 521, "list-entry-n" },
280 { 522, "list-attrib-n" },
281 { 523, "linked-list-n" },
282 { 524, "update-entry-by-name" },
283 { 525, "create-entry-u" },
284 { 526, "get-entry-by-id-u" },
285 { 527, "get-entry-by-name-u" },
286 { 528, "replace-entry-u" },
287 { 529, "list-entry-u" },
288 { 530, "list-attrib-u" },
289 { 531, "linked-list-u" },
291 { 533, "get-addrs-u" },
292 { 534, "list-attrib-n2" },
296 static const struct tok kauth_req
[] = {
298 { 21, "authenticate" },
299 { 22, "authenticate-v2" },
301 { 3, "get-ticket-old" },
302 { 23, "get-ticket" },
305 { 6, "create-user" },
306 { 7, "delete-user" },
312 { 13, "get-random-key" },
314 { 15, "lock-status" },
318 static const struct tok vol_req
[] = {
319 { 100, "create-volume" },
320 { 101, "delete-volume" },
323 { 104, "end-trans" },
325 { 106, "set-flags" },
326 { 107, "get-flags" },
327 { 108, "trans-create" },
329 { 110, "get-nth-volume" },
330 { 111, "set-forwarding" },
332 { 113, "get-status" },
333 { 114, "sig-restore" },
334 { 115, "list-partitions" },
335 { 116, "list-volumes" },
336 { 117, "set-id-types" },
338 { 119, "partition-info" },
340 { 121, "list-one-volume" },
343 { 124, "x-list-volumes" },
344 { 125, "x-list-one-volume" },
346 { 127, "x-list-partitions" },
347 { 128, "forward-multiple" },
348 { 65536, "convert-ro" },
349 { 65537, "get-size" },
350 { 65538, "dump-v2" },
354 static const struct tok bos_req
[] = {
355 { 80, "create-bnode" },
356 { 81, "delete-bnode" },
357 { 82, "set-status" },
358 { 83, "get-status" },
359 { 84, "enumerate-instance" },
360 { 85, "get-instance-info" },
361 { 86, "get-instance-parm" },
362 { 87, "add-superuser" },
363 { 88, "delete-superuser" },
364 { 89, "list-superusers" },
367 { 92, "delete-key" },
368 { 93, "set-cell-name" },
369 { 94, "get-cell-name" },
370 { 95, "get-cell-host" },
371 { 96, "add-cell-host" },
372 { 97, "delete-cell-host" },
373 { 98, "set-t-status" },
374 { 99, "shutdown-all" },
375 { 100, "restart-all" },
376 { 101, "startup-all" },
377 { 102, "set-noauth-flag" },
380 { 105, "start-bozo-install" },
381 { 106, "uninstall" },
382 { 107, "get-dates" },
385 { 110, "set-restart-time" },
386 { 111, "get-restart-time" },
387 { 112, "start-bozo-log" },
389 { 114, "get-instance-strings" },
390 { 115, "get-restricted" },
391 { 116, "set-restricted" },
395 static const struct tok ubik_req
[] = {
396 { 10000, "vote-beacon" },
397 { 10001, "vote-debug-old" },
398 { 10002, "vote-sdebug-old" },
399 { 10003, "vote-getsyncsite" },
400 { 10004, "vote-debug" },
401 { 10005, "vote-sdebug" },
402 { 10006, "vote-xdebug" },
403 { 10007, "vote-xsdebug" },
404 { 20000, "disk-begin" },
405 { 20001, "disk-commit" },
406 { 20002, "disk-lock" },
407 { 20003, "disk-write" },
408 { 20004, "disk-getversion" },
409 { 20005, "disk-getfile" },
410 { 20006, "disk-sendfile" },
411 { 20007, "disk-abort" },
412 { 20008, "disk-releaselocks" },
413 { 20009, "disk-truncate" },
414 { 20010, "disk-probe" },
415 { 20011, "disk-writev" },
416 { 20012, "disk-interfaceaddr" },
417 { 20013, "disk-setversion" },
421 #define VOTE_LOW 10000
422 #define VOTE_HIGH 10007
423 #define DISK_LOW 20000
424 #define DISK_HIGH 20013
426 static const struct tok cb_types
[] = {
433 static const struct tok ubik_lock_types
[] = {
440 static const char *voltype
[] = { "read-write", "read-only", "backup" };
442 static const struct tok afs_fs_errors
[] = {
443 { 101, "salvage volume" },
444 { 102, "no such vnode" },
445 { 103, "no such volume" },
446 { 104, "volume exist" },
447 { 105, "no service" },
448 { 106, "volume offline" },
449 { 107, "voline online" },
451 { 109, "diskquota exceeded" },
452 { 110, "volume busy" },
453 { 111, "volume moved" },
454 { 112, "AFS IO error" },
455 { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */
460 * Reasons for acknowledging a packet
463 static const struct tok rx_ack_reasons
[] = {
464 { 1, "ack requested" },
465 { 2, "duplicate packet" },
466 { 3, "out of sequence" },
467 { 4, "exceeds window" },
468 { 5, "no buffer space" },
470 { 7, "ping response" },
477 * Cache entries we keep around so we can figure out the RX opcode
478 * numbers for replies. This allows us to make sense of RX reply packets.
481 struct rx_cache_entry
{
482 uint32_t callnum
; /* Call number (net order) */
483 struct in_addr client
; /* client IP address (net order) */
484 struct in_addr server
; /* server IP address (net order) */
485 u_int dport
; /* server port (host order) */
486 uint16_t serviceId
; /* Service identifier (net order) */
487 uint32_t opcode
; /* RX opcode (host order) */
490 #define RX_CACHE_SIZE 64
492 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
494 static uint32_t rx_cache_next
= 0;
495 static uint32_t rx_cache_hint
= 0;
496 static void rx_cache_insert(netdissect_options
*, const u_char
*, const struct ip
*, u_int
);
497 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
498 uint32_t, uint32_t *);
500 static void fs_print(netdissect_options
*, const u_char
*, u_int
);
501 static void fs_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
502 static void acl_print(netdissect_options
*, u_char
*, int, u_char
*);
503 static void cb_print(netdissect_options
*, const u_char
*, u_int
);
504 static void cb_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
505 static void prot_print(netdissect_options
*, const u_char
*, u_int
);
506 static void prot_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
507 static void vldb_print(netdissect_options
*, const u_char
*, u_int
);
508 static void vldb_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
509 static void kauth_print(netdissect_options
*, const u_char
*, u_int
);
510 static void kauth_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
511 static void vol_print(netdissect_options
*, const u_char
*, u_int
);
512 static void vol_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
513 static void bos_print(netdissect_options
*, const u_char
*, u_int
);
514 static void bos_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
515 static void ubik_print(netdissect_options
*, const u_char
*);
516 static void ubik_reply_print(netdissect_options
*, const u_char
*, u_int
, uint32_t);
518 static void rx_ack_print(netdissect_options
*, const u_char
*, u_int
);
520 static int is_ubik(uint32_t);
523 * Handle the rx-level packet. See if we know what port it's going to so
524 * we can peek at the afs call inside
528 rx_print(netdissect_options
*ndo
,
529 const u_char
*bp
, u_int length
, u_int sport
, u_int dport
,
532 const struct rx_header
*rxh
;
537 if (!ND_TTEST_LEN(bp
, sizeof(struct rx_header
))) {
538 ND_PRINT((ndo
, " [|rx] (%u)", length
));
542 rxh
= (const struct rx_header
*) bp
;
544 type
= EXTRACT_U_1(rxh
->type
);
545 ND_PRINT((ndo
, " rx %s", tok2str(rx_types
, "type %u", type
)));
547 flags
= EXTRACT_U_1(rxh
->flags
);
548 if (ndo
->ndo_vflag
) {
551 if (ndo
->ndo_vflag
> 1)
552 ND_PRINT((ndo
, " cid %08x call# %u",
553 EXTRACT_BE_U_4(rxh
->cid
),
554 EXTRACT_BE_U_4(rxh
->callNumber
)));
556 ND_PRINT((ndo
, " seq %u ser %u",
557 EXTRACT_BE_U_4(rxh
->seq
),
558 EXTRACT_BE_U_4(rxh
->serial
)));
560 if (ndo
->ndo_vflag
> 2)
561 ND_PRINT((ndo
, " secindex %u serviceid %hu",
562 EXTRACT_U_1(rxh
->securityIndex
),
563 EXTRACT_BE_U_2(rxh
->serviceId
)));
565 if (ndo
->ndo_vflag
> 1)
566 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
567 if (flags
& rx_flags
[i
].flag
&&
568 (!rx_flags
[i
].packetType
||
569 type
== rx_flags
[i
].packetType
)) {
572 ND_PRINT((ndo
, " "));
574 ND_PRINT((ndo
, ","));
576 ND_PRINT((ndo
, "<%s>", rx_flags
[i
].s
));
582 * Try to handle AFS calls that we know about. Check the destination
583 * port and make sure it's a data packet. Also, make sure the
584 * seq number is 1 (because otherwise it's a continuation packet,
585 * and we can't interpret that). Also, seems that reply packets
586 * do not have the client-init flag set, so we check for that
590 if (type
== RX_PACKET_TYPE_DATA
&&
591 EXTRACT_BE_U_4(rxh
->seq
) == 1 &&
592 flags
& RX_CLIENT_INITIATED
) {
595 * Insert this call into the call cache table, so we
596 * have a chance to print out replies
599 rx_cache_insert(ndo
, bp
, (const struct ip
*) bp2
, dport
);
602 case FS_RX_PORT
: /* AFS file service */
603 fs_print(ndo
, bp
, length
);
605 case CB_RX_PORT
: /* AFS callback service */
606 cb_print(ndo
, bp
, length
);
608 case PROT_RX_PORT
: /* AFS protection service */
609 prot_print(ndo
, bp
, length
);
611 case VLDB_RX_PORT
: /* AFS VLDB service */
612 vldb_print(ndo
, bp
, length
);
614 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
615 kauth_print(ndo
, bp
, length
);
617 case VOL_RX_PORT
: /* AFS Volume service */
618 vol_print(ndo
, bp
, length
);
620 case BOS_RX_PORT
: /* AFS BOS service */
621 bos_print(ndo
, bp
, length
);
628 * If it's a reply (client-init is _not_ set, but seq is one)
629 * then look it up in the cache. If we find it, call the reply
630 * printing functions Note that we handle abort packets here,
631 * because printing out the return code can be useful at times.
634 } else if (((type
== RX_PACKET_TYPE_DATA
&&
635 EXTRACT_BE_U_4(rxh
->seq
) == 1) ||
636 type
== RX_PACKET_TYPE_ABORT
) &&
637 (flags
& RX_CLIENT_INITIATED
) == 0 &&
638 rx_cache_find(rxh
, (const struct ip
*) bp2
,
642 case FS_RX_PORT
: /* AFS file service */
643 fs_reply_print(ndo
, bp
, length
, opcode
);
645 case CB_RX_PORT
: /* AFS callback service */
646 cb_reply_print(ndo
, bp
, length
, opcode
);
648 case PROT_RX_PORT
: /* AFS PT service */
649 prot_reply_print(ndo
, bp
, length
, opcode
);
651 case VLDB_RX_PORT
: /* AFS VLDB service */
652 vldb_reply_print(ndo
, bp
, length
, opcode
);
654 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
655 kauth_reply_print(ndo
, bp
, length
, opcode
);
657 case VOL_RX_PORT
: /* AFS Volume service */
658 vol_reply_print(ndo
, bp
, length
, opcode
);
660 case BOS_RX_PORT
: /* AFS BOS service */
661 bos_reply_print(ndo
, bp
, length
, opcode
);
668 * If it's an RX ack packet, then use the appropriate ack decoding
669 * function (there isn't any service-specific information in the
670 * ack packet, so we can use one for all AFS services)
673 } else if (type
== RX_PACKET_TYPE_ACK
)
674 rx_ack_print(ndo
, bp
, length
);
677 ND_PRINT((ndo
, " (%u)", length
));
681 * Insert an entry into the cache. Taken from print-nfs.c
685 rx_cache_insert(netdissect_options
*ndo
,
686 const u_char
*bp
, const struct ip
*ip
, u_int dport
)
688 struct rx_cache_entry
*rxent
;
689 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
691 if (!ND_TTEST_4(bp
+ sizeof(struct rx_header
)))
694 rxent
= &rx_cache
[rx_cache_next
];
696 if (++rx_cache_next
>= RX_CACHE_SIZE
)
699 rxent
->callnum
= EXTRACT_BE_U_4(rxh
->callNumber
);
700 UNALIGNED_MEMCPY(&rxent
->client
, &ip
->ip_src
, sizeof(uint32_t));
701 UNALIGNED_MEMCPY(&rxent
->server
, &ip
->ip_dst
, sizeof(uint32_t));
702 rxent
->dport
= dport
;
703 rxent
->serviceId
= EXTRACT_BE_U_4(rxh
->serviceId
);
704 rxent
->opcode
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
708 * Lookup an entry in the cache. Also taken from print-nfs.c
710 * Note that because this is a reply, we're looking at the _source_
715 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, u_int sport
,
719 struct rx_cache_entry
*rxent
;
723 UNALIGNED_MEMCPY(&clip
, &ip
->ip_dst
, sizeof(uint32_t));
724 UNALIGNED_MEMCPY(&sip
, &ip
->ip_src
, sizeof(uint32_t));
726 /* Start the search where we last left off */
730 rxent
= &rx_cache
[i
];
731 if (rxent
->callnum
== EXTRACT_BE_U_4(rxh
->callNumber
) &&
732 rxent
->client
.s_addr
== clip
&&
733 rxent
->server
.s_addr
== sip
&&
734 rxent
->serviceId
== EXTRACT_BE_U_4(rxh
->serviceId
) &&
735 rxent
->dport
== sport
) {
737 /* We got a match! */
740 *opcode
= rxent
->opcode
;
743 if (++i
>= RX_CACHE_SIZE
)
745 } while (i
!= rx_cache_hint
);
747 /* Our search failed */
752 * These extrememly grody macros handle the printing of various AFS stuff.
755 #define FIDOUT() { uint32_t n1, n2, n3; \
756 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 3); \
757 n1 = EXTRACT_BE_U_4(bp); \
758 bp += sizeof(uint32_t); \
759 n2 = EXTRACT_BE_U_4(bp); \
760 bp += sizeof(uint32_t); \
761 n3 = EXTRACT_BE_U_4(bp); \
762 bp += sizeof(uint32_t); \
763 ND_PRINT((ndo, " fid %u/%u/%u", n1, n2, n3)); \
766 #define STROUT(MAX) { uint32_t _i; \
767 ND_TCHECK_LEN(bp, sizeof(uint32_t)); \
768 _i = EXTRACT_BE_U_4(bp); \
771 bp += sizeof(uint32_t); \
772 ND_PRINT((ndo, " \"")); \
773 if (fn_printn(ndo, bp, _i, ndo->ndo_snapend)) \
775 ND_PRINT((ndo, "\"")); \
776 bp += ((_i + sizeof(uint32_t) - 1) / sizeof(uint32_t)) * sizeof(uint32_t); \
779 #define INTOUT() { int32_t _i; \
781 _i = EXTRACT_BE_S_4(bp); \
782 bp += sizeof(int32_t); \
783 ND_PRINT((ndo, " %d", _i)); \
786 #define UINTOUT() { uint32_t _i; \
788 _i = EXTRACT_BE_U_4(bp); \
789 bp += sizeof(uint32_t); \
790 ND_PRINT((ndo, " %u", _i)); \
793 #define UINT64OUT() { uint64_t _i; \
794 ND_TCHECK_LEN(bp, sizeof(uint64_t)); \
795 _i = EXTRACT_BE_U_8(bp); \
796 bp += sizeof(uint64_t); \
797 ND_PRINT((ndo, " %" PRIu64, _i)); \
800 #define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \
802 _t = (time_t) EXTRACT_BE_S_4(bp); \
803 bp += sizeof(int32_t); \
804 tm = localtime(&_t); \
805 strftime(str, 256, "%Y/%m/%d %H:%M:%S", tm); \
806 ND_PRINT((ndo, " %s", str)); \
809 #define STOREATTROUT() { uint32_t mask, _i; \
810 ND_TCHECK_LEN(bp, (sizeof(uint32_t) * 6)); \
811 mask = EXTRACT_BE_U_4(bp); bp += sizeof(uint32_t); \
812 if (mask) ND_PRINT((ndo, " StoreStatus")); \
813 if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \
814 else bp += sizeof(uint32_t); \
815 _i = EXTRACT_BE_U_4(bp); bp += sizeof(uint32_t); \
816 if (mask & 2) ND_PRINT((ndo, " owner %u", _i)); \
817 _i = EXTRACT_BE_U_4(bp); bp += sizeof(uint32_t); \
818 if (mask & 4) ND_PRINT((ndo, " group %u", _i)); \
819 _i = EXTRACT_BE_U_4(bp); bp += sizeof(uint32_t); \
820 if (mask & 8) ND_PRINT((ndo, " mode %o", _i & 07777)); \
821 _i = EXTRACT_BE_U_4(bp); bp += sizeof(uint32_t); \
822 if (mask & 16) ND_PRINT((ndo, " segsize %u", _i)); \
823 /* undocumented in 3.3 docu */ \
824 if (mask & 1024) ND_PRINT((ndo, " fsync")); \
827 #define UBIK_VERSIONOUT() {uint32_t epoch; uint32_t counter; \
828 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 2); \
829 epoch = EXTRACT_BE_U_4(bp); \
830 bp += sizeof(uint32_t); \
831 counter = EXTRACT_BE_U_4(bp); \
832 bp += sizeof(uint32_t); \
833 ND_PRINT((ndo, " %u.%u", epoch, counter)); \
836 #define AFSUUIDOUT() {uint32_t temp; int _i; \
837 ND_TCHECK_LEN(bp, 11 * sizeof(uint32_t)); \
838 temp = EXTRACT_BE_U_4(bp); \
839 bp += sizeof(uint32_t); \
840 ND_PRINT((ndo, " %08x", temp)); \
841 temp = EXTRACT_BE_U_4(bp); \
842 bp += sizeof(uint32_t); \
843 ND_PRINT((ndo, "%04x", temp)); \
844 temp = EXTRACT_BE_U_4(bp); \
845 bp += sizeof(uint32_t); \
846 ND_PRINT((ndo, "%04x", temp)); \
847 for (_i = 0; _i < 8; _i++) { \
848 temp = EXTRACT_BE_U_4(bp); \
849 bp += sizeof(uint32_t); \
850 ND_PRINT((ndo, "%02x", (unsigned char) temp)); \
855 * This is the sickest one of all
858 #define VECOUT(MAX) { u_char *sp; \
859 u_char s[AFSNAMEMAX]; \
861 if ((MAX) + 1 > sizeof(s)) \
863 ND_TCHECK_LEN(bp, (MAX) * sizeof(uint32_t)); \
865 for (k = 0; k < (MAX); k++) { \
866 *sp++ = (u_char) EXTRACT_BE_U_4(bp); \
867 bp += sizeof(uint32_t); \
870 ND_PRINT((ndo, " \"")); \
871 fn_print(ndo, s, NULL); \
872 ND_PRINT((ndo, "\"")); \
875 #define DESTSERVEROUT() { uint32_t n1, n2, n3; \
876 ND_TCHECK_LEN(bp, sizeof(uint32_t) * 3); \
877 n1 = EXTRACT_BE_U_4(bp); \
878 bp += sizeof(uint32_t); \
879 n2 = EXTRACT_BE_U_4(bp); \
880 bp += sizeof(uint32_t); \
881 n3 = EXTRACT_BE_U_4(bp); \
882 bp += sizeof(uint32_t); \
883 ND_PRINT((ndo, " server %u:%u:%u", n1, n2, n3)); \
887 * Handle calls to the AFS file service (fs)
891 fs_print(netdissect_options
*ndo
,
892 const u_char
*bp
, u_int length
)
897 if (length
<= sizeof(struct rx_header
))
901 * Print out the afs call we're invoking. The table used here was
902 * gleaned from fsint/afsint.xg
905 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
906 fs_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
908 ND_PRINT((ndo
, " fs call %s", tok2str(fs_req
, "op#%u", fs_op
)));
911 * Print out arguments to some of the AFS calls. This stuff is
915 bp
+= sizeof(struct rx_header
) + 4;
918 * Sigh. This is gross. Ritchie forgive me.
922 case 130: /* Fetch data */
924 ND_PRINT((ndo
, " offset"));
926 ND_PRINT((ndo
, " length"));
929 case 131: /* Fetch ACL */
930 case 132: /* Fetch Status */
931 case 143: /* Old set lock */
932 case 144: /* Old extend lock */
933 case 145: /* Old release lock */
934 case 156: /* Set lock */
935 case 157: /* Extend lock */
936 case 158: /* Release lock */
939 case 135: /* Store status */
943 case 133: /* Store data */
946 ND_PRINT((ndo
, " offset"));
948 ND_PRINT((ndo
, " length"));
950 ND_PRINT((ndo
, " flen"));
953 case 134: /* Store ACL */
955 char a
[AFSOPAQUEMAX
+1];
958 i
= EXTRACT_BE_U_4(bp
);
959 bp
+= sizeof(uint32_t);
960 ND_TCHECK_LEN(bp
, i
);
961 i
= min(AFSOPAQUEMAX
, i
);
962 strncpy(a
, (const char *) bp
, i
);
964 acl_print(ndo
, (u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
967 case 137: /* Create file */
968 case 141: /* MakeDir */
973 case 136: /* Remove file */
974 case 142: /* Remove directory */
978 case 138: /* Rename file */
979 ND_PRINT((ndo
, " old"));
982 ND_PRINT((ndo
, " new"));
986 case 139: /* Symlink */
989 ND_PRINT((ndo
, " link to"));
995 ND_PRINT((ndo
, " link to"));
998 case 148: /* Get volume info */
1001 case 149: /* Get volume stats */
1002 case 150: /* Set volume stats */
1003 ND_PRINT((ndo
, " volid"));
1006 case 154: /* New get volume info */
1007 ND_PRINT((ndo
, " volname"));
1010 case 155: /* Bulk stat */
1011 case 65536: /* Inline bulk stat */
1015 j
= EXTRACT_BE_U_4(bp
);
1016 bp
+= sizeof(uint32_t);
1018 for (i
= 0; i
< j
; i
++) {
1021 ND_PRINT((ndo
, ","));
1024 ND_PRINT((ndo
, " <none!>"));
1026 case 65537: /* Fetch data 64 */
1028 ND_PRINT((ndo
, " offset"));
1030 ND_PRINT((ndo
, " length"));
1033 case 65538: /* Store data 64 */
1036 ND_PRINT((ndo
, " offset"));
1038 ND_PRINT((ndo
, " length"));
1040 ND_PRINT((ndo
, " flen"));
1043 case 65541: /* CallBack rx conn address */
1044 ND_PRINT((ndo
, " addr"));
1053 ND_PRINT((ndo
, " [|fs]"));
1057 * Handle replies to the AFS file service
1061 fs_reply_print(netdissect_options
*ndo
,
1062 const u_char
*bp
, u_int length
, uint32_t opcode
)
1065 const struct rx_header
*rxh
;
1068 if (length
<= sizeof(struct rx_header
))
1071 rxh
= (const struct rx_header
*) bp
;
1074 * Print out the afs call we're invoking. The table used here was
1075 * gleaned from fsint/afsint.xg
1078 ND_PRINT((ndo
, " fs reply %s", tok2str(fs_req
, "op#%u", opcode
)));
1080 type
= EXTRACT_U_1(rxh
->type
);
1081 bp
+= sizeof(struct rx_header
);
1084 * If it was a data packet, interpret the response
1087 if (type
== RX_PACKET_TYPE_DATA
) {
1089 case 131: /* Fetch ACL */
1091 char a
[AFSOPAQUEMAX
+1];
1093 i
= EXTRACT_BE_U_4(bp
);
1094 bp
+= sizeof(uint32_t);
1095 ND_TCHECK_LEN(bp
, i
);
1096 i
= min(AFSOPAQUEMAX
, i
);
1097 strncpy(a
, (const char *) bp
, i
);
1099 acl_print(ndo
, (u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1102 case 137: /* Create file */
1103 case 141: /* MakeDir */
1104 ND_PRINT((ndo
, " new"));
1107 case 151: /* Get root volume */
1108 ND_PRINT((ndo
, " root volume"));
1111 case 153: /* Get time */
1117 } else if (type
== RX_PACKET_TYPE_ABORT
) {
1119 * Otherwise, just print out the return code
1124 errcode
= EXTRACT_BE_S_4(bp
);
1125 bp
+= sizeof(int32_t);
1127 ND_PRINT((ndo
, " error %s", tok2str(afs_fs_errors
, "#%d", errcode
)));
1129 ND_PRINT((ndo
, " strange fs reply of type %u", type
));
1135 ND_PRINT((ndo
, " [|fs]"));
1139 * Print out an AFS ACL string. An AFS ACL is a string that has the
1142 * <positive> <negative>
1146 * "positive" and "negative" are integers which contain the number of
1147 * positive and negative ACL's in the string. The uid/aclbits pair are
1148 * ASCII strings containing the UID/PTS record and an ASCII number
1149 * representing a logical OR of all the ACL permission bits
1153 acl_print(netdissect_options
*ndo
,
1154 u_char
*s
, int maxsize
, u_char
*end
)
1161 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1164 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1173 * This wacky order preserves the order used by the "fs" command
1176 #define ACLOUT(acl) \
1177 ND_PRINT((ndo, "%s%s%s%s%s%s%s", \
1178 acl & PRSFS_READ ? "r" : "", \
1179 acl & PRSFS_LOOKUP ? "l" : "", \
1180 acl & PRSFS_INSERT ? "i" : "", \
1181 acl & PRSFS_DELETE ? "d" : "", \
1182 acl & PRSFS_WRITE ? "w" : "", \
1183 acl & PRSFS_LOCK ? "k" : "", \
1184 acl & PRSFS_ADMINISTER ? "a" : ""));
1186 for (i
= 0; i
< pos
; i
++) {
1187 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1188 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1191 ND_PRINT((ndo
, " +{"));
1192 fn_print(ndo
, (u_char
*)user
, NULL
);
1193 ND_PRINT((ndo
, " "));
1195 ND_PRINT((ndo
, "}"));
1200 for (i
= 0; i
< neg
; i
++) {
1201 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1202 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1205 ND_PRINT((ndo
, " -{"));
1206 fn_print(ndo
, (u_char
*)user
, NULL
);
1207 ND_PRINT((ndo
, " "));
1209 ND_PRINT((ndo
, "}"));
1222 * Handle calls to the AFS callback service
1226 cb_print(netdissect_options
*ndo
,
1227 const u_char
*bp
, u_int length
)
1232 if (length
<= sizeof(struct rx_header
))
1236 * Print out the afs call we're invoking. The table used here was
1237 * gleaned from fsint/afscbint.xg
1240 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
1241 cb_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
1243 ND_PRINT((ndo
, " cb call %s", tok2str(cb_req
, "op#%u", cb_op
)));
1245 bp
+= sizeof(struct rx_header
) + 4;
1248 * Print out the afs call we're invoking. The table used here was
1249 * gleaned from fsint/afscbint.xg
1253 case 204: /* Callback */
1257 j
= EXTRACT_BE_U_4(bp
);
1258 bp
+= sizeof(uint32_t);
1260 for (i
= 0; i
< j
; i
++) {
1263 ND_PRINT((ndo
, ","));
1267 ND_PRINT((ndo
, " <none!>"));
1270 j
= EXTRACT_BE_U_4(bp
);
1271 bp
+= sizeof(uint32_t);
1274 ND_PRINT((ndo
, ";"));
1276 for (i
= 0; i
< j
; i
++) {
1277 ND_PRINT((ndo
, " ver"));
1279 ND_PRINT((ndo
, " expires"));
1282 t
= EXTRACT_BE_U_4(bp
);
1283 bp
+= sizeof(uint32_t);
1284 tok2str(cb_types
, "type %u", t
);
1288 ND_PRINT((ndo
, " afsuuid"));
1299 ND_PRINT((ndo
, " [|cb]"));
1303 * Handle replies to the AFS Callback Service
1307 cb_reply_print(netdissect_options
*ndo
,
1308 const u_char
*bp
, u_int length
, uint32_t opcode
)
1310 const struct rx_header
*rxh
;
1313 if (length
<= sizeof(struct rx_header
))
1316 rxh
= (const struct rx_header
*) bp
;
1319 * Print out the afs call we're invoking. The table used here was
1320 * gleaned from fsint/afscbint.xg
1323 ND_PRINT((ndo
, " cb reply %s", tok2str(cb_req
, "op#%u", opcode
)));
1325 type
= EXTRACT_U_1(rxh
->type
);
1326 bp
+= sizeof(struct rx_header
);
1329 * If it was a data packet, interpret the response.
1332 if (type
== RX_PACKET_TYPE_DATA
)
1334 case 213: /* InitCallBackState3 */
1342 * Otherwise, just print out the return code
1344 ND_PRINT((ndo
, " errcode"));
1351 ND_PRINT((ndo
, " [|cb]"));
1355 * Handle calls to the AFS protection database server
1359 prot_print(netdissect_options
*ndo
,
1360 const u_char
*bp
, u_int length
)
1365 if (length
<= sizeof(struct rx_header
))
1369 * Print out the afs call we're invoking. The table used here was
1370 * gleaned from ptserver/ptint.xg
1373 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
1374 pt_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
1376 ND_PRINT((ndo
, " pt"));
1378 if (is_ubik(pt_op
)) {
1379 ubik_print(ndo
, bp
);
1383 ND_PRINT((ndo
, " call %s", tok2str(pt_req
, "op#%u", pt_op
)));
1386 * Decode some of the arguments to the PT calls
1389 bp
+= sizeof(struct rx_header
) + 4;
1392 case 500: /* I New User */
1394 ND_PRINT((ndo
, " id"));
1396 ND_PRINT((ndo
, " oldid"));
1399 case 501: /* Where is it */
1400 case 506: /* Delete */
1401 case 508: /* Get CPS */
1402 case 512: /* List entry */
1403 case 514: /* List elements */
1404 case 517: /* List owned */
1405 case 518: /* Get CPS2 */
1406 case 519: /* Get host CPS */
1407 case 530: /* List super groups */
1408 ND_PRINT((ndo
, " id"));
1411 case 502: /* Dump entry */
1412 ND_PRINT((ndo
, " pos"));
1415 case 503: /* Add to group */
1416 case 507: /* Remove from group */
1417 case 515: /* Is a member of? */
1418 ND_PRINT((ndo
, " uid"));
1420 ND_PRINT((ndo
, " gid"));
1423 case 504: /* Name to ID */
1427 j
= EXTRACT_BE_U_4(bp
);
1428 bp
+= sizeof(uint32_t);
1431 * Who designed this chicken-shit protocol?
1433 * Each character is stored as a 32-bit
1437 for (i
= 0; i
< j
; i
++) {
1441 ND_PRINT((ndo
, " <none!>"));
1444 case 505: /* Id to name */
1447 ND_PRINT((ndo
, " ids:"));
1449 i
= EXTRACT_BE_U_4(bp
);
1450 bp
+= sizeof(uint32_t);
1451 for (j
= 0; j
< i
; j
++)
1454 ND_PRINT((ndo
, " <none!>"));
1457 case 509: /* New entry */
1459 ND_PRINT((ndo
, " flag"));
1461 ND_PRINT((ndo
, " oid"));
1464 case 511: /* Set max */
1465 ND_PRINT((ndo
, " id"));
1467 ND_PRINT((ndo
, " gflag"));
1470 case 513: /* Change entry */
1471 ND_PRINT((ndo
, " id"));
1474 ND_PRINT((ndo
, " oldid"));
1476 ND_PRINT((ndo
, " newid"));
1479 case 520: /* Update entry */
1480 ND_PRINT((ndo
, " id"));
1492 ND_PRINT((ndo
, " [|pt]"));
1496 * Handle replies to the AFS protection service
1500 prot_reply_print(netdissect_options
*ndo
,
1501 const u_char
*bp
, u_int length
, uint32_t opcode
)
1503 const struct rx_header
*rxh
;
1507 if (length
< sizeof(struct rx_header
))
1510 rxh
= (const struct rx_header
*) bp
;
1513 * Print out the afs call we're invoking. The table used here was
1514 * gleaned from ptserver/ptint.xg. Check to see if it's a
1515 * Ubik call, however.
1518 ND_PRINT((ndo
, " pt"));
1520 if (is_ubik(opcode
)) {
1521 ubik_reply_print(ndo
, bp
, length
, opcode
);
1525 ND_PRINT((ndo
, " reply %s", tok2str(pt_req
, "op#%u", opcode
)));
1527 type
= EXTRACT_U_1(rxh
->type
);
1528 bp
+= sizeof(struct rx_header
);
1531 * If it was a data packet, interpret the response
1534 if (type
== RX_PACKET_TYPE_DATA
)
1536 case 504: /* Name to ID */
1539 ND_PRINT((ndo
, " ids:"));
1541 i
= EXTRACT_BE_U_4(bp
);
1542 bp
+= sizeof(uint32_t);
1543 for (j
= 0; j
< i
; j
++)
1546 ND_PRINT((ndo
, " <none!>"));
1549 case 505: /* ID to name */
1553 j
= EXTRACT_BE_U_4(bp
);
1554 bp
+= sizeof(uint32_t);
1557 * Who designed this chicken-shit protocol?
1559 * Each character is stored as a 32-bit
1563 for (i
= 0; i
< j
; i
++) {
1567 ND_PRINT((ndo
, " <none!>"));
1570 case 508: /* Get CPS */
1571 case 514: /* List elements */
1572 case 517: /* List owned */
1573 case 518: /* Get CPS2 */
1574 case 519: /* Get host CPS */
1578 j
= EXTRACT_BE_U_4(bp
);
1579 bp
+= sizeof(uint32_t);
1580 for (i
= 0; i
< j
; i
++) {
1584 ND_PRINT((ndo
, " <none!>"));
1587 case 510: /* List max */
1588 ND_PRINT((ndo
, " maxuid"));
1590 ND_PRINT((ndo
, " maxgid"));
1598 * Otherwise, just print out the return code
1600 ND_PRINT((ndo
, " errcode"));
1607 ND_PRINT((ndo
, " [|pt]"));
1611 * Handle calls to the AFS volume location database service
1615 vldb_print(netdissect_options
*ndo
,
1616 const u_char
*bp
, u_int length
)
1621 if (length
<= sizeof(struct rx_header
))
1625 * Print out the afs call we're invoking. The table used here was
1626 * gleaned from vlserver/vldbint.xg
1629 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
1630 vldb_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
1632 ND_PRINT((ndo
, " vldb"));
1634 if (is_ubik(vldb_op
)) {
1635 ubik_print(ndo
, bp
);
1638 ND_PRINT((ndo
, " call %s", tok2str(vldb_req
, "op#%u", vldb_op
)));
1641 * Decode some of the arguments to the VLDB calls
1644 bp
+= sizeof(struct rx_header
) + 4;
1647 case 501: /* Create new volume */
1648 case 517: /* Create entry N */
1651 case 502: /* Delete entry */
1652 case 503: /* Get entry by ID */
1653 case 507: /* Update entry */
1654 case 508: /* Set lock */
1655 case 509: /* Release lock */
1656 case 518: /* Get entry by ID N */
1657 ND_PRINT((ndo
, " volid"));
1660 i
= EXTRACT_BE_U_4(bp
);
1661 bp
+= sizeof(uint32_t);
1663 ND_PRINT((ndo
, " type %s", voltype
[i
]));
1665 case 504: /* Get entry by name */
1666 case 519: /* Get entry by name N */
1667 case 524: /* Update entry by name */
1668 case 527: /* Get entry by name U */
1671 case 505: /* Get new vol id */
1672 ND_PRINT((ndo
, " bump"));
1675 case 506: /* Replace entry */
1676 case 520: /* Replace entry N */
1677 ND_PRINT((ndo
, " volid"));
1680 i
= EXTRACT_BE_U_4(bp
);
1681 bp
+= sizeof(uint32_t);
1683 ND_PRINT((ndo
, " type %s", voltype
[i
]));
1686 case 510: /* List entry */
1687 case 521: /* List entry N */
1688 ND_PRINT((ndo
, " index"));
1698 ND_PRINT((ndo
, " [|vldb]"));
1702 * Handle replies to the AFS volume location database service
1706 vldb_reply_print(netdissect_options
*ndo
,
1707 const u_char
*bp
, u_int length
, uint32_t opcode
)
1709 const struct rx_header
*rxh
;
1713 if (length
< sizeof(struct rx_header
))
1716 rxh
= (const struct rx_header
*) bp
;
1719 * Print out the afs call we're invoking. The table used here was
1720 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1721 * Ubik call, however.
1724 ND_PRINT((ndo
, " vldb"));
1726 if (is_ubik(opcode
)) {
1727 ubik_reply_print(ndo
, bp
, length
, opcode
);
1731 ND_PRINT((ndo
, " reply %s", tok2str(vldb_req
, "op#%u", opcode
)));
1733 type
= EXTRACT_U_1(rxh
->type
);
1734 bp
+= sizeof(struct rx_header
);
1737 * If it was a data packet, interpret the response
1740 if (type
== RX_PACKET_TYPE_DATA
)
1742 case 510: /* List entry */
1743 ND_PRINT((ndo
, " count"));
1745 ND_PRINT((ndo
, " nextindex"));
1747 case 503: /* Get entry by id */
1748 case 504: /* Get entry by name */
1749 { uint32_t nservers
, j
;
1752 bp
+= sizeof(uint32_t);
1753 ND_PRINT((ndo
, " numservers"));
1755 nservers
= EXTRACT_BE_U_4(bp
);
1756 bp
+= sizeof(uint32_t);
1757 ND_PRINT((ndo
, " %u", nservers
));
1758 ND_PRINT((ndo
, " servers"));
1759 for (i
= 0; i
< 8; i
++) {
1762 ND_PRINT((ndo
, " %s",
1763 intoa(((const struct in_addr
*) bp
)->s_addr
)));
1764 bp
+= sizeof(uint32_t);
1766 ND_PRINT((ndo
, " partitions"));
1767 for (i
= 0; i
< 8; i
++) {
1769 j
= EXTRACT_BE_U_4(bp
);
1770 if (i
< nservers
&& j
<= 26)
1771 ND_PRINT((ndo
, " %c", 'a' + j
));
1772 else if (i
< nservers
)
1773 ND_PRINT((ndo
, " %u", j
));
1774 bp
+= sizeof(uint32_t);
1776 ND_TCHECK_LEN(bp
, 8 * sizeof(uint32_t));
1777 bp
+= 8 * sizeof(uint32_t);
1778 ND_PRINT((ndo
, " rwvol"));
1780 ND_PRINT((ndo
, " rovol"));
1782 ND_PRINT((ndo
, " backup"));
1786 case 505: /* Get new volume ID */
1787 ND_PRINT((ndo
, " newvol"));
1790 case 521: /* List entry */
1791 case 529: /* List entry U */
1792 ND_PRINT((ndo
, " count"));
1794 ND_PRINT((ndo
, " nextindex"));
1796 case 518: /* Get entry by ID N */
1797 case 519: /* Get entry by name N */
1798 { uint32_t nservers
, j
;
1800 ND_PRINT((ndo
, " numservers"));
1802 nservers
= EXTRACT_BE_U_4(bp
);
1803 bp
+= sizeof(uint32_t);
1804 ND_PRINT((ndo
, " %u", nservers
));
1805 ND_PRINT((ndo
, " servers"));
1806 for (i
= 0; i
< 13; i
++) {
1809 ND_PRINT((ndo
, " %s",
1810 intoa(((const struct in_addr
*) bp
)->s_addr
)));
1811 bp
+= sizeof(uint32_t);
1813 ND_PRINT((ndo
, " partitions"));
1814 for (i
= 0; i
< 13; i
++) {
1816 j
= EXTRACT_BE_U_4(bp
);
1817 if (i
< nservers
&& j
<= 26)
1818 ND_PRINT((ndo
, " %c", 'a' + j
));
1819 else if (i
< nservers
)
1820 ND_PRINT((ndo
, " %u", j
));
1821 bp
+= sizeof(uint32_t);
1823 ND_TCHECK_LEN(bp
, 13 * sizeof(uint32_t));
1824 bp
+= 13 * sizeof(uint32_t);
1825 ND_PRINT((ndo
, " rwvol"));
1827 ND_PRINT((ndo
, " rovol"));
1829 ND_PRINT((ndo
, " backup"));
1833 case 526: /* Get entry by ID U */
1834 case 527: /* Get entry by name U */
1835 { uint32_t nservers
, j
;
1837 ND_PRINT((ndo
, " numservers"));
1839 nservers
= EXTRACT_BE_U_4(bp
);
1840 bp
+= sizeof(uint32_t);
1841 ND_PRINT((ndo
, " %u", nservers
));
1842 ND_PRINT((ndo
, " servers"));
1843 for (i
= 0; i
< 13; i
++) {
1845 ND_PRINT((ndo
, " afsuuid"));
1848 ND_TCHECK_LEN(bp
, 44);
1852 ND_TCHECK_LEN(bp
, 4 * 13);
1854 ND_PRINT((ndo
, " partitions"));
1855 for (i
= 0; i
< 13; i
++) {
1857 j
= EXTRACT_BE_U_4(bp
);
1858 if (i
< nservers
&& j
<= 26)
1859 ND_PRINT((ndo
, " %c", 'a' + j
));
1860 else if (i
< nservers
)
1861 ND_PRINT((ndo
, " %u", j
));
1862 bp
+= sizeof(uint32_t);
1864 ND_TCHECK_LEN(bp
, 13 * sizeof(uint32_t));
1865 bp
+= 13 * sizeof(uint32_t);
1866 ND_PRINT((ndo
, " rwvol"));
1868 ND_PRINT((ndo
, " rovol"));
1870 ND_PRINT((ndo
, " backup"));
1879 * Otherwise, just print out the return code
1881 ND_PRINT((ndo
, " errcode"));
1888 ND_PRINT((ndo
, " [|vldb]"));
1892 * Handle calls to the AFS Kerberos Authentication service
1896 kauth_print(netdissect_options
*ndo
,
1897 const u_char
*bp
, u_int length
)
1901 if (length
<= sizeof(struct rx_header
))
1905 * Print out the afs call we're invoking. The table used here was
1906 * gleaned from kauth/kauth.rg
1909 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
1910 kauth_op
= EXTRACT_BE_U_4(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#%u", 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"));
1952 i
= EXTRACT_BE_U_4(bp
);
1953 bp
+= sizeof(uint32_t);
1954 ND_TCHECK_LEN(bp
, 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 const u_char
*bp
, u_int length
, uint32_t opcode
)
1990 const struct rx_header
*rxh
;
1993 if (length
<= sizeof(struct rx_header
))
1996 rxh
= (const struct rx_header
*) bp
;
1999 * Print out the afs call we're invoking. The table used here was
2000 * gleaned from kauth/kauth.rg
2003 ND_PRINT((ndo
, " kauth"));
2005 if (is_ubik(opcode
)) {
2006 ubik_reply_print(ndo
, bp
, length
, opcode
);
2010 ND_PRINT((ndo
, " reply %s", tok2str(kauth_req
, "op#%u", opcode
)));
2012 type
= EXTRACT_U_1(rxh
->type
);
2013 bp
+= sizeof(struct rx_header
);
2016 * If it was a data packet, interpret the response.
2019 if (type
== RX_PACKET_TYPE_DATA
)
2020 /* Well, no, not really. Leave this for later */
2024 * Otherwise, just print out the return code
2026 ND_PRINT((ndo
, " errcode"));
2033 ND_PRINT((ndo
, " [|kauth]"));
2037 * Handle calls to the AFS Volume location service
2041 vol_print(netdissect_options
*ndo
,
2042 const u_char
*bp
, u_int length
)
2046 if (length
<= sizeof(struct rx_header
))
2050 * Print out the afs call we're invoking. The table used here was
2051 * gleaned from volser/volint.xg
2054 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
2055 vol_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
2057 ND_PRINT((ndo
, " vol call %s", tok2str(vol_req
, "op#%u", vol_op
)));
2059 bp
+= sizeof(struct rx_header
) + 4;
2062 case 100: /* Create volume */
2063 ND_PRINT((ndo
, " partition"));
2065 ND_PRINT((ndo
, " name"));
2067 ND_PRINT((ndo
, " type"));
2069 ND_PRINT((ndo
, " parent"));
2072 case 101: /* Delete volume */
2073 case 107: /* Get flags */
2074 ND_PRINT((ndo
, " trans"));
2077 case 102: /* Restore */
2078 ND_PRINT((ndo
, " totrans"));
2080 ND_PRINT((ndo
, " flags"));
2083 case 103: /* Forward */
2084 ND_PRINT((ndo
, " fromtrans"));
2086 ND_PRINT((ndo
, " fromdate"));
2089 ND_PRINT((ndo
, " desttrans"));
2092 case 104: /* End trans */
2093 ND_PRINT((ndo
, " trans"));
2096 case 105: /* Clone */
2097 ND_PRINT((ndo
, " trans"));
2099 ND_PRINT((ndo
, " purgevol"));
2101 ND_PRINT((ndo
, " newtype"));
2103 ND_PRINT((ndo
, " newname"));
2106 case 106: /* Set flags */
2107 ND_PRINT((ndo
, " trans"));
2109 ND_PRINT((ndo
, " flags"));
2112 case 108: /* Trans create */
2113 ND_PRINT((ndo
, " vol"));
2115 ND_PRINT((ndo
, " partition"));
2117 ND_PRINT((ndo
, " flags"));
2120 case 109: /* Dump */
2121 case 655537: /* Get size */
2122 ND_PRINT((ndo
, " fromtrans"));
2124 ND_PRINT((ndo
, " fromdate"));
2127 case 110: /* Get n-th volume */
2128 ND_PRINT((ndo
, " index"));
2131 case 111: /* Set forwarding */
2132 ND_PRINT((ndo
, " tid"));
2134 ND_PRINT((ndo
, " newsite"));
2137 case 112: /* Get name */
2138 case 113: /* Get status */
2139 ND_PRINT((ndo
, " tid"));
2141 case 114: /* Signal restore */
2142 ND_PRINT((ndo
, " name"));
2144 ND_PRINT((ndo
, " type"));
2146 ND_PRINT((ndo
, " pid"));
2148 ND_PRINT((ndo
, " cloneid"));
2151 case 116: /* List volumes */
2152 ND_PRINT((ndo
, " partition"));
2154 ND_PRINT((ndo
, " flags"));
2157 case 117: /* Set id types */
2158 ND_PRINT((ndo
, " tid"));
2160 ND_PRINT((ndo
, " name"));
2162 ND_PRINT((ndo
, " type"));
2164 ND_PRINT((ndo
, " pid"));
2166 ND_PRINT((ndo
, " clone"));
2168 ND_PRINT((ndo
, " backup"));
2171 case 119: /* Partition info */
2172 ND_PRINT((ndo
, " name"));
2175 case 120: /* Reclone */
2176 ND_PRINT((ndo
, " tid"));
2179 case 121: /* List one volume */
2180 case 122: /* Nuke volume */
2181 case 124: /* Extended List volumes */
2182 case 125: /* Extended List one volume */
2183 case 65536: /* Convert RO to RW volume */
2184 ND_PRINT((ndo
, " partid"));
2186 ND_PRINT((ndo
, " volid"));
2189 case 123: /* Set date */
2190 ND_PRINT((ndo
, " tid"));
2192 ND_PRINT((ndo
, " date"));
2195 case 126: /* Set info */
2196 ND_PRINT((ndo
, " tid"));
2199 case 128: /* Forward multiple */
2200 ND_PRINT((ndo
, " fromtrans"));
2202 ND_PRINT((ndo
, " fromdate"));
2207 j
= EXTRACT_BE_U_4(bp
);
2208 bp
+= sizeof(uint32_t);
2209 for (i
= 0; i
< j
; i
++) {
2212 ND_PRINT((ndo
, ","));
2215 ND_PRINT((ndo
, " <none!>"));
2218 case 65538: /* Dump version 2 */
2219 ND_PRINT((ndo
, " fromtrans"));
2221 ND_PRINT((ndo
, " fromdate"));
2223 ND_PRINT((ndo
, " flags"));
2232 ND_PRINT((ndo
, " [|vol]"));
2236 * Handle replies to the AFS Volume Service
2240 vol_reply_print(netdissect_options
*ndo
,
2241 const u_char
*bp
, u_int length
, uint32_t opcode
)
2243 const struct rx_header
*rxh
;
2246 if (length
<= sizeof(struct rx_header
))
2249 rxh
= (const 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#%u", opcode
)));
2258 type
= EXTRACT_U_1(rxh
->type
);
2259 bp
+= sizeof(struct rx_header
);
2262 * If it was a data packet, interpret the response.
2265 if (type
== RX_PACKET_TYPE_DATA
) {
2267 case 100: /* Create volume */
2268 ND_PRINT((ndo
, " volid"));
2270 ND_PRINT((ndo
, " trans"));
2273 case 104: /* End transaction */
2276 case 105: /* Clone */
2277 ND_PRINT((ndo
, " newvol"));
2280 case 107: /* Get flags */
2283 case 108: /* Transaction create */
2284 ND_PRINT((ndo
, " trans"));
2287 case 110: /* Get n-th volume */
2288 ND_PRINT((ndo
, " volume"));
2290 ND_PRINT((ndo
, " partition"));
2293 case 112: /* Get name */
2296 case 113: /* Get status */
2297 ND_PRINT((ndo
, " volid"));
2299 ND_PRINT((ndo
, " nextuniq"));
2301 ND_PRINT((ndo
, " type"));
2303 ND_PRINT((ndo
, " parentid"));
2305 ND_PRINT((ndo
, " clone"));
2307 ND_PRINT((ndo
, " backup"));
2309 ND_PRINT((ndo
, " restore"));
2311 ND_PRINT((ndo
, " maxquota"));
2313 ND_PRINT((ndo
, " minquota"));
2315 ND_PRINT((ndo
, " owner"));
2317 ND_PRINT((ndo
, " create"));
2319 ND_PRINT((ndo
, " access"));
2321 ND_PRINT((ndo
, " update"));
2323 ND_PRINT((ndo
, " expire"));
2325 ND_PRINT((ndo
, " backup"));
2327 ND_PRINT((ndo
, " copy"));
2330 case 115: /* Old list partitions */
2332 case 116: /* List volumes */
2333 case 121: /* List one volume */
2337 j
= EXTRACT_BE_U_4(bp
);
2338 bp
+= sizeof(uint32_t);
2339 for (i
= 0; i
< j
; i
++) {
2340 ND_PRINT((ndo
, " name"));
2342 ND_PRINT((ndo
, " volid"));
2344 ND_PRINT((ndo
, " type"));
2345 bp
+= sizeof(uint32_t) * 21;
2347 ND_PRINT((ndo
, ","));
2350 ND_PRINT((ndo
, " <none!>"));
2360 * Otherwise, just print out the return code
2362 ND_PRINT((ndo
, " errcode"));
2369 ND_PRINT((ndo
, " [|vol]"));
2373 * Handle calls to the AFS BOS service
2377 bos_print(netdissect_options
*ndo
,
2378 const u_char
*bp
, u_int length
)
2382 if (length
<= sizeof(struct rx_header
))
2386 * Print out the afs call we're invoking. The table used here was
2387 * gleaned from bozo/bosint.xg
2390 ND_TCHECK_4(bp
+ sizeof(struct rx_header
));
2391 bos_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
2393 ND_PRINT((ndo
, " bos call %s", tok2str(bos_req
, "op#%u", bos_op
)));
2396 * Decode some of the arguments to the BOS calls
2399 bp
+= sizeof(struct rx_header
) + 4;
2402 case 80: /* Create B node */
2403 ND_PRINT((ndo
, " type"));
2405 ND_PRINT((ndo
, " instance"));
2408 case 81: /* Delete B node */
2409 case 83: /* Get status */
2410 case 85: /* Get instance info */
2411 case 87: /* Add super user */
2412 case 88: /* Delete super user */
2413 case 93: /* Set cell name */
2414 case 96: /* Add cell host */
2415 case 97: /* Delete cell host */
2416 case 104: /* Restart */
2417 case 106: /* Uninstall */
2418 case 108: /* Exec */
2419 case 112: /* Getlog */
2420 case 114: /* Get instance strings */
2423 case 82: /* Set status */
2424 case 98: /* Set T status */
2426 ND_PRINT((ndo
, " status"));
2429 case 86: /* Get instance parm */
2431 ND_PRINT((ndo
, " num"));
2434 case 84: /* Enumerate instance */
2435 case 89: /* List super users */
2436 case 90: /* List keys */
2437 case 91: /* Add key */
2438 case 92: /* Delete key */
2439 case 95: /* Get cell host */
2442 case 105: /* Install */
2444 ND_PRINT((ndo
, " size"));
2446 ND_PRINT((ndo
, " flags"));
2448 ND_PRINT((ndo
, " date"));
2458 ND_PRINT((ndo
, " [|bos]"));
2462 * Handle replies to the AFS BOS Service
2466 bos_reply_print(netdissect_options
*ndo
,
2467 const u_char
*bp
, u_int length
, uint32_t opcode
)
2469 const struct rx_header
*rxh
;
2472 if (length
<= sizeof(struct rx_header
))
2475 rxh
= (const struct rx_header
*) bp
;
2478 * Print out the afs call we're invoking. The table used here was
2479 * gleaned from volser/volint.xg
2482 ND_PRINT((ndo
, " bos reply %s", tok2str(bos_req
, "op#%u", opcode
)));
2484 type
= EXTRACT_U_1(rxh
->type
);
2485 bp
+= sizeof(struct rx_header
);
2488 * If it was a data packet, interpret the response.
2491 if (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
,
2534 * Print out the afs call we're invoking. The table used here was
2535 * gleaned from ubik/ubik_int.xg
2538 /* Every function that calls this function first makes a bounds check
2539 * for (sizeof(rx_header) + 4) bytes, so long as it remains this way
2540 * the line below will not over-read.
2542 ubik_op
= EXTRACT_BE_U_4(bp
+ sizeof(struct rx_header
));
2544 ND_PRINT((ndo
, " ubik call %s", tok2str(ubik_req
, "op#%u", ubik_op
)));
2547 * Decode some of the arguments to the Ubik calls
2550 bp
+= sizeof(struct rx_header
) + 4;
2553 case 10000: /* Beacon */
2555 temp
= EXTRACT_BE_U_4(bp
);
2556 bp
+= sizeof(uint32_t);
2557 ND_PRINT((ndo
, " syncsite %s", temp
? "yes" : "no"));
2558 ND_PRINT((ndo
, " votestart"));
2560 ND_PRINT((ndo
, " dbversion"));
2562 ND_PRINT((ndo
, " tid"));
2565 case 10003: /* Get sync site */
2566 ND_PRINT((ndo
, " site"));
2569 case 20000: /* Begin */
2570 case 20001: /* Commit */
2571 case 20007: /* Abort */
2572 case 20008: /* Release locks */
2573 case 20010: /* Writev */
2574 ND_PRINT((ndo
, " tid"));
2577 case 20002: /* Lock */
2578 ND_PRINT((ndo
, " tid"));
2580 ND_PRINT((ndo
, " file"));
2582 ND_PRINT((ndo
, " pos"));
2584 ND_PRINT((ndo
, " length"));
2587 temp
= EXTRACT_BE_U_4(bp
);
2588 bp
+= sizeof(uint32_t);
2589 tok2str(ubik_lock_types
, "type %u", temp
);
2591 case 20003: /* Write */
2592 ND_PRINT((ndo
, " tid"));
2594 ND_PRINT((ndo
, " file"));
2596 ND_PRINT((ndo
, " pos"));
2599 case 20005: /* Get file */
2600 ND_PRINT((ndo
, " file"));
2603 case 20006: /* Send file */
2604 ND_PRINT((ndo
, " file"));
2606 ND_PRINT((ndo
, " length"));
2608 ND_PRINT((ndo
, " dbversion"));
2611 case 20009: /* Truncate */
2612 ND_PRINT((ndo
, " tid"));
2614 ND_PRINT((ndo
, " file"));
2616 ND_PRINT((ndo
, " length"));
2619 case 20012: /* Set version */
2620 ND_PRINT((ndo
, " tid"));
2622 ND_PRINT((ndo
, " oldversion"));
2624 ND_PRINT((ndo
, " newversion"));
2634 ND_PRINT((ndo
, " [|ubik]"));
2638 * Handle Ubik replies to any one of the replicated database services
2642 ubik_reply_print(netdissect_options
*ndo
,
2643 const u_char
*bp
, u_int length
, uint32_t opcode
)
2645 const struct rx_header
*rxh
;
2648 if (length
< sizeof(struct rx_header
))
2651 rxh
= (const struct rx_header
*) bp
;
2654 * Print out the ubik call we're invoking. This table was gleaned
2655 * from ubik/ubik_int.xg
2658 ND_PRINT((ndo
, " ubik reply %s", tok2str(ubik_req
, "op#%u", opcode
)));
2660 type
= EXTRACT_U_1(rxh
->type
);
2661 bp
+= sizeof(struct rx_header
);
2664 * If it was a data packet, print out the arguments to the Ubik calls
2667 if (type
== RX_PACKET_TYPE_DATA
)
2669 case 10000: /* Beacon */
2670 ND_PRINT((ndo
, " vote no"));
2672 case 20004: /* Get version */
2673 ND_PRINT((ndo
, " dbversion"));
2681 * Otherwise, print out "yes" it it was a beacon packet (because
2682 * that's how yes votes are returned, go figure), otherwise
2683 * just print out the error code.
2688 case 10000: /* Beacon */
2689 ND_PRINT((ndo
, " vote yes until"));
2693 ND_PRINT((ndo
, " errcode"));
2700 ND_PRINT((ndo
, " [|ubik]"));
2704 * Handle RX ACK packets.
2708 rx_ack_print(netdissect_options
*ndo
,
2709 const u_char
*bp
, u_int length
)
2711 const struct rx_ackPacket
*rxa
;
2714 uint32_t firstPacket
;
2716 if (length
< sizeof(struct rx_header
))
2719 bp
+= sizeof(struct rx_header
);
2721 ND_TCHECK_LEN(bp
, sizeof(struct rx_ackPacket
));
2723 rxa
= (const struct rx_ackPacket
*) bp
;
2724 bp
+= sizeof(struct rx_ackPacket
);
2727 * Print out a few useful things from the ack packet structure
2730 if (ndo
->ndo_vflag
> 2)
2731 ND_PRINT((ndo
, " bufspace %u maxskew %d",
2732 EXTRACT_BE_U_2(rxa
->bufferSpace
),
2733 EXTRACT_BE_U_2(rxa
->maxSkew
)));
2735 firstPacket
= EXTRACT_BE_U_4(rxa
->firstPacket
);
2736 ND_PRINT((ndo
, " first %u serial %u reason %s",
2737 firstPacket
, EXTRACT_BE_U_4(rxa
->serial
),
2738 tok2str(rx_ack_reasons
, "#%u", EXTRACT_U_1(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 nAcks
= EXTRACT_U_1(rxa
->nAcks
);
2762 ND_TCHECK_LEN(bp
, nAcks
);
2765 * Sigh, this is gross, but it seems to work to collapse
2769 for (i
= 0, start
= last
= -2; i
< nAcks
; i
++)
2770 if (EXTRACT_U_1(bp
+ i
) == RX_ACK_TYPE_ACK
) {
2773 * I figured this deserved _some_ explanation.
2774 * First, print "acked" and the packet seq
2775 * number if this is the first time we've
2776 * seen an acked packet.
2780 ND_PRINT((ndo
, " acked %u", firstPacket
+ i
));
2785 * Otherwise, if there is a skip in
2786 * the range (such as an nacked packet in
2787 * the middle of some acked packets),
2788 * then print the current packet number
2789 * seperated from the last number by
2793 else if (last
!= i
- 1) {
2794 ND_PRINT((ndo
, ",%u", firstPacket
+ i
));
2799 * We always set last to the value of
2800 * the last ack we saw. Conversely, start
2801 * is set to the value of the first ack
2802 * we saw in a range.
2808 * Okay, this bit a code gets executed when
2809 * we hit a nack ... in _this_ case we
2810 * want to print out the range of packets
2811 * that were acked, so we need to print
2812 * the _previous_ packet number seperated
2813 * from the first by a dash (-). Since we
2814 * already printed the first packet above,
2815 * just print the final packet. Don't
2816 * do this if there will be a single-length
2819 } else if (last
== i
- 1 && start
!= last
)
2820 ND_PRINT((ndo
, "-%u", firstPacket
+ i
- 1));
2823 * So, what's going on here? We ran off the end of the
2824 * ack list, and if we got a range we need to finish it up.
2825 * So we need to determine if the last packet in the list
2826 * was an ack (if so, then last will be set to it) and
2827 * we need to see if the last range didn't start with the
2828 * last packet (because if it _did_, then that would mean
2829 * that the packet number has already been printed and
2830 * we don't need to print it again).
2833 if (last
== i
- 1 && start
!= last
)
2834 ND_PRINT((ndo
, "-%u", firstPacket
+ i
- 1));
2837 * Same as above, just without comments
2840 for (i
= 0, start
= last
= -2; i
< nAcks
; i
++)
2841 if (EXTRACT_U_1(bp
+ i
) == RX_ACK_TYPE_NACK
) {
2843 ND_PRINT((ndo
, " nacked %u", firstPacket
+ i
));
2845 } else if (last
!= i
- 1) {
2846 ND_PRINT((ndo
, ",%u", firstPacket
+ i
));
2850 } else if (last
== i
- 1 && start
!= last
)
2851 ND_PRINT((ndo
, "-%u", firstPacket
+ i
- 1));
2853 if (last
== i
- 1 && start
!= last
)
2854 ND_PRINT((ndo
, "-%u", firstPacket
+ i
- 1));
2863 * These are optional fields; depending on your version of AFS,
2864 * you may or may not see them
2867 #define TRUNCRET(n) if (ndo->ndo_snapend - bp + 1 <= n) return;
2869 if (ndo
->ndo_vflag
> 1) {
2871 ND_PRINT((ndo
, " ifmtu"));
2875 ND_PRINT((ndo
, " maxmtu"));
2879 ND_PRINT((ndo
, " rwind"));
2883 ND_PRINT((ndo
, " maxpackets"));
2890 ND_PRINT((ndo
, " [|ack]"));