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