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