IPv4 address is not unsigned int. This change introduces in_addr_t.
PR: 9982 Adviced by: des Reviewed by: -alpha and -net (no objection) Obtained from: OpenBSD
This commit is contained in:
parent
c805813625
commit
2da24fa6e9
@ -84,13 +84,13 @@ struct in_addr;
|
||||
__BEGIN_DECLS
|
||||
int ascii2addr __P((int, const char *, void *));
|
||||
char *addr2ascii __P((int, const void *, int, char *));
|
||||
unsigned long inet_addr __P((const char *));
|
||||
in_addr_t inet_addr __P((const char *));
|
||||
int inet_aton __P((const char *, struct in_addr *));
|
||||
unsigned long inet_lnaof __P((struct in_addr));
|
||||
struct in_addr inet_makeaddr __P((u_long , u_long));
|
||||
char * inet_neta __P((u_long, char *, size_t));
|
||||
unsigned long inet_netof __P((struct in_addr));
|
||||
unsigned long inet_network __P((const char *));
|
||||
in_addr_t inet_lnaof __P((struct in_addr));
|
||||
struct in_addr inet_makeaddr __P((in_addr_t, in_addr_t));
|
||||
char * inet_neta __P((in_addr_t, char *, size_t));
|
||||
in_addr_t inet_netof __P((struct in_addr));
|
||||
in_addr_t inet_network __P((const char *));
|
||||
char *inet_net_ntop __P((int, const void *, int, char *, size_t));
|
||||
int inet_net_pton __P((int, const char *, void *, size_t));
|
||||
char *inet_ntoa __P((struct in_addr));
|
||||
|
@ -55,9 +55,9 @@
|
||||
.Fd #include <arpa/inet.h>
|
||||
.Ft int
|
||||
.Fn inet_aton "const char *cp" "struct in_addr *pin"
|
||||
.Ft unsigned long
|
||||
.Ft in_addr_t
|
||||
.Fn inet_addr "const char *cp"
|
||||
.Ft unsigned long
|
||||
.Ft in_addr_t
|
||||
.Fn inet_network "const char *cp"
|
||||
.Ft char *
|
||||
.Fn inet_ntoa "struct in_addr in"
|
||||
@ -66,10 +66,10 @@
|
||||
.Ft int
|
||||
.Fn inet_pton "int af" "const char *src" "void *dst"
|
||||
.Ft struct in_addr
|
||||
.Fn inet_makeaddr "unsigned long net" "unsigned long lna"
|
||||
.Ft unsigned long
|
||||
.Fn inet_makeaddr "in_addr_t net" "in_addr_t lna"
|
||||
.Ft in_addr_t
|
||||
.Fn inet_lnaof "struct in_addr in"
|
||||
.Ft unsigned long
|
||||
.Ft in_addr_t
|
||||
.Fn inet_netof "struct in_addr in"
|
||||
.Sh DESCRIPTION
|
||||
The routines
|
||||
|
@ -72,7 +72,7 @@ static char rcsid[] = "$FreeBSD$";
|
||||
* ASCII internet address interpretation routine.
|
||||
* The value returned is in network order.
|
||||
*/
|
||||
u_long /* XXX should be struct in_addr :( */
|
||||
in_addr_t /* XXX should be struct in_addr :( */
|
||||
inet_addr(cp)
|
||||
register const char *cp;
|
||||
{
|
||||
@ -96,7 +96,7 @@ inet_aton(cp, addr)
|
||||
struct in_addr *addr;
|
||||
{
|
||||
u_long parts[4];
|
||||
u_long val;
|
||||
in_addr_t val;
|
||||
char *c;
|
||||
char *endptr;
|
||||
int gotend, n;
|
||||
|
@ -29,6 +29,8 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
@ -44,11 +46,11 @@ static char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93";
|
||||
* internet address; handles class a/b/c network
|
||||
* number formats.
|
||||
*/
|
||||
u_long
|
||||
in_addr_t
|
||||
inet_lnaof(in)
|
||||
struct in_addr in;
|
||||
{
|
||||
register u_long i = ntohl(in.s_addr);
|
||||
register in_addr_t i = ntohl(in.s_addr);
|
||||
|
||||
if (IN_CLASSA(i))
|
||||
return ((i)&IN_CLASSA_HOST);
|
||||
|
@ -29,6 +29,8 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
@ -45,9 +47,9 @@ static char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93";
|
||||
*/
|
||||
struct in_addr
|
||||
inet_makeaddr(net, host)
|
||||
u_long net, host;
|
||||
in_addr_t net, host;
|
||||
{
|
||||
u_long addr;
|
||||
in_addr_t addr;
|
||||
|
||||
if (net < 128)
|
||||
addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST);
|
||||
|
@ -38,7 +38,7 @@ static const char rcsid[] = "$FreeBSD$";
|
||||
/*
|
||||
* char *
|
||||
* inet_neta(src, dst, size)
|
||||
* format a u_long network number into presentation format.
|
||||
* format a in_addr_t network number into presentation format.
|
||||
* return:
|
||||
* pointer to dst, or NULL if an error occurred (check errno).
|
||||
* note:
|
||||
@ -48,7 +48,7 @@ static const char rcsid[] = "$FreeBSD$";
|
||||
*/
|
||||
char *
|
||||
inet_neta(src, dst, size)
|
||||
u_long src;
|
||||
in_addr_t src;
|
||||
char *dst;
|
||||
size_t size;
|
||||
{
|
||||
|
@ -29,6 +29,8 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
@ -43,11 +45,11 @@ static char sccsid[] = "@(#)inet_netof.c 8.1 (Berkeley) 6/4/93";
|
||||
* Return the network number from an internet
|
||||
* address; handles class a/b/c network #'s.
|
||||
*/
|
||||
u_long
|
||||
in_addr_t
|
||||
inet_netof(in)
|
||||
struct in_addr in;
|
||||
{
|
||||
register u_long i = ntohl(in.s_addr);
|
||||
register in_addr_t i = ntohl(in.s_addr);
|
||||
|
||||
if (IN_CLASSA(i))
|
||||
return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT);
|
||||
|
@ -47,13 +47,14 @@ static char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93";
|
||||
* The library routines call this routine to interpret
|
||||
* network numbers.
|
||||
*/
|
||||
u_long
|
||||
in_addr_t
|
||||
inet_network(cp)
|
||||
register const char *cp;
|
||||
{
|
||||
register u_long val, base, n, i;
|
||||
register in_addr_t val, base, n;
|
||||
register char c;
|
||||
u_long parts[4], *pp = parts;
|
||||
in_addr_t parts[4], *pp = parts;
|
||||
register int i;
|
||||
|
||||
again:
|
||||
val = 0; base = 10;
|
||||
|
@ -232,7 +232,7 @@
|
||||
* Internet address (a structure for historical reasons)
|
||||
*/
|
||||
struct in_addr {
|
||||
u_int32_t s_addr;
|
||||
in_addr_t s_addr;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -73,6 +73,7 @@ typedef int32_t daddr_t; /* disk address */
|
||||
typedef u_int32_t u_daddr_t; /* unsigned disk address */
|
||||
typedef u_int32_t fixpt_t; /* fixed point number */
|
||||
typedef u_int32_t gid_t; /* group id */
|
||||
typedef u_int32_t in_addr_t; /* base type for internet address */
|
||||
typedef u_int32_t ino_t; /* inode number */
|
||||
typedef long key_t; /* IPC key (for Sys V IPC) */
|
||||
typedef u_int16_t mode_t; /* permissions */
|
||||
|
Loading…
Reference in New Issue
Block a user