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_GROUP_H__
17 #define __GBP_ENDPOINT_GROUP_H__
19 #include <plugins/gbp/gbp_types.h>
21 #include <vnet/fib/fib_types.h>
24 * An Endpoint Group representation
26 typedef struct gpb_endpoint_group_t_
34 * Bridge-domain ID the EPG is in
39 * route-domain/IP-table ID the EPG is in
41 u32 gepg_rd[FIB_PROTOCOL_IP_MAX];
44 * resulting FIB indices
46 u32 gepg_fib_index[FIB_PROTOCOL_IP_MAX];
49 * Is the EPG an external/NAT
54 * the uplink interface dedicated to the EPG
56 u32 gepg_uplink_sw_if_index;
59 * The DPO used in the L3 path for forwarding internal subnets
61 dpo_id_t gepg_dpo[FIB_PROTOCOL_IP_MAX];
62 } gbp_endpoint_group_t;
65 * EPG DB, key'd on EGP-ID
67 typedef struct gbp_endpoint_group_db_t_
70 } gbp_endpoint_group_db_t;
72 extern int gbp_endpoint_group_add (epg_id_t epg_id,
75 u32 ip6_table_id, u32 uplink_sw_if_index);
76 extern void gbp_endpoint_group_delete (epg_id_t epg_id);
78 typedef int (*gbp_endpoint_group_cb_t) (gbp_endpoint_group_t * gbpe,
80 extern void gbp_endpoint_group_walk (gbp_endpoint_group_cb_t bgpe, void *ctx);
82 extern gbp_endpoint_group_t *gbp_endpoint_group_find (epg_id_t epg_id);
85 * DP functions and databases
87 extern gbp_endpoint_group_db_t gbp_endpoint_group_db;
88 extern gbp_endpoint_group_t *gbp_endpoint_group_pool;
91 gbp_epg_itf_lookup (epg_id_t epg)
95 p = hash_get (gbp_endpoint_group_db.gepg_hash, epg);
99 gbp_endpoint_group_t *gepg;
101 gepg = pool_elt_at_index (gbp_endpoint_group_pool, p[0]);
102 return (gepg->gepg_uplink_sw_if_index);
107 always_inline const dpo_id_t *
108 gbp_epg_dpo_lookup (epg_id_t epg, fib_protocol_t fproto)
112 p = hash_get (gbp_endpoint_group_db.gepg_hash, epg);
116 gbp_endpoint_group_t *gepg;
118 gepg = pool_elt_at_index (gbp_endpoint_group_pool, p[0]);
119 return (&gepg->gepg_dpo[fproto]);
127 * fd.io coding-style-patch-verification: ON
130 * eval: (c-set-style "gnu")