+// SPDX-License-Identifier: MIT
/*
Copyright 2007, 2008 by Grégoire Henry, Julien Cristau and Juliusz Chroboczek
Copyright 2011, 2012 by Matthieu Boutier and Juliusz Chroboczek
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/time.h>
#include <sys/param.h>
#include <time.h>
}
int
-kernel_route(int operation, const unsigned char *pref, unsigned short plen,
- const unsigned char *gate, int ifindex, unsigned int metric,
- const unsigned char *newgate, int newifindex,
+kernel_route(enum babel_kernel_routes operation, const unsigned char *pref,
+ unsigned short plen, const unsigned char *gate, int ifindex,
+ unsigned int metric, const unsigned char *newgate, int newifindex,
unsigned int newmetric)
{
int rc;
switch (operation) {
case ROUTE_ADD:
return zebra_route(1, family, pref, plen, gate, ifindex, metric);
- break;
case ROUTE_FLUSH:
return zebra_route(0, family, pref, plen, gate, ifindex, metric);
- break;
case ROUTE_MODIFY:
if(newmetric == metric && memcmp(newgate, gate, 16) == 0 &&
newifindex == ifindex)
rc = zebra_route(1, family, pref, plen, newgate, newifindex,
newmetric);
return rc;
- break;
- default:
- zlog_err("this should never happen (false value - kernel_route)");
- assert(0);
- exit(1);
- break;
}
+
+ return 0;
}
static int
switch (family) {
case AF_INET:
uchar_to_inaddr(&api_nh->gate.ipv4, gate);
- if (IPV4_ADDR_SAME (&api_nh->gate.ipv4, &quagga_prefix.u.prefix4) &&
- quagga_prefix.prefixlen == 32) {
- api_nh->type = NEXTHOP_TYPE_IFINDEX;
- } else {
- api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
+ if (IPV4_ADDR_SAME(&api_nh->gate.ipv4, &quagga_prefix.u.prefix4)
+ && quagga_prefix.prefixlen == IPV4_MAX_BITLEN) {
+ api_nh->type = NEXTHOP_TYPE_IFINDEX;
+ } else {
+ api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
}
break;
case AF_INET6:
return -1;
}
- u_char len = (u_char) ifp->hw_addr_len;
+ uint8_t len = (uint8_t)ifp->hw_addr_len;
char *tmp = (void*) ifp->hw_addr;
if (len == 8) {
/* Like gettimeofday, but returns monotonic time. If POSIX clocks are not
available, falls back to gettimeofday but enforces monotonicity. */
-int
+void
gettime(struct timeval *tv)
{
- return monotime(tv);
+ monotime(tv);
}
/* If /dev/urandom doesn't exist, this will fail with ENOENT, which the