diff options
author | brian <brian@FreeBSD.org> | 1997-07-12 19:22:34 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-07-12 19:22:34 +0000 |
commit | aa8643ed6cef49dd34a96a1fe0d74f4d82400a70 (patch) | |
tree | 06a62bd2e31fd4cd3bf5caf401742183586dda5b /usr.sbin | |
parent | a6c3d5ca854ee3a57e3d5dd08770f6eb8b762b87 (diff) | |
download | FreeBSD-src-aa8643ed6cef49dd34a96a1fe0d74f4d82400a70.zip FreeBSD-src-aa8643ed6cef49dd34a96a1fe0d74f4d82400a70.tar.gz |
Allow service names in "set server"
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/command.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 1fbe8b3..2158947 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.64 1997/06/28 01:34:02 brian Exp $ + * $Id: command.c,v 1.65 1997/06/30 03:03:29 brian Exp $ * */ #include <sys/types.h> @@ -862,8 +862,20 @@ char **argv; mask = m; } res = ServerLocalOpen(argv[0], mask); - } else if (strspn(argv[0], "0123456789") == strlen(argv[0])) - res = ServerTcpOpen(atoi(argv[0])); + } else { + int port; + if (strspn(argv[0], "0123456789") != strlen(argv[0])) { + struct servent *s; + if ((s = getservbyname(argv[0], "tcp")) == NULL) { + port = 0; + LogPrintf(LogWARN, "%s: Invalid port or service\n", argv[0]); + } else + port = ntohs(s->s_port); + } else + port = atoi(argv[0]); + if (port) + res = ServerTcpOpen(port); + } return res; } |