From aa8dd5d2add8f620b86ea8e05a6cc01bee5bc32d Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 12 Mar 2005 05:10:24 +0000 Subject: Accept special formatting arguments in the Header line. --- common/spio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'common/spio.c') 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; -- cgit v1.2.3