CVS commit: src/usr.bin/getaddrinfo
Module Name:src Committed By: christos Date: Tue Apr 29 01:21:02 UTC 2014 Modified Files: src/usr.bin/getaddrinfo: Makefile Log Message: need bsd.own.mk To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/getaddrinfo/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/getaddrinfo/Makefile diff -u src/usr.bin/getaddrinfo/Makefile:1.1 src/usr.bin/getaddrinfo/Makefile:1.2 --- src/usr.bin/getaddrinfo/Makefile:1.1 Mon Sep 30 02:19:22 2013 +++ src/usr.bin/getaddrinfo/Makefile Mon Apr 28 21:21:02 2014 @@ -1,4 +1,6 @@ -# $NetBSD: Makefile,v 1.1 2013/09/30 06:19:22 riastradh Exp $ +# $NetBSD: Makefile,v 1.2 2014/04/29 01:21:02 christos Exp $ + +.include PROG= getaddrinfo
CVS commit: src/usr.bin/getaddrinfo
Module Name:src Committed By: wiz Date: Tue Apr 22 06:02:06 UTC 2014 Modified Files: src/usr.bin/getaddrinfo: getaddrinfo.1 Log Message: Bump date for previous. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/getaddrinfo/getaddrinfo.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/getaddrinfo/getaddrinfo.1 diff -u src/usr.bin/getaddrinfo/getaddrinfo.1:1.4 src/usr.bin/getaddrinfo/getaddrinfo.1:1.5 --- src/usr.bin/getaddrinfo/getaddrinfo.1:1.4 Tue Apr 22 02:23:03 2014 +++ src/usr.bin/getaddrinfo/getaddrinfo.1 Tue Apr 22 06:02:06 2014 @@ -1,4 +1,4 @@ -.\" $NetBSD: getaddrinfo.1,v 1.4 2014/04/22 02:23:03 ginsbach Exp $ +.\" $NetBSD: getaddrinfo.1,v 1.5 2014/04/22 06:02:06 wiz Exp $ .\" .\" Copyright (c) 2013 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd March 19, 2014 +.Dd April 22, 2014 .Dt GETADDRINFO 1 .Os .Sh NAME
CVS commit: src/usr.bin/getaddrinfo
Module Name:src Committed By: ginsbach Date: Tue Apr 22 02:23:03 UTC 2014 Modified Files: src/usr.bin/getaddrinfo: getaddrinfo.1 getaddrinfo.c Log Message: Add optional method for specifying protocol as part of the service option. This is similar to how the port number and protocol name are specified in services(5). To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/getaddrinfo/getaddrinfo.1 \ src/usr.bin/getaddrinfo/getaddrinfo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/getaddrinfo/getaddrinfo.1 diff -u src/usr.bin/getaddrinfo/getaddrinfo.1:1.3 src/usr.bin/getaddrinfo/getaddrinfo.1:1.4 --- src/usr.bin/getaddrinfo/getaddrinfo.1:1.3 Wed Mar 19 18:21:39 2014 +++ src/usr.bin/getaddrinfo/getaddrinfo.1 Tue Apr 22 02:23:03 2014 @@ -1,4 +1,4 @@ -.\" $NetBSD: getaddrinfo.1,v 1.3 2014/03/19 18:21:39 riastradh Exp $ +.\" $NetBSD: getaddrinfo.1,v 1.4 2014/04/22 02:23:03 ginsbach Exp $ .\" .\" Copyright (c) 2013 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -38,7 +38,7 @@ .Op Fl cNnP .Op Fl f Ar family .Op Fl p Ar protocol -.Op Fl s Ar service +.Op Fl s Ar service Ns Op Ns / Ns Ar protocol .Op Fl t Ar socktype .Op Ar hostname .Sh DESCRIPTION @@ -119,8 +119,11 @@ or Specify a protocol. Protocols may be numeric, or symbolic as listed in .Xr protocols 5 . -.It Fl s Ar service +.It Fl s Ar service Ns Op Ns / Ns Ar protocol Specify a service to look up. +Services may be symbolic or numeric with an optional +protocol suffix as listed in +.Xr services 5 . If no service is specified, a hostname must be specified. .It Fl t Ar socktype Specify a socket type. Index: src/usr.bin/getaddrinfo/getaddrinfo.c diff -u src/usr.bin/getaddrinfo/getaddrinfo.c:1.3 src/usr.bin/getaddrinfo/getaddrinfo.c:1.4 --- src/usr.bin/getaddrinfo/getaddrinfo.c:1.3 Wed Mar 19 01:24:32 2014 +++ src/usr.bin/getaddrinfo/getaddrinfo.c Tue Apr 22 02:23:03 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: getaddrinfo.c,v 1.3 2014/03/19 01:24:32 ginsbach Exp $ */ +/* $NetBSD: getaddrinfo.c,v 1.4 2014/04/22 02:23:03 ginsbach Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: getaddrinfo.c,v 1.3 2014/03/19 01:24:32 ginsbach Exp $"); +__RCSID("$NetBSD: getaddrinfo.c,v 1.4 2014/04/22 02:23:03 ginsbach Exp $"); #include #include @@ -132,6 +132,24 @@ main(int argc, char **argv) if (argc == 1) hostname = argv[0]; + if (service != NULL) { + char *p; + + if ((p = strchr(service, '/')) != NULL) { + if (hints.ai_protocol != 0) { +warnx("protocol already specified"); +usage(); + } + *p = '\0'; + p++; + + if (!parse_protocol(p, &hints.ai_protocol)) { +warnx("invalid protocol: %s", p); +usage(); + } + } + } + error = getaddrinfo(hostname, service, &hints, &addrinfo); if (error) errx(1, "%s", gai_strerror(error));
CVS commit: src/usr.bin/getaddrinfo
Module Name:src Committed By: riastradh Date: Wed Mar 19 18:21:39 UTC 2014 Modified Files: src/usr.bin/getaddrinfo: getaddrinfo.1 Log Message: Clarify some wording in getaddrinfo.1. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/getaddrinfo/getaddrinfo.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/getaddrinfo/getaddrinfo.1 diff -u src/usr.bin/getaddrinfo/getaddrinfo.1:1.2 src/usr.bin/getaddrinfo/getaddrinfo.1:1.3 --- src/usr.bin/getaddrinfo/getaddrinfo.1:1.2 Mon Sep 30 08:13:59 2013 +++ src/usr.bin/getaddrinfo/getaddrinfo.1 Wed Mar 19 18:21:39 2014 @@ -1,4 +1,4 @@ -.\" $NetBSD: getaddrinfo.1,v 1.2 2013/09/30 08:13:59 wiz Exp $ +.\" $NetBSD: getaddrinfo.1,v 1.3 2014/03/19 18:21:39 riastradh Exp $ .\" .\" Copyright (c) 2013 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd September 30, 2013 +.Dd March 19, 2014 .Dt GETADDRINFO 1 .Os .Sh NAME @@ -50,10 +50,15 @@ the routine and formats them to standard output. .Pp The output is a sequence of lines of space-separated fields: +.Pp .Dl socket-type address-family protocol [af-specific data ...] .Pp -For the internet family, the address-family-specific data are the -internet address and the port number. +For the +.Dq inet +and +.Dq inet6 +address families, the af-specific data are the IP/IPv6 address and port +number. .Pp Although the .Nm @@ -143,7 +148,8 @@ dgram inet udp 149.20.53.67 0 stream inet6 tcp 2001:4f8:3:7:2e0:81ff:fe52:9ab6 0 stream inet tcp 149.20.53.67 0 .Ed -The unspecified service manifested as a port number of zero. +.Pp +The port number here is zero because no service was specified. .Pp Look up .Dq morden.NetBSD.org
CVS commit: src/usr.bin/getaddrinfo
Module Name:src Committed By: ginsbach Date: Wed Mar 19 01:24:32 UTC 2014 Modified Files: src/usr.bin/getaddrinfo: getaddrinfo.c Log Message: Add missing include files. Don't rely on them bein pulled in as a side effect of other includes. Fixes build errors when getaddrinfo(1) is added to the usr.bin tree. - need for address family (AF_*) and socket type (SOCK_*) - need for printf() and friends To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/getaddrinfo/getaddrinfo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/getaddrinfo/getaddrinfo.c diff -u src/usr.bin/getaddrinfo/getaddrinfo.c:1.2 src/usr.bin/getaddrinfo/getaddrinfo.c:1.3 --- src/usr.bin/getaddrinfo/getaddrinfo.c:1.2 Fri Mar 14 13:17:18 2014 +++ src/usr.bin/getaddrinfo/getaddrinfo.c Wed Mar 19 01:24:32 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: getaddrinfo.c,v 1.2 2014/03/14 13:17:18 ginsbach Exp $ */ +/* $NetBSD: getaddrinfo.c,v 1.3 2014/03/19 01:24:32 ginsbach Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -30,7 +30,10 @@ */ #include -__RCSID("$NetBSD: getaddrinfo.c,v 1.2 2014/03/14 13:17:18 ginsbach Exp $"); +__RCSID("$NetBSD: getaddrinfo.c,v 1.3 2014/03/19 01:24:32 ginsbach Exp $"); + +#include +#include #include #include @@ -40,6 +43,7 @@ __RCSID("$NetBSD: getaddrinfo.c,v 1.2 20 #include #include #include +#include #include #include #include
CVS commit: src/usr.bin/getaddrinfo
Module Name:src Committed By: ginsbach Date: Fri Mar 14 13:17:18 UTC 2014 Modified Files: src/usr.bin/getaddrinfo: getaddrinfo.c Log Message: add missing break To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/getaddrinfo/getaddrinfo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/getaddrinfo/getaddrinfo.c diff -u src/usr.bin/getaddrinfo/getaddrinfo.c:1.1 src/usr.bin/getaddrinfo/getaddrinfo.c:1.2 --- src/usr.bin/getaddrinfo/getaddrinfo.c:1.1 Mon Sep 30 06:19:22 2013 +++ src/usr.bin/getaddrinfo/getaddrinfo.c Fri Mar 14 13:17:18 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: getaddrinfo.c,v 1.1 2013/09/30 06:19:22 riastradh Exp $ */ +/* $NetBSD: getaddrinfo.c,v 1.2 2014/03/14 13:17:18 ginsbach Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: getaddrinfo.c,v 1.1 2013/09/30 06:19:22 riastradh Exp $"); +__RCSID("$NetBSD: getaddrinfo.c,v 1.2 2014/03/14 13:17:18 ginsbach Exp $"); #include #include @@ -101,6 +101,7 @@ main(int argc, char **argv) warnx("invalid protocol: %s", optarg); usage(); } + break; case 'P': hints.ai_flags |= AI_PASSIVE;
CVS commit: src/usr.bin/getaddrinfo
Module Name:src Committed By: ginsbach Date: Thu Feb 27 01:17:13 UTC 2014 Modified Files: src/usr.bin/getaddrinfo: tables.awk Log Message: AF_MAX isn't an address family so don't include it in the generated table. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/getaddrinfo/tables.awk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/getaddrinfo/tables.awk diff -u src/usr.bin/getaddrinfo/tables.awk:1.1 src/usr.bin/getaddrinfo/tables.awk:1.2 --- src/usr.bin/getaddrinfo/tables.awk:1.1 Mon Sep 30 06:19:22 2013 +++ src/usr.bin/getaddrinfo/tables.awk Thu Feb 27 01:17:13 2014 @@ -1,6 +1,6 @@ #!/usr/bin/awk -f -# $NetBSD: tables.awk,v 1.1 2013/09/30 06:19:22 riastradh Exp $ +# $NetBSD: tables.awk,v 1.2 2014/02/27 01:17:13 ginsbach Exp $ # Copyright (c) 2013 The NetBSD Foundation, Inc. # All rights reserved. @@ -38,7 +38,7 @@ BEGIN { next } -$2 ~ /^AF_[A-Z0-9_]*$/ { +($2 ~ /^AF_[A-Z0-9_]*$/) && ($2 != "AF_MAX") { afs[n_afs++] = substr($2, 4) }
CVS commit: src/usr.bin/getaddrinfo
Module Name:src Committed By: wiz Date: Mon Sep 30 08:14:00 UTC 2013 Modified Files: src/usr.bin/getaddrinfo: getaddrinfo.1 Log Message: Sort. Use .Ex for EXIT STATUS section. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/getaddrinfo/getaddrinfo.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/getaddrinfo/getaddrinfo.1 diff -u src/usr.bin/getaddrinfo/getaddrinfo.1:1.1 src/usr.bin/getaddrinfo/getaddrinfo.1:1.2 --- src/usr.bin/getaddrinfo/getaddrinfo.1:1.1 Mon Sep 30 06:19:22 2013 +++ src/usr.bin/getaddrinfo/getaddrinfo.1 Mon Sep 30 08:13:59 2013 @@ -1,4 +1,4 @@ -.\" $NetBSD: getaddrinfo.1,v 1.1 2013/09/30 06:19:22 riastradh Exp $ +.\" $NetBSD: getaddrinfo.1,v 1.2 2013/09/30 08:13:59 wiz Exp $ .\" .\" Copyright (c) 2013 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd April 25, 2013 +.Dd September 30, 2013 .Dt GETADDRINFO 1 .Os .Sh NAME @@ -35,11 +35,11 @@ .Nd resolve names to socket addresses .Sh SYNOPSIS .Nm -.Op Fl cnNP +.Op Fl cNnP .Op Fl f Ar family .Op Fl p Ar protocol -.Op Fl t Ar socktype .Op Fl s Ar service +.Op Fl t Ar socktype .Op Ar hostname .Sh DESCRIPTION The @@ -86,25 +86,18 @@ For example, .Dq inet corresponds with .Dv AF_INET . -.It Fl n -Treat the hostname as a numeric address and do not attempt name -resolution, as if with the -.Dv AI_NUMERICHOST -flag to -.Xr getaddrinfo 3 . .It Fl N Treat the service as numeric and do not attempt service name resolution, as if with the .Dv AI_NUMERICSERV flag to .Xr getaddrinfo 3 . -.It Fl s Ar service -Specify a service to look up. -If no service is specified, a hostname must be specified. -.It Fl p Ar protocol -Specify a protocol. -Protocols may be numeric, or symbolic as listed in -.Xr protocols 5 . +.It Fl n +Treat the hostname as a numeric address and do not attempt name +resolution, as if with the +.Dv AI_NUMERICHOST +flag to +.Xr getaddrinfo 3 . .It Fl P Return socket addresses intended for use with .Xr bind 2 , @@ -117,6 +110,13 @@ By default, the socket addresses are int .Xr sendto 2 , or .Xr sendmsg 2 . +.It Fl p Ar protocol +Specify a protocol. +Protocols may be numeric, or symbolic as listed in +.Xr protocols 5 . +.It Fl s Ar service +Specify a service to look up. +If no service is specified, a hostname must be specified. .It Fl t Ar socktype Specify a socket type. Socket types are named like the @@ -131,10 +131,8 @@ For example, corresponds with .Dv SOCK_DGRAM . .El -.Pp -The -.Nm -utility exits 0 on success, and \*[Gt]0 if an error occurs. +.Sh EXIT STATUS +.Ex -std getaddrinfo .Sh EXAMPLES Look up .Dq www.NetBSD.org :
CVS commit: src/usr.bin/getaddrinfo
Module Name:src Committed By: riastradh Date: Mon Sep 30 06:19:22 UTC 2013 Added Files: src/usr.bin/getaddrinfo: Makefile getaddrinfo.1 getaddrinfo.c tables.awk Log Message: New utility getaddrinfo(1) to reflect getaddrinfo(3). Discussed on tech-userlevel back in April: https://mail-index.netbsd.org/tech-userlevel/2013/04/25/msg007719.html Not hooked into the build or sets yet. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/usr.bin/getaddrinfo/Makefile \ src/usr.bin/getaddrinfo/getaddrinfo.1 \ src/usr.bin/getaddrinfo/getaddrinfo.c src/usr.bin/getaddrinfo/tables.awk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/usr.bin/getaddrinfo/Makefile diff -u /dev/null src/usr.bin/getaddrinfo/Makefile:1.1 --- /dev/null Mon Sep 30 06:19:22 2013 +++ src/usr.bin/getaddrinfo/Makefile Mon Sep 30 06:19:22 2013 @@ -0,0 +1,20 @@ +# $NetBSD: Makefile,v 1.1 2013/09/30 06:19:22 riastradh Exp $ + +PROG= getaddrinfo + +DPADD+= ${LIBUTIL} +LDADD+= -lutil + +WARNS= 5 + +SYS_SOCKET_H?= ${NETBSDSRCDIR}/sys/sys/socket.h + +CPPFLAGS+= -I. +DPSRCS+= tables.h +CLEANFILES+= tables.h +tables.h: tables.awk ${SYS_SOCKET_H} + ${_MKTARGET_CREATE} + ${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET}.tmp \ + && mv -f -- ${.TARGET}.tmp ${.TARGET} + +.include Index: src/usr.bin/getaddrinfo/getaddrinfo.1 diff -u /dev/null src/usr.bin/getaddrinfo/getaddrinfo.1:1.1 --- /dev/null Mon Sep 30 06:19:22 2013 +++ src/usr.bin/getaddrinfo/getaddrinfo.1 Mon Sep 30 06:19:22 2013 @@ -0,0 +1,174 @@ +.\" $NetBSD: getaddrinfo.1,v 1.1 2013/09/30 06:19:22 riastradh Exp $ +.\" +.\" Copyright (c) 2013 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This documentation is derived from text contributed to The NetBSD +.\" Foundation by Taylor R. Campbell. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\"notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\"notice, this list of conditions and the following disclaimer in the +.\"documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT 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. +.\" +.Dd April 25, 2013 +.Dt GETADDRINFO 1 +.Os +.Sh NAME +.Nm getaddrinfo +.Nd resolve names to socket addresses +.Sh SYNOPSIS +.Nm +.Op Fl cnNP +.Op Fl f Ar family +.Op Fl p Ar protocol +.Op Fl t Ar socktype +.Op Fl s Ar service +.Op Ar hostname +.Sh DESCRIPTION +The +.Nm +utility resolves host and service names to socket addresses as if with +the +.Xr getaddrinfo 3 +routine and formats them to standard output. +.Pp +The output is a sequence of lines of space-separated fields: +.Dl socket-type address-family protocol [af-specific data ...] +.Pp +For the internet family, the address-family-specific data are the +internet address and the port number. +.Pp +Although the +.Nm +utility may query the DNS to give answers, depending on the +system's +.Xr nsswitch.conf 5 +configuration, it is not intended to be a general-purpose utility to +query the DNS; use the +.Xr dig 1 +utility for that. +.Pp +The following options are available: +.Bl -tag -width Ds +.It Fl c +Look up a canonical name as if with the +.Dv AI_CANONNAME +flag to +.Xr getaddrinfo 3 +and print it on the first line before the socket addresses. +.It Fl f Ar family +Specify an address family. +Address families are named like the +.Dv AF_... +constants for address family numbers in the +.Aq Pa sys/socket.h +header file but without the +.Dv AF_ +prefix and lowercase. +For example, +.Dq inet +corresponds with +.Dv AF_INET . +.It Fl n +Treat the hostname as a numeric address and do not attempt name +resolution, as if with the +.Dv AI_NUMERICHOST +flag to +.Xr getaddrinfo 3 . +.It Fl N +Treat the service as numeric and do not attempt service name +resolution, as if with the +.Dv AI_NUMERICSERV +flag to +.Xr getaddrinfo 3 . +.It Fl s Ar service +Specify a service to look up. +If no servi