version 1.107, 2012/04/01 02:58:57 |
version 1.108, 2012/07/07 09:36:30 |
|
|
int unix_listen(char *); |
int unix_listen(char *); |
void set_common_sockopts(int); |
void set_common_sockopts(int); |
int map_tos(char *, int *); |
int map_tos(char *, int *); |
|
void report_connect(const struct sockaddr *, socklen_t); |
void usage(int); |
void usage(int); |
|
|
int |
int |
|
|
if (rv < 0) |
if (rv < 0) |
err(1, "connect"); |
err(1, "connect"); |
|
|
|
if (vflag) |
|
report_connect((struct sockaddr *)&z, len); |
|
|
readwrite(s); |
readwrite(s); |
} else { |
} else { |
len = sizeof(cliaddr); |
len = sizeof(cliaddr); |
|
|
&len); |
&len); |
if (connfd == -1) |
if (connfd == -1) |
err(1, "accept"); |
err(1, "accept"); |
|
|
|
if (vflag) |
|
report_connect((struct sockaddr *)&cliaddr, len); |
|
|
readwrite(connfd); |
readwrite(connfd); |
close(connfd); |
close(connfd); |
} |
} |
|
|
} |
} |
|
|
return (0); |
return (0); |
|
} |
|
|
|
void |
|
report_connect(const struct sockaddr *sa, socklen_t salen) |
|
{ |
|
char remote_host[NI_MAXHOST]; |
|
char remote_port[NI_MAXSERV]; |
|
int herr; |
|
int flags = NI_NUMERICSERV; |
|
|
|
if (nflag) |
|
flags |= NI_NUMERICHOST; |
|
|
|
if ((herr = getnameinfo(sa, salen, |
|
remote_host, sizeof(remote_host), |
|
remote_port, sizeof(remote_port), |
|
flags)) != 0) { |
|
if (herr == EAI_SYSTEM) |
|
err(1, "getnameinfo"); |
|
else |
|
errx(1, "getnameinfo: %s", gai_strerror(herr)); |
|
} |
|
|
|
fprintf(stderr, |
|
"Connection from %s %s " |
|
"received!\n", remote_host, remote_port); |
} |
} |
|
|
void |
void |