2 * Copyright (c) 2018 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef __GBP_ENDPOINT_H__
17 #define __GBP_ENDPOINT_H__
19 #include <plugins/gbp/gbp_types.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/ethernet/mac_address.h>
23 #include <vppinfra/bihash_16_8.h>
24 #include <vppinfra/bihash_template.h>
25 #include <vppinfra/bihash_24_8.h>
26 #include <vppinfra/bihash_template.h>
29 * Flags for each endpoint
31 typedef enum gbp_endpoint_flags_t_
33 GBP_ENDPOINT_FLAG_NONE = 0,
34 GBP_ENDPOINT_FLAG_BOUNCE = (1 << 0),
35 GBP_ENDPOINT_FLAG_DYNAMIC = (1 << 1),
36 } gbp_endpoint_flags_t;
39 * A Group Based Policy Endpoint.
40 * This is typically a VM or container. If the endpoint is local (i.e. on
41 * the same compute node as VPP) then there is one interface per-endpoint.
42 * If the EP is remote,e.g. reachable over a [vxlan] tunnel, then there
43 * will be multiple EPs reachable over the tunnel and they can be distinguished
44 * via either their MAC or IP Address[es].
46 typedef struct gbp_endpoint_t_
49 * The interface on which the EP is connected
54 * A vector of ip addresses that below to the endpoint
56 ip46_address_t *ge_ips;
59 * MAC address of the endpoint
64 * The endpoint's designated EPG
71 gbp_endpoint_flags_t ge_flags;
74 extern u8 *format_gbp_endpoint (u8 * s, va_list * args);
77 * Interface to source EPG DB - a per-interface vector
79 typedef struct gbp_ep_by_itf_db_t_
84 typedef struct gbp_ep_by_ip_itf_db_t_
86 clib_bihash_24_8_t gte_table;
87 } gbp_ep_by_ip_itf_db_t;
89 typedef struct gbp_ep_by_mac_itf_db_t_
91 clib_bihash_16_8_t gte_table;
92 } gbp_ep_by_mac_itf_db_t;
94 extern int gbp_endpoint_update (u32 sw_if_index,
95 const ip46_address_t * ip,
96 const mac_address_t * mac,
97 epg_id_t epg_id, u32 * handle);
98 extern void gbp_endpoint_delete (u32 handle);
100 typedef walk_rc_t (*gbp_endpoint_cb_t) (gbp_endpoint_t * gbpe, void *ctx);
101 extern void gbp_endpoint_walk (gbp_endpoint_cb_t cb, void *ctx);
105 * DP functions and databases
107 extern gbp_ep_by_itf_db_t gbp_ep_by_itf_db;
108 extern gbp_ep_by_mac_itf_db_t gbp_ep_by_mac_itf_db;
109 extern gbp_ep_by_ip_itf_db_t gbp_ep_by_ip_itf_db;
110 extern gbp_endpoint_t *gbp_endpoint_pool;
113 * Get the endpoint from a port/interface
115 always_inline gbp_endpoint_t *
116 gbp_endpoint_get (index_t gbpei)
118 return (pool_elt_at_index (gbp_endpoint_pool, gbpei));
121 always_inline gbp_endpoint_t *
122 gbp_endpoint_get_itf (u32 sw_if_index)
124 return (gbp_endpoint_get (gbp_ep_by_itf_db.gte_vec[sw_if_index]));
130 * fd.io coding-style-patch-verification: ON
133 * eval: (c-set-style "gnu")