[BusyBox] ipcalc request
Marco Manfredini
mldb at gmx.net
Wed Feb 5 04:43:03 UTC 2003
Hello to the list!
I need the option to specify netmasks in the "/xx" CIDR format and made a
litte patch to the current ipcalc.c to accept this. Additionaly I made the -n
option to return the netmask in decimal dotted format, even if it was given
in the command line (to convert from CIDR=>DD).
Quite useful I think. Could this be merged somehow?
Greeting Marco
patch here:
root at gontscharow:~/uclibc/build/usr/src/busybox/networking# diff -pu ipcalc.c
ipcalc.c.~1.1.~
--- ipcalc.c 2003-02-05 11:32:02.000000000 +0100
+++ ipcalc.c.~1.1.~ 2002-11-11 00:42:27.000000000 +0100
@@ -86,7 +86,7 @@ int ipcalc_main(int argc, char **argv)
}
}
- if (mode & (BROADCAST | NETWORK | NETMASK)) {
+ if (mode & (BROADCAST | NETWORK)) {
if (argc - optind > 2) {
show_usage();
}
@@ -105,16 +105,7 @@ int ipcalc_main(int argc, char **argv)
if (argc - optind == 2) {
- const char *m=argv[optind+1];
- if (m[0]!='/') {
- netmask = inet_addr(m);
- } else {
- int bits=atoi(m+1);
- if (bits<=0 || bits>=32)
netmask=INADDR_NONE;
- else {
- netmask =
htonl((unsigned long)0xffffffffl << (32-bits));
- }
- }
+ netmask = inet_addr(argv[optind + 1]);
}
if (ipaddr == INADDR_NONE) {
More information about the busybox
mailing list