diff options
author | Bill Nottingham <notting@redhat.com> | 2004-05-05 01:15:46 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2004-05-05 01:15:46 +0000 |
commit | fec6e5fce6c590e42ff14b421589514cfe3c33bb (patch) | |
tree | 1621f5cb0bdf7598e3fa1d85b5bbca0beede09e6 /src | |
parent | d2e5c7948122794d9a90fc4ee0a0369b80439752 (diff) | |
download | initscripts-fec6e5fce6c590e42ff14b421589514cfe3c33bb.tar initscripts-fec6e5fce6c590e42ff14b421589514cfe3c33bb.tar.gz initscripts-fec6e5fce6c590e42ff14b421589514cfe3c33bb.tar.bz2 initscripts-fec6e5fce6c590e42ff14b421589514cfe3c33bb.tar.xz initscripts-fec6e5fce6c590e42ff14b421589514cfe3c33bb.zip |
ip addresses are ints, not longs (#122479)
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcalc.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/ipcalc.c b/src/ipcalc.c index 468a037c..8964bf7f 100644 --- a/src/ipcalc.c +++ b/src/ipcalc.c @@ -56,7 +56,7 @@ */ /*! - \fn unsigned long int prefix2mask(int bits) + \fn unsigned int prefix2mask(int bits) \brief creates a netmask from a specified number of bits This function converts a prefix length to a netmask. As CIDR (classless @@ -69,20 +69,20 @@ \param prefix is the number of bits to create a mask for. \return a network mask, in network byte order. */ -unsigned long int prefix2mask(int prefix) { +unsigned int prefix2mask(int prefix) { return htonl(~((1 << (32 - prefix)) - 1)); } /*! - \fn int mask2prefix(unsigned long int mask) + \fn int mask2prefix(unsigned int mask) \brief calculates the number of bits masked off by a netmask. This function calculates the significant bits in an IP address as specified by a netmask. See also \ref prefix2mask. - \param mask is the netmask, specified as an unsigned long integer in network byte order. + \param mask is the netmask, specified as an unsigned integer in network byte order. \return the number of significant bits. */ -int mask2prefix(unsigned long int mask) +int mask2prefix(unsigned int mask) { int i; int count = IPBITS; @@ -96,7 +96,7 @@ int mask2prefix(unsigned long int mask) } /*! - \fn unsigned long int default_netmask(unsigned long int addr) + \fn unsigned int default_netmask(unsigned int addr) \brief returns the default (canonical) netmask associated with specified IP address. @@ -108,7 +108,7 @@ int mask2prefix(unsigned long int mask) \param addr an IP address in network byte order. \return a netmask in network byte order. */ -unsigned long int default_netmask(unsigned long int addr) +unsigned int default_netmask(unsigned int addr) { if (((ntohl(addr) & 0xFF000000) >> 24) <= 127) return htonl(0xFF000000); @@ -119,7 +119,7 @@ unsigned long int default_netmask(unsigned long int addr) } /*! - \fn unsigned long int calc_broadcast(unsigned long int addr, int prefix) + \fn unsigned int calc_broadcast(unsigned int addr, int prefix) \brief calculate broadcast address given an IP address and a prefix length. @@ -129,14 +129,14 @@ unsigned long int default_netmask(unsigned long int addr) \return the calculated broadcast address for the network, in network byte order. */ -unsigned long int calc_broadcast(unsigned long int addr, +unsigned int calc_broadcast(unsigned int addr, int prefix) { return (addr & prefix2mask(prefix)) | ~prefix2mask(prefix); } /*! - \fn unsigned long int calc_network(unsigned long int addr, int prefix) + \fn unsigned int calc_network(unsigned int addr, int prefix) \brief calculates the network address for a specified address and prefix. \param addr an IP address, in network byte order @@ -144,13 +144,13 @@ unsigned long int calc_broadcast(unsigned long int addr, \return the base address of the network that addr is associated with, in network byte order. */ -unsigned long int calc_network(unsigned long int addr, int prefix) +unsigned int calc_network(unsigned int addr, int prefix) { return (addr & prefix2mask(prefix)); } /*! - \fn const char *get_hostname(unsigned long int addr) + \fn const char *get_hostname(unsigned int addr) \brief returns the hostname associated with the specified IP address \param addr an IP address to find a hostname for, in network byte order @@ -159,7 +159,7 @@ unsigned long int calc_network(unsigned long int addr, int prefix) in a static buffer that may disappear at any time, the caller should copy the data if it needs permanent storage. */ -const char *get_hostname(unsigned long int addr) +const char *get_hostname(unsigned int addr) { struct hostent * hostinfo; int x; |