diff options
-rw-r--r-- | usr.sbin/pppctl/pppctl.8 | 15 | ||||
-rw-r--r-- | usr.sbin/pppctl/pppctl.c | 16 |
2 files changed, 22 insertions, 9 deletions
diff --git a/usr.sbin/pppctl/pppctl.8 b/usr.sbin/pppctl/pppctl.8 index 8a3afe7..211d0e6 100644 --- a/usr.sbin/pppctl/pppctl.8 +++ b/usr.sbin/pppctl/pppctl.8 @@ -1,4 +1,4 @@ -.\" $Id:$ +.\" $Id: pppctl.8,v 1.1 1997/06/28 01:04:52 brian Exp $ .Dd 26 June 1997 .Os FreeBSD .Dt PPPCTL 8 @@ -11,7 +11,7 @@ PPP control program .Op Fl v .Op Fl t Ar n .Op Fl p Ar passwd -.Ar Port | LocalSocket +.Ar [host:]Port | LocalSocket .Ar command .Op Ar ;command .Ar ... @@ -26,11 +26,14 @@ expects at least two arguments. The first is interpreted as the socket on which the .Nm ppp daemon is listening. If the socket contains a leading '/', it -is taken as an AF_LOCAL socket. If it consists entirely of numbers, -it is interpreted as a TCP port number on localhost. If it contains -any characters, the first of which is not a '/' character, it is -interpreted as an entry of type "tcp" from +is taken as an AF_LOCAL socket. If it contains a colon, it is +treated as a host:port pair, otherwise it is treated as just a +port specification on the local machine (127.0.0.1). Both the +host and port may be specified numerically if you wish to avoid +a DNS lookup or don't have an entry for the given port in .Pa /etc/services . + +.Pp All remaining arguments are concatenated to form the command(s) that will be sent to the .Nm ppp 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"); |