blob: bd4aa401c5bebbb9cf3f59df4291677406695217 [file] [log] [blame]
Dave Barach8d0f2f02018-03-12 09:31:36 -04001;;; Copyright (c) 2016 Cisco and/or its affiliates.
2;;; Licensed under the Apache License, Version 2.0 (the "License");
3;;; you may not use this file except in compliance with the License.
4;;; You may obtain a copy of the License at:
5;;;
6;;; http://www.apache.org/licenses/LICENSE-2.0
7;;;
8;;; Unless required by applicable law or agreed to in writing, software
9;;; distributed under the License is distributed on an "AS IS" BASIS,
10;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11;;; See the License for the specific language governing permissions and
12;;; limitations under the License.
13
Ed Warnickecb9cada2015-12-08 15:45:58 -070014;;; tunnel-h-skel.el - tunnel encap header file skeleton
15
16(require 'skeleton)
17
Keith Burns (alagalah)ca46d8c2016-03-18 07:22:15 -070018(define-skeleton skel-tunnel-h
Ed Warnickecb9cada2015-12-08 15:45:58 -070019"Insert a tunnel encap header file"
20nil
21'(setq encap_stack (skeleton-read "encap_stack (e.g ip4_udp_lisp): "))
22'(setq ENCAP_STACK (upcase encap_stack))
23'(setq encap-stack (replace-regexp-in-string "_" "-" encap_stack))
24"
25#ifndef included_vnet_" encap_stack "_h
26#define included_vnet_" encap_stack "_h
27
Dave Wallace526b5e82016-03-14 00:10:24 -040028#include <vppinfra/error.h>
29#include <vppinfra/hash.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070030#include <vnet/vnet.h>
31#include <vnet/ip/ip.h>
32#include <vnet/l2/l2_input.h>
33#include <vnet/ethernet/ethernet.h>
34#include <vnet/" encap-stack "/" encap_stack "_packet.h>
35#include <vnet/ip/ip4_packet.h>
36#include <vnet/ip/udp.h>
37
38/* Encap stack built in encap.c */
39typedef CLIB_PACKED (struct {
40 ip4_header_t ip4; /* 20 bytes */
41 udp_header_t udp; /* 8 bytes */
42 " encap_stack "_header_t lisp; /* 8 bytes */
43}) " encap_stack "_header_t;
44
45typedef CLIB_PACKED(struct {
46 /*
47 * Key fields:
48 * all fields in NET byte order
49 */
50 union {
51 struct {
52 u32 FIXME_NET_BYTE_ORDER;
53 };
54 u64 as_u64[1];
55 };
56}) " encap_stack "_tunnel_key_t;
57
58typedef struct {
59 /* Rewrite string. $$$$ maybe: embed vnet_rewrite header */
60 u8 * rewrite;
61
62 /* decap next index */
63 u32 decap_next_index;
64
65 /* tunnel src and dst addresses */
66 ip4_address_t src;
67 ip4_address_t dst;
68
69 /* FIB indices */
70 u32 encap_fib_index; /* tunnel partner lookup here */
71 u32 decap_fib_index; /* inner IP lookup here */
72
73 /* vnet intfc hw/sw_if_index */
74 u32 hw_if_index;
75
76 /* encap header fields in HOST byte order */
77 u32 FIXME;
78} " encap_stack "_tunnel_t;
79
80#define foreach_" encap_stack "_input_next \\
81_(DROP, \"error-drop\") \\
82_(IP4_INPUT, \"ip4-input\") \\
83_(IP6_INPUT, \"ip6-input\") \\
84_(ETHERNET_INPUT, \"ethernet-input\") \\
85_(" ENCAP_STACK "_ENCAP, \"" encap-stack "-encap\")
86
87typedef enum {
88#define _(s,n) " ENCAP_STACK "_INPUT_NEXT_##s,
89 foreach_" encap_stack "_input_next
90#undef _
91 " ENCAP_STACK "_INPUT_N_NEXT,
92} " encap_stack "_input_next_t;
93
94typedef enum {
95#define " encap_stack "_error(n,s) " ENCAP_STACK "_ERROR_##n,
96#include <vnet/" encap-stack "/" encap_stack "_error.def>
97#undef " encap_stack "_error
98 " ENCAP_STACK "_N_ERROR,
99} " encap_stack "_input_error_t;
100
101typedef struct {
102 /* vector of encap tunnel instances */
103 " encap_stack "_tunnel_t *tunnels;
104
105 /* lookup tunnel by key */
106 uword * " encap_stack "_tunnel_by_key;
107
108 /* Free vlib hw_if_indices */
109 u32 * free_" encap_stack "_tunnel_hw_if_indices;
110
111 /* convenience */
112 vlib_main_t * vlib_main;
113 vnet_main_t * vnet_main;
114} " encap_stack "_main_t;
115
116" encap_stack "_main_t " encap_stack "_main;
117
118vlib_node_registration_t " encap_stack "_input_node;
119vlib_node_registration_t " encap_stack "_encap_node;
120
121u8 * format_" encap_stack "_encap_trace (u8 * s, va_list * args);
122u8 * format_" encap_stack "_header_with_length (u8 * s, va_list * args);
123
124typedef struct {
125 u8 is_add;
126 ip4_address_t src, dst;
127 u32 encap_fib_index;
128 u32 decap_fib_index;
129 u32 decap_next_index;
130 /* encap fields in HOST byte order */
131 u8 FIXME_HOST_BYTE_ORDER;
132} vnet_" encap_stack "_add_del_tunnel_args_t;
133
134int vnet_" encap_stack "_add_del_tunnel
135(vnet_" encap_stack "_add_del_tunnel_args_t *a, u32 * hw_if_indexp);
136
137u8 * format_" encap_stack "_header_with_length (u8 * s, va_list * args);
138
139#endif /* included_vnet_" encap_stack "_h */
140
141")