#include "prefix.h"
#include "vector.h"
#include "distribute.h"
+#include "lib_errors.h"
#include "babel_main.h"
#include "util.h"
#include "route.h"
#include "xroute.h"
#include "babel_memory.h"
+#include "babel_errors.h"
#define IS_ENABLE(ifp) (babel_enable_if_lookup(ifp->name) >= 0)
/* To support pseudo interface do not free interface structure. */
/* if_delete(ifp); */
- ifp->ifindex = IFINDEX_INTERNAL;
+ if_set_index(ifp, IFINDEX_INTERNAL);
return 0;
}
if (babel_ifp->ipv4 == NULL) {
babel_ifp->ipv4 = malloc(4);
if (babel_ifp->ipv4 == NULL) {
- zlog_err("not einough memory");
+ flog_err(EC_BABEL_MEMORY, "not enough memory");
} else {
memcpy(babel_ifp->ipv4, &prefix->u.prefix4, 4);
}
if (ret < 0) {
vty_out (vty, "There is same network configuration %s\n",
argv[1]->arg);
- return CMD_WARNING_CONFIG_FAILED;
+ return CMD_WARNING;
}
return CMD_SUCCESS;
tmp = babel_ifp->sendbuf;
babel_ifp->sendbuf = realloc(babel_ifp->sendbuf, babel_ifp->bufsize);
if(babel_ifp->sendbuf == NULL) {
- zlog_err("Couldn't reallocate sendbuf.");
+ flog_err(EC_BABEL_MEMORY, "Couldn't reallocate sendbuf.");
free(tmp);
babel_ifp->bufsize = 0;
return -1;
rc = setsockopt(protocol_socket, IPPROTO_IPV6, IPV6_JOIN_GROUP,
(char*)&mreq, sizeof(mreq));
if(rc < 0) {
- zlog_err("setsockopt(IPV6_JOIN_GROUP) on interface '%s': %s",
- ifp->name, safe_strerror(errno));
+ flog_err_sys(EC_LIB_SOCKET,
+ "setsockopt(IPV6_JOIN_GROUP) on interface '%s': %s",
+ ifp->name, safe_strerror(errno));
/* This is probably due to a missing link-local address,
so down this interface, and wait until the main loop
tries to up it again. */
rc = setsockopt(protocol_socket, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
(char*)&mreq, sizeof(mreq));
if(rc < 0)
- zlog_err("setsockopt(IPV6_LEAVE_GROUP) on interface '%s': %s",
- ifp->name, safe_strerror(errno));
+ flog_err_sys(EC_LIB_SOCKET,
+ "setsockopt(IPV6_LEAVE_GROUP) on interface '%s': %s",
+ ifp->name, safe_strerror(errno));
}
update_interface_metric(ifp);
void
babel_interface_close_all(void)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp = NULL;
- struct listnode *linklist_node = NULL;
- FOR_ALL_INTERFACES(ifp, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp) {
if(!if_up(ifp))
continue;
send_wildcard_retraction(ifp);
usleep(roughly(1000));
gettime(&babel_now);
}
- FOR_ALL_INTERFACES(ifp, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp) {
if(!if_up(ifp))
continue;
/* Make sure they got it. */
"Interface information\n"
"Interface\n")
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node;
if (argc == 3)
{
- for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp))
+ FOR_ALL_INTERFACES (vrf, ifp)
show_babel_interface_sub (vty, ifp);
return CMD_SUCCESS;
}
break;
if(k > 0)
channels[j++] = ',';
- snprintf(channels + j, 100 - j, "%d", route->channels[k]);
+ snprintf(channels + j, 100 - j, "%u", route->channels[k]);
j = strlen(channels);
}
snprintf(channels + j, 100 - j, ")");
}
route_stream_done(routes);
} else {
- zlog_err("Couldn't allocate route stream.");
+ flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
}
xroutes = xroute_stream();
if(xroutes) {
}
xroute_stream_done(xroutes);
} else {
- zlog_err("Couldn't allocate route stream.");
+ flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
}
return CMD_SUCCESS;
}
}
route_stream_done(routes);
} else {
- zlog_err("Couldn't allocate route stream.");
+ flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
}
xroutes = xroute_stream();
if(xroutes) {
}
xroute_stream_done(xroutes);
} else {
- zlog_err("Couldn't allocate route stream.");
+ flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
}
return CMD_SUCCESS;
}
}
route_stream_done(routes);
} else {
- zlog_err("Couldn't allocate route stream.");
+ flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
}
xroutes = xroute_stream();
if(xroutes) {
}
xroute_stream_done(xroutes);
} else {
- zlog_err("Couldn't allocate route stream.");
+ flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
}
return CMD_SUCCESS;
}
}
route_stream_done(routes);
} else {
- zlog_err("Couldn't allocate route stream.");
+ flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
}
xroutes = xroute_stream();
if(xroutes) {
}
xroute_stream_done(xroutes);
} else {
- zlog_err("Couldn't allocate route stream.");
+ flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
}
return CMD_SUCCESS;
}
static int
interface_config_write (struct vty *vty)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
int write = 0;
- for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp)) {
- vty_out (vty, "interface %s\n",ifp->name);
+ FOR_ALL_INTERFACES (vrf, ifp) {
+ vty_frame (vty, "interface %s\n",ifp->name);
if (ifp->desc)
vty_out (vty, " description %s\n",ifp->desc);
babel_interface_nfo *babel_ifp = babel_get_if_nfo (ifp);
write++;
}
}
- vty_out (vty, "!\n");
+ vty_endframe (vty, "!\n");
write++;
}
return write;