Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/getaddrinfo Add optional method for specifying proto...
details: https://anonhg.NetBSD.org/src/rev/74916356c358
branches: trunk
changeset: 328875:74916356c358
user: ginsbach <ginsbach%NetBSD.org@localhost>
date: Tue Apr 22 02:23:03 2014 +0000
description:
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).
diffstat:
usr.bin/getaddrinfo/getaddrinfo.1 | 9 ++++++---
usr.bin/getaddrinfo/getaddrinfo.c | 22 ++++++++++++++++++++--
2 files changed, 26 insertions(+), 5 deletions(-)
diffs (74 lines):
diff -r 22f454d3f6d7 -r 74916356c358 usr.bin/getaddrinfo/getaddrinfo.1
--- a/usr.bin/getaddrinfo/getaddrinfo.1 Mon Apr 21 22:40:00 2014 +0000
+++ b/usr.bin/getaddrinfo/getaddrinfo.1 Tue Apr 22 02:23:03 2014 +0000
@@ -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 @@
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.
diff -r 22f454d3f6d7 -r 74916356c358 usr.bin/getaddrinfo/getaddrinfo.c
--- a/usr.bin/getaddrinfo/getaddrinfo.c Mon Apr 21 22:40:00 2014 +0000
+++ b/usr.bin/getaddrinfo/getaddrinfo.c Tue Apr 22 02:23:03 2014 +0000
@@ -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 <sys/cdefs.h>
-__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 <sys/types.h>
#include <sys/socket.h>
@@ -132,6 +132,24 @@
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));
Home |
Main Index |
Thread Index |
Old Index