]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/rfapi/rfapi_encap_tlv.c
Merge pull request #561 from donaldsharp/static_config2
[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 attr_extra *attre = attr->extra;
166 struct rfapi_un_option *uo = NULL;
167 struct rfapi_tunneltype_option *tto;
168 int rc;
169 struct bgp_attr_encap_subtlv *stlv;
170
171 if (!attre)
172 return NULL;
173
174 /* no tunnel encap attr stored */
175 if (!attre->encap_tunneltype)
176 return NULL;
177
178 stlv = attre->encap_subtlvs;
179
180 uo = XCALLOC (MTYPE_RFAPI_UN_OPTION, sizeof (struct rfapi_un_option));
181 assert (uo);
182 uo->type = RFAPI_UN_OPTION_TYPE_TUNNELTYPE;
183 uo->v.tunnel.type = attre->encap_tunneltype;
184 tto = &uo->v.tunnel;
185
186 switch (attre->encap_tunneltype)
187 {
188 case BGP_ENCAP_TYPE_L2TPV3_OVER_IP:
189 rc = tlv_to_bgp_encap_type_l2tpv3overip (stlv, &tto->bgpinfo.l2tpv3_ip);
190 break;
191
192 case BGP_ENCAP_TYPE_GRE:
193 rc = tlv_to_bgp_encap_type_gre (stlv, &tto->bgpinfo.gre);
194 break;
195
196 case BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT:
197 rc = tlv_to_bgp_encap_type_transmit_tunnel_endpoint (stlv,
198 &tto->bgpinfo.transmit_tunnel_endpoint);
199 break;
200
201 case BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE:
202 rc = tlv_to_bgp_encap_type_ipsec_in_tunnel_mode (stlv,
203 &tto->bgpinfo.ipsec_tunnel);
204 break;
205
206 case BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE:
207 rc =
208 tlv_to_bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode (stlv,
209 &tto->bgpinfo.ip_ipsec);
210 break;
211
212 case BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE:
213 rc =
214 tlv_to_bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode
215 (stlv, &tto->bgpinfo.mpls_ipsec);
216 break;
217
218 case BGP_ENCAP_TYPE_IP_IN_IP:
219 rc = tlv_to_bgp_encap_type_ip_in_ip (stlv, &tto->bgpinfo.ip_ip);
220 break;
221
222 case BGP_ENCAP_TYPE_VXLAN:
223 rc = tlv_to_bgp_encap_type_vxlan (stlv, &tto->bgpinfo.vxlan);
224 break;
225
226 case BGP_ENCAP_TYPE_NVGRE:
227 rc = tlv_to_bgp_encap_type_nvgre (stlv, &tto->bgpinfo.nvgre);
228 break;
229
230 case BGP_ENCAP_TYPE_MPLS:
231 rc = tlv_to_bgp_encap_type_mpls (stlv, &tto->bgpinfo.mpls);
232 break;
233
234 case BGP_ENCAP_TYPE_MPLS_IN_GRE:
235 rc = tlv_to_bgp_encap_type_mpls_in_gre (stlv, &tto->bgpinfo.mpls_gre);
236 break;
237
238 case BGP_ENCAP_TYPE_VXLAN_GPE:
239 rc = tlv_to_bgp_encap_type_vxlan_gpe (stlv, &tto->bgpinfo.vxlan_gpe);
240 break;
241
242 case BGP_ENCAP_TYPE_MPLS_IN_UDP:
243 rc = tlv_to_bgp_encap_type_mpls_in_udp (stlv, &tto->bgpinfo.mpls_udp);
244 break;
245
246 case BGP_ENCAP_TYPE_PBB:
247 rc = tlv_to_bgp_encap_type_pbb (stlv, &tto->bgpinfo.pbb);
248 break;
249
250 default:
251 vnc_zlog_debug_verbose ("%s: unknown tunnel type %d",
252 __func__, attre->encap_tunneltype);
253 rc = -1;
254 break;
255 }
256 if (rc)
257 {
258 XFREE (MTYPE_RFAPI_UN_OPTION, uo);
259 uo = NULL;
260 }
261 return uo;
262 }
263
264 /***********************************************************************
265 * SUBTLV PRINT
266 ***********************************************************************/
267
268 static void
269 subtlv_print_encap_l2tpv3_over_ip (
270 void *stream,
271 int column_offset,
272 struct bgp_tea_subtlv_encap_l2tpv3_over_ip *st)
273 {
274 int (*fp) (void *, const char *, ...);
275 struct vty *vty;
276 void *out;
277 const char *vty_newline;
278
279 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
280 return;
281 if (!st)
282 return;
283
284 fp (out, "%*s%s%s", column_offset, "", "SubTLV: Encap(L2TPv3 over IP)",
285 vty_newline);
286 fp (out, "%*s SessionID: %d%s", column_offset, "", st->sessionid,
287 vty_newline);
288 fp (out, "%*s Cookie: (length %d)%s", column_offset, "", st->cookie_length,
289 vty_newline);
290 }
291
292 static void
293 subtlv_print_encap_gre (
294 void *stream,
295 int column_offset,
296 struct bgp_tea_subtlv_encap_gre_key *st)
297 {
298 int (*fp) (void *, const char *, ...);
299 struct vty *vty;
300 void *out;
301 const char *vty_newline;
302
303 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
304 return;
305 if (!st)
306 return;
307
308 fp (out, "%*s%s%s", column_offset, "", "SubTLV: Encap(GRE)", vty_newline);
309 fp (out, "%*s GRE key: %d (0x%x)%s", column_offset, "", st->gre_key,
310 st->gre_key, vty_newline);
311 }
312
313 static void
314 subtlv_print_encap_pbb (
315 void *stream,
316 int column_offset,
317 struct bgp_tea_subtlv_encap_pbb *st)
318 {
319 int (*fp) (void *, const char *, ...);
320 struct vty *vty;
321 void *out;
322 const char *vty_newline;
323
324 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
325 return;
326 if (!st)
327 return;
328
329 fp (out, "%*s%s%s", column_offset, "", "SubTLV: Encap(PBB)", vty_newline);
330 if (st->flag_isid)
331 {
332 fp (out, "%*s ISID: %d (0x%x)%s", column_offset, "", st->isid,
333 st->isid, vty_newline);
334 }
335 if (st->flag_vid)
336 {
337 fp (out, "%*s VID: %d (0x%x)%s", column_offset, "", st->vid, st->vid,
338 vty_newline);
339 }
340 fp (out, "%*s MACADDR %02x:%02x:%02x:%02x:%02x:%02x%s",
341 column_offset, "",
342 st->macaddr[0],
343 st->macaddr[1],
344 st->macaddr[2],
345 st->macaddr[3], st->macaddr[4], st->macaddr[5], vty_newline);
346 }
347
348 static void
349 subtlv_print_proto_type (
350 void *stream,
351 int column_offset,
352 struct bgp_tea_subtlv_proto_type *st)
353 {
354 int (*fp) (void *, const char *, ...);
355 struct vty *vty;
356 void *out;
357 const char *vty_newline;
358
359 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
360 return;
361 if (!st)
362 return;
363
364 fp (out, "%*s%s%s", column_offset, "", "SubTLV: Encap(Proto Type)",
365 vty_newline);
366 fp (out, "%*s Proto %d (0x%x)%s", column_offset, "", st->proto, st->proto,
367 vty_newline);
368 }
369
370 static void
371 subtlv_print_color (
372 void *stream,
373 int column_offset,
374 struct bgp_tea_subtlv_color *st)
375 {
376 int (*fp) (void *, const char *, ...);
377 struct vty *vty;
378 void *out;
379 const char *vty_newline;
380
381 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
382 return;
383 if (!st)
384 return;
385
386 fp (out, "%*s%s%s", column_offset, "", "SubTLV: Color", vty_newline);
387 fp (out, "%*s Color: %d (0x%x)", column_offset, "", st->color, st->color,
388 vty_newline);
389 }
390
391 static void
392 subtlv_print_ipsec_ta (
393 void *stream,
394 int column_offset,
395 struct bgp_tea_subtlv_ipsec_ta *st)
396 {
397 int (*fp) (void *, const char *, ...);
398 struct vty *vty;
399 void *out;
400 const char *vty_newline;
401
402 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
403 return;
404 if (!st)
405 return;
406
407 fp (out, "%*s%s%s", column_offset, "", "SubTLV: IPSEC TA", vty_newline);
408 fp (out, "%*s Authenticator Type: %d (0x%x)", column_offset, "",
409 st->authenticator_type, st->authenticator_type, vty_newline);
410 fp (out, "%*s Authenticator: (length %d)", column_offset, "",
411 st->authenticator_length, vty_newline);
412 }
413
414 /***********************************************************************
415 * TLV PRINT
416 ***********************************************************************/
417
418 static void
419 print_encap_type_l2tpv3overip (
420 void *stream,
421 int column_offset,
422 struct bgp_encap_type_l2tpv3_over_ip *bet)
423 {
424 const char *type = "L2TPv3 over IP";
425 int (*fp) (void *, const char *, ...);
426 struct vty *vty;
427 void *out;
428 const char *vty_newline;
429
430 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
431 return;
432 if (!bet)
433 return;
434
435 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
436
437 subtlv_print_encap_l2tpv3_over_ip (stream, column_offset + 2,
438 &bet->st_encap);
439 subtlv_print_proto_type (stream, column_offset + 2, &bet->st_proto);
440 subtlv_print_color (stream, column_offset + 2, &bet->st_color);
441 }
442
443 static void
444 print_encap_type_gre (
445 void *stream,
446 int column_offset,
447 struct bgp_encap_type_gre *bet)
448 {
449 const char *type = "GRE";
450 int (*fp) (void *, const char *, ...);
451 struct vty *vty;
452 void *out;
453 const char *vty_newline;
454
455 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
456 return;
457 if (!bet)
458 return;
459
460 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
461
462 subtlv_print_encap_gre (stream, column_offset + 2, &bet->st_encap);
463 subtlv_print_proto_type (stream, column_offset + 2, &bet->st_proto);
464 subtlv_print_color (stream, column_offset + 2, &bet->st_color);
465 }
466
467 static void
468 print_encap_type_ip_in_ip (
469 void *stream,
470 int column_offset,
471 struct bgp_encap_type_ip_in_ip *bet)
472 {
473 const char *type = "IP in IP";
474 int (*fp) (void *, const char *, ...);
475 struct vty *vty;
476 void *out;
477 const char *vty_newline;
478
479 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
480 return;
481 if (!bet)
482 return;
483
484 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
485
486 subtlv_print_proto_type (stream, column_offset + 2, &bet->st_proto);
487 subtlv_print_color (stream, column_offset + 2, &bet->st_color);
488 }
489
490 static void
491 print_encap_type_transmit_tunnel_endpoint (
492 void *stream,
493 int column_offset,
494 struct bgp_encap_type_transmit_tunnel_endpoint *bet)
495 {
496 const char *type = "Transmit Tunnel Endpoint";
497 int (*fp) (void *, const char *, ...);
498 struct vty *vty;
499 void *out;
500 const char *vty_newline;
501
502 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
503 return;
504 if (!bet)
505 return;
506
507 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
508
509 /* no subtlvs for this type */
510 }
511
512 static void
513 print_encap_type_ipsec_in_tunnel_mode (
514 void *stream,
515 int column_offset,
516 struct bgp_encap_type_ipsec_in_tunnel_mode *bet)
517 {
518 const char *type = "IPSEC in Tunnel mode";
519 int (*fp) (void *, const char *, ...);
520 struct vty *vty;
521 void *out;
522 const char *vty_newline;
523
524 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
525 return;
526 if (!bet)
527 return;
528
529 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
530 subtlv_print_ipsec_ta (stream, column_offset + 2, &bet->st_ipsec_ta);
531 }
532
533 static void
534 print_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode (
535 void *stream,
536 int column_offset,
537 struct bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode *bet)
538 {
539 const char *type = "IP in IP Tunnel with IPSEC transport mode";
540 int (*fp) (void *, const char *, ...);
541 struct vty *vty;
542 void *out;
543 const char *vty_newline;
544
545 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
546 return;
547 if (!bet)
548 return;
549
550 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
551
552 subtlv_print_ipsec_ta (stream, column_offset + 2, &bet->st_ipsec_ta);
553 }
554
555 static void
556 print_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode (
557 void *stream,
558 int column_offset,
559 struct bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode *bet)
560 {
561 const char *type = "MPLS in IP Tunnel with IPSEC transport mode";
562 int (*fp) (void *, const char *, ...);
563 struct vty *vty;
564 void *out;
565 const char *vty_newline;
566
567 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
568 return;
569 if (!bet)
570 return;
571
572 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
573
574 subtlv_print_ipsec_ta (stream, column_offset + 2, &bet->st_ipsec_ta);
575 }
576
577
578 static void
579 print_encap_type_pbb (
580 void *stream,
581 int column_offset,
582 struct bgp_encap_type_pbb *bet)
583 {
584 const char *type = "PBB";
585 int (*fp) (void *, const char *, ...);
586 struct vty *vty;
587 void *out;
588 const char *vty_newline;
589
590 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
591 return;
592 if (!bet)
593 return;
594
595 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
596
597 subtlv_print_encap_pbb (stream, column_offset + 2, &bet->st_encap);
598 }
599
600
601 static void
602 print_encap_type_vxlan (
603 void *stream,
604 int column_offset,
605 struct bgp_encap_type_vxlan *bet)
606 {
607 const char *type = "VXLAN";
608 int (*fp) (void *, const char *, ...);
609 struct vty *vty;
610 void *out;
611 const char *vty_newline;
612
613 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
614 return;
615 if (!bet)
616 return;
617
618 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
619
620 /* no subtlvs for this type */
621 }
622
623
624 static void
625 print_encap_type_nvgre (
626 void *stream,
627 int column_offset,
628 struct bgp_encap_type_nvgre *bet)
629 {
630 const char *type = "NVGRE";
631 int (*fp) (void *, const char *, ...);
632 struct vty *vty;
633 void *out;
634 const char *vty_newline;
635
636 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
637 return;
638 if (!bet)
639 return;
640
641 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
642
643 /* no subtlvs for this type */
644 }
645
646 static void
647 print_encap_type_mpls (
648 void *stream,
649 int column_offset,
650 struct bgp_encap_type_mpls *bet)
651 {
652 const char *type = "MPLS";
653 int (*fp) (void *, const char *, ...);
654 struct vty *vty;
655 void *out;
656 const char *vty_newline;
657
658 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
659 return;
660 if (!bet)
661 return;
662
663 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
664
665 /* no subtlvs for this type */
666 }
667
668 static void
669 print_encap_type_mpls_in_gre (
670 void *stream,
671 int column_offset,
672 struct bgp_encap_type_mpls_in_gre *bet)
673 {
674 const char *type = "MPLS in GRE";
675 int (*fp) (void *, const char *, ...);
676 struct vty *vty;
677 void *out;
678 const char *vty_newline;
679
680 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
681 return;
682 if (!bet)
683 return;
684
685 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
686
687 /* no subtlvs for this type */
688 }
689
690 static void
691 print_encap_type_vxlan_gpe (
692 void *stream,
693 int column_offset,
694 struct bgp_encap_type_vxlan_gpe *bet)
695 {
696 const char *type = "VXLAN GPE";
697 int (*fp) (void *, const char *, ...);
698 struct vty *vty;
699 void *out;
700 const char *vty_newline;
701
702 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
703 return;
704 if (!bet)
705 return;
706
707 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
708
709 /* no subtlvs for this type */
710 }
711
712 static void
713 print_encap_type_mpls_in_udp (
714 void *stream,
715 int column_offset,
716 struct bgp_encap_type_mpls_in_udp *bet)
717 {
718 const char *type = "MPLS in UDP";
719 int (*fp) (void *, const char *, ...);
720 struct vty *vty;
721 void *out;
722 const char *vty_newline;
723
724 if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0)
725 return;
726 if (!bet)
727 return;
728
729 fp (out, "%*sTEA type %s%s", column_offset, "", type, vty_newline);
730
731 /* no subtlvs for this type */
732 }
733
734 void
735 rfapi_print_tunneltype_option (
736 void *stream,
737 int column_offset,
738 struct rfapi_tunneltype_option *tto)
739 {
740 switch (tto->type)
741 {
742 case BGP_ENCAP_TYPE_L2TPV3_OVER_IP:
743 print_encap_type_l2tpv3overip (stream, column_offset,
744 &tto->bgpinfo.l2tpv3_ip);
745 break;
746
747 case BGP_ENCAP_TYPE_GRE:
748 print_encap_type_gre (stream, column_offset, &tto->bgpinfo.gre);
749 break;
750
751 case BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT:
752 print_encap_type_transmit_tunnel_endpoint (stream, column_offset,
753 &tto->bgpinfo.transmit_tunnel_endpoint);
754 break;
755
756 case BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE:
757 print_encap_type_ipsec_in_tunnel_mode (stream, column_offset,
758 &tto->bgpinfo.ipsec_tunnel);
759 break;
760
761 case BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE:
762 print_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode (stream,
763 column_offset,
764 &tto->bgpinfo.ip_ipsec);
765 break;
766
767 case BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE:
768 print_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode (stream,
769 column_offset,
770 &tto->bgpinfo.mpls_ipsec);
771 break;
772
773 case BGP_ENCAP_TYPE_IP_IN_IP:
774 print_encap_type_ip_in_ip (stream, column_offset, &tto->bgpinfo.ip_ip);
775 break;
776
777 case BGP_ENCAP_TYPE_VXLAN:
778 print_encap_type_vxlan (stream, column_offset, &tto->bgpinfo.vxlan);
779 break;
780
781 case BGP_ENCAP_TYPE_NVGRE:
782 print_encap_type_nvgre (stream, column_offset, &tto->bgpinfo.nvgre);
783 break;
784
785 case BGP_ENCAP_TYPE_MPLS:
786 print_encap_type_mpls (stream, column_offset, &tto->bgpinfo.mpls);
787 break;
788
789 case BGP_ENCAP_TYPE_MPLS_IN_GRE:
790 print_encap_type_mpls_in_gre (stream, column_offset,
791 &tto->bgpinfo.mpls_gre);
792 break;
793
794 case BGP_ENCAP_TYPE_VXLAN_GPE:
795 print_encap_type_vxlan_gpe (stream, column_offset,
796 &tto->bgpinfo.vxlan_gpe);
797 break;
798
799 case BGP_ENCAP_TYPE_MPLS_IN_UDP:
800 print_encap_type_mpls_in_udp (stream, column_offset,
801 &tto->bgpinfo.mpls_udp);
802 break;
803
804 case BGP_ENCAP_TYPE_PBB:
805 print_encap_type_pbb (stream, column_offset, &tto->bgpinfo.pbb);
806 break;
807
808 default:
809 assert (0);
810 }
811 }