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.43 2002/02/08 22:36:21 nneul 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 int afs_packet_init_count = 100;
67 struct afs_request_key {
68 guint32 conversation, callnumber;
72 struct afs_request_val {
76 GHashTable *afs_request_hash = NULL;
77 GMemChunk *afs_request_keys = NULL;
78 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
432 /* FIXME: sscanf is probably quite dangerous if we run outside the packet. */
434 dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset)
438 int i, n, pos, neg, acl;
439 char user[128]; /* Be sure to adjust sscanf()s below if length is changed... */
442 bytes = tvb_get_ntohl(tvb, offset);
443 OUT_UINT(hf_afs_fs_acl_datasize);
446 if (sscanf((char *) GETSTR, "%d %n", &pos, &n) != 1) {
447 /* does not matter what we return, if this fails,
448 * we cant dissect anything else in the packet either.
452 proto_tree_add_uint(tree, hf_afs_fs_acl_count_positive, tvb,
457 if (sscanf((char *) GETSTR, "%d %n", &neg, &n) != 1) {
460 proto_tree_add_uint(tree, hf_afs_fs_acl_count_negative, tvb,
465 * This wacky order preserves the order used by the "fs" command
467 for (i = 0; i < pos; i++) {
468 if (sscanf((char *) GETSTR,
469 "%127s %d %n", user, &acl, &n) != 2) {
472 ACLOUT(user,1,acl,n);
475 for (i = 0; i < neg; i++) {
476 if (sscanf((char *) GETSTR,
477 "%127s %d %n", user, &acl, &n) != 2) {
480 ACLOUT(user,0,acl,n);
482 if (offset >= old_offset+bytes ) {
491 * Here are the helper dissection routines
495 dissect_fs_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
497 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
501 case 130: /* fetch data */
502 /* only on first packet */
503 if ( rxinfo->seq == 1 )
505 OUT_FS_AFSFetchStatus("Status");
506 OUT_FS_AFSCallBack();
509 OUT_BYTES_ALL(hf_afs_fs_data);
511 case 131: /* fetch acl */
512 offset = dissect_acl(tvb, rxinfo, tree, offset);
513 OUT_FS_AFSFetchStatus("Status");
516 case 132: /* Fetch status */
517 OUT_FS_AFSFetchStatus("Status");
518 OUT_FS_AFSCallBack();
521 case 133: /* Store data */
522 case 134: /* Store ACL */
523 case 135: /* Store status */
524 case 136: /* Remove file */
525 OUT_FS_AFSFetchStatus("Status");
528 case 137: /* create file */
529 case 141: /* make dir */
530 case 161: /* lookup */
531 case 163: /* dfs symlink */
532 OUT_FS_AFSFid((opcode == 137)? "New File" : ((opcode == 141)? "New Directory" : "File"));
533 OUT_FS_AFSFetchStatus("File Status");
534 OUT_FS_AFSFetchStatus("Directory Status");
535 OUT_FS_AFSCallBack();
538 case 138: /* rename */
539 OUT_FS_AFSFetchStatus("Old Directory Status");
540 OUT_FS_AFSFetchStatus("New Directory Status");
543 case 139: /* symlink */
544 OUT_FS_AFSFid("Symlink");
546 OUT_FS_AFSFetchStatus("Symlink Status");
547 case 142: /* rmdir */
548 OUT_FS_AFSFetchStatus("Directory Status");
551 case 143: /* old set lock */
552 case 144: /* old extend lock */
553 case 145: /* old release lock */
554 case 147: /* give up callbacks */
555 case 150: /* set volume status */
556 case 152: /* check token */
557 /* nothing returned */
559 case 146: /* get statistics */
560 OUT_FS_ViceStatistics();
562 case 148: /* get volume info */
563 case 154: /* n-get-volume-info */
566 case 149: /* get volume status */
567 OUT_FS_AFSFetchVolumeStatus();
568 OUT_RXString(hf_afs_fs_volname);
569 OUT_RXString(hf_afs_fs_offlinemsg);
570 OUT_RXString(hf_afs_fs_motd);
572 case 151: /* root volume */
573 OUT_RXString(hf_afs_fs_volname);
575 case 153: /* get time */
576 OUT_TIMESTAMP(hf_afs_fs_timestamp);
578 case 155: /* bulk status */
579 OUT_FS_AFSBulkStats();
584 case 156: /* set lock */
585 case 157: /* extend lock */
586 case 158: /* release lock */
589 case 159: /* x-stats-version */
590 OUT_UINT(hf_afs_fs_xstats_version);
592 case 160: /* get xstats */
593 OUT_UINT(hf_afs_fs_xstats_version);
594 OUT_DATE(hf_afs_fs_xstats_timestamp);
595 OUT_FS_AFS_CollData();
597 case 162: /* flush cps */
598 OUT_UINT(hf_afs_fs_cps_spare2);
599 OUT_UINT(hf_afs_fs_cps_spare3);
603 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
605 OUT_UINT(hf_afs_fs_errcode);
610 dissect_fs_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
612 /* skip the opcode if this is the first packet in the stream */
613 if ( rxinfo->seq == 1 )
615 offset += 4; /* skip the opcode */
620 case 130: /* Fetch data */
621 OUT_FS_AFSFid("Source");
622 OUT_UINT(hf_afs_fs_offset);
623 OUT_UINT(hf_afs_fs_length);
625 case 131: /* Fetch ACL */
626 OUT_FS_AFSFid("Target");
628 case 132: /* Fetch Status */
629 OUT_FS_AFSFid("Target");
631 case 133: /* Store Data */
632 if ( rxinfo->seq == 1 )
634 OUT_FS_AFSFid("Destination");
635 OUT_FS_AFSStoreStatus("Status");
636 OUT_UINT(hf_afs_fs_offset);
637 OUT_UINT(hf_afs_fs_length);
638 OUT_UINT(hf_afs_fs_flength);
640 OUT_BYTES_ALL(hf_afs_fs_data);
642 case 134: /* Store ACL */
643 OUT_FS_AFSFid("Target");
644 offset = dissect_acl(tvb, rxinfo, tree, offset);
646 case 135: /* Store Status */
647 OUT_FS_AFSFid("Target");
648 OUT_FS_AFSStoreStatus("Status");
650 case 136: /* Remove File */
651 OUT_FS_AFSFid("Remove File");
652 OUT_RXString(hf_afs_fs_name);
654 case 137: /* Create File */
655 OUT_FS_AFSFid("Target");
656 OUT_RXString(hf_afs_fs_name);
657 OUT_FS_AFSStoreStatus("Status");
659 case 138: /* Rename file */
660 OUT_FS_AFSFid("Old");
661 OUT_RXString(hf_afs_fs_oldname);
662 OUT_FS_AFSFid("New");
663 OUT_RXString(hf_afs_fs_newname);
665 case 139: /* Symlink */
666 OUT_FS_AFSFid("File");
667 OUT_RXString(hf_afs_fs_symlink_name);
668 OUT_RXString(hf_afs_fs_symlink_content);
669 OUT_FS_AFSStoreStatus("Status");
672 OUT_FS_AFSFid("Link To (New File)");
673 OUT_RXString(hf_afs_fs_name);
674 OUT_FS_AFSFid("Link From (Old File)");
676 case 141: /* Make dir */
677 OUT_FS_AFSFid("Target");
678 OUT_RXString(hf_afs_fs_name);
679 OUT_FS_AFSStoreStatus("Status");
681 case 142: /* Remove dir */
682 OUT_FS_AFSFid("Target");
683 OUT_RXString(hf_afs_fs_name);
685 case 143: /* Old Set Lock */
686 OUT_FS_AFSFid("Target");
687 OUT_UINT(hf_afs_fs_vicelocktype);
690 case 144: /* Old Extend Lock */
691 OUT_FS_AFSFid("Target");
694 case 145: /* Old Release Lock */
695 OUT_FS_AFSFid("Target");
698 case 146: /* Get statistics */
701 case 147: /* Give up callbacks */
705 case 148: /* Get vol info */
706 OUT_RXString(hf_afs_fs_volname);
708 case 149: /* Get vol stats */
709 OUT_UINT(hf_afs_fs_volid);
711 case 150: /* Set vol stats */
712 OUT_UINT(hf_afs_fs_volid);
713 OUT_FS_AFSStoreVolumeStatus();
714 OUT_RXString(hf_afs_fs_volname);
715 OUT_RXString(hf_afs_fs_offlinemsg);
716 OUT_RXString(hf_afs_fs_motd);
718 case 151: /* get root volume */
721 case 152: /* check token */
722 OUT_UINT(hf_afs_fs_viceid);
725 case 153: /* get time */
728 case 154: /* new get vol info */
729 OUT_RXString(hf_afs_fs_volname);
731 case 155: /* bulk stat */
734 case 156: /* Set Lock */
735 OUT_FS_AFSFid("Target");
736 OUT_UINT(hf_afs_fs_vicelocktype);
738 case 157: /* Extend Lock */
739 OUT_FS_AFSFid("Target");
741 case 158: /* Release Lock */
742 OUT_FS_AFSFid("Target");
744 case 159: /* xstats version */
747 case 160: /* get xstats */
748 OUT_UINT(hf_afs_fs_xstats_clientversion);
749 OUT_UINT(hf_afs_fs_xstats_collnumber);
751 case 161: /* lookup */
752 OUT_FS_AFSFid("Target");
753 OUT_RXString(hf_afs_fs_name);
755 case 162: /* flush cps */
758 OUT_UINT(hf_afs_fs_cps_spare1);
760 case 163: /* dfs symlink */
761 OUT_FS_AFSFid("Target");
762 OUT_RXString(hf_afs_fs_symlink_name);
763 OUT_RXString(hf_afs_fs_symlink_content);
764 OUT_FS_AFSStoreStatus("Symlink Status");
773 dissect_bos_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
775 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
779 case 80: /* create bnode */
782 case 81: /* delete bnode */
785 case 82: /* set status */
788 case 83: /* get status */
789 OUT_INT(hf_afs_bos_status);
790 OUT_RXString(hf_afs_bos_statusdesc);
792 case 84: /* enumerate instance */
793 OUT_RXString(hf_afs_bos_instance);
795 case 85: /* get instance info */
796 OUT_RXString(hf_afs_bos_type);
799 case 86: /* get instance parm */
800 OUT_RXString(hf_afs_bos_parm);
802 case 87: /* add siperuser */
805 case 88: /* delete superuser */
808 case 89: /* list superusers */
809 OUT_RXString(hf_afs_bos_user);
811 case 90: /* list keys */
812 OUT_UINT(hf_afs_bos_kvno);
816 case 91: /* add key */
819 case 92: /* delete key */
822 case 93: /* set cell name */
825 case 94: /* get cell name */
826 OUT_RXString(hf_afs_bos_cell);
828 case 95: /* get cell host */
829 OUT_RXString(hf_afs_bos_host);
831 case 96: /* add cell host */
834 case 97: /* delete cell host */
837 case 98: /* set tstatus */
840 case 99: /* shutdown all */
843 case 100: /* restart all */
846 case 101: /* startup all */
849 case 102: /* set noauth flag */
852 case 103: /* rebozo */
855 case 104: /* restart */
858 case 105: /* install */
861 case 106: /* uninstall */
864 case 107: /* get dates */
865 OUT_DATE(hf_afs_bos_newtime);
866 OUT_DATE(hf_afs_bos_baktime);
867 OUT_DATE(hf_afs_bos_oldtime);
872 case 109: /* prune */
875 case 110: /* set restart time */
878 case 111: /* get restart time */
881 case 112: /* get log */
882 /* need to make this dump a big string somehow */
883 OUT_BYTES_ALL(hf_afs_bos_data);
885 case 113: /* wait all */
888 case 114: /* get instance strings */
889 OUT_RXString(hf_afs_bos_error);
890 OUT_RXString(hf_afs_bos_spare1);
891 OUT_RXString(hf_afs_bos_spare2);
892 OUT_RXString(hf_afs_bos_spare3);
896 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
898 OUT_UINT(hf_afs_bos_errcode);
903 dissect_bos_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
905 offset += 4; /* skip the opcode */
909 case 80: /* create b node */
910 OUT_RXString(hf_afs_bos_type);
911 OUT_RXString(hf_afs_bos_instance);
912 OUT_RXString(hf_afs_bos_parm);
913 OUT_RXString(hf_afs_bos_parm);
914 OUT_RXString(hf_afs_bos_parm);
915 OUT_RXString(hf_afs_bos_parm);
916 OUT_RXString(hf_afs_bos_parm);
917 OUT_RXString(hf_afs_bos_parm);
919 case 81: /* delete b node */
920 OUT_RXString(hf_afs_bos_instance);
922 case 82: /* set status */
923 OUT_RXString(hf_afs_bos_instance);
924 OUT_UINT(hf_afs_bos_status);
926 case 83: /* get status */
927 OUT_RXString(hf_afs_bos_instance);
929 case 84: /* enumerate instance */
930 OUT_UINT(hf_afs_bos_num);
932 case 85: /* get instance info */
933 OUT_RXString(hf_afs_bos_instance);
935 case 86: /* get instance parm */
936 OUT_RXString(hf_afs_bos_instance);
937 OUT_UINT(hf_afs_bos_num);
939 case 87: /* add super user */
940 OUT_RXString(hf_afs_bos_user);
942 case 88: /* delete super user */
943 OUT_RXString(hf_afs_bos_user);
945 case 89: /* list super users */
946 OUT_UINT(hf_afs_bos_num);
948 case 90: /* list keys */
949 OUT_UINT(hf_afs_bos_num);
951 case 91: /* add key */
952 OUT_UINT(hf_afs_bos_num);
955 case 92: /* delete key */
956 OUT_UINT(hf_afs_bos_num);
958 case 93: /* set cell name */
959 OUT_RXString(hf_afs_bos_content);
961 case 95: /* set cell host */
962 OUT_UINT(hf_afs_bos_num);
964 case 96: /* add cell host */
965 OUT_RXString(hf_afs_bos_content);
967 case 97: /* delete cell host */
968 OUT_RXString(hf_afs_bos_content);
970 case 98: /* set t status */
971 OUT_RXString(hf_afs_bos_content);
972 OUT_UINT(hf_afs_bos_status);
974 case 99: /* shutdown all */
977 case 100: /* restart all */
980 case 101: /* startup all */
983 case 102: /* set no-auth flag */
984 OUT_UINT(hf_afs_bos_flags);
986 case 103: /* re-bozo? */
989 case 104: /* restart */
990 OUT_RXString(hf_afs_bos_instance);
992 case 105: /* install */
993 OUT_RXString(hf_afs_bos_path);
994 OUT_UINT(hf_afs_bos_size);
995 OUT_UINT(hf_afs_bos_flags);
996 OUT_UINT(hf_afs_bos_date);
998 case 106: /* uninstall */
999 OUT_RXString(hf_afs_bos_path);
1001 case 107: /* get dates */
1002 OUT_RXString(hf_afs_bos_path);
1004 case 108: /* exec */
1005 OUT_RXString(hf_afs_bos_cmd);
1007 case 109: /* prune */
1008 OUT_UINT(hf_afs_bos_flags);
1010 case 110: /* set restart time */
1011 OUT_UINT(hf_afs_bos_num);
1014 case 111: /* get restart time */
1015 OUT_UINT(hf_afs_bos_num);
1017 case 112: /* get log */
1018 OUT_RXString(hf_afs_bos_file);
1020 case 113: /* wait all */
1023 case 114: /* get instance strings */
1024 OUT_RXString(hf_afs_bos_content);
1033 dissect_vol_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1035 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1040 /* should loop here maybe */
1041 OUT_UINT(hf_afs_vol_count);
1042 OUT_RXStringV(hf_afs_vol_name, 32); /* not sure on */
1046 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1048 OUT_UINT(hf_afs_vol_errcode);
1053 dissect_vol_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1055 offset += 4; /* skip the opcode */
1059 case 121: /* list one vol */
1060 OUT_UINT(hf_afs_vol_count);
1061 OUT_UINT(hf_afs_vol_id);
1070 dissect_kauth_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1072 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1078 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1080 OUT_UINT(hf_afs_kauth_errcode);
1085 dissect_kauth_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1087 offset += 4; /* skip the opcode */
1091 case 1: /* authenticate old */
1092 case 21: /* authenticate */
1093 case 22: /* authenticate v2 */
1094 case 2: /* change pw */
1095 case 5: /* set fields */
1096 case 6: /* create user */
1097 case 7: /* delete user */
1098 case 8: /* get entry */
1099 case 14: /* unlock */
1100 case 15: /* lock status */
1101 OUT_RXString(hf_afs_kauth_princ);
1102 OUT_RXString(hf_afs_kauth_realm);
1103 OUT_BYTES_ALL(hf_afs_kauth_data);
1105 case 3: /* getticket-old */
1106 case 23: /* getticket */
1107 OUT_UINT(hf_afs_kauth_kvno);
1108 OUT_RXString(hf_afs_kauth_domain);
1109 OUT_RXString(hf_afs_kauth_data);
1110 OUT_RXString(hf_afs_kauth_princ);
1111 OUT_RXString(hf_afs_kauth_realm);
1113 case 4: /* set pass */
1114 OUT_RXString(hf_afs_kauth_princ);
1115 OUT_RXString(hf_afs_kauth_realm);
1116 OUT_UINT(hf_afs_kauth_kvno);
1118 case 12: /* get pass */
1119 OUT_RXString(hf_afs_kauth_name);
1128 dissect_cb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1130 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1136 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1138 OUT_UINT(hf_afs_cb_errcode);
1143 dissect_cb_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1145 offset += 4; /* skip the opcode */
1149 case 204: /* callback */
1153 j = tvb_get_ntohl(tvb, offset);
1158 OUT_CB_AFSFid("Target");
1161 j = tvb_get_ntohl(tvb, offset);
1165 OUT_CB_AFSCallBack();
1175 dissect_prot_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1177 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1181 case 504: /* name to id */
1185 j = tvb_get_ntohl(tvb, offset);
1186 OUT_UINT(hf_afs_prot_count);
1190 OUT_UINT(hf_afs_prot_id);
1194 case 505: /* id to name */
1198 j = tvb_get_ntohl(tvb, offset);
1199 OUT_UINT(hf_afs_prot_count);
1203 OUT_RXStringV(hf_afs_prot_name, PRNAMEMAX);
1207 case 508: /* get cps */
1208 case 514: /* list elements */
1209 case 517: /* list owned */
1210 case 518: /* get cps2 */
1211 case 519: /* get host cps */
1215 j = tvb_get_ntohl(tvb, offset);
1216 OUT_UINT(hf_afs_prot_count);
1220 OUT_UINT(hf_afs_prot_id);
1224 case 510: /* list max */
1225 OUT_UINT(hf_afs_prot_maxuid);
1226 OUT_UINT(hf_afs_prot_maxgid);
1230 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1232 OUT_UINT(hf_afs_prot_errcode);
1237 dissect_prot_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1239 offset += 4; /* skip the opcode */
1243 case 500: /* new user */
1244 OUT_RXString(hf_afs_prot_name);
1245 OUT_UINT(hf_afs_prot_id);
1246 OUT_UINT(hf_afs_prot_oldid);
1248 case 501: /* where is it */
1249 case 506: /* delete */
1250 case 508: /* get cps */
1251 case 512: /* list entry */
1252 case 514: /* list elements */
1253 case 517: /* list owned */
1254 case 519: /* get host cps */
1255 OUT_UINT(hf_afs_prot_id);
1257 case 502: /* dump entry */
1258 OUT_UINT(hf_afs_prot_pos);
1260 case 503: /* add to group */
1261 case 507: /* remove from group */
1262 case 515: /* is a member of? */
1263 OUT_UINT(hf_afs_prot_uid);
1264 OUT_UINT(hf_afs_prot_gid);
1266 case 504: /* name to id */
1270 j = tvb_get_ntohl(tvb, offset);
1271 OUT_UINT(hf_afs_prot_count);
1275 OUT_RXStringV(hf_afs_prot_name,PRNAMEMAX);
1279 case 505: /* id to name */
1283 j = tvb_get_ntohl(tvb, offset);
1284 OUT_UINT(hf_afs_prot_count);
1288 OUT_UINT(hf_afs_prot_id);
1292 case 509: /* new entry */
1293 OUT_RXString(hf_afs_prot_name);
1294 OUT_UINT(hf_afs_prot_flag);
1295 OUT_UINT(hf_afs_prot_oldid);
1297 case 511: /* set max */
1298 OUT_UINT(hf_afs_prot_id);
1299 OUT_UINT(hf_afs_prot_flag);
1301 case 513: /* change entry */
1302 OUT_UINT(hf_afs_prot_id);
1303 OUT_RXString(hf_afs_prot_name);
1304 OUT_UINT(hf_afs_prot_oldid);
1305 OUT_UINT(hf_afs_prot_newid);
1307 case 520: /* update entry */
1308 OUT_UINT(hf_afs_prot_id);
1309 OUT_RXString(hf_afs_prot_name);
1318 dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1320 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1324 case 510: /* list entry */
1325 OUT_UINT(hf_afs_vldb_count);
1326 OUT_UINT(hf_afs_vldb_nextindex);
1328 case 503: /* get entry by id */
1329 case 504: /* get entry by name */
1332 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1334 nservers = tvb_get_ntohl(tvb, offset);
1335 OUT_UINT(hf_afs_vldb_numservers);
1340 OUT_IP(hf_afs_vldb_server);
1350 j = tvb_get_ntohl(tvb, offset);
1351 strcpy(part, "/vicepa");
1352 if ( i<nservers && j<=25 )
1354 part[6] = 'a' + (char) j;
1355 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1360 SKIP(8 * sizeof(guint32));
1361 OUT_UINT(hf_afs_vldb_rwvol);
1362 OUT_UINT(hf_afs_vldb_rovol);
1363 OUT_UINT(hf_afs_vldb_bkvol);
1364 OUT_UINT(hf_afs_vldb_clonevol);
1368 case 505: /* get new volume id */
1369 OUT_UINT(hf_afs_vldb_id);
1371 case 521: /* list entry */
1372 case 529: /* list entry U */
1373 OUT_UINT(hf_afs_vldb_count);
1374 OUT_UINT(hf_afs_vldb_nextindex);
1376 case 518: /* get entry by id n */
1377 case 519: /* get entry by name N */
1380 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1381 nservers = tvb_get_ntohl(tvb, offset);
1382 OUT_UINT(hf_afs_vldb_numservers);
1383 for (i=0; i<13; i++)
1387 OUT_IP(hf_afs_vldb_server);
1394 for (i=0; i<13; i++)
1397 j = tvb_get_ntohl(tvb, offset);
1398 strcpy(part, "/vicepa");
1399 if ( i<nservers && j<=25 )
1401 part[6] = 'a' + (char) j;
1402 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1407 SKIP(13 * sizeof(guint32));
1408 OUT_UINT(hf_afs_vldb_rwvol);
1409 OUT_UINT(hf_afs_vldb_rovol);
1410 OUT_UINT(hf_afs_vldb_bkvol);
1413 case 526: /* get entry by id u */
1414 case 527: /* get entry by name u */
1417 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1418 nservers = tvb_get_ntohl(tvb, offset);
1419 OUT_UINT(hf_afs_vldb_numservers);
1420 for (i=0; i<13; i++)
1424 OUT_UUID(hf_afs_vldb_serveruuid);
1431 for (i=0; i<13; i++)
1435 OUT_UINT(hf_afs_vldb_serveruniq);
1439 SKIP(sizeof(guint32));
1442 for (i=0; i<13; i++)
1445 j = tvb_get_ntohl(tvb, offset);
1446 strcpy(part, "/vicepa");
1447 if ( i<nservers && j<=25 )
1449 part[6] = 'a' + (char) j;
1450 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1455 for (i=0; i<13; i++)
1459 OUT_UINT(hf_afs_vldb_serverflags);
1463 SKIP(sizeof(guint32));
1466 OUT_UINT(hf_afs_vldb_rwvol);
1467 OUT_UINT(hf_afs_vldb_rovol);
1468 OUT_UINT(hf_afs_vldb_bkvol);
1469 OUT_UINT(hf_afs_vldb_clonevol);
1470 OUT_UINT(hf_afs_vldb_flags);
1471 OUT_UINT(hf_afs_vldb_spare1);
1472 OUT_UINT(hf_afs_vldb_spare2);
1473 OUT_UINT(hf_afs_vldb_spare3);
1474 OUT_UINT(hf_afs_vldb_spare4);
1475 OUT_UINT(hf_afs_vldb_spare5);
1476 OUT_UINT(hf_afs_vldb_spare6);
1477 OUT_UINT(hf_afs_vldb_spare7);
1478 OUT_UINT(hf_afs_vldb_spare8);
1479 OUT_UINT(hf_afs_vldb_spare9);
1484 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1486 OUT_UINT(hf_afs_vldb_errcode);
1491 dissect_vldb_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1493 offset += 4; /* skip the opcode */
1497 case 501: /* create new volume */
1498 case 517: /* create entry N */
1499 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1501 case 502: /* delete entry */
1502 case 503: /* get entry by id */
1503 case 507: /* update entry */
1504 case 508: /* set lock */
1505 case 509: /* release lock */
1506 case 518: /* get entry by id */
1507 OUT_UINT(hf_afs_vldb_id);
1508 OUT_UINT(hf_afs_vldb_type);
1510 case 504: /* get entry by name */
1511 case 519: /* get entry by name N */
1512 case 524: /* update entry by name */
1513 case 527: /* get entry by name U */
1514 OUT_RXString(hf_afs_vldb_name);
1516 case 505: /* get new vol id */
1517 OUT_UINT(hf_afs_vldb_bump);
1519 case 506: /* replace entry */
1520 case 520: /* replace entry N */
1521 OUT_UINT(hf_afs_vldb_id);
1522 OUT_UINT(hf_afs_vldb_type);
1523 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1525 case 510: /* list entry */
1526 case 521: /* list entry N */
1527 OUT_UINT(hf_afs_vldb_index);
1529 case 532: /* regaddr */
1530 OUT_UUID(hf_afs_vldb_serveruuid);
1531 OUT_UINT(hf_afs_vldb_spare1);
1532 OUT_VLDB_BulkAddr();
1541 dissect_ubik_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1545 case 10000: /* vote-beacon */
1547 case 10001: /* vote-debug-old */
1548 OUT_UBIK_DebugOld();
1550 case 10002: /* vote-sdebug-old */
1551 OUT_UBIK_SDebugOld();
1553 case 10003: /* vote-get syncsite */
1555 case 10004: /* vote-debug */
1556 OUT_UBIK_DebugOld();
1557 OUT_UBIK_InterfaceAddrs();
1559 case 10005: /* vote-sdebug */
1560 OUT_UBIK_SDebugOld();
1561 OUT_UBIK_InterfaceAddrs();
1563 case 10006: /* vote-xdebug */
1564 OUT_UBIK_DebugOld();
1565 OUT_UBIK_InterfaceAddrs();
1566 OUT_UINT(hf_afs_ubik_isclone);
1568 case 10007: /* vote-xsdebug */
1569 OUT_UBIK_SDebugOld();
1570 OUT_UBIK_InterfaceAddrs();
1571 OUT_UINT(hf_afs_ubik_isclone);
1573 case 20000: /* disk-begin */
1575 case 20004: /* get version */
1576 OUT_UBIKVERSION("DB Version");
1578 case 20010: /* disk-probe */
1580 case 20012: /* disk-interfaceaddr */
1581 OUT_UBIK_InterfaceAddrs();
1587 dissect_ubik_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1589 offset += 4; /* skip the opcode */
1593 case 10000: /* vote-beacon */
1594 OUT_UINT(hf_afs_ubik_state);
1595 OUT_DATE(hf_afs_ubik_votestart);
1596 OUT_UBIKVERSION("DB Version");
1597 OUT_UBIKVERSION("TID");
1599 case 10001: /* vote-debug-old */
1601 case 10002: /* vote-sdebug-old */
1602 OUT_UINT(hf_afs_ubik_site);
1604 case 10003: /* vote-get sync site */
1605 OUT_IP(hf_afs_ubik_site);
1607 case 10004: /* vote-debug */
1608 case 10005: /* vote-sdebug */
1609 OUT_IP(hf_afs_ubik_site);
1611 case 20000: /* disk-begin */
1612 OUT_UBIKVERSION("TID");
1614 case 20001: /* disk-commit */
1615 OUT_UBIKVERSION("TID");
1617 case 20002: /* disk-lock */
1618 OUT_UBIKVERSION("TID");
1619 OUT_UINT(hf_afs_ubik_file);
1620 OUT_UINT(hf_afs_ubik_pos);
1621 OUT_UINT(hf_afs_ubik_length);
1622 OUT_UINT(hf_afs_ubik_locktype);
1624 case 20003: /* disk-write */
1625 OUT_UBIKVERSION("TID");
1626 OUT_UINT(hf_afs_ubik_file);
1627 OUT_UINT(hf_afs_ubik_pos);
1629 case 20004: /* disk-get version */
1631 case 20005: /* disk-get file */
1632 OUT_UINT(hf_afs_ubik_file);
1634 case 20006: /* disk-send file */
1635 OUT_UINT(hf_afs_ubik_file);
1636 OUT_UINT(hf_afs_ubik_length);
1637 OUT_UBIKVERSION("DB Version");
1639 case 20007: /* disk-abort */
1640 case 20008: /* disk-release locks */
1641 case 20010: /* disk-probe */
1643 case 20009: /* disk-truncate */
1644 OUT_UBIKVERSION("TID");
1645 OUT_UINT(hf_afs_ubik_file);
1646 OUT_UINT(hf_afs_ubik_length);
1648 case 20011: /* disk-writev */
1649 OUT_UBIKVERSION("TID");
1651 case 20012: /* disk-interfaceaddr */
1652 OUT_UBIK_InterfaceAddrs();
1654 case 20013: /* disk-set version */
1655 OUT_UBIKVERSION("TID");
1656 OUT_UBIKVERSION("Old DB Version");
1657 OUT_UBIKVERSION("New DB Version");
1666 dissect_backup_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1668 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1674 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1676 OUT_UINT(hf_afs_backup_errcode);
1681 dissect_backup_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1683 offset += 4; /* skip the opcode */
1691 * Registration code for registering the protocol and fields
1695 proto_register_afs(void)
1697 static hf_register_info hf[] = {
1698 #include "packet-afs-register-info.h"
1700 static gint *ett[] = {
1708 &ett_afs_status_mask,
1710 &ett_afs_volumeinfo,
1712 &ett_afs_vldb_flags,
1715 proto_afs = proto_register_protocol("Andrew File System (AFS)",
1717 proto_register_field_array(proto_afs, hf, array_length(hf));
1718 proto_register_subtree_array(ett, array_length(ett));
1719 register_init_routine(&afs_init_protocol);
1721 register_dissector("afs", dissect_afs, proto_afs);