FD.io VPP  v18.07-rc0-415-g6c78436
Vector Packet Processing
gbp_contract.h
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 
16 #ifndef __GBP_CONTRACT_H__
17 #define __GBP_CONTRACT_H__
18 
19 #include <plugins/gbp/gbp_types.h>
20 
21 /**
22  * The key for an Contract
23  */
24 typedef struct gbp_contract_key_t_
25 {
26  union
27  {
28  struct
29  {
30  /**
31  * source and destination EPGs for which the ACL applies
32  */
35  };
37  };
39 
40 /**
41  * A Group Based Policy Contract.
42  * Determines the ACL that applies to traffic pass between two endpoint groups
43  */
44 typedef struct gbp_contract_t_
45 {
46  /**
47  * source and destination EPGs
48  */
50 
51  /**
52  * The ACL to apply for packets from the source to the destination EPG
53  */
56 
57 /**
58  * EPG src,dst pair to ACL mapping table, aka contract DB
59  */
60 typedef struct gbp_contract_db_t_
61 {
62  /**
63  * We can form a u64 key from the pair, so use a simple hash table
64  */
67 
68 extern void gbp_contract_update (epg_id_t src_epg,
69  epg_id_t dst_epg, u32 acl_index);
70 extern void gbp_contract_delete (epg_id_t src_epg, epg_id_t dst_epg);
71 
72 typedef int (*gbp_contract_cb_t) (gbp_contract_t * gbpe, void *ctx);
73 extern void gbp_contract_walk (gbp_contract_cb_t bgpe, void *ctx);
74 
75 
76 /**
77  * DP functions and databases
78  */
80 
83 {
84  uword *p;
85 
86  p = hash_get (gbp_contract_db.gc_hash, key->as_u64);
87 
88  if (NULL != p)
89  return (p[0]);
90 
91  return (~0);
92 }
93 
94 #endif
95 
96 /*
97  * fd.io coding-style-patch-verification: ON
98  *
99  * Local Variables:
100  * eval: (c-set-style "gnu")
101  * End:
102  */
gbp_contract_key_t gc_key
source and destination EPGs
Definition: gbp_contract.h:49
unsigned long u64
Definition: types.h:89
struct gbp_contract_key_t_ gbp_contract_key_t
The key for an Contract.
#define NULL
Definition: clib.h:55
The key for an Contract.
Definition: gbp_contract.h:24
EPG src,dst pair to ACL mapping table, aka contract DB.
Definition: gbp_contract.h:60
void gbp_contract_update(epg_id_t src_epg, epg_id_t dst_epg, u32 acl_index)
Definition: gbp_contract.c:26
#define always_inline
Definition: clib.h:92
u32 epg_id_t
Definition: gbp_types.h:21
struct gbp_contract_db_t_ gbp_contract_db_t
EPG src,dst pair to ACL mapping table, aka contract DB.
void gbp_contract_walk(gbp_contract_cb_t bgpe, void *ctx)
Definition: gbp_contract.c:48
unsigned int u32
Definition: types.h:88
gbp_contract_db_t gbp_contract_db
DP functions and databases.
Definition: gbp_contract.c:23
uword * gc_hash
We can form a u64 key from the pair, so use a simple hash table.
Definition: gbp_contract.h:65
#define hash_get(h, key)
Definition: hash.h:249
static u32 gbp_acl_lookup(gbp_contract_key_t *key)
Definition: gbp_contract.h:82
epg_id_t gck_src
source and destination EPGs for which the ACL applies
Definition: gbp_contract.h:33
long ctx[MAX_CONNS]
Definition: main.c:126
struct gbp_contract_t_ gbp_contract_t
A Group Based Policy Contract.
void gbp_contract_delete(epg_id_t src_epg, epg_id_t dst_epg)
Definition: gbp_contract.c:37
u64 uword
Definition: types.h:112
u32 gc_acl_index
The ACL to apply for packets from the source to the destination EPG.
Definition: gbp_contract.h:54
A Group Based Policy Contract.
Definition: gbp_contract.h:44
int(* gbp_contract_cb_t)(gbp_contract_t *gbpe, void *ctx)
Definition: gbp_contract.h:72