Return to misc.c CVS log | Up to [local] / src / usr.bin / ssh |
version 1.132, 2018/10/03 06:38:35 | version 1.133, 2018/10/05 14:26:09 | ||
---|---|---|---|
|
|
||
#include <netinet/in.h> | #include <netinet/in.h> | ||
#include <netinet/ip.h> | #include <netinet/ip.h> | ||
#include <netinet/tcp.h> | #include <netinet/tcp.h> | ||
#include <arpa/inet.h> | |||
#include <ctype.h> | #include <ctype.h> | ||
#include <errno.h> | #include <errno.h> | ||
|
|
||
int | int | ||
a2port(const char *s) | a2port(const char *s) | ||
{ | { | ||
struct servent *se; | |||
long long port; | long long port; | ||
const char *errstr; | const char *errstr; | ||
port = strtonum(s, 0, 65535, &errstr); | port = strtonum(s, 0, 65535, &errstr); | ||
if (errstr != NULL) | if (errstr == NULL) | ||
return -1; | return (int)port; | ||
return (int)port; | if ((se = getservbyname(s, "tcp")) != NULL) | ||
return ntohs(se->s_port); | |||
return -1; | |||
} | } | ||
int | int |