libip: replace v4parsecidr() with new parseipandmask()

we want to accept V4 subnets in CIDR notation consistently which
means we need to interpret the mask in context of the IP address.
so parseipmask() now has an additional v4 flag argument which
offsets the prefixlength by 96 so a /24 will be interpreted
as a /120.

parseipandmask() is the new function which handles this automatically
depending on the ip address type.

v4parsecidr() is now obsolete.
This commit is contained in:
cinap_lenrek 2019-02-11 23:26:57 +01:00
parent 66b9196f77
commit 0af11f97b5
4 changed files with 49 additions and 49 deletions

View file

@ -31,9 +31,7 @@ _readoldipifc(char *buf, Ipifc **l, int index)
/* allocate new local address */
*ll = lifc = mallocz(sizeof(Iplifc), 1);
ll = &lifc->next;
parseip(lifc->ip, f[i]);
parseipmask(lifc->mask, f[i+1]);
parseipandmask(lifc->ip, lifc->mask, f[i], f[i+1]);
parseip(lifc->net, f[i+2]);
ifc->pktin = strtoul(f[i+3], nil, 10);
ifc->pktout = strtoul(f[i+4], nil, 10);
@ -129,8 +127,7 @@ lose:
*ll = lifc = mallocz(sizeof(Iplifc), 1);
ll = &lifc->next;
parseip(lifc->ip, f[0]);
parseipmask(lifc->mask, f[1]);
parseipandmask(lifc->ip, lifc->mask, f[0], f[1]);
parseip(lifc->net, f[2]);
lifc->validlt = strtoul(f[3], nil, 10);