summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pppctl/pppctl.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-07-28 22:17:48 +0000
committerbrian <brian@FreeBSD.org>1997-07-28 22:17:48 +0000
commit62296c6450c3104df51d51aa47ad4b74faae7e6b (patch)
treeb4e84c5756f7f9045aaa6877d58dfe023c5405ab /usr.sbin/pppctl/pppctl.c
parentcea42fceea7b0e876dc4e273e20a3c8b63dcb553 (diff)
downloadFreeBSD-src-62296c6450c3104df51d51aa47ad4b74faae7e6b.zip
FreeBSD-src-62296c6450c3104df51d51aa47ad4b74faae7e6b.tar.gz
Allow hosts specified by IP number (avoiding
a DNS lookup) Update doc including the [host:]port syntax.
Diffstat (limited to 'usr.sbin/pppctl/pppctl.c')
-rw-r--r--usr.sbin/pppctl/pppctl.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.sbin/pppctl/pppctl.c b/usr.sbin/pppctl/pppctl.c
index 323c3dd..ca0748a 100644
--- a/usr.sbin/pppctl/pppctl.c
+++ b/usr.sbin/pppctl/pppctl.c
@@ -1,6 +1,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <sys/un.h>
#include <netdb.h>
#include <signal.h>
@@ -170,6 +171,7 @@ main(int argc, char **argv)
}
} else {
char *port, *host, *colon;
+ int hlen;
colon = strchr(argv[arg], ':');
if (colon) {
@@ -178,15 +180,24 @@ main(int argc, char **argv)
host = argv[arg];
} else {
port = argv[arg];
- host = "localhost";
+ host = "127.0.0.1";
}
sock = (struct sockaddr *)&ifsin;
socksz = sizeof ifsin;
+ hlen = strlen(host);
- if ((h = gethostbyname(host)) == 0) {
+ if (strspn(host, "0123456789.") == hlen) {
+ if (!inet_aton(host, (struct in_addr *)&ifsin.sin_addr.s_addr)) {
+ fprintf(stderr, "Cannot translate %s\n", host);
+ return 1;
+ }
+ } else if ((h = gethostbyname(host)) == 0) {
fprintf(stderr, "Cannot resolve %s\n", host);
return 1;
}
+ else
+ ifsin.sin_addr.s_addr = *(u_long *)h->h_addr_list[0];
+
if (colon)
*colon = ':';
@@ -201,7 +212,6 @@ main(int argc, char **argv)
ifsin.sin_len = sizeof(ifsin);
ifsin.sin_family = AF_INET;
- ifsin.sin_addr.s_addr = *(u_long *)h->h_addr_list[0];
if (fd = socket(AF_INET, SOCK_STREAM, 0), fd < 0) {
fprintf(stderr, "Cannot create internet socket\n");
OpenPOWER on IntegriCloud