mirror of
https://github.com/ChronosX88/netsukuku.git
synced 2024-11-22 18:22:18 +00:00
gmap: Limit new IPv4 nodes to a class-b private network
* 172 is generally used for auto-config... so it fits well with the ad-hoc mesh nature of Netsukuku * IPv6 could be limited to a uni-cast local address as well.
This commit is contained in:
parent
ba6c7a6bf9
commit
1dc21e5bc5
26
src/gmap.c
26
src/gmap.c
@ -572,11 +572,31 @@ random_ip(inet_prefix * ipstart, int final_level, int final_gid,
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
/*
|
/*
|
||||||
* Let's choose a completely random ip.
|
* Let's choose a completely random ip.
|
||||||
|
* New gnodes are limited to:
|
||||||
|
* IPv4: 172.16.0.0/12
|
||||||
|
* IPv6: fe6e:746b::/32
|
||||||
*/
|
*/
|
||||||
levels = total_levels;
|
levels = total_levels;
|
||||||
if (my_family == AF_INET)
|
if (my_family == AF_INET) {
|
||||||
idata[0] = rand();
|
int i = 0;
|
||||||
else {
|
while (i < 4) {
|
||||||
|
int octet = 0;
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
octet = 172;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
octet = (rand() % (31-16)) + 16;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
octet = rand() % 255;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
idata[0] |= (octet << (i * 8));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// TODO: Generate a random address in fe6e:746b::/32
|
||||||
idata[0] = rand();
|
idata[0] = rand();
|
||||||
idata[1] = rand();
|
idata[1] = rand();
|
||||||
idata[2] = rand();
|
idata[2] = rand();
|
||||||
|
Loading…
Reference in New Issue
Block a user