summaryrefslogtreecommitdiffstats
path: root/release
diff options
context:
space:
mode:
authorabial <abial@FreeBSD.org>2001-01-10 23:06:31 +0000
committerabial <abial@FreeBSD.org>2001-01-10 23:06:31 +0000
commit9f9ad5c48c0a3f5f71ec8d26cbf36d0617a9a1b7 (patch)
tree9be3847254b530ac050e3fe25639807812b7ecd7 /release
parentd9b10e22484739c4060ebe44003ae96100c06210 (diff)
downloadFreeBSD-src-9f9ad5c48c0a3f5f71ec8d26cbf36d0617a9a1b7.zip
FreeBSD-src-9f9ad5c48c0a3f5f71ec8d26cbf36d0617a9a1b7.tar.gz
Fix so that the netmask is displayed correctly when it does not
consist of contiguous bits in little endian format. Before the fix the netmask of 0xfffffff0 (0xf0ffffff in little endian format) was displayed /24 instead of /28. Also, add a missing include. Submitted by: Maxime Soule <Maxime.Soule@IPricot.com>
Diffstat (limited to 'release')
-rw-r--r--release/picobsd/tinyware/ns/ns.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/release/picobsd/tinyware/ns/ns.c b/release/picobsd/tinyware/ns/ns.c
index a5e6a25..2d62529 100644
--- a/release/picobsd/tinyware/ns/ns.c
+++ b/release/picobsd/tinyware/ns/ns.c
@@ -58,6 +58,7 @@
#ifdef BRIDGING
#include <net/if_types.h> /* IFT_ETHER */
+#include <net/ethernet.h>
#include <net/bridge.h>
#endif
@@ -98,15 +99,19 @@ sock_ntop(const struct sockaddr *sa, size_t salen)
switch (sa->sa_family) {
case 255: {
- struct sockaddr_in *sin = (struct sockaddr_in *) sa;
u_long mask;
+ u_int index = 1 << 31;
+ u_short new_mask = 0;
int i;
i=0;
- mask=ntohl(sin->sin_addr.s_addr);
+ mask = ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
- while(mask & (0x80000000>>i)) i++;
- sprintf(str,"/%d",i);
+ while(mask & index) {
+ new_mask++;
+ index >>= 1;
+ }
+ sprintf(str,"/%hu", new_mask);
return(str);
}
case AF_UNSPEC:
OpenPOWER on IntegriCloud