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.35 2001/11/03 00:58:49 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>
51 #include "conversation.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_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->fd, COL_PROTOCOL)) {
200 col_set_str(pinfo->fd, COL_PROTOCOL, "AFS (RX)");
202 if (check_col(pinfo->fd, COL_INFO)) {
203 col_clear(pinfo->fd, 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->fd, COL_INFO))
338 col_add_fstr(pinfo->fd, 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->fd, COL_INFO))
345 col_add_fstr(pinfo->fd, 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->fd, COL_INFO))
353 col_add_fstr(pinfo->fd, 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,
361 tvb_length_remaining(tvb, offset), FALSE);
362 afs_tree = proto_item_add_subtree(ti, ett_afs);
364 proto_tree_add_text(afs_tree, tvb,
365 offset, tvb_length_remaining(tvb, offset),
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 ti = proto_tree_add_uint(afs_tree,
377 node, tvb, offset, 4, opcode);
378 } else if ( reply && node != 0 ) {
379 /* the opcode isn't in this packet */
380 ti = proto_tree_add_uint(afs_tree,
381 node, tvb, offset, 0, opcode);
383 ti = proto_tree_add_text(afs_tree, tvb,
384 offset, 0, "Operation: Unknown");
387 /* Add the subtree for this particular service */
388 afs_op_tree = proto_item_add_subtree(ti, ett_afs_op);
390 if ( typenode != 0 ) {
391 /* indicate the type of request */
392 proto_tree_add_boolean_hidden(afs_tree, typenode, tvb, offset, 0, 1);
395 /* Process the packet according to what service it is */
397 (*dissector)(tvb, rxinfo, afs_op_tree, offset, opcode);
402 /* if it's the last packet, and it's a reply, remove opcode
404 /* ignoring for now, I'm not sure how the chunk deallocation works */
405 if ( rxinfo->flags & RX_LAST_PACKET && reply ){
412 * Here is a helper routine for adding an AFS acl to the proto tree
413 * This is to be used with FS packets only
415 * An AFS ACL is a string that has the following format:
417 * <positive> <negative>
421 * "positive" and "negative" are integers which contain the number of
422 * positive and negative ACL's in the string. The uid/aclbits pair are
423 * ASCII strings containing the UID/PTS record and and a ascii number
424 * representing a logical OR of all the ACL permission bits
426 /* FIXME: sscanf is probably quite dangerous if we run outside the packet. */
428 dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset)
432 int i, n, pos, neg, acl;
433 char user[128]; /* Be sure to adjust sscanf()s below if length is changed... */
436 bytes = tvb_get_ntohl(tvb, offset);
437 OUT_UINT(hf_afs_fs_acl_datasize);
440 if (sscanf((char *) GETSTR, "%d %n", &pos, &n) != 1) {
441 /* does not matter what we return, if this fails,
442 * we cant dissect anything else in the packet either.
446 proto_tree_add_uint(tree, hf_afs_fs_acl_count_positive, tvb,
451 if (sscanf((char *) GETSTR, "%d %n", &neg, &n) != 1) {
454 proto_tree_add_uint(tree, hf_afs_fs_acl_count_negative, tvb,
459 * This wacky order preserves the order used by the "fs" command
461 for (i = 0; i < pos; i++) {
462 if (sscanf((char *) GETSTR,
463 "%127s %d %n", user, &acl, &n) != 2) {
466 ACLOUT(user,1,acl,n);
469 for (i = 0; i < neg; i++) {
470 if (sscanf((char *) GETSTR,
471 "%127s %d %n", user, &acl, &n) != 2) {
474 ACLOUT(user,0,acl,n);
476 if (offset >= old_offset+bytes ) {
485 * Here are the helper dissection routines
489 dissect_fs_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
491 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
495 case 130: /* fetch data */
496 /* only on first packet */
497 if ( rxinfo->seq == 1 )
499 OUT_FS_AFSFetchStatus("Status");
500 OUT_FS_AFSCallBack();
503 OUT_BYTES_ALL(hf_afs_fs_data);
505 case 131: /* fetch acl */
506 offset = dissect_acl(tvb, rxinfo, tree, offset);
507 OUT_FS_AFSFetchStatus("Status");
510 case 132: /* Fetch status */
511 OUT_FS_AFSFetchStatus("Status");
512 OUT_FS_AFSCallBack();
515 case 133: /* Store data */
516 case 134: /* Store ACL */
517 case 135: /* Store status */
518 case 136: /* Remove file */
519 OUT_FS_AFSFetchStatus("Status");
522 case 137: /* create file */
523 case 141: /* make dir */
524 case 161: /* lookup */
525 case 163: /* dfs symlink */
526 OUT_FS_AFSFid((opcode == 137)? "New File" : ((opcode == 141)? "New Directory" : "File"));
527 OUT_FS_AFSFetchStatus("File Status");
528 OUT_FS_AFSFetchStatus("Directory Status");
529 OUT_FS_AFSCallBack();
532 case 138: /* rename */
533 OUT_FS_AFSFetchStatus("Old Directory Status");
534 OUT_FS_AFSFetchStatus("New Directory Status");
537 case 139: /* symlink */
538 OUT_FS_AFSFid("Symlink");
540 OUT_FS_AFSFetchStatus("Symlink Status");
541 case 142: /* rmdir */
542 OUT_FS_AFSFetchStatus("Directory Status");
545 case 143: /* old set lock */
546 case 144: /* old extend lock */
547 case 145: /* old release lock */
548 case 147: /* give up callbacks */
549 case 150: /* set volume status */
550 case 152: /* check token */
551 /* nothing returned */
553 case 146: /* get statistics */
554 OUT_FS_ViceStatistics();
556 case 148: /* get volume info */
557 case 154: /* n-get-volume-info */
560 case 149: /* get volume status */
561 OUT_FS_AFSFetchVolumeStatus();
562 OUT_STRING(hf_afs_fs_volname);
563 OUT_STRING(hf_afs_fs_offlinemsg);
564 OUT_STRING(hf_afs_fs_motd);
566 case 151: /* root volume */
567 OUT_STRING(hf_afs_fs_volname);
569 case 153: /* get time */
570 OUT_TIMESTAMP(hf_afs_fs_timestamp);
572 case 155: /* bulk status */
573 OUT_FS_AFSBulkStats();
577 case 156: /* set lock */
578 case 157: /* extend lock */
579 case 158: /* release lock */
582 case 159: /* x-stats-version */
583 OUT_UINT(hf_afs_fs_xstats_version);
585 case 160: /* get xstats */
586 OUT_UINT(hf_afs_fs_xstats_version);
587 OUT_DATE(hf_afs_fs_xstats_timestamp);
588 OUT_FS_AFS_CollData();
590 case 162: /* flush cps */
591 OUT_UINT(hf_afs_fs_cps_spare2);
592 OUT_UINT(hf_afs_fs_cps_spare3);
596 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
598 OUT_UINT(hf_afs_fs_errcode);
603 dissect_fs_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
605 offset += 4; /* skip the opcode */
609 case 130: /* Fetch data */
610 OUT_FS_AFSFid("Source");
611 OUT_UINT(hf_afs_fs_offset);
612 OUT_UINT(hf_afs_fs_length);
614 case 131: /* Fetch ACL */
615 OUT_FS_AFSFid("Target");
617 case 132: /* Fetch Status */
618 OUT_FS_AFSFid("Target");
620 case 133: /* Store Data */
621 OUT_FS_AFSFid("Destination");
622 OUT_FS_AFSStoreStatus("Status");
623 OUT_UINT(hf_afs_fs_offset);
624 OUT_UINT(hf_afs_fs_length);
625 OUT_UINT(hf_afs_fs_flength);
627 case 134: /* Store ACL */
628 OUT_FS_AFSFid("Target");
629 offset = dissect_acl(tvb, rxinfo, tree, offset);
631 case 135: /* Store Status */
632 OUT_FS_AFSFid("Target");
633 OUT_FS_AFSStoreStatus("Status");
635 case 136: /* Remove File */
636 OUT_FS_AFSFid("Remove File");
637 OUT_STRING(hf_afs_fs_name);
639 case 137: /* Create File */
640 OUT_FS_AFSFid("Target");
641 OUT_STRING(hf_afs_fs_name);
642 OUT_FS_AFSStoreStatus("Status");
644 case 138: /* Rename file */
645 OUT_FS_AFSFid("Old");
646 OUT_STRING(hf_afs_fs_oldname);
647 OUT_FS_AFSFid("New");
648 OUT_STRING(hf_afs_fs_newname);
650 case 139: /* Symlink */
651 OUT_FS_AFSFid("File");
652 OUT_STRING(hf_afs_fs_symlink_name);
653 OUT_STRING(hf_afs_fs_symlink_content);
654 OUT_FS_AFSStoreStatus("Status");
657 OUT_FS_AFSFid("Link To (New File)");
658 OUT_STRING(hf_afs_fs_name);
659 OUT_FS_AFSFid("Link From (Old File)");
661 case 141: /* Make dir */
662 OUT_FS_AFSFid("Target");
663 OUT_STRING(hf_afs_fs_name);
664 OUT_FS_AFSStoreStatus("Status");
666 case 142: /* Remove dir */
667 OUT_FS_AFSFid("Target");
668 OUT_STRING(hf_afs_fs_name);
670 case 143: /* Old Set Lock */
671 OUT_FS_AFSFid("Target");
672 OUT_UINT(hf_afs_fs_vicelocktype);
675 case 144: /* Old Extend Lock */
676 OUT_FS_AFSFid("Target");
679 case 145: /* Old Release Lock */
680 OUT_FS_AFSFid("Target");
683 case 146: /* Get statistics */
686 case 147: /* Give up callbacks */
690 case 148: /* Get vol info */
691 OUT_STRING(hf_afs_fs_volname);
693 case 149: /* Get vol stats */
694 OUT_UINT(hf_afs_fs_volid);
696 case 150: /* Set vol stats */
697 OUT_UINT(hf_afs_fs_volid);
698 OUT_FS_AFSStoreVolumeStatus();
699 OUT_STRING(hf_afs_fs_volname);
700 OUT_STRING(hf_afs_fs_offlinemsg);
701 OUT_STRING(hf_afs_fs_motd);
703 case 151: /* get root volume */
706 case 152: /* check token */
707 OUT_UINT(hf_afs_fs_viceid);
710 case 153: /* get time */
713 case 154: /* new get vol info */
714 OUT_STRING(hf_afs_fs_volname);
716 case 155: /* bulk stat */
719 case 156: /* Set Lock */
720 OUT_FS_AFSFid("Target");
721 OUT_UINT(hf_afs_fs_vicelocktype);
723 case 157: /* Extend Lock */
724 OUT_FS_AFSFid("Target");
726 case 158: /* Release Lock */
727 OUT_FS_AFSFid("Target");
729 case 159: /* xstats version */
732 case 160: /* get xstats */
733 OUT_UINT(hf_afs_fs_xstats_clientversion);
734 OUT_UINT(hf_afs_fs_xstats_collnumber);
736 case 161: /* lookup */
737 OUT_FS_AFSFid("Target");
738 OUT_STRING(hf_afs_fs_name);
740 case 162: /* flush cps */
743 OUT_UINT(hf_afs_fs_cps_spare1);
745 case 163: /* dfs symlink */
746 OUT_FS_AFSFid("Target");
747 OUT_STRING(hf_afs_fs_symlink_name);
748 OUT_STRING(hf_afs_fs_symlink_content);
749 OUT_FS_AFSStoreStatus("Symlink Status");
758 dissect_bos_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
760 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
764 case 80: /* create bnode */
767 case 81: /* delete bnode */
770 case 82: /* set status */
773 case 83: /* get status */
774 OUT_INT(hf_afs_bos_status);
775 OUT_STRING(hf_afs_bos_statusdesc);
777 case 84: /* enumerate instance */
778 OUT_STRING(hf_afs_bos_instance);
780 case 85: /* get instance info */
781 OUT_STRING(hf_afs_bos_type);
784 case 86: /* get instance parm */
785 OUT_STRING(hf_afs_bos_parm);
787 case 87: /* add siperuser */
790 case 88: /* delete superuser */
793 case 89: /* list superusers */
794 OUT_STRING(hf_afs_bos_user);
796 case 90: /* list keys */
797 OUT_UINT(hf_afs_bos_kvno);
801 case 91: /* add key */
804 case 92: /* delete key */
807 case 93: /* set cell name */
810 case 94: /* get cell name */
811 OUT_STRING(hf_afs_bos_cell);
813 case 95: /* get cell host */
814 OUT_STRING(hf_afs_bos_host);
816 case 96: /* add cell host */
819 case 97: /* delete cell host */
822 case 98: /* set tstatus */
825 case 99: /* shutdown all */
828 case 100: /* restart all */
831 case 101: /* startup all */
834 case 102: /* set noauth flag */
837 case 103: /* rebozo */
840 case 104: /* restart */
843 case 105: /* install */
846 case 106: /* uninstall */
849 case 107: /* get dates */
850 OUT_DATE(hf_afs_bos_newtime);
851 OUT_DATE(hf_afs_bos_baktime);
852 OUT_DATE(hf_afs_bos_oldtime);
857 case 109: /* prune */
860 case 110: /* set restart time */
863 case 111: /* get restart time */
866 case 112: /* get log */
867 /* need to make this dump a big string somehow */
868 OUT_BYTES_ALL(hf_afs_bos_data);
870 case 113: /* wait all */
873 case 114: /* get instance strings */
874 OUT_STRING(hf_afs_bos_error);
875 OUT_STRING(hf_afs_bos_spare1);
876 OUT_STRING(hf_afs_bos_spare2);
877 OUT_STRING(hf_afs_bos_spare3);
881 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
883 OUT_UINT(hf_afs_bos_errcode);
888 dissect_bos_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
890 offset += 4; /* skip the opcode */
894 case 80: /* create b node */
895 OUT_STRING(hf_afs_bos_type);
896 OUT_STRING(hf_afs_bos_instance);
897 OUT_STRING(hf_afs_bos_parm);
898 OUT_STRING(hf_afs_bos_parm);
899 OUT_STRING(hf_afs_bos_parm);
900 OUT_STRING(hf_afs_bos_parm);
901 OUT_STRING(hf_afs_bos_parm);
902 OUT_STRING(hf_afs_bos_parm);
904 case 81: /* delete b node */
905 OUT_STRING(hf_afs_bos_instance);
907 case 82: /* set status */
908 OUT_STRING(hf_afs_bos_instance);
909 OUT_UINT(hf_afs_bos_status);
911 case 83: /* get status */
912 OUT_STRING(hf_afs_bos_instance);
914 case 84: /* enumerate instance */
915 OUT_UINT(hf_afs_bos_num);
917 case 85: /* get instance info */
918 OUT_STRING(hf_afs_bos_instance);
920 case 86: /* get instance parm */
921 OUT_STRING(hf_afs_bos_instance);
922 OUT_UINT(hf_afs_bos_num);
924 case 87: /* add super user */
925 OUT_STRING(hf_afs_bos_user);
927 case 88: /* delete super user */
928 OUT_STRING(hf_afs_bos_user);
930 case 89: /* list super users */
931 OUT_UINT(hf_afs_bos_num);
933 case 90: /* list keys */
934 OUT_UINT(hf_afs_bos_num);
936 case 91: /* add key */
937 OUT_UINT(hf_afs_bos_num);
940 case 92: /* delete key */
941 OUT_UINT(hf_afs_bos_num);
943 case 93: /* set cell name */
944 OUT_STRING(hf_afs_bos_content);
946 case 95: /* set cell host */
947 OUT_UINT(hf_afs_bos_num);
949 case 96: /* add cell host */
950 OUT_STRING(hf_afs_bos_content);
952 case 97: /* delete cell host */
953 OUT_STRING(hf_afs_bos_content);
955 case 98: /* set t status */
956 OUT_STRING(hf_afs_bos_content);
957 OUT_UINT(hf_afs_bos_status);
959 case 99: /* shutdown all */
962 case 100: /* restart all */
965 case 101: /* startup all */
968 case 102: /* set no-auth flag */
969 OUT_UINT(hf_afs_bos_flags);
971 case 103: /* re-bozo? */
974 case 104: /* restart */
975 OUT_STRING(hf_afs_bos_instance);
977 case 105: /* install */
978 OUT_STRING(hf_afs_bos_path);
979 OUT_UINT(hf_afs_bos_size);
980 OUT_UINT(hf_afs_bos_flags);
981 OUT_UINT(hf_afs_bos_date);
983 case 106: /* uninstall */
984 OUT_STRING(hf_afs_bos_path);
986 case 107: /* get dates */
987 OUT_STRING(hf_afs_bos_path);
990 OUT_STRING(hf_afs_bos_cmd);
992 case 109: /* prune */
993 OUT_UINT(hf_afs_bos_flags);
995 case 110: /* set restart time */
996 OUT_UINT(hf_afs_bos_num);
999 case 111: /* get restart time */
1000 OUT_UINT(hf_afs_bos_num);
1002 case 112: /* get log */
1003 OUT_STRING(hf_afs_bos_file);
1005 case 113: /* wait all */
1008 case 114: /* get instance strings */
1009 OUT_STRING(hf_afs_bos_content);
1018 dissect_vol_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1020 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1025 /* should loop here maybe */
1026 OUT_UINT(hf_afs_vol_count);
1027 VECOUT(hf_afs_vol_name, 32); /* not sure on */
1031 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1033 OUT_UINT(hf_afs_vol_errcode);
1038 dissect_vol_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1040 offset += 4; /* skip the opcode */
1044 case 121: /* list one vol */
1045 OUT_UINT(hf_afs_vol_count);
1046 OUT_UINT(hf_afs_vol_id);
1055 dissect_kauth_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1057 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1063 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1065 OUT_UINT(hf_afs_kauth_errcode);
1070 dissect_kauth_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1072 offset += 4; /* skip the opcode */
1076 case 1: /* authenticate old */
1077 case 21: /* authenticate */
1078 case 22: /* authenticate v2 */
1079 case 2: /* change pw */
1080 case 5: /* set fields */
1081 case 6: /* create user */
1082 case 7: /* delete user */
1083 case 8: /* get entry */
1084 case 14: /* unlock */
1085 case 15: /* lock status */
1086 OUT_STRING(hf_afs_kauth_princ);
1087 OUT_STRING(hf_afs_kauth_realm);
1088 OUT_BYTES_ALL(hf_afs_kauth_data);
1090 case 3: /* getticket-old */
1091 case 23: /* getticket */
1092 OUT_UINT(hf_afs_kauth_kvno);
1093 OUT_STRING(hf_afs_kauth_domain);
1094 OUT_STRING(hf_afs_kauth_data);
1095 OUT_STRING(hf_afs_kauth_princ);
1096 OUT_STRING(hf_afs_kauth_realm);
1098 case 4: /* set pass */
1099 OUT_STRING(hf_afs_kauth_princ);
1100 OUT_STRING(hf_afs_kauth_realm);
1101 OUT_UINT(hf_afs_kauth_kvno);
1103 case 12: /* get pass */
1104 OUT_STRING(hf_afs_kauth_name);
1113 dissect_cb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1115 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1121 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1123 OUT_UINT(hf_afs_cb_errcode);
1128 dissect_cb_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1130 offset += 4; /* skip the opcode */
1134 case 204: /* callback */
1138 j = tvb_get_ntohl(tvb, offset);
1143 OUT_CB_AFSFid("Target");
1146 j = tvb_get_ntohl(tvb, offset);
1150 OUT_CB_AFSCallBack();
1160 dissect_prot_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1162 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1166 case 504: /* name to id */
1170 j = tvb_get_ntohl(tvb, offset);
1171 OUT_UINT(hf_afs_prot_count);
1175 OUT_UINT(hf_afs_prot_id);
1179 case 505: /* id to name */
1183 j = tvb_get_ntohl(tvb, offset);
1184 OUT_UINT(hf_afs_prot_count);
1188 VECOUT(hf_afs_prot_name, PRNAMEMAX);
1192 case 508: /* get cps */
1193 case 514: /* list elements */
1194 case 517: /* list owned */
1195 case 518: /* get cps2 */
1196 case 519: /* get host cps */
1200 j = tvb_get_ntohl(tvb, offset);
1201 OUT_UINT(hf_afs_prot_count);
1205 OUT_UINT(hf_afs_prot_id);
1209 case 510: /* list max */
1210 OUT_UINT(hf_afs_prot_maxuid);
1211 OUT_UINT(hf_afs_prot_maxgid);
1215 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1217 OUT_UINT(hf_afs_prot_errcode);
1222 dissect_prot_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1224 offset += 4; /* skip the opcode */
1228 case 500: /* new user */
1229 OUT_STRING(hf_afs_prot_name);
1230 OUT_UINT(hf_afs_prot_id);
1231 OUT_UINT(hf_afs_prot_oldid);
1233 case 501: /* where is it */
1234 case 506: /* delete */
1235 case 508: /* get cps */
1236 case 512: /* list entry */
1237 case 514: /* list elements */
1238 case 517: /* list owned */
1239 case 519: /* get host cps */
1240 OUT_UINT(hf_afs_prot_id);
1242 case 502: /* dump entry */
1243 OUT_UINT(hf_afs_prot_pos);
1245 case 503: /* add to group */
1246 case 507: /* remove from group */
1247 case 515: /* is a member of? */
1248 OUT_UINT(hf_afs_prot_uid);
1249 OUT_UINT(hf_afs_prot_gid);
1251 case 504: /* name to id */
1255 j = tvb_get_ntohl(tvb, offset);
1256 OUT_UINT(hf_afs_prot_count);
1260 VECOUT(hf_afs_prot_name,PRNAMEMAX);
1264 case 505: /* id to name */
1268 j = tvb_get_ntohl(tvb, offset);
1269 OUT_UINT(hf_afs_prot_count);
1273 OUT_UINT(hf_afs_prot_id);
1277 case 509: /* new entry */
1278 OUT_STRING(hf_afs_prot_name);
1279 OUT_UINT(hf_afs_prot_flag);
1280 OUT_UINT(hf_afs_prot_oldid);
1282 case 511: /* set max */
1283 OUT_UINT(hf_afs_prot_id);
1284 OUT_UINT(hf_afs_prot_flag);
1286 case 513: /* change entry */
1287 OUT_UINT(hf_afs_prot_id);
1288 OUT_STRING(hf_afs_prot_name);
1289 OUT_UINT(hf_afs_prot_oldid);
1290 OUT_UINT(hf_afs_prot_newid);
1292 case 520: /* update entry */
1293 OUT_UINT(hf_afs_prot_id);
1294 OUT_STRING(hf_afs_prot_name);
1303 dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1305 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1309 case 510: /* list entry */
1310 OUT_UINT(hf_afs_vldb_count);
1311 OUT_UINT(hf_afs_vldb_nextindex);
1313 case 503: /* get entry by id */
1314 case 504: /* get entry by name */
1317 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1318 nservers = tvb_get_ntohl(tvb, offset);
1319 OUT_UINT(hf_afs_vldb_numservers);
1324 OUT_IP(hf_afs_vldb_server);
1334 j = tvb_get_ntohl(tvb, offset);
1335 strcpy(part, "/vicepa");
1336 if ( i<nservers && j<=25 )
1338 part[6] = 'a' + (char) j;
1339 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1344 SKIP(8 * sizeof(guint32));
1345 OUT_UINT(hf_afs_vldb_rwvol);
1346 OUT_UINT(hf_afs_vldb_rovol);
1347 OUT_UINT(hf_afs_vldb_bkvol);
1350 case 505: /* get new volume id */
1351 OUT_UINT(hf_afs_vldb_id);
1353 case 521: /* list entry */
1354 case 529: /* list entry U */
1355 OUT_UINT(hf_afs_vldb_count);
1356 OUT_UINT(hf_afs_vldb_nextindex);
1358 case 518: /* get entry by id n */
1359 case 519: /* get entry by name N */
1362 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1363 nservers = tvb_get_ntohl(tvb, offset);
1364 OUT_UINT(hf_afs_vldb_numservers);
1365 for (i=0; i<13; i++)
1369 OUT_IP(hf_afs_vldb_server);
1376 for (i=0; i<13; i++)
1379 j = tvb_get_ntohl(tvb, offset);
1380 strcpy(part, "/vicepa");
1381 if ( i<nservers && j<=25 )
1383 part[6] = 'a' + (char) j;
1384 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1389 SKIP(13 * sizeof(guint32));
1390 OUT_UINT(hf_afs_vldb_rwvol);
1391 OUT_UINT(hf_afs_vldb_rovol);
1392 OUT_UINT(hf_afs_vldb_bkvol);
1395 case 526: /* get entry by id u */
1396 case 527: /* get entry by name u */
1399 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1400 nservers = tvb_get_ntohl(tvb, offset);
1401 OUT_UINT(hf_afs_vldb_numservers);
1402 for (i=0; i<13; i++)
1406 OUT_BYTES(hf_afs_vldb_serveruuid, 11*sizeof(guint32));
1410 SKIP(11*sizeof(guint32));
1413 for (i=0; i<13; i++)
1416 j = tvb_get_ntohl(tvb, offset);
1417 strcpy(part, "/vicepa");
1418 if ( i<nservers && j<=25 )
1420 part[6] = 'a' + (char) j;
1421 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1426 SKIP(13 * sizeof(guint32));
1427 OUT_UINT(hf_afs_vldb_rwvol);
1428 OUT_UINT(hf_afs_vldb_rovol);
1429 OUT_UINT(hf_afs_vldb_bkvol);
1434 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1436 OUT_UINT(hf_afs_vldb_errcode);
1441 dissect_vldb_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1443 offset += 4; /* skip the opcode */
1447 case 501: /* create new volume */
1448 case 517: /* create entry N */
1449 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1451 case 502: /* delete entry */
1452 case 503: /* get entry by id */
1453 case 507: /* update entry */
1454 case 508: /* set lock */
1455 case 509: /* release lock */
1456 case 518: /* get entry by id */
1457 OUT_UINT(hf_afs_vldb_id);
1458 OUT_UINT(hf_afs_vldb_type);
1460 case 504: /* get entry by name */
1461 case 519: /* get entry by name N */
1462 case 524: /* update entry by name */
1463 case 527: /* get entry by name U */
1464 OUT_STRING(hf_afs_vldb_name);
1466 case 505: /* get new vol id */
1467 OUT_UINT(hf_afs_vldb_bump);
1469 case 506: /* replace entry */
1470 case 520: /* replace entry N */
1471 OUT_UINT(hf_afs_vldb_id);
1472 OUT_UINT(hf_afs_vldb_type);
1473 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1475 case 510: /* list entry */
1476 case 521: /* list entry N */
1477 OUT_UINT(hf_afs_vldb_index);
1486 dissect_ubik_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1490 case 10000: /* vote-beacon */
1492 case 10001: /* vote-debug-old */
1493 OUT_UBIK_DebugOld();
1495 case 10002: /* vote-sdebug-old */
1496 OUT_UBIK_SDebugOld();
1498 case 10003: /* vote-get syncsite */
1500 case 10004: /* vote-debug */
1501 OUT_UBIK_DebugOld();
1502 OUT_UBIK_InterfaceAddrs();
1504 case 10005: /* vote-sdebug */
1505 OUT_UBIK_SDebugOld();
1506 OUT_UBIK_InterfaceAddrs();
1508 case 10006: /* vote-xdebug */
1509 OUT_UBIK_DebugOld();
1510 OUT_UBIK_InterfaceAddrs();
1511 OUT_UINT(hf_afs_ubik_isclone);
1513 case 10007: /* vote-xsdebug */
1514 OUT_UBIK_SDebugOld();
1515 OUT_UBIK_InterfaceAddrs();
1516 OUT_UINT(hf_afs_ubik_isclone);
1518 case 20000: /* disk-begin */
1520 case 20004: /* get version */
1521 OUT_UBIKVERSION("DB Version");
1523 case 20010: /* disk-probe */
1525 case 20012: /* disk-interfaceaddr */
1526 OUT_UBIK_InterfaceAddrs();
1532 dissect_ubik_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1534 offset += 4; /* skip the opcode */
1538 case 10000: /* vote-beacon */
1539 OUT_UINT(hf_afs_ubik_state);
1540 OUT_DATE(hf_afs_ubik_votestart);
1541 OUT_UBIKVERSION("DB Version");
1542 OUT_UBIKVERSION("TID");
1544 case 10001: /* vote-debug-old */
1546 case 10002: /* vote-sdebug-old */
1547 OUT_UINT(hf_afs_ubik_site);
1549 case 10003: /* vote-get sync site */
1550 OUT_IP(hf_afs_ubik_site);
1552 case 10004: /* vote-debug */
1553 case 10005: /* vote-sdebug */
1554 OUT_IP(hf_afs_ubik_site);
1556 case 20000: /* disk-begin */
1557 OUT_UBIKVERSION("TID");
1559 case 20001: /* disk-commit */
1560 OUT_UBIKVERSION("TID");
1562 case 20002: /* disk-lock */
1563 OUT_UBIKVERSION("TID");
1564 OUT_UINT(hf_afs_ubik_file);
1565 OUT_UINT(hf_afs_ubik_pos);
1566 OUT_UINT(hf_afs_ubik_length);
1567 OUT_UINT(hf_afs_ubik_locktype);
1569 case 20003: /* disk-write */
1570 OUT_UBIKVERSION("TID");
1571 OUT_UINT(hf_afs_ubik_file);
1572 OUT_UINT(hf_afs_ubik_pos);
1574 case 20004: /* disk-get version */
1576 case 20005: /* disk-get file */
1577 OUT_UINT(hf_afs_ubik_file);
1579 case 20006: /* disk-send file */
1580 OUT_UINT(hf_afs_ubik_file);
1581 OUT_UINT(hf_afs_ubik_length);
1582 OUT_UBIKVERSION("DB Version");
1584 case 20007: /* disk-abort */
1585 case 20008: /* disk-release locks */
1586 case 20010: /* disk-probe */
1588 case 20009: /* disk-truncate */
1589 OUT_UBIKVERSION("TID");
1590 OUT_UINT(hf_afs_ubik_file);
1591 OUT_UINT(hf_afs_ubik_length);
1593 case 20011: /* disk-writev */
1594 OUT_UBIKVERSION("TID");
1596 case 20012: /* disk-interfaceaddr */
1597 OUT_UBIK_InterfaceAddrs();
1599 case 20013: /* disk-set version */
1600 OUT_UBIKVERSION("TID");
1601 OUT_UBIKVERSION("Old DB Version");
1602 OUT_UBIKVERSION("New DB Version");
1611 dissect_backup_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1613 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1619 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1621 OUT_UINT(hf_afs_backup_errcode);
1626 dissect_backup_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1628 offset += 4; /* skip the opcode */
1636 * Registration code for registering the protocol and fields
1640 proto_register_afs(void)
1642 static hf_register_info hf[] = {
1643 #include "packet-afs-register-info.h"
1645 static gint *ett[] = {
1653 &ett_afs_status_mask,
1655 &ett_afs_volumeinfo,
1659 proto_afs = proto_register_protocol("Andrew File System (AFS)",
1661 proto_register_field_array(proto_afs, hf, array_length(hf));
1662 proto_register_subtree_array(ett, array_length(ett));
1663 register_init_routine(&afs_init_protocol);
1665 register_dissector("afs", dissect_afs, proto_afs);