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.51 2002/11/28 03:57: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.
42 #include <epan/packet.h>
43 #include <epan/conversation.h>
44 #include <epan/resolv.h>
46 #include "packet-rx.h"
47 #include "packet-afs.h"
48 #include "packet-afs-defs.h"
49 #include "packet-afs-macros.h"
51 #define GETSTR tvb_get_ptr(tvb,offset,tvb_ensure_length_remaining(tvb,offset))
53 #define VALID_OPCODE(opcode) ((opcode >= OPCODE_LOW && opcode <= OPCODE_HIGH) || \
54 (opcode >= VOTE_LOW && opcode <= VOTE_HIGH) || \
55 (opcode >= DISK_LOW && opcode <= DISK_HIGH))
57 static int afs_packet_init_count = 100;
59 struct afs_request_key {
60 guint32 conversation, callnumber;
64 struct afs_request_val {
68 static GHashTable *afs_request_hash = NULL;
69 static GMemChunk *afs_request_keys = NULL;
70 static GMemChunk *afs_request_vals = NULL;
75 * Dissector prototypes
77 static int dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo,
78 proto_tree *tree, int offset);
79 static void dissect_fs_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
80 proto_tree *tree, int offset, int opcode);
81 static void dissect_fs_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
82 proto_tree *tree, int offset, int opcode);
83 static void dissect_bos_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
84 proto_tree *tree, int offset, int opcode);
85 static void dissect_bos_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
86 proto_tree *tree, int offset, int opcode);
87 static void dissect_vol_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
88 proto_tree *tree, int offset, int opcode);
89 static void dissect_vol_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
90 proto_tree *tree, int offset, int opcode);
91 static void dissect_kauth_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
92 proto_tree *tree, int offset, int opcode);
93 static void dissect_kauth_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
94 proto_tree *tree, int offset, int opcode);
95 static void dissect_cb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
96 proto_tree *tree, int offset, int opcode);
97 static void dissect_cb_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
98 proto_tree *tree, int offset, int opcode);
99 static void dissect_prot_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
100 proto_tree *tree, int offset, int opcode);
101 static void dissect_prot_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
102 proto_tree *tree, int offset, int opcode);
103 static void dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
104 proto_tree *tree, int offset, int opcode);
105 static void dissect_vldb_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
106 proto_tree *tree, int offset, int opcode);
107 static void dissect_ubik_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
108 proto_tree *tree, int offset, int opcode);
109 static void dissect_ubik_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
110 proto_tree *tree, int offset, int opcode);
111 static void dissect_backup_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
112 proto_tree *tree, int offset, int opcode);
113 static void dissect_backup_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
114 proto_tree *tree, int offset, int opcode);
120 afs_equal(gconstpointer v, gconstpointer w)
122 const struct afs_request_key *v1 = (const struct afs_request_key *)v;
123 const struct afs_request_key *v2 = (const struct afs_request_key *)w;
125 if (v1 -> conversation == v2 -> conversation &&
126 v1 -> service == v2 -> service &&
127 v1 -> callnumber == v2 -> callnumber ) {
136 afs_hash (gconstpointer v)
138 const struct afs_request_key *key = (const struct afs_request_key *)v;
141 val = key -> conversation + key -> service + key -> callnumber;
147 * Protocol initialization
150 afs_init_protocol(void)
152 if (afs_request_hash)
153 g_hash_table_destroy(afs_request_hash);
154 if (afs_request_keys)
155 g_mem_chunk_destroy(afs_request_keys);
156 if (afs_request_vals)
157 g_mem_chunk_destroy(afs_request_vals);
159 afs_request_hash = g_hash_table_new(afs_hash, afs_equal);
160 afs_request_keys = g_mem_chunk_new("afs_request_keys",
161 sizeof(struct afs_request_key),
162 afs_packet_init_count * sizeof(struct afs_request_key),
164 afs_request_vals = g_mem_chunk_new("afs_request_vals",
165 sizeof(struct afs_request_val),
166 afs_packet_init_count * sizeof(struct afs_request_val),
173 * Dissection routines
177 dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
179 struct rxinfo *rxinfo = pinfo->private_data;
181 conversation_t *conversation;
182 struct afs_request_key request_key, *new_request_key;
183 struct afs_request_val *request_val;
184 proto_tree *afs_tree, *afs_op_tree, *ti;
185 int port, node, typenode, opcode;
186 value_string const *vals;
188 void (*dissector)(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode);
191 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
192 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AFS (RX)");
194 if (check_col(pinfo->cinfo, COL_INFO)) {
195 col_clear(pinfo->cinfo, COL_INFO);
198 reply = (rxinfo->flags & RX_CLIENT_INITIATED) == 0;
199 port = ((reply == 0) ? pinfo->destport : pinfo->srcport );
202 * Find out what conversation this packet is part of.
203 * XXX - this should really be done by the transport-layer protocol,
204 * although for connectionless transports, we may not want to do that
205 * unless we know some higher-level protocol will want it - or we
206 * may want to do it, so you can say e.g. "show only the packets in
207 * this UDP 'connection'".
209 * Note that we don't have to worry about the direction this packet
210 * was going - the conversation code handles that for us, treating
211 * packets from A:X to B:Y as being part of the same conversation as
212 * packets from B:Y to A:X.
214 conversation = find_conversation(&pinfo->src, &pinfo->dst, pinfo->ptype,
215 pinfo->srcport, pinfo->destport, 0);
216 if (conversation == NULL) {
217 /* It's not part of any conversation - create a new one. */
218 conversation = conversation_new(&pinfo->src, &pinfo->dst,
219 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
222 request_key.conversation = conversation->index;
223 request_key.service = rxinfo->serviceid;
224 request_key.callnumber = rxinfo->callnumber;
226 request_val = (struct afs_request_val *) g_hash_table_lookup(
227 afs_request_hash, &request_key);
229 /* only allocate a new hash element when it's a request */
231 if ( !request_val && !reply) {
232 new_request_key = g_mem_chunk_alloc(afs_request_keys);
233 *new_request_key = request_key;
235 request_val = g_mem_chunk_alloc(afs_request_vals);
236 request_val -> opcode = tvb_get_ntohl(tvb, offset);
238 g_hash_table_insert(afs_request_hash, new_request_key,
243 opcode = request_val->opcode;
252 typenode = hf_afs_fs;
253 node = hf_afs_fs_opcode;
255 dissector = reply ? dissect_fs_reply : dissect_fs_request;
258 typenode = hf_afs_cb;
259 node = hf_afs_cb_opcode;
261 dissector = reply ? dissect_cb_reply : dissect_cb_request;
264 typenode = hf_afs_prot;
265 node = hf_afs_prot_opcode;
267 dissector = reply ? dissect_prot_reply : dissect_prot_request;
270 typenode = hf_afs_vldb;
271 node = hf_afs_vldb_opcode;
273 dissector = reply ? dissect_vldb_reply : dissect_vldb_request;
276 typenode = hf_afs_kauth;
277 node = hf_afs_kauth_opcode;
279 dissector = reply ? dissect_kauth_reply : dissect_kauth_request;
282 typenode = hf_afs_vol;
283 node = hf_afs_vol_opcode;
285 dissector = reply ? dissect_vol_reply : dissect_vol_request;
288 typenode = hf_afs_error;
289 node = hf_afs_error_opcode;
290 /* dissector = reply ? dissect_error_reply : dissect_error_request; */
293 typenode = hf_afs_bos;
294 node = hf_afs_bos_opcode;
296 dissector = reply ? dissect_bos_reply : dissect_bos_request;
298 case AFS_PORT_UPDATE:
299 typenode = hf_afs_update;
300 node = hf_afs_update_opcode;
302 /* dissector = reply ? dissect_update_reply : dissect_update_request; */
304 case AFS_PORT_RMTSYS:
305 typenode = hf_afs_rmtsys;
306 node = hf_afs_rmtsys_opcode;
308 /* dissector = reply ? dissect_rmtsys_reply : dissect_rmtsys_request; */
310 case AFS_PORT_BACKUP:
311 typenode = hf_afs_backup;
312 node = hf_afs_backup_opcode;
314 dissector = reply ? dissect_backup_reply : dissect_backup_request;
318 if ( (opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
319 (opcode >= DISK_LOW && opcode <= DISK_HIGH) ) {
320 typenode = hf_afs_ubik;
321 node = hf_afs_ubik_opcode;
323 dissector = reply ? dissect_ubik_reply : dissect_ubik_request;
327 if ( VALID_OPCODE(opcode) ) {
329 if (check_col(pinfo->cinfo, COL_INFO))
330 col_add_fstr(pinfo->cinfo, COL_INFO, "%s%s %s: %s (%d)",
331 typenode == hf_afs_ubik ? "UBIK-" : "",
332 val_to_str(port, port_types_short, "Unknown(%d)"),
333 reply ? "Reply" : "Request",
334 val_to_str(opcode, vals, "Unknown(%d)"), opcode);
336 if (check_col(pinfo->cinfo, COL_INFO))
337 col_add_fstr(pinfo->cinfo, COL_INFO, "%s%s %s: Unknown(%d)",
338 typenode == hf_afs_ubik ? "UBIK-" : "",
339 val_to_str(port, port_types_short, "Unknown(%d)"),
340 reply ? "Reply" : "Request",
344 if (check_col(pinfo->cinfo, COL_INFO))
345 col_add_fstr(pinfo->cinfo, COL_INFO, "Encrypted %s %s",
346 val_to_str(port, port_types_short, "Unknown(%d)"),
347 reply ? "Reply" : "Request"
352 ti = proto_tree_add_item(tree, proto_afs, tvb, offset, -1,
354 afs_tree = proto_item_add_subtree(ti, ett_afs);
356 proto_tree_add_text(afs_tree, tvb,
358 "Service: %s%s%s %s",
359 VALID_OPCODE(opcode) ? "" : "Encrypted ",
360 typenode == hf_afs_ubik ? "UBIK - " : "",
361 val_to_str(port, port_types, "Unknown(%d)"),
362 reply ? "Reply" : "Request");
364 if ( VALID_OPCODE(opcode) ) {
365 /* until we do cache, can't handle replies */
367 if ( !reply && node != 0 ) {
368 if ( rxinfo->seq == 1 )
370 ti = proto_tree_add_uint(afs_tree,
371 node, tvb, offset, 4, opcode);
373 ti = proto_tree_add_uint(afs_tree,
374 node, tvb, offset, 0, opcode);
376 } else if ( reply && node != 0 ) {
377 /* the opcode isn't in this packet */
378 ti = proto_tree_add_uint(afs_tree,
379 node, tvb, offset, 0, opcode);
381 ti = proto_tree_add_text(afs_tree, tvb,
382 offset, 0, "Operation: Unknown");
385 /* Add the subtree for this particular service */
386 afs_op_tree = proto_item_add_subtree(ti, ett_afs_op);
388 if ( typenode != 0 ) {
389 /* indicate the type of request */
390 proto_tree_add_boolean_hidden(afs_tree, typenode, tvb, offset, 0, 1);
393 /* Process the packet according to what service it is */
395 (*dissector)(tvb, rxinfo, afs_op_tree, offset, opcode);
400 /* if it's the last packet, and it's a reply, remove opcode
402 /* ignoring for now, I'm not sure how the chunk deallocation works */
403 if ( rxinfo->flags & RX_LAST_PACKET && reply ){
410 * Here is a helper routine for adding an AFS acl to the proto tree
411 * This is to be used with FS packets only
413 * An AFS ACL is a string that has the following format:
415 * <positive> <negative>
419 * "positive" and "negative" are integers which contain the number of
420 * positive and negative ACL's in the string. The uid/aclbits pair are
421 * ASCII strings containing the UID/PTS record and and a ascii number
422 * representing a logical OR of all the ACL permission bits
427 * sscanf is probably quite dangerous if we run outside the packet.
429 * "GETSTR" doesn't guarantee that the resulting string is
432 * Should this just scan the string itself, rather than using "sscanf()"?
435 dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset)
439 int i, n, pos, neg, acl;
440 char user[128]; /* Be sure to adjust sscanf()s below if length is changed... */
443 bytes = tvb_get_ntohl(tvb, offset);
444 OUT_UINT(hf_afs_fs_acl_datasize);
447 if (sscanf(GETSTR, "%d %n", &pos, &n) != 1) {
448 /* does not matter what we return, if this fails,
449 * we cant dissect anything else in the packet either.
453 proto_tree_add_uint(tree, hf_afs_fs_acl_count_positive, tvb,
458 if (sscanf(GETSTR, "%d %n", &neg, &n) != 1) {
461 proto_tree_add_uint(tree, hf_afs_fs_acl_count_negative, tvb,
466 * This wacky order preserves the order used by the "fs" command
468 for (i = 0; i < pos; i++) {
469 if (sscanf(GETSTR, "%127s %d %n", user, &acl, &n) != 2) {
472 ACLOUT(user,1,acl,n);
475 for (i = 0; i < neg; i++) {
476 if (sscanf(GETSTR, "%127s %d %n", user, &acl, &n) != 2) {
479 ACLOUT(user,0,acl,n);
481 if (offset >= old_offset+bytes ) {
490 * Here are the helper dissection routines
494 dissect_fs_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
496 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
500 case 130: /* fetch data */
501 /* only on first packet */
502 if ( rxinfo->seq == 1 )
504 OUT_FS_AFSFetchStatus("Status");
505 OUT_FS_AFSCallBack();
508 OUT_BYTES_ALL(hf_afs_fs_data);
510 case 131: /* fetch acl */
511 offset = dissect_acl(tvb, rxinfo, tree, offset);
512 OUT_FS_AFSFetchStatus("Status");
515 case 132: /* Fetch status */
516 OUT_FS_AFSFetchStatus("Status");
517 OUT_FS_AFSCallBack();
520 case 133: /* Store data */
521 case 134: /* Store ACL */
522 case 135: /* Store status */
523 case 136: /* Remove file */
524 OUT_FS_AFSFetchStatus("Status");
527 case 137: /* create file */
528 case 141: /* make dir */
529 case 161: /* lookup */
530 case 163: /* dfs symlink */
531 OUT_FS_AFSFid((opcode == 137)? "New File" : ((opcode == 141)? "New Directory" : "File"));
532 OUT_FS_AFSFetchStatus("File Status");
533 OUT_FS_AFSFetchStatus("Directory Status");
534 OUT_FS_AFSCallBack();
537 case 138: /* rename */
538 OUT_FS_AFSFetchStatus("Old Directory Status");
539 OUT_FS_AFSFetchStatus("New Directory Status");
542 case 139: /* symlink */
543 OUT_FS_AFSFid("Symlink");
545 OUT_FS_AFSFetchStatus("Symlink Status");
546 case 142: /* rmdir */
547 OUT_FS_AFSFetchStatus("Directory Status");
550 case 143: /* old set lock */
551 case 144: /* old extend lock */
552 case 145: /* old release lock */
553 case 147: /* give up callbacks */
554 case 150: /* set volume status */
555 case 152: /* check token */
556 /* nothing returned */
558 case 146: /* get statistics */
559 OUT_FS_ViceStatistics();
561 case 148: /* get volume info */
562 case 154: /* n-get-volume-info */
565 case 149: /* get volume status */
566 OUT_FS_AFSFetchVolumeStatus();
567 OUT_RXString(hf_afs_fs_volname);
568 OUT_RXString(hf_afs_fs_offlinemsg);
569 OUT_RXString(hf_afs_fs_motd);
571 case 151: /* root volume */
572 OUT_RXString(hf_afs_fs_volname);
574 case 153: /* get time */
575 OUT_TIMESTAMP(hf_afs_fs_timestamp);
577 case 155: /* bulk status */
578 OUT_FS_AFSBulkStats();
583 case 156: /* set lock */
584 case 157: /* extend lock */
585 case 158: /* release lock */
588 case 159: /* x-stats-version */
589 OUT_UINT(hf_afs_fs_xstats_version);
591 case 160: /* get xstats */
592 OUT_UINT(hf_afs_fs_xstats_version);
593 OUT_DATE(hf_afs_fs_xstats_timestamp);
594 OUT_FS_AFS_CollData();
596 case 162: /* flush cps */
597 OUT_UINT(hf_afs_fs_cps_spare2);
598 OUT_UINT(hf_afs_fs_cps_spare3);
602 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
604 OUT_UINT(hf_afs_fs_errcode);
609 dissect_fs_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
611 /* skip the opcode if this is the first packet in the stream */
612 if ( rxinfo->seq == 1 )
614 offset += 4; /* skip the opcode */
619 case 130: /* Fetch data */
620 OUT_FS_AFSFid("Source");
621 OUT_UINT(hf_afs_fs_offset);
622 OUT_UINT(hf_afs_fs_length);
624 case 131: /* Fetch ACL */
625 OUT_FS_AFSFid("Target");
627 case 132: /* Fetch Status */
628 OUT_FS_AFSFid("Target");
630 case 133: /* Store Data */
631 if ( rxinfo->seq == 1 )
633 OUT_FS_AFSFid("Destination");
634 OUT_FS_AFSStoreStatus("Status");
635 OUT_UINT(hf_afs_fs_offset);
636 OUT_UINT(hf_afs_fs_length);
637 OUT_UINT(hf_afs_fs_flength);
639 OUT_BYTES_ALL(hf_afs_fs_data);
641 case 134: /* Store ACL */
642 OUT_FS_AFSFid("Target");
643 offset = dissect_acl(tvb, rxinfo, tree, offset);
645 case 135: /* Store Status */
646 OUT_FS_AFSFid("Target");
647 OUT_FS_AFSStoreStatus("Status");
649 case 136: /* Remove File */
650 OUT_FS_AFSFid("Remove File");
651 OUT_RXString(hf_afs_fs_name);
653 case 137: /* Create File */
654 OUT_FS_AFSFid("Target");
655 OUT_RXString(hf_afs_fs_name);
656 OUT_FS_AFSStoreStatus("Status");
658 case 138: /* Rename file */
659 OUT_FS_AFSFid("Old");
660 OUT_RXString(hf_afs_fs_oldname);
661 OUT_FS_AFSFid("New");
662 OUT_RXString(hf_afs_fs_newname);
664 case 139: /* Symlink */
665 OUT_FS_AFSFid("File");
666 OUT_RXString(hf_afs_fs_symlink_name);
667 OUT_RXString(hf_afs_fs_symlink_content);
668 OUT_FS_AFSStoreStatus("Status");
671 OUT_FS_AFSFid("Link To (New File)");
672 OUT_RXString(hf_afs_fs_name);
673 OUT_FS_AFSFid("Link From (Old File)");
675 case 141: /* Make dir */
676 OUT_FS_AFSFid("Target");
677 OUT_RXString(hf_afs_fs_name);
678 OUT_FS_AFSStoreStatus("Status");
680 case 142: /* Remove dir */
681 OUT_FS_AFSFid("Target");
682 OUT_RXString(hf_afs_fs_name);
684 case 143: /* Old Set Lock */
685 OUT_FS_AFSFid("Target");
686 OUT_UINT(hf_afs_fs_vicelocktype);
689 case 144: /* Old Extend Lock */
690 OUT_FS_AFSFid("Target");
693 case 145: /* Old Release Lock */
694 OUT_FS_AFSFid("Target");
697 case 146: /* Get statistics */
700 case 147: /* Give up callbacks */
704 case 148: /* Get vol info */
705 OUT_RXString(hf_afs_fs_volname);
707 case 149: /* Get vol stats */
708 OUT_UINT(hf_afs_fs_volid);
710 case 150: /* Set vol stats */
711 OUT_UINT(hf_afs_fs_volid);
712 OUT_FS_AFSStoreVolumeStatus();
713 OUT_RXString(hf_afs_fs_volname);
714 OUT_RXString(hf_afs_fs_offlinemsg);
715 OUT_RXString(hf_afs_fs_motd);
717 case 151: /* get root volume */
720 case 152: /* check token */
721 OUT_UINT(hf_afs_fs_viceid);
724 case 153: /* get time */
727 case 154: /* new get vol info */
728 OUT_RXString(hf_afs_fs_volname);
730 case 155: /* bulk stat */
733 case 156: /* Set Lock */
734 OUT_FS_AFSFid("Target");
735 OUT_UINT(hf_afs_fs_vicelocktype);
737 case 157: /* Extend Lock */
738 OUT_FS_AFSFid("Target");
740 case 158: /* Release Lock */
741 OUT_FS_AFSFid("Target");
743 case 159: /* xstats version */
746 case 160: /* get xstats */
747 OUT_UINT(hf_afs_fs_xstats_clientversion);
748 OUT_UINT(hf_afs_fs_xstats_collnumber);
750 case 161: /* lookup */
751 OUT_FS_AFSFid("Target");
752 OUT_RXString(hf_afs_fs_name);
754 case 162: /* flush cps */
757 OUT_UINT(hf_afs_fs_cps_spare1);
759 case 163: /* dfs symlink */
760 OUT_FS_AFSFid("Target");
761 OUT_RXString(hf_afs_fs_symlink_name);
762 OUT_RXString(hf_afs_fs_symlink_content);
763 OUT_FS_AFSStoreStatus("Symlink Status");
772 dissect_bos_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
774 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
778 case 80: /* create bnode */
781 case 81: /* delete bnode */
784 case 82: /* set status */
787 case 83: /* get status */
788 OUT_INT(hf_afs_bos_status);
789 OUT_RXString(hf_afs_bos_statusdesc);
791 case 84: /* enumerate instance */
792 OUT_RXString(hf_afs_bos_instance);
794 case 85: /* get instance info */
795 OUT_RXString(hf_afs_bos_type);
798 case 86: /* get instance parm */
799 OUT_RXString(hf_afs_bos_parm);
801 case 87: /* add siperuser */
804 case 88: /* delete superuser */
807 case 89: /* list superusers */
808 OUT_RXString(hf_afs_bos_user);
810 case 90: /* list keys */
811 OUT_UINT(hf_afs_bos_kvno);
815 case 91: /* add key */
818 case 92: /* delete key */
821 case 93: /* set cell name */
824 case 94: /* get cell name */
825 OUT_RXString(hf_afs_bos_cell);
827 case 95: /* get cell host */
828 OUT_RXString(hf_afs_bos_host);
830 case 96: /* add cell host */
833 case 97: /* delete cell host */
836 case 98: /* set tstatus */
839 case 99: /* shutdown all */
842 case 100: /* restart all */
845 case 101: /* startup all */
848 case 102: /* set noauth flag */
851 case 103: /* rebozo */
854 case 104: /* restart */
857 case 105: /* install */
860 case 106: /* uninstall */
863 case 107: /* get dates */
864 OUT_DATE(hf_afs_bos_newtime);
865 OUT_DATE(hf_afs_bos_baktime);
866 OUT_DATE(hf_afs_bos_oldtime);
871 case 109: /* prune */
874 case 110: /* set restart time */
877 case 111: /* get restart time */
880 case 112: /* get log */
881 /* need to make this dump a big string somehow */
882 OUT_BYTES_ALL(hf_afs_bos_data);
884 case 113: /* wait all */
887 case 114: /* get instance strings */
888 OUT_RXString(hf_afs_bos_error);
889 OUT_RXString(hf_afs_bos_spare1);
890 OUT_RXString(hf_afs_bos_spare2);
891 OUT_RXString(hf_afs_bos_spare3);
895 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
897 OUT_UINT(hf_afs_bos_errcode);
902 dissect_bos_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
904 offset += 4; /* skip the opcode */
908 case 80: /* create b node */
909 OUT_RXString(hf_afs_bos_type);
910 OUT_RXString(hf_afs_bos_instance);
911 OUT_RXString(hf_afs_bos_parm);
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);
918 case 81: /* delete b node */
919 OUT_RXString(hf_afs_bos_instance);
921 case 82: /* set status */
922 OUT_RXString(hf_afs_bos_instance);
923 OUT_UINT(hf_afs_bos_status);
925 case 83: /* get status */
926 OUT_RXString(hf_afs_bos_instance);
928 case 84: /* enumerate instance */
929 OUT_UINT(hf_afs_bos_num);
931 case 85: /* get instance info */
932 OUT_RXString(hf_afs_bos_instance);
934 case 86: /* get instance parm */
935 OUT_RXString(hf_afs_bos_instance);
936 OUT_UINT(hf_afs_bos_num);
938 case 87: /* add super user */
939 OUT_RXString(hf_afs_bos_user);
941 case 88: /* delete super user */
942 OUT_RXString(hf_afs_bos_user);
944 case 89: /* list super users */
945 OUT_UINT(hf_afs_bos_num);
947 case 90: /* list keys */
948 OUT_UINT(hf_afs_bos_num);
950 case 91: /* add key */
951 OUT_UINT(hf_afs_bos_num);
954 case 92: /* delete key */
955 OUT_UINT(hf_afs_bos_num);
957 case 93: /* set cell name */
958 OUT_RXString(hf_afs_bos_content);
960 case 95: /* set cell host */
961 OUT_UINT(hf_afs_bos_num);
963 case 96: /* add cell host */
964 OUT_RXString(hf_afs_bos_content);
966 case 97: /* delete cell host */
967 OUT_RXString(hf_afs_bos_content);
969 case 98: /* set t status */
970 OUT_RXString(hf_afs_bos_content);
971 OUT_UINT(hf_afs_bos_status);
973 case 99: /* shutdown all */
976 case 100: /* restart all */
979 case 101: /* startup all */
982 case 102: /* set no-auth flag */
983 OUT_UINT(hf_afs_bos_flags);
985 case 103: /* re-bozo? */
988 case 104: /* restart */
989 OUT_RXString(hf_afs_bos_instance);
991 case 105: /* install */
992 OUT_RXString(hf_afs_bos_path);
993 OUT_UINT(hf_afs_bos_size);
994 OUT_UINT(hf_afs_bos_flags);
995 OUT_UINT(hf_afs_bos_date);
997 case 106: /* uninstall */
998 OUT_RXString(hf_afs_bos_path);
1000 case 107: /* get dates */
1001 OUT_RXString(hf_afs_bos_path);
1003 case 108: /* exec */
1004 OUT_RXString(hf_afs_bos_cmd);
1006 case 109: /* prune */
1007 OUT_UINT(hf_afs_bos_flags);
1009 case 110: /* set restart time */
1010 OUT_UINT(hf_afs_bos_num);
1013 case 111: /* get restart time */
1014 OUT_UINT(hf_afs_bos_num);
1016 case 112: /* get log */
1017 OUT_RXString(hf_afs_bos_file);
1019 case 113: /* wait all */
1022 case 114: /* get instance strings */
1023 OUT_RXString(hf_afs_bos_content);
1032 dissect_vol_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1034 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1039 /* should loop here maybe */
1040 OUT_UINT(hf_afs_vol_count);
1041 OUT_RXStringV(hf_afs_vol_name, 32); /* not sure on */
1045 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1047 OUT_UINT(hf_afs_vol_errcode);
1052 dissect_vol_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1054 offset += 4; /* skip the opcode */
1058 case 121: /* list one vol */
1059 OUT_UINT(hf_afs_vol_count);
1060 OUT_UINT(hf_afs_vol_id);
1069 dissect_kauth_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1071 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1077 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1079 OUT_UINT(hf_afs_kauth_errcode);
1084 dissect_kauth_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1086 offset += 4; /* skip the opcode */
1090 case 1: /* authenticate old */
1091 case 21: /* authenticate */
1092 case 22: /* authenticate v2 */
1093 case 2: /* change pw */
1094 case 5: /* set fields */
1095 case 6: /* create user */
1096 case 7: /* delete user */
1097 case 8: /* get entry */
1098 case 14: /* unlock */
1099 case 15: /* lock status */
1100 OUT_RXString(hf_afs_kauth_princ);
1101 OUT_RXString(hf_afs_kauth_realm);
1102 OUT_BYTES_ALL(hf_afs_kauth_data);
1104 case 3: /* getticket-old */
1105 case 23: /* getticket */
1106 OUT_KAUTH_GetTicket();
1108 case 4: /* set pass */
1109 OUT_RXString(hf_afs_kauth_princ);
1110 OUT_RXString(hf_afs_kauth_realm);
1111 OUT_UINT(hf_afs_kauth_kvno);
1113 case 12: /* get pass */
1114 OUT_RXString(hf_afs_kauth_name);
1123 dissect_cb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1125 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1131 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1133 OUT_UINT(hf_afs_cb_errcode);
1138 dissect_cb_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1140 offset += 4; /* skip the opcode */
1144 case 204: /* callback */
1148 j = tvb_get_ntohl(tvb, offset);
1153 OUT_CB_AFSFid("Target");
1156 j = tvb_get_ntohl(tvb, offset);
1160 OUT_CB_AFSCallBack();
1170 dissect_prot_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1172 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1176 case 504: /* name to id */
1180 j = tvb_get_ntohl(tvb, offset);
1181 OUT_UINT(hf_afs_prot_count);
1185 OUT_UINT(hf_afs_prot_id);
1189 case 505: /* id to name */
1193 j = tvb_get_ntohl(tvb, offset);
1194 OUT_UINT(hf_afs_prot_count);
1198 OUT_RXStringV(hf_afs_prot_name, PRNAMEMAX);
1202 case 508: /* get cps */
1203 case 514: /* list elements */
1204 case 517: /* list owned */
1205 case 518: /* get cps2 */
1206 case 519: /* get host cps */
1210 j = tvb_get_ntohl(tvb, offset);
1211 OUT_UINT(hf_afs_prot_count);
1215 OUT_UINT(hf_afs_prot_id);
1219 case 510: /* list max */
1220 OUT_UINT(hf_afs_prot_maxuid);
1221 OUT_UINT(hf_afs_prot_maxgid);
1225 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1227 OUT_UINT(hf_afs_prot_errcode);
1232 dissect_prot_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1234 offset += 4; /* skip the opcode */
1238 case 500: /* new user */
1239 OUT_RXString(hf_afs_prot_name);
1240 OUT_UINT(hf_afs_prot_id);
1241 OUT_UINT(hf_afs_prot_oldid);
1243 case 501: /* where is it */
1244 case 506: /* delete */
1245 case 508: /* get cps */
1246 case 512: /* list entry */
1247 case 514: /* list elements */
1248 case 517: /* list owned */
1249 case 519: /* get host cps */
1250 OUT_UINT(hf_afs_prot_id);
1252 case 502: /* dump entry */
1253 OUT_UINT(hf_afs_prot_pos);
1255 case 503: /* add to group */
1256 case 507: /* remove from group */
1257 case 515: /* is a member of? */
1258 OUT_UINT(hf_afs_prot_uid);
1259 OUT_UINT(hf_afs_prot_gid);
1261 case 504: /* name to id */
1265 j = tvb_get_ntohl(tvb, offset);
1266 OUT_UINT(hf_afs_prot_count);
1270 OUT_RXStringV(hf_afs_prot_name,PRNAMEMAX);
1274 case 505: /* id to name */
1278 j = tvb_get_ntohl(tvb, offset);
1279 OUT_UINT(hf_afs_prot_count);
1283 OUT_UINT(hf_afs_prot_id);
1287 case 509: /* new entry */
1288 OUT_RXString(hf_afs_prot_name);
1289 OUT_UINT(hf_afs_prot_flag);
1290 OUT_UINT(hf_afs_prot_oldid);
1292 case 511: /* set max */
1293 OUT_UINT(hf_afs_prot_id);
1294 OUT_UINT(hf_afs_prot_flag);
1296 case 513: /* change entry */
1297 OUT_UINT(hf_afs_prot_id);
1298 OUT_RXString(hf_afs_prot_name);
1299 OUT_UINT(hf_afs_prot_oldid);
1300 OUT_UINT(hf_afs_prot_newid);
1302 case 520: /* update entry */
1303 OUT_UINT(hf_afs_prot_id);
1304 OUT_RXString(hf_afs_prot_name);
1313 dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1315 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1319 case 510: /* list entry */
1320 OUT_UINT(hf_afs_vldb_count);
1321 OUT_UINT(hf_afs_vldb_nextindex);
1323 case 503: /* get entry by id */
1324 case 504: /* get entry by name */
1327 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1329 nservers = tvb_get_ntohl(tvb, offset);
1330 OUT_UINT(hf_afs_vldb_numservers);
1335 OUT_IP(hf_afs_vldb_server);
1345 j = tvb_get_ntohl(tvb, offset);
1346 strcpy(part, "/vicepa");
1347 if ( i<nservers && j<=25 )
1349 part[6] = 'a' + (char) j;
1350 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1355 SKIP(8 * sizeof(guint32));
1356 OUT_UINT(hf_afs_vldb_rwvol);
1357 OUT_UINT(hf_afs_vldb_rovol);
1358 OUT_UINT(hf_afs_vldb_bkvol);
1359 OUT_UINT(hf_afs_vldb_clonevol);
1363 case 505: /* get new volume id */
1364 OUT_UINT(hf_afs_vldb_id);
1366 case 521: /* list entry */
1367 case 529: /* list entry U */
1368 OUT_UINT(hf_afs_vldb_count);
1369 OUT_UINT(hf_afs_vldb_nextindex);
1371 case 518: /* get entry by id n */
1372 case 519: /* get entry by name N */
1375 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1376 nservers = tvb_get_ntohl(tvb, offset);
1377 OUT_UINT(hf_afs_vldb_numservers);
1378 for (i=0; i<13; i++)
1382 OUT_IP(hf_afs_vldb_server);
1389 for (i=0; i<13; i++)
1392 j = tvb_get_ntohl(tvb, offset);
1393 strcpy(part, "/vicepa");
1394 if ( i<nservers && j<=25 )
1396 part[6] = 'a' + (char) j;
1397 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1402 SKIP(13 * sizeof(guint32));
1403 OUT_UINT(hf_afs_vldb_rwvol);
1404 OUT_UINT(hf_afs_vldb_rovol);
1405 OUT_UINT(hf_afs_vldb_bkvol);
1408 case 526: /* get entry by id u */
1409 case 527: /* get entry by name u */
1412 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1413 nservers = tvb_get_ntohl(tvb, offset);
1414 OUT_UINT(hf_afs_vldb_numservers);
1415 for (i=0; i<13; i++)
1419 OUT_UUID(hf_afs_vldb_serveruuid);
1426 for (i=0; i<13; i++)
1430 OUT_UINT(hf_afs_vldb_serveruniq);
1434 SKIP(sizeof(guint32));
1437 for (i=0; i<13; i++)
1440 j = tvb_get_ntohl(tvb, offset);
1441 strcpy(part, "/vicepa");
1442 if ( i<nservers && j<=25 )
1444 part[6] = 'a' + (char) j;
1445 proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1450 for (i=0; i<13; i++)
1454 OUT_UINT(hf_afs_vldb_serverflags);
1458 SKIP(sizeof(guint32));
1461 OUT_UINT(hf_afs_vldb_rwvol);
1462 OUT_UINT(hf_afs_vldb_rovol);
1463 OUT_UINT(hf_afs_vldb_bkvol);
1464 OUT_UINT(hf_afs_vldb_clonevol);
1465 OUT_UINT(hf_afs_vldb_flags);
1466 OUT_UINT(hf_afs_vldb_spare1);
1467 OUT_UINT(hf_afs_vldb_spare2);
1468 OUT_UINT(hf_afs_vldb_spare3);
1469 OUT_UINT(hf_afs_vldb_spare4);
1470 OUT_UINT(hf_afs_vldb_spare5);
1471 OUT_UINT(hf_afs_vldb_spare6);
1472 OUT_UINT(hf_afs_vldb_spare7);
1473 OUT_UINT(hf_afs_vldb_spare8);
1474 OUT_UINT(hf_afs_vldb_spare9);
1479 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1481 OUT_UINT(hf_afs_vldb_errcode);
1486 dissect_vldb_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1488 offset += 4; /* skip the opcode */
1492 case 501: /* create new volume */
1493 case 517: /* create entry N */
1494 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1496 case 502: /* delete entry */
1497 case 503: /* get entry by id */
1498 case 507: /* update entry */
1499 case 508: /* set lock */
1500 case 509: /* release lock */
1501 case 518: /* get entry by id */
1502 OUT_UINT(hf_afs_vldb_id);
1503 OUT_UINT(hf_afs_vldb_type);
1505 case 504: /* get entry by name */
1506 case 519: /* get entry by name N */
1507 case 524: /* update entry by name */
1508 case 527: /* get entry by name U */
1509 OUT_RXString(hf_afs_vldb_name);
1511 case 505: /* get new vol id */
1512 OUT_UINT(hf_afs_vldb_bump);
1514 case 506: /* replace entry */
1515 case 520: /* replace entry N */
1516 OUT_UINT(hf_afs_vldb_id);
1517 OUT_UINT(hf_afs_vldb_type);
1518 OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1520 case 510: /* list entry */
1521 case 521: /* list entry N */
1522 OUT_UINT(hf_afs_vldb_index);
1524 case 532: /* regaddr */
1525 OUT_UUID(hf_afs_vldb_serveruuid);
1526 OUT_UINT(hf_afs_vldb_spare1);
1527 OUT_VLDB_BulkAddr();
1536 dissect_ubik_reply(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1540 case 10000: /* vote-beacon */
1542 case 10001: /* vote-debug-old */
1543 OUT_UBIK_DebugOld();
1545 case 10002: /* vote-sdebug-old */
1546 OUT_UBIK_SDebugOld();
1548 case 10003: /* vote-get syncsite */
1550 case 10004: /* vote-debug */
1551 OUT_UBIK_DebugOld();
1552 OUT_UBIK_InterfaceAddrs();
1554 case 10005: /* vote-sdebug */
1555 OUT_UBIK_SDebugOld();
1556 OUT_UBIK_InterfaceAddrs();
1558 case 10006: /* vote-xdebug */
1559 OUT_UBIK_DebugOld();
1560 OUT_UBIK_InterfaceAddrs();
1561 OUT_UINT(hf_afs_ubik_isclone);
1563 case 10007: /* vote-xsdebug */
1564 OUT_UBIK_SDebugOld();
1565 OUT_UBIK_InterfaceAddrs();
1566 OUT_UINT(hf_afs_ubik_isclone);
1568 case 20000: /* disk-begin */
1570 case 20004: /* get version */
1571 OUT_UBIKVERSION("DB Version");
1573 case 20010: /* disk-probe */
1575 case 20012: /* disk-interfaceaddr */
1576 OUT_UBIK_InterfaceAddrs();
1582 dissect_ubik_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1584 offset += 4; /* skip the opcode */
1588 case 10000: /* vote-beacon */
1589 OUT_UINT(hf_afs_ubik_state);
1590 OUT_DATE(hf_afs_ubik_votestart);
1591 OUT_UBIKVERSION("DB Version");
1592 OUT_UBIKVERSION("TID");
1594 case 10001: /* vote-debug-old */
1596 case 10002: /* vote-sdebug-old */
1597 OUT_UINT(hf_afs_ubik_site);
1599 case 10003: /* vote-get sync site */
1600 OUT_IP(hf_afs_ubik_site);
1602 case 10004: /* vote-debug */
1603 case 10005: /* vote-sdebug */
1604 OUT_IP(hf_afs_ubik_site);
1606 case 20000: /* disk-begin */
1607 OUT_UBIKVERSION("TID");
1609 case 20001: /* disk-commit */
1610 OUT_UBIKVERSION("TID");
1612 case 20002: /* disk-lock */
1613 OUT_UBIKVERSION("TID");
1614 OUT_UINT(hf_afs_ubik_file);
1615 OUT_UINT(hf_afs_ubik_pos);
1616 OUT_UINT(hf_afs_ubik_length);
1617 OUT_UINT(hf_afs_ubik_locktype);
1619 case 20003: /* disk-write */
1620 OUT_UBIKVERSION("TID");
1621 OUT_UINT(hf_afs_ubik_file);
1622 OUT_UINT(hf_afs_ubik_pos);
1624 case 20004: /* disk-get version */
1626 case 20005: /* disk-get file */
1627 OUT_UINT(hf_afs_ubik_file);
1629 case 20006: /* disk-send file */
1630 OUT_UINT(hf_afs_ubik_file);
1631 OUT_UINT(hf_afs_ubik_length);
1632 OUT_UBIKVERSION("DB Version");
1634 case 20007: /* disk-abort */
1635 case 20008: /* disk-release locks */
1636 case 20010: /* disk-probe */
1638 case 20009: /* disk-truncate */
1639 OUT_UBIKVERSION("TID");
1640 OUT_UINT(hf_afs_ubik_file);
1641 OUT_UINT(hf_afs_ubik_length);
1643 case 20011: /* disk-writev */
1644 OUT_UBIKVERSION("TID");
1646 case 20012: /* disk-interfaceaddr */
1647 OUT_UBIK_InterfaceAddrs();
1649 case 20013: /* disk-set version */
1650 OUT_UBIKVERSION("TID");
1651 OUT_UBIKVERSION("Old DB Version");
1652 OUT_UBIKVERSION("New DB Version");
1661 dissect_backup_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1663 if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1669 else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1671 OUT_UINT(hf_afs_backup_errcode);
1676 dissect_backup_request(tvbuff_t *tvb _U_, struct rxinfo *rxinfo _U_, proto_tree *tree _U_, int offset, int opcode)
1678 offset += 4; /* skip the opcode */
1686 * Registration code for registering the protocol and fields
1690 proto_register_afs(void)
1692 static hf_register_info hf[] = {
1693 #include "packet-afs-register-info.h"
1695 static gint *ett[] = {
1703 &ett_afs_status_mask,
1705 &ett_afs_volumeinfo,
1707 &ett_afs_vldb_flags,
1710 proto_afs = proto_register_protocol("Andrew File System (AFS)",
1712 proto_register_field_array(proto_afs, hf, array_length(hf));
1713 proto_register_subtree_array(ett, array_length(ett));
1714 register_init_routine(&afs_init_protocol);
1716 register_dissector("afs", dissect_afs, proto_afs);