|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
26 #define SYSLOG_VERSION "1"
28 #define DEFAULT_UDP_PORT 514
29 #define DEFAULT_MAX_MSG_SIZE 480
31 #define encode_priority(f, p) ((f << 3) | p)
46 return format (s,
"%4d-%02d-%02dT%02d:%02d:%02d.%06dZ", 1900 + tm->tm_year,
47 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min,
70 u8 **sds = va_arg (*args,
u8 **);
105 sd =
format (0,
"%s", sd_id);
163 u32 bi, msg_len, *to_next;
201 u32 *
r = va_arg (*args,
u32 *);
204 #define _(v,f,s) else if (unformat (input, s)) *r = SYSLOG_FACILITY_##f;
216 u32 *
r = va_arg (*args,
u32 *);
219 #define _(v,f,s) else if (unformat (input, s)) *r = SYSLOG_SEVERITY_##f;
236 #define _(v,f,str) case SYSLOG_SEVERITY_##f: t = (u8 *) str; break;
240 return format (s,
"unknown");
243 return format (s,
"%s", t);
254 return VNET_API_ERROR_INVALID_VALUE;
256 if (collector->
as_u32 == 0 || collector_port == 0 ||
src->as_u32 == 0)
257 return VNET_API_ERROR_INVALID_VALUE;
267 return VNET_API_ERROR_NO_SUCH_FIB;
303 else if (
unformat (line_input,
"port %u", &collector_port))
309 else if (
unformat (line_input,
"max-msg-size %u", &max_msg_size))
319 if (collector.
as_u32 == 0)
384 u8 *
app_name = 0, *msgid = 0, *sd_id = 0, *param_name = 0, *param_value = 0;
402 if (
unformat (line_input,
"%s", &msgid))
406 while (
unformat (line_input,
"sd-id %s", &sd_id))
410 (line_input,
"sd-param %s %s", ¶m_name,
415 (
char *) param_value);
521 .path =
"set syslog sender",
522 .short_help =
"set syslog sender "
523 "collector <ip4-address> [port <port>] "
524 "src <ip4-address> [vrf-id <vrf-id>] "
525 "[max-msg-size <max-msg-size>]",
542 .path =
"show syslog sender",
543 .short_help =
"show syslog sender",
563 .path =
"test syslog",
564 .short_help =
"test syslog <facility> <severity> <app-name> <msgid> "
565 "[sd-id <sd-id> sd-param <name> <value>] [<message]",
580 .path =
"set syslog filter",
581 .short_help =
"set syslog filter severity <severity>",
598 .path =
"show syslog filter",
599 .short_help =
"show syslog filter",
609 struct timeval timeval_0;
615 gettimeofday (&timeval_0, 0);
617 (
f64) timeval_0.tv_sec + (((
f64) timeval_0.tv_usec) * 1e-6) - vlib_time_0;
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
static clib_error_t * set_syslog_filter_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vlib_cli_command_t set_syslog_sender_command
(constructor) VLIB_CLI_COMMAND (set_syslog_sender_command)
void syslog_add_udp_transport(vlib_main_t *vm, u32 bi)
Add UDP/IP transport layer by prepending it to existing data.
vnet_api_error_t set_syslog_sender(ip4_address_t *collector, u16 collector_port, ip4_address_t *src, u32 vrf_id, u32 max_msg_size)
Set syslog sender configuration.
u32 fib_table_get_table_id(u32 fib_index, fib_protocol_t proto)
Get the Table-ID of the FIB from protocol and index.
u32 procid
process ID RFC5424 6.2.6.
u8 ** structured_data
structured data RFC5424 6.3.
@ foreach_syslog_severity
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static clib_error_t * show_syslog_filter_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_c_string_is_terminated(V)
Test whether a vector is a NULL terminated c-string.
static u8 * format_syslog_severity(u8 *s, va_list *args)
ip4_address_t src_address
IPv4 address of sender (source)
#define clib_error_return(e, args...)
u32 ip4_lookup_node_index
ip4-lookup node index
static vlib_cli_command_t show_syslog_sender_command
(constructor) VLIB_CLI_COMMAND (show_syslog_sender_command)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static u8 * format_vnet_api_errno(u8 *s, va_list *args)
void syslog_msg_init(syslog_msg_t *syslog_msg, syslog_facility_t facility, syslog_severity_t severity, char *app_name, char *msgid)
Initialize syslog message header.
vnet_hw_if_output_node_runtime_t * r
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
vnet_main_t * vnet_main
convenience variables
syslog_severity_t severity_filter
severity filter (specified severity and greater match)
static clib_error_t * show_syslog_sender_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
syslog_main_t syslog_main
static u8 * format_syslog_header(u8 *s, va_list *args)
u16 collector_port
UDP port number of remote host (destination)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static clib_error_t * set_syslog_sender_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static __clib_warn_unused_result u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
vnet_main_t * vnet_get_main(void)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static clib_error_t * test_syslog_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 max_msg_size
message size limit
static int syslog_severity_filter_block(syslog_severity_t s)
Severity filter test.
static u8 * format_syslog_msg(u8 *s, va_list *args)
static u8 * format_syslog_timestamp(u8 *s, va_list *args)
sll srl srl sll sra u16x4 i
#define VLIB_CLI_COMMAND(x,...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u16 current_length
Nbytes between current data and the end of this buffer.
#define DEFAULT_MAX_MSG_SIZE
void syslog_msg_add_msg(syslog_msg_t *syslog_msg, char *fmt,...)
Add free-form message RFC5424 6.4.
ip4_address_t collector
IPv4 address of remote host (destination)
#define vec_free(V)
Free vector's memory (no header).
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
description fragment has unexpected format
static vlib_cli_command_t test_syslog_command
(constructor) VLIB_CLI_COMMAND (test_syslog_command)
syslog_header_t header
header
#define VLIB_INIT_FUNCTION(x)
void syslog_msg_add_sd_param(syslog_msg_t *syslog_msg, char *name, char *fmt,...)
Add structured data elemnt parameter name-value pair RFC5424 6.3.3.
static uword unformat_syslog_severity(unformat_input_t *input, va_list *args)
static uword unformat_syslog_facility(unformat_input_t *input, va_list *args)
u8 * msg
free-form message RFC5424 6.4.
static u8 * format_syslog_structured_data(u8 *s, va_list *args)
static int syslog_is_enabled(void)
Check if syslog logging is enabled.
f64 time_offset
time offset
static vlib_main_t * vlib_get_main(void)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
u32 fib_index
FIB table index.
static vlib_cli_command_t set_syslog_filter_command
(constructor) VLIB_CLI_COMMAND (set_syslog_filter_command)
void syslog_msg_sd_init(syslog_msg_t *syslog_msg, char *sd_id)
Initialize structured data element.
int syslog_msg_send(syslog_msg_t *syslog_msg)
Send syslog message.
static f64 vlib_time_now(vlib_main_t *vm)
#define encode_priority(f, p)
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
@ foreach_syslog_facility
static vlib_cli_command_t show_syslog_filter_command
(constructor) VLIB_CLI_COMMAND (show_syslog_filter_command)
static clib_error_t * syslog_init(vlib_main_t *vm)
VLIB buffer representation.