Small fix for dissect_ndr_nt_UNICODE_STRING_str() in packet-dcerpc-nt.c
[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.20 2002/01/24 09:20:54 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         const guint8 *prefix;
199         proto_item *ti;
200         proto_tree *msg_tree;
201
202         proto_tree_add_uint(tree, hf_zebra_len, tvb, offset, 2, len);
203         offset += 2;
204         proto_tree_add_uint(tree, hf_zebra_command, tvb, offset, 1,
205                 command);
206         offset += 1;
207         switch(command) {
208                 case ZEBRA_INTERFACE_ADD:
209                 case ZEBRA_INTERFACE_UP:
210                 case ZEBRA_INTERFACE_DOWN:
211                         if (request) break;
212                         /* Request just subscribes to messages */
213
214                         proto_tree_add_item(tree, hf_zebra_interface, 
215                                 tvb, offset, INTERFACE_NAMSIZ, FALSE);
216                         offset += INTERFACE_NAMSIZ;
217
218                         proto_tree_add_item(tree, hf_zebra_index, tvb,
219                                  offset, 4, FALSE);
220                         offset += 4;
221
222                         proto_tree_add_item(tree, hf_zebra_intflags, tvb,
223                                  offset, 4, FALSE);
224                         offset += 4;
225                         
226                         proto_tree_add_item(tree, hf_zebra_metric, tvb,
227                                  offset, 4, FALSE);
228                         offset += 4;
229
230                         proto_tree_add_item(tree, hf_zebra_mtu, tvb,
231                                  offset, 4, FALSE);
232                         offset += 4;
233
234                         proto_tree_add_item(tree, hf_zebra_bandwidth, tvb,
235                                  offset, 4, FALSE);
236                         offset += 4;
237
238                         break;
239                 case ZEBRA_INTERFACE_DELETE:
240                         proto_tree_add_item(tree, hf_zebra_interface,
241                                 tvb, offset, INTERFACE_NAMSIZ, FALSE);
242                         offset += INTERFACE_NAMSIZ;
243
244                         proto_tree_add_item(tree, hf_zebra_index, tvb,
245                                  offset, 4, FALSE);
246                         offset += 4;
247                         break;
248                 case ZEBRA_INTERFACE_ADDRESS_ADD:
249                 case ZEBRA_INTERFACE_ADDRESS_DELETE:
250                         proto_tree_add_item(tree, hf_zebra_index, tvb,
251                                  offset, 4, FALSE);
252                         offset += 4;
253
254                         proto_tree_add_item(tree, hf_zebra_family, tvb,
255                                  offset, 1, FALSE);
256                         offset += 1;
257
258                         if (len == 17) { /* IPv4 */
259                                 proto_tree_add_item(tree, hf_zebra_prefix4,
260                                         tvb, offset, 4, FALSE);
261                                 offset += 4;
262                         }
263                         else if (len == 41) { /* IPv6 */
264                                 proto_tree_add_item(tree, hf_zebra_prefix6,
265                                         tvb, offset, 16, FALSE);
266                                 offset += 16;
267                         }
268                         else break;
269
270                         proto_tree_add_item(tree, hf_zebra_prefixlen, tvb,
271                                  offset, 1, FALSE);
272                         offset += 1;
273
274                         if (len == 17) { /* IPv4 */
275                                 proto_tree_add_item(tree, hf_zebra_dest4,
276                                         tvb, offset, 4, FALSE);
277                                 offset += 4;
278                         }
279                         else if (len == 41) { /* IPv6 */
280                                 proto_tree_add_item(tree, hf_zebra_dest6,
281                                         tvb, offset, 16, FALSE);
282                                 offset += 16;
283                         }
284                         break;
285
286                 case ZEBRA_IPV4_ROUTE_ADD:
287                 case ZEBRA_IPV4_ROUTE_DELETE:
288                         proto_tree_add_item(tree, hf_zebra_type, tvb,
289                                  offset, 1, FALSE);
290                         offset += 1;
291
292                         proto_tree_add_item(tree, hf_zebra_rtflags, tvb,
293                                  offset, 1, FALSE);
294                         offset += 1;
295
296                         message = tvb_get_guint8(tvb, offset);
297                         ti = proto_tree_add_uint(tree, hf_zebra_message, tvb,
298                                  offset, 1, message);
299                         msg_tree = proto_item_add_subtree(ti, ett_message);
300                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_nexthop,
301                                 tvb, offset, 1, message);
302                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_index,
303                                 tvb, offset, 1, message);
304                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_distance,
305                                 tvb, offset, 1, message);
306                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_metric,
307                                 tvb, offset, 1, message);
308                         offset += 1;
309
310                         prefixlen = tvb_get_guint8(tvb, offset);
311                         proto_tree_add_uint(tree, hf_zebra_prefixlen, tvb,
312                                  offset, 1, prefixlen);
313                         offset += 1;
314
315                         prefix = tvb_get_ptr(tvb, offset, PSIZE(prefixlen));
316                         prefix4 = 0;
317                         memcpy(&prefix4, prefix,
318                             MIN((unsigned) PSIZE(prefixlen), sizeof prefix4));
319                         proto_tree_add_ipv4(tree, hf_zebra_prefix4,
320                                 tvb, offset, PSIZE(prefixlen), prefix4);
321                         offset += PSIZE(prefixlen);
322
323                         if (message & ZEBRA_ZAPI_MESSAGE_NEXTHOP) {
324                                 i = tvb_get_guint8(tvb, offset);
325                                 proto_tree_add_uint(tree, hf_zebra_nexthopnum,
326                                         tvb, offset, 1, i);
327                                 offset += 1;
328
329                                 if (i>len) break; /* Sanity */
330
331                                 while (i--) {
332                                         proto_tree_add_item(tree,
333                                                 hf_zebra_nexthop4, tvb,
334                                                 offset, 4, FALSE);
335                                         offset += 4;
336                                 }
337                         }
338                         if (message & ZEBRA_ZAPI_MESSAGE_IFINDEX) {
339                                 i = tvb_get_guint8(tvb, offset);
340                                 proto_tree_add_uint(tree, hf_zebra_indexnum,
341                                         tvb, offset, 1, i);
342                                 offset += 1;
343
344                                 if (i>len) break; /* Sanity */
345
346                                 while (i--) {
347                                         proto_tree_add_item(tree,
348                                                 hf_zebra_index, tvb,
349                                                 offset, 4, FALSE);
350                                         offset += 4;
351                                 }
352                         }
353                         if (message & ZEBRA_ZAPI_MESSAGE_DISTANCE) {
354                                 proto_tree_add_item(tree, hf_zebra_distance,
355                                         tvb, offset, 1, FALSE);
356                                 offset += 1;
357                         }
358                         if (message & ZEBRA_ZAPI_MESSAGE_METRIC) {
359                                 proto_tree_add_item(tree, hf_zebra_metric,
360                                         tvb, offset, 4, FALSE);
361                                 offset += 4;
362                         }
363                         break;
364                 case ZEBRA_IPV6_ROUTE_ADD:
365                 case ZEBRA_IPV6_ROUTE_DELETE:
366                         proto_tree_add_item(tree, hf_zebra_type, tvb,
367                                  offset, 1, FALSE);
368                         offset += 1;
369
370                         proto_tree_add_item(tree, hf_zebra_rtflags, tvb,
371                                  offset, 1, FALSE);
372                         offset += 1;
373
374                         message = tvb_get_guint8(tvb, offset);
375                         ti = proto_tree_add_uint(tree, hf_zebra_message, tvb,
376                                  offset, 1, message);
377                         msg_tree = proto_item_add_subtree(ti, ett_message);
378                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_nexthop,
379                                 tvb, offset, 1, message);
380                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_index,
381                                 tvb, offset, 1, message);
382                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_distance,
383                                 tvb, offset, 1, message);
384                         proto_tree_add_boolean(msg_tree, hf_zebra_msg_metric,
385                                 tvb, offset, 1, message);
386                         offset += 1;
387
388                         prefixlen = tvb_get_guint8(tvb, offset);
389                         proto_tree_add_uint(tree, hf_zebra_prefixlen, tvb,
390                                  offset, 1, prefixlen);
391                         offset += 1;
392
393                         prefix = tvb_get_ptr(tvb, offset, PSIZE(prefixlen));
394                         memset(buffer6, '\0', sizeof buffer6);
395                         memcpy(buffer6, prefix,
396                             MIN((unsigned) PSIZE(prefixlen), sizeof buffer6));
397                         proto_tree_add_ipv6(tree, hf_zebra_prefix6,
398                                 tvb, offset, PSIZE(prefixlen), buffer6);
399                         offset += PSIZE(prefixlen);
400
401                         if (message & ZEBRA_ZAPI_MESSAGE_NEXTHOP) {
402                                 i = tvb_get_guint8(tvb, offset);
403                                 proto_tree_add_uint(tree, hf_zebra_nexthopnum,
404                                         tvb, offset, 1, i);
405                                 offset += 1;
406
407                                 if (i>len) break; /* Sanity */
408
409                                 while (i--) {
410                                         proto_tree_add_item(tree,
411                                                 hf_zebra_nexthop6, tvb,
412                                                 offset, 16, FALSE);
413                                         offset += 16;
414                                 }
415                         }
416                         if (message & ZEBRA_ZAPI_MESSAGE_IFINDEX) {
417                                 i = tvb_get_guint8(tvb, offset);
418                                 proto_tree_add_uint(tree, hf_zebra_indexnum,
419                                         tvb, offset, 1, i);
420                                 offset += 1;
421
422                                 if (i>len) break; /* Sanity */
423
424                                 while (i--) {
425                                         proto_tree_add_item(tree,
426                                                 hf_zebra_index, tvb,
427                                                 offset, 4, FALSE);
428                                         offset += 4;
429                                 }
430                         }
431                         if (message & ZEBRA_ZAPI_MESSAGE_DISTANCE) {
432                                 proto_tree_add_item(tree, hf_zebra_distance,
433                                         tvb, offset, 1, FALSE);
434                                 offset += 1;
435                         }
436                         if (message & ZEBRA_ZAPI_MESSAGE_METRIC) {
437                                 proto_tree_add_item(tree, hf_zebra_metric,
438                                         tvb, offset, 4, FALSE);
439                                 offset += 4;
440                         }
441                         break;
442                 case ZEBRA_REDISTRIBUTE_ADD:
443                 case ZEBRA_REDISTRIBUTE_DELETE:
444                         proto_tree_add_item(tree, hf_zebra_type, tvb,
445                                  offset, 1, FALSE);
446                         offset += 1;
447                         break;
448                 case ZEBRA_REDISTRIBUTE_DEFAULT_ADD:
449                 case ZEBRA_REDISTRIBUTE_DEFAULT_DELETE:
450                         break;
451                 case ZEBRA_IPV4_NEXTHOP_LOOKUP:
452                         proto_tree_add_item(tree, hf_zebra_nexthop4,
453                                 tvb, offset, 4, FALSE);
454                         offset += 4;
455
456                         proto_tree_add_item(tree, hf_zebra_metric,
457                                 tvb, offset, 4, FALSE);
458                         offset += 4;
459                         break;
460                 case ZEBRA_IPV6_NEXTHOP_LOOKUP:
461                         /* Not yet implemeted in ZEBRA */
462                         break;
463         }
464 }
465                 
466 static void
467 dissect_zebra(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
468 {
469         proto_item      *ti;
470         proto_tree      *zebra_tree;
471         gboolean        request;
472         int             left, offset;
473
474         if (check_col(pinfo->cinfo, COL_PROTOCOL))
475                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZEBRA");
476
477         request = (pinfo->destport == pinfo->match_port);
478         left = tvb_reported_length(tvb);
479         offset = 0;
480
481         if (check_col(pinfo->cinfo, COL_INFO)) {
482                 col_set_str(pinfo->cinfo, COL_INFO, 
483                         request? "ZEBRA Request" : "ZEBRA Reply");
484         }
485         if (tree) {
486                 ti = proto_tree_add_item(tree, proto_zebra, tvb, offset, -1,
487                         FALSE);
488                 zebra_tree = proto_item_add_subtree(ti, ett_zebra);
489                 proto_tree_add_boolean_hidden(zebra_tree, hf_zebra_request,
490                         tvb, offset, 0, request);
491
492                 for (;;) {
493                         guint8          command;
494                         guint16         len;
495                         proto_tree      *zebra_request_tree;
496                         
497                         if (left < 3) break;
498
499                         len = tvb_get_ntohs(tvb, offset);
500                         if (len < 3) break;
501
502                         command = tvb_get_guint8(tvb, offset+2);
503
504                         ti = proto_tree_add_uint(zebra_tree,
505                                 hf_zebra_command, tvb, offset, len,
506                                 command);
507                         zebra_request_tree = proto_item_add_subtree(ti,
508                                 ett_zebra_request);
509                         dissect_zebra_request(zebra_request_tree, request, tvb,
510                                 offset, len, command);
511
512                         offset += len;
513                         left -= len;
514                 }
515         }
516 }
517
518 void
519 proto_register_zebra(void)
520 {
521
522   static hf_register_info hf[] = {
523     { &hf_zebra_len,
524       { "Length",               "zebra.len",
525         FT_UINT16, BASE_DEC, NULL, 0x0,
526         "Length of ZEBRA request", HFILL }},
527     { &hf_zebra_request,
528       { "Request",              "zebra.request",
529         FT_BOOLEAN, BASE_NONE, NULL, 0x0,
530         "TRUE if ZEBRA request", HFILL }},
531     { &hf_zebra_command,
532       { "Command",              "zebra.command",
533         FT_UINT8, BASE_DEC, VALS(messages), 0x0,
534         "ZEBRA command", HFILL }},
535     { &hf_zebra_interface,
536       { "Interface",            "zebra.interface",
537         FT_STRING, BASE_NONE, NULL, 0x0,
538         "Interface name of ZEBRA request", HFILL }},
539     { &hf_zebra_index,
540       { "Index",                "zebra.index",
541         FT_UINT32, BASE_DEC, NULL, 0x0,
542         "Index of interface", HFILL }},
543     { &hf_zebra_indexnum,
544       { "Index Number",         "zebra.indexnum",
545         FT_UINT8, BASE_DEC, NULL, 0x0,
546         "Number of indices for route", HFILL }},
547     { &hf_zebra_intflags,
548       { "Flags",                "zebra.intflags",
549         FT_UINT32, BASE_DEC, NULL, 0x0,
550         "Flags of interface", HFILL }},
551     { &hf_zebra_rtflags,
552       { "Flags",                "zebra.rtflags",
553         FT_UINT8, BASE_DEC, NULL, 0x0,
554         "Flags of route", HFILL }},
555     { &hf_zebra_message,
556       { "Message",              "zebra.message",
557         FT_UINT8, BASE_DEC, NULL, 0x0,
558         "Message type of route", HFILL }},
559     { &hf_zebra_msg_nexthop,
560       { "Message Nexthop",      "zebra.message.nexthop",
561         FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_NEXTHOP,
562         "Message contains nexthop", HFILL }},
563     { &hf_zebra_msg_index,
564       { "Message Index",        "zebra.message.index",
565         FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_IFINDEX,
566         "Message contains index", HFILL }},
567     { &hf_zebra_msg_distance,
568       { "Message Distance",     "zebra.message.distance",
569         FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_DISTANCE,
570         "Message contains distance", HFILL }},
571     { &hf_zebra_msg_metric,
572       { "Message Metric",       "zebra.message.metric",
573         FT_BOOLEAN, 8, NULL, ZEBRA_ZAPI_MESSAGE_METRIC,
574         "Message contains metric", HFILL }},
575     { &hf_zebra_type,
576       { "Type",                 "zebra.type",
577         FT_UINT8, BASE_DEC, VALS(routes), 0x0,
578         "Type of route", HFILL }},
579     { &hf_zebra_distance,
580       { "Distance",             "zebra.distance",
581         FT_UINT8, BASE_DEC, NULL, 0x0,
582         "Distance of route", HFILL }},
583     { &hf_zebra_metric,
584       { "Metric",               "zebra.metric",
585         FT_UINT32, BASE_DEC, NULL, 0x0,
586         "Metric of interface or route", HFILL }},
587     { &hf_zebra_mtu,
588       { "MTU",                  "zebra.mtu",
589         FT_UINT32, BASE_DEC, NULL, 0x0,
590         "MTU of interface", HFILL }},
591     { &hf_zebra_bandwidth,
592       { "Bandwidth",            "zebra.bandwidth",
593         FT_UINT32, BASE_DEC, NULL, 0x0,
594         "Bandwidth of interface", HFILL }},
595     { &hf_zebra_family,
596       { "Family",               "zebra.family",
597         FT_UINT32, BASE_DEC, NULL, 0x0,
598         "Family of IP address", HFILL }},
599     { &hf_zebra_dest4,
600       { "Destination",          "zebra.dest4",
601         FT_IPv4, BASE_NONE, NULL, 0x0,
602         "Destination IPv4 field", HFILL }},
603     { &hf_zebra_dest6,
604       { "Destination",          "zebra.dest6",
605         FT_IPv6, BASE_NONE, NULL, 0x0,
606         "Destination IPv6 field", HFILL }},
607     { &hf_zebra_nexthopnum,
608       { "Nexthop Number",       "zebra.nexthopnum",
609         FT_UINT8, BASE_DEC, NULL, 0x0,
610         "Number of nexthops in route", HFILL }},
611     { &hf_zebra_nexthop4,
612       { "Nexthop",              "zebra.nexthop4",
613         FT_IPv4, BASE_NONE, NULL, 0x0,
614         "Nethop IPv4 field of route", HFILL }},
615     { &hf_zebra_nexthop6,
616       { "Nexthop",              "zebra.nexthop6",
617         FT_IPv6, BASE_NONE, NULL, 0x0,
618         "Nethop IPv6 field of route", HFILL }},
619     { &hf_zebra_prefixlen,
620       { "Prefix length",        "zebra.prefixlen",
621         FT_UINT32, BASE_DEC, NULL, 0x0,
622         "Prefix length", HFILL }},
623     { &hf_zebra_prefix4,
624       { "Prefix",               "zebra.prefix4",
625         FT_IPv4, BASE_NONE, NULL, 0x0,
626         "Prefix IPv4", HFILL }},
627     { &hf_zebra_prefix6,
628       { "Prefix",               "zebra.prefix6",
629         FT_IPv6, BASE_NONE, NULL, 0x0,
630         "Prefix IPv6", HFILL }},
631   };
632
633   static gint *ett[] = {
634     &ett_zebra,
635     &ett_zebra_request,
636     &ett_message,
637   };
638
639   proto_zebra = proto_register_protocol("Zebra Protocol", "ZEBRA", "zebra");
640   proto_register_field_array(proto_zebra, hf, array_length(hf));
641   proto_register_subtree_array(ett, array_length(ett));
642 }
643
644 void
645 proto_reg_handoff_zebra(void)
646 {
647   dissector_handle_t zebra_handle;
648
649   zebra_handle = create_dissector_handle(dissect_zebra, proto_zebra);
650   dissector_add("tcp.port", TCP_PORT_ZEBRA, zebra_handle);
651 }