ip/tinc: fix mistake from previous commit
This commit is contained in:
parent
dc6772fccc
commit
cce5422e79
1 changed files with 14 additions and 6 deletions
|
@ -63,8 +63,9 @@ struct Snet
|
||||||
Host *owner;
|
Host *owner;
|
||||||
|
|
||||||
Snet *next; /* next subnet on owner */
|
Snet *next; /* next subnet on owner */
|
||||||
uchar mask[IPaddrlen];
|
|
||||||
uchar ip[IPaddrlen];
|
uchar ip[IPaddrlen];
|
||||||
|
uchar mask[IPaddrlen];
|
||||||
|
int prefixlen;
|
||||||
int weight;
|
int weight;
|
||||||
char reported;
|
char reported;
|
||||||
char deleted;
|
char deleted;
|
||||||
|
@ -345,11 +346,11 @@ reportsubnet(Conn *c, Snet *t)
|
||||||
if(t->owner == c->host)
|
if(t->owner == c->host)
|
||||||
return;
|
return;
|
||||||
if(t->deleted)
|
if(t->deleted)
|
||||||
consend(c, "%d %x %s %I %M #%d", DEL_SUBNET, rand(),
|
consend(c, "%d %x %s %I/%d#%d", DEL_SUBNET, rand(),
|
||||||
t->owner->name, t->ip, t->mask, t->weight);
|
t->owner->name, t->ip, t->prefixlen, t->weight);
|
||||||
else
|
else
|
||||||
consend(c, "%d %x %s %I %M #%d", ADD_SUBNET, rand(), t->owner->name,
|
consend(c, "%d %x %s %I/%d#%d", ADD_SUBNET, rand(), t->owner->name,
|
||||||
t->ip, t->mask, t->weight);
|
t->ip, t->prefixlen, t->weight);
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
reportedge(Conn *c, Edge *e)
|
reportedge(Conn *c, Edge *e)
|
||||||
|
@ -459,12 +460,18 @@ Snet*
|
||||||
getsubnet(Host *h, char *s, int new)
|
getsubnet(Host *h, char *s, int new)
|
||||||
{
|
{
|
||||||
uchar ip[IPaddrlen], mask[IPaddrlen];
|
uchar ip[IPaddrlen], mask[IPaddrlen];
|
||||||
int weight;
|
int weight, prefixlen;
|
||||||
Snet *t;
|
Snet *t;
|
||||||
|
|
||||||
if(parseipandmask(ip, mask, s, strchr(s, '/')) == -1)
|
if(parseipandmask(ip, mask, s, strchr(s, '/')) == -1)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
|
for(prefixlen = 0; prefixlen < 128; prefixlen++)
|
||||||
|
if((mask[prefixlen/8] & (0x80 >> (prefixlen%8))) == 0)
|
||||||
|
break;
|
||||||
|
if(isv4(ip))
|
||||||
|
prefixlen -= 96;
|
||||||
|
|
||||||
maskip(ip, mask, ip);
|
maskip(ip, mask, ip);
|
||||||
|
|
||||||
weight = 10;
|
weight = 10;
|
||||||
|
@ -486,6 +493,7 @@ if(debug) fprint(2, "%s adding subnet: %I %M #%d\n", h->name, ip, mask, weight);
|
||||||
t = emalloc(sizeof(Snet));
|
t = emalloc(sizeof(Snet));
|
||||||
ipmove(t->ip, ip);
|
ipmove(t->ip, ip);
|
||||||
ipmove(t->mask, mask);
|
ipmove(t->mask, mask);
|
||||||
|
t->prefixlen = prefixlen;
|
||||||
t->weight = weight;
|
t->weight = weight;
|
||||||
t->owner = h;
|
t->owner = h;
|
||||||
t->next = h->snet;
|
t->next = h->snet;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue