FD.io VPP  v16.06
Vector Packet Processing
vcgn_db.h
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * vcgn_db.h - translation database definitions
4  *
5  * Copyright (c) 2007-2014 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19 
20 #ifndef __VCGN_DB_H__
21 #define __VCGN_DB_H__
22 
23 #include "index_list.h"
24 
25 /*
26  * The key structure. All fields are in NETWORK byte order!
27  */
28 typedef struct {
29  u32 ipv4;
30  u16 port;
31  u16 vrf; //bit0-12:vrf, bit13:unused, bit14-15:protocol
33 
34 /* bit14-15:protocol in cnat_db_key_t */
35 #define CNAT_INVALID_PROTO 0x0000
36 #define CNAT_UDP 0x4000
37 #define CNAT_TCP 0x8000
38 #define CNAT_ICMP 0xc000
39 #define CNAT_VRF_MASK 0x3fff
40 #define CNAT_PRO_MASK 0xc000
41 #define CNAT_PRO_SHIFT 14
42 
43 /*
44  * Maximum number of VRF entries supported
45  */
46 #define CNAT_MAX_VRFMAP_ENTRIES (CNAT_VRF_MASK + 1)
47 /*
48  * for hashing purposes, fetch the key in one instr.
49  */
50 typedef union {
51  cnat_db_key_t k;
52  u64 key64;
53 } cnat_key_t;
54 
55 /*
56  * Main translation database entries. Currently 0x50 = 80 bytes in length.
57  * Given 20,000,000 entries, it saves nearly 1gb of SDRAM to pack the entries
58  * and pay the extra prefetch. So, that's what we do.
59  */
60 
61 typedef struct {
62  /* 0x00 */
63  index_slist_t out2in_hash; /* hash-and-chain, x2 */
64  index_slist_t in2out_hash;
65 
66  /* 0x08 */
67  cnat_key_t out2in_key; /* network-to-user, outside-to-inside key */
68 
69  /* 0x10 */
70  cnat_key_t in2out_key; /* user-to-network, inside-to-outside key */
71 
72  /* 0x18 */
73  index_dlist_t user_ports; /* per-user translation list */
74 
75  /* 0x20 */
76  u32 user_index; /* index of user that owns this entry */
77 
78  /* 0x24 */
79  u16 vrfmap_index; /* index of vrfmap */
80 
81  /* 0x26 */
82  u16 flags; /* Always need flags... */
83 #define CNAT_DB_FLAG_PORT_PAIR (1<<0)
84 #define CNAT_DB_FLAG_TCP_ACTIVE (1<<1)
85 #define CNAT_DB_FLAG_ENTRY_FREE (1<<2)
86 #define CNAT_DB_FLAG_UDP_ACTIVE (1<<3)
87 #define CNAT_DB_FLAG_STATIC_PORT (1<<4)
88 #define CNAT_DB_FLAG_ALG_ENTRY (1<<5)
89 
90  /* 0x28 */
91  u32 dst_ipv4; /* pointer to ipv4 dst list, used in evil mode */
92 
93  /* 0x2C */
94  u32 out2in_pkts; /* pkt counters */
95 
96  /* 0x30 */
97  u32 in2out_pkts;
98 
99  /* 0x34 */
100  u32 entry_expires; /* timestamp used to expire translations */
101 
102  /* 0x38 */
103  union { /* used by FTP ALG, pkt len delta due to FTP PORT cmd */
104  u16 delta;
105  i8 alg_dlt[2]; /* two delta values, 0 for previous, 1 for current */
106  u16 il; /* Used to indicate if interleaved mode is used
107  in case of RTSP ALG */
108  } alg;
109 
110  /* 0x 48 */
111  u32 tcp_seq_num; /* last tcp (FTP) seq # that has pkt len change due to PORT */
112 
114 
115  /* 0x4C... last byte -- 72 total */
117 #endif
Definition: cnat_db.h:153
char i8
Definition: types.h:45
unsigned long u64
Definition: types.h:89
unsigned int u32
Definition: types.h:88
unsigned short u16
Definition: types.h:57
cnat_timeout_t destn_key
Definition: vcgn_db.h:113
u32 flags
Definition: vhost-user.h:73