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