add packet flag for slow-start/jumbogram
[metze/wireshark/wip.git] / packet-rx.c
1 /* packet-rx.c
2  * Routines for RX 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  *
7  * $Id: packet-rx.c,v 1.33 2002/02/03 15:59:42 nneul Exp $
8  *
9  * Ethereal - Network traffic analyzer
10  * By Gerald Combs <gerald@ethereal.com>
11  * Copyright 1998 Gerald Combs
12  *
13  * Copied from packet-tftp.c
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
28  */
29
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
33
34 #include <stdio.h>
35
36 #ifdef HAVE_SYS_TYPES_H
37 # include <sys/types.h>
38 #endif
39
40 #ifdef HAVE_NETINET_IN_H
41 # include <netinet/in.h>
42 #endif
43
44 #include <string.h>
45 #include <glib.h>
46 #include <epan/packet.h>
47 #include "packet-rx.h"
48 #include <epan/resolv.h>
49
50 #define UDP_PORT_RX_LOW         7000
51 #define UDP_PORT_RX_HIGH        7009
52 #define UDP_PORT_RX_AFS_BACKUPS 7021
53
54 static const value_string rx_types[] = {
55         { RX_PACKET_TYPE_DATA,          "data" },
56         { RX_PACKET_TYPE_ACK,           "ack" },
57         { RX_PACKET_TYPE_BUSY,          "busy" },
58         { RX_PACKET_TYPE_ABORT,         "abort" },
59         { RX_PACKET_TYPE_ACKALL,        "ackall" },
60         { RX_PACKET_TYPE_CHALLENGE,     "challenge" },
61         { RX_PACKET_TYPE_RESPONSE,      "response" },
62         { RX_PACKET_TYPE_DEBUG,         "debug" },
63         { RX_PACKET_TYPE_PARAMS,        "params" },
64         { RX_PACKET_TYPE_VERSION,       "version" },
65         { 0,                            NULL },
66 };
67
68 static const value_string rx_flags[] = {
69         { RX_CLIENT_INITIATED,  "client-init" },
70         { RX_REQUEST_ACK,       "req-ack" },
71         { RX_LAST_PACKET,       "last-pckt" },
72         { RX_MORE_PACKETS,      "more-pckts" },
73         { RX_FREE_PACKET,       "free-pckt" },
74         { RX_SLOW_START_OR_JUMBO, "slow-start/jumbogram" },
75         { 0,                    NULL }
76 };
77
78 static const value_string rx_reason[] = {
79         { RX_ACK_REQUESTED,             "Ack Requested"         },
80         { RX_ACK_DUPLICATE,             "Duplicate Packet"      },
81         { RX_ACK_OUT_OF_SEQUENCE,       "Out Of Sequence"       },
82         { RX_ACK_EXEEDS_WINDOW,         "Exceeds Window"        },      
83         { RX_ACK_NOSPACE,               "No Space"              },
84         { RX_ACK_PING,                  "Ping"                  },
85         { RX_ACK_PING_RESPONSE,         "Ping Response"         },
86         { RX_ACK_DELAY,                 "Delay"                 },
87         { 0,                            NULL                    }
88 };
89
90 static const value_string rx_ack_type[] = {
91         { RX_ACK_TYPE_NACK,     "NACK"  },
92         { RX_ACK_TYPE_ACK,      "ACK"   },
93         { 0,                    NULL    }
94 };
95
96 static int proto_rx = -1;
97 static int hf_rx_epoch = -1;
98 static int hf_rx_cid = -1;
99 static int hf_rx_seq = -1;
100 static int hf_rx_serial = -1;
101 static int hf_rx_callnumber = -1;
102 static int hf_rx_type = -1;
103 static int hf_rx_flags = -1;
104 static int hf_rx_flags_clientinit = -1;
105 static int hf_rx_flags_request_ack = -1;
106 static int hf_rx_flags_last_packet = -1;
107 static int hf_rx_flags_more_packets = -1;
108 static int hf_rx_flags_free_packet = -1;
109 static int hf_rx_userstatus = -1;
110 static int hf_rx_securityindex = -1;
111 static int hf_rx_spare = -1;
112 static int hf_rx_serviceid = -1;
113 static int hf_rx_bufferspace = -1;
114 static int hf_rx_maxskew = -1;
115 static int hf_rx_first_packet = -1;
116 static int hf_rx_prev_packet = -1;
117 static int hf_rx_reason = -1;
118 static int hf_rx_numacks = -1;
119 static int hf_rx_ack_type = -1;
120 static int hf_rx_ack = -1;
121 static int hf_rx_challenge = -1;
122 static int hf_rx_version = -1;
123 static int hf_rx_nonce = -1;
124 static int hf_rx_inc_nonce = -1;
125 static int hf_rx_min_level = -1;
126 static int hf_rx_level = -1;
127 static int hf_rx_response = -1;
128 static int hf_rx_encrypted = -1;
129 static int hf_rx_kvno = -1;
130 static int hf_rx_ticket_len = -1;
131 static int hf_rx_ticket = -1;
132 static int hf_rx_ifmtu = -1;
133 static int hf_rx_maxmtu = -1;
134 static int hf_rx_rwind = -1;
135 static int hf_rx_maxpackets = -1;
136 static int hf_rx_abort = -1;
137 static int hf_rx_abortcode = -1;
138
139 static gint ett_rx = -1;
140 static gint ett_rx_flags = -1;
141 static gint ett_rx_ack = -1;
142 static gint ett_rx_challenge = -1;
143 static gint ett_rx_response = -1;
144 static gint ett_rx_encrypted = -1;
145 static gint ett_rx_abort = -1;
146
147 static dissector_handle_t afs_handle;
148
149 static int
150 dissect_rx_response_encrypted(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
151 {
152         proto_tree *tree;
153         proto_item *item;
154         int old_offset=offset;
155         int i;
156         guint32 callnumber;
157
158         item = proto_tree_add_item(parent_tree, hf_rx_encrypted, tvb, offset, -1, FALSE);
159         tree = proto_item_add_subtree(item, ett_rx_encrypted);
160
161         /* epoch : 4 bytes */
162         {
163                 nstime_t ts;
164                 ts.secs = tvb_get_ntohl(tvb, offset);
165                 ts.nsecs = 0;
166                 
167                 proto_tree_add_time(tree, hf_rx_epoch, tvb,
168                         offset, 4, &ts);
169                 offset += 4;
170         }
171
172         /* cid : 4 bytes */
173         proto_tree_add_item(tree, hf_rx_cid, tvb, offset, 4, FALSE);
174         offset += 4;
175
176         /*FIXME dont know how to handle this checksum, skipping it */
177         offset += 4;
178
179         /* sequrityindex : 1 byte */
180         proto_tree_add_item(tree, hf_rx_securityindex, tvb, offset, 1, FALSE);
181         offset += 4;
182
183         for (i=0; i<RX_MAXCALLS; i++) {
184                 /* callnumber : 4 bytes */
185                 callnumber = tvb_get_ntohl(tvb, offset);
186                 proto_tree_add_uint(tree, hf_rx_callnumber, tvb,
187                         offset, 4, callnumber);
188                 offset += 4;
189         }
190
191         /* inc nonce : 4 bytes */
192         proto_tree_add_item(tree, hf_rx_inc_nonce, tvb, offset, 4, FALSE);
193         offset += 4;
194
195         /* level : 4 bytes */
196         proto_tree_add_item(tree, hf_rx_level, tvb, offset, 4, FALSE);
197         offset += 4;
198         
199         proto_item_set_len(item, offset-old_offset);    
200         return offset;
201 }
202         
203
204 static int
205 dissect_rx_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint32 seq, guint32 callnumber)
206 {
207         proto_tree *tree;
208         proto_item *item;
209         guint32 version, tl;
210         int old_offset=offset;
211
212         if (check_col(pinfo->cinfo, COL_INFO)) {
213                 col_add_fstr(pinfo->cinfo, COL_INFO,
214                         "RESPONSE  "
215                         "Seq: %lu  "
216                         "Call: %lu  "
217                         "Source Port: %s  "
218                         "Destination Port: %s  ",
219                         (unsigned long)seq,
220                         (unsigned long)callnumber,
221                         get_udp_port(pinfo->srcport),
222                         get_udp_port(pinfo->destport)
223                 );
224         }
225
226         item = proto_tree_add_item(parent_tree, hf_rx_response, tvb, offset, -1, FALSE);
227         tree = proto_item_add_subtree(item, ett_rx_response);
228
229         version = tvb_get_ntohl(tvb, offset);
230         proto_tree_add_uint(tree, hf_rx_version, tvb,
231                 offset, 4, version);
232         offset += 4;
233
234         if (version==2) {
235                 /* skip unused */
236                 offset += 4;
237
238                 /* encrypted : struct */
239                 offset = dissect_rx_response_encrypted(tvb, pinfo, tree, offset);
240
241                 /* kvno */
242                 proto_tree_add_item(tree, hf_rx_kvno, tvb, offset, 4, FALSE);
243                 offset += 4;
244                 
245                 /* ticket_len */
246                 tl = tvb_get_ntohl(tvb, offset);
247                 proto_tree_add_uint(tree, hf_rx_ticket_len, tvb,
248                         offset, 4, tl);
249                 offset += 4;
250         
251                 proto_tree_add_item(tree, hf_rx_ticket, tvb, offset, tl, FALSE);
252                 offset += tl;   
253         }
254
255         proto_item_set_len(item, offset-old_offset);    
256         return offset;
257 }
258
259 static int
260 dissect_rx_abort(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint32 seq, guint32 callnumber)
261 {
262         proto_tree *tree;
263         proto_item *item;
264         int old_offset=offset;
265
266         if (check_col(pinfo->cinfo, COL_INFO)) {
267                 col_add_fstr(pinfo->cinfo, COL_INFO,
268                         "ABORT  "
269                         "Seq: %lu  "
270                         "Call: %lu  "
271                         "Source Port: %s  "
272                         "Destination Port: %s  ",
273                         (unsigned long)seq,
274                         (unsigned long)callnumber,
275                         get_udp_port(pinfo->srcport),
276                         get_udp_port(pinfo->destport)
277                 );
278         }
279
280         item = proto_tree_add_item(parent_tree, hf_rx_abort, tvb, offset, -1, FALSE);
281         tree = proto_item_add_subtree(item, ett_rx_abort);
282
283         /* kvno */
284         proto_tree_add_item(tree, hf_rx_abortcode, tvb, offset, 4, FALSE);
285         offset += 4;
286                 
287         proto_item_set_len(item, offset-old_offset);    
288         return offset;
289 }
290
291
292 static int
293 dissect_rx_challenge(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint32 seq, guint32 callnumber)
294 {
295         proto_tree *tree;
296         proto_item *item;
297         guint32 version;
298         int old_offset=offset;
299
300         if (check_col(pinfo->cinfo, COL_INFO)) {
301                 col_add_fstr(pinfo->cinfo, COL_INFO,
302                         "CHALLENGE  "
303                         "Seq: %lu  "
304                         "Call: %lu  "
305                         "Source Port: %s  "
306                         "Destination Port: %s  ",
307                         (unsigned long)seq,
308                         (unsigned long)callnumber,
309                         get_udp_port(pinfo->srcport),
310                         get_udp_port(pinfo->destport)
311                 );
312         }
313
314         item = proto_tree_add_item(parent_tree, hf_rx_challenge, tvb, offset, -1, FALSE);
315         tree = proto_item_add_subtree(item, ett_rx_challenge);
316
317         version = tvb_get_ntohl(tvb, offset);
318         proto_tree_add_uint(tree, hf_rx_version, tvb,
319                 offset, 4, version);
320         offset += 4;
321
322         if (version==2) {
323                 proto_tree_add_item(tree, hf_rx_nonce, tvb, offset, 4, FALSE);
324                 offset += 4;
325
326                 proto_tree_add_item(tree, hf_rx_min_level, tvb, offset, 4, FALSE);
327                 offset += 4;
328         }
329
330         proto_item_set_len(item, offset-old_offset);    
331         return offset;
332 }
333
334 static int
335 dissect_rx_acks(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint32 seq, guint32 callnumber)
336 {
337         proto_tree *tree;
338         proto_item *item;
339         guint8 num;
340         int old_offset = offset;
341
342         if (check_col(pinfo->cinfo, COL_INFO)) {
343                 col_add_fstr(pinfo->cinfo, COL_INFO,
344                         "ACK  "
345                         "Seq: %lu  "
346                         "Call: %lu  "
347                         "Source Port: %s  "
348                         "Destination Port: %s  ",
349                         (unsigned long)seq,
350                         (unsigned long)callnumber,
351                         get_udp_port(pinfo->srcport),
352                         get_udp_port(pinfo->destport)
353                 );
354         }
355
356         item = proto_tree_add_item(parent_tree, hf_rx_ack, tvb, offset, -1, FALSE);
357         tree = proto_item_add_subtree(item, ett_rx_ack);
358
359
360         /* bufferspace: 2 bytes*/
361         proto_tree_add_item(tree, hf_rx_bufferspace, tvb, offset, 2, FALSE);
362         offset += 2;
363         
364         /* maxskew: 2 bytes*/
365         proto_tree_add_item(tree, hf_rx_maxskew, tvb, offset, 2, FALSE);
366         offset += 2;
367         
368         /* first packet: 4 bytes*/
369         proto_tree_add_item(tree, hf_rx_first_packet, tvb, offset, 4, FALSE);
370         offset += 4;
371         
372         /* prev packet: 4 bytes*/
373         proto_tree_add_item(tree, hf_rx_prev_packet, tvb, offset, 4, FALSE);
374         offset += 4;
375
376         /* serial : 4 bytes */  
377         proto_tree_add_item(tree, hf_rx_serial, tvb, offset, 4, FALSE);
378         offset += 4;
379
380         /* reason : 1 byte */
381         proto_tree_add_item(tree, hf_rx_reason, tvb, offset, 1, FALSE);
382         offset += 1;
383
384         /* nACKs */
385         num = tvb_get_guint8(tvb, offset);
386         proto_tree_add_uint(tree, hf_rx_numacks, tvb, offset, 1, num);
387         offset += 1;
388
389         while(num--){
390                 proto_tree_add_item(tree, hf_rx_ack_type, tvb, offset, 1,
391                         FALSE);
392                 offset += 1;
393         }
394
395         /* Some implementations adds some extra fields.
396          * As far as I can see, these first add 3 padding bytes and then
397          * up to 4 32-bit values. (0,3,4 have been witnessed)
398          *
399          * RX as a protocol seems to be completely nondefined and seems to lack
400          * any sort of documentation other than "read the source of any of the
401          * (compatible?) implementations.
402          */
403         if (tvb_length_remaining(tvb, offset)>3) {
404                 offset += 3;    /* guess. some implementations adds 3 bytes */
405
406                 if (tvb_reported_length_remaining(tvb, offset) >= 4){
407                         proto_tree_add_item(tree, hf_rx_ifmtu, tvb, offset, 4,
408                                 FALSE);
409                         offset += 4;
410                 }
411                 if (tvb_reported_length_remaining(tvb, offset) >= 4){
412                         proto_tree_add_item(tree, hf_rx_maxmtu, tvb, offset, 4,
413                                 FALSE);
414                         offset += 4;
415                 }
416                 if (tvb_reported_length_remaining(tvb, offset) >= 4){
417                         proto_tree_add_item(tree, hf_rx_rwind, tvb, offset, 4,
418                                 FALSE);
419                         offset += 4;
420                 }
421                 if (tvb_reported_length_remaining(tvb, offset) >= 4){
422                         proto_tree_add_item(tree, hf_rx_maxpackets, tvb, offset, 4,
423                                 FALSE);
424                         offset += 4;
425                 }
426         }
427
428         proto_item_set_len(item, offset-old_offset);    
429         return offset;
430 }
431
432
433 static int
434 dissect_rx_flags(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *parent_tree, int offset)
435 {
436         proto_tree *tree;
437         proto_item *item;
438         guint8 flags;
439
440         flags = tvb_get_guint8(tvb, offset);
441         rxinfo->flags = flags;
442
443         item = proto_tree_add_uint(parent_tree, hf_rx_flags, tvb,
444                 offset, 1, flags);
445         tree = proto_item_add_subtree(item, ett_rx_flags);
446
447         proto_tree_add_uint(tree, hf_rx_flags_free_packet, tvb,
448                 offset, 1, flags);
449         proto_tree_add_uint(tree, hf_rx_flags_more_packets, tvb,
450                 offset, 1, flags);
451         proto_tree_add_uint(tree, hf_rx_flags_last_packet, tvb,
452                 offset, 1, flags);
453         proto_tree_add_uint(tree, hf_rx_flags_request_ack, tvb,
454                 offset, 1, flags);
455         proto_tree_add_uint(tree, hf_rx_flags_clientinit, tvb,
456                 offset, 1, flags);
457
458         offset += 1;
459         return offset;
460 }
461
462 static void
463 dissect_rx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
464 {
465         proto_tree *tree;
466         proto_item *item;
467         int offset = 0;
468         struct rxinfo rxinfo;
469         guint8 type;
470         guint32 seq, callnumber;
471         guint16 serviceid;
472
473         if (check_col(pinfo->cinfo, COL_PROTOCOL))
474                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RX");
475         if (check_col(pinfo->cinfo, COL_INFO))
476                 col_clear(pinfo->cinfo, COL_INFO);
477
478         item = proto_tree_add_protocol_format(parent_tree, proto_rx, tvb, 
479                 offset, 28, "RX Protocol");
480         tree = proto_item_add_subtree(item, ett_rx);
481
482         /* epoch : 4 bytes */
483         {
484                 nstime_t ts;;
485                 ts.secs = tvb_get_ntohl(tvb, offset);
486                 ts.nsecs = 0;
487                 
488                 proto_tree_add_time(tree, hf_rx_epoch, tvb,
489                         offset, 4, &ts);
490                 offset += 4;
491         }
492
493         /* cid : 4 bytes */
494         proto_tree_add_item(tree, hf_rx_cid, tvb, offset, 4, FALSE);
495         offset += 4;
496
497         /* callnumber : 4 bytes */
498         callnumber = tvb_get_ntohl(tvb, offset);
499         proto_tree_add_uint(tree, hf_rx_callnumber, tvb,
500                 offset, 4, callnumber);
501         offset += 4;
502         rxinfo.callnumber = callnumber;
503
504         /* seq : 4 bytes */
505         seq = tvb_get_ntohl(tvb, offset);
506         proto_tree_add_uint(tree, hf_rx_seq, tvb,
507                 offset, 4, seq);
508         offset += 4;
509         rxinfo.seq = seq;
510
511         /* serial : 4 bytes */
512         proto_tree_add_item(tree, hf_rx_serial, tvb, offset, 4, FALSE);
513         offset += 4;
514
515         /* type : 1 byte */
516         type = tvb_get_guint8(tvb, offset);
517         proto_tree_add_uint(tree, hf_rx_type, tvb,
518                 offset, 1, type);
519         offset += 1;
520         rxinfo.type = type;
521
522         /* flags : 1 byte */
523         offset = dissect_rx_flags(tvb, &rxinfo, tree, offset);
524
525         /* userstatus : 1 byte */
526         proto_tree_add_item(tree, hf_rx_userstatus, tvb, offset, 1, FALSE);
527         offset += 1;
528
529         /* sequrityindex : 1 byte */
530         proto_tree_add_item(tree, hf_rx_securityindex, tvb, offset, 1, FALSE);
531         offset += 1;
532
533         /*
534          * How clever: even though the AFS header files indicate that the
535          * serviceId is first, it's really encoded _after_ the spare field.
536          * I wasted a day figuring that out!
537          */
538
539         /* spare */
540         proto_tree_add_item(tree, hf_rx_spare, tvb, offset, 2, FALSE);
541         offset += 2;
542
543         /* service id : 2 bytes */
544         serviceid = tvb_get_ntohs(tvb, offset);
545         proto_tree_add_uint(tree, hf_rx_serviceid, tvb,
546                 offset, 2, serviceid);
547         offset += 2;
548         rxinfo.serviceid = serviceid;
549
550         switch (type) {
551         case RX_PACKET_TYPE_ACK:
552                 /*dissect_rx_acks(tvb, pinfo, parent_tree, offset, 
553                         cant create it in a parallell tree, then ett seasrch
554                         wont work */
555                 dissect_rx_acks(tvb, pinfo, tree, offset, 
556                         seq, callnumber);
557                 break;
558         case RX_PACKET_TYPE_ACKALL:
559                 /* does not contain any payload */
560                 if (check_col(pinfo->cinfo, COL_INFO)) {
561                         col_add_fstr(pinfo->cinfo, COL_INFO,
562                                 "ACKALL  "
563                                 "Seq: %lu  "
564                                 "Call: %lu  "
565                                 "Source Port: %s  "
566                                 "Destination Port: %s  ",
567                                 (unsigned long)seq,
568                                 (unsigned long)callnumber,
569                                 get_udp_port(pinfo->srcport),
570                                 get_udp_port(pinfo->destport)
571                         );
572                 }
573                 break;
574         case RX_PACKET_TYPE_CHALLENGE:
575                 dissect_rx_challenge(tvb, pinfo, tree, offset, seq, callnumber);
576                 break;
577         case RX_PACKET_TYPE_RESPONSE:
578                 dissect_rx_response(tvb, pinfo, tree, offset, seq, callnumber);
579                 break;
580         case RX_PACKET_TYPE_DATA: {
581                 tvbuff_t *next_tvb;
582                 pinfo->private_data = &rxinfo;
583                 next_tvb = tvb_new_subset(tvb, offset, -1, -1);
584                 call_dissector(afs_handle, next_tvb, pinfo, parent_tree);
585                 };
586                 break;
587         case RX_PACKET_TYPE_ABORT:
588                 dissect_rx_abort(tvb, pinfo, tree, offset, seq, callnumber);
589                 break;
590         }
591
592 }
593
594 void
595 proto_register_rx(void)
596 {
597         static hf_register_info hf[] = {
598                 { &hf_rx_epoch, {
599                         "Epoch", "rx.epoch", FT_ABSOLUTE_TIME, BASE_DEC,
600                         NULL, 0, "Epoch", HFILL }},
601
602                 { &hf_rx_cid, {
603                         "CID", "rx.cid", FT_UINT32, BASE_DEC,
604                         NULL, 0, "CID", HFILL }},
605
606                 { &hf_rx_callnumber, {
607                         "Call Number", "rx.callnumber", FT_UINT32, BASE_DEC,
608                         NULL, 0, "Call Number", HFILL }},
609
610                 { &hf_rx_seq, {
611                         "Sequence Number", "rx.seq", FT_UINT32, BASE_DEC,
612                         NULL, 0, "Sequence Number", HFILL }},
613
614                 { &hf_rx_serial, {
615                         "Serial", "rx.serial", FT_UINT32, BASE_DEC,
616                         NULL, 0, "Serial", HFILL }},
617
618                 { &hf_rx_type, {
619                         "Type", "rx.type", FT_UINT8, BASE_DEC,
620                         VALS(rx_types), 0, "Type", HFILL }},
621
622                 { &hf_rx_flags, {
623                         "Flags", "rx.flags", FT_UINT8, BASE_HEX,
624                         NULL, 0, "Flags", HFILL }},
625
626                 { &hf_rx_flags_clientinit, {
627                         "Client Initiated", "rx.flags.client_init", FT_UINT8, BASE_BIN,
628                         NULL, RX_CLIENT_INITIATED, "Client Initiated", HFILL }},
629
630                 { &hf_rx_flags_request_ack, {
631                         "Request Ack", "rx.flags.request_ack", FT_UINT8, BASE_BIN,
632                         NULL, RX_REQUEST_ACK, "Request Ack", HFILL }},
633
634                 { &hf_rx_flags_last_packet, {
635                         "Last Packet", "rx.flags.last_packet", FT_UINT8, BASE_BIN,
636                         NULL, RX_LAST_PACKET, "Last Packet", HFILL }},
637
638                 { &hf_rx_flags_more_packets, {
639                         "More Packets", "rx.flags.more_packets", FT_UINT8, BASE_BIN,
640                         NULL, RX_MORE_PACKETS, "More Packets", HFILL }},
641
642                 { &hf_rx_flags_free_packet, {
643                         "Free Packet", "rx.flags.free_packet", FT_UINT8, BASE_BIN,
644                         NULL, RX_FREE_PACKET, "Free Packet", HFILL }},
645
646                 { &hf_rx_userstatus, {
647                         "User Status", "rx.userstatus", FT_UINT32, BASE_DEC,
648                         NULL, 0, "User Status", HFILL }},
649
650                 { &hf_rx_securityindex, {
651                         "Security Index", "rx.securityindex", FT_UINT32, BASE_DEC,
652                         NULL, 0, "Security Index", HFILL }},
653
654                 { &hf_rx_spare, {
655                         "Spare/Checksum", "rx.spare", FT_UINT16, BASE_DEC,
656                         NULL, 0, "Spare/Checksum", HFILL }},
657
658                 { &hf_rx_serviceid, {
659                         "Service ID", "rx.serviceid", FT_UINT16, BASE_DEC,
660                         NULL, 0, "Service ID", HFILL }},
661
662                 { &hf_rx_bufferspace, {
663                         "Bufferspace", "rx.bufferspace", FT_UINT16, BASE_DEC,
664                         NULL, 0, "Number Of Packets Available", HFILL }},
665
666                 { &hf_rx_maxskew, {
667                         "Max Skew", "rx.maxskew", FT_UINT16, BASE_DEC,
668                         NULL, 0, "Max Skew", HFILL }},
669
670                 { &hf_rx_first_packet, {
671                         "First Packet", "rx.first", FT_UINT32, BASE_DEC,
672                         NULL, 0, "First Packet", HFILL }},
673
674                 { &hf_rx_prev_packet, {
675                         "Prev Packet", "rx.prev", FT_UINT32, BASE_DEC,
676                         NULL, 0, "Previous Packet", HFILL }},
677
678                 { &hf_rx_reason, {
679                         "Reason", "rx.reason", FT_UINT8, BASE_DEC,
680                         VALS(rx_reason), 0, "Reason For This ACK", HFILL }},
681
682                 { &hf_rx_numacks, {
683                         "Num ACKs", "rx.num_acks", FT_UINT8, BASE_DEC,
684                         NULL, 0, "Number Of ACKs", HFILL }},
685
686                 { &hf_rx_ack_type, {
687                         "ACK Type", "rx.ack_type", FT_UINT8, BASE_DEC,
688                         VALS(rx_ack_type), 0, "Type Of ACKs", HFILL }},
689
690                 { &hf_rx_ack, {
691                         "ACK Packet", "rx.ack", FT_NONE, BASE_NONE,
692                         NULL, 0, "ACK Packet", HFILL }},
693
694                 { &hf_rx_challenge, {
695                         "CHALLENGE Packet", "rx.challenge", FT_NONE, BASE_NONE,
696                         NULL, 0, "CHALLENGE Packet", HFILL }},
697
698                 { &hf_rx_version, {
699                         "Version", "rx.version", FT_UINT32, BASE_DEC,
700                         NULL, 0, "Version Of Challenge/Response", HFILL }},
701
702                 { &hf_rx_nonce, {
703                         "Nonce", "rx.nonce", FT_UINT32, BASE_HEX,
704                         NULL, 0, "Nonce", HFILL }},
705
706                 { &hf_rx_inc_nonce, {
707                         "Inc Nonce", "rx.inc_nonce", FT_UINT32, BASE_HEX,
708                         NULL, 0, "Incremented Nonce", HFILL }},
709
710                 { &hf_rx_min_level, {
711                         "Min Level", "rx.min_level", FT_UINT32, BASE_DEC,
712                         NULL, 0, "Min Level", HFILL }},
713
714                 { &hf_rx_level, {
715                         "Level", "rx.level", FT_UINT32, BASE_DEC,
716                         NULL, 0, "Level", HFILL }},
717
718                 { &hf_rx_response, {
719                         "RESPONSE Packet", "rx.response", FT_NONE, BASE_NONE,
720                         NULL, 0, "RESPONSE Packet", HFILL }},
721
722                 { &hf_rx_abort, {
723                         "ABORT Packet", "rx.abort", FT_NONE, BASE_NONE,
724                         NULL, 0, "ABORT Packet", HFILL }},
725
726                 { &hf_rx_encrypted, {
727                         "Encrypted", "rx.encrypted", FT_NONE, BASE_NONE,
728                         NULL, 0, "Encrypted part of response packet", HFILL }},
729
730                 { &hf_rx_kvno, {
731                         "kvno", "rx.kvno", FT_UINT32, BASE_DEC,
732                         NULL, 0, "kvno", HFILL }},
733
734                 { &hf_rx_ticket_len, {
735                         "Ticket len", "rx.ticket_len", FT_UINT32, BASE_DEC,
736                         NULL, 0, "Ticket Length", HFILL }},
737
738                 { &hf_rx_ticket, {
739                         "ticket", "rx.ticket", FT_BYTES, BASE_HEX,
740                         NULL, 0, "Ticket", HFILL }},
741
742                 { &hf_rx_ifmtu, {
743                         "Interface MTU", "rx.if_mtu", FT_UINT32, BASE_DEC,
744                         NULL, 0, "Interface MTU", HFILL }},
745
746                 { &hf_rx_maxmtu, {
747                         "Max MTU", "rx.max_mtu", FT_UINT32, BASE_DEC,
748                         NULL, 0, "Max MTU", HFILL }},
749
750                 { &hf_rx_rwind, {
751                         "rwind", "rx.rwind", FT_UINT32, BASE_DEC,
752                         NULL, 0, "rwind", HFILL }},
753
754                 { &hf_rx_maxpackets, {
755                         "Max Packets", "rx.max_packets", FT_UINT32, BASE_DEC,
756                         NULL, 0, "Max Packets", HFILL }},
757
758                 { &hf_rx_abortcode, {
759                         "Abort Code", "rx.abort_code", FT_UINT32, BASE_DEC,
760                         NULL, 0, "Abort Code", HFILL }},
761
762         };
763         static gint *ett[] = {
764                 &ett_rx,
765                 &ett_rx_flags,
766                 &ett_rx_ack,
767                 &ett_rx_challenge,
768                 &ett_rx_response,
769                 &ett_rx_encrypted,
770                 &ett_rx_abort
771         };
772
773         proto_rx = proto_register_protocol("RX Protocol", "RX", "rx");
774         proto_register_field_array(proto_rx, hf, array_length(hf));
775         proto_register_subtree_array(ett, array_length(ett));
776 }
777
778 void
779 proto_reg_handoff_rx(void)
780 {
781         dissector_handle_t rx_handle;
782
783         int port;
784
785         /*
786          * Get handle for the AFS dissector.
787          */
788         afs_handle = find_dissector("afs");
789
790         /* Ports in the range UDP_PORT_RX_LOW to UDP_PORT_RX_HIGH
791            are all used for various AFS services. */
792         rx_handle = create_dissector_handle(dissect_rx, proto_rx);
793         for (port = UDP_PORT_RX_LOW; port <= UDP_PORT_RX_HIGH; port++)
794                 dissector_add("udp.port", port, rx_handle);
795         dissector_add("udp.port", UDP_PORT_RX_AFS_BACKUPS, rx_handle);
796 }