FD.io VPP  v17.01-9-ge7dcee4
Vector Packet Processing
cnat_syslog.h
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * cnat_syslog.h
4  *
5  * Copyright (c) 2011-2013 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 __CNAT_SYSLOG_H__
21 #define __CNAT_SYSLOG_H__
22 
23 #include <vlib/vlib.h>
24 #include <vnet/vnet.h>
25 #include <vnet/pg/pg.h>
26 #include <vppinfra/error.h>
27 
28 #include "cnat_db.h"
29 #include "nat64_db.h"
30 #include "cnat_log_common.h"
31 #include "dslite_defs.h"
32 
33 #define SYSLOG_CONFIG_DEBUG_PRINTF(level, ...) \
34  if (config_debug_level > level) PLATFORM_DEBUG_PRINT(__VA_ARGS__);
35 
36 
37 /* one time call at the beginning */
39 
40 /*
41  * unconditional call
42  * will check logging config inside
43  */
45  cnat_vrfmap_t *vrfmap);
46 
47 /*
48  * unconditional call
49  * will check logging config inside
50  */
52  cnat_vrfmap_t *vrfmap);
53 
55  dslite_table_entry_t *dslite_entry, cnat_session_entry_t *sdb
56 #ifndef NO_BULK_LOGGING
57  , int bulk_alloc
58 #endif
59  );
60 
62  dslite_key_t * key,
63  dslite_table_entry_t *dslite_entry);
64 
65 #define SYSLOG_TIMESTAMP_LENGTH 20
66 
67 #define CNAT_SYSLOG_VERSION_NUMBER 1
68 #define CNAT_SYSLOG_PRIORITY 16*8+6
69 /* facility = local0 + severity = info */
70 
71 #define MAX_SYSLOG_HOSTNAME_LEN 32
72 
73 /* 6 for priority + space
74  * 2 for version + space
75  * 21 YYYY MMM DD HH:MM:SS + space
76  * 33 for hostname + space
77  * 4 for App Name (-) + space + Proc ID (-) + space
78  * 7 for Msg ID (DSLite is the longest Msg ID so far + space
79  * 2 for Structured data (-) + space
80  */
81 #define MAX_SYSLOG_HEADER_LEN 75
82 
83 /* 18 for Event Name (Portblockrunout is the longest as of now)
84  * 3 for L4 (including space)
85  * 16 for original souce IP + space
86  * 33 for inside vrf name + space
87  * 40 for original source IPV6 + space
88  * 16 for translated source IP + space
89  * 6 for original port + space
90  * 6 for translated first source port + space
91  * 5 for translated last source port
92  * 2 for [] enclosure
93  */
94 #define MAX_SYSLOG_RECORD_LEN 145
95 
96 typedef enum {
100 
101 typedef enum {
112 
113 /*
114  * This structure store the Syslog Logging information on per
115  * collector basis. This structure is allocated from a pool and index
116  * to this structure is stored VRF MAP structures
117  */
118 typedef struct {
119  /*
120  * nat64_id will be 0 for nat44 config and i_vrf_id, i_vrf will be 0
121  * for nat64 config. Nat64_id will be used while nat64 collector is
122  * search and i_vrf* for nat44 collector
123  */
124  /* Similarly for ds_lite, ds_lite_id will be used and nat64_id,
125  * ivrf_id shall be set to 0
126  */
127  u32 i_vrf_id; /* Inside VRF ID corresponding to this collector */
128  u16 i_vrf; /* Inside VRF (uidb_index) corresponding to this collector */
129  u16 ds_lite_id; /* DS Lite instance for this collector */
130  u16 port; /* Destination port number of the collector */
131 
132  /*
133  * This field determines the maximum size of the Syslog information
134  * that can be stored in a logging packet
135  */
137  u32 ipv4_address; /* Destination IP address of the collector */
138  /*
139  * Timestamp in UNIX seconds corresponding to when the current
140  * logging packet was created
141  */
143 
144  /*
145  * Indicates if the entry is already deleted
146  */
148 
151 
152  char header_hostname[MAX_SYSLOG_HOSTNAME_LEN];
153  char vrf_name[VRF_NAME_LEN_STORED];
156  /*
157  * current logging context
158  */
161 
163 
164 
165 /*
166  * Global structure for CGN APP configuration
167  */
168 typedef struct {
169 
171 
172  /*
173  * Whether we have initialized the Syslog information
174  */
176 
178 
179 typedef struct {
184 
187 
188 #define SYSLOG_DEF_PATH_MTU 1500
189 
190 #endif /* __CNAT_SYSLOG_H__ */
syslog_event_type_t
Definition: cnat_syslog.h:101
Definition: cnat_db.h:153
void cnat_syslog_ds_lite_mapping_create(cnat_main_db_entry_t *db, dslite_table_entry_t *dslite_entry, cnat_session_entry_t *sdb, int bulk_alloc)
spp_ctx_t * current_logging_context
Definition: cnat_syslog.h:159
Definition: dslite_defs.h:106
syslog_service_type_t
Definition: cnat_syslog.h:96
unsigned long u64
Definition: types.h:89
void cnat_syslog_log_mapping_delete(cnat_main_db_entry_t *db, cnat_vrfmap_t *vrfmap)
Definition: cnat_syslog.c:423
cnat_syslog_global_info_t cnat_syslog_global_info
Definition: cnat_syslog.c:37
spp_ctx_t * queued_logging_context
Definition: cnat_syslog.h:160
void cnat_syslog_logging_init()
Definition: cnat_syslog.c:412
#define VRF_NAME_LEN_STORED
Definition: cnat_db.h:27
void cnat_syslog_log_mapping_create(cnat_main_db_entry_t *db, cnat_vrfmap_t *vrfmap)
Definition: cnat_syslog.c:417
unsigned int u32
Definition: types.h:88
Definition: cnat_db.h:336
cnat_syslog_logging_info_t * cnat_syslog_logging_info_pool
Definition: cnat_syslog.c:38
unsigned short u16
Definition: types.h:57
void cnat_syslog_ds_lite_port_limit_exceeded(dslite_key_t *key, dslite_table_entry_t *dslite_entry)
Definition: cnat_syslog.c:429
unsigned char u8
Definition: types.h:56
struct _spp_ctx spp_ctx_t
#define MAX_SYSLOG_HOSTNAME_LEN
Definition: cnat_syslog.h:71