Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/rdate Support -4 and -6.
details: https://anonhg.NetBSD.org/src/rev/c050d84ce92a
branches: trunk
changeset: 355985:c050d84ce92a
user: ginsbach <ginsbach%NetBSD.org@localhost>
date: Sat Aug 26 19:26:32 2017 +0000
description:
Support -4 and -6.
diffstat:
usr.sbin/rdate/rdate.8 | 14 +++++++++++---
usr.sbin/rdate/rdate.c | 29 ++++++++++++++++++++---------
2 files changed, 31 insertions(+), 12 deletions(-)
diffs (116 lines):
diff -r c9ebafdb4ba7 -r c050d84ce92a usr.sbin/rdate/rdate.8
--- a/usr.sbin/rdate/rdate.8 Sat Aug 26 18:16:05 2017 +0000
+++ b/usr.sbin/rdate/rdate.8 Sat Aug 26 19:26:32 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: rdate.8,v 1.12 2017/08/26 18:16:05 ginsbach Exp $
+.\" $NetBSD: rdate.8,v 1.13 2017/08/26 19:26:32 ginsbach Exp $
.\"
.\" Copyright (c) 1994 Christos Zoulas
.\" All rights reserved.
@@ -23,7 +23,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 30, 1994
+.Dd August 26, 2017
.Dt RDATE 8
.Os
.Sh NAME
@@ -31,7 +31,7 @@
.Nd set the system's date from a remote host
.Sh SYNOPSIS
.Nm
-.Op Fl aps
+.Op Fl 46aps
.Ar host
.Sh DESCRIPTION
.Nm
@@ -43,6 +43,14 @@
Available options:
.Pp
.Bl -tag -width indent
+.It Fl 4
+Forces
+.Nm
+to use IPv4 addresses only.
+.It Fl 6
+Forces
+.Nm
+to use IPv6 addresses only.
.It Fl a
Use the
.Xr adjtime 2
diff -r c9ebafdb4ba7 -r c050d84ce92a usr.sbin/rdate/rdate.c
--- a/usr.sbin/rdate/rdate.c Sat Aug 26 18:16:05 2017 +0000
+++ b/usr.sbin/rdate/rdate.c Sat Aug 26 19:26:32 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rdate.c,v 1.21 2017/08/26 18:16:05 ginsbach Exp $ */
+/* $NetBSD: rdate.c,v 1.22 2017/08/26 19:26:32 ginsbach Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rdate.c,v 1.21 2017/08/26 18:16:05 ginsbach Exp $");
+__RCSID("$NetBSD: rdate.c,v 1.22 2017/08/26 19:26:32 ginsbach Exp $");
#endif /* lint */
#include <sys/types.h>
@@ -59,7 +59,9 @@
static void
usage(void)
{
- (void) fprintf(stderr, "usage: %s [-aps] host\n", getprogname());
+ (void) fprintf(stderr, "usage: %s [-46aps] host\n", getprogname());
+ (void) fprintf(stderr, " -4: use IPv4 addresses only\n");
+ (void) fprintf(stderr, " -6: use IPv6 addresses only\n");
(void) fprintf(stderr, " -a: use adjtime instead of instant change\n");
(void) fprintf(stderr, " -p: just print, don't set\n");
(void) fprintf(stderr, " -s: just set, don't print\n");
@@ -78,10 +80,23 @@
struct addrinfo hints, *res, *res0;
int c;
int error;
+ int family = AF_UNSPEC;
adjustment = 0;
- while ((c = getopt(argc, argv, "psa")) != -1)
+ while ((c = getopt(argc, argv, "46aps")) != -1)
switch (c) {
+ case '4':
+ family = AF_INET;
+ break;
+
+ case '6':
+ family = AF_INET6;
+ break;
+
+ case 'a':
+ slidetime++;
+ break;
+
case 'p':
pr++;
break;
@@ -90,10 +105,6 @@
silent++;
break;
- case 'a':
- slidetime++;
- break;
-
default:
usage();
return 1;
@@ -106,7 +117,7 @@
hname = argv[optind];
memset(&hints, 0, sizeof (hints));
- hints.ai_family = PF_UNSPEC;
+ hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
error = getaddrinfo(hname, "time", &hints, &res0);
Home |
Main Index |
Thread Index |
Old Index