Allow hosts specified by IP number (avoiding
a DNS lookup) Update doc including the [host:]port syntax.
This commit is contained in:
parent
e663ea9c1d
commit
437b5af636
@ -1,4 +1,4 @@
|
|||||||
.\" $Id:$
|
.\" $Id: pppctl.8,v 1.1 1997/06/28 01:04:52 brian Exp $
|
||||||
.Dd 26 June 1997
|
.Dd 26 June 1997
|
||||||
.Os FreeBSD
|
.Os FreeBSD
|
||||||
.Dt PPPCTL 8
|
.Dt PPPCTL 8
|
||||||
@ -11,7 +11,7 @@ PPP control program
|
|||||||
.Op Fl v
|
.Op Fl v
|
||||||
.Op Fl t Ar n
|
.Op Fl t Ar n
|
||||||
.Op Fl p Ar passwd
|
.Op Fl p Ar passwd
|
||||||
.Ar Port | LocalSocket
|
.Ar [host:]Port | LocalSocket
|
||||||
.Ar command
|
.Ar command
|
||||||
.Op Ar ;command
|
.Op Ar ;command
|
||||||
.Ar ...
|
.Ar ...
|
||||||
@ -26,11 +26,14 @@ expects at least two arguments. The first is interpreted as the
|
|||||||
socket on which the
|
socket on which the
|
||||||
.Nm ppp
|
.Nm ppp
|
||||||
daemon is listening. If the socket contains a leading '/', it
|
daemon is listening. If the socket contains a leading '/', it
|
||||||
is taken as an AF_LOCAL socket. If it consists entirely of numbers,
|
is taken as an AF_LOCAL socket. If it contains a colon, it is
|
||||||
it is interpreted as a TCP port number on localhost. If it contains
|
treated as a host:port pair, otherwise it is treated as just a
|
||||||
any characters, the first of which is not a '/' character, it is
|
port specification on the local machine (127.0.0.1). Both the
|
||||||
interpreted as an entry of type "tcp" from
|
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 .
|
.Pa /etc/services .
|
||||||
|
|
||||||
|
.Pp
|
||||||
All remaining arguments are concatenated to form the command(s) that
|
All remaining arguments are concatenated to form the command(s) that
|
||||||
will be sent to the
|
will be sent to the
|
||||||
.Nm ppp
|
.Nm ppp
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@ -170,6 +171,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char *port, *host, *colon;
|
char *port, *host, *colon;
|
||||||
|
int hlen;
|
||||||
|
|
||||||
colon = strchr(argv[arg], ':');
|
colon = strchr(argv[arg], ':');
|
||||||
if (colon) {
|
if (colon) {
|
||||||
@ -178,15 +180,24 @@ main(int argc, char **argv)
|
|||||||
host = argv[arg];
|
host = argv[arg];
|
||||||
} else {
|
} else {
|
||||||
port = argv[arg];
|
port = argv[arg];
|
||||||
host = "localhost";
|
host = "127.0.0.1";
|
||||||
}
|
}
|
||||||
sock = (struct sockaddr *)&ifsin;
|
sock = (struct sockaddr *)&ifsin;
|
||||||
socksz = sizeof 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);
|
fprintf(stderr, "Cannot resolve %s\n", host);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
ifsin.sin_addr.s_addr = *(u_long *)h->h_addr_list[0];
|
||||||
|
|
||||||
if (colon)
|
if (colon)
|
||||||
*colon = ':';
|
*colon = ':';
|
||||||
|
|
||||||
@ -201,7 +212,6 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
ifsin.sin_len = sizeof(ifsin);
|
ifsin.sin_len = sizeof(ifsin);
|
||||||
ifsin.sin_family = AF_INET;
|
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) {
|
if (fd = socket(AF_INET, SOCK_STREAM, 0), fd < 0) {
|
||||||
fprintf(stderr, "Cannot create internet socket\n");
|
fprintf(stderr, "Cannot create internet socket\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user