2 * Copyright (c) 2021 David Lamparter, for NetDEF, Inc.
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef _FRR_ZLOG_5424_H
18 #define _FRR_ZLOG_5424_H
24 #include "zlog_targets.h"
31 /* can be used to disable a target temporarily */
32 ZLOG_5424_DST_NONE
= 0,
39 #define ZLOG_5424_DST_LAST ZLOG_5424_DST_UNIX
42 enum zlog_5424_format
{
48 #define ZLOG_FMT_LAST ZLOG_FMT_JOURNALD
51 /* actual RCU'd logging backend */
54 struct zlog_cfg_5424
{
55 struct zlt_5424
*active
;
57 pthread_mutex_t cfg_mtx
;
59 /* general settings for all dsts */
70 enum zlog_5424_format fmt
;
72 /* destination specifics */
73 enum zlog_5424_dst dst
;
75 /* pre-opened FD. not the actual fd we log to */
78 /* file, fifo, unix */
87 /* remaining fields are internally used & updated by the 5424
88 * code - *not* config. don't set these.
91 /* sockets only - read handler to reconnect on errors */
92 struct thread_master
*master
;
93 struct thread
*t_reconnect
;
94 unsigned int reconn_backoff
, reconn_backoff_cur
, reconn_backoff_max
;
96 struct sockaddr_storage sa
;
100 /* these don't do malloc/free to allow using a static global */
101 extern void zlog_5424_init(struct zlog_cfg_5424
*zcf
);
103 /* keepopen = true => for shutdown, just zap the config, keep logging */
104 extern void zlog_5424_fini(struct zlog_cfg_5424
*zcf
, bool keepopen
);
106 /* apply metadata/config changes */
107 extern bool zlog_5424_apply_meta(struct zlog_cfg_5424
*zcf
);
109 /* apply changes requiring (re-)opening the destination
111 * also does log cycling/rotate & applies _meta at the same time
113 extern bool zlog_5424_apply_dst(struct zlog_cfg_5424
*zcf
);
115 /* SIGHUP log rotation */
116 extern bool zlog_5424_rotate(struct zlog_cfg_5424
*zcf
);
118 extern void zlog_5424_state(struct zlog_cfg_5424
*zcf
, size_t *lost_msgs
,
119 int *last_errno
, bool *stale_errno
,
120 struct timeval
*err_ts
);
122 /* this is the dynamically allocated "variant" */
123 PREDECL_RBTREE_UNIQ(targets
);
125 struct zlog_cfg_5424_user
{
126 struct targets_item targets_item
;
129 struct zlog_cfg_5424 cfg
;
133 /* non-const, always same as cfg.filename */
136 /* uid/gid strings to write back out in show config */
148 DECLARE_QOBJ_TYPE(zlog_cfg_5424_user
);
150 extern void log_5424_cmd_init(void);
152 #endif /* _FRR_ZLOG_5424_H */