diff options
author | 2004-02-16 21:25:41 +0000 | |
---|---|---|
committer | 2004-02-16 21:25:41 +0000 | |
commit | 22d417c3588833de9e28be5ae8b344dd64513faa (patch) | |
tree | 6707c9a1bdff37a3e5d0cdfb842895dc2e00be2e | |
parent | check for isakmp_sa->transport != NULL; noticed by bluhm at genua.de ok hshoexer@ (diff) | |
download | wireguard-openbsd-22d417c3588833de9e28be5ae8b344dd64513faa.tar.xz wireguard-openbsd-22d417c3588833de9e28be5ae8b344dd64513faa.zip |
add IPv4/IPv6 transport selection. ok millert@ deraadt@
-rw-r--r-- | usr.sbin/rdate/ntp.c | 8 | ||||
-rw-r--r-- | usr.sbin/rdate/rdate.8 | 12 | ||||
-rw-r--r-- | usr.sbin/rdate/rdate.c | 26 | ||||
-rw-r--r-- | usr.sbin/rdate/rfc868time.c | 8 |
4 files changed, 37 insertions, 17 deletions
diff --git a/usr.sbin/rdate/ntp.c b/usr.sbin/rdate/ntp.c index 31aae2061b9..1d19b0a5cc1 100644 --- a/usr.sbin/rdate/ntp.c +++ b/usr.sbin/rdate/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.14 2003/05/14 18:06:21 itojun Exp $ */ +/* $OpenBSD: ntp.c,v 1.15 2004/02/16 21:25:41 jakob Exp $ */ /* * Copyright (c) 1996, 1997 by N.M. Maclaren. All rights reserved. @@ -101,7 +101,7 @@ struct ntp_data { double current; }; -void ntp_client(const char *, struct timeval *, struct timeval *, int); +void ntp_client(const char *, int, struct timeval *, struct timeval *, int); int sync_ntp(int, const struct sockaddr *, double *, double *); void make_packet(struct ntp_data *); int write_packet(int, const struct sockaddr *, struct ntp_data *); @@ -114,7 +114,7 @@ void create_timeval(double, struct timeval *, struct timeval *); int corrleaps; void -ntp_client(const char *hostname, struct timeval *new, +ntp_client(const char *hostname, int family, struct timeval *new, struct timeval *adjust, int leapflag) { struct addrinfo hints, *res0, *res; @@ -122,7 +122,7 @@ ntp_client(const char *hostname, struct timeval *new, int packets = 0, s, ierror; memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; + hints.ai_family = family; hints.ai_socktype = SOCK_DGRAM; ierror = getaddrinfo(hostname, "ntp", &hints, &res0); if (ierror) { diff --git a/usr.sbin/rdate/rdate.8 b/usr.sbin/rdate/rdate.8 index 2af93654760..194d0d0e4f0 100644 --- a/usr.sbin/rdate/rdate.8 +++ b/usr.sbin/rdate/rdate.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: rdate.8,v 1.24 2003/08/08 10:13:33 jmc Exp $ +.\" $OpenBSD: rdate.8,v 1.25 2004/02/16 21:25:41 jakob Exp $ .\" $NetBSD: rdate.8,v 1.4 1996/04/08 20:55:17 jtc Exp $ .\" .\" Copyright (c) 1994 Christos Zoulas @@ -37,7 +37,7 @@ .Nd set the system's date from a remote host .Sh SYNOPSIS .Nm rdate -.Op Fl ncpsav +.Op Fl 46ncpsav .Ar host .Sh DESCRIPTION .Nm @@ -53,6 +53,14 @@ uses the RFC 868 TCP protocol. .Pp The options are as follows: .Bl -tag -width Ds +.It Fl 4 +Forces +.Nm +to use IPv4 addresses only. +.It Fl 6 +Forces +.Nm +to use IPv6 addresses only. .It Fl n Use SNTP (RFC 1361) instead of the RFC 868 time protocol. .It Fl c diff --git a/usr.sbin/rdate/rdate.c b/usr.sbin/rdate/rdate.c index 6c65fdc6149..6a13d1ca379 100644 --- a/usr.sbin/rdate/rdate.c +++ b/usr.sbin/rdate/rdate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rdate.c,v 1.20 2003/06/26 19:47:10 deraadt Exp $ */ +/* $OpenBSD: rdate.c,v 1.21 2004/02/16 21:25:41 jakob Exp $ */ /* $NetBSD: rdate.c,v 1.4 1996/03/16 12:37:45 pk Exp $ */ /* @@ -42,11 +42,12 @@ #if 0 from: static char rcsid[] = "$NetBSD: rdate.c,v 1.3 1996/02/22 06:59:18 thorpej Exp $"; #else -static const char rcsid[] = "$OpenBSD: rdate.c,v 1.20 2003/06/26 19:47:10 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: rdate.c,v 1.21 2004/02/16 21:25:41 jakob Exp $"; #endif #endif /* lint */ #include <sys/param.h> +#include <sys/socket.h> #include <sys/time.h> #include <stdio.h> @@ -63,8 +64,8 @@ static const char rcsid[] = "$OpenBSD: rdate.c,v 1.20 2003/06/26 19:47:10 deraad #define logwtmp(a,b,c) #endif -void rfc868time_client (const char *, struct timeval *, struct timeval *, int); -void ntp_client (const char *, struct timeval *, struct timeval *, int); +void rfc868time_client (const char *, int, struct timeval *, struct timeval *, int); +void ntp_client (const char *, int, struct timeval *, struct timeval *, int); extern char *__progname; @@ -78,6 +79,8 @@ usage(void) (void) fprintf(stderr, " -s: just set, don't print\n"); (void) fprintf(stderr, " -a: use adjtime instead of instant change\n"); (void) fprintf(stderr, " -v: verbose output\n"); + (void) fprintf(stderr, " -4: use IPv4 only\n"); + (void) fprintf(stderr, " -6: use IPv6 only\n"); } int @@ -88,11 +91,20 @@ main(int argc, char **argv) char *hname; extern int optind; int c; + int family = PF_UNSPEC; struct timeval new, adjust; - while ((c = getopt(argc, argv, "psancv")) != -1) + while ((c = getopt(argc, argv, "46psancv")) != -1) switch (c) { + case '4': + family = PF_INET; + break; + + case '6': + family = PF_INET6; + break; + case 'p': pr++; break; @@ -129,9 +141,9 @@ main(int argc, char **argv) hname = argv[optind]; if (ntp) - ntp_client(hname, &new, &adjust, corrleaps); + ntp_client(hname, family, &new, &adjust, corrleaps); else - rfc868time_client(hname, &new, &adjust, corrleaps); + rfc868time_client(hname, family, &new, &adjust, corrleaps); if (!pr) { if (!slidetime) { diff --git a/usr.sbin/rdate/rfc868time.c b/usr.sbin/rdate/rfc868time.c index 9edd1b364aa..f87a65f855d 100644 --- a/usr.sbin/rdate/rfc868time.c +++ b/usr.sbin/rdate/rfc868time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rfc868time.c,v 1.5 2002/09/08 12:33:42 jakob Exp $ */ +/* $OpenBSD: rfc868time.c,v 1.6 2004/02/16 21:25:41 jakob Exp $ */ /* $NetBSD: rdate.c,v 1.4 1996/03/16 12:37:45 pk Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 from: static char rcsid[] = "$NetBSD: rdate.c,v 1.3 1996/02/22 06:59:18 thorpej Exp $"; #else -static const char rcsid[] = "$OpenBSD: rfc868time.c,v 1.5 2002/09/08 12:33:42 jakob Exp $"; +static const char rcsid[] = "$OpenBSD: rfc868time.c,v 1.6 2004/02/16 21:25:41 jakob Exp $"; #endif #endif /* lint */ @@ -68,7 +68,7 @@ static const char rcsid[] = "$OpenBSD: rfc868time.c,v 1.5 2002/09/08 12:33:42 ja void -rfc868time_client (const char *hostname, struct timeval *new, +rfc868time_client (const char *hostname, int family, struct timeval *new, struct timeval *adjust, int leapflag) { struct addrinfo hints, *res0, *res; @@ -79,7 +79,7 @@ rfc868time_client (const char *hostname, struct timeval *new, u_int64_t td; memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; + hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; /* XXX what about rfc868 UDP * probably not due to the Y2038 issue -mirabile */ |