]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/rfapi/rfapi_encap_tlv.c
Merge remote-tracking branch 'origin/master' into evpn_plus_struct_attr
[mirror_frr.git] / bgpd / rfapi / rfapi_encap_tlv.c
1 /*
2 * Copyright 2015-2016, LabN Consulting, L.L.C.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; see the file COPYING; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include "lib/zebra.h"
20
21 #include "lib/memory.h"
22 #include "lib/prefix.h"
23 #include "lib/table.h"
24 #include "lib/vty.h"
25
26 #include "bgpd/bgpd.h"
27 #include "bgpd/bgp_attr.h"
28
29 #include "bgpd/bgp_encap_types.h"
30 #include "bgpd/bgp_encap_tlv.h"
31
32 #include "bgpd/rfapi/rfapi.h"
33 #include "bgpd/rfapi/rfapi_encap_tlv.h"
34 #include "bgpd/rfapi/rfapi_private.h"
35 #include "bgpd/rfapi/rfapi_monitor.h"
36 #include "bgpd/rfapi/rfapi_vty.h"
37 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
38 #include "bgpd/rfapi/vnc_debug.h"
39
40 static void
41 rfapi_add_endpoint_address_to_subtlv (
42 struct bgp *bgp,
43 struct rfapi_ip_addr *ea,
44 struct bgp_tea_subtlv_remote_endpoint *subtlv)
45 {
46 subtlv->family = ea->addr_family;
47 if (subtlv->family == AF_INET)
48 subtlv->ip_address.v4 = ea->addr.v4;
49 else
50 subtlv->ip_address.v6 = ea->addr.v6;
51 subtlv->as4 = htonl (bgp->as);
52 }
53
54 bgp_encap_types
55 rfapi_tunneltype_option_to_tlv (
56 struct bgp *bgp,
57 struct rfapi_ip_addr *ea,
58 struct rfapi_tunneltype_option *tto,
59 struct attr *attr,
60 int always_add)
61 {
62
63 #define _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS(ttype) \
64 if ((always_add || (bgp->rfapi_cfg && \
65 !CHECK_FLAG(bgp->rfapi_cfg->flags, \
66 BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP))) && \
67 ea && !CHECK_SUBTLV_FLAG(&tto->bgpinfo.ttype, \
68 BGP_TEA_SUBTLV_REMOTE_ENDPOINT)) { \
69 rfapi_add_endpoint_address_to_subtlv(bgp, ea, \
70 &tto->bgpinfo.ttype.st_endpoint); \
71 SET_SUBTLV_FLAG(&tto->bgpinfo.ttype, BGP_TEA_SUBTLV_REMOTE_ENDPOINT); \
72 }
73
74 struct rfapi_tunneltype_option dto;
75 if (tto == NULL)
76 { /* create default type */
77 tto = &dto;
78 memset (tto, 0, sizeof (dto));
79 tto->type = RFAPI_BGP_ENCAP_TYPE_DEFAULT;
80 }
81 switch (tto->type)
82 {
83 case BGP_ENCAP_TYPE_L2TPV3_OVER_IP:
84 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (l2tpv3_ip);
85 bgp_encap_type_l2tpv3overip_to_tlv (&tto->bgpinfo.l2tpv3_ip, attr);
86 break;
87
88 case BGP_ENCAP_TYPE_GRE:
89 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (gre);
90 bgp_encap_type_gre_to_tlv (&tto->bgpinfo.gre, attr);
91 break;
92
93 case BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT:
94 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (transmit_tunnel_endpoint);
95 bgp_encap_type_transmit_tunnel_endpoint (&tto->bgpinfo.transmit_tunnel_endpoint,
96 attr);
97 break;
98
99 case BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE:
100 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (ipsec_tunnel);
101 bgp_encap_type_ipsec_in_tunnel_mode_to_tlv (&tto->bgpinfo.ipsec_tunnel,
102 attr);
103 break;
104
105 case BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE:
106 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (ip_ipsec);
107 bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode_to_tlv
108 (&tto->bgpinfo.ip_ipsec, attr);
109 break;
110
111 case BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE:
112 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (mpls_ipsec);
113 bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode_to_tlv
114 (&tto->bgpinfo.mpls_ipsec, attr);
115 break;
116
117 case BGP_ENCAP_TYPE_IP_IN_IP:
118 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (ip_ip);
119 bgp_encap_type_ip_in_ip_to_tlv (&tto->bgpinfo.ip_ip, attr);
120 break;
121
122 case BGP_ENCAP_TYPE_VXLAN:
123 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (vxlan);
124 bgp_encap_type_vxlan_to_tlv (&tto->bgpinfo.vxlan, attr);
125 break;
126
127 case BGP_ENCAP_TYPE_NVGRE:
128 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (nvgre);
129 bgp_encap_type_nvgre_to_tlv (&tto->bgpinfo.nvgre, attr);
130 break;
131
132 case BGP_ENCAP_TYPE_MPLS:
133 /* nothing to do for MPLS */
134 break;
135
136 case BGP_ENCAP_TYPE_MPLS_IN_GRE:
137 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (mpls_gre);
138 bgp_encap_type_mpls_in_gre_to_tlv (&tto->bgpinfo.mpls_gre, attr);
139 break;
140
141 case BGP_ENCAP_TYPE_VXLAN_GPE:
142 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (vxlan_gpe);
143 bgp_encap_type_vxlan_gpe_to_tlv (&tto->bgpinfo.vxlan_gpe, attr);
144 break;
145
146 case BGP_ENCAP_TYPE_MPLS_IN_UDP:
147 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (mpls_udp);
148 bgp_encap_type_mpls_in_udp_to_tlv (&tto->bgpinfo.mpls_udp, attr);
149 break;
150
151 case BGP_ENCAP_TYPE_PBB:
152 _RTTO_MAYBE_ADD_ENDPOINT_ADDRESS (pbb);
153 bgp_encap_type_pbb_to_tlv (&tto->bgpinfo.pbb, attr);
154 break;
155
156 default:
157 assert (0);
158 }
159 return tto->type;
160 }
161
162 struct rfapi_un_option *
163 rfapi_encap_tlv_to_un_option (struct attr *attr)
164 {
165 struct rfapi_un_option *uo = NULL;
166 struct rfapi_tunneltype_option *tto;
167 int rc;
168 struct bgp_attr_encap_subtlv *stlv;
169
170 /* no tunnel encap attr stored */
171 if (!attr->encap_tunneltype)
172 return NULL;
173
174 stlv = attr->encap_subtlvs;
175
176 uo = XCALLOC (MTYPE_RFAPI_UN_OPTION, sizeof (struct rfapi_un_option));
177 assert (uo);
178 uo->type = RFAPI_UN_OPTION_TYPE_TUNNELTYPE;
179 uo->v.tunnel.type = attr->encap_tunneltype;
180 tto = &uo->v.tunnel;
181
182 switch (attr->encap_tunneltype)
183 {
184 case BGP_ENCAP_TYPE_L2TPV3_OVER_IP:
185 rc = tlv_to_bgp_encap_type_l2tpv3overip (stlv, &tto->bgpinfo.l2tpv3_ip);
186 break;
187
188 case BGP_ENCAP_TYPE_GRE:
189 rc = tlv_to_bgp_encap_type_gre (stlv, &tto->bgpinfo.gre);
190 break;
191
192 case BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT:
193 rc = tlv_to_bgp_encap_type_transmit_tunnel_endpoint (stlv,
194 &tto->bgpinfo.transmit_tunnel_endpoint);
195 break;
196
197 case BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE:
198 rc = tlv_to_bgp_encap_type_ipsec_in_tunnel_mode (stlv,
199 &tto->bgpinfo.ipsec_tunnel);
200 break;
201
202 case BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE:
203 rc =
204 tlv_to_bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode (stlv,
205 &tto->bgpinfo.ip_ipsec);
206 break;
207
208 case BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE:
209 rc =
210 tlv_to_bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode
211 (stlv, &tto->bgpinfo.mpls_ipsec);
212 break;
213
214 case BGP_ENCAP_TYPE_IP_IN_IP:
215 rc = tlv_to_bgp_encap_type_ip_in_ip (stlv, &tto->bgpinfo.ip_ip);
216 break;
217
218 case BGP_ENCAP_TYPE_VXLAN:
219 rc = tlv_to_bgp_encap_type_vxlan (stlv, &tto->bgpinfo.vxlan);
220 break;
221
222 case BGP_ENCAP_TYPE_NVGRE:
223 rc = tlv_to_bgp_encap_type_nvgre (stlv, &tto->bgpinfo.nvgre);
224 break;
225
226 case BGP_ENCAP_TYPE_MPLS:
227 rc = tlv_to_bgp_encap_type_mpls (stlv, &tto->bgpinfo.mpls);
228 break;
229
230 case BGP_ENCAP_TYPE_MPLS_IN_GRE:
231 rc = tlv_to_bgp_encap_type_mpls_in_gre (stlv, &tto->bgpinfo.mpls_gre);
232 break;
233
234 case BGP_ENCAP_TYPE_VXLAN_GPE:
235 rc = tlv_to_bgp_encap_type_vxlan_gpe (stlv, &tto->bgpinfo.vxlan_gpe);
236 break;
237
238 case BGP_ENCAP_TYPE_MPLS_IN_UDP:
239 rc = tlv_to_bgp_encap_type_mpls_in_udp (stlv, &tto->bgpinfo.mpls_udp);
240 break;
241
242 case BGP_ENCAP_TYPE_PBB:
243 rc = tlv_to_bgp_encap_type_pbb (stlv, &tto->bgpinfo.pbb);
244 break;
245
246 default:
247 vnc_zlog_debug_verbose ("%s: unknown tunnel type %d",
248 __func__, attr->encap_tunneltype);
249 rc = -1;
250 break;
251 }
252 if (rc)
253 {
254 XFREE (MTYPE_RFAPI_UN_OPTION, uo);
255 uo = NULL;
256 }
257 return uo;
258 }
259
260 /***********************************************************************
261 * SUBTLV PRINT
262 ***********************************************************************/
263
264 static void
265 subtlv_print_encap_l2tpv3_over_ip (
266 void *stream,
267 int column_offset,
268 struct bgp_tea_subtlv_encap_l2tpv3_over_ip *st)
269 {
270 int (*fp) (void *, const char *, ...);
271 struct vty *vty;
272 void *out;
273 const char *vty_newline;
274
275 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
276 return;
277 if (!st)
278 return;
279
280 fp (out, "%*s%s%s", column_offset, "", "SubTLV: Encap(L2TPv3 over IP)",
281 vty_newline);
282 fp (out, "%*s SessionID: %d%s", column_offset, "", st->sessionid,
283 vty_newline);
284 fp (out, "%*s Cookie: (length %d)%s", column_offset, "", st->cookie_length,
285 vty_newline);
286 }
287
288 static void
289 subtlv_print_encap_gre (
290 void *stream,
291 int column_offset,
292 struct bgp_tea_subtlv_encap_gre_key *st)
293 {
294 int (*fp) (void *, const char *, ...);
295 struct vty *vty;
296 void *out;
297 const char *vty_newline;
298
299 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
300 return;
301 if (!st)
302 return;
303
304 fp (out, "%*s%s%s", column_offset, "", "SubTLV: Encap(GRE)", vty_newline);
305 fp (out, "%*s GRE key: %d (0x%x)%s", column_offset, "", st->gre_key,
306 st->gre_key, vty_newline);
307 }
308
309 static void
310 subtlv_print_encap_pbb (
311 void *stream,
312 int column_offset,
313 struct bgp_tea_subtlv_encap_pbb *st)
314 {
315 int (*fp) (void *, const char *, ...);
316 struct vty *vty;
317 void *out;
318 const char *vty_newline;
319
320 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
321 return;
322 if (!st)
323 return;
324
325 fp (out, "%*s%s%s", column_offset, "", "SubTLV: Encap(PBB)", vty_newline);
326 if (st->flag_isid)
327 {
328 fp (out, "%*s ISID: %d (0x%x)%s", column_offset, "", st->isid,
329 st->isid, vty_newline);
330 }
331 if (st->flag_vid)
332 {
333 fp (out, "%*s VID: %d (0x%x)%s", column_offset, "", st->vid, st->vid,
334 vty_newline);
335 }
336 fp (out, "%*s MACADDR %02x:%02x:%02x:%02x:%02x:%02x%s",
337 column_offset, "",
338 st->macaddr[0],
339 st->macaddr[1],
340 st->macaddr[2],
341 st->macaddr[3], st->macaddr[4], st->macaddr[5], vty_newline);
342 }
343
344 static void
345 subtlv_print_proto_type (
346 void *stream,
347 int column_offset,
348 struct bgp_tea_subtlv_proto_type *st)
349 {
350 int (*fp) (void *, const char *, ...);
351 struct vty *vty;
352 void *out;
353 const char *vty_newline;
354
355 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
356 return;
357 if (!st)
358 return;
359
360 fp (out, "%*s%s%s", column_offset, "", "SubTLV: Encap(Proto Type)",
361 vty_newline);
362 fp (out, "%*s Proto %d (0x%x)%s", column_offset, "", st->proto, st->proto,
363 vty_newline);
364 }
365
366 static void
367 subtlv_print_color (
368 void *stream,
369 int column_offset,
370 struct bgp_tea_subtlv_color *st)
371 {
372 int (*fp) (void *, const char *, ...);
373 struct vty *vty;
374 void *out;
375 const char *vty_newline;
376
377 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
378 return;
379 if (!st)
380 return;
381
382 fp (out, "%*s%s%s", column_offset, "", "SubTLV: Color", vty_newline);
383 fp (out, "%*s Color: %d (0x%x)", column_offset, "", st->color, st->color,
384 vty_newline);
385 }
386
387 static void
388 subtlv_print_ipsec_ta (
389 void *stream,
390 int column_offset,
391 struct bgp_tea_subtlv_ipsec_ta *st)
392 {
393 int (*fp) (void *, const char *, ...);
394 struct vty *vty;
395 void *out;
396 const char *vty_newline;
397
398 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
399 return;
400 if (!st)
401 return;
402
403 fp (out, "%*s%s%s", column_offset, "", "SubTLV: IPSEC TA", vty_newline);
404 fp (out, "%*s Authenticator Type: %d (0x%x)", column_offset, "",
405 st->authenticator_type, st->authenticator_type, vty_newline);
406 fp (out, "%*s Authenticator: (length %d)", column_offset, "",
407 st->authenticator_length, vty_newline);
408 }
409
410 /***********************************************************************
411 * TLV PRINT
412 ***********************************************************************/
413
414 static void
415 print_encap_type_l2tpv3overip (
416 void *stream,
417 int column_offset,
418 struct bgp_encap_type_l2tpv3_over_ip *bet)
419 {
420 const char *type = "L2TPv3 over IP";
421 int (*fp) (void *, const char *, ...);
422 struct vty *vty;
423 void *out;
424 const char *vty_newline;
425
426 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
427 return;
428 if (!bet)
429 return;
430
431 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
432
433 subtlv_print_encap_l2tpv3_over_ip (stream, column_offset + 2,
434 &bet->st_encap);
435 subtlv_print_proto_type (stream, column_offset + 2, &bet->st_proto);
436 subtlv_print_color (stream, column_offset + 2, &bet->st_color);
437 }
438
439 static void
440 print_encap_type_gre (
441 void *stream,
442 int column_offset,
443 struct bgp_encap_type_gre *bet)
444 {
445 const char *type = "GRE";
446 int (*fp) (void *, const char *, ...);
447 struct vty *vty;
448 void *out;
449 const char *vty_newline;
450
451 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
452 return;
453 if (!bet)
454 return;
455
456 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
457
458 subtlv_print_encap_gre (stream, column_offset + 2, &bet->st_encap);
459 subtlv_print_proto_type (stream, column_offset + 2, &bet->st_proto);
460 subtlv_print_color (stream, column_offset + 2, &bet->st_color);
461 }
462
463 static void
464 print_encap_type_ip_in_ip (
465 void *stream,
466 int column_offset,
467 struct bgp_encap_type_ip_in_ip *bet)
468 {
469 const char *type = "IP in IP";
470 int (*fp) (void *, const char *, ...);
471 struct vty *vty;
472 void *out;
473 const char *vty_newline;
474
475 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
476 return;
477 if (!bet)
478 return;
479
480 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
481
482 subtlv_print_proto_type (stream, column_offset + 2, &bet->st_proto);
483 subtlv_print_color (stream, column_offset + 2, &bet->st_color);
484 }
485
486 static void
487 print_encap_type_transmit_tunnel_endpoint (
488 void *stream,
489 int column_offset,
490 struct bgp_encap_type_transmit_tunnel_endpoint *bet)
491 {
492 const char *type = "Transmit Tunnel Endpoint";
493 int (*fp) (void *, const char *, ...);
494 struct vty *vty;
495 void *out;
496 const char *vty_newline;
497
498 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
499 return;
500 if (!bet)
501 return;
502
503 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
504
505 /* no subtlvs for this type */
506 }
507
508 static void
509 print_encap_type_ipsec_in_tunnel_mode (
510 void *stream,
511 int column_offset,
512 struct bgp_encap_type_ipsec_in_tunnel_mode *bet)
513 {
514 const char *type = "IPSEC in Tunnel mode";
515 int (*fp) (void *, const char *, ...);
516 struct vty *vty;
517 void *out;
518 const char *vty_newline;
519
520 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
521 return;
522 if (!bet)
523 return;
524
525 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
526 subtlv_print_ipsec_ta (stream, column_offset + 2, &bet->st_ipsec_ta);
527 }
528
529 static void
530 print_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode (
531 void *stream,
532 int column_offset,
533 struct bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode *bet)
534 {
535 const char *type = "IP in IP Tunnel with IPSEC transport mode";
536 int (*fp) (void *, const char *, ...);
537 struct vty *vty;
538 void *out;
539 const char *vty_newline;
540
541 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
542 return;
543 if (!bet)
544 return;
545
546 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
547
548 subtlv_print_ipsec_ta (stream, column_offset + 2, &bet->st_ipsec_ta);
549 }
550
551 static void
552 print_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode (
553 void *stream,
554 int column_offset,
555 struct bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode *bet)
556 {
557 const char *type = "MPLS in IP Tunnel with IPSEC transport mode";
558 int (*fp) (void *, const char *, ...);
559 struct vty *vty;
560 void *out;
561 const char *vty_newline;
562
563 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
564 return;
565 if (!bet)
566 return;
567
568 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
569
570 subtlv_print_ipsec_ta (stream, column_offset + 2, &bet->st_ipsec_ta);
571 }
572
573
574 static void
575 print_encap_type_pbb (
576 void *stream,
577 int column_offset,
578 struct bgp_encap_type_pbb *bet)
579 {
580 const char *type = "PBB";
581 int (*fp) (void *, const char *, ...);
582 struct vty *vty;
583 void *out;
584 const char *vty_newline;
585
586 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
587 return;
588 if (!bet)
589 return;
590
591 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
592
593 subtlv_print_encap_pbb (stream, column_offset + 2, &bet->st_encap);
594 }
595
596
597 static void
598 print_encap_type_vxlan (
599 void *stream,
600 int column_offset,
601 struct bgp_encap_type_vxlan *bet)
602 {
603 const char *type = "VXLAN";
604 int (*fp) (void *, const char *, ...);
605 struct vty *vty;
606 void *out;
607 const char *vty_newline;
608
609 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
610 return;
611 if (!bet)
612 return;
613
614 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
615
616 /* no subtlvs for this type */
617 }
618
619
620 static void
621 print_encap_type_nvgre (
622 void *stream,
623 int column_offset,
624 struct bgp_encap_type_nvgre *bet)
625 {
626 const char *type = "NVGRE";
627 int (*fp) (void *, const char *, ...);
628 struct vty *vty;
629 void *out;
630 const char *vty_newline;
631
632 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
633 return;
634 if (!bet)
635 return;
636
637 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
638
639 /* no subtlvs for this type */
640 }
641
642 static void
643 print_encap_type_mpls (
644 void *stream,
645 int column_offset,
646 struct bgp_encap_type_mpls *bet)
647 {
648 const char *type = "MPLS";
649 int (*fp) (void *, const char *, ...);
650 struct vty *vty;
651 void *out;
652 const char *vty_newline;
653
654 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
655 return;
656 if (!bet)
657 return;
658
659 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
660
661 /* no subtlvs for this type */
662 }
663
664 static void
665 print_encap_type_mpls_in_gre (
666 void *stream,
667 int column_offset,
668 struct bgp_encap_type_mpls_in_gre *bet)
669 {
670 const char *type = "MPLS in GRE";
671 int (*fp) (void *, const char *, ...);
672 struct vty *vty;
673 void *out;
674 const char *vty_newline;
675
676 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
677 return;
678 if (!bet)
679 return;
680
681 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
682
683 /* no subtlvs for this type */
684 }
685
686 static void
687 print_encap_type_vxlan_gpe (
688 void *stream,
689 int column_offset,
690 struct bgp_encap_type_vxlan_gpe *bet)
691 {
692 const char *type = "VXLAN GPE";
693 int (*fp) (void *, const char *, ...);
694 struct vty *vty;
695 void *out;
696 const char *vty_newline;
697
698 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
699 return;
700 if (!bet)
701 return;
702
703 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
704
705 /* no subtlvs for this type */
706 }
707
708 static void
709 print_encap_type_mpls_in_udp (
710 void *stream,
711 int column_offset,
712 struct bgp_encap_type_mpls_in_udp *bet)
713 {
714 const char *type = "MPLS in UDP";
715 int (*fp) (void *, const char *, ...);
716 struct vty *vty;
717 void *out;
718 const char *vty_newline;
719
720 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
721 return;
722 if (!bet)
723 return;
724
725 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
726
727 /* no subtlvs for this type */
728 }
729
730 void
731 rfapi_print_tunneltype_option (
732 void *stream,
733 int column_offset,
734 struct rfapi_tunneltype_option *tto)
735 {
736 switch (tto->type)
737 {
738 case BGP_ENCAP_TYPE_L2TPV3_OVER_IP:
739 print_encap_type_l2tpv3overip (stream, column_offset,
740 &tto->bgpinfo.l2tpv3_ip);
741 break;
742
743 case BGP_ENCAP_TYPE_GRE:
744 print_encap_type_gre (stream, column_offset, &tto->bgpinfo.gre);
745 break;
746
747 case BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT:
748 print_encap_type_transmit_tunnel_endpoint (stream, column_offset,
749 &tto->bgpinfo.transmit_tunnel_endpoint);
750 break;
751
752 case BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE:
753 print_encap_type_ipsec_in_tunnel_mode (stream, column_offset,
754 &tto->bgpinfo.ipsec_tunnel);
755 break;
756
757 case BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE:
758 print_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode (stream,
759 column_offset,
760 &tto->bgpinfo.ip_ipsec);
761 break;
762
763 case BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE:
764 print_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode (stream,
765 column_offset,
766 &tto->bgpinfo.mpls_ipsec);
767 break;
768
769 case BGP_ENCAP_TYPE_IP_IN_IP:
770 print_encap_type_ip_in_ip (stream, column_offset, &tto->bgpinfo.ip_ip);
771 break;
772
773 case BGP_ENCAP_TYPE_VXLAN:
774 print_encap_type_vxlan (stream, column_offset, &tto->bgpinfo.vxlan);
775 break;
776
777 case BGP_ENCAP_TYPE_NVGRE:
778 print_encap_type_nvgre (stream, column_offset, &tto->bgpinfo.nvgre);
779 break;
780
781 case BGP_ENCAP_TYPE_MPLS:
782 print_encap_type_mpls (stream, column_offset, &tto->bgpinfo.mpls);
783 break;
784
785 case BGP_ENCAP_TYPE_MPLS_IN_GRE:
786 print_encap_type_mpls_in_gre (stream, column_offset,
787 &tto->bgpinfo.mpls_gre);
788 break;
789
790 case BGP_ENCAP_TYPE_VXLAN_GPE:
791 print_encap_type_vxlan_gpe (stream, column_offset,
792 &tto->bgpinfo.vxlan_gpe);
793 break;
794
795 case BGP_ENCAP_TYPE_MPLS_IN_UDP:
796 print_encap_type_mpls_in_udp (stream, column_offset,
797 &tto->bgpinfo.mpls_udp);
798 break;
799
800 case BGP_ENCAP_TYPE_PBB:
801 print_encap_type_pbb (stream, column_offset, &tto->bgpinfo.pbb);
802 break;
803
804 default:
805 assert (0);
806 }
807 }