aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ipcalc.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ipcalc.c b/src/ipcalc.c
index 2535bb6b..fc8d3d5c 100644
--- a/src/ipcalc.c
+++ b/src/ipcalc.c
@@ -8,7 +8,7 @@
typedef unsigned int int32;
int main(int argc, char ** argv) {
- int showBroadcast = 0, showNetwork = 0, showHostname = 0;
+ int showBroadcast = 0, showNetwork = 0, showHostname = 0, showNetmask = 0;
int beSilent = 0;
int rc;
poptContext optCon;
@@ -19,6 +19,7 @@ int main(int argc, char ** argv) {
struct poptOption optionsTable[] = {
{ "broadcast", '\0', 0, &showBroadcast, 0 },
{ "hostname", '\0', 0, &showHostname, 0 },
+ { "netmask", '\0', 0, &showNetmask, 0 },
{ "network", '\0', 0, &showNetwork, 0 },
{ "silent", '\0', 0, &beSilent, 0 },
{ NULL, '\0', 0, 0, 0 },
@@ -69,6 +70,16 @@ int main(int argc, char ** argv) {
return 1;
}
+ if (showNetmask) {
+ if (((ntohl(ip) & 0xFF000000) >> 24) <= 127)
+ chptr = "255.0.0.0";
+ else if (((ntohl(ip) & 0xFF000000) >> 24) <= 191)
+ chptr = "255.255.0.0";
+ else
+ chptr = "255.255.255.0";
+
+ printf("NETMASK=%s\n", chptr);
+ }
if (showBroadcast) {
broadcast = (ip & netmask) | ~netmask;