Squelch a "signed vs. unsigned comparison" warning (which warned of a
[obnox/wireshark/wip.git] / packet-atalk.c
1 /* packet-atalk.c
2  * Routines for Appletalk packet disassembly (DDP, currently).
3  *
4  * $Id: packet-atalk.c,v 1.55 2001/06/18 02:17:44 guy Exp $
5  *
6  * Simon Wilkinson <sxw@dcs.ed.ac.uk>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  * 
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  */
22
23 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #endif
26
27 #ifdef HAVE_SYS_TYPES_H
28 # include <sys/types.h>
29 #endif
30
31 #ifdef HAVE_NETINET_IN_H
32 # include <netinet/in.h>
33 #endif
34
35 #include <glib.h>
36 #include "packet.h"
37 #include "etypes.h"
38 #include "ppptypes.h"
39 #include "aftypes.h"
40 #include "atalk-utils.h"
41
42 static int proto_ddp = -1;
43 static int hf_ddp_hopcount = -1;
44 static int hf_ddp_len = -1;
45 static int hf_ddp_checksum = -1;
46 static int hf_ddp_dst_net = -1;
47 static int hf_ddp_src_net = -1;
48 static int hf_ddp_dst_node = -1;
49 static int hf_ddp_src_node = -1;
50 static int hf_ddp_dst_socket = -1;
51 static int hf_ddp_src_socket = -1;
52 static int hf_ddp_type = -1;
53
54 static int proto_nbp = -1;
55 static int hf_nbp_op = -1;
56 static int hf_nbp_info = -1;
57 static int hf_nbp_count = -1;
58 static int hf_nbp_tid = -1;
59
60 static int hf_nbp_node_net = -1;
61 static int hf_nbp_node_port = -1;
62 static int hf_nbp_node_node = -1;
63 static int hf_nbp_node_enum = -1;
64 static int hf_nbp_node_object = -1;
65 static int hf_nbp_node_type = -1;
66 static int hf_nbp_node_zone = -1;
67
68 static int proto_rtmp = -1;
69 static int hf_rtmp_net = -1;
70 static int hf_rtmp_node_len = -1;
71 static int hf_rtmp_node = -1;
72 static int hf_rtmp_tuple_net = -1;
73 static int hf_rtmp_tuple_range_start = -1;
74 static int hf_rtmp_tuple_range_end = -1;
75 static int hf_rtmp_tuple_dist = -1;
76 static int hf_rtmp_function = -1;
77
78 static gint ett_nbp = -1;
79 static gint ett_nbp_info = -1;
80 static gint ett_nbp_node = -1;
81 static gint ett_rtmp = -1;
82 static gint ett_rtmp_tuple = -1;
83 static gint ett_ddp = -1;
84 static gint ett_pstring = -1;
85
86 static dissector_table_t ddp_dissector_table;
87
88 /*
89  * P = Padding, H = Hops, L = Len
90  *
91  * PPHHHHLL LLLLLLLL
92  *
93  * Assumes the argument is in host byte order.
94  */
95 #define ddp_hops(x)     ( ( x >> 10) & 0x3C )
96 #define ddp_len(x)              ( x & 0x03ff )
97 typedef struct _e_ddp {
98   guint16       hops_len; /* combines pad, hops, and len */
99   guint16       sum,dnet,snet;
100   guint8        dnode,snode;
101   guint8        dport,sport;
102   guint8        type;
103 } e_ddp;
104
105 #define DDP_HEADER_SIZE 13
106
107
108 static const value_string op_vals[] = {
109   {DDP_RTMPDATA, "AppleTalk Routing Table response or data" },
110   {DDP_NBP, "AppleTalk Name Binding Protocol packet"},
111   {DDP_ATP, "AppleTalk Transaction Protocol packet"},
112   {DDP_AEP, "AppleTalk Echo Protocol packet"},
113   {DDP_RTMPREQ, "AppleTalk Routing Table request"},
114   {DDP_ZIP, "AppleTalk Zone Information Protocol packet"},
115   {DDP_ADSP, "AppleTalk Data Stream Protocol"},
116   {DDP_EIGRP, "Cisco EIGRP for AppleTalk"},
117   {0, NULL}
118 };
119
120 static const value_string rtmp_function_vals[] = {
121   {1, "Request"},
122   {2, "Route Data Request (split horizon processed)"},
123   {3, "Route Data Request (no split horizon processing)"},
124   {0, NULL}
125 };
126
127 #define NBP_LOOKUP 2
128 #define NBP_FORWARD 4
129 #define NBP_REPLY 3
130
131 static const value_string nbp_op_vals[] = {
132   {NBP_LOOKUP, "lookup"},
133   {NBP_FORWARD, "forward request"},
134   {NBP_REPLY, "reply"},
135   {0, NULL}
136 };
137
138 /*
139  * XXX - do this with an FT_UINT_STRING?
140  * Unfortunately, you can't extract from an FT_UINT_STRING the string,
141  * which we'd want to do in order to put it into the "Data:" portion.
142  */
143 int dissect_pascal_string(tvbuff_t *tvb, int offset, proto_tree *tree,
144         int hf_index)
145 {
146         int len;
147         
148         len = tvb_get_guint8(tvb, offset);
149         offset++;
150
151         if ( tree )
152         {
153                 char *tmp;
154                 proto_tree *item;
155                 proto_tree *subtree;
156                 
157                 /*
158                  * XXX - if we could do this inside the protocol tree
159                  * code, we could perhaps avoid allocating and freeing
160                  * this string buffer.
161                  */
162                 tmp = g_malloc( len+1 );
163                 tvb_memcpy(tvb, tmp, offset, len);
164                 tmp[len] = 0;
165                 item = proto_tree_add_string(tree, hf_index, tvb, offset-1, len+1, tmp);
166
167                 subtree = proto_item_add_subtree(item, ett_pstring);
168                 proto_tree_add_text(subtree, tvb, offset-1, 1, "Length: %d", len);
169                 proto_tree_add_text(subtree, tvb, offset, len, "Data: %s", tmp);
170                 
171                 g_free(tmp);
172         }
173         offset += len;
174         
175         return offset;  
176 }
177
178 static void
179 dissect_rtmp_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
180   proto_tree *rtmp_tree;
181   proto_item *ti;
182   guint8 function;
183
184   if (check_col(pinfo->fd, COL_PROTOCOL))
185     col_set_str(pinfo->fd, COL_PROTOCOL, "RTMP");
186   if (check_col(pinfo->fd, COL_INFO))
187     col_clear(pinfo->fd, COL_INFO);
188
189   function = tvb_get_guint8(tvb, 0);
190
191   if (check_col(pinfo->fd, COL_INFO))
192     col_add_fstr(pinfo->fd, COL_INFO, "%s",
193         val_to_str(function, rtmp_function_vals, "Unknown function (%02)"));
194   
195   if (tree) {
196     ti = proto_tree_add_item(tree, proto_rtmp, tvb, 0, 1, FALSE);
197     rtmp_tree = proto_item_add_subtree(ti, ett_rtmp);
198
199     proto_tree_add_uint(rtmp_tree, hf_rtmp_function, tvb, 0, 1, function);
200   }
201 }
202
203 static void
204 dissect_rtmp_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
205   proto_tree *rtmp_tree;
206   proto_item *ti;
207   int offset = 0;
208   guint16 net;
209   guint8 nodelen,nodelen_bits;
210   guint16 node; /* might be more than 8 bits */
211   int i;
212
213   if (check_col(pinfo->fd, COL_PROTOCOL))
214     col_set_str(pinfo->fd, COL_PROTOCOL, "RTMP");
215   if (check_col(pinfo->fd, COL_INFO))
216     col_clear(pinfo->fd, COL_INFO);
217
218   net = tvb_get_ntohs(tvb, offset);
219   nodelen_bits = tvb_get_guint8(tvb, offset+2);
220   if ( nodelen_bits <= 8 ) {
221     node = tvb_get_guint8(tvb, offset)+1;
222     nodelen = 1;
223   } else {
224     node = tvb_get_ntohs(tvb, offset);
225     nodelen = 2;
226   }
227   
228   if (check_col(pinfo->fd, COL_INFO))
229     col_add_fstr(pinfo->fd, COL_INFO, "Net: %u  Node Len: %u  Node: %u",
230                 net, nodelen_bits, node);
231   
232   if (tree) {
233     ti = proto_tree_add_item(tree, proto_rtmp, tvb, offset,
234                              tvb_length_remaining(tvb, offset), FALSE);
235     rtmp_tree = proto_item_add_subtree(ti, ett_rtmp);
236
237     proto_tree_add_uint(rtmp_tree, hf_rtmp_net, tvb, offset, 2, net);
238     proto_tree_add_uint(rtmp_tree, hf_rtmp_node_len, tvb, offset+2, 1,
239                         nodelen_bits);
240     proto_tree_add_uint(rtmp_tree, hf_rtmp_node, tvb, offset+3, nodelen,
241                         node);
242     offset += 3 + nodelen;
243
244     i = 1;
245     while (tvb_offset_exists(tvb, offset)) {
246       proto_tree *tuple_item, *tuple_tree;
247       guint16 tuple_net;
248       guint8 tuple_dist;
249       guint16 tuple_range_end;
250
251       tuple_net = tvb_get_ntohs(tvb, offset);
252       tuple_dist = tvb_get_guint8(tvb, offset+2);
253
254       if (tuple_dist & 0x80) {
255         tuple_range_end = tvb_get_ntohs(tvb, offset+3);
256         tuple_item = proto_tree_add_text(rtmp_tree, tvb, offset, 6,
257                         "Tuple %d:  Range Start: %u  Dist: %u  Range End: %u",
258                         i, tuple_net, tuple_dist&0x7F, tuple_range_end);
259       } else {
260         tuple_item = proto_tree_add_text(rtmp_tree, tvb, offset, 3,
261                         "Tuple %d:  Net: %u  Dist: %u",
262                         i, tuple_net, tuple_dist);
263       }
264       tuple_tree = proto_item_add_subtree(tuple_item, ett_rtmp_tuple);
265
266       if (tuple_dist & 0x80) {
267         proto_tree_add_uint(tuple_tree, hf_rtmp_tuple_range_start, tvb, offset, 2, 
268                         tuple_net);
269       } else {
270         proto_tree_add_uint(tuple_tree, hf_rtmp_tuple_net, tvb, offset, 2, 
271                         tuple_net);
272       }
273       proto_tree_add_uint(tuple_tree, hf_rtmp_tuple_dist, tvb, offset+2, 1,
274                         tuple_dist & 0x7F);
275
276       if (tuple_dist & 0x80) {
277         /*
278          * Extended network tuple.
279          */
280         proto_tree_add_item(tuple_tree, hf_rtmp_tuple_range_end, tvb, offset+3, 2, 
281                                 FALSE);
282         offset += 6;
283       } else
284         offset += 3;
285
286       i++;
287     }
288   }
289 }
290
291 static void
292 dissect_nbp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
293   proto_tree *nbp_tree;
294   proto_tree *nbp_info_tree;
295   proto_item *ti, *info_item;
296   int offset = 0;
297   guint8 info;
298   guint op, count;
299   unsigned int i;
300
301   if (check_col(pinfo->fd, COL_PROTOCOL))
302     col_set_str(pinfo->fd, COL_PROTOCOL, "NBP");
303   if (check_col(pinfo->fd, COL_INFO))
304     col_clear(pinfo->fd, COL_INFO);
305
306   info = tvb_get_guint8(tvb, offset);
307   op = info >> 4;
308   count = info & 0x0F;
309
310   if (check_col(pinfo->fd, COL_INFO))
311     col_add_fstr(pinfo->fd, COL_INFO, "Op: %s  Count: %u",
312       val_to_str(op, nbp_op_vals, "Unknown (0x%01x)"), count);
313   
314   if (tree) {
315     ti = proto_tree_add_item(tree, proto_nbp, tvb, offset,
316                 tvb_length_remaining(tvb, offset), FALSE);
317     nbp_tree = proto_item_add_subtree(ti, ett_nbp);
318
319     info_item = proto_tree_add_uint_format(nbp_tree, hf_nbp_info, tvb, offset, 1,
320                 info,
321                 "Info: 0x%01X  Operation: %s  Count: %u", info,
322                 val_to_str(op, nbp_op_vals, "Unknown (0x%01X)"),
323                 count);
324     nbp_info_tree = proto_item_add_subtree(info_item, ett_nbp_info);
325     proto_tree_add_uint(nbp_info_tree, hf_nbp_op, tvb, offset, 1, info);
326     proto_tree_add_uint(nbp_info_tree, hf_nbp_count, tvb, offset, 1, info);
327     proto_tree_add_item(nbp_tree, hf_nbp_tid, tvb, offset+1, 1, FALSE);
328     offset += 2;
329
330     for (i=0; i<count; i++) {
331       proto_tree *node_item,*node_tree;
332       int soffset = offset;
333
334       node_item = proto_tree_add_text(nbp_tree, tvb, offset, 4, 
335                         "Node %d", i+1);
336       node_tree = proto_item_add_subtree(node_item, ett_nbp_node);
337
338       proto_tree_add_item(node_tree, hf_nbp_node_net, tvb, offset, 2, FALSE);
339       offset += 2;
340       proto_tree_add_item(node_tree, hf_nbp_node_node, tvb, offset, 1, FALSE);
341       offset++;
342       proto_tree_add_item(node_tree, hf_nbp_node_port, tvb, offset, 1, FALSE);
343       offset++;
344       proto_tree_add_item(node_tree, hf_nbp_node_enum, tvb, offset, 1, FALSE);
345       offset++;
346
347       offset = dissect_pascal_string(tvb, offset, node_tree, hf_nbp_node_object);
348       offset = dissect_pascal_string(tvb, offset, node_tree, hf_nbp_node_type);
349       offset = dissect_pascal_string(tvb, offset, node_tree, hf_nbp_node_zone);
350
351       proto_item_set_len(node_item, offset-soffset);
352     }
353   }
354
355   return;
356 }
357
358 static void
359 dissect_ddp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
360   e_ddp       ddp;
361   proto_tree *ddp_tree;
362   proto_item *ti;
363   static struct atalk_ddp_addr src, dst;
364   tvbuff_t   *new_tvb;
365
366   if (check_col(pinfo->fd, COL_PROTOCOL))
367     col_set_str(pinfo->fd, COL_PROTOCOL, "DDP");
368   if (check_col(pinfo->fd, COL_INFO))
369     col_clear(pinfo->fd, COL_INFO);
370
371   tvb_memcpy(tvb, (guint8 *)&ddp, 0, sizeof(e_ddp));
372   ddp.dnet=ntohs(ddp.dnet);
373   ddp.snet=ntohs(ddp.snet);
374   ddp.sum=ntohs(ddp.sum);
375   ddp.hops_len=ntohs(ddp.hops_len);
376   
377   src.net = ddp.snet;
378   src.node = ddp.snode;
379   src.port = ddp.sport;
380   dst.net = ddp.dnet;
381   dst.node = ddp.dnode;
382   dst.port = ddp.dport;
383   SET_ADDRESS(&pinfo->net_src, AT_ATALK, sizeof src, (guint8 *)&src);
384   SET_ADDRESS(&pinfo->src, AT_ATALK, sizeof src, (guint8 *)&src);
385   SET_ADDRESS(&pinfo->net_dst, AT_ATALK, sizeof dst, (guint8 *)&dst);
386   SET_ADDRESS(&pinfo->dst, AT_ATALK, sizeof dst, (guint8 *)&dst);
387
388   if (check_col(pinfo->fd, COL_INFO))
389     col_add_str(pinfo->fd, COL_INFO,
390       val_to_str(ddp.type, op_vals, "Unknown DDP protocol (%02x)"));
391   
392   if (tree) {
393     ti = proto_tree_add_item(tree, proto_ddp, tvb, 0, DDP_HEADER_SIZE,
394                              FALSE);
395     ddp_tree = proto_item_add_subtree(ti, ett_ddp);
396     proto_tree_add_uint(ddp_tree, hf_ddp_hopcount,   tvb, 0, 1,
397                         ddp_hops(ddp.hops_len));
398     proto_tree_add_uint(ddp_tree, hf_ddp_len,        tvb, 0, 2, 
399                         ddp_len(ddp.hops_len));
400     proto_tree_add_uint(ddp_tree, hf_ddp_checksum,   tvb, 2,  2,
401                         ddp.sum);
402     proto_tree_add_uint(ddp_tree, hf_ddp_dst_net,    tvb, 4,  2,
403                         ddp.dnet);
404     proto_tree_add_uint(ddp_tree, hf_ddp_src_net,    tvb, 6,  2,
405                         ddp.snet);
406     proto_tree_add_uint(ddp_tree, hf_ddp_dst_node,   tvb, 8,  1,
407                         ddp.dnode);
408     proto_tree_add_uint(ddp_tree, hf_ddp_src_node,   tvb, 9,  1,
409                         ddp.snode);
410     proto_tree_add_uint(ddp_tree, hf_ddp_dst_socket, tvb, 10, 1,
411                         ddp.dport);
412     proto_tree_add_uint(ddp_tree, hf_ddp_src_socket, tvb, 11, 1,
413                         ddp.sport);
414     proto_tree_add_uint(ddp_tree, hf_ddp_type,       tvb, 12, 1,
415                         ddp.type);  
416   }
417
418   new_tvb = tvb_new_subset(tvb, DDP_HEADER_SIZE, -1, -1);
419
420   if (!dissector_try_port(ddp_dissector_table, ddp.type, new_tvb, pinfo, tree))
421     dissect_data(new_tvb, 0, pinfo, tree);
422 }
423
424 void
425 proto_register_atalk(void)
426 {
427   static hf_register_info hf_ddp[] = {
428     { &hf_ddp_hopcount,
429       { "Hop count",            "ddp.hopcount", FT_UINT8,  BASE_DEC, NULL, 0x0,
430         "", HFILL }},
431
432     { &hf_ddp_len,
433       { "Datagram length",      "ddp.len",      FT_UINT16, BASE_DEC, NULL, 0x0,
434         "", HFILL }},
435
436     { &hf_ddp_checksum,
437       { "Checksum",             "ddp.checksum", FT_UINT16, BASE_DEC, NULL, 0x0,
438         "", HFILL }},
439
440     { &hf_ddp_dst_net,
441       { "Destination Net",      "ddp.dst.net",  FT_UINT16, BASE_DEC, NULL, 0x0,
442         "", HFILL }},
443
444     { &hf_ddp_src_net,
445       { "Source Net",           "ddp.src.net",  FT_UINT16, BASE_DEC, NULL, 0x0,
446         "", HFILL }},
447
448     { &hf_ddp_dst_node,
449       { "Destination Node",     "ddp.dst.node", FT_UINT8,  BASE_DEC, NULL, 0x0,
450         "", HFILL }},
451
452     { &hf_ddp_src_node,
453       { "Source Node",          "ddp.src.node", FT_UINT8,  BASE_DEC, NULL, 0x0,
454         "", HFILL }},
455
456     { &hf_ddp_dst_socket,
457       { "Destination Socket",   "ddp.dst.socket", FT_UINT8,  BASE_DEC, NULL, 0x0,
458         "", HFILL }},
459
460     { &hf_ddp_src_socket,
461       { "Source Socket",        "ddp.src.socket", FT_UINT8,  BASE_DEC, NULL, 0x0,
462         "", HFILL }},
463
464     { &hf_ddp_type,
465       { "Protocol type",        "ddp.type",     FT_UINT8,  BASE_DEC, VALS(op_vals), 0x0,
466         "", HFILL }},
467   };
468
469   static hf_register_info hf_nbp[] = {
470     { &hf_nbp_op,
471       { "Operation",            "nbp.op",       FT_UINT8,  BASE_DEC, 
472                 VALS(nbp_op_vals), 0xF0, "Operation", HFILL }},
473     { &hf_nbp_info,
474       { "Info",         "nbp.info",     FT_UINT8,  BASE_HEX, 
475                 NULL, 0x0, "Info", HFILL }},
476     { &hf_nbp_count,
477       { "Count",                "nbp.count",    FT_UINT8,  BASE_DEC, 
478                 NULL, 0x0F, "Count", HFILL }},
479     { &hf_nbp_node_net,
480       { "Network",              "nbp.net",      FT_UINT16,  BASE_DEC, 
481                 NULL, 0x0, "Network", HFILL }},
482     { &hf_nbp_node_node,
483       { "Node",         "nbp.node",     FT_UINT8,  BASE_DEC, 
484                 NULL, 0x0, "Node", HFILL }},
485     { &hf_nbp_node_port,
486       { "Port",         "nbp.port",     FT_UINT8,  BASE_DEC, 
487                 NULL, 0x0, "Port", HFILL }},
488     { &hf_nbp_node_enum,
489       { "Enumerator",           "nbp.enum",     FT_UINT8,  BASE_DEC, 
490                 NULL, 0x0, "Enumerator", HFILL }},
491     { &hf_nbp_node_object,
492       { "Object",               "nbp.object",   FT_STRING,  BASE_DEC, 
493                 NULL, 0x0, "Object", HFILL }},
494     { &hf_nbp_node_type,
495       { "Type",         "nbp.type",     FT_STRING,  BASE_DEC, 
496                 NULL, 0x0, "Type", HFILL }},
497     { &hf_nbp_node_zone,
498       { "Zone",         "nbp.zone",     FT_STRING,  BASE_DEC, 
499                 NULL, 0x0, "Zone", HFILL }},
500     { &hf_nbp_tid,
501       { "Transaction ID",               "nbp.tid",      FT_UINT8,  BASE_DEC, 
502                 NULL, 0x0, "Transaction ID", HFILL }}
503   };
504
505   static hf_register_info hf_rtmp[] = {
506     { &hf_rtmp_net,
507       { "Net",          "rtmp.net",     FT_UINT16,  BASE_DEC, 
508                 NULL, 0x0, "Net", HFILL }},
509     { &hf_rtmp_node,
510       { "Node",         "nbp.nodeid",   FT_UINT8,  BASE_DEC, 
511                 NULL, 0x0, "Node", HFILL }},
512     { &hf_rtmp_node_len,
513       { "Node Length",          "nbp.nodeid.length",    FT_UINT8,  BASE_DEC, 
514                 NULL, 0x0, "Node Length", HFILL }},
515     { &hf_rtmp_tuple_net,
516       { "Net",          "rtmp.tuple.net",       FT_UINT16,  BASE_DEC, 
517                 NULL, 0x0, "Net", HFILL }},
518     { &hf_rtmp_tuple_range_start,
519       { "Range Start",          "rtmp.tuple.range_start",       FT_UINT16,  BASE_DEC, 
520                 NULL, 0x0, "Range Start", HFILL }},
521     { &hf_rtmp_tuple_range_end,
522       { "Range End",            "rtmp.tuple.range_end", FT_UINT16,  BASE_DEC, 
523                 NULL, 0x0, "Range End", HFILL }},
524     { &hf_rtmp_tuple_dist,
525       { "Distance",             "rtmp.tuple.dist",      FT_UINT16,  BASE_DEC, 
526                 NULL, 0x0, "Distance", HFILL }},
527     { &hf_rtmp_function,
528       { "Function",             "rtmp.function",        FT_UINT8,  BASE_DEC, 
529                 VALS(rtmp_function_vals), 0x0, "Request Function", HFILL }}
530   };
531
532
533   static gint *ett[] = {
534         &ett_ddp,
535         &ett_nbp,
536         &ett_nbp_info,
537         &ett_nbp_node,
538         &ett_pstring,
539         &ett_rtmp,
540         &ett_rtmp_tuple
541   };
542
543   proto_ddp = proto_register_protocol("Datagram Delivery Protocol", "DDP", "ddp");
544   proto_register_field_array(proto_ddp, hf_ddp, array_length(hf_ddp));
545
546   proto_nbp = proto_register_protocol("Name Binding Protocol", "NBP", "nbp");
547   proto_register_field_array(proto_nbp, hf_nbp, array_length(hf_nbp));
548
549   proto_rtmp = proto_register_protocol("Routing Table Maintenance Protocol",
550                                        "RTMP", "rtmp");
551   proto_register_field_array(proto_rtmp, hf_rtmp, array_length(hf_rtmp));
552
553   proto_register_subtree_array(ett, array_length(ett));
554
555   /* subdissector code */
556   ddp_dissector_table = register_dissector_table("ddp.type");
557 }
558
559 void
560 proto_reg_handoff_atalk(void)
561 {
562   dissector_add("ethertype", ETHERTYPE_ATALK, dissect_ddp, proto_ddp);
563   dissector_add("chdlctype", ETHERTYPE_ATALK, dissect_ddp, proto_ddp);
564   dissector_add("ppp.protocol", PPP_AT, dissect_ddp, proto_ddp);
565   dissector_add("null.type", BSD_AF_APPLETALK, dissect_ddp, proto_ddp);
566   dissector_add("ddp.type", DDP_NBP, dissect_nbp, proto_nbp);
567   dissector_add("ddp.type", DDP_RTMPREQ, dissect_rtmp_request, proto_rtmp);
568   dissector_add("ddp.type", DDP_RTMPDATA, dissect_rtmp_data, proto_rtmp);
569 }