FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
syslog.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /**
16  * @file syslog.c
17  * RFC5424 syslog protocol implementation
18  */
19 
20 #include <unistd.h>
21 #include <vnet/fib/fib_table.h>
22 #include <vnet/ip/format.h>
23 #include <vnet/syslog/syslog.h>
24 #include <vnet/syslog/syslog_udp.h>
25 
26 #define SYSLOG_VERSION "1"
27 #define NILVALUE "-"
28 #define DEFAULT_UDP_PORT 514
29 #define DEFAULT_MAX_MSG_SIZE 480
30 
31 #define encode_priority(f, p) ((f << 3) | p)
32 
34 
35 /* format timestamp RFC5424 6.2.3. */
36 static u8 *
37 format_syslog_timestamp (u8 * s, va_list * args)
38 {
39  f64 timestamp = va_arg (*args, f64);
40  struct tm *tm;
41  word msec;
42 
43  time_t t = timestamp;
44  tm = gmtime (&t);
45  msec = 1e6 * (timestamp - t);
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,
48  tm->tm_sec, msec);
49 }
50 
51 /* format header RFC5424 6.2. */
52 static u8 *
53 format_syslog_header (u8 * s, va_list * args)
54 {
56  syslog_header_t *h = va_arg (*args, syslog_header_t *);
57  u32 pri = encode_priority (h->facility, h->severity);
58 
59  return format (s, "<%d>%s %U %U %s %d %s", pri, SYSLOG_VERSION,
60  format_syslog_timestamp, h->timestamp + sm->time_offset,
62  h->app_name ? h->app_name : NILVALUE, sm->procid,
63  h->msgid ? h->msgid : NILVALUE);
64 }
65 
66 /* format strucured data elements RFC5424 6.3. */
67 static u8 *
68 format_syslog_structured_data (u8 * s, va_list * args)
69 {
70  u8 **sds = va_arg (*args, u8 **);
71  int i;
72 
73  if (vec_len (sds))
74  {
75  for (i = 0; i < vec_len (sds); i++)
76  s = format (s, "[%v]", sds[i]);
77  }
78  /* if zero structured data elemts field must contain NILVALUE */
79  else
80  s = format (s, "%s", NILVALUE);
81 
82  return s;
83 }
84 
85 static u8 *
86 format_syslog_msg (u8 * s, va_list * args)
87 {
88  syslog_msg_t *m = va_arg (*args, syslog_msg_t *);
89 
90  s =
91  format (s, "%U %U", format_syslog_header, &m->header,
93  /* free-form message is optional */
94  if (m->msg)
95  s = format (s, " %s", m->msg);
96 
97  return s;
98 }
99 
100 void
102 {
103  u8 *sd;
104 
105  sd = format (0, "%s", sd_id);
106  vec_add1 (syslog_msg->structured_data, sd);
107  syslog_msg->curr_sd_index++;
108 }
109 
110 void
112  ...)
113 {
114  va_list va;
115  u8 *value;
116 
117  va_start (va, fmt);
118  value = va_format (0, fmt, &va);
119  va_end (va);
121 
122  syslog_msg->structured_data[syslog_msg->curr_sd_index] =
123  format (syslog_msg->structured_data[syslog_msg->curr_sd_index],
124  " %s=\"%s\"", name, value);
125  vec_free (value);
126 }
127 
128 void
130 {
131  va_list va;
132  u8 *msg;
133 
134  va_start (va, fmt);
135  msg = va_format (0, fmt, &va);
136  va_end (va);
138 
139  syslog_msg->msg = msg;
140 }
141 
142 void
144  syslog_severity_t severity, char *app_name, char *msgid)
145 {
147 
148  syslog_msg->header.facility = facility;
149  syslog_msg->header.severity = severity;
150  syslog_msg->header.timestamp = vlib_time_now (vm);
151  syslog_msg->header.app_name = app_name;
152  syslog_msg->header.msgid = msgid;
153  syslog_msg->structured_data = 0;
154  syslog_msg->curr_sd_index = ~0;
155  syslog_msg->msg = 0;
156 }
157 
158 int
160 {
161  syslog_main_t *sm = &syslog_main;
163  u32 bi, msg_len, *to_next;
164  u8 *tmp;
165  vlib_buffer_t *b;
166  vlib_frame_t *f;
167  int i;
168 
169  if (vlib_buffer_alloc (vm, &bi, 1) != 1)
170  return -1;
171 
172  b = vlib_get_buffer (vm, bi);
173 
174  /* one message per UDP datagram RFC5426 3.1. */
175  tmp = format (0, "%U", format_syslog_msg, syslog_msg);
176  msg_len = vec_len (tmp) - (vec_c_string_is_terminated (tmp) ? 1 : 0);
177  msg_len = msg_len < sm->max_msg_size ? msg_len : sm->max_msg_size;
178  clib_memcpy_fast (b->data, tmp, msg_len);
179  b->current_length = msg_len;
180  vec_free (tmp);
181 
182  vec_free (syslog_msg->msg);
183  for (i = 0; i < vec_len (syslog_msg->structured_data); i++)
184  vec_free (syslog_msg->structured_data[i]);
185  vec_free (syslog_msg->structured_data);
186 
188 
190  to_next = vlib_frame_vector_args (f);
191  to_next[0] = bi;
192  f->n_vectors = 1;
194 
195  return 0;
196 }
197 
198 static uword
200 {
201  u32 *r = va_arg (*args, u32 *);
202 
203  if (0);
204 #define _(v,f,s) else if (unformat (input, s)) *r = SYSLOG_FACILITY_##f;
206 #undef _
207  else
208  return 0;
209 
210  return 1;
211 }
212 
213 static uword
215 {
216  u32 *r = va_arg (*args, u32 *);
217 
218  if (0);
219 #define _(v,f,s) else if (unformat (input, s)) *r = SYSLOG_SEVERITY_##f;
221 #undef _
222  else
223  return 0;
224 
225  return 1;
226 }
227 
228 static u8 *
229 format_syslog_severity (u8 * s, va_list * args)
230 {
231  u32 i = va_arg (*args, u32);
232  u8 *t = 0;
233 
234  switch (i)
235  {
236 #define _(v,f,str) case SYSLOG_SEVERITY_##f: t = (u8 *) str; break;
238 #undef _
239  default:
240  return format (s, "unknown");
241  }
242 
243  return format (s, "%s", t);
244 }
245 
247 set_syslog_sender (ip4_address_t * collector, u16 collector_port,
248  ip4_address_t * src, u32 vrf_id, u32 max_msg_size)
249 {
250  syslog_main_t *sm = &syslog_main;
251  u32 fib_index;
252 
253  if (max_msg_size < DEFAULT_MAX_MSG_SIZE)
254  return VNET_API_ERROR_INVALID_VALUE;
255 
256  if (collector->as_u32 == 0 || collector_port == 0 || src->as_u32 == 0)
257  return VNET_API_ERROR_INVALID_VALUE;
258 
259  if (vrf_id == ~0)
260  {
261  fib_index = ~0;
262  }
263  else
264  {
265  fib_index = fib_table_find (FIB_PROTOCOL_IP4, vrf_id);
266  if (fib_index == ~0)
267  return VNET_API_ERROR_NO_SUCH_FIB;
268  }
269 
270  sm->fib_index = fib_index;
271 
272  sm->collector.as_u32 = collector->as_u32;
273  sm->collector_port = (u16) collector_port;
274  sm->src_address.as_u32 = src->as_u32;
275  sm->max_msg_size = max_msg_size;
276 
277  return 0;
278 }
279 
280 static clib_error_t *
282  vlib_cli_command_t * cmd)
283 {
284  unformat_input_t _line_input, *line_input = &_line_input;
285  ip4_address_t collector, src;
286  u32 collector_port = DEFAULT_UDP_PORT;
287  u32 vrf_id = ~0;
288  u32 max_msg_size = DEFAULT_MAX_MSG_SIZE;
289  clib_error_t *ret = 0;
290 
291  collector.as_u32 = 0;
292  src.as_u32 = 0;
293 
294  /* Get a line of input. */
295  if (!unformat_user (input, unformat_line_input, line_input))
296  return 0;
297 
298  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
299  {
300  if (unformat
301  (line_input, "collector %U", unformat_ip4_address, &collector))
302  ;
303  else if (unformat (line_input, "port %u", &collector_port))
304  ;
305  else if (unformat (line_input, "src %U", unformat_ip4_address, &src))
306  ;
307  else if (unformat (line_input, "vrf-id %u", &vrf_id))
308  ;
309  else if (unformat (line_input, "max-msg-size %u", &max_msg_size))
310  ;
311  else
312  {
313  ret = clib_error_return (0, "Unknown input `%U'",
314  format_unformat_error, line_input);
315  goto done;
316  }
317  }
318 
319  if (collector.as_u32 == 0)
320  {
321  ret = clib_error_return (0, "collector address required");
322  goto done;
323  }
324 
325  if (src.as_u32 == 0)
326  {
327  ret = clib_error_return (0, "src address required");
328  goto done;
329  }
330 
331  if (max_msg_size < DEFAULT_MAX_MSG_SIZE)
332  {
333  ret =
334  clib_error_return (0, "too small max-msg-size value, minimum is %u",
336  goto done;
337  }
338 
340  set_syslog_sender (&collector, collector_port, &src, vrf_id,
341  max_msg_size);
342 
343  if (rv)
344  ret =
345  clib_error_return (0, "set syslog sender failed rv=%d:%U", (int) rv,
347 
348 done:
349  unformat_free (line_input);
350  return ret;
351 }
352 
353 static clib_error_t *
355  vlib_cli_command_t * cmd)
356 {
357  syslog_main_t *sm = &syslog_main;
358  u32 vrf_id = ~0;
359 
360  if (sm->fib_index != ~0)
362 
363  if (syslog_is_enabled ())
364  vlib_cli_output (vm, "collector %U:%u, src address %U, VRF ID %d, "
365  "max-msg-size %u",
368  vrf_id, sm->max_msg_size);
369  else
370  vlib_cli_output (vm, "syslog sender is disabled");
371 
372  return 0;
373 }
374 
375 static clib_error_t *
377  vlib_cli_command_t * cmd)
378 {
379  unformat_input_t _line_input, *line_input = &_line_input;
381  syslog_facility_t facility;
382  syslog_severity_t severity;
383  clib_error_t *ret = 0;
384  u8 *app_name = 0, *msgid = 0, *sd_id = 0, *param_name = 0, *param_value = 0;
385 
386  if (!syslog_is_enabled ())
387  return 0;
388 
389  /* Get a line of input. */
390  if (!unformat_user (input, unformat_line_input, line_input))
391  return 0;
392 
393  if (unformat (line_input, "%U", unformat_syslog_facility, &facility))
394  {
395  if (unformat (line_input, "%U", unformat_syslog_severity, &severity))
396  {
397  if (syslog_severity_filter_block (severity))
398  goto done;
399 
400  if (unformat (line_input, "%s", &app_name))
401  {
402  if (unformat (line_input, "%s", &msgid))
403  {
404  syslog_msg_init (&syslog_msg, facility, severity,
405  (char *) app_name, (char *) msgid);
406  while (unformat (line_input, "sd-id %s", &sd_id))
407  {
408  syslog_msg_sd_init (&syslog_msg, (char *) sd_id);
409  while (unformat
410  (line_input, "sd-param %s %s", &param_name,
411  &param_value))
412  {
414  (char *) param_name,
415  (char *) param_value);
416  vec_free (param_name);
417  vec_free (param_value);
418  }
419  vec_free (sd_id);
420  }
421  if (unformat_check_input (line_input) !=
424  format_unformat_input, line_input);
426  }
427  else
428  {
429  ret =
430  clib_error_return (0, "Unknown input `%U'",
431  format_unformat_error, line_input);
432  goto done;
433  }
434  }
435  else
436  {
437  ret =
438  clib_error_return (0, "Unknown input `%U'",
439  format_unformat_error, line_input);
440  goto done;
441  }
442  }
443  else
444  {
445  ret =
446  clib_error_return (0, "Unknown input `%U'", format_unformat_error,
447  line_input);
448  goto done;
449  }
450  }
451  else
452  {
453  ret =
454  clib_error_return (0, "Unknown input `%U'", format_unformat_error,
455  line_input);
456  goto done;
457  }
458 
459 done:
460  vec_free (app_name);
461  vec_free (msgid);
462  unformat_free (line_input);
463  return ret;
464 }
465 
466 static clib_error_t *
468  vlib_cli_command_t * cmd)
469 {
470  unformat_input_t _line_input, *line_input = &_line_input;
471  syslog_main_t *sm = &syslog_main;
472  clib_error_t *ret = 0;
473 
474  /* Get a line of input. */
475  if (!unformat_user (input, unformat_line_input, line_input))
476  return 0;
477 
478  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
479  {
480  if (unformat
481  (line_input, "severity %U", unformat_syslog_severity,
482  &sm->severity_filter))
483  ;
484  else
485  {
486  ret = clib_error_return (0, "Unknown input `%U'",
487  format_unformat_error, line_input);
488  goto done;
489  }
490  }
491 
492 done:
493  unformat_free (line_input);
494  return ret;
495 }
496 
497 static clib_error_t *
499  vlib_cli_command_t * cmd)
500 {
501  syslog_main_t *sm = &syslog_main;
502 
503  vlib_cli_output (vm, "severity-filter: %U", format_syslog_severity,
504  sm->severity_filter);
505 
506  return 0;
507 }
508 
509 /* *INDENT-OFF* */
510 /*?
511  * Set syslog sender configuration.
512  *
513  * @cliexpar
514  * @parblock
515  *
516  * Example of how to configure syslog sender:
517  * @cliexcmd{set syslog sender collector 10.10.10.10 port 514 src 172.16.2.2}
518  * @endparblock
519 ?*/
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>]",
526  .function = set_syslog_sender_command_fn,
527 };
528 
529 /*?
530  * Show syslog sender configuration.
531  *
532  * @cliexpar
533  * @parblock
534  *
535  * Example of how to display syslog sender configuration:
536  * @cliexstart{show syslog sender}
537  * collector 10.10.10.10:514, src address 172.16.2.2, VRF ID 0, max-msg-size 480
538  * @cliexend
539  * @endparblock
540 ?*/
542  .path = "show syslog sender",
543  .short_help = "show syslog sender",
544  .function = show_syslog_sender_command_fn,
545 };
546 
547 /*?
548  * This command generate test syslog message.
549  *
550  * @cliexpar
551  * @parblock
552  *
553  * Example of how to generate following syslog message
554  * '<em><180>1 2018-11-07T11:36:41.231759Z 172.16.1.1 test 10484 testMsg
555  * [exampleSDID@32473 eventID="1011" eventSource="App" iut="3"]
556  * this is message</em>'
557  * @cliexcmd{test syslog local6 warning test testMsg sd-id <!--
558  * --> exampleSDID@32473 sd-param eventID 1011 sd-param eventSource App <!--
559  * --> sd-param iut 3 this is message}
560  * @endparblock
561 ?*/
563  .path = "test syslog",
564  .short_help = "test syslog <facility> <severity> <app-name> <msgid> "
565  "[sd-id <sd-id> sd-param <name> <value>] [<message]",
566  .function = test_syslog_command_fn,
567 };
568 
569 /*?
570  * Set syslog severity filter, specified severity and greater match.
571  *
572  * @cliexpar
573  * @parblock
574  *
575  * Example of how to configure syslog severity filter:
576  * @cliexcmd{set syslog filter severity warning}
577  * @endparblock
578 ?*/
580  .path = "set syslog filter",
581  .short_help = "set syslog filter severity <severity>",
582  .function = set_syslog_filter_command_fn,
583 };
584 
585 /*?
586  * Show syslog severity filter.
587  *
588  * @cliexpar
589  * @parblock
590  *
591  * Example of how to display syslog severity filter:
592  * @cliexstart{show syslog filter}
593  * severity-filter: warning
594  * @cliexend
595  * @endparblock
596 ?*/
598  .path = "show syslog filter",
599  .short_help = "show syslog filter",
600  .function = show_syslog_filter_command_fn,
601 };
602 /* *INDENT-ON* */
603 
604 static clib_error_t *
606 {
607  syslog_main_t *sm = &syslog_main;
608  f64 vlib_time_0 = vlib_time_now (vm);
609  struct timeval timeval_0;
611 
612  sm->vnet_main = vnet_get_main ();
613 
614  sm->procid = getpid ();
615  gettimeofday (&timeval_0, 0);
616  sm->time_offset =
617  (f64) timeval_0.tv_sec + (((f64) timeval_0.tv_usec) * 1e-6) - vlib_time_0;
618 
619  sm->collector.as_u32 = 0;
620  sm->src_address.as_u32 = 0;
623  sm->fib_index = ~0;
624  sm->severity_filter = SYSLOG_SEVERITY_INFORMATIONAL;
625 
626  ip4_lookup_node = vlib_get_node_by_name (vm, (u8 *) "ip4-lookup");
628 
629  return 0;
630 }
631 
633 
634 /*
635  * fd.io coding-style-patch-verification: ON
636  *
637  * Local Variables:
638  * eval: (c-set-style "gnu")
639  * End:
640  */
format_unformat_input
u8 * format_unformat_input(u8 *s, va_list *va)
Definition: unformat.c:143
tmp
u32 * tmp
Definition: interface_output.c:1078
ip4_lookup_node
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
Definition: ip4_forward.c:104
vlib_frame_t::n_vectors
u16 n_vectors
Definition: node.h:387
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
DEFAULT_UDP_PORT
#define DEFAULT_UDP_PORT
Definition: syslog.c:28
set_syslog_filter_command_fn
static clib_error_t * set_syslog_filter_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: syslog.c:467
set_syslog_sender_command
static vlib_cli_command_t set_syslog_sender_command
(constructor) VLIB_CLI_COMMAND (set_syslog_sender_command)
Definition: syslog.c:520
syslog_add_udp_transport
void syslog_add_udp_transport(vlib_main_t *vm, u32 bi)
Add UDP/IP transport layer by prepending it to existing data.
Definition: syslog_udp.c:25
format_ip4_address
format_function_t format_ip4_address
Definition: format.h:73
syslog_header_t
syslog header
Definition: syslog.h:77
set_syslog_sender
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.
Definition: syslog.c:247
fib_table_get_table_id
u32 fib_table_get_table_id(u32 fib_index, fib_protocol_t proto)
Get the Table-ID of the FIB from protocol and index.
Definition: fib_table.c:1095
syslog_main_t::procid
u32 procid
process ID RFC5424 6.2.6.
Definition: syslog.h:112
syslog_msg_t::structured_data
u8 ** structured_data
structured data RFC5424 6.3.
Definition: syslog.h:102
foreach_syslog_severity
@ foreach_syslog_severity
Definition: syslog.h:72
syslog_facility_t
syslog_facility_t
Definition: syslog.h:51
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
f
vlib_frame_t * f
Definition: interface_output.c:1080
show_syslog_filter_command_fn
static clib_error_t * show_syslog_filter_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: syslog.c:498
unformat_line_input
unformat_function_t unformat_line_input
Definition: format.h:275
name
string name[64]
Definition: fib.api:25
vec_c_string_is_terminated
#define vec_c_string_is_terminated(V)
Test whether a vector is a NULL terminated c-string.
Definition: vec.h:1124
format_syslog_severity
static u8 * format_syslog_severity(u8 *s, va_list *args)
Definition: syslog.c:229
syslog_main_t::src_address
ip4_address_t src_address
IPv4 address of sender (source)
Definition: syslog.h:124
syslog_msg
static u8 * syslog_msg
Definition: main.c:95
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vlib_cli_command_t::path
char * path
Definition: cli.h:96
ip4_address_t::as_u32
u32 as_u32
Definition: ip4_packet.h:57
syslog_main_t::ip4_lookup_node_index
u32 ip4_lookup_node_index
ip4-lookup node index
Definition: syslog.h:136
fib_table.h
u16
unsigned short u16
Definition: types.h:57
show_syslog_sender_command
static vlib_cli_command_t show_syslog_sender_command
(constructor) VLIB_CLI_COMMAND (show_syslog_sender_command)
Definition: syslog.c:541
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
syslog_severity_t
syslog_severity_t
Definition: syslog.h:69
NILVALUE
#define NILVALUE
Definition: syslog.c:27
va_format
__clib_export u8 * va_format(u8 *s, const char *fmt, va_list *va)
Definition: format.c:391
format_vnet_api_errno
static u8 * format_vnet_api_errno(u8 *s, va_list *args)
Definition: api_errno.h:172
syslog_msg_init
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.
Definition: syslog.c:143
unformat_input_t
struct _unformat_input_t unformat_input_t
r
vnet_hw_if_output_node_runtime_t * r
Definition: interface_output.c:1071
vlib_frame_t
Definition: node.h:372
vlib_get_frame_to_node
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
Definition: main.c:184
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
syslog_main_t::vnet_main
vnet_main_t * vnet_main
convenience variables
Definition: syslog.h:139
h
h
Definition: flowhash_template.h:372
syslog_main_t::severity_filter
syslog_severity_t severity_filter
severity filter (specified severity and greater match)
Definition: syslog.h:133
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
show_syslog_sender_command_fn
static clib_error_t * show_syslog_sender_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: syslog.c:354
vlib_put_frame_to_node
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
Definition: main.c:218
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
unformat_free
static void unformat_free(unformat_input_t *i)
Definition: format.h:155
syslog_main
syslog_main_t syslog_main
Definition: syslog.c:33
format_syslog_header
static u8 * format_syslog_header(u8 *s, va_list *args)
Definition: syslog.c:53
syslog_main_t::collector_port
u16 collector_port
UDP port number of remote host (destination)
Definition: syslog.h:121
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
set_syslog_sender_command_fn
static clib_error_t * set_syslog_sender_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: syslog.c:281
vlib_buffer_alloc
static __clib_warn_unused_result u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
Definition: buffer_funcs.h:708
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
format.h
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
test_syslog_command_fn
static clib_error_t * test_syslog_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: syslog.c:376
syslog_main_t::max_msg_size
u32 max_msg_size
message size limit
Definition: syslog.h:130
SYSLOG_VERSION
#define SYSLOG_VERSION
Definition: syslog.c:26
uword
u64 uword
Definition: types.h:112
syslog_severity_filter_block
static int syslog_severity_filter_block(syslog_severity_t s)
Severity filter test.
Definition: syslog.h:210
format_syslog_msg
static u8 * format_syslog_msg(u8 *s, va_list *args)
Definition: syslog.c:86
format_syslog_timestamp
static u8 * format_syslog_timestamp(u8 *s, va_list *args)
Definition: syslog.c:37
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
f64
double f64
Definition: types.h:142
syslog_udp.h
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
app_name
static char * app_name
Definition: vapi_cpp_test.cpp:33
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
src
vl_api_address_t src
Definition: gre.api:54
ip4_address_t
Definition: ip4_packet.h:50
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
fmt
int cJSON_bool fmt
Definition: cJSON.h:160
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
syslog.h
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
DEFAULT_MAX_MSG_SIZE
#define DEFAULT_MAX_MSG_SIZE
Definition: syslog.c:29
syslog_msg_add_msg
void syslog_msg_add_msg(syslog_msg_t *syslog_msg, char *fmt,...)
Add free-form message RFC5424 6.4.
Definition: syslog.c:129
syslog_main_t::collector
ip4_address_t collector
IPv4 address of remote host (destination)
Definition: syslog.h:118
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vlib_get_node_by_name
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
format
description fragment has unexpected format
Definition: map.api:433
test_syslog_command
static vlib_cli_command_t test_syslog_command
(constructor) VLIB_CLI_COMMAND (test_syslog_command)
Definition: syslog.c:562
syslog_msg_t::header
syslog_header_t header
header
Definition: syslog.h:99
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
syslog_msg_add_sd_param
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.
Definition: syslog.c:111
unformat_syslog_severity
static uword unformat_syslog_severity(unformat_input_t *input, va_list *args)
Definition: syslog.c:214
unformat_syslog_facility
static uword unformat_syslog_facility(unformat_input_t *input, va_list *args)
Definition: syslog.c:199
value
u8 value
Definition: qos.api:54
syslog_msg_t::msg
u8 * msg
free-form message RFC5424 6.4.
Definition: syslog.h:106
format_syslog_structured_data
static u8 * format_syslog_structured_data(u8 *s, va_list *args)
Definition: syslog.c:68
syslog_is_enabled
static int syslog_is_enabled(void)
Check if syslog logging is enabled.
Definition: syslog.h:197
syslog_msg_t
syslog message
Definition: syslog.h:96
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
syslog_main_t::time_offset
f64 time_offset
time offset
Definition: syslog.h:115
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
syslog_main_t
Definition: syslog.h:109
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
vec_terminate_c_string
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
Definition: vec.h:1132
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
syslog_main_t::fib_index
u32 fib_index
FIB table index.
Definition: syslog.h:127
set_syslog_filter_command
static vlib_cli_command_t set_syslog_filter_command
(constructor) VLIB_CLI_COMMAND (set_syslog_filter_command)
Definition: syslog.c:579
syslog_msg_sd_init
void syslog_msg_sd_init(syslog_msg_t *syslog_msg, char *sd_id)
Initialize structured data element.
Definition: syslog.c:101
word
i64 word
Definition: types.h:111
rv
int __clib_unused rv
Definition: application.c:491
syslog_msg_send
int syslog_msg_send(syslog_msg_t *syslog_msg)
Send syslog message.
Definition: syslog.c:159
unformat_ip4_address
unformat_function_t unformat_ip4_address
Definition: format.h:68
vrf_id
u32 vrf_id
Definition: nat44_ed.api:1053
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
vlib_cli_command_t
Definition: cli.h:92
encode_priority
#define encode_priority(f, p)
Definition: syslog.c:31
fib_table_find
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1106
timestamp
f64 timestamp
Definition: vpe_types.api:28
foreach_syslog_facility
@ foreach_syslog_facility
Definition: syslog.h:54
show_syslog_filter_command
static vlib_cli_command_t show_syslog_filter_command
(constructor) VLIB_CLI_COMMAND (show_syslog_filter_command)
Definition: syslog.c:597
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
vnet_api_error_t
vnet_api_error_t
Definition: api_errno.h:162
syslog_init
static clib_error_t * syslog_init(vlib_main_t *vm)
Definition: syslog.c:605
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111