Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/net add NetBSD RCSID on top.
details: https://anonhg.NetBSD.org/src/rev/754c90940757
branches: trunk
changeset: 474338:754c90940757
user: itojun <itojun%NetBSD.org@localhost>
date: Sun Jul 04 00:43:43 1999 +0000
description:
add NetBSD RCSID on top.
diffstat:
lib/libc/net/getaddrinfo.c | 2 +
lib/libc/net/getnameinfo.c | 2 +
lib/libc/net/ifname.c | 2 +
lib/libc/net/ip6opt.c | 2 +
lib/libc/net/rcmd.3 | 30 +++++++++++++++---
lib/libc/net/rcmd.c | 73 ++++++++++++++++++++++++++++++++-------------
lib/libc/net/res_init.c | 46 +++++++++++++++++-----------
lib/libc/net/rthdr.c | 2 +
lib/libc/net/vars6.c | 2 +
9 files changed, 115 insertions(+), 46 deletions(-)
diffs (truncated from 335 to 300 lines):
diff -r a95e6607e4ff -r 754c90940757 lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c Sun Jul 04 00:34:20 1999 +0000
+++ b/lib/libc/net/getaddrinfo.c Sun Jul 04 00:43:43 1999 +0000
@@ -1,3 +1,5 @@
+/* $NetBSD: getaddrinfo.c,v 1.6 1999/07/04 00:43:43 itojun Exp $ */
+
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
diff -r a95e6607e4ff -r 754c90940757 lib/libc/net/getnameinfo.c
--- a/lib/libc/net/getnameinfo.c Sun Jul 04 00:34:20 1999 +0000
+++ b/lib/libc/net/getnameinfo.c Sun Jul 04 00:43:43 1999 +0000
@@ -1,3 +1,5 @@
+/* $NetBSD: getnameinfo.c,v 1.2 1999/07/04 00:43:43 itojun Exp $ */
+
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
diff -r a95e6607e4ff -r 754c90940757 lib/libc/net/ifname.c
--- a/lib/libc/net/ifname.c Sun Jul 04 00:34:20 1999 +0000
+++ b/lib/libc/net/ifname.c Sun Jul 04 00:43:43 1999 +0000
@@ -1,3 +1,5 @@
+/* $NetBSD: ifname.c,v 1.3 1999/07/04 00:43:43 itojun Exp $ */
+
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
diff -r a95e6607e4ff -r 754c90940757 lib/libc/net/ip6opt.c
--- a/lib/libc/net/ip6opt.c Sun Jul 04 00:34:20 1999 +0000
+++ b/lib/libc/net/ip6opt.c Sun Jul 04 00:43:43 1999 +0000
@@ -1,3 +1,5 @@
+/* $NetBSD: ip6opt.c,v 1.2 1999/07/04 00:43:44 itojun Exp $ */
+
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
diff -r a95e6607e4ff -r 754c90940757 lib/libc/net/rcmd.3
--- a/lib/libc/net/rcmd.3 Sun Jul 04 00:34:20 1999 +0000
+++ b/lib/libc/net/rcmd.3 Sun Jul 04 00:43:43 1999 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: rcmd.3,v 1.17 1999/03/22 19:44:54 garbled Exp $
+.\" $NetBSD: rcmd.3,v 1.18 1999/07/04 00:43:44 itojun Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -39,6 +39,7 @@
.Sh NAME
.Nm rcmd ,
.Nm rresvport ,
+.Nm rresvport_af ,
.Nm iruserok ,
.Nm ruserok ,
.Nm orcmd
@@ -54,6 +55,8 @@
.Ft int
.Fn rresvport "int *port"
.Ft int
+.Fn rresvport_af "int *port" "int family"
+.Ft int
.Fn iruserok "u_int32_t raddr" "int superuser" "const char *ruser" "const char *luser"
.Ft int
.Fn ruserok "const char *rhost" "int superuser" "const char *ruser" "const char *luser"
@@ -83,13 +86,24 @@
returns a descriptor to a socket
with an address in the privileged port space.
The
+.Fn rresvport_af
+function is similar to
+.Fn rresvport ,
+but you can explicitly specify the address family to use.
+Calling
+.Fn rresvport_af
+with
+.Dv AF_INET
+has the same effect as
+.Fn rresvport .
+The
.Fn iruserok
and
.Fn ruserok
functions are used by servers
to authenticate clients requesting service with
.Fn rcmd .
-All five functions are present in the same file and are used
+All six functions are present in the same file and are used
by the
.Xr rshd 8
server (among others).
@@ -145,7 +159,9 @@
.Pp
The
.Fn rresvport
-function is used to obtain a socket with a privileged
+and
+.Fn rresvport_af
+functions are used to obtain a socket with a privileged
address bound to it. This socket is suitable for use
by
.Fn rcmd
@@ -200,9 +216,11 @@
.Pp
The
.Fn rresvport
+and
+.Fn rresvport_af
function
-returns a valid, bound socket descriptor on success.
-It returns \-1 on error with the global value
+return a valid, bound socket descriptor on success.
+They return \-1 on error with the global value
.Va errno
set according to the reason for failure.
The error code
@@ -244,6 +262,8 @@
.Fn rcmd
function appeared in
.Nx 1.3 .
+.Fn rresvport_af
+was defined in RFC2292.
.Sh BUGS
As the
.Nm
diff -r a95e6607e4ff -r 754c90940757 lib/libc/net/rcmd.c
--- a/lib/libc/net/rcmd.c Sun Jul 04 00:34:20 1999 +0000
+++ b/lib/libc/net/rcmd.c Sun Jul 04 00:43:43 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rcmd.c,v 1.31 1999/05/03 15:26:12 christos Exp $ */
+/* $NetBSD: rcmd.c,v 1.32 1999/07/04 00:43:44 itojun Exp $ */
/*
* Copyright (c) 1997 Matthew R. Green.
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#else
-__RCSID("$NetBSD: rcmd.c,v 1.31 1999/05/03 15:26:12 christos Exp $");
+__RCSID("$NetBSD: rcmd.c,v 1.32 1999/07/04 00:43:44 itojun Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -397,21 +397,62 @@
rresvport(alport)
int *alport;
{
- struct sockaddr_in sin;
+ return rresvport_af(alport, AF_INET);
+}
+
+int
+rresvport_af(alport, family)
+ int *alport;
+ int family;
+{
+ struct sockaddr_storage ss;
+ struct sockaddr *sa;
+ int salen;
int s;
+ u_int16_t *portp;
+ memset(&ss, 0, sizeof(ss));
+ sa = (struct sockaddr *)&ss;
+ switch (family) {
+ case AF_INET:
#ifdef BSD4_4
- sin.sin_len = sizeof(struct sockaddr_in);
+ sa->sa_len =
+#endif
+ salen = sizeof(struct sockaddr_in);
+ portp = &((struct sockaddr_in *)sa)->sin_port;
+ break;
+ case AF_INET6:
+#ifdef BSD4_4
+ sa->sa_len =
#endif
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = INADDR_ANY;
- s = socket(AF_INET, SOCK_STREAM, 0);
+ salen = sizeof(struct sockaddr_in6);
+ portp = &((struct sockaddr_in6 *)sa)->sin6_port;
+ break;
+ default:
+ portp = NULL;
+ return EAFNOSUPPORT;
+ }
+ sa->sa_family = family;
+ s = socket(family, SOCK_STREAM, 0);
if (s < 0)
return (-1);
-#ifndef BSD4_4
+#ifdef BSD4_4
+ if (family == AF_INET) {
+ *portp = 0;
+ if (bindresvport(s, (struct sockaddr_in *)sa) < 0) {
+ int sverr = errno;
+
+ (void)close(s);
+ errno = sverr;
+ return (-1);
+ }
+ *alport = (int)ntohs(*portp);
+ return (s);
+ }
+#endif
for (;;) {
- sin.sin_port = htons((u_short)*alport);
- if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
+ *portp = htons((u_short)*alport);
+ if (bind(s, sa, salen) >= 0)
return (s);
if (errno != EADDRINUSE) {
(void)close(s);
@@ -424,18 +465,6 @@
return (-1);
}
}
-#else
- sin.sin_port = 0;
- if (bindresvport(s, &sin) < 0) {
- int sverr = errno;
-
- (void)close(s);
- errno = sverr;
- return (-1);
- }
- *alport = (int)ntohs(sin.sin_port);
- return (s);
-#endif
}
int __check_rhosts_file = 1;
diff -r a95e6607e4ff -r 754c90940757 lib/libc/net/res_init.c
--- a/lib/libc/net/res_init.c Sun Jul 04 00:34:20 1999 +0000
+++ b/lib/libc/net/res_init.c Sun Jul 04 00:43:43 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: res_init.c,v 1.24 1999/07/01 18:19:35 itojun Exp $ */
+/* $NetBSD: res_init.c,v 1.25 1999/07/04 00:43:44 itojun Exp $ */
/*-
* Copyright (c) 1985, 1989, 1993
@@ -59,7 +59,7 @@
static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static char rcsid[] = "Id: res_init.c,v 8.8 1997/06/01 20:34:37 vixie Exp ";
#else
-__RCSID("$NetBSD: res_init.c,v 1.24 1999/07/01 18:19:35 itojun Exp $");
+__RCSID("$NetBSD: res_init.c,v 1.25 1999/07/04 00:43:44 itojun Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -140,15 +140,10 @@
#endif
#ifdef INET6
struct sockaddr_in6 *sin6;
- struct addrinfo *ai;
- static char nsport[32];
- struct addrinfo hints;
#endif
_res.id = res_randomid();
#ifdef INET6
- if (nsport[0] == '\0')
- sprintf(nsport, "%u", NAMESERVER_PORT);
sin6 = (struct sockaddr_in6 *)&_res_ext.nsaddr;
sin6->sin6_len = sizeof(struct sockaddr_in6);
sin6->sin6_family = AF_INET6;
@@ -278,9 +273,9 @@
if (MATCH(buf, "nameserver") && nserv < MAXNS) {
#ifdef INET6
char *q;
-#else /* INET6 */
+ struct in6_addr a6;
+#endif /* INET6 */
struct in_addr a;
-#endif /* INET6 */
cp = buf + sizeof("nameserver") - 1;
while (*cp == ' ' || *cp == '\t')
@@ -294,17 +289,30 @@
break;
}
}
- memset(&hints, 0, sizeof(hints));
- hints.ai_flags = AI_NUMERICHOST;
- if (getaddrinfo(cp, nsport, &hints, &ai) == 0) {
- memcpy(&_res_ext.nsaddr_list[nserv],
- ai->ai_addr, ai->ai_addrlen);
- /* for compatibility */
- if (ai->ai_family == AF_INET)
- memcpy(&_res.nsaddr_list[nserv],
- ai->ai_addr, ai->ai_addrlen);
+ if (inet_pton(AF_INET6, cp, &a6) == 1) {
+ sin6 = (struct sockaddr_in6 *)
+ &_res_ext.nsaddr_list[nserv];
+ memset(sin6, 0, sizeof(*sin6));
+ sin6->sin6_family = AF_INET6;
+ sin6->sin6_len = sizeof(struct sockaddr_in6);
+ memcpy(&sin6->sin6_addr, &a6, sizeof(sin6->sin6_addr));
+ sin6->sin6_port = htons(NAMESERVER_PORT);
+ /* just for safety */
+ memset(&_res.nsaddr_list[nserv], 0,
+ sizeof(_res.nsaddr_list[nserv]));
Home |
Main Index |
Thread Index |
Old Index