2 // Copyright (c) 2010-2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #ifndef _PROX_LUA_TYPES_H_
18 #define _PROX_LUA_TYPES_H_
21 #include <rte_ether.h>
37 #define MAX_HOP_INDEX 128
38 enum l4gen_peer {PEER_SERVER, PEER_CLIENT};
40 static const char *l4gen_peer_to_str(enum l4gen_peer peer)
42 return peer == PEER_SERVER? "server" : "client";
58 uint32_t n_free_rules;
59 uint32_t n_used_rules;
60 struct next_hop *next_hops;
61 struct rte_lpm *rte_lpm;
65 struct rte_lpm6 *rte_lpm6;
66 struct next_hop6 *next_hops;
67 uint32_t n_free_rules;
68 uint32_t n_used_rules;
71 struct ipv6_tun_binding_entry {
72 struct ipv6_addr endpoint_addr; // IPv6 local addr
73 struct ether_addr next_hop_mac; // mac addr of next hop towards lwB4
74 uint32_t public_ipv4; // Public IPv4 address
75 uint16_t public_port; // Public base port (together with port mask, defines the Port Set)
76 } __attribute__((__packed__));
78 struct ipv6_tun_binding_table {
79 uint32_t num_binding_entries;
80 struct ipv6_tun_binding_entry entry[0];
83 struct cpe_table_entry {
89 struct ether_addr eth_addr;
93 struct cpe_table_data {
95 struct cpe_table_entry entries[0];
108 enum acl_action {ACL_NOT_SET, ACL_ALLOW, ACL_DROP, ACL_RATE_LIMIT};
110 const char *get_lua_to_errors(void);
112 enum lua_place {STACK, TABLE, GLOBAL};
113 int lua_getfrom(struct lua_State *L, enum lua_place from, const char *name);
115 int lua_to_port(struct lua_State *L, enum lua_place from, const char *name, uint16_t *port);
116 int lua_to_ip(struct lua_State *L, enum lua_place from, const char *name, uint32_t *ip);
117 int lua_to_ip6(struct lua_State *L, enum lua_place from, const char *name, uint8_t *ip);
118 int lua_to_mac(struct lua_State *L, enum lua_place from, const char *name, struct ether_addr *mac);
119 int lua_to_cidr(struct lua_State *L, enum lua_place from, const char *name, struct ip4_subnet *cidr);
120 int lua_to_cidr6(struct lua_State *L, enum lua_place from, const char *name, struct ip6_subnet *cidr);
121 int lua_to_int(struct lua_State *L, enum lua_place from, const char *name, uint32_t *val);
122 int lua_to_double(struct lua_State *L, enum lua_place from, const char *name, double *val);
123 int lua_to_string(struct lua_State *L, enum lua_place from, const char *name, char *dst, size_t size);
124 int lua_to_val_mask(struct lua_State *L, enum lua_place from, const char *name, struct val_mask *val_mask);
125 int lua_to_val_range(struct lua_State *L, enum lua_place from, const char *name, struct val_range *val_range);
126 int lua_to_action(struct lua_State *L, enum lua_place from, const char *name, enum acl_action *action);
127 int lua_to_dscp(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, uint8_t **dscp);
128 int lua_to_user_table(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, uint16_t **user_table);
129 int lua_to_lpm4(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, struct lpm4 **lpm);
130 int lua_to_routes4(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, struct lpm4 *lpm);
131 int lua_to_next_hop(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, struct next_hop **nh);
132 int lua_to_lpm6(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, struct lpm6 **lpm);
133 int lua_to_ip6_tun_binding(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, struct ipv6_tun_binding_table **data);
134 int lua_to_qinq_gre_map(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, struct qinq_gre_map **qinq_gre_map);
135 int lua_to_cpe_table_data(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, struct cpe_table_data **data);
136 int lua_to_rules(struct lua_State *L, enum lua_place from, const char *name, struct rte_acl_ctx *ctx, uint32_t* n_max_rules, int use_qinq, uint16_t qinq_tag);
137 int lua_to_routes4_entry(struct lua_State *L, enum lua_place from, const char *name, struct ip4_subnet *cidr, uint32_t *nh_idx);
138 int lua_to_next_hop6(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, struct next_hop6 **nh);
139 int lua_to_routes6(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, struct lpm6 *lpm);
140 int lua_to_tuples(struct lua_State *L, enum lua_place from, const char *name, uint8_t socket, struct rte_hash **lookup_hash, uint8_t **out_if);
142 #endif /* _PROX_LUA_TYPES_H_ */