FD.io VPP  v18.07.1-13-g909ba93
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  * The value for an Contract
42  */
43 typedef struct gbp_contract_value_t_
44 {
45  union
46  {
47  struct
48  {
49  /**
50  * lookup context and acl index
51  */
54  };
56  };
58 
59 /**
60  * A Group Based Policy Contract.
61  * Determines the ACL that applies to traffic pass between two endpoint groups
62  */
63 typedef struct gbp_contract_t_
64 {
65  /**
66  * source and destination EPGs
67  */
69 
70  /**
71  * The ACL to apply for packets from the source to the destination EPG
72  */
75 
76 /**
77  * EPG src,dst pair to ACL mapping table, aka contract DB
78  */
79 typedef struct gbp_contract_db_t_
80 {
81  /**
82  * We can form a u64 key from the pair, so use a simple hash table
83  */
86 
87 extern void gbp_contract_update (epg_id_t src_epg,
88  epg_id_t dst_epg, u32 acl_index);
89 extern void gbp_contract_delete (epg_id_t src_epg, epg_id_t dst_epg);
90 
91 typedef int (*gbp_contract_cb_t) (gbp_contract_t * gbpe, void *ctx);
92 extern void gbp_contract_walk (gbp_contract_cb_t bgpe, void *ctx);
93 
94 
95 /**
96  * DP functions and databases
97  */
99 
102 {
103  uword *p;
104 
105  p = hash_get (gbp_contract_db.gc_hash, key->as_u64);
106 
107  if (NULL != p)
108  return (p[0]);
109 
110  return (~0);
111 }
112 
113 #endif
114 
115 /*
116  * fd.io coding-style-patch-verification: ON
117  *
118  * Local Variables:
119  * eval: (c-set-style "gnu")
120  * End:
121  */
gbp_contract_key_t gc_key
source and destination EPGs
Definition: gbp_contract.h:68
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:79
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:90
unsigned int u32
Definition: types.h:88
gbp_contract_db_t gbp_contract_db
DP functions and databases.
Definition: gbp_contract.c:23
gbp_contract_value_t gc_value
The ACL to apply for packets from the source to the destination EPG.
Definition: gbp_contract.h:73
uword * gc_hash
We can form a u64 key from the pair, so use a simple hash table.
Definition: gbp_contract.h:84
#define hash_get(h, key)
Definition: hash.h:249
u32 gc_lc_index
lookup context and acl index
Definition: gbp_contract.h:52
The value for an Contract.
Definition: gbp_contract.h:43
static u64 gbp_acl_lookup(gbp_contract_key_t *key)
Definition: gbp_contract.h:101
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:70
u64 uword
Definition: types.h:112
struct gbp_contract_value_t_ gbp_contract_value_t
The value for an Contract.
A Group Based Policy Contract.
Definition: gbp_contract.h:63
int(* gbp_contract_cb_t)(gbp_contract_t *gbpe, void *ctx)
Definition: gbp_contract.h:91