summaryrefslogtreecommitdiff
path: root/src/bsd
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-02-04 01:07:27 +0000
committerChristian Pointner <equinox@anytun.org>2009-02-04 01:07:27 +0000
commitcd425ede7e3f2236d062f80e4e1f4ed0f39a6848 (patch)
tree7b25f92e484b5918283379f92c8939d0d6cfba87 /src/bsd
parentadded linux support for new ifconfig usage (diff)
OpenBSD support for new ifconifg method
Diffstat (limited to 'src/bsd')
-rw-r--r--src/bsd/tun.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/src/bsd/tun.c b/src/bsd/tun.c
index 07eae2b..14b2f6e 100644
--- a/src/bsd/tun.c
+++ b/src/bsd/tun.c
@@ -163,6 +163,8 @@ int tun_init_post(tun_device_t* dev)
}
ti.flags |= IFF_MULTICAST;
+ if(dev->type_ == TYPE_TUN)
+ ti.flags &= ~IFF_POINTOPOINT;
if (ioctl(dev->fd_, TUNSIFINFO, &ti) < 0) {
log_printf(ERR, "can't enable multicast for interface");
@@ -172,7 +174,7 @@ int tun_init_post(tun_device_t* dev)
}
#elif defined(__GNUC__) && defined(__FreeBSD__)
-
+ #warning this device has never been tested on FreeBSD and might not work
int tun_init_post(tun_device_t* dev)
{
if(!dev)
@@ -191,7 +193,7 @@ int tun_init_post(tun_device_t* dev)
}
#elif defined(__GNUC__) && defined(__NetBSD__)
-
+ #warning this device has never been tested on NetBSD and might not work
int tun_init_post(tun_device_t* dev)
{
if(!dev)
@@ -287,38 +289,35 @@ void tun_do_ifconfig(tun_device_t* dev)
return;
-/* char* command = NULL; */
-/* char* netmask; */
-/* char* end; */
-/* if(dev->type_ == TYPE_TAP) { */
-/* netmask = "netmask "; */
-/* #if defined(__GNUC__) && defined(__OpenBSD__) */
-/* end = " link0"; */
-/* #elif defined(__GNUC__) && defined(__FreeBSD__) */
-/* end = " up"; */
-/* #elif defined(__GNUC__) && defined(__NetBSD__) */
-/* end = ""; */
-/* #else */
-/* #error This Device works just for OpenBSD, FreeBSD or NetBSD */
-/* #endif */
-/* } */
-/* else { */
-/* netmask = ""; */
-/* end = " netmask 255.255.255.255 up"; */
-/* } */
-
-/* asprintf(&command, "/sbin/ifconfig %s %s %s%s mtu %d%s", dev->actual_name_, dev->local_ , netmask, */
-/* dev->remote_netmask_, dev->mtu_, end); */
-/* if(!command) { */
-/* log_printf(ERR, "Execution of ifconfig failed"); */
-/* return; */
-/* } */
-
-/* int result = system(command); */
-/* if(result == -1) */
-/* log_printf(ERR, "Execution of ifconfig failed"); */
-/* else */
-/* log_printf(NOTICE, "ifconfig returned %d", WEXITSTATUS(result)); */
-
-/* free(command); */
+ char* command = NULL;
+ char* netmask;
+ char* end;
+ if(dev->type_ == TYPE_TAP) {
+#if defined(__GNUC__) && defined(__OpenBSD__)
+ end = " link0";
+#elif defined(__GNUC__) && defined(__FreeBSD__)
+ end = " up";
+#elif defined(__GNUC__) && defined(__NetBSD__)
+ end = "";
+#else
+ #error This Device works just for OpenBSD, FreeBSD or NetBSD
+#endif
+ }
+ else
+ end = " up";
+
+ asprintf(&command, "/sbin/ifconfig %s %s netmask %s mtu %d%s", dev->actual_name_, dev->net_addr_,
+ dev->net_mask_, dev->mtu_, end);
+ if(!command) {
+ log_printf(ERR, "Execution of ifconfig failed");
+ return;
+ }
+
+ int result = system(command);
+ if(result == -1)
+ log_printf(ERR, "Execution of ifconfig failed");
+ else
+ log_printf(NOTICE, "ifconfig returned %d", WEXITSTATUS(result));
+
+ free(command);
}