From 4b0e0061398e9627e37c5c3aa42d7bd55950d33d Mon Sep 17 00:00:00 2001 From: Tristan Brice Velloza Kildaire Date: Sun, 15 Dec 2024 17:44:29 +0200 Subject: [PATCH] TAP_ - Cleaned up a little bit - The `mtu` (on Luinux) must be `1280` of greater, else IPv6 won't work (and the address will not be allowed to be added) --- TAP.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/TAP.c b/TAP.c index e360281..3cee749 100644 --- a/TAP.c +++ b/TAP.c @@ -13,6 +13,7 @@ extern bool verbose; extern bool noipv6; extern bool set_ipv4; extern bool set_ipv6; +extern bool link_local_v6; extern bool set_netmask; extern bool noup; extern int mtu; @@ -99,30 +100,38 @@ void trySixSet interfaceIndex ); + if(mtu < 1280) + { + printf("MTU must be 1280 bytes or more for IPv6\n"); + cleanup(); + exit(1); + } + int dummySock = socket(AF_INET6, SOCK_DGRAM, 0); - - - struct in6_ifreq paramReq; memset(¶mReq, 0, sizeof(struct in6_ifreq)); paramReq.ifr6_ifindex = interfaceIndex; - printf("paramReq.ifr6_ifindex: %d\n", paramReq.ifr6_ifindex); paramReq.ifr6_prefixlen = prefixLen; paramReq.ifr6_addr = address; - + // Try add the address if(ioctl(dummySock, SIOCSIFADDR, ¶mReq) < 0) { - // perror("Fokop"); - printf("Fokop\n"); + printf + ( + "There was an errror assigning address '%s/%d' to if_index %d\n", + ip_str, + prefixLen, + interfaceIndex + ); cleanup(); close(dummySock); exit(1); } - printf("Sucessfully applied IPv6 configuration"); + printf("Address '%s/%d' added\n", ip_str, prefixLen); close(dummySock); } @@ -306,7 +315,7 @@ int open_tap(void) { } } - if(set_ipv6) { + if(set_ipv6 || link_local_v6) { printf("TODO: Implement set ipv6\n"); // Firstly, obtain the interface index by `ifr_name` @@ -363,7 +372,7 @@ int open_tap(void) { // FIXME: Allow the ipv6 to be empty and just do link-local - printf("IPv6 settings SHOULD be done now\n"); + printf("IPv6 configuration done\n"); } } }