Add a new Wiretap encapsulation type for Cisco HDLC. Map the NetBSD
[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.51 2001/03/15 09:11:00 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 "packet-atalk.h"
38 #include "etypes.h"
39 #include "ppptypes.h"
40 #include "aftypes.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 gchar *
108 atalk_addr_to_str(const struct atalk_ddp_addr *addrp)
109 {
110   static gchar  str[3][14];
111   static gchar  *cur;
112
113   if (cur == &str[0][0]) {
114     cur = &str[1][0];
115   } else if (cur == &str[1][0]) {
116     cur = &str[2][0];
117   } else {
118     cur = &str[0][0];
119   }
120
121   sprintf(cur, "%u.%u:%u", addrp->net, addrp->node, addrp->port);
122   return cur;
123 }
124
125 static const value_string op_vals[] = {
126   {DDP_RTMPDATA, "AppleTalk Routing Table response or data" },
127   {DDP_NBP, "AppleTalk Name Binding Protocol packet"},
128   {DDP_ATP, "AppleTalk Transaction Protocol packet"},
129   {DDP_AEP, "AppleTalk Echo Protocol packet"},
130   {DDP_RTMPREQ, "AppleTalk Routing Table request"},
131   {DDP_ZIP, "AppleTalk Zone Information Protocol packet"},
132   {DDP_ADSP, "AppleTalk Data Stream Protocol"},
133   {DDP_EIGRP, "Cisco EIGRP for AppleTalk"},
134   {0, NULL}
135 };
136
137 static const value_string rtmp_function_vals[] = {
138   {1, "Request"},
139   {2, "Route Data Request (split horizon processed)"},
140   {3, "Route Data Request (no split horizon processing)"},
141   {0, NULL}
142 };
143
144 #define NBP_LOOKUP 2
145 #define NBP_FORWARD 4
146 #define NBP_REPLY 3
147
148 static const value_string nbp_op_vals[] = {
149   {NBP_LOOKUP, "lookup"},
150   {NBP_FORWARD, "forward request"},
151   {NBP_REPLY, "reply"},
152   {0, NULL}
153 };
154
155 /*
156  * XXX - do this with an FT_UINT_STRING?
157  * Unfortunately, you can't extract from an FT_UINT_STRING the string,
158  * which we'd want to do in order to put it into the "Data:" portion.
159  */
160 int dissect_pascal_string(tvbuff_t *tvb, int offset, proto_tree *tree,
161         int hf_index)
162 {
163         int len;
164         
165         len = tvb_get_guint8(tvb, offset);
166         offset++;
167
168         if ( tree )
169         {
170                 char *tmp;
171                 proto_tree *item;
172                 proto_tree *subtree;
173                 
174                 /*
175                  * XXX - if we could do this inside the protocol tree
176                  * code, we could perhaps avoid allocating and freeing
177                  * this string buffer.
178                  */
179                 tmp = g_malloc( len+1 );
180                 tvb_memcpy(tvb, tmp, offset, len);
181                 tmp[len] = 0;
182                 item = proto_tree_add_string(tree, hf_index, tvb, offset-1, len+1, tmp);
183
184                 subtree = proto_item_add_subtree(item, ett_pstring);
185                 proto_tree_add_text(subtree, tvb, offset-1, 1, "Length: %d", len);
186                 proto_tree_add_text(subtree, tvb, offset, len, "Data: %s", tmp);
187                 
188                 g_free(tmp);
189         }
190         offset += len;
191         
192         return offset;  
193 }
194
195 static void
196 dissect_rtmp_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
197   proto_tree *rtmp_tree;
198   proto_item *ti;
199   guint8 function;
200
201   if (check_col(pinfo->fd, COL_PROTOCOL))
202     col_set_str(pinfo->fd, COL_PROTOCOL, "RTMP");
203   if (check_col(pinfo->fd, COL_INFO))
204     col_clear(pinfo->fd, COL_INFO);
205
206   function = tvb_get_guint8(tvb, 0);
207
208   if (check_col(pinfo->fd, COL_INFO))
209     col_add_fstr(pinfo->fd, COL_INFO, "%s",
210         val_to_str(function, rtmp_function_vals, "Unknown function (%02)"));
211   
212   if (tree) {
213     ti = proto_tree_add_item(tree, proto_rtmp, tvb, 0, 1, FALSE);
214     rtmp_tree = proto_item_add_subtree(ti, ett_rtmp);
215
216     proto_tree_add_uint(rtmp_tree, hf_rtmp_function, tvb, 0, 1, function);
217   }
218 }
219
220 static void
221 dissect_rtmp_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
222   proto_tree *rtmp_tree;
223   proto_item *ti;
224   int offset = 0;
225   guint16 net;
226   guint8 nodelen,nodelen_bits;
227   guint16 node; /* might be more than 8 bits */
228   int i;
229
230   if (check_col(pinfo->fd, COL_PROTOCOL))
231     col_set_str(pinfo->fd, COL_PROTOCOL, "RTMP");
232   if (check_col(pinfo->fd, COL_INFO))
233     col_clear(pinfo->fd, COL_INFO);
234
235   net = tvb_get_ntohs(tvb, offset);
236   nodelen_bits = tvb_get_guint8(tvb, offset+2);
237   if ( nodelen_bits <= 8 ) {
238     node = tvb_get_guint8(tvb, offset)+1;
239     nodelen = 1;
240   } else {
241     node = tvb_get_ntohs(tvb, offset);
242     nodelen = 2;
243   }
244   
245   if (check_col(pinfo->fd, COL_INFO))
246     col_add_fstr(pinfo->fd, COL_INFO, "Net: %u  Node Len: %u  Node: %u",
247                 net, nodelen_bits, node);
248   
249   if (tree) {
250     ti = proto_tree_add_item(tree, proto_rtmp, tvb, offset,
251                              tvb_length_remaining(tvb, offset), FALSE);
252     rtmp_tree = proto_item_add_subtree(ti, ett_rtmp);
253
254     proto_tree_add_uint(rtmp_tree, hf_rtmp_net, tvb, offset, 2, net);
255     proto_tree_add_uint(rtmp_tree, hf_rtmp_node_len, tvb, offset+2, 1,
256                         nodelen_bits);
257     proto_tree_add_uint(rtmp_tree, hf_rtmp_node, tvb, offset+3, nodelen,
258                         node);
259     offset += 3 + nodelen;
260
261     i = 1;
262     while (tvb_offset_exists(tvb, offset)) {
263       proto_tree *tuple_item, *tuple_tree;
264       guint16 tuple_net;
265       guint8 tuple_dist;
266       guint16 tuple_range_end;
267
268       tuple_net = tvb_get_ntohs(tvb, offset);
269       tuple_dist = tvb_get_guint8(tvb, offset+2);
270
271       if (tuple_dist & 0x80) {
272         tuple_range_end = tvb_get_ntohs(tvb, offset+3);
273         tuple_item = proto_tree_add_text(rtmp_tree, tvb, offset, 6,
274                         "Tuple %d:  Range Start: %u  Dist: %u  Range End: %u",
275                         i, tuple_net, tuple_dist&0x7F, tuple_range_end);
276       } else {
277         tuple_item = proto_tree_add_text(rtmp_tree, tvb, offset, 3,
278                         "Tuple %d:  Net: %u  Dist: %u",
279                         i, tuple_net, tuple_dist);
280       }
281       tuple_tree = proto_item_add_subtree(tuple_item, ett_rtmp_tuple);
282
283       if (tuple_dist & 0x80) {
284         proto_tree_add_uint(tuple_tree, hf_rtmp_tuple_range_start, tvb, offset, 2, 
285                         tuple_net);
286       } else {
287         proto_tree_add_uint(tuple_tree, hf_rtmp_tuple_net, tvb, offset, 2, 
288                         tuple_net);
289       }
290       proto_tree_add_uint(tuple_tree, hf_rtmp_tuple_dist, tvb, offset+2, 1,
291                         tuple_dist & 0x7F);
292
293       if (tuple_dist & 0x80) {
294         /*
295          * Extended network tuple.
296          */
297         proto_tree_add_item(tuple_tree, hf_rtmp_tuple_range_end, tvb, offset+3, 2, 
298                                 FALSE);
299         offset += 6;
300       } else
301         offset += 3;
302
303       i++;
304     }
305   }
306 }
307
308 static void
309 dissect_nbp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
310   proto_tree *nbp_tree;
311   proto_tree *nbp_info_tree;
312   proto_item *ti, *info_item;
313   int offset = 0;
314   guint8 info;
315   guint op, count;
316   int i;
317
318   if (check_col(pinfo->fd, COL_PROTOCOL))
319     col_set_str(pinfo->fd, COL_PROTOCOL, "NBP");
320   if (check_col(pinfo->fd, COL_INFO))
321     col_clear(pinfo->fd, COL_INFO);
322
323   info = tvb_get_guint8(tvb, offset);
324   op = info >> 4;
325   count = info & 0x0F;
326
327   if (check_col(pinfo->fd, COL_INFO))
328     col_add_fstr(pinfo->fd, COL_INFO, "Op: %s  Count: %u",
329       val_to_str(op, nbp_op_vals, "Unknown (0x%01x)"), count);
330   
331   if (tree) {
332     ti = proto_tree_add_item(tree, proto_nbp, tvb, offset, END_OF_FRAME, FALSE);
333     nbp_tree = proto_item_add_subtree(ti, ett_nbp);
334
335     info_item = proto_tree_add_uint_format(nbp_tree, hf_nbp_info, tvb, offset, 1,
336                 info,
337                 "Info: 0x%01X  Operation: %s  Count: %u", info,
338                 val_to_str(op, nbp_op_vals, "Unknown (0x%01X)"),
339                 count);
340     nbp_info_tree = proto_item_add_subtree(info_item, ett_nbp_info);
341     proto_tree_add_uint(nbp_info_tree, hf_nbp_op, tvb, offset, 1, info);
342     proto_tree_add_uint(nbp_info_tree, hf_nbp_count, tvb, offset, 1, info);
343     proto_tree_add_item(nbp_tree, hf_nbp_tid, tvb, offset+1, 1, FALSE);
344     offset += 2;
345
346     for (i=0; i<count; i++) {
347       proto_tree *node_item,*node_tree;
348       int soffset = offset;
349
350       node_item = proto_tree_add_text(nbp_tree, tvb, offset, 4, 
351                         "Node %d", i+1);
352       node_tree = proto_item_add_subtree(node_item, ett_nbp_node);
353
354       proto_tree_add_item(node_tree, hf_nbp_node_net, tvb, offset, 2, FALSE);
355       offset += 2;
356       proto_tree_add_item(node_tree, hf_nbp_node_node, tvb, offset, 1, FALSE);
357       offset++;
358       proto_tree_add_item(node_tree, hf_nbp_node_port, tvb, offset, 1, FALSE);
359       offset++;
360       proto_tree_add_item(node_tree, hf_nbp_node_enum, tvb, offset, 1, FALSE);
361       offset++;
362
363       offset = dissect_pascal_string(tvb, offset, node_tree, hf_nbp_node_object);
364       offset = dissect_pascal_string(tvb, offset, node_tree, hf_nbp_node_type);
365       offset = dissect_pascal_string(tvb, offset, node_tree, hf_nbp_node_zone);
366
367       proto_item_set_len(node_item, offset-soffset);
368     }
369   }
370
371   return;
372 }
373
374 static void
375 dissect_ddp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
376   e_ddp       ddp;
377   proto_tree *ddp_tree;
378   proto_item *ti;
379   static struct atalk_ddp_addr src, dst;
380   tvbuff_t   *new_tvb;
381
382   if (check_col(pinfo->fd, COL_PROTOCOL))
383     col_set_str(pinfo->fd, COL_PROTOCOL, "DDP");
384   if (check_col(pinfo->fd, COL_INFO))
385     col_clear(pinfo->fd, COL_INFO);
386
387   tvb_memcpy(tvb, (guint8 *)&ddp, 0, sizeof(e_ddp));
388   ddp.dnet=ntohs(ddp.dnet);
389   ddp.snet=ntohs(ddp.snet);
390   ddp.sum=ntohs(ddp.sum);
391   ddp.hops_len=ntohs(ddp.hops_len);
392   
393   src.net = ddp.snet;
394   src.node = ddp.snode;
395   src.port = ddp.sport;
396   dst.net = ddp.dnet;
397   dst.node = ddp.dnode;
398   dst.port = ddp.dport;
399   SET_ADDRESS(&pinfo->net_src, AT_ATALK, sizeof src, (guint8 *)&src);
400   SET_ADDRESS(&pinfo->src, AT_ATALK, sizeof src, (guint8 *)&src);
401   SET_ADDRESS(&pinfo->net_dst, AT_ATALK, sizeof dst, (guint8 *)&dst);
402   SET_ADDRESS(&pinfo->dst, AT_ATALK, sizeof dst, (guint8 *)&dst);
403
404   if (check_col(pinfo->fd, COL_INFO))
405     col_add_str(pinfo->fd, COL_INFO,
406       val_to_str(ddp.type, op_vals, "Unknown DDP protocol (%02x)"));
407   
408   if (tree) {
409     ti = proto_tree_add_item(tree, proto_ddp, tvb, 0, DDP_HEADER_SIZE,
410                              FALSE);
411     ddp_tree = proto_item_add_subtree(ti, ett_ddp);
412     proto_tree_add_uint(ddp_tree, hf_ddp_hopcount,   tvb, 0, 1,
413                         ddp_hops(ddp.hops_len));
414     proto_tree_add_uint(ddp_tree, hf_ddp_len,        tvb, 0, 2, 
415                         ddp_len(ddp.hops_len));
416     proto_tree_add_uint(ddp_tree, hf_ddp_checksum,   tvb, 2,  2,
417                         ddp.sum);
418     proto_tree_add_uint(ddp_tree, hf_ddp_dst_net,    tvb, 4,  2,
419                         ddp.dnet);
420     proto_tree_add_uint(ddp_tree, hf_ddp_src_net,    tvb, 6,  2,
421                         ddp.snet);
422     proto_tree_add_uint(ddp_tree, hf_ddp_dst_node,   tvb, 8,  1,
423                         ddp.dnode);
424     proto_tree_add_uint(ddp_tree, hf_ddp_src_node,   tvb, 9,  1,
425                         ddp.snode);
426     proto_tree_add_uint(ddp_tree, hf_ddp_dst_socket, tvb, 10, 1,
427                         ddp.dport);
428     proto_tree_add_uint(ddp_tree, hf_ddp_src_socket, tvb, 11, 1,
429                         ddp.sport);
430     proto_tree_add_uint(ddp_tree, hf_ddp_type,       tvb, 12, 1,
431                         ddp.type);  
432   }
433
434   new_tvb = tvb_new_subset(tvb, DDP_HEADER_SIZE, -1, -1);
435
436   if (!dissector_try_port(ddp_dissector_table, ddp.type, new_tvb, pinfo, tree))
437     dissect_data(new_tvb, 0, pinfo, tree);
438 }
439
440 void
441 proto_register_atalk(void)
442 {
443   static hf_register_info hf_ddp[] = {
444     { &hf_ddp_hopcount,
445       { "Hop count",            "ddp.hopcount", FT_UINT8,  BASE_DEC, NULL, 0x0,
446         "" }},
447
448     { &hf_ddp_len,
449       { "Datagram length",      "ddp.len",      FT_UINT16, BASE_DEC, NULL, 0x0,
450         "" }},
451
452     { &hf_ddp_checksum,
453       { "Checksum",             "ddp.checksum", FT_UINT16, BASE_DEC, NULL, 0x0,
454         "" }},
455
456     { &hf_ddp_dst_net,
457       { "Destination Net",      "ddp.dst.net",  FT_UINT16, BASE_DEC, NULL, 0x0,
458         "" }},
459
460     { &hf_ddp_src_net,
461       { "Source Net",           "ddp.src.net",  FT_UINT16, BASE_DEC, NULL, 0x0,
462         "" }},
463
464     { &hf_ddp_dst_node,
465       { "Destination Node",     "ddp.dst.node", FT_UINT8,  BASE_DEC, NULL, 0x0,
466         "" }},
467
468     { &hf_ddp_src_node,
469       { "Source Node",          "ddp.src.node", FT_UINT8,  BASE_DEC, NULL, 0x0,
470         "" }},
471
472     { &hf_ddp_dst_socket,
473       { "Destination Socket",   "ddp.dst.socket", FT_UINT8,  BASE_DEC, NULL, 0x0,
474         "" }},
475
476     { &hf_ddp_src_socket,
477       { "Source Socket",        "ddp.src.socket", FT_UINT8,  BASE_DEC, NULL, 0x0,
478         "" }},
479
480     { &hf_ddp_type,
481       { "Protocol type",        "ddp.type",     FT_UINT8,  BASE_DEC, VALS(op_vals), 0x0,
482         "" }},
483   };
484
485   static hf_register_info hf_nbp[] = {
486     { &hf_nbp_op,
487       { "Operation",            "nbp.op",       FT_UINT8,  BASE_DEC, 
488                 VALS(nbp_op_vals), 0xF0, "Operation" }},
489     { &hf_nbp_info,
490       { "Info",         "nbp.info",     FT_UINT8,  BASE_HEX, 
491                 NULL, 0x0, "Info" }},
492     { &hf_nbp_count,
493       { "Count",                "nbp.count",    FT_UINT8,  BASE_DEC, 
494                 NULL, 0x0F, "Count" }},
495     { &hf_nbp_node_net,
496       { "Network",              "nbp.net",      FT_UINT16,  BASE_DEC, 
497                 NULL, 0x0, "Network" }},
498     { &hf_nbp_node_node,
499       { "Node",         "nbp.node",     FT_UINT8,  BASE_DEC, 
500                 NULL, 0x0, "Node" }},
501     { &hf_nbp_node_port,
502       { "Port",         "nbp.port",     FT_UINT8,  BASE_DEC, 
503                 NULL, 0x0, "Port" }},
504     { &hf_nbp_node_enum,
505       { "Enumerator",           "nbp.enum",     FT_UINT8,  BASE_DEC, 
506                 NULL, 0x0, "Enumerator" }},
507     { &hf_nbp_node_object,
508       { "Object",               "nbp.object",   FT_STRING,  BASE_DEC, 
509                 NULL, 0x0, "Object" }},
510     { &hf_nbp_node_type,
511       { "Type",         "nbp.type",     FT_STRING,  BASE_DEC, 
512                 NULL, 0x0, "Type" }},
513     { &hf_nbp_node_zone,
514       { "Zone",         "nbp.zone",     FT_STRING,  BASE_DEC, 
515                 NULL, 0x0, "Zone" }},
516     { &hf_nbp_tid,
517       { "Transaction ID",               "nbp.tid",      FT_UINT8,  BASE_DEC, 
518                 NULL, 0x0, "Transaction ID" }}
519   };
520
521   static hf_register_info hf_rtmp[] = {
522     { &hf_rtmp_net,
523       { "Net",          "rtmp.net",     FT_UINT16,  BASE_DEC, 
524                 NULL, 0x0, "Net" }},
525     { &hf_rtmp_node,
526       { "Node",         "nbp.nodeid",   FT_UINT8,  BASE_DEC, 
527                 NULL, 0x0, "Node" }},
528     { &hf_rtmp_node_len,
529       { "Node Length",          "nbp.nodeid.length",    FT_UINT8,  BASE_DEC, 
530                 NULL, 0x0, "Node Length" }},
531     { &hf_rtmp_tuple_net,
532       { "Net",          "rtmp.tuple.net",       FT_UINT16,  BASE_DEC, 
533                 NULL, 0x0, "Net" }},
534     { &hf_rtmp_tuple_range_start,
535       { "Range Start",          "rtmp.tuple.range_start",       FT_UINT16,  BASE_DEC, 
536                 NULL, 0x0, "Range Start" }},
537     { &hf_rtmp_tuple_range_end,
538       { "Range End",            "rtmp.tuple.range_end", FT_UINT16,  BASE_DEC, 
539                 NULL, 0x0, "Range End" }},
540     { &hf_rtmp_tuple_dist,
541       { "Distance",             "rtmp.tuple.dist",      FT_UINT16,  BASE_DEC, 
542                 NULL, 0x0, "Distance" }},
543     { &hf_rtmp_function,
544       { "Function",             "rtmp.function",        FT_UINT8,  BASE_DEC, 
545                 VALS(rtmp_function_vals), 0x0, "Request Function" }}
546   };
547
548
549   static gint *ett[] = {
550         &ett_ddp,
551         &ett_nbp,
552         &ett_nbp_info,
553         &ett_nbp_node,
554         &ett_pstring,
555         &ett_rtmp,
556         &ett_rtmp_tuple
557   };
558
559   proto_ddp = proto_register_protocol("Datagram Delivery Protocol", "DDP", "ddp");
560   proto_register_field_array(proto_ddp, hf_ddp, array_length(hf_ddp));
561
562   proto_nbp = proto_register_protocol("Name Binding Protocol", "NBP", "nbp");
563   proto_register_field_array(proto_nbp, hf_nbp, array_length(hf_nbp));
564
565   proto_rtmp = proto_register_protocol("Routing Table Maintenance Protocol",
566                                        "RTMP", "rtmp");
567   proto_register_field_array(proto_rtmp, hf_rtmp, array_length(hf_rtmp));
568
569   proto_register_subtree_array(ett, array_length(ett));
570
571   /* subdissector code */
572   ddp_dissector_table = register_dissector_table("ddp.type");
573 }
574
575 void
576 proto_reg_handoff_atalk(void)
577 {
578   dissector_add("ethertype", ETHERTYPE_ATALK, dissect_ddp, proto_ddp);
579   dissector_add("chdlctype", ETHERTYPE_ATALK, dissect_ddp, proto_ddp);
580   dissector_add("ppp.protocol", PPP_AT, dissect_ddp, proto_ddp);
581   dissector_add("null.type", BSD_AF_APPLETALK, dissect_ddp, proto_ddp);
582   dissector_add("ddp.type", DDP_NBP, dissect_nbp, proto_nbp);
583   dissector_add("ddp.type", DDP_RTMPREQ, dissect_rtmp_request, proto_rtmp);
584   dissector_add("ddp.type", DDP_RTMPDATA, dissect_rtmp_data, proto_rtmp);
585 }