Call the AFS dissector through a handle.
[obnox/wireshark/wip.git] / packet-afs.c
1 /* packet-afs.c
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. 
10  *
11  * $Id: packet-afs.c,v 1.31 2001/05/27 05:00:17 guy Exp $
12  *
13  * Ethereal - Network traffic analyzer
14  * By Gerald Combs <gerald@ethereal.com>
15  * Copyright 1998 Gerald Combs
16  *
17  * Copied from packet-tftp.c
18  *
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.
23  *
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.
28  *
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.
32  */
33
34 #ifdef HAVE_CONFIG_H
35 # include "config.h"
36 #endif
37
38 #include <stdio.h>
39
40 #ifdef HAVE_SYS_TYPES_H
41 # include <sys/types.h>
42 #endif
43
44 #ifdef HAVE_NETINET_IN_H
45 # include <netinet/in.h>
46 #endif
47
48 #include <string.h>
49 #include <glib.h>
50 #include "packet.h"
51 #include "conversation.h"
52 #include "resolv.h"
53
54 #include "packet-rx.h"
55 #include "packet-afs.h"
56 #include "packet-afs-defs.h"
57 #include "packet-afs-macros.h"
58
59 #define GETSTR tvb_get_ptr(tvb,offset,tvb_length_remaining(tvb,offset))
60
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))
64
65 int afs_packet_init_count = 100;
66
67 struct afs_request_key {
68   guint32 conversation, callnumber;
69   guint16 service;
70 };
71
72 struct afs_request_val {
73   guint32 opcode;
74 };
75
76 GHashTable *afs_request_hash = NULL;
77 GMemChunk *afs_request_keys = NULL;
78 GMemChunk *afs_request_vals = NULL;
79
80
81
82 /*
83  * Dissector prototypes
84  */
85 static int dissect_acl(tvbuff_t *tvb, packet_info *pinfo, 
86         proto_tree *tree, int offset);
87 static void dissect_fs_reply(tvbuff_t *tvb, packet_info *pinfo, 
88         proto_tree *tree, int offset, int opcode);
89 static void dissect_fs_request(tvbuff_t *tvb, packet_info *pinfo, 
90         proto_tree *tree, int offset, int opcode);
91 static void dissect_bos_reply(tvbuff_t *tvb, packet_info *pinfo, 
92         proto_tree *tree, int offset, int opcode);
93 static void dissect_bos_request(tvbuff_t *tvb, packet_info *pinfo, 
94         proto_tree *tree, int offset, int opcode);
95 static void dissect_vol_reply(tvbuff_t *tvb, packet_info *pinfo, 
96         proto_tree *tree, int offset, int opcode);
97 static void dissect_vol_request(tvbuff_t *tvb, packet_info *pinfo, 
98         proto_tree *tree, int offset, int opcode);
99 static void dissect_kauth_reply(tvbuff_t *tvb, packet_info *pinfo, 
100         proto_tree *tree, int offset, int opcode);
101 static void dissect_kauth_request(tvbuff_t *tvb, packet_info *pinfo, 
102         proto_tree *tree, int offset, int opcode);
103 static void dissect_cb_reply(tvbuff_t *tvb, packet_info *pinfo, 
104         proto_tree *tree, int offset, int opcode);
105 static void dissect_cb_request(tvbuff_t *tvb, packet_info *pinfo, 
106         proto_tree *tree, int offset, int opcode);
107 static void dissect_prot_reply(tvbuff_t *tvb, packet_info *pinfo, 
108         proto_tree *tree, int offset, int opcode);
109 static void dissect_prot_request(tvbuff_t *tvb, packet_info *pinfo, 
110         proto_tree *tree, int offset, int opcode);
111 static void dissect_vldb_reply(tvbuff_t *tvb, packet_info *pinfo, 
112         proto_tree *tree, int offset, int opcode);
113 static void dissect_vldb_request(tvbuff_t *tvb, packet_info *pinfo, 
114         proto_tree *tree, int offset, int opcode);
115 static void dissect_ubik_reply(tvbuff_t *tvb, packet_info *pinfo, 
116         proto_tree *tree, int offset, int opcode);
117 static void dissect_ubik_request(tvbuff_t *tvb, packet_info *pinfo, 
118         proto_tree *tree, int offset, int opcode);
119 static void dissect_backup_reply(tvbuff_t *tvb, packet_info *pinfo, 
120         proto_tree *tree, int offset, int opcode);
121 static void dissect_backup_request(tvbuff_t *tvb, packet_info *pinfo, 
122         proto_tree *tree, int offset, int opcode);
123
124 /*
125  * Hash Functions
126  */
127 static gint
128 afs_equal(gconstpointer v, gconstpointer w)
129 {
130   struct afs_request_key *v1 = (struct afs_request_key *)v;
131   struct afs_request_key *v2 = (struct afs_request_key *)w;
132
133   if (v1 -> conversation == v2 -> conversation &&
134       v1 -> service == v2 -> service &&
135       v1 -> callnumber == v2 -> callnumber ) {
136
137     return 1;
138   }
139
140   return 0;
141 }
142
143 static guint
144 afs_hash (gconstpointer v)
145 {
146         struct afs_request_key *key = (struct afs_request_key *)v;
147         guint val;
148
149         val = key -> conversation + key -> service + key -> callnumber;
150
151         return val;
152 }
153
154 /*
155  * Protocol initialization
156  */
157 static void
158 afs_init_protocol(void)
159 {
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);
166
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),
171                 G_ALLOC_AND_FREE);
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),
175                 G_ALLOC_AND_FREE);
176 }
177
178
179
180 /*
181  * Dissection routines
182  */
183
184 static void
185 dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
186 {
187         int reply = 0;
188         conversation_t *conversation;
189         struct afs_request_key request_key, *new_request_key;
190         struct afs_request_val *request_val;
191         proto_tree      *afs_tree, *afs_op_tree, *ti;
192         int port, node, typenode, opcode;
193         value_string const *vals;
194         int offset = 0;
195         void (*dissector)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode);
196
197
198         if (check_col(pinfo->fd, COL_PROTOCOL)) {
199                 col_set_str(pinfo->fd, COL_PROTOCOL, "AFS (RX)");
200         }
201         if (check_col(pinfo->fd, COL_INFO)) {
202                 col_clear(pinfo->fd, COL_INFO);
203         }
204
205         reply = (pinfo->ps.rx.flags & RX_CLIENT_INITIATED) == 0;
206         port = ((reply == 0) ? pinfo->destport : pinfo->srcport );
207
208         /*
209          * Find out what conversation this packet is part of.
210          * XXX - this should really be done by the transport-layer protocol,
211          * although for connectionless transports, we may not want to do that
212          * unless we know some higher-level protocol will want it - or we
213          * may want to do it, so you can say e.g. "show only the packets in
214          * this UDP 'connection'".
215          *
216          * Note that we don't have to worry about the direction this packet
217          * was going - the conversation code handles that for us, treating
218          * packets from A:X to B:Y as being part of the same conversation as
219          * packets from B:Y to A:X.
220          */
221         conversation = find_conversation(&pinfo->src, &pinfo->dst, pinfo->ptype,
222             pinfo->srcport, pinfo->destport, 0);
223         if (conversation == NULL) {
224                 /* It's not part of any conversation - create a new one. */
225                 conversation = conversation_new(&pinfo->src, &pinfo->dst, 
226                         pinfo->ptype, pinfo->srcport, pinfo->destport, NULL, 0);
227         }
228
229         request_key.conversation = conversation->index; 
230         request_key.service = pinfo->ps.rx.serviceid;
231         request_key.callnumber = pinfo->ps.rx.callnumber;
232
233         request_val = (struct afs_request_val *) g_hash_table_lookup(
234                 afs_request_hash, &request_key);
235
236         /* only allocate a new hash element when it's a request */
237         opcode = 0;
238         if ( !request_val && !reply) {
239                 new_request_key = g_mem_chunk_alloc(afs_request_keys);
240                 *new_request_key = request_key;
241
242                 request_val = g_mem_chunk_alloc(afs_request_vals);
243                 request_val -> opcode = tvb_get_ntohl(tvb, offset);
244
245                 g_hash_table_insert(afs_request_hash, new_request_key,
246                         request_val);
247         }
248
249         if ( request_val ) {
250                 opcode = request_val->opcode;
251         }
252
253         node = 0;
254         typenode = 0;
255         vals = NULL;
256         dissector = NULL;
257         switch (port) {
258                 case AFS_PORT_FS:
259                         typenode = hf_afs_fs;
260                         node = hf_afs_fs_opcode;
261                         vals = fs_req;
262                         dissector = reply ? dissect_fs_reply : dissect_fs_request;
263                         break;
264                 case AFS_PORT_CB:
265                         typenode = hf_afs_cb;
266                         node = hf_afs_cb_opcode;
267                         vals = cb_req;
268                         dissector = reply ? dissect_cb_reply : dissect_cb_request;
269                         break;
270                 case AFS_PORT_PROT:
271                         typenode = hf_afs_prot;
272                         node = hf_afs_prot_opcode;
273                         vals = prot_req;
274                         dissector = reply ? dissect_prot_reply : dissect_prot_request;
275                         break;
276                 case AFS_PORT_VLDB:
277                         typenode = hf_afs_vldb;
278                         node = hf_afs_vldb_opcode;
279                         vals = vldb_req;
280                         dissector = reply ? dissect_vldb_reply : dissect_vldb_request;
281                         break;
282                 case AFS_PORT_KAUTH:
283                         typenode = hf_afs_kauth;
284                         node = hf_afs_kauth_opcode;
285                         vals = kauth_req;
286                         dissector = reply ? dissect_kauth_reply : dissect_kauth_request;
287                         break;
288                 case AFS_PORT_VOL:
289                         typenode = hf_afs_vol;
290                         node = hf_afs_vol_opcode;
291                         vals = vol_req;
292                         dissector = reply ? dissect_vol_reply : dissect_vol_request;
293                         break;
294                 case AFS_PORT_ERROR:
295                         typenode = hf_afs_error;
296                         node = hf_afs_error_opcode;
297                         /* dissector = reply ? dissect_error_reply : dissect_error_request; */
298                         break;
299                 case AFS_PORT_BOS:
300                         typenode = hf_afs_bos;
301                         node = hf_afs_bos_opcode;
302                         vals = bos_req;
303                         dissector = reply ? dissect_bos_reply : dissect_bos_request;
304                         break;
305                 case AFS_PORT_UPDATE:
306                         typenode = hf_afs_update;
307                         node = hf_afs_update_opcode;
308                         vals = update_req;
309                         /* dissector = reply ? dissect_update_reply : dissect_update_request; */
310                         break;
311                 case AFS_PORT_RMTSYS:
312                         typenode = hf_afs_rmtsys;
313                         node = hf_afs_rmtsys_opcode;
314                         vals = rmtsys_req;
315                         /* dissector = reply ? dissect_rmtsys_reply : dissect_rmtsys_request; */
316                         break;
317                 case AFS_PORT_BACKUP:
318                         typenode = hf_afs_backup;
319                         node = hf_afs_backup_opcode;
320                         vals = backup_req;
321                         dissector = reply ? dissect_backup_reply : dissect_backup_request;
322                         break;
323         }
324
325         if ( (opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
326                 (opcode >= DISK_LOW && opcode <= DISK_HIGH) ) {
327                 typenode = hf_afs_ubik;
328                 node = hf_afs_ubik_opcode;
329                 vals = ubik_req;
330                 dissector = reply ? dissect_ubik_reply : dissect_ubik_request;
331         }
332
333
334         if ( VALID_OPCODE(opcode) ) {
335                 if ( vals ) {
336                         if (check_col(pinfo->fd, COL_INFO))
337                                 col_add_fstr(pinfo->fd, COL_INFO, "%s%s %s: %s (%d)",
338                                 typenode == hf_afs_ubik ? "UBIK-" : "",
339                                 val_to_str(port, port_types_short, "Unknown(%d)"),
340                                 reply ? "Reply" : "Request",
341                                 val_to_str(opcode, vals, "Unknown(%d)"), opcode);
342                 } else {
343                         if (check_col(pinfo->fd, COL_INFO))
344                                 col_add_fstr(pinfo->fd, COL_INFO, "%s%s %s: Unknown(%d)",
345                                 typenode == hf_afs_ubik ? "UBIK-" : "",
346                                 val_to_str(port, port_types_short, "Unknown(%d)"),
347                                 reply ? "Reply" : "Request",
348                                 opcode);
349                 }
350         } else {
351                 if (check_col(pinfo->fd, COL_INFO))
352                         col_add_fstr(pinfo->fd, COL_INFO, "Encrypted %s %s",
353                         val_to_str(port, port_types_short, "Unknown(%d)"),
354                         reply ? "Reply" : "Request"
355                         );
356         }
357
358         if (tree) {
359                 ti = proto_tree_add_item(tree, proto_afs, tvb, offset, 
360                                 tvb_length_remaining(tvb, offset), FALSE);
361                 afs_tree = proto_item_add_subtree(ti, ett_afs);
362
363                 proto_tree_add_text(afs_tree, tvb,
364                         offset, tvb_length_remaining(tvb, offset),
365                         "Service: %s%s%s %s",
366                         VALID_OPCODE(opcode) ? "" : "Encrypted ",
367                         typenode == hf_afs_ubik ? "UBIK - " : "",
368                         val_to_str(port, port_types, "Unknown(%d)"),
369                         reply ? "Reply" : "Request");
370
371                 if ( VALID_OPCODE(opcode) ) {
372                         /* until we do cache, can't handle replies */
373                         ti = NULL;
374                         if ( !reply && node != 0 ) {
375                                 ti = proto_tree_add_uint(afs_tree,
376                                         node, tvb, offset, 4, opcode);
377                         } else if ( reply && node != 0 ) {
378                                 /* the opcode isn't in this packet */
379                                 ti = proto_tree_add_uint(afs_tree,
380                                         node, tvb, offset, 0, opcode);
381                         } else {
382                                 ti = proto_tree_add_text(afs_tree, tvb,
383                                         offset, 0, "Operation: Unknown");
384                         }
385         
386                         /* Add the subtree for this particular service */
387                         afs_op_tree = proto_item_add_subtree(ti, ett_afs_op);
388         
389                         if ( typenode != 0 ) {
390                                 /* indicate the type of request */
391                                 proto_tree_add_boolean_hidden(afs_tree, typenode, tvb, offset, 0, 1);
392                         }
393         
394                         /* Process the packet according to what service it is */
395                         if ( dissector ) {
396                                 (*dissector)(tvb, pinfo, afs_op_tree, offset, opcode);
397                         }
398                 }
399         }
400
401         /* if it's the last packet, and it's a reply, remove opcode
402                 from hash */
403         /* ignoring for now, I'm not sure how the chunk deallocation works */
404         if ( pinfo->ps.rx.flags & RX_LAST_PACKET && reply ){
405
406         }
407 }
408
409
410 /*
411  * Here is a helper routine for adding an AFS acl to the proto tree
412  * This is to be used with FS packets only
413  *
414  * An AFS ACL is a string that has the following format:
415  *
416  * <positive> <negative>
417  * <uid1> <aclbits1>
418  * ....
419  *
420  * "positive" and "negative" are integers which contain the number of
421  * positive and negative ACL's in the string.  The uid/aclbits pair are
422  * ASCII strings containing the UID/PTS record and and a ascii number
423  * representing a logical OR of all the ACL permission bits
424  */
425 /* FIXME: sscanf is probably quite dangerous if we run outside the packet. */
426 static int 
427 dissect_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
428 {
429         int old_offset;
430         guint32 bytes;
431         int i, n, pos, neg, acl;
432         char user[128]; /* Be sure to adjust sscanf()s below if length is changed... */
433
434         old_offset = offset;
435         bytes = tvb_get_ntohl(tvb, offset);
436         OUT_UINT(hf_afs_fs_acl_datasize);
437
438
439         if (sscanf((char *) GETSTR, "%d %n", &pos, &n) != 1) {
440                 /* does not matter what we return, if this fails, 
441                  * we cant dissect anything else in the packet either.
442                  */
443                 return offset;
444         }
445         proto_tree_add_uint(tree, hf_afs_fs_acl_count_positive, tvb, 
446                 offset, n, pos);
447         offset += n;
448
449
450         if (sscanf((char *) GETSTR, "%d %n", &neg, &n) != 1) {
451                 return offset;
452         }
453         proto_tree_add_uint(tree, hf_afs_fs_acl_count_negative, tvb, 
454                 offset, n, neg);
455         offset += n;
456
457         /*
458          * This wacky order preserves the order used by the "fs" command
459          */
460         for (i = 0; i < pos; i++) {
461                 if (sscanf((char *) GETSTR, 
462                                 "%127s %d %n", user, &acl, &n) != 2) {
463                         return offset;
464                 }
465                 ACLOUT(user,1,acl,n);
466                 offset += n;
467         }
468         for (i = 0; i < neg; i++) {
469                 if (sscanf((char *) GETSTR, 
470                         "%127s %d %n", user, &acl, &n) != 2) {
471                         return offset;
472                 }
473                 ACLOUT(user,0,acl,n);
474                 offset += n;
475                 if (offset >= old_offset+bytes ) {
476                         return offset;
477                 }
478         }
479
480         return offset;
481 }
482
483 /*
484  * Here are the helper dissection routines
485  */
486
487 static void
488 dissect_fs_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
489 {
490         if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
491         {
492                 switch ( opcode )
493                 {
494                         case 130: /* fetch data */
495                                 /* only on first packet */
496                                 if ( pinfo->ps.rx.seq == 1 )
497                                 {
498                                         OUT_FS_AFSFetchStatus("Status");
499                                         OUT_FS_AFSCallBack();
500                                         OUT_FS_AFSVolSync();
501                                 }
502                                 OUT_BYTES_ALL(hf_afs_fs_data);
503                                 break;
504                         case 131: /* fetch acl */
505                                 offset = dissect_acl(tvb, pinfo, tree, offset);
506                                 OUT_FS_AFSFetchStatus("Status");
507                                 OUT_FS_AFSVolSync();
508                                 break;
509                         case 132: /* Fetch status */
510                                 OUT_FS_AFSFetchStatus("Status");
511                                 OUT_FS_AFSCallBack();
512                                 OUT_FS_AFSVolSync();
513                                 break;  
514                         case 133: /* Store data */
515                         case 134: /* Store ACL */
516                         case 135: /* Store status */
517                         case 136: /* Remove file */
518                                 OUT_FS_AFSFetchStatus("Status");
519                                 OUT_FS_AFSVolSync();
520                                 break;
521                         case 137: /* create file */
522                         case 141: /* make dir */
523                         case 161: /* lookup */
524                         case 163: /* dfs symlink */
525                                 OUT_FS_AFSFid((opcode == 137)? "New File" : ((opcode == 141)? "New Directory" : "File"));
526                                 OUT_FS_AFSFetchStatus("File Status");
527                                 OUT_FS_AFSFetchStatus("Directory Status");
528                                 OUT_FS_AFSCallBack();
529                                 OUT_FS_AFSVolSync();
530                                 break;
531                         case 138: /* rename */
532                                 OUT_FS_AFSFetchStatus("Old Directory Status");
533                                 OUT_FS_AFSFetchStatus("New Directory Status");
534                                 OUT_FS_AFSVolSync();
535                                 break;
536                         case 139: /* symlink */
537                                 OUT_FS_AFSFid("Symlink");
538                         case 140: /* link */
539                                 OUT_FS_AFSFetchStatus("Symlink Status");
540                         case 142: /* rmdir */
541                                 OUT_FS_AFSFetchStatus("Directory Status");
542                                 OUT_FS_AFSVolSync();
543                                 break;
544                         case 143: /* old set lock */
545                         case 144: /* old extend lock */
546                         case 145: /* old release lock */
547                         case 147: /* give up callbacks */
548                         case 150: /* set volume status */
549                         case 152: /* check token */ 
550                                 /* nothing returned */
551                                 break;
552                         case 146: /* get statistics */
553                                 OUT_FS_ViceStatistics();
554                                 break;
555                         case 148: /* get volume info */
556                         case 154: /* n-get-volume-info */
557                                 OUT_FS_VolumeInfo();
558                                 break;
559                         case 149: /* get volume status */
560                                 OUT_FS_AFSFetchVolumeStatus();
561                                 OUT_STRING(hf_afs_fs_volname);
562                                 OUT_STRING(hf_afs_fs_offlinemsg);
563                                 OUT_STRING(hf_afs_fs_motd);
564                                 break;
565                         case 151: /* root volume */
566                                 OUT_STRING(hf_afs_fs_volname);
567                                 break;
568                         case 153: /* get time */
569                                 OUT_TIMESTAMP(hf_afs_fs_timestamp);
570                                 break;
571                         case 155: /* bulk status */
572                                 OUT_FS_AFSBulkStats();
573                                 OUT_FS_AFSCBs();
574                                 OUT_FS_AFSVolSync();
575                                 break;
576                         case 156: /* set lock */
577                         case 157: /* extend lock */
578                         case 158: /* release lock */
579                                 OUT_FS_AFSVolSync();
580                                 break;
581                         case 159: /* x-stats-version */
582                                 OUT_UINT(hf_afs_fs_xstats_version);
583                                 break;
584                         case 160: /* get xstats */
585                                 OUT_UINT(hf_afs_fs_xstats_version);
586                                 OUT_DATE(hf_afs_fs_xstats_timestamp);
587                                 OUT_FS_AFS_CollData();
588                                 break;
589                         case 162: /* flush cps */
590                                 OUT_UINT(hf_afs_fs_cps_spare2);
591                                 OUT_UINT(hf_afs_fs_cps_spare3);
592                                 break;
593                 }
594         }
595         else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
596         {
597                 OUT_UINT(hf_afs_fs_errcode);
598         }
599 }
600
601 static void
602 dissect_fs_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
603 {
604         offset += 4;  /* skip the opcode */
605
606         switch ( opcode )
607         {
608                 case 130: /* Fetch data */
609                         OUT_FS_AFSFid("Source");
610                         OUT_UINT(hf_afs_fs_offset);
611                         OUT_UINT(hf_afs_fs_length);
612                         break;
613                 case 131: /* Fetch ACL */
614                         OUT_FS_AFSFid("Target");
615                         break;          
616                 case 132: /* Fetch Status */
617                         OUT_FS_AFSFid("Target");
618                         break;
619                 case 133: /* Store Data */
620                         OUT_FS_AFSFid("Destination");
621                         OUT_FS_AFSStoreStatus("Status");
622                         OUT_UINT(hf_afs_fs_offset);
623                         OUT_UINT(hf_afs_fs_length);
624                         OUT_UINT(hf_afs_fs_flength);
625                         break;
626                 case 134: /* Store ACL */
627                         OUT_FS_AFSFid("Target");
628                         offset = dissect_acl(tvb, pinfo, tree, offset);
629                         break;
630                 case 135: /* Store Status */
631                         OUT_FS_AFSFid("Target");
632                         OUT_FS_AFSStoreStatus("Status");
633                         break;
634                 case 136: /* Remove File */
635                         OUT_FS_AFSFid("Remove File");
636                         OUT_STRING(hf_afs_fs_name);
637                         break;
638                 case 137: /* Create File */
639                         OUT_FS_AFSFid("Target");
640                         OUT_STRING(hf_afs_fs_name);
641                         OUT_FS_AFSStoreStatus("Status");
642                         break;
643                 case 138: /* Rename file */
644                         OUT_FS_AFSFid("Old");
645                         OUT_STRING(hf_afs_fs_oldname);
646                         OUT_FS_AFSFid("New");
647                         OUT_STRING(hf_afs_fs_newname);
648                         break;
649                 case 139: /* Symlink */
650                         OUT_FS_AFSFid("File");
651                         OUT_STRING(hf_afs_fs_symlink_name);
652                         OUT_STRING(hf_afs_fs_symlink_content);
653                         OUT_FS_AFSStoreStatus("Status");
654                         break;
655                 case 140: /* Link */
656                         OUT_FS_AFSFid("Link To (New File)");
657                         OUT_STRING(hf_afs_fs_name);
658                         OUT_FS_AFSFid("Link From (Old File)");
659                         break;
660                 case 141: /* Make dir */
661                         OUT_FS_AFSFid("Target");
662                         OUT_STRING(hf_afs_fs_name);
663                         OUT_FS_AFSStoreStatus("Status");
664                         break;
665                 case 142: /* Remove dir */
666                         OUT_FS_AFSFid("Target");
667                         OUT_STRING(hf_afs_fs_name);
668                         break;
669                 case 143: /* Old Set Lock */
670                         OUT_FS_AFSFid("Target");
671                         OUT_UINT(hf_afs_fs_vicelocktype);
672                         OUT_FS_AFSVolSync();
673                         break;
674                 case 144: /* Old Extend Lock */
675                         OUT_FS_AFSFid("Target");
676                         OUT_FS_AFSVolSync();
677                         break;
678                 case 145: /* Old Release Lock */
679                         OUT_FS_AFSFid("Target");
680                         OUT_FS_AFSVolSync();
681                         break;
682                 case 146: /* Get statistics */
683                         /* no params */
684                         break;
685                 case 147: /* Give up callbacks */
686                         OUT_FS_AFSCBFids();
687                         OUT_FS_AFSCBs();
688                         break;
689                 case 148: /* Get vol info */
690                         OUT_STRING(hf_afs_fs_volname);
691                         break;
692                 case 149: /* Get vol stats */
693                         OUT_UINT(hf_afs_fs_volid);
694                         break;
695                 case 150: /* Set vol stats */
696                         OUT_UINT(hf_afs_fs_volid);
697                         OUT_FS_AFSStoreVolumeStatus();
698                         OUT_STRING(hf_afs_fs_volname);
699                         OUT_STRING(hf_afs_fs_offlinemsg);
700                         OUT_STRING(hf_afs_fs_motd);
701                         break;
702                 case 151: /* get root volume */
703                         /* no params */
704                         break;
705                 case 152: /* check token */
706                         OUT_UINT(hf_afs_fs_viceid);
707                         OUT_FS_AFSTOKEN();
708                         break;
709                 case 153: /* get time */
710                         /* no params */
711                         break;
712                 case 154: /* new get vol info */
713                         OUT_STRING(hf_afs_fs_volname);
714                         break;
715                 case 155: /* bulk stat */
716                         OUT_FS_AFSCBFids();
717                         break;
718                 case 156: /* Set Lock */
719                         OUT_FS_AFSFid("Target");
720                         OUT_UINT(hf_afs_fs_vicelocktype);
721                         break;
722                 case 157: /* Extend Lock */
723                         OUT_FS_AFSFid("Target");
724                         break;
725                 case 158: /* Release Lock */
726                         OUT_FS_AFSFid("Target");
727                         break;
728                 case 159: /* xstats version */
729                         /* no params */
730                         break;
731                 case 160: /* get xstats */
732                         OUT_UINT(hf_afs_fs_xstats_clientversion);
733                         OUT_UINT(hf_afs_fs_xstats_collnumber);
734                         break;
735                 case 161: /* lookup */
736                         OUT_FS_AFSFid("Target");
737                         OUT_STRING(hf_afs_fs_name);
738                         break;
739                 case 162: /* flush cps */
740                         OUT_FS_ViceIds();
741                         OUT_FS_IPAddrs();
742                         OUT_UINT(hf_afs_fs_cps_spare1);
743                         break;
744                 case 163: /* dfs symlink */
745                         OUT_FS_AFSFid("Target");
746                         OUT_STRING(hf_afs_fs_symlink_name);
747                         OUT_STRING(hf_afs_fs_symlink_content);
748                         OUT_FS_AFSStoreStatus("Symlink Status");
749                         break;
750         }
751 }
752
753 /*
754  * BOS Helpers
755  */
756 static void
757 dissect_bos_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
758 {
759         if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
760         {
761                 switch ( opcode )
762                 {
763                         case 80: /* create bnode */
764                                 /* no output */
765                                 break;
766                         case 81: /* delete bnode */
767                                 /* no output */
768                                 break;
769                         case 82: /* set status */
770                                 /* no output */
771                                 break;
772                         case 83: /* get status */
773                                 OUT_INT(hf_afs_bos_status);
774                                 OUT_STRING(hf_afs_bos_statusdesc);
775                                 break;
776                         case 84: /* enumerate instance */
777                                 OUT_STRING(hf_afs_bos_instance);
778                                 break;
779                         case 85: /* get instance info */
780                                 OUT_STRING(hf_afs_bos_type);
781                                 OUT_BOS_STATUS();
782                                 break;
783                         case 86: /* get instance parm */
784                                 OUT_STRING(hf_afs_bos_parm);
785                                 break;
786                         case 87: /* add siperuser */
787                                 /* no output */
788                                 break;
789                         case 88: /* delete superuser */
790                                 /* no output */
791                                 break;
792                         case 89: /* list superusers */
793                                 OUT_STRING(hf_afs_bos_user);
794                                 break;
795                         case 90: /* list keys */
796                                 OUT_UINT(hf_afs_bos_kvno);
797                                 OUT_BOS_KEY();
798                                 OUT_BOS_KEYINFO();
799                                 break;
800                         case 91: /* add key */
801                                 /* no output */
802                                 break;
803                         case 92: /* delete key */
804                                 /* no output */
805                                 break;
806                         case 93: /* set cell name */
807                                 /* no output */
808                                 break;
809                         case 94: /* get cell name */
810                                 OUT_STRING(hf_afs_bos_cell);
811                                 break;
812                         case 95: /* get cell host */
813                                 OUT_STRING(hf_afs_bos_host);
814                                 break;
815                         case 96: /* add cell host */
816                                 /* no output */
817                                 break;
818                         case 97: /* delete cell host */
819                                 /* no output */
820                                 break;
821                         case 98: /* set tstatus */
822                                 /* no output */
823                                 break;
824                         case 99: /* shutdown all */
825                                 /* no output */
826                                 break;
827                         case 100: /* restart all */
828                                 /* no output */
829                                 break;
830                         case 101: /* startup all */
831                                 /* no output */
832                                 break;
833                         case 102: /* set noauth flag */
834                                 /* no output */
835                                 break;
836                         case 103: /* rebozo */
837                                 /* no output */
838                                 break;
839                         case 104: /* restart */
840                                 /* no output */
841                                 break;
842                         case 105: /* install */
843                                 /* no output */
844                                 break;
845                         case 106: /* uninstall */
846                                 /* no output */
847                                 break;
848                         case 107: /* get dates */
849                                 OUT_DATE(hf_afs_bos_newtime);
850                                 OUT_DATE(hf_afs_bos_baktime);
851                                 OUT_DATE(hf_afs_bos_oldtime);
852                                 break;
853                         case 108: /* exec */
854                                 /* no output */
855                                 break;
856                         case 109: /* prune */
857                                 /* no output */
858                                 break;
859                         case 110: /* set restart time */
860                                 /* no output */
861                                 break;
862                         case 111: /* get restart time */
863                                 OUT_BOS_TIME();
864                                 break;
865                         case 112: /* get log */
866                                 /* need to make this dump a big string somehow */
867                                 OUT_BYTES_ALL(hf_afs_bos_data);
868                                 break;
869                         case 113: /* wait all */
870                                 /* no output */
871                                 break;
872                         case 114: /* get instance strings */
873                                 OUT_STRING(hf_afs_bos_error);
874                                 OUT_STRING(hf_afs_bos_spare1);
875                                 OUT_STRING(hf_afs_bos_spare2);
876                                 OUT_STRING(hf_afs_bos_spare3);
877                                 break;
878                 }
879         }
880         else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
881         {
882                 OUT_UINT(hf_afs_bos_errcode);
883         }
884 }
885
886 static void
887 dissect_bos_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
888 {
889         offset += 4;  /* skip the opcode */
890
891         switch ( opcode )
892         {
893                 case 80: /* create b node */
894                         OUT_STRING(hf_afs_bos_type);
895                         OUT_STRING(hf_afs_bos_instance);
896                         OUT_STRING(hf_afs_bos_parm);
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                         break;
903                 case 81: /* delete b node */
904                         OUT_STRING(hf_afs_bos_instance);
905                         break;
906                 case 82: /* set status */
907                         OUT_STRING(hf_afs_bos_instance);
908                         OUT_UINT(hf_afs_bos_status);
909                         break;
910                 case 83: /* get status */
911                         OUT_STRING(hf_afs_bos_instance);
912                         break;
913                 case 84: /* enumerate instance */
914                         OUT_UINT(hf_afs_bos_num);
915                         break;
916                 case 85: /* get instance info */
917                         OUT_STRING(hf_afs_bos_instance);
918                         break;
919                 case 86: /* get instance parm */
920                         OUT_STRING(hf_afs_bos_instance);
921                         OUT_UINT(hf_afs_bos_num);
922                         break;
923                 case 87: /* add super user */
924                         OUT_STRING(hf_afs_bos_user);
925                         break;
926                 case 88: /* delete super user */
927                         OUT_STRING(hf_afs_bos_user);
928                         break;
929                 case 89: /* list super users */
930                         OUT_UINT(hf_afs_bos_num);
931                         break;
932                 case 90: /* list keys */
933                         OUT_UINT(hf_afs_bos_num);
934                         break;
935                 case 91: /* add key */
936                         OUT_UINT(hf_afs_bos_num);
937                         OUT_BOS_KEY();
938                         break;
939                 case 92: /* delete key */
940                         OUT_UINT(hf_afs_bos_num);
941                         break;
942                 case 93: /* set cell name */
943                         OUT_STRING(hf_afs_bos_content);
944                         break;
945                 case 95: /* set cell host */
946                         OUT_UINT(hf_afs_bos_num);
947                         break;
948                 case 96: /* add cell host */
949                         OUT_STRING(hf_afs_bos_content);
950                         break;
951                 case 97: /* delete cell host */
952                         OUT_STRING(hf_afs_bos_content);
953                         break;
954                 case 98: /* set t status */
955                         OUT_STRING(hf_afs_bos_content);
956                         OUT_UINT(hf_afs_bos_status);
957                         break;
958                 case 99: /* shutdown all */
959                         /* no params */
960                         break;
961                 case 100: /* restart all */
962                         /* no params */
963                         break;
964                 case 101: /* startup all */
965                         /* no params */
966                         break;
967                 case 102: /* set no-auth flag */
968                         OUT_UINT(hf_afs_bos_flags);
969                         break;
970                 case 103: /* re-bozo? */
971                         /* no params */
972                         break;
973                 case 104: /* restart */
974                         OUT_STRING(hf_afs_bos_instance);
975                         break;
976                 case 105: /* install */
977                         OUT_STRING(hf_afs_bos_path);
978                         OUT_UINT(hf_afs_bos_size);
979                         OUT_UINT(hf_afs_bos_flags);
980                         OUT_UINT(hf_afs_bos_date);
981                         break;
982                 case 106: /* uninstall */
983                         OUT_STRING(hf_afs_bos_path);
984                         break;
985                 case 107: /* get dates */
986                         OUT_STRING(hf_afs_bos_path);
987                         break;
988                 case 108: /* exec */
989                         OUT_STRING(hf_afs_bos_cmd);
990                         break;
991                 case 109: /* prune */
992                         OUT_UINT(hf_afs_bos_flags);
993                         break;
994                 case 110: /* set restart time */
995                         OUT_UINT(hf_afs_bos_num);
996                         OUT_BOS_TIME();
997                         break;
998                 case 111: /* get restart time */
999                         OUT_UINT(hf_afs_bos_num);
1000                         break;
1001                 case 112: /* get log */
1002                         OUT_STRING(hf_afs_bos_file);
1003                         break;
1004                 case 113: /* wait all */
1005                         /* no params */
1006                         break;
1007                 case 114: /* get instance strings */
1008                         OUT_STRING(hf_afs_bos_content);
1009                         break;
1010         }
1011 }
1012
1013 /*
1014  * VOL Helpers
1015  */
1016 static void
1017 dissect_vol_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1018 {
1019         if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
1020         {
1021                 switch ( opcode )
1022                 {
1023                         case 121:
1024                                 /* should loop here maybe */
1025                                 OUT_UINT(hf_afs_vol_count);
1026                                 VECOUT(hf_afs_vol_name, 32); /* not sure on  */
1027                                 break;
1028                 }
1029         }
1030         else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
1031         {
1032                 OUT_UINT(hf_afs_vol_errcode);
1033         }
1034 }
1035
1036 static void
1037 dissect_vol_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1038 {
1039         offset += 4;  /* skip the opcode */
1040
1041         switch ( opcode )
1042         {
1043                 case 121: /* list one vol */
1044                         OUT_UINT(hf_afs_vol_count);
1045                         OUT_UINT(hf_afs_vol_id);
1046                         break;
1047         }
1048 }
1049
1050 /*
1051  * KAUTH Helpers
1052  */
1053 static void
1054 dissect_kauth_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1055 {
1056         if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
1057         {
1058                 switch ( opcode )
1059                 {
1060                 }
1061         }
1062         else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
1063         {
1064                 OUT_UINT(hf_afs_kauth_errcode);
1065         }
1066 }
1067
1068 static void
1069 dissect_kauth_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1070 {
1071         offset += 4;  /* skip the opcode */
1072
1073         switch ( opcode )
1074         {
1075                 case 1: /* authenticate old */
1076                 case 21: /* authenticate */
1077                 case 22: /* authenticate v2 */
1078                 case 2: /* change pw */
1079                 case 5: /* set fields */
1080                 case 6: /* create user */
1081                 case 7: /* delete user */
1082                 case 8: /* get entry */
1083                 case 14: /* unlock */
1084                 case 15: /* lock status */
1085                         OUT_STRING(hf_afs_kauth_princ);
1086                         OUT_STRING(hf_afs_kauth_realm);
1087                         OUT_BYTES_ALL(hf_afs_kauth_data);
1088                         break;
1089                 case 3: /* getticket-old */
1090                 case 23: /* getticket */
1091                         OUT_UINT(hf_afs_kauth_kvno);
1092                         OUT_STRING(hf_afs_kauth_domain);
1093                         OUT_STRING(hf_afs_kauth_data);
1094                         OUT_STRING(hf_afs_kauth_princ);
1095                         OUT_STRING(hf_afs_kauth_realm);
1096                         break;
1097                 case 4: /* set pass */
1098                         OUT_STRING(hf_afs_kauth_princ);
1099                         OUT_STRING(hf_afs_kauth_realm);
1100                         OUT_UINT(hf_afs_kauth_kvno);
1101                         break;
1102                 case 12: /* get pass */
1103                         OUT_STRING(hf_afs_kauth_name);
1104                         break;
1105         }
1106 }
1107
1108 /*
1109  * CB Helpers
1110  */
1111 static void
1112 dissect_cb_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1113 {
1114         if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
1115         {
1116                 switch ( opcode )
1117                 {
1118                 }
1119         }
1120         else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
1121         {
1122                 OUT_UINT(hf_afs_cb_errcode);
1123         }
1124 }
1125
1126 static void
1127 dissect_cb_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1128 {
1129         offset += 4;  /* skip the opcode */
1130
1131         switch ( opcode )
1132         {
1133                 case 204: /* callback */
1134                 {
1135                         unsigned int i,j;
1136
1137                         j = tvb_get_ntohl(tvb, offset);
1138                         offset += 4;
1139
1140                         for (i=0; i<j; i++)
1141                         {
1142                                 OUT_CB_AFSFid("Target");
1143                         }
1144
1145                         j = tvb_get_ntohl(tvb, offset);
1146                         offset += 4;
1147                         for (i=0; i<j; i++)
1148                         {
1149                                 OUT_CB_AFSCallBack();
1150                         }
1151                 }
1152         }
1153 }
1154
1155 /*
1156  * PROT Helpers
1157  */
1158 static void
1159 dissect_prot_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1160 {
1161         if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
1162         {
1163                 switch ( opcode )
1164                 {
1165                         case 504: /* name to id */
1166                                 {
1167                                         unsigned int i, j;
1168
1169                                         j = tvb_get_ntohl(tvb, offset);
1170                                         OUT_UINT(hf_afs_prot_count);
1171
1172                                         for (i=0; i<j; i++)
1173                                         {
1174                                                 OUT_UINT(hf_afs_prot_id);
1175                                         }
1176                                 }
1177                                 break;
1178                         case 505: /* id to name */
1179                                 {
1180                                         unsigned int i, j;
1181
1182                                         j = tvb_get_ntohl(tvb, offset);
1183                                         OUT_UINT(hf_afs_prot_count);
1184
1185                                         for (i=0; i<j; i++)
1186                                         {
1187                                                 VECOUT(hf_afs_prot_name, PRNAMEMAX);
1188                                         }
1189                                 }
1190                                 break;
1191                         case 508: /* get cps */
1192                         case 514: /* list elements */
1193                         case 517: /* list owned */
1194                         case 518: /* get cps2 */
1195                         case 519: /* get host cps */
1196                                 {
1197                                         unsigned int i, j;
1198
1199                                         j = tvb_get_ntohl(tvb, offset);
1200                                         OUT_UINT(hf_afs_prot_count);
1201
1202                                         for (i=0; i<j; i++)
1203                                         {
1204                                                 OUT_UINT(hf_afs_prot_id);
1205                                         }
1206                                 }
1207                                 break;
1208                         case 510: /* list max */
1209                                 OUT_UINT(hf_afs_prot_maxuid);
1210                                 OUT_UINT(hf_afs_prot_maxgid);
1211                                 break;
1212                 }
1213         }
1214         else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
1215         {
1216                 OUT_UINT(hf_afs_prot_errcode);
1217         }
1218 }
1219
1220 static void
1221 dissect_prot_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1222 {
1223         offset += 4;  /* skip the opcode */
1224
1225         switch ( opcode )
1226         {
1227                 case 500: /* new user */
1228                         OUT_STRING(hf_afs_prot_name);
1229                         OUT_UINT(hf_afs_prot_id);
1230                         OUT_UINT(hf_afs_prot_oldid);
1231                         break;
1232                 case 501: /* where is it */
1233                 case 506: /* delete */
1234                 case 508: /* get cps */
1235                 case 512: /* list entry */
1236                 case 514: /* list elements */
1237                 case 517: /* list owned */
1238                 case 519: /* get host cps */
1239                         OUT_UINT(hf_afs_prot_id);
1240                         break;
1241                 case 502: /* dump entry */
1242                         OUT_UINT(hf_afs_prot_pos);
1243                         break;
1244                 case 503: /* add to group */
1245                 case 507: /* remove from group */
1246                 case 515: /* is a member of? */
1247                         OUT_UINT(hf_afs_prot_uid);
1248                         OUT_UINT(hf_afs_prot_gid);
1249                         break;
1250                 case 504: /* name to id */
1251                         {
1252                                 unsigned int i, j;
1253
1254                                 j = tvb_get_ntohl(tvb, offset);
1255                                 OUT_UINT(hf_afs_prot_count);
1256
1257                                 for (i=0; i<j; i++)
1258                                 {
1259                                         VECOUT(hf_afs_prot_name,PRNAMEMAX);
1260                                 }
1261                         }
1262                         break;
1263                 case 505: /* id to name */
1264                         {
1265                                 unsigned int i, j;
1266
1267                                 j = tvb_get_ntohl(tvb, offset);
1268                                 OUT_UINT(hf_afs_prot_count);
1269
1270                                 for (i=0; i<j; i++)
1271                                 {
1272                                         OUT_UINT(hf_afs_prot_id);
1273                                 }
1274                         }
1275                         break;
1276                 case 509: /* new entry */
1277                         OUT_STRING(hf_afs_prot_name);
1278                         OUT_UINT(hf_afs_prot_flag);
1279                         OUT_UINT(hf_afs_prot_oldid);
1280                         break;
1281                 case 511: /* set max */
1282                         OUT_UINT(hf_afs_prot_id);
1283                         OUT_UINT(hf_afs_prot_flag);
1284                         break;
1285                 case 513: /* change entry */
1286                         OUT_UINT(hf_afs_prot_id);
1287                         OUT_STRING(hf_afs_prot_name);
1288                         OUT_UINT(hf_afs_prot_oldid);
1289                         OUT_UINT(hf_afs_prot_newid);
1290                         break;
1291                 case 520: /* update entry */
1292                         OUT_UINT(hf_afs_prot_id);
1293                         OUT_STRING(hf_afs_prot_name);
1294                         break;
1295         }
1296 }
1297
1298 /*
1299  * VLDB Helpers
1300  */
1301 static void
1302 dissect_vldb_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1303 {
1304         if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
1305         {
1306                 switch ( opcode )
1307                 {
1308                         case 510: /* list entry */
1309                                 OUT_UINT(hf_afs_vldb_count);
1310                                 OUT_UINT(hf_afs_vldb_nextindex);
1311                                 break;
1312                         case 503: /* get entry by id */
1313                         case 504: /* get entry by name */
1314                                 {
1315                                         int nservers,i,j;
1316                                         VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1317                                         nservers = tvb_get_ntohl(tvb, offset);
1318                                         OUT_UINT(hf_afs_vldb_numservers);
1319                                         for (i=0; i<8; i++)
1320                                         {
1321                                                 if ( i<nservers )
1322                                                 {
1323                                                         OUT_IP(hf_afs_vldb_server);
1324                                                 }
1325                                                 else
1326                                                 {
1327                                                         SKIP(4);
1328                                                 }
1329                                         }
1330                                         for (i=0; i<8; i++)
1331                                         {
1332                                                 char part[8];
1333                                                 j = tvb_get_ntohl(tvb, offset);
1334                                                 strcpy(part, "/vicepa");
1335                                                 if ( i<nservers && j<=25 )
1336                                                 {
1337                                                         part[6] = 'a' + (char) j;
1338                                                         proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1339                                                                 offset, 4, part);
1340                                                 }
1341                                                 SKIP(4);
1342                                         }
1343                                         SKIP(8 * sizeof(guint32));
1344                                         OUT_UINT(hf_afs_vldb_rwvol);
1345                                         OUT_UINT(hf_afs_vldb_rovol);
1346                                         OUT_UINT(hf_afs_vldb_bkvol);
1347                                 }
1348                                 break;
1349                         case 505: /* get new volume id */
1350                                 OUT_UINT(hf_afs_vldb_id);
1351                                 break;
1352                         case 521: /* list entry */
1353                         case 529: /* list entry U */
1354                                 OUT_UINT(hf_afs_vldb_count);
1355                                 OUT_UINT(hf_afs_vldb_nextindex);
1356                                 break;
1357                         case 518: /* get entry by id n */
1358                         case 519: /* get entry by name N */
1359                                 {
1360                                         int nservers,i,j;
1361                                         VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1362                                         nservers = tvb_get_ntohl(tvb, offset);
1363                                         OUT_UINT(hf_afs_vldb_numservers);
1364                                         for (i=0; i<13; i++)
1365                                         {
1366                                                 if ( i<nservers )
1367                                                 {
1368                                                         OUT_IP(hf_afs_vldb_server);
1369                                                 }
1370                                                 else
1371                                                 {
1372                                                         SKIP(4);
1373                                                 }
1374                                         }
1375                                         for (i=0; i<13; i++)
1376                                         {
1377                                                 char part[8];
1378                                                 j = tvb_get_ntohl(tvb, offset);
1379                                                 strcpy(part, "/vicepa");
1380                                                 if ( i<nservers && j<=25 )
1381                                                 {
1382                                                         part[6] = 'a' + (char) j;
1383                                                         proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1384                                                                 offset, 4, part);
1385                                                 }
1386                                                 SKIP(4);
1387                                         }
1388                                         SKIP(13 * sizeof(guint32));
1389                                         OUT_UINT(hf_afs_vldb_rwvol);
1390                                         OUT_UINT(hf_afs_vldb_rovol);
1391                                         OUT_UINT(hf_afs_vldb_bkvol);
1392                                 }
1393                                 break;
1394                         case 526: /* get entry by id u */
1395                         case 527: /* get entry by name u */
1396                                 {
1397                                         int nservers,i,j;
1398                                         VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1399                                         nservers = tvb_get_ntohl(tvb, offset);
1400                                         OUT_UINT(hf_afs_vldb_numservers);
1401                                         for (i=0; i<13; i++)
1402                                         {
1403                                                 if ( i<nservers )
1404                                                 {
1405                                                         OUT_BYTES(hf_afs_vldb_serveruuid, 11*sizeof(guint32));
1406                                                 }
1407                                                 else
1408                                                 {
1409                                                         SKIP(11*sizeof(guint32));
1410                                                 }
1411                                         }
1412                                         for (i=0; i<13; i++)
1413                                         {
1414                                                 char part[8];
1415                                                 j = tvb_get_ntohl(tvb, offset);
1416                                                 strcpy(part, "/vicepa");
1417                                                 if ( i<nservers && j<=25 )
1418                                                 {
1419                                                         part[6] = 'a' + (char) j;
1420                                                         proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1421                                                                 offset, 4, part);
1422                                                 }
1423                                                 SKIP(4);
1424                                         }
1425                                         SKIP(13 * sizeof(guint32));
1426                                         OUT_UINT(hf_afs_vldb_rwvol);
1427                                         OUT_UINT(hf_afs_vldb_rovol);
1428                                         OUT_UINT(hf_afs_vldb_bkvol);
1429                                 }
1430                                 break;
1431                 }
1432         }
1433         else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
1434         {
1435                 OUT_UINT(hf_afs_vldb_errcode);
1436         }
1437 }
1438
1439 static void
1440 dissect_vldb_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1441 {
1442         offset += 4;  /* skip the opcode */
1443
1444         switch ( opcode )
1445         {
1446                 case 501: /* create new volume */
1447                 case 517: /* create entry N */
1448                         VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1449                         break;
1450                 case 502: /* delete entry */
1451                 case 503: /* get entry by id */
1452                 case 507: /* update entry */
1453                 case 508: /* set lock */
1454                 case 509: /* release lock */
1455                 case 518: /* get entry by id */
1456                         OUT_UINT(hf_afs_vldb_id);
1457                         OUT_UINT(hf_afs_vldb_type);
1458                         break;
1459                 case 504: /* get entry by name */
1460                 case 519: /* get entry by name N */
1461                 case 524: /* update entry by name */
1462                 case 527: /* get entry by name U */
1463                         OUT_STRING(hf_afs_vldb_name);
1464                         break;
1465                 case 505: /* get new vol id */
1466                         OUT_UINT(hf_afs_vldb_bump);
1467                         break;
1468                 case 506: /* replace entry */
1469                 case 520: /* replace entry N */
1470                         OUT_UINT(hf_afs_vldb_id);
1471                         OUT_UINT(hf_afs_vldb_type);
1472                         VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1473                         break;
1474                 case 510: /* list entry */
1475                 case 521: /* list entry N */
1476                         OUT_UINT(hf_afs_vldb_index);
1477                         break;
1478         }
1479 }
1480
1481 /*
1482  * UBIK Helpers
1483  */
1484 static void
1485 dissect_ubik_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1486 {
1487         switch ( opcode )
1488         {
1489                 case 10000: /* vote-beacon */
1490                         break;
1491                 case 10001: /* vote-debug-old */
1492                         OUT_UBIK_DebugOld();
1493                         break;
1494                 case 10002: /* vote-sdebug-old */
1495                         OUT_UBIK_SDebugOld();
1496                         break;
1497                 case 10003: /* vote-get syncsite */
1498                         break;
1499                 case 10004: /* vote-debug */
1500                         OUT_UBIK_DebugOld();
1501                         OUT_UBIK_InterfaceAddrs();
1502                         break;
1503                 case 10005: /* vote-sdebug */
1504                         OUT_UBIK_SDebugOld();
1505                         OUT_UBIK_InterfaceAddrs();
1506                         break;
1507                 case 10006: /* vote-xdebug */
1508                         OUT_UBIK_DebugOld();
1509                         OUT_UBIK_InterfaceAddrs();
1510                         OUT_UINT(hf_afs_ubik_isclone);
1511                         break;
1512                 case 10007: /* vote-xsdebug */
1513                         OUT_UBIK_SDebugOld();
1514                         OUT_UBIK_InterfaceAddrs();
1515                         OUT_UINT(hf_afs_ubik_isclone);
1516                         break;
1517                 case 20000: /* disk-begin */
1518                         break;
1519                 case 20004: /* get version */
1520                         OUT_UBIKVERSION("DB Version");
1521                         break;
1522                 case 20010: /* disk-probe */
1523                         break;
1524                 case 20012: /* disk-interfaceaddr */
1525                         OUT_UBIK_InterfaceAddrs();
1526                         break;
1527         }
1528 }
1529
1530 static void
1531 dissect_ubik_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1532 {
1533         offset += 4;  /* skip the opcode */
1534
1535         switch ( opcode )
1536         {
1537                 case 10000: /* vote-beacon */
1538                         OUT_UINT(hf_afs_ubik_state);
1539                         OUT_DATE(hf_afs_ubik_votestart);
1540                         OUT_UBIKVERSION("DB Version");
1541                         OUT_UBIKVERSION("TID");
1542                         break;
1543                 case 10001: /* vote-debug-old */
1544                         break;
1545                 case 10002: /* vote-sdebug-old */
1546                         OUT_UINT(hf_afs_ubik_site);
1547                         break;
1548                 case 10003: /* vote-get sync site */
1549                         OUT_IP(hf_afs_ubik_site);
1550                         break;
1551                 case 10004: /* vote-debug */
1552                 case 10005: /* vote-sdebug */
1553                         OUT_IP(hf_afs_ubik_site);
1554                         break;
1555                 case 20000: /* disk-begin */
1556                         OUT_UBIKVERSION("TID");
1557                         break;
1558                 case 20001: /* disk-commit */
1559                         OUT_UBIKVERSION("TID");
1560                         break;
1561                 case 20002: /* disk-lock */
1562                         OUT_UBIKVERSION("TID");
1563                         OUT_UINT(hf_afs_ubik_file);
1564                         OUT_UINT(hf_afs_ubik_pos);
1565                         OUT_UINT(hf_afs_ubik_length);
1566                         OUT_UINT(hf_afs_ubik_locktype);
1567                         break;
1568                 case 20003: /* disk-write */
1569                         OUT_UBIKVERSION("TID");
1570                         OUT_UINT(hf_afs_ubik_file);
1571                         OUT_UINT(hf_afs_ubik_pos);
1572                         break;
1573                 case 20004: /* disk-get version */
1574                         break;
1575                 case 20005: /* disk-get file */
1576                         OUT_UINT(hf_afs_ubik_file);
1577                         break;
1578                 case 20006: /* disk-send file */
1579                         OUT_UINT(hf_afs_ubik_file);
1580                         OUT_UINT(hf_afs_ubik_length);
1581                         OUT_UBIKVERSION("DB Version");
1582                         break;
1583                 case 20007: /* disk-abort */
1584                 case 20008: /* disk-release locks */
1585                 case 20010: /* disk-probe */
1586                         break;
1587                 case 20009: /* disk-truncate */
1588                         OUT_UBIKVERSION("TID");
1589                         OUT_UINT(hf_afs_ubik_file);
1590                         OUT_UINT(hf_afs_ubik_length);
1591                         break;
1592                 case 20011: /* disk-writev */
1593                         OUT_UBIKVERSION("TID");
1594                         break;
1595                 case 20012: /* disk-interfaceaddr */
1596                         OUT_UBIK_InterfaceAddrs();
1597                         break;
1598                 case 20013: /* disk-set version */
1599                         OUT_UBIKVERSION("TID");
1600                         OUT_UBIKVERSION("Old DB Version");
1601                         OUT_UBIKVERSION("New DB Version");
1602                         break;
1603         }
1604 }
1605
1606 /*
1607  * BACKUP Helpers
1608  */
1609 static void
1610 dissect_backup_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1611 {
1612         if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
1613         {
1614                 switch ( opcode )
1615                 {
1616                 }
1617         }
1618         else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
1619         {
1620                 OUT_UINT(hf_afs_backup_errcode);
1621         }
1622 }
1623
1624 static void
1625 dissect_backup_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
1626 {
1627         offset += 4;  /* skip the opcode */
1628
1629         switch ( opcode )
1630         {
1631         }
1632 }
1633
1634 /*
1635  * Registration code for registering the protocol and fields
1636  */
1637
1638 void
1639 proto_register_afs(void)
1640 {
1641         static hf_register_info hf[] = {
1642 #include "packet-afs-register-info.h"
1643         };
1644         static gint *ett[] = {
1645                 &ett_afs,
1646                 &ett_afs_op,
1647                 &ett_afs_acl,
1648                 &ett_afs_fid,
1649                 &ett_afs_callback,
1650                 &ett_afs_ubikver,
1651                 &ett_afs_status,
1652                 &ett_afs_status_mask,
1653                 &ett_afs_volsync,
1654                 &ett_afs_volumeinfo,
1655                 &ett_afs_vicestat,
1656         };
1657
1658         proto_afs = proto_register_protocol("Andrew File System (AFS)",
1659             "AFS (RX)", "afs");
1660         proto_register_field_array(proto_afs, hf, array_length(hf));
1661         proto_register_subtree_array(ett, array_length(ett));
1662         register_init_routine(&afs_init_protocol);
1663
1664         register_dissector("afs", dissect_afs, proto_afs);
1665 }