diff options
| author | Nakidai <nakidai@disroot.org> | 2025-12-05 14:30:53 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2025-12-05 14:30:53 +0300 |
| commit | 226096ac0275e6aadf3ff9459e130e6dd1821934 (patch) | |
| tree | 412e00eafa16477c5377f03fca011987d279f045 /fatvpn.c | |
| parent | 8231f3bef51e0d30eec41aab78631c29b00db491 (diff) | |
| download | fatvpn-dev.tar.gz fatvpn-dev.zip | |
Port fatvpn.c tp OpenBSD dev
Haven't tasted yet, though
Diffstat (limited to 'fatvpn.c')
| -rw-r--r-- | fatvpn.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fatvpn.c b/fatvpn.c index 59eaa10..01c6459 100644 --- a/fatvpn.c +++ b/fatvpn.c @@ -18,7 +18,11 @@ int main(int argc, char *argv[]){ struct timespec t; struct timeval slp; struct termios attr; +#ifdef __linux__ struct ifreq ifr; +#elif __OpenBSD__ + char *tappath; +#endif fd_set rset; /* arguments */ @@ -135,6 +139,10 @@ int main(int argc, char *argv[]){ /* cur pkt buf */ pkt = malloc(MAX_PKT_SZ); if (pkt == NULL) fputs("pkt = malloc() failed\n",stderr), exit(1); +#ifdef __OpenBSD__ + tappath = malloc(MAX_TAPPATH_SZ); + if (tappath == NULL) fputs("tappath = malloc() failed\n",stderr), exit(1); +#endif /* socket, setsockopt */ skt = socket(srv.ss_family, SOCK_DGRAM, 0); ERRDIE(skt, "socket"); @@ -143,6 +151,7 @@ int main(int argc, char *argv[]){ ERRDIE(res, "SO_REUSEADDR"); /* tap */ +#ifdef __linux__ tap = open("/dev/net/tun", O_RDWR); ERRDIE(tap, "/dev/net/tun"); @@ -151,6 +160,11 @@ int main(int argc, char *argv[]){ strncpy(ifr.ifr_name, argv[1], IFNAMSIZ); res = ioctl(tap, TUNSETIFF, &ifr); ERRDIE(res, "TUNSETIFF"); +#elif __OpenBSD__ + snprintf(tappath, MAX_TAPPATH_SZ, "/dev/%s", argv[1]); + tap = open(tappath, O_RDWR); + ERRDIE(tap, tappath); +#endif fdmax = (tap > skt) ? tap+1 : skt+1; |