Trivial warning fixes
[obnox/wireshark/wip.git] / epan / dissectors / packet-zebra.c
1 /* packet-zebra.c
2  * Routines for zebra packet disassembly
3  *
4  * Jochen Friedrich <jochen@scram.de>
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31 #include <string.h>
32 #include <ctype.h>
33
34 #include <glib.h>
35 #include <epan/packet.h>
36
37 static int proto_zebra = -1;
38 static int hf_zebra_len = -1;
39 static int hf_zebra_command = -1;
40 static int hf_zebra_request = -1;
41 static int hf_zebra_interface = -1;
42 static int hf_zebra_index = -1;
43 static int hf_zebra_indexnum = -1;
44 static int hf_zebra_type = -1;
45 static int hf_zebra_intflags = -1;
46 static int hf_zebra_rtflags = -1;
47 static int hf_zebra_distance = -1;
48 static int hf_zebra_metric = -1;
49 static int hf_zebra_mtu = -1;
50 static int hf_zebra_bandwidth = -1;
51 static int hf_zebra_family = -1;
52 static int hf_zebra_message = -1;
53 static int hf_zebra_msg_nexthop = -1;
54 static int hf_zebra_msg_index = -1;
55 static int hf_zebra_msg_distance = -1;
56 static int hf_zebra_msg_metric = -1;
57 static int hf_zebra_nexthopnum = -1;
58 static int hf_zebra_nexthop4 = -1;
59 static int hf_zebra_nexthop6 = -1;
60 static int hf_zebra_dest4 = -1;
61 static int hf_zebra_dest6 = -1;
62 static int hf_zebra_prefixlen = -1;
63 static int hf_zebra_prefix4 = -1;
64 static int hf_zebra_prefix6 = -1;
65
66 static gint ett_zebra = -1;
67 static gint ett_zebra_request = -1;
68 static gint ett_message = -1;
69
70 #define TCP_PORT_ZEBRA                  2600
71
72 /* Zebra message types. */
73 #define ZEBRA_INTERFACE_ADD                1
74 #define ZEBRA_INTERFACE_DELETE             2
75 #define ZEBRA_INTERFACE_ADDRESS_ADD        3
76 #define ZEBRA_INTERFACE_ADDRESS_DELETE     4
77 #define ZEBRA_INTERFACE_UP                 5
78 #define ZEBRA_INTERFACE_DOWN               6
79 #define ZEBRA_IPV4_ROUTE_ADD               7
80 #define ZEBRA_IPV4_ROUTE_DELETE            8
81 #define ZEBRA_IPV6_ROUTE_ADD               9
82 #define ZEBRA_IPV6_ROUTE_DELETE           10
83 #define ZEBRA_REDISTRIBUTE_ADD            11
84 #define ZEBRA_REDISTRIBUTE_DELETE         12
85 #define ZEBRA_REDISTRIBUTE_DEFAULT_ADD    13
86 #define ZEBRA_REDISTRIBUTE_DEFAULT_DELETE 14
87 #define ZEBRA_IPV4_NEXTHOP_LOOKUP         15
88 #define ZEBRA_IPV6_NEXTHOP_LOOKUP         16
89
90 static const value_string messages[] = {
91         { ZEBRA_INTERFACE_ADD,                  "Add Interface" },
92         { ZEBRA_INTERFACE_DELETE,               "Delete Interface" },
93         { ZEBRA_INTERFACE_ADDRESS_ADD,          "Add Interface Address" },
94         { ZEBRA_INTERFACE_ADDRESS_DELETE,       "Delete Interface Address" },
95         { ZEBRA_INTERFACE_UP,                   "Interface Up" },
96         { ZEBRA_INTERFACE_DOWN,                 "Interface Down" },
97         { ZEBRA_IPV4_ROUTE_ADD,                 "Add IPv4 Route" },
98         { ZEBRA_IPV4_ROUTE_DELETE,              "Delete IPv4 Route" },
99         { ZEBRA_IPV6_ROUTE_ADD,                 "Add IPv6 Route" },
100         { ZEBRA_IPV6_ROUTE_DELETE,              "Delete IPv6 Route" },
101         { ZEBRA_REDISTRIBUTE_ADD,               "Add Redistribute" },
102         { ZEBRA_REDISTRIBUTE_DELETE,            "Delete Redistribute" },
103         { ZEBRA_REDISTRIBUTE_DEFAULT_ADD,       "Add Default Redistribute" },
104         { ZEBRA_REDISTRIBUTE_DEFAULT_DELETE,    "Delete Default Redistribute" },
105         { ZEBRA_IPV4_NEXTHOP_LOOKUP,            "IPv4 Nexthop Lookup" },
106         { ZEBRA_IPV6_NEXTHOP_LOOKUP,            "IPv6 Nexthop Lookup" },
107         { 0,                                    NULL },
108 };
109
110 /* Zebra route's types. */
111 #define ZEBRA_ROUTE_SYSTEM               0
112 #define ZEBRA_ROUTE_KERNEL               1
113 #define ZEBRA_ROUTE_CONNECT              2
114 #define ZEBRA_ROUTE_STATIC               3
115 #define ZEBRA_ROUTE_RIP                  4
116 #define ZEBRA_ROUTE_RIPNG                5
117 #define ZEBRA_ROUTE_OSPF                 6
118 #define ZEBRA_ROUTE_OSPF6                7
119 #define ZEBRA_ROUTE_BGP                  8
120
121 static const value_string routes[] = {
122         { ZEBRA_ROUTE_SYSTEM,                   "System Route" },
123         { ZEBRA_ROUTE_KERNEL,                   "Kernel Route" },
124         { ZEBRA_ROUTE_CONNECT,                  "Connected Route" },
125         { ZEBRA_ROUTE_STATIC,                   "Static Route" },
126         { ZEBRA_ROUTE_RIP,                      "RIP Route" },
127         { ZEBRA_ROUTE_RIPNG,                    "RIPnG Route" },
128         { ZEBRA_ROUTE_OSPF,                     "OSPF Route" },
129         { ZEBRA_ROUTE_OSPF6,                    "OSPF6 Route" },
130         { ZEBRA_ROUTE_BGP,                      "BGP Route" },
131         { 0,                                    NULL },
132 };
133
134 /* Zebra's family types. */
135 #define ZEBRA_FAMILY_IPV4                1
136 #define ZEBRA_FAMILY_IPV6                2
137
138 static const value_string families[] = {
139         { ZEBRA_FAMILY_IPV4,                    "IPv4" },
140         { ZEBRA_FAMILY_IPV6,                    "IPv6" },
141         { 0,                                    NULL },
142 };
143
144 /* Zebra message flags */
145 #define ZEBRA_FLAG_INTERNAL           0x01
146 #define ZEBRA_FLAG_SELFROUTE          0x02
147 #define ZEBRA_FLAG_BLACKHOLE          0x04
148
149 /* Zebra API message flag. */
150 #define ZEBRA_ZAPI_MESSAGE_NEXTHOP    0x01
151 #define ZEBRA_ZAPI_MESSAGE_IFINDEX    0x02
152 #define ZEBRA_ZAPI_MESSAGE_DISTANCE   0x04
153 #define ZEBRA_ZAPI_MESSAGE_METRIC     0x08
154
155 #define INTERFACE_NAMSIZ      20
156
157 #define PSIZE(a) (((a) + 7) / (8))
158
159 static void
160 dissect_zebra_request(proto_tree *tree, gboolean request, tvbuff_t *tvb,
161         int offset, guint16 len, guint8 command)
162 {
163         guint32 prefix4;
164         guint16 i;
165         guint8  buffer6[16], prefixlen, message;
166         proto_item *ti;
167         proto_tree *msg_tree;
168
169         proto_tree_add_uint(tree, hf_zebra_len, tvb, offset, 2, len);
170         offset += 2;
171         proto_tree_add_uint(tree, hf_zebra_command, tvb, offset, 1,
172                 command);
173         offset += 1;
174         switch(command) {
175                 case ZEBRA_INTERFACE_ADD:
176                 case ZEBRA_INTERFACE_UP:
177                 case ZEBRA_INTERFACE_DOWN:
178                         if (request) break;
179                         /* Request just subscribes to messages */
180
181                         proto_tree_add_item(tree, hf_zebra_interface,
182                                 tvb, offset, INTERFACE_NAMSIZ, FALSE);
183                         offset += INTERFACE_NAMSIZ;
184
185                         proto_tree_add_item(tree, hf_zebra_index, tvb,
186                                  offset, 4, FALSE);
187                         offset += 4;
188
189                         proto_tree_add_item(tree, hf_zebra_intflags, tvb,
190                                  offset, 4, FALSE);
191                         offset += 4;
192
193                         proto_tree_add_item(tree, hf_zebra_metric, tvb,
194                                  offset, 4, FALSE);
195                         offset += 4;
196
197                         proto_tree_add_item(tree, hf_zebra_mtu, tvb,
198                                  offset, 4, FALSE);
199                         offset += 4;
200
201                         proto_tree_add_item(tree, hf_zebra_bandwidth, tvb,
202                                  offset, 4, FALSE);
203                         offset += 4;
204
205                         break;
206                 case ZEBRA_INTERFACE_DELETE:
207                         proto_tree_add_item(tree, hf_zebra_interface,
208                                 tvb, offset, INTERFACE_NAMSIZ, FALSE);
209                         offset += INTERFACE_NAMSIZ;
210
211                         proto_tree_add_item(tree, hf_zebra_index, tvb,
212                                  offset, 4, FALSE);
213                         offset += 4;
214                         break;
215                 case ZEBRA_INTERFACE_ADDRESS_ADD:
216                 case ZEBRA_INTERFACE_ADDRESS_DELETE:
217                         proto_tree_add_item(tree, hf_zebra_index, tvb,
218                                  offset, 4, FALSE);
219                         offset += 4;
220
221                         proto_tree_add_item(tree, hf_zebra_family, tvb,
222                                  offset, 1, FALSE);
223                         offset += 1;
224
225                         /* XXX - switch on the address family here, instead? */
226                         if (len == 17) { /* IPv4 */
227                                 proto_tree_add_item(tree, hf_zebra_prefix4,
228                                         tvb, offset, 4, FALSE);
229                                 offset += 4;
230                         }
231                         else if (len == 41) { /* IPv6 */
232                                 proto_tree_add_item(tree, hf_zebra_prefix6,
233                                         tvb, offset, 16, FALSE);
234                                 offset += 16;
235                         }
236                         else break;
237
238                         proto_tree_add_item(tree, hf_zebra_prefixlen, tvb,
239                                  offset, 1, FALSE);
240                         offset += 1;
241
242                         if (len == 17) { /* IPv4 */
243                                 proto_tree_add_item(tree, hf_zebra_dest4,
244                                         tvb, offset, 4, FALSE);
245                                 offset += 4;
246                         }
247                         else if (len == 41) { /* IPv6 */
248                                 proto_tree_add_item(tree, hf_zebra_dest6,
249                                         tvb, offset, 16, FALSE);
250                                 offset += 16;
251                         }
252                         break;
253
254                 case ZEBRA_IPV4_ROUTE_ADD:
255                 case ZEBRA_IPV4_ROUTE_DELETE:
256                         proto_tree_add_item(tree, hf_zebra_type, tvb,
257                                  offset, 1, FALSE);
258                         offset += 1;
259
260                         proto_tree_add_item(tree, hf_zebra_rtflags, tvb,
261                                  offset, 1, FALSE);
262                         offset += 1;
263
264                         message = tvb_get_guint8(tvb, offset);
265                         ti = proto_tree_add_uint(tree, hf_zebra_message, tvb,
266                                  offset, 1, message);
267                         msg_tree = proto_item_add_subtree(ti, ett_message);
268                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_nexthop,
269                                 tvb, offset, 1, message);
270                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_index,
271                                 tvb, offset, 1, message);
272                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_distance,
273                                 tvb, offset, 1, message);
274                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_metric,
275                                 tvb, offset, 1, message);
276                         offset += 1;
277
278                         prefixlen = tvb_get_guint8(tvb, offset);
279                         proto_tree_add_uint(tree, hf_zebra_prefixlen, tvb,
280                                  offset, 1, prefixlen);
281                         offset += 1;
282
283                         prefix4 = 0;
284                         tvb_memcpy(tvb, (guint8 *)&prefix4, offset,
285                             MIN((unsigned) PSIZE(prefixlen), sizeof prefix4));
286                         proto_tree_add_ipv4(tree, hf_zebra_prefix4,
287                                 tvb, offset, PSIZE(prefixlen), prefix4);
288                         offset += PSIZE(prefixlen);
289
290                         if (message & ZEBRA_ZAPI_MESSAGE_NEXTHOP) {
291                                 i = tvb_get_guint8(tvb, offset);
292                                 proto_tree_add_uint(tree, hf_zebra_nexthopnum,
293                                         tvb, offset, 1, i);
294                                 offset += 1;
295
296                                 if (i>len) break; /* Sanity */
297
298                                 while (i--) {
299                                         proto_tree_add_item(tree,
300                                                 hf_zebra_nexthop4, tvb,
301                                                 offset, 4, FALSE);
302                                         offset += 4;
303                                 }
304                         }
305                         if (message & ZEBRA_ZAPI_MESSAGE_IFINDEX) {
306                                 i = tvb_get_guint8(tvb, offset);
307                                 proto_tree_add_uint(tree, hf_zebra_indexnum,
308                                         tvb, offset, 1, i);
309                                 offset += 1;
310
311                                 if (i>len) break; /* Sanity */
312
313                                 while (i--) {
314                                         proto_tree_add_item(tree,
315                                                 hf_zebra_index, tvb,
316                                                 offset, 4, FALSE);
317                                         offset += 4;
318                                 }
319                         }
320                         if (message & ZEBRA_ZAPI_MESSAGE_DISTANCE) {
321                                 proto_tree_add_item(tree, hf_zebra_distance,
322                                         tvb, offset, 1, FALSE);
323                                 offset += 1;
324                         }
325                         if (message & ZEBRA_ZAPI_MESSAGE_METRIC) {
326                                 proto_tree_add_item(tree, hf_zebra_metric,
327                                         tvb, offset, 4, FALSE);
328                                 offset += 4;
329                         }
330                         break;
331                 case ZEBRA_IPV6_ROUTE_ADD:
332                 case ZEBRA_IPV6_ROUTE_DELETE:
333                         proto_tree_add_item(tree, hf_zebra_type, tvb,
334                                  offset, 1, FALSE);
335                         offset += 1;
336
337                         proto_tree_add_item(tree, hf_zebra_rtflags, tvb,
338                                  offset, 1, FALSE);
339                         offset += 1;
340
341                         message = tvb_get_guint8(tvb, offset);
342                         ti = proto_tree_add_uint(tree, hf_zebra_message, tvb,
343                                  offset, 1, message);
344                         msg_tree = proto_item_add_subtree(ti, ett_message);
345                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_nexthop,
346                                 tvb, offset, 1, message);
347                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_index,
348                                 tvb, offset, 1, message);
349                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_distance,
350                                 tvb, offset, 1, message);
351                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_metric,
352                                 tvb, offset, 1, message);
353                         offset += 1;
354
355                         prefixlen = tvb_get_guint8(tvb, offset);
356                         proto_tree_add_uint(tree, hf_zebra_prefixlen, tvb,
357                                  offset, 1, prefixlen);
358                         offset += 1;
359
360                         memset(buffer6, '\0', sizeof buffer6);
361                         tvb_memcpy(tvb, buffer6, offset,
362                             MIN((unsigned) PSIZE(prefixlen), sizeof buffer6));
363                         proto_tree_add_ipv6(tree, hf_zebra_prefix6,
364                                 tvb, offset, PSIZE(prefixlen), buffer6);
365                         offset += PSIZE(prefixlen);
366
367                         if (message & ZEBRA_ZAPI_MESSAGE_NEXTHOP) {
368                                 i = tvb_get_guint8(tvb, offset);
369                                 proto_tree_add_uint(tree, hf_zebra_nexthopnum,
370                                         tvb, offset, 1, i);
371                                 offset += 1;
372
373                                 if (i>len) break; /* Sanity */
374
375                                 while (i--) {
376                                         proto_tree_add_item(tree,
377                                                 hf_zebra_nexthop6, tvb,
378                                                 offset, 16, FALSE);
379                                         offset += 16;
380                                 }
381                         }
382                         if (message & ZEBRA_ZAPI_MESSAGE_IFINDEX) {
383                                 i = tvb_get_guint8(tvb, offset);
384                                 proto_tree_add_uint(tree, hf_zebra_indexnum,
385                                         tvb, offset, 1, i);
386                                 offset += 1;
387
388                                 if (i>len) break; /* Sanity */
389
390                                 while (i--) {
391                                         proto_tree_add_item(tree,
392                                                 hf_zebra_index, tvb,
393                                                 offset, 4, FALSE);
394                                         offset += 4;
395                                 }
396                         }
397                         if (message & ZEBRA_ZAPI_MESSAGE_DISTANCE) {
398                                 proto_tree_add_item(tree, hf_zebra_distance,
399                                         tvb, offset, 1, FALSE);
400                                 offset += 1;
401                         }
402                         if (message & ZEBRA_ZAPI_MESSAGE_METRIC) {
403                                 proto_tree_add_item(tree, hf_zebra_metric,
404                                         tvb, offset, 4, FALSE);
405                                 offset += 4;
406                         }
407                         break;
408                 case ZEBRA_REDISTRIBUTE_ADD:
409                 case ZEBRA_REDISTRIBUTE_DELETE:
410                         proto_tree_add_item(tree, hf_zebra_type, tvb,
411                                  offset, 1, FALSE);
412                         offset += 1;
413                         break;
414                 case ZEBRA_REDISTRIBUTE_DEFAULT_ADD:
415                 case ZEBRA_REDISTRIBUTE_DEFAULT_DELETE:
416                         break;
417                 case ZEBRA_IPV4_NEXTHOP_LOOKUP:
418                         proto_tree_add_item(tree, hf_zebra_nexthop4,
419                                 tvb, offset, 4, FALSE);
420                         offset += 4;
421
422                         proto_tree_add_item(tree, hf_zebra_metric,
423                                 tvb, offset, 4, FALSE);
424                         offset += 4;
425                         break;
426                 case ZEBRA_IPV6_NEXTHOP_LOOKUP:
427                         /* Not yet implemeted in ZEBRA */
428                         break;
429         }
430 }
431
432 static void
433 dissect_zebra(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
434 {
435         proto_item      *ti;
436         proto_tree      *zebra_tree;
437         gboolean        request;
438         int             left, offset;
439
440         if (check_col(pinfo->cinfo, COL_PROTOCOL))
441                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZEBRA");
442
443         request = (pinfo->destport == pinfo->match_port);
444         left = tvb_reported_length(tvb);
445         offset = 0;
446
447         if (check_col(pinfo->cinfo, COL_INFO)) {
448                 col_set_str(pinfo->cinfo, COL_INFO,
449                         request? "ZEBRA Request" : "ZEBRA Reply");
450         }
451         if (tree) {
452                 ti = proto_tree_add_item(tree, proto_zebra, tvb, offset, -1,
453                         FALSE);
454                 zebra_tree = proto_item_add_subtree(ti, ett_zebra);
455                 ti = proto_tree_add_boolean(zebra_tree, hf_zebra_request,
456                         tvb, offset, 0, request);
457                 PROTO_ITEM_SET_HIDDEN(ti);
458
459                 for (;;) {
460                         guint8          command;
461                         guint16         len;
462                         proto_tree      *zebra_request_tree;
463
464                         if (left < 3) break;
465
466                         len = tvb_get_ntohs(tvb, offset);
467                         if (len < 3) break;
468
469                         command = tvb_get_guint8(tvb, offset+2);
470
471                         ti = proto_tree_add_uint(zebra_tree,
472                                 hf_zebra_command, tvb, offset, len,
473                                 command);
474                         zebra_request_tree = proto_item_add_subtree(ti,
475                                 ett_zebra_request);
476                         dissect_zebra_request(zebra_request_tree, request, tvb,
477                                 offset, len, command);
478
479                         offset += len;
480                         left -= len;
481                 }
482         }
483 }
484
485 void
486 proto_register_zebra(void)
487 {
488
489   static hf_register_info hf[] = {
490     { &hf_zebra_len,
491       { "Length",               "zebra.len",
492         FT_UINT16, BASE_DEC, NULL, 0x0,
493         "Length of ZEBRA request", HFILL }},
494     { &hf_zebra_request,
495       { "Request",              "zebra.request",
496         FT_BOOLEAN, BASE_NONE, NULL, 0x0,
497         "TRUE if ZEBRA request", HFILL }},
498     { &hf_zebra_command,
499       { "Command",              "zebra.command",
500         FT_UINT8, BASE_DEC, VALS(messages), 0x0,
501         "ZEBRA command", HFILL }},
502     { &hf_zebra_interface,
503       { "Interface",            "zebra.interface",
504         FT_STRING, BASE_NONE, NULL, 0x0,
505         "Interface name of ZEBRA request", HFILL }},
506     { &hf_zebra_index,
507       { "Index",                "zebra.index",
508         FT_UINT32, BASE_DEC, NULL, 0x0,
509         "Index of interface", HFILL }},
510     { &hf_zebra_indexnum,
511       { "Index Number",         "zebra.indexnum",
512         FT_UINT8, BASE_DEC, NULL, 0x0,
513         "Number of indices for route", HFILL }},
514     { &hf_zebra_intflags,
515       { "Flags",                "zebra.intflags",
516         FT_UINT32, BASE_DEC, NULL, 0x0,
517         "Flags of interface", HFILL }},
518     { &hf_zebra_rtflags,
519       { "Flags",                "zebra.rtflags",
520         FT_UINT8, BASE_DEC, NULL, 0x0,
521         "Flags of route", HFILL }},
522     { &hf_zebra_message,
523       { "Message",              "zebra.message",
524         FT_UINT8, BASE_DEC, NULL, 0x0,
525         "Message type of route", HFILL }},
526     { &hf_zebra_msg_nexthop,
527       { "Message Nexthop",      "zebra.message.nexthop",
528         FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_NEXTHOP,
529         "Message contains nexthop", HFILL }},
530     { &hf_zebra_msg_index,
531       { "Message Index",        "zebra.message.index",
532         FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_IFINDEX,
533         "Message contains index", HFILL }},
534     { &hf_zebra_msg_distance,
535       { "Message Distance",     "zebra.message.distance",
536         FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_DISTANCE,
537         "Message contains distance", HFILL }},
538     { &hf_zebra_msg_metric,
539       { "Message Metric",       "zebra.message.metric",
540         FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_METRIC,
541         "Message contains metric", HFILL }},
542     { &hf_zebra_type,
543       { "Type",                 "zebra.type",
544         FT_UINT8, BASE_DEC, VALS(routes), 0x0,
545         "Type of route", HFILL }},
546     { &hf_zebra_distance,
547       { "Distance",             "zebra.distance",
548         FT_UINT8, BASE_DEC, NULL, 0x0,
549         "Distance of route", HFILL }},
550     { &hf_zebra_metric,
551       { "Metric",               "zebra.metric",
552         FT_UINT32, BASE_DEC, NULL, 0x0,
553         "Metric of interface or route", HFILL }},
554     { &hf_zebra_mtu,
555       { "MTU",                  "zebra.mtu",
556         FT_UINT32, BASE_DEC, NULL, 0x0,
557         "MTU of interface", HFILL }},
558     { &hf_zebra_bandwidth,
559       { "Bandwidth",            "zebra.bandwidth",
560         FT_UINT32, BASE_DEC, NULL, 0x0,
561         "Bandwidth of interface", HFILL }},
562     { &hf_zebra_family,
563       { "Family",               "zebra.family",
564         FT_UINT32, BASE_DEC, VALS(families), 0x0,
565         "Family of IP address", HFILL }},
566     { &hf_zebra_dest4,
567       { "Destination",          "zebra.dest4",
568         FT_IPv4, BASE_NONE, NULL, 0x0,
569         "Destination IPv4 field", HFILL }},
570     { &hf_zebra_dest6,
571       { "Destination",          "zebra.dest6",
572         FT_IPv6, BASE_NONE, NULL, 0x0,
573         "Destination IPv6 field", HFILL }},
574     { &hf_zebra_nexthopnum,
575       { "Nexthop Number",       "zebra.nexthopnum",
576         FT_UINT8, BASE_DEC, NULL, 0x0,
577         "Number of nexthops in route", HFILL }},
578     { &hf_zebra_nexthop4,
579       { "Nexthop",              "zebra.nexthop4",
580         FT_IPv4, BASE_NONE, NULL, 0x0,
581         "Nethop IPv4 field of route", HFILL }},
582     { &hf_zebra_nexthop6,
583       { "Nexthop",              "zebra.nexthop6",
584         FT_IPv6, BASE_NONE, NULL, 0x0,
585         "Nethop IPv6 field of route", HFILL }},
586     { &hf_zebra_prefixlen,
587       { "Prefix length",        "zebra.prefixlen",
588         FT_UINT32, BASE_DEC, NULL, 0x0,
589         "Prefix length", HFILL }},
590     { &hf_zebra_prefix4,
591       { "Prefix",               "zebra.prefix4",
592         FT_IPv4, BASE_NONE, NULL, 0x0,
593         "Prefix IPv4", HFILL }},
594     { &hf_zebra_prefix6,
595       { "Prefix",               "zebra.prefix6",
596         FT_IPv6, BASE_NONE, NULL, 0x0,
597         "Prefix IPv6", HFILL }},
598   };
599
600   static gint *ett[] = {
601     &ett_zebra,
602     &ett_zebra_request,
603     &ett_message,
604   };
605
606   proto_zebra = proto_register_protocol("Zebra Protocol", "ZEBRA", "zebra");
607   proto_register_field_array(proto_zebra, hf, array_length(hf));
608   proto_register_subtree_array(ett, array_length(ett));
609 }
610
611 void
612 proto_reg_handoff_zebra(void)
613 {
614   dissector_handle_t zebra_handle;
615
616   zebra_handle = create_dissector_handle(dissect_zebra, proto_zebra);
617   dissector_add("tcp.port", TCP_PORT_ZEBRA, zebra_handle);
618 }