mirror of
https://github.com/markqvist/tncattach.git
synced 2025-07-30 12:32:25 -04:00
TAP
- Cleaned up - Remove dneed for `link_local_v6` tncattach - Removed `link_local_v6`
This commit is contained in:
parent
5223391129
commit
439bce5e4d
66
TAP.c
66
TAP.c
@ -242,7 +242,7 @@ int open_tap(void) {
|
||||
}
|
||||
}
|
||||
|
||||
if(set_ipv6 || link_local_v6)
|
||||
if(set_ipv6)
|
||||
{
|
||||
// Firstly, obtain the interface index by `ifr_name`
|
||||
int inet6 = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
@ -254,46 +254,36 @@ int open_tap(void) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// If link-local was requested
|
||||
if(link_local_v6)
|
||||
char* ipPart = strtok(ipv6_addr, "/");
|
||||
char* prefixPart_s = strtok(NULL, "/");
|
||||
printf("ip part: %s\n", ipPart);
|
||||
|
||||
if(!prefixPart_s)
|
||||
{
|
||||
// Do nothing; kernel adds for us
|
||||
perror("No prefix length was provided"); // TODO: Move logic into arg parsing
|
||||
close(inet6);
|
||||
cleanup();
|
||||
exit(1);
|
||||
}
|
||||
printf("prefix part: %s\n", prefixPart_s);
|
||||
|
||||
long prefixLen_l = strtol(prefixPart_s, NULL, 10); // TODO: Add handling here for errors (using errno)
|
||||
|
||||
|
||||
|
||||
// Convert ASCII IPv6 address to ABI structure
|
||||
struct in6_addr six_addr_itself;
|
||||
memset(&six_addr_itself, 0, sizeof(struct in6_addr));
|
||||
if(inet_pton(AF_INET6, ipv6_addr, &six_addr_itself) < 0)
|
||||
{
|
||||
printf("Error parsing IPv6 address '%s'\n", ipv6_addr);
|
||||
close(inet6);
|
||||
cleanup();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// If use-specified non-link-local IPv6 was
|
||||
if(set_ipv6)
|
||||
{
|
||||
char* ipPart = strtok(ipv6_addr, "/");
|
||||
char* prefixPart_s = strtok(NULL, "/");
|
||||
printf("ip part: %s\n", ipPart);
|
||||
|
||||
if(!prefixPart_s)
|
||||
{
|
||||
perror("No prefix length was provided"); // TODO: Move logic into arg parsing
|
||||
close(inet6);
|
||||
cleanup();
|
||||
exit(1);
|
||||
}
|
||||
printf("prefix part: %s\n", prefixPart_s);
|
||||
|
||||
long prefixLen_l = strtol(prefixPart_s, NULL, 10); // TODO: Add handling here for errors (using errno)
|
||||
|
||||
|
||||
|
||||
// Convert ASCII IPv6 address to ABI structure
|
||||
struct in6_addr six_addr_itself;
|
||||
memset(&six_addr_itself, 0, sizeof(struct in6_addr));
|
||||
if(inet_pton(AF_INET6, ipv6_addr, &six_addr_itself) < 0)
|
||||
{
|
||||
printf("Error parsing IPv6 address '%s'\n", ipv6_addr);
|
||||
close(inet6);
|
||||
cleanup();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Add user's requested address
|
||||
trySixSet(ifr.ifr_ifindex, six_addr_itself, prefixLen_l);
|
||||
}
|
||||
// Add user's requested address
|
||||
trySixSet(ifr.ifr_ifindex, six_addr_itself, prefixLen_l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ bool noup = false;
|
||||
bool daemonize = false;
|
||||
bool set_ipv4 = false;
|
||||
bool set_ipv6 = false;
|
||||
bool link_local_v6 = false; // FIXME: make this true by default
|
||||
bool set_netmask = false;
|
||||
bool kiss_over_tcp = false;
|
||||
char* ipv4_addr;
|
||||
@ -641,7 +640,6 @@ int main(int argc, char **argv) {
|
||||
if (arguments.set_ipv4) set_ipv4 = true;
|
||||
if (arguments.set_netmask) set_netmask = true;
|
||||
if (arguments.set_ipv6) set_ipv6 = true;
|
||||
if (arguments.link_local_v6) link_local_v6 = true;
|
||||
if (arguments.noup) noup = true;
|
||||
mtu = arguments.mtu;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user