summaryrefslogtreecommitdiff
path: root/common/spio.c
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2005-03-12 05:10:24 +0000
committerStef Walter <stef@memberwebs.com>2005-03-12 05:10:24 +0000
commit795bf2eb48104bade902d11b88a956d4d2ebae9f (patch)
tree8d3b4bbfe1478e57995539eb821657d46704cec8 /common/spio.c
parent289f38b3bd5f6b38cac46a1c65d05d4a7c14971e (diff)
Accept special formatting arguments in the Header line.
Diffstat (limited to 'common/spio.c')
-rw-r--r--common/spio.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/spio.c b/common/spio.c
index 67e0405..a723936 100644
--- a/common/spio.c
+++ b/common/spio.c
@@ -113,6 +113,7 @@ void spio_init(spio_t* io, const char* name)
void spio_attach(spctx_t* ctx, spio_t* io, int fd, struct sockaddr_any* peer)
{
struct sockaddr_any peeraddr;
+ struct sockaddr_any locaddr;
io->fd = fd;
@@ -130,6 +131,17 @@ void spio_attach(spctx_t* ctx, spio_t* io, int fd, struct sockaddr_any* peer)
strlcpy(io->peername, "UNKNOWN", MAXPATHLEN);
}
+ /* Get the address on which we accepted the connection */
+ memset(&locaddr, 0, sizeof(locaddr));
+ SANY_LEN(locaddr) = sizeof(locaddr);
+
+ if(getsockname(fd, &SANY_ADDR(locaddr), &SANY_LEN(locaddr)) == -1 ||
+ sock_any_ntop(&locaddr, io->localname, MAXPATHLEN, SANY_OPT_NOPORT) == -1)
+ {
+ sp_message(ctx, LOG_WARNING, "%s: couldn't get socket address", GET_IO_NAME(io));
+ strlcpy(io->localname, "UNKNOWN", MAXPATHLEN);
+ }
+
/* As a double check */
io->line[0] = 0;
io->_nx = NULL;