mirror of
https://github.com/markqvist/tncattach.git
synced 2025-09-03 05:27:47 -04:00
TAP
- Randomize the remaining octets of the link-local address
This commit is contained in:
parent
95930680d0
commit
5546163742
17
TAP.c
17
TAP.c
@ -23,10 +23,22 @@ extern char* ipv6_addr;
|
|||||||
extern char* netmask;
|
extern char* netmask;
|
||||||
extern void cleanup();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Allow optional-arg for case where we must also generate the hwaddr
|
// TODO: Allow optional-arg for case where we must also generate the hwaddr
|
||||||
// (this would be the case whereby we are running without `--ethernet`)
|
// (this would be the case whereby we are running without `--ethernet`)
|
||||||
struct in6_addr generateLinkLocal(char* interfaceName)
|
struct in6_addr generateLinkLocal(char* interfaceName)
|
||||||
{
|
{
|
||||||
|
srand(0); // TODO: FIXME, use time or something
|
||||||
|
|
||||||
struct in6_addr ll_a;
|
struct in6_addr ll_a;
|
||||||
memset(&ll_a, 0, sizeof(struct in6_addr));
|
memset(&ll_a, 0, sizeof(struct in6_addr));
|
||||||
ll_a.s6_addr[0] = 0xfe;
|
ll_a.s6_addr[0] = 0xfe;
|
||||||
@ -38,6 +50,11 @@ struct in6_addr generateLinkLocal(char* interfaceName)
|
|||||||
// (TODO, should not matter, link-local is interface scoped)
|
// (TODO, should not matter, link-local is interface scoped)
|
||||||
// TODO: Should tie it to mac address because of uniqueness
|
// TODO: Should tie it to mac address because of uniqueness
|
||||||
// on the lan it shall attach to (over lora)
|
// on the lan it shall attach to (over lora)
|
||||||
|
localRand(&ll_a);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int dummySock = socket(AF_PACKET, SOCK_PACKET, 0);
|
int dummySock = socket(AF_PACKET, SOCK_PACKET, 0);
|
||||||
if(dummySock < 0)
|
if(dummySock < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user