#include "vty.h"
#include "memory.h"
#include "libfrr.h"
+#include "lib_errors.h"
#include "babel_main.h"
#include "babeld.h"
#include "message.h"
#include "resend.h"
#include "babel_zebra.h"
+#include "babel_errors.h"
static void babel_fail(void);
static void babel_init_random(void);
int protocol_socket = -1; /* socket: communicate with others babeld */
static char babel_config_default[] = SYSCONFDIR BABEL_DEFAULT_CONFIG;
-static char *babel_config_file = NULL;
static char *babel_vty_addr = NULL;
static int babel_vty_port = BABEL_VTY_PORT;
ZCAP_BIND
};
-static struct zebra_privs_t babeld_privs =
+struct zebra_privs_t babeld_privs =
{
#if defined(FRR_USER)
.user = FRR_USER,
{ 0 }
};
+static const struct frr_yang_module_info *babeld_yang_modules[] =
+ {
+ &frr_interface_info,
+ };
+
FRR_DAEMON_INFO(babeld, BABELD,
.vty_port = BABEL_VTY_PORT,
.proghelp = "Implementation of the BABEL routing protocol.",
.n_signals = array_size(babel_signals),
.privs = &babeld_privs,
+
+ .yang_modules = babeld_yang_modules,
+ .n_yang_modules = array_size(babeld_yang_modules),
)
int
frr_preinit (&babeld_di, argc, argv);
frr_opt_add ("", longopts, "");
-
+
babel_init_random();
/* set the Babel's default link-local multicast address and Babel's port */
master = frr_init ();
/* Library inits. */
- zprivs_init (&babeld_privs);
- cmd_init (1);
- vty_init (master);
+ babel_error_init();
resend_delay = BABEL_DEFAULT_RESEND_DELAY;
change_smoothing_half_life(BABEL_DEFAULT_SMOOTHING_HALF_LIFE);
/* this replace kernel_setup && kernel_setup_socket */
babelz_zebra_init ();
- /* Get zebra configuration file. */
- vty_read_config (babel_config_file, babel_config_default);
-
/* init buffer */
rc = resize_receive_buffer(1500);
if(rc < 0)
rc = read_random_bytes(&seed, sizeof(seed));
if(rc < 0) {
- zlog_err("read(random): %s", safe_strerror(errno));
+ flog_err_sys(EC_LIB_SYSTEM_CALL, "read(random): %s",
+ safe_strerror(errno));
seed = 42;
}
fd_null = open("/dev/null", O_RDONLY);
if(fd_null < 0) {
- zlog_err("open(null): %s", safe_strerror(errno));
+ flog_err_sys(EC_LIB_SYSTEM_CALL, "open(null): %s", safe_strerror(errno));
exit(1);
}
rc = dup2(fd_null, fd);
if(rc < 0) {
- zlog_err("dup2(null, 0): %s", safe_strerror(errno));
+ flog_err_sys(EC_LIB_SYSTEM_CALL, "dup2(null, 0): %s",
+ safe_strerror(errno));
exit(1);
}
fd = open(state_file, O_RDONLY);
if(fd < 0 && errno != ENOENT)
- zlog_err("open(babel-state: %s)", safe_strerror(errno));
+ flog_err_sys(EC_LIB_SYSTEM_CALL, "open(babel-state: %s)",
+ safe_strerror(errno));
rc = unlink(state_file);
if(fd >= 0 && rc < 0) {
- zlog_err("unlink(babel-state): %s", safe_strerror(errno));
+ flog_err_sys(EC_LIB_SYSTEM_CALL, "unlink(babel-state): %s",
+ safe_strerror(errno));
/* If we couldn't unlink it, it's probably stale. */
goto fini;
}
long t;
rc = read(fd, buf, 99);
if(rc < 0) {
- zlog_err("read(babel-state): %s", safe_strerror(errno));
+ flog_err_sys(EC_LIB_SYSTEM_CALL, "read(babel-state): %s",
+ safe_strerror(errno));
} else {
buf[rc] = '\0';
rc = sscanf(buf, "%99s %d %ld\n", buf2, &s, &t);
unsigned char sid[8];
rc = parse_eui64(buf2, sid);
if(rc < 0) {
- zlog_err("Couldn't parse babel-state.");
+ flog_err(EC_BABEL_CONFIG, "Couldn't parse babel-state.");
} else {
struct timeval realnow;
debugf(BABEL_DEBUG_COMMON,
if(memcmp(sid, myid, 8) == 0)
myseqno = seqno_plus(s, 1);
else
- zlog_err("ID mismatch in babel-state. id=%s; old=%s",
+ flog_err(EC_BABEL_CONFIG,
+ "ID mismatch in babel-state. id=%s; old=%s",
format_eui64(myid),
format_eui64(sid));
}
} else {
- zlog_err("Couldn't parse babel-state.");
+ flog_err(EC_BABEL_CONFIG, "Couldn't parse babel-state.");
}
}
goto fini;
debugf(BABEL_DEBUG_COMMON, "Save state file.");
fd = open(state_file, O_WRONLY | O_TRUNC | O_CREAT, 0644);
if(fd < 0) {
- zlog_err("creat(babel-state): %s", safe_strerror(errno));
+ flog_err_sys(EC_LIB_SYSTEM_CALL, "creat(babel-state): %s",
+ safe_strerror(errno));
unlink(state_file);
} else {
struct timeval realnow;
format_eui64(myid), (int)myseqno,
(long)realnow.tv_sec);
if(rc < 0 || rc >= 100) {
- zlog_err("write(babel-state): overflow.");
+ flog_err(EC_BABEL_CONFIG, "write(babel-state): overflow.");
unlink(state_file);
} else {
rc = write(fd, buf, rc);
if(rc < 0) {
- zlog_err("write(babel-state): %s", safe_strerror(errno));
+ flog_err(EC_BABEL_CONFIG, "write(babel-state): %s",
+ safe_strerror(errno));
unlink(state_file);
}
fsync(fd);
vty_out (vty,
"state file = %s\n"
"configuration file = %s\n"
- "protocol informations:\n"
+ "protocol information:\n"
" multicast address = %s\n"
" port = %d\n"
"vty address = %s\n"
"id = %s\n"
"kernel_metric = %d\n",
state_file,
- babel_config_file ? babel_config_file : babel_config_default,
+ babeld_di.config_file ? babeld_di.config_file : babel_config_default,
format_address(protocol_group),
protocol_port,
babel_vty_addr ? babel_vty_addr : "None",