Commit f92f7719 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add TCP_hisname() function



git-svn-id: http://www.varnish-cache.org/svn/trunk@4449 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 6a5ae277
......@@ -61,6 +61,7 @@ int SUB_run(struct vsb *sb, sub_func_f *func, void *priv, const char *name,
#define TCP_PORTBUFSIZE 16
void TCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen);
void TCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen);
int TCP_filter_http(int sock);
void TCP_blocking(int sock);
void TCP_nonblocking(int sock);
......
......@@ -98,6 +98,23 @@ TCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen)
AZ(getsockname(sock, addr, &l));
TCP_name(addr, l, abuf, alen, pbuf, plen);
}
/*--------------------------------------------------------------------*/
void
TCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen)
{
struct sockaddr_storage addr_s;
struct sockaddr *addr = (void*)&addr_s;
socklen_t l;
l = sizeof addr_s;
if (!getpeername(sock, addr, &l))
TCP_name(addr, l, abuf, alen, pbuf, plen);
else {
strlcpy(abuf, "<none>", alen);
strlcpy(pbuf, "<none>", plen);
}
}
/*--------------------------------------------------------------------*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment