aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-04-25 16:55:39 +0200
committerHarald Welte <laforge@gnumonks.org>2018-04-25 20:46:05 +0200
commitb4c08280396f3c48d4630291959c6831a3fd24b1 (patch)
treea19ec6d7457704eb92dce18993409f9f5ed753b7 /lib
parentdf3dcac439694196b0c1acfcc7b9885bf4ec5286 (diff)
lib/tun.c: generalize tun_*route() to netdev_*route()
There's nothing specific to tun devices in adding a route to the kernel. Change-Id: Ib077934aa5f3c9bed06e2cf16a980c965a7a046d
Diffstat (limited to 'lib')
-rw-r--r--lib/tun.c20
-rw-r--r--lib/tun.h3
2 files changed, 8 insertions, 15 deletions
diff --git a/lib/tun.c b/lib/tun.c
index d6ca24e..14e4a58 100644
--- a/lib/tun.c
+++ b/lib/tun.c
@@ -274,7 +274,7 @@ static int tun_setaddr6(struct tun_t *this, struct in6_addr *addr, struct in6_ad
#if 0 /* FIXME */
//#if defined(__FreeBSD__) || defined (__APPLE__)
- tun_addroute6(this, dstaddr, addr, prefixlen);
+ netdev_addroute6(dstaddr, addr, prefixlen);
this->routes = 1;
#endif
@@ -644,9 +644,7 @@ int tun_addaddr(struct tun_t *this, struct in46_addr *addr, struct in46_addr *ds
}
}
-static int tun_route(struct tun_t *this,
- struct in_addr *dst,
- struct in_addr *gateway, struct in_addr *mask, int delete)
+static int netdev_route(struct in_addr *dst, struct in_addr *gateway, struct in_addr *mask, int delete)
{
#if defined(__linux__)
@@ -745,18 +743,14 @@ static int tun_route(struct tun_t *this,
}
-int tun_addroute(struct tun_t *this,
- struct in_addr *dst,
- struct in_addr *gateway, struct in_addr *mask)
+int netdev_addroute(struct in_addr *dst, struct in_addr *gateway, struct in_addr *mask)
{
- return tun_route(this, dst, gateway, mask, 0);
+ return netdev_route(dst, gateway, mask, 0);
}
-int tun_delroute(struct tun_t *this,
- struct in_addr *dst,
- struct in_addr *gateway, struct in_addr *mask)
+int netdev_delroute(struct in_addr *dst, struct in_addr *gateway, struct in_addr *mask)
{
- return tun_route(this, dst, gateway, mask, 1);
+ return netdev_route(dst, gateway, mask, 1);
}
int tun_new(struct tun_t **tun, const char *dev_name)
@@ -858,7 +852,7 @@ int tun_free(struct tun_t *tun)
{
if (tun->routes) {
- tun_delroute(tun, &tun->dstaddr, &tun->addr, &tun->netmask);
+ netdev_delroute(&tun->dstaddr, &tun->addr, &tun->netmask);
}
if (close(tun->fd)) {
diff --git a/lib/tun.h b/lib/tun.h
index 6f7c0ff..af9e9f4 100644
--- a/lib/tun.h
+++ b/lib/tun.h
@@ -86,8 +86,7 @@ extern int tun_addaddr(struct tun_t *this, struct in46_addr *addr,
extern int tun_setaddr(struct tun_t *this, struct in46_addr *our_adr,
struct in46_addr *his_adr, size_t prefixlen);
-int tun_addroute(struct tun_t *this, struct in_addr *dst,
- struct in_addr *gateway, struct in_addr *mask);
+int netdev_addroute(struct in_addr *dst, struct in_addr *gateway, struct in_addr *mask);
extern int tun_set_cb_ind(struct tun_t *this,
int (*cb_ind) (struct tun_t * tun, void *pack,