mirror of
https://github.com/markqvist/tncattach.git
synced 2025-06-29 15:05:20 -04:00
Compare commits
4 Commits
0f115a3572
...
ec9f6365d7
Author | SHA1 | Date | |
---|---|---|---|
|
ec9f6365d7 | ||
|
66815f7f1a | ||
|
5546163742 | ||
|
95930680d0 |
30
TAP.c
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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user