25 #define NAT44_SESSION_CREATE_LEN 26 26 #define NAT_ADDRESSES_EXHAUTED_LEN 13 27 #define MAX_ENTRIES_PER_USER_LEN 17 29 #define NAT44_SESSION_CREATE_FIELD_COUNT 8 30 #define NAT_ADDRESSES_EXHAUTED_FIELD_COUNT 3 31 #define MAX_ENTRIES_PER_USER_FIELD_COUNT 4 128 udp->
dst_port = clib_host_to_net_u16 (collector_port);
129 udp->
length = clib_host_to_net_u16 (
vec_len (rewrite) -
sizeof (*ip));
194 ip->
length = clib_host_to_net_u16 ((
u8 *) f - (
u8 *) ip);
277 *offset = (
u32) (((
u8 *)(s+1)) - (
u8 *)tp);
301 (sizeof (*ip) +
sizeof (*udp) +
304 (sizeof (*ip) +
sizeof (*udp)));
325 u16 nat_src_port,
u32 vrf_id,
int do_flush)
355 clib_warning (
"can't allocate buffer for NAT IPFIX event");
388 u64 time_stamp = clib_host_to_net_u64 (now);
390 offset +=
sizeof (time_stamp);
393 offset +=
sizeof (nat_event);
396 offset +=
sizeof (src_ip);
399 offset +=
sizeof (nat_src_ip);
402 offset +=
sizeof (proto);
405 offset +=
sizeof (src_port);
408 offset +=
sizeof (nat_src_port);
411 offset +=
sizeof (vrf_id);
455 clib_warning (
"can't allocate buffer for NAT IPFIX event");
488 u64 time_stamp = clib_host_to_net_u64 (now);
490 offset +=
sizeof (time_stamp);
493 offset +=
sizeof (nat_event);
496 offset +=
sizeof (pool_id);
541 clib_warning (
"can't allocate buffer for NAT IPFIX event");
574 u64 time_stamp = clib_host_to_net_u64 (now);
576 offset +=
sizeof (time_stamp);
579 offset +=
sizeof (nat_event);
582 offset +=
sizeof (quota_event);
585 offset +=
sizeof (src_ip);
704 (
u8 *) &a,
sizeof (a));
739 (
u8 *) &a,
sizeof (a));
770 u8 e = enable ? 1 : 0;
777 memset (&a, 0,
sizeof (a));
780 a.
src_port = src_port ? src_port : UDP_DST_PORT_ipfix;
782 if (sm->deterministic)
790 clib_warning (
"vnet_flow_report_add_del returned %d", rv);
802 clib_warning (
"vnet_flow_report_add_del returned %d", rv);
812 clib_warning (
"vnet_flow_report_add_del returned %d", rv);
u32 max_entries_per_user_next_record_offset
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
vlib_frame_t * max_entries_per_user_frame
void snat_ipfix_logging_max_entries_per_user(u32 src_ip)
Generate maximum entries per user exceeded event.
static void snat_ipfix_logging_nat44_ses(u8 nat_event, u32 src_ip, u32 nat_src_ip, snat_protocol_t snat_proto, u16 src_port, u16 nat_src_port, u32 vrf_id, int do_flush)
static u8 * snat_template_rewrite(flow_report_main_t *frm, flow_report_t *fr, ip4_address_t *collector_address, ip4_address_t *src_address, u16 collector_port, nat_event_t event, quota_exceed_event_t quota_event)
Create an IPFIX template packet rewrite string.
static void snat_ipfix_send(flow_report_main_t *frm, vlib_frame_t *f, vlib_buffer_t *b0, u16 template_id)
vlib_frame_t * addr_exhausted_frame
static u32 ipfix_e_id_length(int e, u16 id, u16 length)
static f64 vlib_time_now(vlib_main_t *vm)
int vnet_flow_report_add_del(flow_report_main_t *frm, vnet_flow_report_add_del_args_t *a, u16 *template_id)
u16 addr_exhausted_template_id
ip4_address_t src_address
void snat_ipfix_logging_init(vlib_main_t *vm)
Initialize SNAT IPFIX logging.
static void snat_ipfix_logging_addr_exhausted(u32 pool_id, int do_flush)
int snat_ipfix_logging_enable_disable(int enable, u32 domain_id, u16 src_port)
Enable/disable SNAT IPFIX logging.
static void snat_ipfix_logging_max_entries_per_usr(u32 src_ip, int do_flush)
u8 enabled
S-NAT IPFIX logging enabled.
void snat_ipfix_logging_nat44_ses_delete(u32 src_ip, u32 nat_src_ip, snat_protocol_t snat_proto, u16 src_port, u16 nat_src_port, u32 vrf_id)
Generate NAT44 session delete event.
u8 * snat_template_rewrite_max_entries_per_usr(flow_report_main_t *frm, flow_report_t *fr, ip4_address_t *collector_address, ip4_address_t *src_address, u16 collector_port)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
ip4_address_t ipfix_collector
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
flow_report_stream_t * streams
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static void snat_ipfix_logging_max_entries_per_usr_rpc_cb(snat_ipfix_logging_max_entries_per_user_args_t *a)
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
vnet_flow_rewrite_callback_t * rewrite_callback
static void snat_ipfix_logging_nat44_ses_rpc_cb(snat_ipfix_logging_nat44_ses_args_t *a)
u32 addr_exhausted_next_record_offset
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
#define NAT44_SESSION_CREATE_FIELD_COUNT
flow_report_main_t flow_report_main
u16 current_length
Nbytes between current data and the end of this buffer.
vlib_frame_t * nat44_session_frame
frames containing ipfix buffers
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
#define VLIB_BUFFER_FLOW_REPORT
u32 stream_index
stream index
static u32 version_length(u16 length)
#define NAT44_SESSION_CREATE_LEN
u64 milisecond_time_0
Time reference pair.
u16 max_entries_per_user_template_id
vlib_buffer_t * nat44_session_buffer
ipfix buffers under construction
snat_ipfix_logging_main_t snat_ipfix_logging_main
u8 * snat_template_rewrite_addr_exhausted(flow_report_main_t *frm, flow_report_t *fr, ip4_address_t *collector_address, ip4_address_t *src_address, u16 collector_port)
#define NAT_ADDRESSES_EXHAUTED_LEN
static u32 ipfix_id_count(u16 id, u16 count)
#define clib_warning(format, args...)
#define clib_memcpy(a, b, c)
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
static u64 unix_time_now_nsec(void)
static u8 snat_proto_to_ip_proto(snat_protocol_t snat_proto)
u16 nat44_session_template_id
template IDs
void snat_ipfix_logging_addresses_exhausted(u32 pool_id)
Generate NAT addresses exhausted event.
u16 ip4_tcp_udp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
vlib_buffer_t * addr_exhausted_buffer
#define NAT_ADDRESSES_EXHAUTED_FIELD_COUNT
static void snat_ipfix_header_create(flow_report_main_t *frm, vlib_buffer_t *b0, u32 *offset)
void snat_ipfix_logging_nat44_ses_create(u32 src_ip, u32 nat_src_ip, snat_protocol_t snat_proto, u16 src_port, u16 nat_src_port, u32 vrf_id)
Generate NAT44 session create event.
snat_protocol_t snat_proto
u8 * snat_template_rewrite_nat44_session(flow_report_main_t *frm, flow_report_t *fr, ip4_address_t *collector_address, ip4_address_t *src_address, u16 collector_port)
template key/value backing page structure
static u32 ipfix_set_id_length(u16 set_id, u16 length)
vlib_frame_t * snat_data_callback_max_entries_per_usr(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void snat_ipfix_logging_addr_exhausted_rpc_cb(snat_ipfix_logging_addr_exhausted_args_t *a)
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
vlib_frame_t * snat_data_callback_addr_exhausted(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
vnet_flow_data_callback_t * flow_data_callback
struct clib_bihash_value offset
template key/value backing page structure
vlib_buffer_t * max_entries_per_user_buffer
static void vlib_buffer_init_for_free_list(vlib_buffer_t *dst, vlib_buffer_free_list_t *fl)
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, u32 free_list_index)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
vlib_frame_t * snat_data_callback_nat44_session(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
#define MAX_ENTRIES_PER_USER_LEN
#define MAX_ENTRIES_PER_USER_FIELD_COUNT
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)
u32 nat44_session_next_record_offset
next record offset