summaryrefslogtreecommitdiff
path: root/lib/libc/net
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-04-05 21:13:18 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-04-05 21:13:18 +0000
commitbb93359ccedae9a32facea758712506a0fe8f3d4 (patch)
treee8c47183ac65cd8ac28764b16b44538c24193d92 /lib/libc/net
parenta75078b4a8609418bb7e9376e492d6ef6c57f181 (diff)
Use in_addr_t not u_long and use in_port_t in some cases instead
of u_short or u_int16_t.
Diffstat (limited to 'lib/libc/net')
-rw-r--r--lib/libc/net/byteorder.37
-rw-r--r--lib/libc/net/getnetbyaddr.c4
-rw-r--r--lib/libc/net/getnetent.36
-rw-r--r--lib/libc/net/getnetnamadr.c10
-rw-r--r--lib/libc/net/getservent.c4
-rw-r--r--lib/libc/net/inet.310
-rw-r--r--lib/libc/net/inet_addr.c8
-rw-r--r--lib/libc/net/inet_lnaof.c6
-rw-r--r--lib/libc/net/inet_makeaddr.c6
-rw-r--r--lib/libc/net/inet_neta.c11
-rw-r--r--lib/libc/net/inet_netof.c6
-rw-r--r--lib/libc/net/inet_network.c8
-rw-r--r--lib/libc/net/ns_ntoa.c4
-rw-r--r--lib/libc/net/rcmd.c12
-rw-r--r--lib/libc/net/res_debug.c6
-rw-r--r--lib/libc/net/res_init.c9
16 files changed, 59 insertions, 58 deletions
diff --git a/lib/libc/net/byteorder.3 b/lib/libc/net/byteorder.3
index b880869b055..53528df7e67 100644
--- a/lib/libc/net/byteorder.3
+++ b/lib/libc/net/byteorder.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: byteorder.3,v 1.3 1996/11/25 13:11:12 niklas Exp $
+.\" $OpenBSD: byteorder.3,v 1.4 1997/04/05 21:13:05 millert Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -75,6 +75,9 @@ functions appeared in
.Bx 4.2 .
.Sh BUGS
On the
-.Tn VAX
+.Tn VAX ,
+.Tn ALPHA ,
+and
+.Tn iX86
bytes are handled backwards from most everyone else in
the world. This is not expected to be fixed in the near future.
diff --git a/lib/libc/net/getnetbyaddr.c b/lib/libc/net/getnetbyaddr.c
index 3d2b6e03526..76431a79a92 100644
--- a/lib/libc/net/getnetbyaddr.c
+++ b/lib/libc/net/getnetbyaddr.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getnetbyaddr.c,v 1.3 1997/03/13 19:07:25 downsj Exp $";
+static char rcsid[] = "$OpenBSD: getnetbyaddr.c,v 1.4 1997/04/05 21:13:06 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <netdb.h>
@@ -41,7 +41,7 @@ extern int _net_stayopen;
struct netent *
_getnetbyaddr(net, type)
- register unsigned long net;
+ register in_addr_t net;
register int type;
{
register struct netent *p;
diff --git a/lib/libc/net/getnetent.3 b/lib/libc/net/getnetent.3
index a3aebf43102..a33ac0fac5c 100644
--- a/lib/libc/net/getnetent.3
+++ b/lib/libc/net/getnetent.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: getnetent.3,v 1.3 1997/03/13 19:07:26 downsj Exp $
+.\" $OpenBSD: getnetent.3,v 1.4 1997/04/05 21:13:07 millert Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -48,7 +48,7 @@
.Ft struct netent *
.Fn getnetbyname "char *name"
.Ft struct netent *
-.Fn getnetbyaddr "unsigned long net" "int type"
+.Fn getnetbyaddr "in_addr_t net" "int type"
.Fn setnetent "int stayopen"
.Fn endnetent
.Sh DESCRIPTION
@@ -68,7 +68,7 @@ struct netent {
char *n_name; /* official name of net */
char **n_aliases; /* alias list */
int n_addrtype; /* net number type */
- unsigned long n_net; /* net number */
+ in_addr_t n_net; /* net number */
};
.Ed
.Pp
diff --git a/lib/libc/net/getnetnamadr.c b/lib/libc/net/getnetnamadr.c
index 8d892a1bce4..ad8ff5540a8 100644
--- a/lib/libc/net/getnetnamadr.c
+++ b/lib/libc/net/getnetnamadr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getnetnamadr.c,v 1.4 1997/04/03 08:33:06 downsj Exp $ */
+/* $OpenBSD: getnetnamadr.c,v 1.5 1997/04/05 21:13:08 millert Exp $ */
/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro
* Dep. Matematica Universidade de Coimbra, Portugal, Europe
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)getnetbyaddr.c 8.1 (Berkeley) 6/4/93";
static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03";
static char rcsid[] = "$From: getnetnamadr.c,v 8.7 1996/08/05 08:31:35 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.4 1997/04/03 08:33:06 downsj Exp $";
+static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.5 1997/04/05 21:13:08 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -66,7 +66,7 @@ static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.4 1997/04/03 08:33:06 downsj
extern int h_errno;
-struct netent *_getnetbyaddr __P((long net, int type));
+struct netent *_getnetbyaddr __P((in_addr_t net, int type));
struct netent *_getnetbyname __P((const char *name));
int _hokchar __P((const char *));
@@ -211,14 +211,14 @@ getnetanswer(answer, anslen, net_i)
struct netent *
getnetbyaddr(net, net_type)
- register u_long net;
+ register in_addr_t net;
register int net_type;
{
unsigned int netbr[4];
int nn, anslen;
querybuf buf;
char qbuf[MAXDNAME];
- unsigned long net2;
+ in_addr_t net2;
struct netent *net_entry;
char lookups[MAXDNSLUS];
int i;
diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c
index ffa727077c3..feb97aa129a 100644
--- a/lib/libc/net/getservent.c
+++ b/lib/libc/net/getservent.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getservent.c,v 1.2 1996/08/19 08:29:00 tholo Exp $";
+static char rcsid[] = "$OpenBSD: getservent.c,v 1.3 1997/04/05 21:13:09 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -99,7 +99,7 @@ again:
if (cp == NULL)
goto again;
*cp++ = '\0';
- serv.s_port = htons((u_short)atoi(p));
+ serv.s_port = htons((in_port_t)atoi(p));
serv.s_proto = cp;
q = serv.s_aliases = serv_aliases;
cp = strpbrk(cp, " \t");
diff --git a/lib/libc/net/inet.3 b/lib/libc/net/inet.3
index 4b31ddc9493..db28804e32c 100644
--- a/lib/libc/net/inet.3
+++ b/lib/libc/net/inet.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: inet.3,v 1.2 1996/08/19 08:29:06 tholo Exp $
+.\" $OpenBSD: inet.3,v 1.3 1997/04/05 21:13:10 millert Exp $
.\"
.\" Copyright (c) 1983, 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -49,17 +49,17 @@
.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"
.Ft struct in_addr
.Fn inet_makeaddr "int net" "int lna"
-.Ft unsigned long
+.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
diff --git a/lib/libc/net/inet_addr.c b/lib/libc/net/inet_addr.c
index ef8ee4963bc..5e4dcdafb28 100644
--- a/lib/libc/net/inet_addr.c
+++ b/lib/libc/net/inet_addr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet_addr.c,v 1.4 1997/03/13 19:07:29 downsj Exp $ */
+/* $OpenBSD: inet_addr.c,v 1.5 1997/04/05 21:13:10 millert Exp $ */
/*
* ++Copyright++ 1983, 1990, 1993
@@ -60,7 +60,7 @@
static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
static char rcsid[] = "$From: inet_addr.c,v 8.5 1996/08/05 08:31:35 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: inet_addr.c,v 1.4 1997/03/13 19:07:29 downsj Exp $";
+static char rcsid[] = "$OpenBSD: inet_addr.c,v 1.5 1997/04/05 21:13:10 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -74,7 +74,7 @@ static char rcsid[] = "$OpenBSD: inet_addr.c,v 1.4 1997/03/13 19:07:29 downsj Ex
* Ascii internet address interpretation routine.
* The value returned is in network order.
*/
-u_long
+in_addr_t
inet_addr(cp)
register const char *cp;
{
@@ -97,7 +97,7 @@ inet_aton(cp, addr)
register const char *cp;
struct in_addr *addr;
{
- register u_long val;
+ register in_addr_t val;
register int base, n;
register char c;
u_int parts[4];
diff --git a/lib/libc/net/inet_lnaof.c b/lib/libc/net/inet_lnaof.c
index 5a9bc4a6fe8..6aed18699b4 100644
--- a/lib/libc/net/inet_lnaof.c
+++ b/lib/libc/net/inet_lnaof.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: inet_lnaof.c,v 1.2 1996/08/19 08:29:09 tholo Exp $";
+static char rcsid[] = "$OpenBSD: inet_lnaof.c,v 1.3 1997/04/05 21:13:11 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -44,11 +44,11 @@ static char rcsid[] = "$OpenBSD: inet_lnaof.c,v 1.2 1996/08/19 08:29:09 tholo Ex
* 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);
diff --git a/lib/libc/net/inet_makeaddr.c b/lib/libc/net/inet_makeaddr.c
index 1b2d4edb5a1..196a589e4c1 100644
--- a/lib/libc/net/inet_makeaddr.c
+++ b/lib/libc/net/inet_makeaddr.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: inet_makeaddr.c,v 1.2 1996/08/19 08:29:11 tholo Exp $";
+static char rcsid[] = "$OpenBSD: inet_makeaddr.c,v 1.3 1997/04/05 21:13:12 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -45,9 +45,9 @@ static char rcsid[] = "$OpenBSD: inet_makeaddr.c,v 1.2 1996/08/19 08:29:11 tholo
*/
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);
diff --git a/lib/libc/net/inet_neta.c b/lib/libc/net/inet_neta.c
index dffd1631b13..ffcddd8d912 100644
--- a/lib/libc/net/inet_neta.c
+++ b/lib/libc/net/inet_neta.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet_neta.c,v 1.1 1997/03/13 19:07:31 downsj Exp $ */
+/* $OpenBSD: inet_neta.c,v 1.2 1997/04/05 21:13:12 millert Exp $ */
/*
* Copyright (c) 1996 by Internet Software Consortium.
@@ -19,9 +19,9 @@
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
-static const char rcsid[] = "$Id: inet_neta.c,v 1.1 1997/03/13 19:07:31 downsj Exp $";
+static const char rcsid[] = "$Id: inet_neta.c,v 1.2 1997/04/05 21:13:12 millert Exp $";
#else
-static const char rcsid[] = "$OpenBSD: inet_neta.c,v 1.1 1997/03/13 19:07:31 downsj Exp $";
+static const char rcsid[] = "$OpenBSD: inet_neta.c,v 1.2 1997/04/05 21:13:12 millert Exp $";
#endif
#endif
@@ -32,11 +32,12 @@ static const char rcsid[] = "$OpenBSD: inet_neta.c,v 1.1 1997/03/13 19:07:31 dow
#include <errno.h>
#include <stdio.h>
+#include <string.h>
/*
* char *
* inet_neta(src, dst, size)
- * format a u_long network number into presentation format.
+ * format an in_addr_t network number into presentation format.
* return:
* pointer to dst, or NULL if an error occurred (check errno).
* note:
@@ -46,7 +47,7 @@ static const char rcsid[] = "$OpenBSD: inet_neta.c,v 1.1 1997/03/13 19:07:31 dow
*/
char *
inet_neta(src, dst, size)
- u_long src;
+ in_addr_t src;
char *dst;
size_t size;
{
diff --git a/lib/libc/net/inet_netof.c b/lib/libc/net/inet_netof.c
index 8f78b7a8b4b..f3b9c016974 100644
--- a/lib/libc/net/inet_netof.c
+++ b/lib/libc/net/inet_netof.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: inet_netof.c,v 1.2 1996/08/19 08:29:12 tholo Exp $";
+static char rcsid[] = "$OpenBSD: inet_netof.c,v 1.3 1997/04/05 21:13:13 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -43,11 +43,11 @@ static char rcsid[] = "$OpenBSD: inet_netof.c,v 1.2 1996/08/19 08:29:12 tholo Ex
* 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);
diff --git a/lib/libc/net/inet_network.c b/lib/libc/net/inet_network.c
index 1ffee63309a..34682bbec16 100644
--- a/lib/libc/net/inet_network.c
+++ b/lib/libc/net/inet_network.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: inet_network.c,v 1.4 1996/08/19 08:29:14 tholo Exp $";
+static char rcsid[] = "$OpenBSD: inet_network.c,v 1.5 1997/04/05 21:13:14 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -45,13 +45,13 @@ static char rcsid[] = "$OpenBSD: inet_network.c,v 1.4 1996/08/19 08:29:14 tholo
* 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;
+ 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:
diff --git a/lib/libc/net/ns_ntoa.c b/lib/libc/net/ns_ntoa.c
index f7932ed3b60..d65d6d84d81 100644
--- a/lib/libc/net/ns_ntoa.c
+++ b/lib/libc/net/ns_ntoa.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: ns_ntoa.c,v 1.3 1996/08/19 08:29:31 tholo Exp $";
+static char rcsid[] = "$OpenBSD: ns_ntoa.c,v 1.4 1997/04/05 21:13:15 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -47,7 +47,7 @@ ns_ntoa(addr)
{
static char obuf[40];
union { union ns_net net_e; u_long long_e; } net;
- u_short port = htons(addr.x_port);
+ in_port_t port = htons(addr.x_port);
register char *cp;
char *cp2;
register u_char *up = addr.x_host.c_host;
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c
index 8029938df33..a0adaf8ed0d 100644
--- a/lib/libc/net/rcmd.c
+++ b/lib/libc/net/rcmd.c
@@ -34,7 +34,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: rcmd.c,v 1.19 1997/01/25 21:30:37 deraadt Exp $";
+static char *rcsid = "$OpenBSD: rcmd.c,v 1.20 1997/04/05 21:13:15 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -56,14 +56,14 @@ static char *rcsid = "$OpenBSD: rcmd.c,v 1.19 1997/01/25 21:30:37 deraadt Exp $"
#include <syslog.h>
#include <stdlib.h>
-int __ivaliduser __P((FILE *, u_long, const char *, const char *));
+int __ivaliduser __P((FILE *, in_addr_t, const char *, const char *));
static int __icheckhost __P((u_int32_t, const char *));
static char *__gethostloop __P((u_int32_t));
int
rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
char **ahost;
- u_short rport;
+ in_port_t rport;
const char *locuser, *remuser, *cmd;
int *fd2p;
{
@@ -259,7 +259,7 @@ rresvport(alport)
s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0)
return (-1);
- sin.sin_port = htons((u_short)*alport);
+ sin.sin_port = htons((in_port_t)*alport);
if (*alport < IPPORT_RESERVED - 1) {
if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
return (s);
@@ -298,7 +298,7 @@ ruserok(rhost, superuser, ruser, luser)
addrs[i] = 0;
for (i = 0; i < MAXADDRS && addrs[i]; i++)
- if (iruserok((u_long)addrs[i], superuser, ruser, luser) == 0)
+ if (iruserok((in_addr_t)addrs[i], superuser, ruser, luser) == 0)
return (0);
return (-1);
}
@@ -390,7 +390,7 @@ again:
int
__ivaliduser(hostf, raddrl, luser, ruser)
FILE *hostf;
- u_long raddrl;
+ in_addr_t raddrl;
const char *luser, *ruser;
{
register char *user, *p;
diff --git a/lib/libc/net/res_debug.c b/lib/libc/net/res_debug.c
index 7fd6d4a21c6..0b623a153c8 100644
--- a/lib/libc/net/res_debug.c
+++ b/lib/libc/net/res_debug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_debug.c,v 1.5 1997/03/13 19:07:37 downsj Exp $ */
+/* $OpenBSD: res_debug.c,v 1.6 1997/04/05 21:13:16 millert Exp $ */
/*
* ++Copyright++ 1985, 1990, 1993
@@ -82,7 +82,7 @@
static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$From: res_debug.c,v 8.19 1996/11/26 10:11:23 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: res_debug.c,v 1.5 1997/03/13 19:07:37 downsj Exp $";
+static char rcsid[] = "$OpenBSD: res_debug.c,v 1.6 1997/04/05 21:13:16 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -518,7 +518,7 @@ __p_rr(cp, msg, file)
} else if (dlen == 7) {
char *address;
u_char protocol;
- u_short port;
+ in_port_t port;
address = inet_ntoa(inaddr);
cp += INADDRSZ;
diff --git a/lib/libc/net/res_init.c b/lib/libc/net/res_init.c
index 81ea50b0fb2..a16c47807f4 100644
--- a/lib/libc/net/res_init.c
+++ b/lib/libc/net/res_init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_init.c,v 1.12 1997/04/03 05:53:46 deraadt Exp $ */
+/* $OpenBSD: res_init.c,v 1.13 1997/04/05 21:13:17 millert Exp $ */
/*
* ++Copyright++ 1985, 1989, 1993
@@ -60,7 +60,7 @@
static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: res_init.c,v 1.12 1997/04/03 05:53:46 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: res_init.c,v 1.13 1997/04/05 21:13:17 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -514,8 +514,5 @@ net_mask(in) /* XXX - should really use system's version of this */
u_int
res_randomid()
{
- struct timeval now;
-
- gettimeofday(&now, NULL);
- return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
+ return (0xffff & arc4random());
}