diff options
author | Erik Troan <ewt@redhat.com> | 1998-03-22 20:33:49 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 1998-03-22 20:33:49 +0000 |
commit | 4e2822fc434126830c8fc362e704f38acda94287 (patch) | |
tree | a38dd46b8004b10f68223074a177491f33e6a898 /src | |
parent | cbc5159cc3b9f76e6a293183674a37382731d674 (diff) | |
download | initscripts-4e2822fc434126830c8fc362e704f38acda94287.tar initscripts-4e2822fc434126830c8fc362e704f38acda94287.tar.gz initscripts-4e2822fc434126830c8fc362e704f38acda94287.tar.bz2 initscripts-4e2822fc434126830c8fc362e704f38acda94287.tar.xz initscripts-4e2822fc434126830c8fc362e704f38acda94287.zip |
added --netmask argument
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcalc.c | 13 |
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; |