1
0
mirror of https://github.com/markqvist/tncattach.git synced 2025-06-29 15:05:20 -04:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Tristan Brice Velloza Kildaire
ec9f6365d7 TAP
- Removed TODO
2024-12-14 14:35:58 +02:00
Tristan Brice Velloza Kildaire
66815f7f1a TAP
- Seed random number generatro based off of current time
2024-12-14 14:35:48 +02:00
Tristan Brice Velloza Kildaire
5546163742 TAP
- Randomize the remaining octets of the link-local address
2024-12-14 14:33:32 +02:00
Tristan Brice Velloza Kildaire
95930680d0 TAP
- Added device type checl
2024-12-14 14:04:15 +02:00

30
TAP.c

@ -23,10 +23,25 @@ extern char* ipv6_addr;
extern char* netmask;
extern void cleanup();
#include<stdlib.h>
void localRand(struct in6_addr* ll_a)
{
for(int i = 2; i < 16; i++)
{
ll_a->s6_addr[i] = rand();
}
}
#include<time.h>
// TODO: Allow optional-arg for case where we must also generate the hwaddr
// (this would be the case whereby we are running without `--ethernet`)
struct in6_addr generateLinkLocal(char* interfaceName)
{
time_t t = time(NULL);
srand(t);
struct in6_addr ll_a;
memset(&ll_a, 0, sizeof(struct in6_addr));
ll_a.s6_addr[0] = 0xfe;
@ -38,6 +53,11 @@ struct in6_addr generateLinkLocal(char* interfaceName)
// (TODO, should not matter, link-local is interface scoped)
// TODO: Should tie it to mac address because of uniqueness
// on the lan it shall attach to (over lora)
localRand(&ll_a);
int dummySock = socket(AF_PACKET, SOCK_PACKET, 0);
if(dummySock < 0)
@ -325,6 +345,16 @@ int open_tap(void) {
exit(1);
}
// Choose stratergy for generating link-local address
if(device_type == IF_TAP)
{
}
else
{
}
// Add link-local address
trySixSet(ifr.ifr_ifindex, generateLinkLocal(if_name), 64);