#include "routemap.h"
#include "if_rmap.h"
#include "privs.h"
+#include "lib_errors.h"
#include "ripngd/ripngd.h"
#include "ripngd/ripng_route.h"
sock = socket(AF_INET6, SOCK_DGRAM, 0);
if (sock < 0) {
- zlog_err("Can't make ripng socket");
+ flog_err_sys(LIB_ERR_SOCKET, "Can't make ripng socket");
return sock;
}
#endif /* SIN6_LEN */
ripaddr.sin6_port = htons(RIPNG_PORT_DEFAULT);
- if (ripngd_privs.change(ZPRIVS_RAISE))
- zlog_err("ripng_make_socket: could not raise privs");
+ frr_elevate_privs(&ripngd_privs) {
- ret = bind(sock, (struct sockaddr *)&ripaddr, sizeof(ripaddr));
- if (ret < 0) {
- zlog_err("Can't bind ripng socket: %s.", safe_strerror(errno));
- if (ripngd_privs.change(ZPRIVS_LOWER))
- zlog_err("ripng_make_socket: could not lower privs");
- goto error;
+ ret = bind(sock, (struct sockaddr *)&ripaddr, sizeof(ripaddr));
+ if (ret < 0) {
+ zlog_err("Can't bind ripng socket: %s.", safe_strerror(errno));
+ goto error;
+ }
}
- if (ripngd_privs.change(ZPRIVS_LOWER))
- zlog_err("ripng_make_socket: could not lower privs");
return sock;
error:
if (ret < 0) {
if (to)
- zlog_err("RIPng send fail on %s to %s: %s", ifp->name,
- inet6_ntoa(to->sin6_addr),
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "RIPng send fail on %s to %s: %s",
+ ifp->name, inet6_ntoa(to->sin6_addr),
+ safe_strerror(errno));
else
- zlog_err("RIPng send fail on %s: %s", ifp->name,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "RIPng send fail on %s: %s", ifp->name,
+ safe_strerror(errno));
}
return ret;
}
/* Receive UDP RIPng packet from socket. */
-static int ripng_recv_packet(int sock, u_char *buf, int bufsize,
+static int ripng_recv_packet(int sock, uint8_t *buf, int bufsize,
struct sockaddr_in6 *from, ifindex_t *ifindex,
int *hoplimit)
{
/* Write routing table entry to the stream and return next index of
the routing table entry in the stream. */
int ripng_write_rte(int num, struct stream *s, struct prefix_ipv6 *p,
- struct in6_addr *nexthop, u_int16_t tag, u_char metric)
+ struct in6_addr *nexthop, uint16_t tag, uint8_t metric)
{
/* RIPng packet header. */
if (num == 0) {
}
/* Write routing table entry. */
- if (!nexthop)
- stream_write(s, (u_char *)&p->prefix, sizeof(struct in6_addr));
- else
- stream_write(s, (u_char *)nexthop, sizeof(struct in6_addr));
+ if (!nexthop) {
+ assert(p);
+ stream_write(s, (uint8_t *)&p->prefix, sizeof(struct in6_addr));
+ } else
+ stream_write(s, (uint8_t *)nexthop, sizeof(struct in6_addr));
stream_putw(s, tag);
if (p)
stream_putc(s, p->prefixlen);