2 * Routines for AFS packet dissection
3 * Copyright 1999, Nathan Neulinger <nneul@umr.edu>
4 * Based on routines from tcpdump patches by
5 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
6 * Portions based on information retrieved from the RX definitions
7 * in Arla, the free AFS client at http://www.stacken.kth.se/project/arla/
8 * Portions based on information/specs retrieved from the OpenAFS sources at
9 * www.openafs.org, Copyright IBM.
11 * $Id: packet-afs.c,v 1.47 2002/06/13 06:43:44 guy Exp $
13 * Ethereal - Network traffic analyzer
14 * By Gerald Combs <gerald@ethereal.com>
15 * Copyright 1998 Gerald Combs
17 * Copied from packet-tftp.c
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
40 #ifdef HAVE_SYS_TYPES_H
41 # include <sys/types.h>
44 #ifdef HAVE_NETINET_IN_H
45 # include <netinet/in.h>
50 #include <epan/packet.h>
51 #include <epan/conversation.h>
52 #include <epan/resolv.h>
54 #include "packet-rx.h"
55 #include "packet-afs.h"
56 #include "packet-afs-defs.h"
57 #include "packet-afs-macros.h"
59 #define GETSTR tvb_get_ptr(tvb,offset,tvb_ensure_length_remaining(tvb,offset))
61 #define VALID_OPCODE(opcode) ((opcode >= OPCODE_LOW && opcode <= OPCODE_HIGH) || \
62 (opcode >= VOTE_LOW && opcode <= VOTE_HIGH) || \
63 (opcode >= DISK_LOW && opcode <= DISK_HIGH))
65 static int afs_packet_init_count = 100;
67 struct afs_request_key {
68 guint32 conversation, callnumber;
72 struct afs_request_val {
76 static GHashTable *afs_request_hash = NULL;
77 static GMemChunk *afs_request_keys = NULL;
78 static GMemChunk *afs_request_vals = NULL;
83 * Dissector prototypes
85 static int dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo,
86 proto_tree *tree, int offset);
87 static void dissect_fs_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
88 proto_tree *tree, int offset, int opcode);
89 static void dissect_fs_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
90 proto_tree *tree, int offset, int opcode);
91 static void dissect_bos_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
92 proto_tree *tree, int offset, int opcode);
93 static void dissect_bos_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
94 proto_tree *tree, int offset, int opcode);
95 static void dissect_vol_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
96 proto_tree *tree, int offset, int opcode);
97 static void dissect_vol_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
98 proto_tree *tree, int offset, int opcode);
99 static void dissect_kauth_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
100 proto_tree *tree, int offset, int opcode);
101 static void dissect_kauth_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
102 proto_tree *tree, int offset, int opcode);
103 static void dissect_cb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
104 proto_tree *tree, int offset, int opcode);
105 static void dissect_cb_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
106 proto_tree *tree, int offset, int opcode);
107 static void dissect_prot_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
108 proto_tree *tree, int offset, int opcode);
109 static void dissect_prot_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
110 proto_tree *tree, int offset, int opcode);
111 static void dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
112 proto_tree *tree, int offset, int opcode);
113 static void dissect_vldb_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
114 proto_tree *tree, int offset, int opcode);
115 static void dissect_ubik_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
116 proto_tree *tree, int offset, int opcode);
117 static void dissect_ubik_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
118 proto_tree *tree, int offset, int opcode);
119 static void dissect_backup_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
120 proto_tree *tree, int offset, int opcode);
121 static void dissect_backup_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
122 proto_tree *tree, int offset, int opcode);
128 afs_equal(gconstpointer v, gconstpointer w)
130 struct afs_request_key *v1 = (struct afs_request_key *)v;
131 struct afs_request_key *v2 = (struct afs_request_key *)w;
133 if (v1 -> conversation == v2 -> conversation &&
134 v1 -> service == v2 -> service &&
135 v1 -> callnumber == v2 -> callnumber ) {
144 afs_hash (gconstpointer v)
146 struct afs_request_key *key = (struct afs_request_key *)v;
149 val = key -> conversation + key -> service + key -> callnumber;
155 * Protocol initialization
158 afs_init_protocol(void)
160 if (afs_request_hash)
161 g_hash_table_destroy(afs_request_hash);
162 if (afs_request_keys)
163 g_mem_chunk_destroy(afs_request_keys);
164 if (afs_request_vals)
165 g_mem_chunk_destroy(afs_request_vals);
167 afs_request_hash = g_hash_table_new(afs_hash, afs_equal);
168 afs_request_keys = g_mem_chunk_new("afs_request_keys",
169 sizeof(struct afs_request_key),
170 afs_packet_init_count * sizeof(struct afs_request_key),
172 afs_request_vals = g_mem_chunk_new("afs_request_vals",
173 sizeof(struct afs_request_val),
174 afs_packet_init_count * sizeof(struct afs_request_val),
181 * Dissection routines
185 dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
187 struct rxinfo *rxinfo = pinfo->private_data;
189 conversation_t *conversation;
190 struct afs_request_key request_key, *new_request_key;
191 struct afs_request_val *request_val;
192 proto_tree *afs_tree, *afs_op_tree, *ti;
193 int port, node, typenode, opcode;
194 value_string const *vals;
196 void (*dissector)(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode);
199 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
200 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AFS (RX)");
202 if (check_col(pinfo->cinfo, COL_INFO)) {
203 col_clear(pinfo->cinfo, COL_INFO);
206 reply = (rxinfo->flags & RX_CLIENT_INITIATED) == 0;
207 port = ((reply == 0) ? pinfo->destport : pinfo->srcport );
210 * Find out what conversation this packet is part of.
211 * XXX - this should really be done by the transport-layer protocol,
212 * although for connectionless transports, we may not want to do that
213 * unless we know some higher-level protocol will want it - or we
214 * may want to do it, so you can say e.g. "show only the packets in
215 * this UDP 'connection'".
217 * Note that we don't have to worry about the direction this packet
218 * was going - the conversation code handles that for us, treating
219 * packets from A:X to B:Y as being part of the same conversation as
220 * packets from B:Y to A:X.
222 conversation = find_conversation(&pinfo->src, &pinfo->dst, pinfo->ptype,
223 pinfo->srcport, pinfo->destport, 0);
224 if (conversation == NULL) {
225 /* It's not part of any conversation - create a new one. */
226 conversation = conversation_new(&pinfo->src, &pinfo->dst,
227 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
230 request_key.conversation = conversation->index;
231 request_key.service = rxinfo->serviceid;
232 request_key.callnumber = rxinfo->callnumber;
234 request_val = (struct afs_request_val *) g_hash_table_lookup(
235 afs_request_hash, &request_key);
237 /* only allocate a new hash element when it's a request */
239 if ( !request_val && !reply) {
240 new_request_key = g_mem_chunk_alloc(afs_request_keys);
241 *new_request_key = request_key;
243 request_val = g_mem_chunk_alloc(afs_request_vals);
244 request_val -> opcode = tvb_get_ntohl(tvb, offset);
246 g_hash_table_insert(afs_request_hash, new_request_key,
251 opcode = request_val->opcode;
260 typenode = hf_afs_fs;
261 node = hf_afs_fs_opcode;
263 dissector = reply ? dissect_fs_reply : dissect_fs_request;
266 typenode = hf_afs_cb;
267 node = hf_afs_cb_opcode;
269 dissector = reply ? dissect_cb_reply : dissect_cb_request;
272 typenode = hf_afs_prot;
273 node = hf_afs_prot_opcode;
275 dissector = reply ? dissect_prot_reply : dissect_prot_request;
278 typenode = hf_afs_vldb;
279 node = hf_afs_vldb_opcode;
281 dissector = reply ? dissect_vldb_reply : dissect_vldb_request;
284 typenode = hf_afs_kauth;
285 node = hf_afs_kauth_opcode;
287 dissector = reply ? dissect_kauth_reply : dissect_kauth_request;
290 typenode = hf_afs_vol;
291 node = hf_afs_vol_opcode;
293 dissector = reply ? dissect_vol_reply : dissect_vol_request;
296 typenode = hf_afs_error;
297 node = hf_afs_error_opcode;
298 /* dissector = reply ? dissect_error_reply : dissect_error_request; */
301 typenode = hf_afs_bos;
302 node = hf_afs_bos_opcode;
304 dissector = reply ? dissect_bos_reply : dissect_bos_request;
306 case AFS_PORT_UPDATE:
307 typenode = hf_afs_update;
308 node = hf_afs_update_opcode;
310 /* dissector = reply ? dissect_update_reply : dissect_update_request; */
312 case AFS_PORT_RMTSYS:
313 typenode = hf_afs_rmtsys;
314 node = hf_afs_rmtsys_opcode;
316 /* dissector = reply ? dissect_rmtsys_reply : dissect_rmtsys_request; */
318 case AFS_PORT_BACKUP:
319 typenode = hf_afs_backup;
320 node = hf_afs_backup_opcode;
322 dissector = reply ? dissect_backup_reply : dissect_backup_request;
326 if ( (opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
327 (opcode >= DISK_LOW && opcode <= DISK_HIGH) ) {
328 typenode = hf_afs_ubik;
329 node = hf_afs_ubik_opcode;
331 dissector = reply ? dissect_ubik_reply : dissect_ubik_request;
335 if ( VALID_OPCODE(opcode) ) {
337 if (check_col(pinfo->cinfo, COL_INFO))
338 col_add_fstr(pinfo->cinfo, COL_INFO, "%s%s %s: %s (%d)",
339 typenode == hf_afs_ubik ? "UBIK-" : "",
340 val_to_str(port, port_types_short, "Unknown(%d)"),
341 reply ? "Reply" : "Request",
342 val_to_str(opcode, vals, "Unknown(%d)"), opcode);
344 if (check_col(pinfo->cinfo, COL_INFO))
345 col_add_fstr(pinfo->cinfo, COL_INFO, "%s%s %s: Unknown(%d)",
346 typenode == hf_afs_ubik ? "UBIK-" : "",
347 val_to_str(port, port_types_short, "Unknown(%d)"),
348 reply ? "Reply" : "Request",
352 if (check_col(pinfo->cinfo, COL_INFO))
353 col_add_fstr(pinfo->cinfo, COL_INFO, "Encrypted %s %s",
354 val_to_str(port, port_types_short, "Unknown(%d)"),
355 reply ? "Reply" : "Request"
360 ti = proto_tree_add_item(tree, proto_afs, tvb, offset, -1,
362 afs_tree = proto_item_add_subtree(ti, ett_afs);
364 proto_tree_add_text(afs_tree, tvb,
366 "Service: %s%s%s %s",
367 VALID_OPCODE(opcode) ? "" : "Encrypted ",
368 typenode == hf_afs_ubik ? "UBIK - " : "",
369 val_to_str(port, port_types, "Unknown(%d)"),
370 reply ? "Reply" : "Request");
372 if ( VALID_OPCODE(opcode) ) {
373 /* until we do cache, can't handle replies */
375 if ( !reply && node != 0 ) {
376 if ( rxinfo->seq == 1 )
378 ti = proto_tree_add_uint(afs_tree,
379 node, tvb, offset, 4, opcode);
381 ti = proto_tree_add_uint(afs_tree,
382 node, tvb, offset, 0, opcode);
384 } else if ( reply && node != 0 ) {
385 /* the opcode isn't in this packet */
386 ti = proto_tree_add_uint(afs_tree,
387 node, tvb, offset, 0, opcode);
389 ti = proto_tree_add_text(afs_tree, tvb,
390 offset, 0, "Operation: Unknown");
393 /* Add the subtree for this particular service */
394 afs_op_tree = proto_item_add_subtree(ti, ett_afs_op);
396 if ( typenode != 0 ) {
397 /* indicate the type of request */
398 proto_tree_add_boolean_hidden(afs_tree, typenode, tvb, offset, 0, 1);
401 /* Process the packet according to what service it is */
403 (*dissector)(tvb, rxinfo, afs_op_tree, offset, opcode);
408 /* if it's the last packet, and it's a reply, remove opcode
410 /* ignoring for now, I'm not sure how the chunk deallocation works */
411 if ( rxinfo->flags & RX_LAST_PACKET && reply ){
418 * Here is a helper routine for adding an AFS acl to the proto tree
419 * This is to be used with FS packets only
421 * An AFS ACL is a string that has the following format:
423 * <positive> <negative>
427 * "positive" and "negative" are integers which contain the number of
428 * positive and negative ACL's in the string. The uid/aclbits pair are
429 * ASCII strings containing the UID/PTS record and and a ascii number
430 * representing a logical OR of all the ACL permission bits
435 * sscanf is probably quite dangerous if we run outside the packet.
437 * "GETSTR" doesn't guarantee that the resulting string is
440 * Should this just scan the string itself, rather than using "sscanf()"?
443 dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset)
447 int i, n, pos, neg, acl;
448 char user[128]; /* Be sure to adjust sscanf()s below if length is changed... */
451 bytes = tvb_get_ntohl(tvb, offset);
452 OUT_UINT(hf_afs_fs_acl_datasize);
455 if (sscanf((char *) GETSTR, "%d %n", &pos, &n) != 1) {
456 /* does not matter what we return, if this fails,
457 * we cant dissect anything else in the packet either.
461 proto_tree_add_uint(tree, hf_afs_fs_acl_count_positive, tvb,
466 if (sscanf((char *) GETSTR, "%d %n", &neg, &n) != 1) {
469 proto_tree_add_uint(tree, hf_afs_fs_acl_count_negative, tvb,
474 * This wacky order preserves the order used by the "fs" command
476 for (i = 0; i < pos; i++) {
477 if (sscanf((char *) GETSTR,
478 "%127s %d %n", user, &acl, &n) != 2) {
481 ACLOUT(user,1,acl,n);
484 for (i = 0; i < neg; i++) {
485 if (sscanf((char *) GETSTR,
486 "%127s %d %n", user, &acl, &n) != 2) {
489 ACLOUT(user,0,acl,n);
491 if (offset >= old_offset+bytes ) {
500 * Here are the helper dissection routines
504 dissect_fs_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
506 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
510 case 130: /* fetch data */
511 /* only on first packet */
512 if ( rxinfo->seq == 1 )
514 OUT_FS_AFSFetchStatus("Status");
515 OUT_FS_AFSCallBack();
518 OUT_BYTES_ALL(hf_afs_fs_data);
520 case 131: /* fetch acl */
521 offset = dissect_acl(tvb, rxinfo, tree, offset);
522 OUT_FS_AFSFetchStatus("Status");
525 case 132: /* Fetch status */
526 OUT_FS_AFSFetchStatus("Status");
527 OUT_FS_AFSCallBack();
530 case 133: /* Store data */
531 case 134: /* Store ACL */
532 case 135: /* Store status */
533 case 136: /* Remove file */
534 OUT_FS_AFSFetchStatus("Status");
537 case 137: /* create file */
538 case 141: /* make dir */
539 case 161: /* lookup */
540 case 163: /* dfs symlink */
541 OUT_FS_AFSFid((opcode == 137)? "New File" : ((opcode == 141)? "New Directory" : "File"));
542 OUT_FS_AFSFetchStatus("File Status");
543 OUT_FS_AFSFetchStatus("Directory Status");
544 OUT_FS_AFSCallBack();
547 case 138: /* rename */
548 OUT_FS_AFSFetchStatus("Old Directory Status");
549 OUT_FS_AFSFetchStatus("New Directory Status");
552 case 139: /* symlink */
553 OUT_FS_AFSFid("Symlink");
555 OUT_FS_AFSFetchStatus("Symlink Status");
556 case 142: /* rmdir */
557 OUT_FS_AFSFetchStatus("Directory Status");
560 case 143: /* old set lock */
561 case 144: /* old extend lock */
562 case 145: /* old release lock */
563 case 147: /* give up callbacks */
564 case 150: /* set volume status */
565 case 152: /* check token */
566 /* nothing returned */
568 case 146: /* get statistics */
569 OUT_FS_ViceStatistics();
571 case 148: /* get volume info */
572 case 154: /* n-get-volume-info */
575 case 149: /* get volume status */
576 OUT_FS_AFSFetchVolumeStatus();
577 OUT_RXString(hf_afs_fs_volname);
578 OUT_RXString(hf_afs_fs_offlinemsg);
579 OUT_RXString(hf_afs_fs_motd);
581 case 151: /* root volume */
582 OUT_RXString(hf_afs_fs_volname);
584 case 153: /* get time */
585 OUT_TIMESTAMP(hf_afs_fs_timestamp);
587 case 155: /* bulk status */
588 OUT_FS_AFSBulkStats();
593 case 156: /* set lock */
594 case 157: /* extend lock */
595 case 158: /* release lock */
598 case 159: /* x-stats-version */
599 OUT_UINT(hf_afs_fs_xstats_version);
601 case 160: /* get xstats */
602 OUT_UINT(hf_afs_fs_xstats_version);
603 OUT_DATE(hf_afs_fs_xstats_timestamp);
604 OUT_FS_AFS_CollData();
606 case 162: /* flush cps */
607 OUT_UINT(hf_afs_fs_cps_spare2);
608 OUT_UINT(hf_afs_fs_cps_spare3);
612 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
614 OUT_UINT(hf_afs_fs_errcode);
619 dissect_fs_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
621 /* skip the opcode if this is the first packet in the stream */
622 if ( rxinfo->seq == 1 )
624 offset += 4; /* skip the opcode */
629 case 130: /* Fetch data */
630 OUT_FS_AFSFid("Source");
631 OUT_UINT(hf_afs_fs_offset);
632 OUT_UINT(hf_afs_fs_length);
634 case 131: /* Fetch ACL */
635 OUT_FS_AFSFid("Target");
637 case 132: /* Fetch Status */
638 OUT_FS_AFSFid("Target");
640 case 133: /* Store Data */
641 if ( rxinfo->seq == 1 )
643 OUT_FS_AFSFid("Destination");
644 OUT_FS_AFSStoreStatus("Status");
645 OUT_UINT(hf_afs_fs_offset);
646 OUT_UINT(hf_afs_fs_length);
647 OUT_UINT(hf_afs_fs_flength);
649 OUT_BYTES_ALL(hf_afs_fs_data);
651 case 134: /* Store ACL */
652 OUT_FS_AFSFid("Target");
653 offset = dissect_acl(tvb, rxinfo, tree, offset);
655 case 135: /* Store Status */
656 OUT_FS_AFSFid("Target");
657 OUT_FS_AFSStoreStatus("Status");
659 case 136: /* Remove File */
660 OUT_FS_AFSFid("Remove File");
661 OUT_RXString(hf_afs_fs_name);
663 case 137: /* Create File */
664 OUT_FS_AFSFid("Target");
665 OUT_RXString(hf_afs_fs_name);
666 OUT_FS_AFSStoreStatus("Status");
668 case 138: /* Rename file */
669 OUT_FS_AFSFid("Old");
670 OUT_RXString(hf_afs_fs_oldname);
671 OUT_FS_AFSFid("New");
672 OUT_RXString(hf_afs_fs_newname);
674 case 139: /* Symlink */
675 OUT_FS_AFSFid("File");
676 OUT_RXString(hf_afs_fs_symlink_name);
677 OUT_RXString(hf_afs_fs_symlink_content);
678 OUT_FS_AFSStoreStatus("Status");
681 OUT_FS_AFSFid("Link To (New File)");
682 OUT_RXString(hf_afs_fs_name);
683 OUT_FS_AFSFid("Link From (Old File)");
685 case 141: /* Make dir */
686 OUT_FS_AFSFid("Target");
687 OUT_RXString(hf_afs_fs_name);
688 OUT_FS_AFSStoreStatus("Status");
690 case 142: /* Remove dir */
691 OUT_FS_AFSFid("Target");
692 OUT_RXString(hf_afs_fs_name);
694 case 143: /* Old Set Lock */
695 OUT_FS_AFSFid("Target");
696 OUT_UINT(hf_afs_fs_vicelocktype);
699 case 144: /* Old Extend Lock */
700 OUT_FS_AFSFid("Target");
703 case 145: /* Old Release Lock */
704 OUT_FS_AFSFid("Target");
707 case 146: /* Get statistics */
710 case 147: /* Give up callbacks */
714 case 148: /* Get vol info */
715 OUT_RXString(hf_afs_fs_volname);
717 case 149: /* Get vol stats */
718 OUT_UINT(hf_afs_fs_volid);
720 case 150: /* Set vol stats */
721 OUT_UINT(hf_afs_fs_volid);
722 OUT_FS_AFSStoreVolumeStatus();
723 OUT_RXString(hf_afs_fs_volname);
724 OUT_RXString(hf_afs_fs_offlinemsg);
725 OUT_RXString(hf_afs_fs_motd);
727 case 151: /* get root volume */
730 case 152: /* check token */
731 OUT_UINT(hf_afs_fs_viceid);
734 case 153: /* get time */
737 case 154: /* new get vol info */
738 OUT_RXString(hf_afs_fs_volname);
740 case 155: /* bulk stat */
743 case 156: /* Set Lock */
744 OUT_FS_AFSFid("Target");
745 OUT_UINT(hf_afs_fs_vicelocktype);
747 case 157: /* Extend Lock */
748 OUT_FS_AFSFid("Target");
750 case 158: /* Release Lock */
751 OUT_FS_AFSFid("Target");
753 case 159: /* xstats version */
756 case 160: /* get xstats */
757 OUT_UINT(hf_afs_fs_xstats_clientversion);
758 OUT_UINT(hf_afs_fs_xstats_collnumber);
760 case 161: /* lookup */
761 OUT_FS_AFSFid("Target");
762 OUT_RXString(hf_afs_fs_name);
764 case 162: /* flush cps */
767 OUT_UINT(hf_afs_fs_cps_spare1);
769 case 163: /* dfs symlink */
770 OUT_FS_AFSFid("Target");
771 OUT_RXString(hf_afs_fs_symlink_name);
772 OUT_RXString(hf_afs_fs_symlink_content);
773 OUT_FS_AFSStoreStatus("Symlink Status");
782 dissect_bos_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
784 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
788 case 80: /* create bnode */
791 case 81: /* delete bnode */
794 case 82: /* set status */
797 case 83: /* get status */
798 OUT_INT(hf_afs_bos_status);
799 OUT_RXString(hf_afs_bos_statusdesc);
801 case 84: /* enumerate instance */
802 OUT_RXString(hf_afs_bos_instance);
804 case 85: /* get instance info */
805 OUT_RXString(hf_afs_bos_type);
808 case 86: /* get instance parm */
809 OUT_RXString(hf_afs_bos_parm);
811 case 87: /* add siperuser */
814 case 88: /* delete superuser */
817 case 89: /* list superusers */
818 OUT_RXString(hf_afs_bos_user);
820 case 90: /* list keys */
821 OUT_UINT(hf_afs_bos_kvno);
825 case 91: /* add key */
828 case 92: /* delete key */
831 case 93: /* set cell name */
834 case 94: /* get cell name */
835 OUT_RXString(hf_afs_bos_cell);
837 case 95: /* get cell host */
838 OUT_RXString(hf_afs_bos_host);
840 case 96: /* add cell host */
843 case 97: /* delete cell host */
846 case 98: /* set tstatus */
849 case 99: /* shutdown all */
852 case 100: /* restart all */
855 case 101: /* startup all */
858 case 102: /* set noauth flag */
861 case 103: /* rebozo */
864 case 104: /* restart */
867 case 105: /* install */
870 case 106: /* uninstall */
873 case 107: /* get dates */
874 OUT_DATE(hf_afs_bos_newtime);
875 OUT_DATE(hf_afs_bos_baktime);
876 OUT_DATE(hf_afs_bos_oldtime);
881 case 109: /* prune */
884 case 110: /* set restart time */
887 case 111: /* get restart time */
890 case 112: /* get log */
891 /* need to make this dump a big string somehow */
892 OUT_BYTES_ALL(hf_afs_bos_data);
894 case 113: /* wait all */
897 case 114: /* get instance strings */
898 OUT_RXString(hf_afs_bos_error);
899 OUT_RXString(hf_afs_bos_spare1);
900 OUT_RXString(hf_afs_bos_spare2);
901 OUT_RXString(hf_afs_bos_spare3);
905 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
907 OUT_UINT(hf_afs_bos_errcode);
912 dissect_bos_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
914 offset += 4; /* skip the opcode */
918 case 80: /* create b node */
919 OUT_RXString(hf_afs_bos_type);
920 OUT_RXString(hf_afs_bos_instance);
921 OUT_RXString(hf_afs_bos_parm);
922 OUT_RXString(hf_afs_bos_parm);
923 OUT_RXString(hf_afs_bos_parm);
924 OUT_RXString(hf_afs_bos_parm);
925 OUT_RXString(hf_afs_bos_parm);
926 OUT_RXString(hf_afs_bos_parm);
928 case 81: /* delete b node */
929 OUT_RXString(hf_afs_bos_instance);
931 case 82: /* set status */
932 OUT_RXString(hf_afs_bos_instance);
933 OUT_UINT(hf_afs_bos_status);
935 case 83: /* get status */
936 OUT_RXString(hf_afs_bos_instance);
938 case 84: /* enumerate instance */
939 OUT_UINT(hf_afs_bos_num);
941 case 85: /* get instance info */
942 OUT_RXString(hf_afs_bos_instance);
944 case 86: /* get instance parm */
945 OUT_RXString(hf_afs_bos_instance);
946 OUT_UINT(hf_afs_bos_num);
948 case 87: /* add super user */
949 OUT_RXString(hf_afs_bos_user);
951 case 88: /* delete super user */
952 OUT_RXString(hf_afs_bos_user);
954 case 89: /* list super users */
955 OUT_UINT(hf_afs_bos_num);
957 case 90: /* list keys */
958 OUT_UINT(hf_afs_bos_num);
960 case 91: /* add key */
961 OUT_UINT(hf_afs_bos_num);
964 case 92: /* delete key */
965 OUT_UINT(hf_afs_bos_num);
967 case 93: /* set cell name */
968 OUT_RXString(hf_afs_bos_content);
970 case 95: /* set cell host */
971 OUT_UINT(hf_afs_bos_num);
973 case 96: /* add cell host */
974 OUT_RXString(hf_afs_bos_content);
976 case 97: /* delete cell host */
977 OUT_RXString(hf_afs_bos_content);
979 case 98: /* set t status */
980 OUT_RXString(hf_afs_bos_content);
981 OUT_UINT(hf_afs_bos_status);
983 case 99: /* shutdown all */
986 case 100: /* restart all */
989 case 101: /* startup all */
992 case 102: /* set no-auth flag */
993 OUT_UINT(hf_afs_bos_flags);
995 case 103: /* re-bozo? */
998 case 104: /* restart */
999 OUT_RXString(hf_afs_bos_instance);
1001 case 105: /* install */
1002 OUT_RXString(hf_afs_bos_path);
1003 OUT_UINT(hf_afs_bos_size);
1004 OUT_UINT(hf_afs_bos_flags);
1005 OUT_UINT(hf_afs_bos_date);
1007 case 106: /* uninstall */
1008 OUT_RXString(hf_afs_bos_path);
1010 case 107: /* get dates */
1011 OUT_RXString(hf_afs_bos_path);
1013 case 108: /* exec */
1014 OUT_RXString(hf_afs_bos_cmd);
1016 case 109: /* prune */
1017 OUT_UINT(hf_afs_bos_flags);
1019 case 110: /* set restart time */
1020 OUT_UINT(hf_afs_bos_num);
1023 case 111: /* get restart time */
1024 OUT_UINT(hf_afs_bos_num);
1026 case 112: /* get log */
1027 OUT_RXString(hf_afs_bos_file);
1029 case 113: /* wait all */
1032 case 114: /* get instance strings */
1033 OUT_RXString(hf_afs_bos_content);
1042 dissect_vol_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1044 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1049 /* should loop here maybe */
1050 OUT_UINT(hf_afs_vol_count);
1051 OUT_RXStringV(hf_afs_vol_name, 32); /* not sure on */
1055 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1057 OUT_UINT(hf_afs_vol_errcode);
1062 dissect_vol_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1064 offset += 4; /* skip the opcode */
1068 case 121: /* list one vol */
1069 OUT_UINT(hf_afs_vol_count);
1070 OUT_UINT(hf_afs_vol_id);
1079 dissect_kauth_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1081 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1087 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1089 OUT_UINT(hf_afs_kauth_errcode);
1094 dissect_kauth_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1096 offset += 4; /* skip the opcode */
1100 case 1: /* authenticate old */
1101 case 21: /* authenticate */
1102 case 22: /* authenticate v2 */
1103 case 2: /* change pw */
1104 case 5: /* set fields */
1105 case 6: /* create user */
1106 case 7: /* delete user */
1107 case 8: /* get entry */
1108 case 14: /* unlock */
1109 case 15: /* lock status */
1110 OUT_RXString(hf_afs_kauth_princ);
1111 OUT_RXString(hf_afs_kauth_realm);
1112 OUT_BYTES_ALL(hf_afs_kauth_data);
1114 case 3: /* getticket-old */
1115 case 23: /* getticket */
1116 OUT_UINT(hf_afs_kauth_kvno);
1117 OUT_RXString(hf_afs_kauth_domain);
1118 OUT_BYTES_ALL(hf_afs_kauth_data);
1119 OUT_RXString(hf_afs_kauth_princ);
1120 OUT_RXString(hf_afs_kauth_realm);
1122 case 4: /* set pass */
1123 OUT_RXString(hf_afs_kauth_princ);
1124 OUT_RXString(hf_afs_kauth_realm);
1125 OUT_UINT(hf_afs_kauth_kvno);
1127 case 12: /* get pass */
1128 OUT_RXString(hf_afs_kauth_name);
1137 dissect_cb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1139 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1145 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1147 OUT_UINT(hf_afs_cb_errcode);
1152 dissect_cb_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1154 offset += 4; /* skip the opcode */
1158 case 204: /* callback */
1162 j = tvb_get_ntohl(tvb, offset);
1167 OUT_CB_AFSFid("Target");
1170 j = tvb_get_ntohl(tvb, offset);
1174 OUT_CB_AFSCallBack();
1184 dissect_prot_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1186 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1190 case 504: /* name to id */
1194 j = tvb_get_ntohl(tvb, offset);
1195 OUT_UINT(hf_afs_prot_count);
1199 OUT_UINT(hf_afs_prot_id);
1203 case 505: /* id to name */
1207 j = tvb_get_ntohl(tvb, offset);
1208 OUT_UINT(hf_afs_prot_count);
1212 OUT_RXStringV(hf_afs_prot_name, PRNAMEMAX);
1216 case 508: /* get cps */
1217 case 514: /* list elements */
1218 case 517: /* list owned */
1219 case 518: /* get cps2 */
1220 case 519: /* get host cps */
1224 j = tvb_get_ntohl(tvb, offset);
1225 OUT_UINT(hf_afs_prot_count);
1229 OUT_UINT(hf_afs_prot_id);
1233 case 510: /* list max */
1234 OUT_UINT(hf_afs_prot_maxuid);
1235 OUT_UINT(hf_afs_prot_maxgid);
1239 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1241 OUT_UINT(hf_afs_prot_errcode);
1246 dissect_prot_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1248 offset += 4; /* skip the opcode */
1252 case 500: /* new user */
1253 OUT_RXString(hf_afs_prot_name);
1254 OUT_UINT(hf_afs_prot_id);
1255 OUT_UINT(hf_afs_prot_oldid);
1257 case 501: /* where is it */
1258 case 506: /* delete */
1259 case 508: /* get cps */
1260 case 512: /* list entry */
1261 case 514: /* list elements */
1262 case 517: /* list owned */
1263 case 519: /* get host cps */
1264 OUT_UINT(hf_afs_prot_id);
1266 case 502: /* dump entry */
1267 OUT_UINT(hf_afs_prot_pos);
1269 case 503: /* add to group */
1270 case 507: /* remove from group */
1271 case 515: /* is a member of? */
1272 OUT_UINT(hf_afs_prot_uid);
1273 OUT_UINT(hf_afs_prot_gid);
1275 case 504: /* name to id */
1279 j = tvb_get_ntohl(tvb, offset);
1280 OUT_UINT(hf_afs_prot_count);
1284 OUT_RXStringV(hf_afs_prot_name,PRNAMEMAX);
1288 case 505: /* id to name */
1292 j = tvb_get_ntohl(tvb, offset);
1293 OUT_UINT(hf_afs_prot_count);
1297 OUT_UINT(hf_afs_prot_id);
1301 case 509: /* new entry */
1302 OUT_RXString(hf_afs_prot_name);
1303 OUT_UINT(hf_afs_prot_flag);
1304 OUT_UINT(hf_afs_prot_oldid);
1306 case 511: /* set max */
1307 OUT_UINT(hf_afs_prot_id);
1308 OUT_UINT(hf_afs_prot_flag);
1310 case 513: /* change entry */
1311 OUT_UINT(hf_afs_prot_id);
1312 OUT_RXString(hf_afs_prot_name);
1313 OUT_UINT(hf_afs_prot_oldid);
1314 OUT_UINT(hf_afs_prot_newid);
1316 case 520: /* update entry */
1317 OUT_UINT(hf_afs_prot_id);
1318 OUT_RXString(hf_afs_prot_name);
1327 dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1329 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1333 case 510: /* list entry */
1334 OUT_UINT(hf_afs_vldb_count);
1335 OUT_UINT(hf_afs_vldb_nextindex);
1337 case 503: /* get entry by id */
1338 case 504: /* get entry by name */
1341 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1343 nservers = tvb_get_ntohl(tvb, offset);
1344 OUT_UINT(hf_afs_vldb_numservers);
1349 OUT_IP(hf_afs_vldb_server);
1359 j = tvb_get_ntohl(tvb, offset);
1360 strcpy(part, "/vicepa");
1361 if ( i<nservers && j<=25 )
1363 part[6] = 'a' + (char) j;
1364 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1369 SKIP(8 * sizeof(guint32));
1370 OUT_UINT(hf_afs_vldb_rwvol);
1371 OUT_UINT(hf_afs_vldb_rovol);
1372 OUT_UINT(hf_afs_vldb_bkvol);
1373 OUT_UINT(hf_afs_vldb_clonevol);
1377 case 505: /* get new volume id */
1378 OUT_UINT(hf_afs_vldb_id);
1380 case 521: /* list entry */
1381 case 529: /* list entry U */
1382 OUT_UINT(hf_afs_vldb_count);
1383 OUT_UINT(hf_afs_vldb_nextindex);
1385 case 518: /* get entry by id n */
1386 case 519: /* get entry by name N */
1389 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1390 nservers = tvb_get_ntohl(tvb, offset);
1391 OUT_UINT(hf_afs_vldb_numservers);
1392 for (i=0; i<13; i++)
1396 OUT_IP(hf_afs_vldb_server);
1403 for (i=0; i<13; i++)
1406 j = tvb_get_ntohl(tvb, offset);
1407 strcpy(part, "/vicepa");
1408 if ( i<nservers && j<=25 )
1410 part[6] = 'a' + (char) j;
1411 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1416 SKIP(13 * sizeof(guint32));
1417 OUT_UINT(hf_afs_vldb_rwvol);
1418 OUT_UINT(hf_afs_vldb_rovol);
1419 OUT_UINT(hf_afs_vldb_bkvol);
1422 case 526: /* get entry by id u */
1423 case 527: /* get entry by name u */
1426 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1427 nservers = tvb_get_ntohl(tvb, offset);
1428 OUT_UINT(hf_afs_vldb_numservers);
1429 for (i=0; i<13; i++)
1433 OUT_UUID(hf_afs_vldb_serveruuid);
1440 for (i=0; i<13; i++)
1444 OUT_UINT(hf_afs_vldb_serveruniq);
1448 SKIP(sizeof(guint32));
1451 for (i=0; i<13; i++)
1454 j = tvb_get_ntohl(tvb, offset);
1455 strcpy(part, "/vicepa");
1456 if ( i<nservers && j<=25 )
1458 part[6] = 'a' + (char) j;
1459 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1464 for (i=0; i<13; i++)
1468 OUT_UINT(hf_afs_vldb_serverflags);
1472 SKIP(sizeof(guint32));
1475 OUT_UINT(hf_afs_vldb_rwvol);
1476 OUT_UINT(hf_afs_vldb_rovol);
1477 OUT_UINT(hf_afs_vldb_bkvol);
1478 OUT_UINT(hf_afs_vldb_clonevol);
1479 OUT_UINT(hf_afs_vldb_flags);
1480 OUT_UINT(hf_afs_vldb_spare1);
1481 OUT_UINT(hf_afs_vldb_spare2);
1482 OUT_UINT(hf_afs_vldb_spare3);
1483 OUT_UINT(hf_afs_vldb_spare4);
1484 OUT_UINT(hf_afs_vldb_spare5);
1485 OUT_UINT(hf_afs_vldb_spare6);
1486 OUT_UINT(hf_afs_vldb_spare7);
1487 OUT_UINT(hf_afs_vldb_spare8);
1488 OUT_UINT(hf_afs_vldb_spare9);
1493 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1495 OUT_UINT(hf_afs_vldb_errcode);
1500 dissect_vldb_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1502 offset += 4; /* skip the opcode */
1506 case 501: /* create new volume */
1507 case 517: /* create entry N */
1508 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1510 case 502: /* delete entry */
1511 case 503: /* get entry by id */
1512 case 507: /* update entry */
1513 case 508: /* set lock */
1514 case 509: /* release lock */
1515 case 518: /* get entry by id */
1516 OUT_UINT(hf_afs_vldb_id);
1517 OUT_UINT(hf_afs_vldb_type);
1519 case 504: /* get entry by name */
1520 case 519: /* get entry by name N */
1521 case 524: /* update entry by name */
1522 case 527: /* get entry by name U */
1523 OUT_RXString(hf_afs_vldb_name);
1525 case 505: /* get new vol id */
1526 OUT_UINT(hf_afs_vldb_bump);
1528 case 506: /* replace entry */
1529 case 520: /* replace entry N */
1530 OUT_UINT(hf_afs_vldb_id);
1531 OUT_UINT(hf_afs_vldb_type);
1532 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1534 case 510: /* list entry */
1535 case 521: /* list entry N */
1536 OUT_UINT(hf_afs_vldb_index);
1538 case 532: /* regaddr */
1539 OUT_UUID(hf_afs_vldb_serveruuid);
1540 OUT_UINT(hf_afs_vldb_spare1);
1541 OUT_VLDB_BulkAddr();
1550 dissect_ubik_reply(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1554 case 10000: /* vote-beacon */
1556 case 10001: /* vote-debug-old */
1557 OUT_UBIK_DebugOld();
1559 case 10002: /* vote-sdebug-old */
1560 OUT_UBIK_SDebugOld();
1562 case 10003: /* vote-get syncsite */
1564 case 10004: /* vote-debug */
1565 OUT_UBIK_DebugOld();
1566 OUT_UBIK_InterfaceAddrs();
1568 case 10005: /* vote-sdebug */
1569 OUT_UBIK_SDebugOld();
1570 OUT_UBIK_InterfaceAddrs();
1572 case 10006: /* vote-xdebug */
1573 OUT_UBIK_DebugOld();
1574 OUT_UBIK_InterfaceAddrs();
1575 OUT_UINT(hf_afs_ubik_isclone);
1577 case 10007: /* vote-xsdebug */
1578 OUT_UBIK_SDebugOld();
1579 OUT_UBIK_InterfaceAddrs();
1580 OUT_UINT(hf_afs_ubik_isclone);
1582 case 20000: /* disk-begin */
1584 case 20004: /* get version */
1585 OUT_UBIKVERSION("DB Version");
1587 case 20010: /* disk-probe */
1589 case 20012: /* disk-interfaceaddr */
1590 OUT_UBIK_InterfaceAddrs();
1596 dissect_ubik_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1598 offset += 4; /* skip the opcode */
1602 case 10000: /* vote-beacon */
1603 OUT_UINT(hf_afs_ubik_state);
1604 OUT_DATE(hf_afs_ubik_votestart);
1605 OUT_UBIKVERSION("DB Version");
1606 OUT_UBIKVERSION("TID");
1608 case 10001: /* vote-debug-old */
1610 case 10002: /* vote-sdebug-old */
1611 OUT_UINT(hf_afs_ubik_site);
1613 case 10003: /* vote-get sync site */
1614 OUT_IP(hf_afs_ubik_site);
1616 case 10004: /* vote-debug */
1617 case 10005: /* vote-sdebug */
1618 OUT_IP(hf_afs_ubik_site);
1620 case 20000: /* disk-begin */
1621 OUT_UBIKVERSION("TID");
1623 case 20001: /* disk-commit */
1624 OUT_UBIKVERSION("TID");
1626 case 20002: /* disk-lock */
1627 OUT_UBIKVERSION("TID");
1628 OUT_UINT(hf_afs_ubik_file);
1629 OUT_UINT(hf_afs_ubik_pos);
1630 OUT_UINT(hf_afs_ubik_length);
1631 OUT_UINT(hf_afs_ubik_locktype);
1633 case 20003: /* disk-write */
1634 OUT_UBIKVERSION("TID");
1635 OUT_UINT(hf_afs_ubik_file);
1636 OUT_UINT(hf_afs_ubik_pos);
1638 case 20004: /* disk-get version */
1640 case 20005: /* disk-get file */
1641 OUT_UINT(hf_afs_ubik_file);
1643 case 20006: /* disk-send file */
1644 OUT_UINT(hf_afs_ubik_file);
1645 OUT_UINT(hf_afs_ubik_length);
1646 OUT_UBIKVERSION("DB Version");
1648 case 20007: /* disk-abort */
1649 case 20008: /* disk-release locks */
1650 case 20010: /* disk-probe */
1652 case 20009: /* disk-truncate */
1653 OUT_UBIKVERSION("TID");
1654 OUT_UINT(hf_afs_ubik_file);
1655 OUT_UINT(hf_afs_ubik_length);
1657 case 20011: /* disk-writev */
1658 OUT_UBIKVERSION("TID");
1660 case 20012: /* disk-interfaceaddr */
1661 OUT_UBIK_InterfaceAddrs();
1663 case 20013: /* disk-set version */
1664 OUT_UBIKVERSION("TID");
1665 OUT_UBIKVERSION("Old DB Version");
1666 OUT_UBIKVERSION("New DB Version");
1675 dissect_backup_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1677 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1683 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1685 OUT_UINT(hf_afs_backup_errcode);
1690 dissect_backup_request(tvbuff_t *tvb _U_, struct rxinfo *rxinfo _U_, proto_tree *tree _U_, int offset, int opcode)
1692 offset += 4; /* skip the opcode */
1700 * Registration code for registering the protocol and fields
1704 proto_register_afs(void)
1706 static hf_register_info hf[] = {
1707 #include "packet-afs-register-info.h"
1709 static gint *ett[] = {
1717 &ett_afs_status_mask,
1719 &ett_afs_volumeinfo,
1721 &ett_afs_vldb_flags,
1724 proto_afs = proto_register_protocol("Andrew File System (AFS)",
1726 proto_register_field_array(proto_afs, hf, array_length(hf));
1727 proto_register_subtree_array(ett, array_length(ett));
1728 register_init_routine(&afs_init_protocol);
1730 register_dissector("afs", dissect_afs, proto_afs);