From 0d5ed2b5ad7a91745391c033c5107b1d180b4470 Mon Sep 17 00:00:00 2001 From: Tristan Brice Velloza Kildaire Date: Sun, 15 Dec 2024 18:07:55 +0200 Subject: [PATCH] TAP - Removed uneeded imports --- TAP.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/TAP.c b/TAP.c index b575fe0..1ed6982 100644 --- a/TAP.c +++ b/TAP.c @@ -1,11 +1,11 @@ #include "TAP.h" // Needed for in6_ifreq -#include +// #include #include -#include -#include -#include +// #include +// #include +// #include char tap_name[IFNAMSIZ]; @@ -43,7 +43,7 @@ void trySixSet interfaceIndex ); - int dummySock = socket(AF_INET6, SOCK_DGRAM, 0); + int inet6 = socket(AF_INET6, SOCK_DGRAM, 0); struct in6_ifreq paramReq; memset(¶mReq, 0, sizeof(struct in6_ifreq)); @@ -53,7 +53,7 @@ void trySixSet // Try add the address - if(ioctl(dummySock, SIOCSIFADDR, ¶mReq) < 0) + if(ioctl(inet6, SIOCSIFADDR, ¶mReq) < 0) { printf ( @@ -63,12 +63,12 @@ void trySixSet interfaceIndex ); cleanup(); - close(dummySock); + close(inet6); exit(1); } printf("Address '%s/%d' added\n", ip_str, prefixLen); - close(dummySock); + close(inet6); } #include @@ -257,16 +257,17 @@ int open_tap(void) { if(mtu < 1280) { printf("MTU must be 1280 bytes or more for IPv6\n"); + close(inet); cleanup(); exit(1); } // Firstly, obtain the interface index by `ifr_name` - int dummySock = socket(AF_INET6, SOCK_DGRAM, 0); - if(ioctl(dummySock, SIOCGIFINDEX, &ifr) < 0) + int inet6 = socket(AF_INET6, SOCK_DGRAM, 0); + if(ioctl(inet6, SIOCGIFINDEX, &ifr) < 0) { printf("Could not get interface index for interface '%s'\n", ifr.ifr_name); - close(dummySock); + close(inet6); cleanup(); exit(1); } @@ -287,7 +288,7 @@ int open_tap(void) { if(!prefixPart_s) { perror("No prefix length was provided"); // TODO: Move logic into arg parsing - close(dummySock); + close(inet6); cleanup(); exit(1); } @@ -303,7 +304,7 @@ int open_tap(void) { if(inet_pton(AF_INET6, ipv6_addr, &six_addr_itself) < 0) { printf("Error parsing IPv6 address '%s'\n", ipv6_addr); - close(dummySock); + close(inet6); cleanup(); exit(1); }