Compare commits

...

4 Commits

Author SHA1 Message Date
Tristan Brice Velloza Kildaire
f6ff9a9618 tncattach
- Cleaned up
2024-12-21 15:39:11 +02:00
Tristan Brice Velloza Kildaire
8f32dc809e TAP
- Cleaned up
2024-12-21 15:38:24 +02:00
Tristan Brice Velloza Kildaire
dcfa6edcb6 Merge branch 'master' of github.com:deavmi/tncattach 2024-12-21 15:14:59 +02:00
Tristan Brice Velloza Kildaire
8b26e1bfb4 TAP
- Cleaned up
2024-12-21 15:14:26 +02:00
2 changed files with 29 additions and 29 deletions

38
TAP.c
View File

@ -29,7 +29,7 @@ void trySixSet
char ip_str[INET6_ADDRSTRLEN+1];
inet_ntop(AF_INET6, &address, ip_str, INET6_ADDRSTRLEN+1);
printf
printf
(
"Adding IPv6 address of '%s/%d' to interface at if_index %d\n",
ip_str,
@ -37,7 +37,7 @@ void trySixSet
interfaceIndex
);
int inet6 = socket(AF_INET6, SOCK_DGRAM, 0);
int inet6 = socket(AF_INET6, SOCK_DGRAM, 0);
if(inet6 < 0)
{
printf("Error opening control socket for adding IPv6 address to interface\n");
@ -45,30 +45,30 @@ void trySixSet
exit(1);
}
struct in6_ifreq paramReq;
memset(&paramReq, 0, sizeof(struct in6_ifreq));
paramReq.ifr6_ifindex = interfaceIndex;
paramReq.ifr6_prefixlen = prefixLen;
paramReq.ifr6_addr = address;
struct in6_ifreq paramReq;
memset(&paramReq, 0, sizeof(struct in6_ifreq));
paramReq.ifr6_ifindex = interfaceIndex;
paramReq.ifr6_prefixlen = prefixLen;
paramReq.ifr6_addr = address;
// Try add the address
if(ioctl(inet6, SIOCSIFADDR, &paramReq) < 0)
{
printf
if(ioctl(inet6, SIOCSIFADDR, &paramReq) < 0)
{
printf
(
"There was an errror assigning address '%s/%d' to if_index %d\n",
ip_str,
prefixLen,
interfaceIndex
);
cleanup();
close(inet6);
exit(1);
}
cleanup();
close(inet6);
exit(1);
}
printf("Address '%s/%d' added\n", ip_str, prefixLen);
close(inet6);
close(inet6);
}
int open_tap(void) {
@ -260,9 +260,9 @@ int open_tap(void) {
exit(1);
}
// if link-local was NOT requested and interface
// has been up'd -> then kernel would have added
// a link-local already, this removes it
// if link-local was NOT requested and interface
// has been up'd -> then kernel would have added
// a link-local already, this removes it
if(!set_linklocal & !noup)
{
// TODO: Get all addresses that start with fe80

View File

@ -504,15 +504,15 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
long prefixLen_l = strtol(prefixPart_s, NULL, 10); // TODO: Add handling here for errors (using errno)
if(prefixLen_l == 0) {
printf("Prefix length '%s' is not numeric\n", prefixPart_s);
exit(EXIT_FAILURE);
}
else if(!(prefixLen_l >= 0 && prefixLen_l <= 128))
{
printf("Prefix length '%s' is not within valid range of 0-128\n", prefixPart_s);
exit(EXIT_FAILURE);
}
if(prefixLen_l == 0) {
printf("Prefix length '%s' is not numeric\n", prefixPart_s);
exit(EXIT_FAILURE);
}
else if(!(prefixLen_l >= 0 && prefixLen_l <= 128))
{
printf("Prefix length '%s' is not within valid range of 0-128\n", prefixPart_s);
exit(EXIT_FAILURE);
}
arguments->ipv6 = ipPart_s;
@ -540,7 +540,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
printf("MTU was %d, setting to minimum of %d as is required for IPv6\n", arguments->mtu, 1280);
arguments->mtu = 1280;
break;
case 'n':
arguments->noipv6 = true;
if(arguments->set_ipv6)