]>
The Tcpdump Group git mirrors - tcpdump/blob - print-rx.c
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>
42 #include <tcpdump-stdinc.h>
44 #include "interface.h"
45 #include "addrtoname.h"
50 #define FS_RX_PORT 7000
51 #define CB_RX_PORT 7001
52 #define PROT_RX_PORT 7002
53 #define VLDB_RX_PORT 7003
54 #define KAUTH_RX_PORT 7004
55 #define VOL_RX_PORT 7005
56 #define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
57 #define BOS_RX_PORT 7007
59 #define AFSNAMEMAX 256
60 #define AFSOPAQUEMAX 1024
64 #define BOSNAMEMAX 256
66 #define PRSFS_READ 1 /* Read files */
67 #define PRSFS_WRITE 2 /* Write files */
68 #define PRSFS_INSERT 4 /* Insert files into a directory */
69 #define PRSFS_LOOKUP 8 /* Lookup files into a directory */
70 #define PRSFS_DELETE 16 /* Delete files */
71 #define PRSFS_LOCK 32 /* Lock files */
72 #define PRSFS_ADMINISTER 64 /* Change ACL's */
81 #define RX_PACKET_TYPE_DATA 1
82 #define RX_PACKET_TYPE_ACK 2
83 #define RX_PACKET_TYPE_BUSY 3
84 #define RX_PACKET_TYPE_ABORT 4
85 #define RX_PACKET_TYPE_ACKALL 5
86 #define RX_PACKET_TYPE_CHALLENGE 6
87 #define RX_PACKET_TYPE_RESPONSE 7
88 #define RX_PACKET_TYPE_DEBUG 8
89 #define RX_PACKET_TYPE_PARAMS 9
90 #define RX_PACKET_TYPE_VERSION 13
92 #define RX_CLIENT_INITIATED 1
93 #define RX_REQUEST_ACK 2
94 #define RX_LAST_PACKET 4
95 #define RX_MORE_PACKETS 8
96 #define RX_FREE_PACKET 16
97 #define RX_SLOW_START_OK 32
98 #define RX_JUMBO_PACKET 32
100 uint8_t securityIndex
;
101 uint16_t spare
; /* How clever: even though the AFS */
102 uint16_t serviceId
; /* header files indicate that the */
103 }; /* serviceId is first, it's really */
104 /* encoded _after_ the spare field */
105 /* I wasted a day figuring that out! */
107 #define NUM_RX_FLAGS 7
109 #define RX_MAXACKS 255
111 struct rx_ackPacket
{
112 uint16_t bufferSpace
; /* Number of packet buffers available */
113 uint16_t maxSkew
; /* Max diff between ack'd packet and */
114 /* highest packet received */
115 uint32_t firstPacket
; /* The first packet in ack list */
116 uint32_t previousPacket
; /* Previous packet recv'd (obsolete) */
117 uint32_t serial
; /* # of packet that prompted the ack */
118 uint8_t reason
; /* Reason for acknowledgement */
119 uint8_t nAcks
; /* Number of acknowledgements */
120 uint8_t acks
[RX_MAXACKS
]; /* Up to RX_MAXACKS acknowledgements */
124 * Values for the acks array
127 #define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
128 #define RX_ACK_TYPE_ACK 1 /* I have this packet */
130 static const struct tok rx_types
[] = {
131 { RX_PACKET_TYPE_DATA
, "data" },
132 { RX_PACKET_TYPE_ACK
, "ack" },
133 { RX_PACKET_TYPE_BUSY
, "busy" },
134 { RX_PACKET_TYPE_ABORT
, "abort" },
135 { RX_PACKET_TYPE_ACKALL
, "ackall" },
136 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
137 { RX_PACKET_TYPE_RESPONSE
, "response" },
138 { RX_PACKET_TYPE_DEBUG
, "debug" },
139 { RX_PACKET_TYPE_PARAMS
, "params" },
140 { RX_PACKET_TYPE_VERSION
, "version" },
144 static const struct double_tok
{
145 int flag
; /* Rx flag */
146 int packetType
; /* Packet type */
147 const char *s
; /* Flag string */
149 { RX_CLIENT_INITIATED
, 0, "client-init" },
150 { RX_REQUEST_ACK
, 0, "req-ack" },
151 { RX_LAST_PACKET
, 0, "last-pckt" },
152 { RX_MORE_PACKETS
, 0, "more-pckts" },
153 { RX_FREE_PACKET
, 0, "free-pckt" },
154 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
155 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
158 static const struct tok fs_req
[] = {
159 { 130, "fetch-data" },
160 { 131, "fetch-acl" },
161 { 132, "fetch-status" },
162 { 133, "store-data" },
163 { 134, "store-acl" },
164 { 135, "store-status" },
165 { 136, "remove-file" },
166 { 137, "create-file" },
172 { 143, "oldsetlock" },
173 { 144, "oldextlock" },
174 { 145, "oldrellock" },
175 { 146, "get-stats" },
177 { 148, "get-vlinfo" },
178 { 149, "get-vlstats" },
179 { 150, "set-vlstats" },
180 { 151, "get-rootvl" },
181 { 152, "check-token" },
183 { 154, "nget-vlinfo" },
184 { 155, "bulk-stat" },
188 { 159, "xstat-ver" },
189 { 160, "get-xstat" },
190 { 161, "dfs-lookup" },
191 { 162, "dfs-flushcps" },
192 { 163, "dfs-symlink" },
193 { 220, "residency" },
194 { 65536, "inline-bulk-status" },
195 { 65537, "fetch-data-64" },
196 { 65538, "store-data-64" },
197 { 65539, "give-up-all-cbs" },
198 { 65540, "get-caps" },
199 { 65541, "cb-rx-conn-addr" },
203 static const struct tok cb_req
[] = {
212 { 212, "whoareyou" },
214 { 214, "probeuuid" },
215 { 215, "getsrvprefs" },
216 { 216, "getcellservdb" },
217 { 217, "getlocalcell" },
218 { 218, "getcacheconf" },
219 { 65536, "getce64" },
220 { 65537, "getcellbynum" },
221 { 65538, "tellmeaboutyourself" },
225 static const struct tok pt_req
[] = {
227 { 501, "where-is-it" },
228 { 502, "dump-entry" },
229 { 503, "add-to-group" },
230 { 504, "name-to-id" },
231 { 505, "id-to-name" },
233 { 507, "remove-from-group" },
235 { 509, "new-entry" },
238 { 512, "list-entry" },
239 { 513, "change-entry" },
240 { 514, "list-elements" },
241 { 515, "same-mbr-of" },
242 { 516, "set-fld-sentry" },
243 { 517, "list-owned" },
245 { 519, "get-host-cps" },
246 { 520, "update-entry" },
247 { 521, "list-entries" },
248 { 530, "list-super-groups" },
252 static const struct tok vldb_req
[] = {
253 { 501, "create-entry" },
254 { 502, "delete-entry" },
255 { 503, "get-entry-by-id" },
256 { 504, "get-entry-by-name" },
257 { 505, "get-new-volume-id" },
258 { 506, "replace-entry" },
259 { 507, "update-entry" },
261 { 509, "releaselock" },
262 { 510, "list-entry" },
263 { 511, "list-attrib" },
264 { 512, "linked-list" },
265 { 513, "get-stats" },
267 { 515, "get-addrs" },
268 { 516, "change-addr" },
269 { 517, "create-entry-n" },
270 { 518, "get-entry-by-id-n" },
271 { 519, "get-entry-by-name-n" },
272 { 520, "replace-entry-n" },
273 { 521, "list-entry-n" },
274 { 522, "list-attrib-n" },
275 { 523, "linked-list-n" },
276 { 524, "update-entry-by-name" },
277 { 525, "create-entry-u" },
278 { 526, "get-entry-by-id-u" },
279 { 527, "get-entry-by-name-u" },
280 { 528, "replace-entry-u" },
281 { 529, "list-entry-u" },
282 { 530, "list-attrib-u" },
283 { 531, "linked-list-u" },
285 { 533, "get-addrs-u" },
286 { 534, "list-attrib-n2" },
290 static const struct tok kauth_req
[] = {
292 { 21, "authenticate" },
293 { 22, "authenticate-v2" },
295 { 3, "get-ticket-old" },
296 { 23, "get-ticket" },
299 { 6, "create-user" },
300 { 7, "delete-user" },
306 { 13, "get-random-key" },
308 { 15, "lock-status" },
312 static const struct tok vol_req
[] = {
313 { 100, "create-volume" },
314 { 101, "delete-volume" },
317 { 104, "end-trans" },
319 { 106, "set-flags" },
320 { 107, "get-flags" },
321 { 108, "trans-create" },
323 { 110, "get-nth-volume" },
324 { 111, "set-forwarding" },
326 { 113, "get-status" },
327 { 114, "sig-restore" },
328 { 115, "list-partitions" },
329 { 116, "list-volumes" },
330 { 117, "set-id-types" },
332 { 119, "partition-info" },
334 { 121, "list-one-volume" },
337 { 124, "x-list-volumes" },
338 { 125, "x-list-one-volume" },
340 { 127, "x-list-partitions" },
341 { 128, "forward-multiple" },
342 { 65536, "convert-ro" },
343 { 65537, "get-size" },
344 { 65538, "dump-v2" },
348 static const struct tok bos_req
[] = {
349 { 80, "create-bnode" },
350 { 81, "delete-bnode" },
351 { 82, "set-status" },
352 { 83, "get-status" },
353 { 84, "enumerate-instance" },
354 { 85, "get-instance-info" },
355 { 86, "get-instance-parm" },
356 { 87, "add-superuser" },
357 { 88, "delete-superuser" },
358 { 89, "list-superusers" },
361 { 92, "delete-key" },
362 { 93, "set-cell-name" },
363 { 94, "get-cell-name" },
364 { 95, "get-cell-host" },
365 { 96, "add-cell-host" },
366 { 97, "delete-cell-host" },
367 { 98, "set-t-status" },
368 { 99, "shutdown-all" },
369 { 100, "restart-all" },
370 { 101, "startup-all" },
371 { 102, "set-noauth-flag" },
374 { 105, "start-bozo-install" },
375 { 106, "uninstall" },
376 { 107, "get-dates" },
379 { 110, "set-restart-time" },
380 { 111, "get-restart-time" },
381 { 112, "start-bozo-log" },
383 { 114, "get-instance-strings" },
384 { 115, "get-restricted" },
385 { 116, "set-restricted" },
389 static const struct tok ubik_req
[] = {
390 { 10000, "vote-beacon" },
391 { 10001, "vote-debug-old" },
392 { 10002, "vote-sdebug-old" },
393 { 10003, "vote-getsyncsite" },
394 { 10004, "vote-debug" },
395 { 10005, "vote-sdebug" },
396 { 10006, "vote-xdebug" },
397 { 10007, "vote-xsdebug" },
398 { 20000, "disk-begin" },
399 { 20001, "disk-commit" },
400 { 20002, "disk-lock" },
401 { 20003, "disk-write" },
402 { 20004, "disk-getversion" },
403 { 20005, "disk-getfile" },
404 { 20006, "disk-sendfile" },
405 { 20007, "disk-abort" },
406 { 20008, "disk-releaselocks" },
407 { 20009, "disk-truncate" },
408 { 20010, "disk-probe" },
409 { 20011, "disk-writev" },
410 { 20012, "disk-interfaceaddr" },
411 { 20013, "disk-setversion" },
415 #define VOTE_LOW 10000
416 #define VOTE_HIGH 10007
417 #define DISK_LOW 20000
418 #define DISK_HIGH 20013
420 static const struct tok cb_types
[] = {
427 static const struct tok ubik_lock_types
[] = {
434 static const char *voltype
[] = { "read-write", "read-only", "backup" };
436 static const struct tok afs_fs_errors
[] = {
437 { 101, "salvage volume" },
438 { 102, "no such vnode" },
439 { 103, "no such volume" },
440 { 104, "volume exist" },
441 { 105, "no service" },
442 { 106, "volume offline" },
443 { 107, "voline online" },
445 { 109, "diskquota exceeded" },
446 { 110, "volume busy" },
447 { 111, "volume moved" },
448 { 112, "AFS IO error" },
449 { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */
454 * Reasons for acknowledging a packet
457 static const struct tok rx_ack_reasons
[] = {
458 { 1, "ack requested" },
459 { 2, "duplicate packet" },
460 { 3, "out of sequence" },
461 { 4, "exceeds window" },
462 { 5, "no buffer space" },
464 { 7, "ping response" },
471 * Cache entries we keep around so we can figure out the RX opcode
472 * numbers for replies. This allows us to make sense of RX reply packets.
475 struct rx_cache_entry
{
476 uint32_t callnum
; /* Call number (net order) */
477 struct in_addr client
; /* client IP address (net order) */
478 struct in_addr server
; /* server IP address (net order) */
479 int dport
; /* server port (host order) */
480 u_short serviceId
; /* Service identifier (net order) */
481 uint32_t opcode
; /* RX opcode (host order) */
484 #define RX_CACHE_SIZE 64
486 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
488 static int rx_cache_next
= 0;
489 static int rx_cache_hint
= 0;
490 static void rx_cache_insert(netdissect_options
*, const u_char
*, const struct ip
*, int);
491 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
494 static void fs_print(netdissect_options
*, const u_char
*, int);
495 static void fs_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
496 static void acl_print(netdissect_options
*, u_char
*, int, u_char
*);
497 static void cb_print(netdissect_options
*, const u_char
*, int);
498 static void cb_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
499 static void prot_print(netdissect_options
*, const u_char
*, int);
500 static void prot_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
501 static void vldb_print(netdissect_options
*, const u_char
*, int);
502 static void vldb_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
503 static void kauth_print(netdissect_options
*, const u_char
*, int);
504 static void kauth_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
505 static void vol_print(netdissect_options
*, const u_char
*, int);
506 static void vol_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
507 static void bos_print(netdissect_options
*, const u_char
*, int);
508 static void bos_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
509 static void ubik_print(netdissect_options
*, const u_char
*);
510 static void ubik_reply_print(netdissect_options
*, const u_char
*, int, int32_t);
512 static void rx_ack_print(netdissect_options
*, const u_char
*, int);
514 static int is_ubik(uint32_t);
517 * Handle the rx-level packet. See if we know what port it's going to so
518 * we can peek at the afs call inside
522 rx_print(netdissect_options
*ndo
,
523 register const u_char
*bp
, int length
, int sport
, int dport
,
526 register const struct rx_header
*rxh
;
530 if (ndo
->ndo_snapend
- bp
< (int)sizeof (struct rx_header
)) {
531 ND_PRINT((ndo
, " [|rx] (%d)", length
));
535 rxh
= (const struct rx_header
*) bp
;
537 ND_PRINT((ndo
, " rx %s", tok2str(rx_types
, "type %d", rxh
->type
)));
539 if (ndo
->ndo_vflag
) {
542 if (ndo
->ndo_vflag
> 1)
543 ND_PRINT((ndo
, " cid %08x call# %d",
544 (int) EXTRACT_32BITS(&rxh
->cid
),
545 (int) EXTRACT_32BITS(&rxh
->callNumber
)));
547 ND_PRINT((ndo
, " seq %d ser %d",
548 (int) EXTRACT_32BITS(&rxh
->seq
),
549 (int) EXTRACT_32BITS(&rxh
->serial
)));
551 if (ndo
->ndo_vflag
> 2)
552 ND_PRINT((ndo
, " secindex %d serviceid %hu",
553 (int) rxh
->securityIndex
,
554 EXTRACT_16BITS(&rxh
->serviceId
)));
556 if (ndo
->ndo_vflag
> 1)
557 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
558 if (rxh
->flags
& rx_flags
[i
].flag
&&
559 (!rx_flags
[i
].packetType
||
560 rxh
->type
== rx_flags
[i
].packetType
)) {
563 ND_PRINT((ndo
, " "));
565 ND_PRINT((ndo
, ","));
567 ND_PRINT((ndo
, "<%s>", rx_flags
[i
].s
));
573 * Try to handle AFS calls that we know about. Check the destination
574 * port and make sure it's a data packet. Also, make sure the
575 * seq number is 1 (because otherwise it's a continuation packet,
576 * and we can't interpret that). Also, seems that reply packets
577 * do not have the client-init flag set, so we check for that
581 if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
582 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
583 rxh
->flags
& RX_CLIENT_INITIATED
) {
586 * Insert this call into the call cache table, so we
587 * have a chance to print out replies
590 rx_cache_insert(ndo
, bp
, (const struct ip
*) bp2
, dport
);
593 case FS_RX_PORT
: /* AFS file service */
594 fs_print(ndo
, bp
, length
);
596 case CB_RX_PORT
: /* AFS callback service */
597 cb_print(ndo
, bp
, length
);
599 case PROT_RX_PORT
: /* AFS protection service */
600 prot_print(ndo
, bp
, length
);
602 case VLDB_RX_PORT
: /* AFS VLDB service */
603 vldb_print(ndo
, bp
, length
);
605 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
606 kauth_print(ndo
, bp
, length
);
608 case VOL_RX_PORT
: /* AFS Volume service */
609 vol_print(ndo
, bp
, length
);
611 case BOS_RX_PORT
: /* AFS BOS service */
612 bos_print(ndo
, bp
, length
);
619 * If it's a reply (client-init is _not_ set, but seq is one)
620 * then look it up in the cache. If we find it, call the reply
621 * printing functions Note that we handle abort packets here,
622 * because printing out the return code can be useful at times.
625 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
626 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
627 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
628 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
629 rx_cache_find(rxh
, (const struct ip
*) bp2
,
633 case FS_RX_PORT
: /* AFS file service */
634 fs_reply_print(ndo
, bp
, length
, opcode
);
636 case CB_RX_PORT
: /* AFS callback service */
637 cb_reply_print(ndo
, bp
, length
, opcode
);
639 case PROT_RX_PORT
: /* AFS PT service */
640 prot_reply_print(ndo
, bp
, length
, opcode
);
642 case VLDB_RX_PORT
: /* AFS VLDB service */
643 vldb_reply_print(ndo
, bp
, length
, opcode
);
645 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
646 kauth_reply_print(ndo
, bp
, length
, opcode
);
648 case VOL_RX_PORT
: /* AFS Volume service */
649 vol_reply_print(ndo
, bp
, length
, opcode
);
651 case BOS_RX_PORT
: /* AFS BOS service */
652 bos_reply_print(ndo
, bp
, length
, opcode
);
659 * If it's an RX ack packet, then use the appropriate ack decoding
660 * function (there isn't any service-specific information in the
661 * ack packet, so we can use one for all AFS services)
664 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
665 rx_ack_print(ndo
, bp
, length
);
668 ND_PRINT((ndo
, " (%d)", length
));
672 * Insert an entry into the cache. Taken from print-nfs.c
676 rx_cache_insert(netdissect_options
*ndo
,
677 const u_char
*bp
, const struct ip
*ip
, int dport
)
679 struct rx_cache_entry
*rxent
;
680 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
682 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t)))
685 rxent
= &rx_cache
[rx_cache_next
];
687 if (++rx_cache_next
>= RX_CACHE_SIZE
)
690 rxent
->callnum
= rxh
->callNumber
;
691 rxent
->client
= ip
->ip_src
;
692 rxent
->server
= ip
->ip_dst
;
693 rxent
->dport
= dport
;
694 rxent
->serviceId
= rxh
->serviceId
;
695 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
699 * Lookup an entry in the cache. Also taken from print-nfs.c
701 * Note that because this is a reply, we're looking at the _source_
706 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
710 struct rx_cache_entry
*rxent
;
711 uint32_t clip
= ip
->ip_dst
.s_addr
;
712 uint32_t sip
= ip
->ip_src
.s_addr
;
714 /* Start the search where we last left off */
718 rxent
= &rx_cache
[i
];
719 if (rxent
->callnum
== rxh
->callNumber
&&
720 rxent
->client
.s_addr
== clip
&&
721 rxent
->server
.s_addr
== sip
&&
722 rxent
->serviceId
== rxh
->serviceId
&&
723 rxent
->dport
== sport
) {
725 /* We got a match! */
728 *opcode
= rxent
->opcode
;
731 if (++i
>= RX_CACHE_SIZE
)
733 } while (i
!= rx_cache_hint
);
735 /* Our search failed */
740 * These extrememly grody macros handle the printing of various AFS stuff.
743 #define FIDOUT() { unsigned long n1, n2, n3; \
744 ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
745 n1 = EXTRACT_32BITS(bp); \
746 bp += sizeof(int32_t); \
747 n2 = EXTRACT_32BITS(bp); \
748 bp += sizeof(int32_t); \
749 n3 = EXTRACT_32BITS(bp); \
750 bp += sizeof(int32_t); \
751 ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \
754 #define STROUT(MAX) { unsigned int i; \
755 ND_TCHECK2(bp[0], sizeof(int32_t)); \
756 i = EXTRACT_32BITS(bp); \
759 bp += sizeof(int32_t); \
760 ND_PRINT((ndo, " \"")); \
761 if (fn_printn(ndo, bp, i, ndo->ndo_snapend)) \
763 ND_PRINT((ndo, "\"")); \
764 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
767 #define INTOUT() { int i; \
768 ND_TCHECK2(bp[0], sizeof(int32_t)); \
769 i = (int) EXTRACT_32BITS(bp); \
770 bp += sizeof(int32_t); \
771 ND_PRINT((ndo, " %d", i)); \
774 #define UINTOUT() { unsigned long i; \
775 ND_TCHECK2(bp[0], sizeof(int32_t)); \
776 i = EXTRACT_32BITS(bp); \
777 bp += sizeof(int32_t); \
778 ND_PRINT((ndo, " %lu", i)); \
781 #define UINT64OUT() { uint64_t i; \
782 ND_TCHECK2(bp[0], sizeof(uint64_t)); \
783 i = EXTRACT_64BITS(bp); \
784 bp += sizeof(uint64_t); \
785 ND_PRINT((ndo, " %" PRIu64, i)); \
788 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
789 ND_TCHECK2(bp[0], sizeof(int32_t)); \
790 t = (time_t) EXTRACT_32BITS(bp); \
791 bp += sizeof(int32_t); \
792 tm = localtime(&t); \
793 strftime(str, 256, "%Y/%m/%d %T", tm); \
794 ND_PRINT((ndo, " %s", str)); \
797 #define STOREATTROUT() { unsigned long mask, i; \
798 ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \
799 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
800 if (mask) ND_PRINT((ndo, " StoreStatus")); \
801 if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \
802 else bp += sizeof(int32_t); \
803 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
804 if (mask & 2) ND_PRINT((ndo, " owner %lu", i)); \
805 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
806 if (mask & 4) ND_PRINT((ndo, " group %lu", i)); \
807 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
808 if (mask & 8) ND_PRINT((ndo, " mode %lo", i & 07777)); \
809 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
810 if (mask & 16) ND_PRINT((ndo, " segsize %lu", i)); \
811 /* undocumented in 3.3 docu */ \
812 if (mask & 1024) ND_PRINT((ndo, " fsync")); \
815 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
816 ND_TCHECK2(bp[0], sizeof(int32_t) * 2); \
817 epoch = EXTRACT_32BITS(bp); \
818 bp += sizeof(int32_t); \
819 counter = EXTRACT_32BITS(bp); \
820 bp += sizeof(int32_t); \
821 ND_PRINT((ndo, " %d.%d", epoch, counter)); \
824 #define AFSUUIDOUT() {uint32_t temp; int i; \
825 ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \
826 temp = EXTRACT_32BITS(bp); \
827 bp += sizeof(uint32_t); \
828 ND_PRINT((ndo, " %08x", temp)); \
829 temp = EXTRACT_32BITS(bp); \
830 bp += sizeof(uint32_t); \
831 ND_PRINT((ndo, "%04x", temp)); \
832 temp = EXTRACT_32BITS(bp); \
833 bp += sizeof(uint32_t); \
834 ND_PRINT((ndo, "%04x", temp)); \
835 for (i = 0; i < 8; i++) { \
836 temp = EXTRACT_32BITS(bp); \
837 bp += sizeof(uint32_t); \
838 ND_PRINT((ndo, "%02x", (unsigned char) temp)); \
843 * This is the sickest one of all
846 #define VECOUT(MAX) { u_char *sp; \
847 u_char s[AFSNAMEMAX]; \
849 if ((MAX) + 1 > sizeof(s)) \
851 ND_TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
853 for (k = 0; k < (MAX); k++) { \
854 *sp++ = (u_char) EXTRACT_32BITS(bp); \
855 bp += sizeof(int32_t); \
858 ND_PRINT((ndo, " \"")); \
859 fn_print(ndo, s, NULL); \
860 ND_PRINT((ndo, "\"")); \
863 #define DESTSERVEROUT() { unsigned long n1, n2, n3; \
864 ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
865 n1 = EXTRACT_32BITS(bp); \
866 bp += sizeof(int32_t); \
867 n2 = EXTRACT_32BITS(bp); \
868 bp += sizeof(int32_t); \
869 n3 = EXTRACT_32BITS(bp); \
870 bp += sizeof(int32_t); \
871 ND_PRINT((ndo, " server %d:%d:%d", (int) n1, (int) n2, (int) n3)); \
875 * Handle calls to the AFS file service (fs)
879 fs_print(netdissect_options
*ndo
,
880 register const u_char
*bp
, int length
)
885 if (length
<= (int)sizeof(struct rx_header
))
888 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
893 * Print out the afs call we're invoking. The table used here was
894 * gleaned from fsint/afsint.xg
897 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
899 ND_PRINT((ndo
, " fs call %s", tok2str(fs_req
, "op#%d", fs_op
)));
902 * Print out arguments to some of the AFS calls. This stuff is
906 bp
+= sizeof(struct rx_header
) + 4;
909 * Sigh. This is gross. Ritchie forgive me.
913 case 130: /* Fetch data */
915 ND_PRINT((ndo
, " offset"));
917 ND_PRINT((ndo
, " length"));
920 case 131: /* Fetch ACL */
921 case 132: /* Fetch Status */
922 case 143: /* Old set lock */
923 case 144: /* Old extend lock */
924 case 145: /* Old release lock */
925 case 156: /* Set lock */
926 case 157: /* Extend lock */
927 case 158: /* Release lock */
930 case 135: /* Store status */
934 case 133: /* Store data */
937 ND_PRINT((ndo
, " offset"));
939 ND_PRINT((ndo
, " length"));
941 ND_PRINT((ndo
, " flen"));
944 case 134: /* Store ACL */
946 char a
[AFSOPAQUEMAX
+1];
948 ND_TCHECK2(bp
[0], 4);
949 i
= EXTRACT_32BITS(bp
);
950 bp
+= sizeof(int32_t);
951 ND_TCHECK2(bp
[0], i
);
952 i
= min(AFSOPAQUEMAX
, i
);
953 strncpy(a
, (const char *) bp
, i
);
955 acl_print(ndo
, (u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
958 case 137: /* Create file */
959 case 141: /* MakeDir */
964 case 136: /* Remove file */
965 case 142: /* Remove directory */
969 case 138: /* Rename file */
970 ND_PRINT((ndo
, " old"));
973 ND_PRINT((ndo
, " new"));
977 case 139: /* Symlink */
980 ND_PRINT((ndo
, " link to"));
986 ND_PRINT((ndo
, " link to"));
989 case 148: /* Get volume info */
992 case 149: /* Get volume stats */
993 case 150: /* Set volume stats */
994 ND_PRINT((ndo
, " volid"));
997 case 154: /* New get volume info */
998 ND_PRINT((ndo
, " volname"));
1001 case 155: /* Bulk stat */
1002 case 65536: /* Inline bulk stat */
1005 ND_TCHECK2(bp
[0], 4);
1006 j
= EXTRACT_32BITS(bp
);
1007 bp
+= sizeof(int32_t);
1009 for (i
= 0; i
< j
; i
++) {
1012 ND_PRINT((ndo
, ","));
1015 ND_PRINT((ndo
, " <none!>"));
1017 case 65537: /* Fetch data 64 */
1019 ND_PRINT((ndo
, " offset"));
1021 ND_PRINT((ndo
, " length"));
1024 case 65538: /* Store data 64 */
1027 ND_PRINT((ndo
, " offset"));
1029 ND_PRINT((ndo
, " length"));
1031 ND_PRINT((ndo
, " flen"));
1034 case 65541: /* CallBack rx conn address */
1035 ND_PRINT((ndo
, " addr"));
1044 ND_PRINT((ndo
, " [|fs]"));
1048 * Handle replies to the AFS file service
1052 fs_reply_print(netdissect_options
*ndo
,
1053 register const u_char
*bp
, int length
, int32_t opcode
)
1056 const struct rx_header
*rxh
;
1058 if (length
<= (int)sizeof(struct rx_header
))
1061 rxh
= (const struct rx_header
*) bp
;
1064 * Print out the afs call we're invoking. The table used here was
1065 * gleaned from fsint/afsint.xg
1068 ND_PRINT((ndo
, " fs reply %s", tok2str(fs_req
, "op#%d", opcode
)));
1070 bp
+= sizeof(struct rx_header
);
1073 * If it was a data packet, interpret the response
1076 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
1078 case 131: /* Fetch ACL */
1080 char a
[AFSOPAQUEMAX
+1];
1081 ND_TCHECK2(bp
[0], 4);
1082 i
= EXTRACT_32BITS(bp
);
1083 bp
+= sizeof(int32_t);
1084 ND_TCHECK2(bp
[0], i
);
1085 i
= min(AFSOPAQUEMAX
, i
);
1086 strncpy(a
, (const char *) bp
, i
);
1088 acl_print(ndo
, (u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1091 case 137: /* Create file */
1092 case 141: /* MakeDir */
1093 ND_PRINT((ndo
, " new"));
1096 case 151: /* Get root volume */
1097 ND_PRINT((ndo
, " root volume"));
1100 case 153: /* Get time */
1106 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1110 * Otherwise, just print out the return code
1112 ND_TCHECK2(bp
[0], sizeof(int32_t));
1113 i
= (int) EXTRACT_32BITS(bp
);
1114 bp
+= sizeof(int32_t);
1116 ND_PRINT((ndo
, " error %s", tok2str(afs_fs_errors
, "#%d", i
)));
1118 ND_PRINT((ndo
, " strange fs reply of type %d", rxh
->type
));
1124 ND_PRINT((ndo
, " [|fs]"));
1128 * Print out an AFS ACL string. An AFS ACL is a string that has the
1131 * <positive> <negative>
1135 * "positive" and "negative" are integers which contain the number of
1136 * positive and negative ACL's in the string. The uid/aclbits pair are
1137 * ASCII strings containing the UID/PTS record and and a ascii number
1138 * representing a logical OR of all the ACL permission bits
1142 acl_print(netdissect_options
*ndo
,
1143 u_char
*s
, int maxsize
, u_char
*end
)
1150 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1153 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1162 * This wacky order preserves the order used by the "fs" command
1165 #define ACLOUT(acl) \
1166 ND_PRINT((ndo, "%s%s%s%s%s%s%s", \
1167 acl & PRSFS_READ ? "r" : "", \
1168 acl & PRSFS_LOOKUP ? "l" : "", \
1169 acl & PRSFS_INSERT ? "i" : "", \
1170 acl & PRSFS_DELETE ? "d" : "", \
1171 acl & PRSFS_WRITE ? "w" : "", \
1172 acl & PRSFS_LOCK ? "k" : "", \
1173 acl & PRSFS_ADMINISTER ? "a" : ""));
1175 for (i
= 0; i
< pos
; i
++) {
1176 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1177 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1180 ND_PRINT((ndo
, " +{"));
1181 fn_print(ndo
, (u_char
*)user
, NULL
);
1182 ND_PRINT((ndo
, " "));
1184 ND_PRINT((ndo
, "}"));
1189 for (i
= 0; i
< neg
; i
++) {
1190 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1191 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1194 ND_PRINT((ndo
, " -{"));
1195 fn_print(ndo
, (u_char
*)user
, NULL
);
1196 ND_PRINT((ndo
, " "));
1198 ND_PRINT((ndo
, "}"));
1211 * Handle calls to the AFS callback service
1215 cb_print(netdissect_options
*ndo
,
1216 register const u_char
*bp
, int length
)
1221 if (length
<= (int)sizeof(struct rx_header
))
1224 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1229 * Print out the afs call we're invoking. The table used here was
1230 * gleaned from fsint/afscbint.xg
1233 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1235 ND_PRINT((ndo
, " cb call %s", tok2str(cb_req
, "op#%d", cb_op
)));
1237 bp
+= sizeof(struct rx_header
) + 4;
1240 * Print out the afs call we're invoking. The table used here was
1241 * gleaned from fsint/afscbint.xg
1245 case 204: /* Callback */
1248 ND_TCHECK2(bp
[0], 4);
1249 j
= EXTRACT_32BITS(bp
);
1250 bp
+= sizeof(int32_t);
1252 for (i
= 0; i
< j
; i
++) {
1255 ND_PRINT((ndo
, ","));
1259 ND_PRINT((ndo
, " <none!>"));
1261 j
= EXTRACT_32BITS(bp
);
1262 bp
+= sizeof(int32_t);
1265 ND_PRINT((ndo
, ";"));
1267 for (i
= 0; i
< j
; i
++) {
1268 ND_PRINT((ndo
, " ver"));
1270 ND_PRINT((ndo
, " expires"));
1272 ND_TCHECK2(bp
[0], 4);
1273 t
= EXTRACT_32BITS(bp
);
1274 bp
+= sizeof(int32_t);
1275 tok2str(cb_types
, "type %d", t
);
1279 ND_PRINT((ndo
, " afsuuid"));
1290 ND_PRINT((ndo
, " [|cb]"));
1294 * Handle replies to the AFS Callback Service
1298 cb_reply_print(netdissect_options
*ndo
,
1299 register const u_char
*bp
, int length
, int32_t opcode
)
1301 const struct rx_header
*rxh
;
1303 if (length
<= (int)sizeof(struct rx_header
))
1306 rxh
= (const struct rx_header
*) bp
;
1309 * Print out the afs call we're invoking. The table used here was
1310 * gleaned from fsint/afscbint.xg
1313 ND_PRINT((ndo
, " cb reply %s", tok2str(cb_req
, "op#%d", opcode
)));
1315 bp
+= sizeof(struct rx_header
);
1318 * If it was a data packet, interpret the response.
1321 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1323 case 213: /* InitCallBackState3 */
1331 * Otherwise, just print out the return code
1333 ND_PRINT((ndo
, " errcode"));
1340 ND_PRINT((ndo
, " [|cb]"));
1344 * Handle calls to the AFS protection database server
1348 prot_print(netdissect_options
*ndo
,
1349 register const u_char
*bp
, int length
)
1354 if (length
<= (int)sizeof(struct rx_header
))
1357 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1362 * Print out the afs call we're invoking. The table used here was
1363 * gleaned from ptserver/ptint.xg
1366 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1368 ND_PRINT((ndo
, " pt"));
1370 if (is_ubik(pt_op
)) {
1371 ubik_print(ndo
, bp
);
1375 ND_PRINT((ndo
, " call %s", tok2str(pt_req
, "op#%d", pt_op
)));
1378 * Decode some of the arguments to the PT calls
1381 bp
+= sizeof(struct rx_header
) + 4;
1384 case 500: /* I New User */
1386 ND_PRINT((ndo
, " id"));
1388 ND_PRINT((ndo
, " oldid"));
1391 case 501: /* Where is it */
1392 case 506: /* Delete */
1393 case 508: /* Get CPS */
1394 case 512: /* List entry */
1395 case 514: /* List elements */
1396 case 517: /* List owned */
1397 case 518: /* Get CPS2 */
1398 case 519: /* Get host CPS */
1399 case 530: /* List super groups */
1400 ND_PRINT((ndo
, " id"));
1403 case 502: /* Dump entry */
1404 ND_PRINT((ndo
, " pos"));
1407 case 503: /* Add to group */
1408 case 507: /* Remove from group */
1409 case 515: /* Is a member of? */
1410 ND_PRINT((ndo
, " uid"));
1412 ND_PRINT((ndo
, " gid"));
1415 case 504: /* Name to ID */
1418 ND_TCHECK2(bp
[0], 4);
1419 j
= EXTRACT_32BITS(bp
);
1420 bp
+= sizeof(int32_t);
1423 * Who designed this chicken-shit protocol?
1425 * Each character is stored as a 32-bit
1429 for (i
= 0; i
< j
; i
++) {
1433 ND_PRINT((ndo
, " <none!>"));
1436 case 505: /* Id to name */
1439 ND_PRINT((ndo
, " ids:"));
1440 ND_TCHECK2(bp
[0], 4);
1441 i
= EXTRACT_32BITS(bp
);
1442 bp
+= sizeof(int32_t);
1443 for (j
= 0; j
< i
; j
++)
1446 ND_PRINT((ndo
, " <none!>"));
1449 case 509: /* New entry */
1451 ND_PRINT((ndo
, " flag"));
1453 ND_PRINT((ndo
, " oid"));
1456 case 511: /* Set max */
1457 ND_PRINT((ndo
, " id"));
1459 ND_PRINT((ndo
, " gflag"));
1462 case 513: /* Change entry */
1463 ND_PRINT((ndo
, " id"));
1466 ND_PRINT((ndo
, " oldid"));
1468 ND_PRINT((ndo
, " newid"));
1471 case 520: /* Update entry */
1472 ND_PRINT((ndo
, " id"));
1484 ND_PRINT((ndo
, " [|pt]"));
1488 * Handle replies to the AFS protection service
1492 prot_reply_print(netdissect_options
*ndo
,
1493 register const u_char
*bp
, int length
, int32_t opcode
)
1495 const struct rx_header
*rxh
;
1498 if (length
< (int)sizeof(struct rx_header
))
1501 rxh
= (const struct rx_header
*) bp
;
1504 * Print out the afs call we're invoking. The table used here was
1505 * gleaned from ptserver/ptint.xg. Check to see if it's a
1506 * Ubik call, however.
1509 ND_PRINT((ndo
, " pt"));
1511 if (is_ubik(opcode
)) {
1512 ubik_reply_print(ndo
, bp
, length
, opcode
);
1516 ND_PRINT((ndo
, " reply %s", tok2str(pt_req
, "op#%d", opcode
)));
1518 bp
+= sizeof(struct rx_header
);
1521 * If it was a data packet, interpret the response
1524 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1526 case 504: /* Name to ID */
1529 ND_PRINT((ndo
, " ids:"));
1530 ND_TCHECK2(bp
[0], 4);
1531 i
= EXTRACT_32BITS(bp
);
1532 bp
+= sizeof(int32_t);
1533 for (j
= 0; j
< i
; j
++)
1536 ND_PRINT((ndo
, " <none!>"));
1539 case 505: /* ID to name */
1542 ND_TCHECK2(bp
[0], 4);
1543 j
= EXTRACT_32BITS(bp
);
1544 bp
+= sizeof(int32_t);
1547 * Who designed this chicken-shit protocol?
1549 * Each character is stored as a 32-bit
1553 for (i
= 0; i
< j
; i
++) {
1557 ND_PRINT((ndo
, " <none!>"));
1560 case 508: /* Get CPS */
1561 case 514: /* List elements */
1562 case 517: /* List owned */
1563 case 518: /* Get CPS2 */
1564 case 519: /* Get host CPS */
1567 ND_TCHECK2(bp
[0], 4);
1568 j
= EXTRACT_32BITS(bp
);
1569 bp
+= sizeof(int32_t);
1570 for (i
= 0; i
< j
; i
++) {
1574 ND_PRINT((ndo
, " <none!>"));
1577 case 510: /* List max */
1578 ND_PRINT((ndo
, " maxuid"));
1580 ND_PRINT((ndo
, " maxgid"));
1588 * Otherwise, just print out the return code
1590 ND_PRINT((ndo
, " errcode"));
1597 ND_PRINT((ndo
, " [|pt]"));
1601 * Handle calls to the AFS volume location database service
1605 vldb_print(netdissect_options
*ndo
,
1606 register const u_char
*bp
, int length
)
1611 if (length
<= (int)sizeof(struct rx_header
))
1614 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1619 * Print out the afs call we're invoking. The table used here was
1620 * gleaned from vlserver/vldbint.xg
1623 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1625 ND_PRINT((ndo
, " vldb"));
1627 if (is_ubik(vldb_op
)) {
1628 ubik_print(ndo
, bp
);
1631 ND_PRINT((ndo
, " call %s", tok2str(vldb_req
, "op#%d", vldb_op
)));
1634 * Decode some of the arguments to the VLDB calls
1637 bp
+= sizeof(struct rx_header
) + 4;
1640 case 501: /* Create new volume */
1641 case 517: /* Create entry N */
1644 case 502: /* Delete entry */
1645 case 503: /* Get entry by ID */
1646 case 507: /* Update entry */
1647 case 508: /* Set lock */
1648 case 509: /* Release lock */
1649 case 518: /* Get entry by ID N */
1650 ND_PRINT((ndo
, " volid"));
1652 ND_TCHECK2(bp
[0], sizeof(int32_t));
1653 i
= EXTRACT_32BITS(bp
);
1654 bp
+= sizeof(int32_t);
1656 ND_PRINT((ndo
, " type %s", voltype
[i
]));
1658 case 504: /* Get entry by name */
1659 case 519: /* Get entry by name N */
1660 case 524: /* Update entry by name */
1661 case 527: /* Get entry by name U */
1664 case 505: /* Get new vol id */
1665 ND_PRINT((ndo
, " bump"));
1668 case 506: /* Replace entry */
1669 case 520: /* Replace entry N */
1670 ND_PRINT((ndo
, " volid"));
1672 ND_TCHECK2(bp
[0], sizeof(int32_t));
1673 i
= EXTRACT_32BITS(bp
);
1674 bp
+= sizeof(int32_t);
1676 ND_PRINT((ndo
, " type %s", voltype
[i
]));
1679 case 510: /* List entry */
1680 case 521: /* List entry N */
1681 ND_PRINT((ndo
, " index"));
1691 ND_PRINT((ndo
, " [|vldb]"));
1695 * Handle replies to the AFS volume location database service
1699 vldb_reply_print(netdissect_options
*ndo
,
1700 register const u_char
*bp
, int length
, int32_t opcode
)
1702 const struct rx_header
*rxh
;
1705 if (length
< (int)sizeof(struct rx_header
))
1708 rxh
= (const struct rx_header
*) bp
;
1711 * Print out the afs call we're invoking. The table used here was
1712 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1713 * Ubik call, however.
1716 ND_PRINT((ndo
, " vldb"));
1718 if (is_ubik(opcode
)) {
1719 ubik_reply_print(ndo
, bp
, length
, opcode
);
1723 ND_PRINT((ndo
, " reply %s", tok2str(vldb_req
, "op#%d", opcode
)));
1725 bp
+= sizeof(struct rx_header
);
1728 * If it was a data packet, interpret the response
1731 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1733 case 510: /* List entry */
1734 ND_PRINT((ndo
, " count"));
1736 ND_PRINT((ndo
, " nextindex"));
1738 case 503: /* Get entry by id */
1739 case 504: /* Get entry by name */
1740 { unsigned long nservers
, j
;
1742 ND_TCHECK2(bp
[0], sizeof(int32_t));
1743 bp
+= sizeof(int32_t);
1744 ND_PRINT((ndo
, " numservers"));
1745 ND_TCHECK2(bp
[0], sizeof(int32_t));
1746 nservers
= EXTRACT_32BITS(bp
);
1747 bp
+= sizeof(int32_t);
1748 ND_PRINT((ndo
, " %lu", nservers
));
1749 ND_PRINT((ndo
, " servers"));
1750 for (i
= 0; i
< 8; i
++) {
1751 ND_TCHECK2(bp
[0], sizeof(int32_t));
1753 ND_PRINT((ndo
, " %s",
1754 intoa(((const struct in_addr
*) bp
)->s_addr
)));
1755 bp
+= sizeof(int32_t);
1757 ND_PRINT((ndo
, " partitions"));
1758 for (i
= 0; i
< 8; i
++) {
1759 ND_TCHECK2(bp
[0], sizeof(int32_t));
1760 j
= EXTRACT_32BITS(bp
);
1761 if (i
< nservers
&& j
<= 26)
1762 ND_PRINT((ndo
, " %c", 'a' + (int)j
));
1763 else if (i
< nservers
)
1764 ND_PRINT((ndo
, " %lu", j
));
1765 bp
+= sizeof(int32_t);
1767 ND_TCHECK2(bp
[0], 8 * sizeof(int32_t));
1768 bp
+= 8 * sizeof(int32_t);
1769 ND_PRINT((ndo
, " rwvol"));
1771 ND_PRINT((ndo
, " rovol"));
1773 ND_PRINT((ndo
, " backup"));
1777 case 505: /* Get new volume ID */
1778 ND_PRINT((ndo
, " newvol"));
1781 case 521: /* List entry */
1782 case 529: /* List entry U */
1783 ND_PRINT((ndo
, " count"));
1785 ND_PRINT((ndo
, " nextindex"));
1787 case 518: /* Get entry by ID N */
1788 case 519: /* Get entry by name N */
1789 { unsigned long nservers
, j
;
1791 ND_PRINT((ndo
, " numservers"));
1792 ND_TCHECK2(bp
[0], sizeof(int32_t));
1793 nservers
= EXTRACT_32BITS(bp
);
1794 bp
+= sizeof(int32_t);
1795 ND_PRINT((ndo
, " %lu", nservers
));
1796 ND_PRINT((ndo
, " servers"));
1797 for (i
= 0; i
< 13; i
++) {
1798 ND_TCHECK2(bp
[0], sizeof(int32_t));
1800 ND_PRINT((ndo
, " %s",
1801 intoa(((const struct in_addr
*) bp
)->s_addr
)));
1802 bp
+= sizeof(int32_t);
1804 ND_PRINT((ndo
, " partitions"));
1805 for (i
= 0; i
< 13; i
++) {
1806 ND_TCHECK2(bp
[0], sizeof(int32_t));
1807 j
= EXTRACT_32BITS(bp
);
1808 if (i
< nservers
&& j
<= 26)
1809 ND_PRINT((ndo
, " %c", 'a' + (int)j
));
1810 else if (i
< nservers
)
1811 ND_PRINT((ndo
, " %lu", j
));
1812 bp
+= sizeof(int32_t);
1814 ND_TCHECK2(bp
[0], 13 * sizeof(int32_t));
1815 bp
+= 13 * sizeof(int32_t);
1816 ND_PRINT((ndo
, " rwvol"));
1818 ND_PRINT((ndo
, " rovol"));
1820 ND_PRINT((ndo
, " backup"));
1824 case 526: /* Get entry by ID U */
1825 case 527: /* Get entry by name U */
1826 { unsigned long nservers
, j
;
1828 ND_PRINT((ndo
, " numservers"));
1829 ND_TCHECK2(bp
[0], sizeof(int32_t));
1830 nservers
= EXTRACT_32BITS(bp
);
1831 bp
+= sizeof(int32_t);
1832 ND_PRINT((ndo
, " %lu", nservers
));
1833 ND_PRINT((ndo
, " servers"));
1834 for (i
= 0; i
< 13; i
++) {
1836 ND_PRINT((ndo
, " afsuuid"));
1839 ND_TCHECK2(bp
[0], 44);
1843 ND_TCHECK2(bp
[0], 4 * 13);
1845 ND_PRINT((ndo
, " partitions"));
1846 for (i
= 0; i
< 13; i
++) {
1847 ND_TCHECK2(bp
[0], sizeof(int32_t));
1848 j
= EXTRACT_32BITS(bp
);
1849 if (i
< nservers
&& j
<= 26)
1850 ND_PRINT((ndo
, " %c", 'a' + (int)j
));
1851 else if (i
< nservers
)
1852 ND_PRINT((ndo
, " %lu", j
));
1853 bp
+= sizeof(int32_t);
1855 ND_TCHECK2(bp
[0], 13 * sizeof(int32_t));
1856 bp
+= 13 * sizeof(int32_t);
1857 ND_PRINT((ndo
, " rwvol"));
1859 ND_PRINT((ndo
, " rovol"));
1861 ND_PRINT((ndo
, " backup"));
1870 * Otherwise, just print out the return code
1872 ND_PRINT((ndo
, " errcode"));
1879 ND_PRINT((ndo
, " [|vldb]"));
1883 * Handle calls to the AFS Kerberos Authentication service
1887 kauth_print(netdissect_options
*ndo
,
1888 register const u_char
*bp
, int length
)
1892 if (length
<= (int)sizeof(struct rx_header
))
1895 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1900 * Print out the afs call we're invoking. The table used here was
1901 * gleaned from kauth/kauth.rg
1904 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1906 ND_PRINT((ndo
, " kauth"));
1908 if (is_ubik(kauth_op
)) {
1909 ubik_print(ndo
, bp
);
1914 ND_PRINT((ndo
, " call %s", tok2str(kauth_req
, "op#%d", kauth_op
)));
1917 * Decode some of the arguments to the KA calls
1920 bp
+= sizeof(struct rx_header
) + 4;
1923 case 1: /* Authenticate old */;
1924 case 21: /* Authenticate */
1925 case 22: /* Authenticate-V2 */
1926 case 2: /* Change PW */
1927 case 5: /* Set fields */
1928 case 6: /* Create user */
1929 case 7: /* Delete user */
1930 case 8: /* Get entry */
1931 case 14: /* Unlock */
1932 case 15: /* Lock status */
1933 ND_PRINT((ndo
, " principal"));
1937 case 3: /* GetTicket-old */
1938 case 23: /* GetTicket */
1941 ND_PRINT((ndo
, " kvno"));
1943 ND_PRINT((ndo
, " domain"));
1945 ND_TCHECK2(bp
[0], sizeof(int32_t));
1946 i
= (int) EXTRACT_32BITS(bp
);
1947 bp
+= sizeof(int32_t);
1948 ND_TCHECK2(bp
[0], i
);
1950 ND_PRINT((ndo
, " principal"));
1955 case 4: /* Set Password */
1956 ND_PRINT((ndo
, " principal"));
1959 ND_PRINT((ndo
, " kvno"));
1962 case 12: /* Get password */
1963 ND_PRINT((ndo
, " name"));
1973 ND_PRINT((ndo
, " [|kauth]"));
1977 * Handle replies to the AFS Kerberos Authentication Service
1981 kauth_reply_print(netdissect_options
*ndo
,
1982 register const u_char
*bp
, int length
, int32_t opcode
)
1984 const struct rx_header
*rxh
;
1986 if (length
<= (int)sizeof(struct rx_header
))
1989 rxh
= (const struct rx_header
*) bp
;
1992 * Print out the afs call we're invoking. The table used here was
1993 * gleaned from kauth/kauth.rg
1996 ND_PRINT((ndo
, " kauth"));
1998 if (is_ubik(opcode
)) {
1999 ubik_reply_print(ndo
, bp
, length
, opcode
);
2003 ND_PRINT((ndo
, " reply %s", tok2str(kauth_req
, "op#%d", opcode
)));
2005 bp
+= sizeof(struct rx_header
);
2008 * If it was a data packet, interpret the response.
2011 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2012 /* Well, no, not really. Leave this for later */
2016 * Otherwise, just print out the return code
2018 ND_PRINT((ndo
, " errcode"));
2025 ND_PRINT((ndo
, " [|kauth]"));
2029 * Handle calls to the AFS Volume location service
2033 vol_print(netdissect_options
*ndo
,
2034 register const u_char
*bp
, int length
)
2038 if (length
<= (int)sizeof(struct rx_header
))
2041 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
2046 * Print out the afs call we're invoking. The table used here was
2047 * gleaned from volser/volint.xg
2050 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2052 ND_PRINT((ndo
, " vol call %s", tok2str(vol_req
, "op#%d", vol_op
)));
2054 bp
+= sizeof(struct rx_header
) + 4;
2057 case 100: /* Create volume */
2058 ND_PRINT((ndo
, " partition"));
2060 ND_PRINT((ndo
, " name"));
2062 ND_PRINT((ndo
, " type"));
2064 ND_PRINT((ndo
, " parent"));
2067 case 101: /* Delete volume */
2068 case 107: /* Get flags */
2069 ND_PRINT((ndo
, " trans"));
2072 case 102: /* Restore */
2073 ND_PRINT((ndo
, " totrans"));
2075 ND_PRINT((ndo
, " flags"));
2078 case 103: /* Forward */
2079 ND_PRINT((ndo
, " fromtrans"));
2081 ND_PRINT((ndo
, " fromdate"));
2084 ND_PRINT((ndo
, " desttrans"));
2087 case 104: /* End trans */
2088 ND_PRINT((ndo
, " trans"));
2091 case 105: /* Clone */
2092 ND_PRINT((ndo
, " trans"));
2094 ND_PRINT((ndo
, " purgevol"));
2096 ND_PRINT((ndo
, " newtype"));
2098 ND_PRINT((ndo
, " newname"));
2101 case 106: /* Set flags */
2102 ND_PRINT((ndo
, " trans"));
2104 ND_PRINT((ndo
, " flags"));
2107 case 108: /* Trans create */
2108 ND_PRINT((ndo
, " vol"));
2110 ND_PRINT((ndo
, " partition"));
2112 ND_PRINT((ndo
, " flags"));
2115 case 109: /* Dump */
2116 case 655537: /* Get size */
2117 ND_PRINT((ndo
, " fromtrans"));
2119 ND_PRINT((ndo
, " fromdate"));
2122 case 110: /* Get n-th volume */
2123 ND_PRINT((ndo
, " index"));
2126 case 111: /* Set forwarding */
2127 ND_PRINT((ndo
, " tid"));
2129 ND_PRINT((ndo
, " newsite"));
2132 case 112: /* Get name */
2133 case 113: /* Get status */
2134 ND_PRINT((ndo
, " tid"));
2136 case 114: /* Signal restore */
2137 ND_PRINT((ndo
, " name"));
2139 ND_PRINT((ndo
, " type"));
2141 ND_PRINT((ndo
, " pid"));
2143 ND_PRINT((ndo
, " cloneid"));
2146 case 116: /* List volumes */
2147 ND_PRINT((ndo
, " partition"));
2149 ND_PRINT((ndo
, " flags"));
2152 case 117: /* Set id types */
2153 ND_PRINT((ndo
, " tid"));
2155 ND_PRINT((ndo
, " name"));
2157 ND_PRINT((ndo
, " type"));
2159 ND_PRINT((ndo
, " pid"));
2161 ND_PRINT((ndo
, " clone"));
2163 ND_PRINT((ndo
, " backup"));
2166 case 119: /* Partition info */
2167 ND_PRINT((ndo
, " name"));
2170 case 120: /* Reclone */
2171 ND_PRINT((ndo
, " tid"));
2174 case 121: /* List one volume */
2175 case 122: /* Nuke volume */
2176 case 124: /* Extended List volumes */
2177 case 125: /* Extended List one volume */
2178 case 65536: /* Convert RO to RW volume */
2179 ND_PRINT((ndo
, " partid"));
2181 ND_PRINT((ndo
, " volid"));
2184 case 123: /* Set date */
2185 ND_PRINT((ndo
, " tid"));
2187 ND_PRINT((ndo
, " date"));
2190 case 126: /* Set info */
2191 ND_PRINT((ndo
, " tid"));
2194 case 128: /* Forward multiple */
2195 ND_PRINT((ndo
, " fromtrans"));
2197 ND_PRINT((ndo
, " fromdate"));
2201 ND_TCHECK2(bp
[0], 4);
2202 j
= EXTRACT_32BITS(bp
);
2203 bp
+= sizeof(int32_t);
2204 for (i
= 0; i
< j
; i
++) {
2207 ND_PRINT((ndo
, ","));
2210 ND_PRINT((ndo
, " <none!>"));
2213 case 65538: /* Dump version 2 */
2214 ND_PRINT((ndo
, " fromtrans"));
2216 ND_PRINT((ndo
, " fromdate"));
2218 ND_PRINT((ndo
, " flags"));
2227 ND_PRINT((ndo
, " [|vol]"));
2231 * Handle replies to the AFS Volume Service
2235 vol_reply_print(netdissect_options
*ndo
,
2236 register const u_char
*bp
, int length
, int32_t opcode
)
2238 const struct rx_header
*rxh
;
2240 if (length
<= (int)sizeof(struct rx_header
))
2243 rxh
= (const struct rx_header
*) bp
;
2246 * Print out the afs call we're invoking. The table used here was
2247 * gleaned from volser/volint.xg
2250 ND_PRINT((ndo
, " vol reply %s", tok2str(vol_req
, "op#%d", opcode
)));
2252 bp
+= sizeof(struct rx_header
);
2255 * If it was a data packet, interpret the response.
2258 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
2260 case 100: /* Create volume */
2261 ND_PRINT((ndo
, " volid"));
2263 ND_PRINT((ndo
, " trans"));
2266 case 104: /* End transaction */
2269 case 105: /* Clone */
2270 ND_PRINT((ndo
, " newvol"));
2273 case 107: /* Get flags */
2276 case 108: /* Transaction create */
2277 ND_PRINT((ndo
, " trans"));
2280 case 110: /* Get n-th volume */
2281 ND_PRINT((ndo
, " volume"));
2283 ND_PRINT((ndo
, " partition"));
2286 case 112: /* Get name */
2289 case 113: /* Get status */
2290 ND_PRINT((ndo
, " volid"));
2292 ND_PRINT((ndo
, " nextuniq"));
2294 ND_PRINT((ndo
, " type"));
2296 ND_PRINT((ndo
, " parentid"));
2298 ND_PRINT((ndo
, " clone"));
2300 ND_PRINT((ndo
, " backup"));
2302 ND_PRINT((ndo
, " restore"));
2304 ND_PRINT((ndo
, " maxquota"));
2306 ND_PRINT((ndo
, " minquota"));
2308 ND_PRINT((ndo
, " owner"));
2310 ND_PRINT((ndo
, " create"));
2312 ND_PRINT((ndo
, " access"));
2314 ND_PRINT((ndo
, " update"));
2316 ND_PRINT((ndo
, " expire"));
2318 ND_PRINT((ndo
, " backup"));
2320 ND_PRINT((ndo
, " copy"));
2323 case 115: /* Old list partitions */
2325 case 116: /* List volumes */
2326 case 121: /* List one volume */
2329 ND_TCHECK2(bp
[0], 4);
2330 j
= EXTRACT_32BITS(bp
);
2331 bp
+= sizeof(int32_t);
2332 for (i
= 0; i
< j
; i
++) {
2333 ND_PRINT((ndo
, " name"));
2335 ND_PRINT((ndo
, " volid"));
2337 ND_PRINT((ndo
, " type"));
2338 bp
+= sizeof(int32_t) * 21;
2340 ND_PRINT((ndo
, ","));
2343 ND_PRINT((ndo
, " <none!>"));
2353 * Otherwise, just print out the return code
2355 ND_PRINT((ndo
, " errcode"));
2362 ND_PRINT((ndo
, " [|vol]"));
2366 * Handle calls to the AFS BOS service
2370 bos_print(netdissect_options
*ndo
,
2371 register const u_char
*bp
, int length
)
2375 if (length
<= (int)sizeof(struct rx_header
))
2378 if (ndo
->ndo_snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
2383 * Print out the afs call we're invoking. The table used here was
2384 * gleaned from bozo/bosint.xg
2387 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2389 ND_PRINT((ndo
, " bos call %s", tok2str(bos_req
, "op#%d", bos_op
)));
2392 * Decode some of the arguments to the BOS calls
2395 bp
+= sizeof(struct rx_header
) + 4;
2398 case 80: /* Create B node */
2399 ND_PRINT((ndo
, " type"));
2401 ND_PRINT((ndo
, " instance"));
2404 case 81: /* Delete B node */
2405 case 83: /* Get status */
2406 case 85: /* Get instance info */
2407 case 87: /* Add super user */
2408 case 88: /* Delete super user */
2409 case 93: /* Set cell name */
2410 case 96: /* Add cell host */
2411 case 97: /* Delete cell host */
2412 case 104: /* Restart */
2413 case 106: /* Uninstall */
2414 case 108: /* Exec */
2415 case 112: /* Getlog */
2416 case 114: /* Get instance strings */
2419 case 82: /* Set status */
2420 case 98: /* Set T status */
2422 ND_PRINT((ndo
, " status"));
2425 case 86: /* Get instance parm */
2427 ND_PRINT((ndo
, " num"));
2430 case 84: /* Enumerate instance */
2431 case 89: /* List super users */
2432 case 90: /* List keys */
2433 case 91: /* Add key */
2434 case 92: /* Delete key */
2435 case 95: /* Get cell host */
2438 case 105: /* Install */
2440 ND_PRINT((ndo
, " size"));
2442 ND_PRINT((ndo
, " flags"));
2444 ND_PRINT((ndo
, " date"));
2454 ND_PRINT((ndo
, " [|bos]"));
2458 * Handle replies to the AFS BOS Service
2462 bos_reply_print(netdissect_options
*ndo
,
2463 register const u_char
*bp
, int length
, int32_t opcode
)
2465 const struct rx_header
*rxh
;
2467 if (length
<= (int)sizeof(struct rx_header
))
2470 rxh
= (const struct rx_header
*) bp
;
2473 * Print out the afs call we're invoking. The table used here was
2474 * gleaned from volser/volint.xg
2477 ND_PRINT((ndo
, " bos reply %s", tok2str(bos_req
, "op#%d", opcode
)));
2479 bp
+= sizeof(struct rx_header
);
2482 * If it was a data packet, interpret the response.
2485 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2486 /* Well, no, not really. Leave this for later */
2490 * Otherwise, just print out the return code
2492 ND_PRINT((ndo
, " errcode"));
2499 ND_PRINT((ndo
, " [|bos]"));
2503 * Check to see if this is a Ubik opcode.
2507 is_ubik(uint32_t opcode
)
2509 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2510 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2517 * Handle Ubik opcodes to any one of the replicated database services
2521 ubik_print(netdissect_options
*ndo
,
2522 register const u_char
*bp
)
2528 * Print out the afs call we're invoking. The table used here was
2529 * gleaned from ubik/ubik_int.xg
2532 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2534 ND_PRINT((ndo
, " ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
)));
2537 * Decode some of the arguments to the Ubik calls
2540 bp
+= sizeof(struct rx_header
) + 4;
2543 case 10000: /* Beacon */
2544 ND_TCHECK2(bp
[0], 4);
2545 temp
= EXTRACT_32BITS(bp
);
2546 bp
+= sizeof(int32_t);
2547 ND_PRINT((ndo
, " syncsite %s", temp
? "yes" : "no"));
2548 ND_PRINT((ndo
, " votestart"));
2550 ND_PRINT((ndo
, " dbversion"));
2552 ND_PRINT((ndo
, " tid"));
2555 case 10003: /* Get sync site */
2556 ND_PRINT((ndo
, " site"));
2559 case 20000: /* Begin */
2560 case 20001: /* Commit */
2561 case 20007: /* Abort */
2562 case 20008: /* Release locks */
2563 case 20010: /* Writev */
2564 ND_PRINT((ndo
, " tid"));
2567 case 20002: /* Lock */
2568 ND_PRINT((ndo
, " tid"));
2570 ND_PRINT((ndo
, " file"));
2572 ND_PRINT((ndo
, " pos"));
2574 ND_PRINT((ndo
, " length"));
2576 temp
= EXTRACT_32BITS(bp
);
2577 bp
+= sizeof(int32_t);
2578 tok2str(ubik_lock_types
, "type %d", temp
);
2580 case 20003: /* Write */
2581 ND_PRINT((ndo
, " tid"));
2583 ND_PRINT((ndo
, " file"));
2585 ND_PRINT((ndo
, " pos"));
2588 case 20005: /* Get file */
2589 ND_PRINT((ndo
, " file"));
2592 case 20006: /* Send file */
2593 ND_PRINT((ndo
, " file"));
2595 ND_PRINT((ndo
, " length"));
2597 ND_PRINT((ndo
, " dbversion"));
2600 case 20009: /* Truncate */
2601 ND_PRINT((ndo
, " tid"));
2603 ND_PRINT((ndo
, " file"));
2605 ND_PRINT((ndo
, " length"));
2608 case 20012: /* Set version */
2609 ND_PRINT((ndo
, " tid"));
2611 ND_PRINT((ndo
, " oldversion"));
2613 ND_PRINT((ndo
, " newversion"));
2623 ND_PRINT((ndo
, " [|ubik]"));
2627 * Handle Ubik replies to any one of the replicated database services
2631 ubik_reply_print(netdissect_options
*ndo
,
2632 register const u_char
*bp
, int length
, int32_t opcode
)
2634 const struct rx_header
*rxh
;
2636 if (length
< (int)sizeof(struct rx_header
))
2639 rxh
= (const struct rx_header
*) bp
;
2642 * Print out the ubik call we're invoking. This table was gleaned
2643 * from ubik/ubik_int.xg
2646 ND_PRINT((ndo
, " ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
)));
2648 bp
+= sizeof(struct rx_header
);
2651 * If it was a data packet, print out the arguments to the Ubik calls
2654 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2656 case 10000: /* Beacon */
2657 ND_PRINT((ndo
, " vote no"));
2659 case 20004: /* Get version */
2660 ND_PRINT((ndo
, " dbversion"));
2668 * Otherwise, print out "yes" it it was a beacon packet (because
2669 * that's how yes votes are returned, go figure), otherwise
2670 * just print out the error code.
2675 case 10000: /* Beacon */
2676 ND_PRINT((ndo
, " vote yes until"));
2680 ND_PRINT((ndo
, " errcode"));
2687 ND_PRINT((ndo
, " [|ubik]"));
2691 * Handle RX ACK packets.
2695 rx_ack_print(netdissect_options
*ndo
,
2696 register const u_char
*bp
, int length
)
2698 const struct rx_ackPacket
*rxa
;
2700 uint32_t firstPacket
;
2702 if (length
< (int)sizeof(struct rx_header
))
2705 bp
+= sizeof(struct rx_header
);
2708 * This may seem a little odd .... the rx_ackPacket structure
2709 * contains an array of individual packet acknowledgements
2710 * (used for selective ack/nack), but since it's variable in size,
2711 * we don't want to truncate based on the size of the whole
2712 * rx_ackPacket structure.
2715 ND_TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2717 rxa
= (const struct rx_ackPacket
*) bp
;
2718 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2721 * Print out a few useful things from the ack packet structure
2724 if (ndo
->ndo_vflag
> 2)
2725 ND_PRINT((ndo
, " bufspace %d maxskew %d",
2726 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2727 (int) EXTRACT_16BITS(&rxa
->maxSkew
)));
2729 firstPacket
= EXTRACT_32BITS(&rxa
->firstPacket
);
2730 ND_PRINT((ndo
, " first %d serial %d reason %s",
2731 firstPacket
, EXTRACT_32BITS(&rxa
->serial
),
2732 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
)));
2735 * Okay, now we print out the ack array. The way _this_ works
2736 * is that we start at "first", and step through the ack array.
2737 * If we have a contiguous range of acks/nacks, try to
2738 * collapse them into a range.
2740 * If you're really clever, you might have noticed that this
2741 * doesn't seem quite correct. Specifically, due to structure
2742 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2743 * yield the start of the ack array (because RX_MAXACKS is 255
2744 * and the structure will likely get padded to a 2 or 4 byte
2745 * boundary). However, this is the way it's implemented inside
2746 * of AFS - the start of the extra fields are at
2747 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2748 * the exact start of the ack array. Sigh. That's why we aren't
2749 * using bp, but instead use rxa->acks[]. But nAcks gets added
2750 * to bp after this, so bp ends up at the right spot. Go figure.
2753 if (rxa
->nAcks
!= 0) {
2755 ND_TCHECK2(bp
[0], rxa
->nAcks
);
2758 * Sigh, this is gross, but it seems to work to collapse
2762 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2763 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2766 * I figured this deserved _some_ explanation.
2767 * First, print "acked" and the packet seq
2768 * number if this is the first time we've
2769 * seen an acked packet.
2773 ND_PRINT((ndo
, " acked %d", firstPacket
+ i
));
2778 * Otherwise, if there is a skip in
2779 * the range (such as an nacked packet in
2780 * the middle of some acked packets),
2781 * then print the current packet number
2782 * seperated from the last number by
2786 else if (last
!= i
- 1) {
2787 ND_PRINT((ndo
, ",%d", firstPacket
+ i
));
2792 * We always set last to the value of
2793 * the last ack we saw. Conversely, start
2794 * is set to the value of the first ack
2795 * we saw in a range.
2801 * Okay, this bit a code gets executed when
2802 * we hit a nack ... in _this_ case we
2803 * want to print out the range of packets
2804 * that were acked, so we need to print
2805 * the _previous_ packet number seperated
2806 * from the first by a dash (-). Since we
2807 * already printed the first packet above,
2808 * just print the final packet. Don't
2809 * do this if there will be a single-length
2812 } else if (last
== i
- 1 && start
!= last
)
2813 ND_PRINT((ndo
, "-%d", firstPacket
+ i
- 1));
2816 * So, what's going on here? We ran off the end of the
2817 * ack list, and if we got a range we need to finish it up.
2818 * So we need to determine if the last packet in the list
2819 * was an ack (if so, then last will be set to it) and
2820 * we need to see if the last range didn't start with the
2821 * last packet (because if it _did_, then that would mean
2822 * that the packet number has already been printed and
2823 * we don't need to print it again).
2826 if (last
== i
- 1 && start
!= last
)
2827 ND_PRINT((ndo
, "-%d", firstPacket
+ i
- 1));
2830 * Same as above, just without comments
2833 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2834 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2836 ND_PRINT((ndo
, " nacked %d", firstPacket
+ i
));
2838 } else if (last
!= i
- 1) {
2839 ND_PRINT((ndo
, ",%d", firstPacket
+ i
));
2843 } else if (last
== i
- 1 && start
!= last
)
2844 ND_PRINT((ndo
, "-%d", firstPacket
+ i
- 1));
2846 if (last
== i
- 1 && start
!= last
)
2847 ND_PRINT((ndo
, "-%d", firstPacket
+ i
- 1));
2854 * These are optional fields; depending on your version of AFS,
2855 * you may or may not see them
2858 #define TRUNCRET(n) if (ndo->ndo_snapend - bp + 1 <= n) return;
2860 if (ndo
->ndo_vflag
> 1) {
2862 ND_PRINT((ndo
, " ifmtu"));
2866 ND_PRINT((ndo
, " maxmtu"));
2870 ND_PRINT((ndo
, " rwind"));
2874 ND_PRINT((ndo
, " maxpackets"));
2881 ND_PRINT((ndo
, " [|ack]"));