1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2021 David Lamparter, for NetDEF, Inc.
6 #ifndef _FRR_ZLOG_5424_H
7 #define _FRR_ZLOG_5424_H
13 #include "zlog_targets.h"
20 /* can be used to disable a target temporarily */
21 ZLOG_5424_DST_NONE
= 0,
28 #define ZLOG_5424_DST_LAST ZLOG_5424_DST_UNIX
31 enum zlog_5424_format
{
37 #define ZLOG_FMT_LAST ZLOG_FMT_JOURNALD
40 /* actual RCU'd logging backend */
43 struct zlog_cfg_5424
{
44 struct zlt_5424
*active
;
46 pthread_mutex_t cfg_mtx
;
48 /* general settings for all dsts */
59 enum zlog_5424_format fmt
;
61 /* destination specifics */
62 enum zlog_5424_dst dst
;
64 /* pre-opened FD. not the actual fd we log to */
67 /* file, fifo, unix */
76 /* remaining fields are internally used & updated by the 5424
77 * code - *not* config. don't set these.
80 /* sockets only - read handler to reconnect on errors */
81 struct thread_master
*master
;
82 struct thread
*t_reconnect
;
83 unsigned int reconn_backoff
, reconn_backoff_cur
, reconn_backoff_max
;
85 struct sockaddr_storage sa
;
89 /* these don't do malloc/free to allow using a static global */
90 extern void zlog_5424_init(struct zlog_cfg_5424
*zcf
);
92 /* keepopen = true => for shutdown, just zap the config, keep logging */
93 extern void zlog_5424_fini(struct zlog_cfg_5424
*zcf
, bool keepopen
);
95 /* apply metadata/config changes */
96 extern bool zlog_5424_apply_meta(struct zlog_cfg_5424
*zcf
);
98 /* apply changes requiring (re-)opening the destination
100 * also does log cycling/rotate & applies _meta at the same time
102 extern bool zlog_5424_apply_dst(struct zlog_cfg_5424
*zcf
);
104 /* SIGHUP log rotation */
105 extern bool zlog_5424_rotate(struct zlog_cfg_5424
*zcf
);
107 extern void zlog_5424_state(struct zlog_cfg_5424
*zcf
, size_t *lost_msgs
,
108 int *last_errno
, bool *stale_errno
,
109 struct timeval
*err_ts
);
111 /* this is the dynamically allocated "variant" */
112 PREDECL_RBTREE_UNIQ(targets
);
114 struct zlog_cfg_5424_user
{
115 struct targets_item targets_item
;
118 struct zlog_cfg_5424 cfg
;
122 /* non-const, always same as cfg.filename */
125 /* uid/gid strings to write back out in show config */
137 DECLARE_QOBJ_TYPE(zlog_cfg_5424_user
);
139 extern void log_5424_cmd_init(void);
141 #endif /* _FRR_ZLOG_5424_H */