ref: 7c3db1d6203a1a63c663373917e80db42b44120b
parent: a7c01127f9749fe471367c6461cde357403cc3b3
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Feb 11 18:29:53 EST 2019
ip/ipconfig: use new parseipandmask() function
--- a/sys/src/cmd/ip/ipconfig/main.c
+++ b/sys/src/cmd/ip/ipconfig/main.c
@@ -118,12 +118,11 @@
usage();
/* fall through */
case 2:
- /*
- * can't test for parseipmask()==-1 cuz 255.255.255.255
- * looks like that.
- */
- if (strcmp(argv[1], "0") != 0)
- parseipmask(conf.mask, argv[1]);
+ if (strcmp(argv[1], "0") != 0){
+ if (parseipandmask(conf.laddr, conf.mask, argv[0], argv[1]) == -1)
+ usage();
+ break;
+ }
/* fall through */
case 1:
if (parseip(conf.laddr, argv[0]) == -1)
@@ -742,15 +741,13 @@
uchar dst[IPaddrlen], mask[IPaddrlen];
if(isv4(gaddr)){
- parseip(dst, "0.0.0.0");
- parseipmask(mask, "0.0.0.0");
+ parseipandmask(dst, mask, "0.0.0.0", "0.0.0.0");
if(src == nil)
src = dst;
if(smask == nil)
smask = mask;
} else {
- parseip(dst, "2000::");
- parseipmask(mask, "/3");
+ parseipandmask(dst, mask, "2000::", "/3");
if(src == nil)
src = IPnoaddr;
if(smask == nil)
@@ -1022,7 +1019,7 @@
}
if(strcmp(nt->attr, "ipmask") == 0) {
nt = uniquent(nt);
- parseipmask(conf.mask, nt->val); /* could be -1 */
+ parseipmask(conf.mask, nt->val, isv4(myip));
continue;
}
if(parseip(ip, nt->val) == -1) {