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