#include "lib/ip.h"
#include "lib/hash.h"
#include "lib/resource.h"
+#include "lib/obstacle.h"
#include "lib/timer.h"
+ #include "lib/tlists.h"
/* Configuration structure */
struct config {
list logfiles; /* Configured log files (sysdep) */
list tests; /* Configured unit tests (f_bt_test_suite) */
list symbols; /* Configured symbols in config order */
+ TLIST_STRUCT_DEF(cli_config, struct cli_config) cli; /* Configured CLI sockets */
- int mrtdump_file; /* Configured MRTDump file (sysdep, fd in unix) */
+ struct rfile *mrtdump_file; /* Configured MRTDump file */
const char *syslog_name; /* Name used for syslog (NULL -> no syslog) */
- struct rtable_config *def_tables[NET_MAX]; /* Default routing tables for each network */
+ struct symbol *def_tables[NET_MAX]; /* Default routing tables for each network */
struct iface_patt *router_id_from; /* Configured list of router ID iface patterns */
u32 router_id; /* Our Router ID */
#define _BIRD_CLI_H_
#include "lib/resource.h"
+#include "lib/lists.h"
#include "lib/event.h"
+ #include "lib/tlists.h"
+ #include "conf/conf.h"
#define CLI_RX_BUF_SIZE 4096
#define CLI_TX_BUF_SIZE 4096
CF_DECLS
- CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT, UDP, PORT)
-CF_KEYWORDS(LOG, SYSLOG, NAME, STDERR, UDP, PORT, CLI)
-CF_KEYWORDS(ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG)
-CF_KEYWORDS(DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, TIMEOUT, THREADS)
++CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT, UDP, PORT, CLI)
+CF_KEYWORDS(NAME, CONFIRM, UNDO, CHECK, TIMEOUT, DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, STATUS)
+CF_KEYWORDS(PING, WAKEUP, SOCKETS, SCHEDULING, EVENTS, TIMERS, ALLOCATOR)
+CF_KEYWORDS(GRACEFUL, RESTART, FIXED)
-%type <i> log_mask log_mask_list log_cat cfg_timeout
+%type <i> log_mask log_mask_list log_cat cfg_timeout debug_unix latency_debug_mask latency_debug_flag latency_debug_list
%type <t> cfg_name
%type <tf> timeformat_which
%type <t> syslog_name
}
;
-
+conf: THREADS expr {
+ if ($2 < 1) cf_error("Number of threads must be at least one.");
+ new_config->thread_count = $2;
+}
+
+
conf: debug_unix ;
debug_unix:
}
int
- sk_open_unix(sock *s, struct birdloop *loop, char *name)
-sk_open_unix(sock *s, const char *name)
++sk_open_unix(sock *s, struct birdloop *loop, const char *name)
{
struct sockaddr_un sa;
int fd;
s->fast_rx = 1;
/* Return value intentionally ignored */
- unlink(path_control_socket);
+ unlink(cf->name);
- if (sk_open_unix(s, &main_birdloop, path_control_socket) < 0)
- die("Cannot create control socket %s: %m", path_control_socket);
- if (sk_open_unix(s, cf->name) < 0)
++ if (sk_open_unix(s, &main_birdloop, cf->name) < 0)
+ {
+ log(L_ERR "Cannot create control socket %s: %m", cf->name);
+ return NULL;
+ }
- if (use_uid || use_gid)
- if (chown(path_control_socket, use_uid, use_gid) < 0)
- die("chown: %m");
+ if (cf->uid || cf->gid)
+ if (chown(cf->name, cf->uid, cf->gid) < 0)
+ {
+ log(L_ERR "Cannot chown control socket %s: %m", cf->name);
+ return NULL;
+ }
- if (chmod(path_control_socket, 0660) < 0)
- die("chmod: %m");
+ if (chmod(cf->name, cf->mode) < 0)
+ {
+ log(L_ERR "Cannot chmod control socket %s: %m", cf->name);
+ return NULL;
+ }
+
+ return l;
+ }
+
+ static void
+ cli_init_unix(uid_t use_uid, gid_t use_gid)
+ {
+ ASSERT_DIE(main_control_socket_config == NULL);
+
+ main_control_socket_config = mb_alloc(&root_pool, sizeof *main_control_socket_config);
+ *main_control_socket_config = (struct cli_config) {
+ .name = path_control_socket,
+ .uid = use_uid,
+ .gid = use_gid,
+ .mode = 0660,
+ };
+
+ ASSERT_DIE(main_control_socket == NULL);
+ cli_init();
+ main_control_socket = cli_listener(main_control_socket_config);
+ if (!main_control_socket)
+ die("Won't run without control socket");
}
+
/*
* PID file
*/
void io_init(void);
void io_loop(void);
void io_log_dump(void);
- int sk_open_unix(struct birdsock *s, struct birdloop *, char *name);
-int sk_open_unix(struct birdsock *s, const char *name);
-struct rfile *rf_open(struct pool *, const char *name, const char *mode);
-struct rfile *rf_fdopen(pool *p, int fd, const char *mode);
-void *rf_file(struct rfile *f);
++int sk_open_unix(struct birdsock *s, struct birdloop *, const char *name);
+
+enum rf_mode {
+ RF_APPEND = 1,
+ RF_FIXED,
+};
+
+struct rfile *rf_open(struct pool *, const char *name, enum rf_mode mode, off_t limit);
+off_t rf_size(struct rfile *);
+int rf_same(struct rfile *, struct rfile *);
+int rf_writev(struct rfile *, struct iovec *, int);
+void rf_write_crude(struct rfile *, const char *, int);
int rf_fileno(struct rfile *f);
+
+extern struct rfile rf_stderr;
+
void test_old_bird(char *path);
ip_addr resolve_hostname(const char *host, int type, const char **err_msg);