2 *------------------------------------------------------------------
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:
10 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
20 #ifndef __CNAT_SYSLOG_H__
21 #define __CNAT_SYSLOG_H__
23 #include <vlib/vlib.h>
24 #include <vnet/vnet.h>
25 #include <vnet/pg/pg.h>
26 #include <vppinfra/error.h>
30 #include "cnat_log_common.h"
31 #include "dslite_defs.h"
33 #define SYSLOG_CONFIG_DEBUG_PRINTF(level, ...) \
34 if (config_debug_level > level) PLATFORM_DEBUG_PRINT(__VA_ARGS__);
37 /* one time call at the beginning */
38 void cnat_syslog_logging_init();
42 * will check logging config inside
44 void cnat_syslog_log_mapping_create(cnat_main_db_entry_t * db,
45 cnat_vrfmap_t *vrfmap);
49 * will check logging config inside
51 void cnat_syslog_log_mapping_delete(cnat_main_db_entry_t * db,
52 cnat_vrfmap_t *vrfmap);
54 void cnat_syslog_ds_lite_mapping_create(cnat_main_db_entry_t *db,
55 dslite_table_entry_t *dslite_entry, cnat_session_entry_t *sdb
56 #ifndef NO_BULK_LOGGING
61 void cnat_syslog_ds_lite_port_limit_exceeded(
63 dslite_table_entry_t *dslite_entry);
65 #define SYSLOG_TIMESTAMP_LENGTH 20
67 #define CNAT_SYSLOG_VERSION_NUMBER 1
68 #define CNAT_SYSLOG_PRIORITY 16*8+6
69 /* facility = local0 + severity = info */
71 #define MAX_SYSLOG_HOSTNAME_LEN 32
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
81 #define MAX_SYSLOG_HEADER_LEN 75
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
94 #define MAX_SYSLOG_RECORD_LEN 145
99 } syslog_service_type_t;
105 sessionbased_withdraw,
106 sessionbased_assignD,
107 sessionbased_withdrawD,
110 max_syslog_event_type
111 } syslog_event_type_t;
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
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
124 /* Similarly for ds_lite, ds_lite_id will be used and nat64_id,
125 * ivrf_id shall be set to 0
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 */
133 * This field determines the maximum size of the Syslog information
134 * that can be stored in a logging packet
136 u16 max_length_minus_max_record_size;
137 u32 ipv4_address; /* Destination IP address of the collector */
139 * Timestamp in UNIX seconds corresponding to when the current
140 * logging packet was created
142 u32 current_logging_context_timestamp;
145 * Indicates if the entry is already deleted
152 char header_hostname[MAX_SYSLOG_HOSTNAME_LEN];
153 char vrf_name[VRF_NAME_LEN_STORED];
157 * current logging context
159 spp_ctx_t *current_logging_context;
160 spp_ctx_t *queued_logging_context;
162 } cnat_syslog_logging_info_t;
166 * Global structure for CGN APP configuration
170 u16 cnat_syslog_disp_node_index;
173 * Whether we have initialized the Syslog information
175 u8 cnat_syslog_init_done;
177 } cnat_syslog_global_info_t;
180 u64 logging_context_creation_fail_count;
181 u64 downstream_constipation_count;
182 u64 logging_context_creation_deferred_count;
183 } cnat_syslog_global_counters_t;
185 extern cnat_syslog_logging_info_t *cnat_syslog_logging_info_pool;
186 extern cnat_syslog_global_info_t cnat_syslog_global_info;
188 #define SYSLOG_DEF_PATH_MTU 1500
190 #endif /* __CNAT_SYSLOG_H__ */