summaryrefslogtreecommitdiffstats
path: root/addr.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-09-14 13:06:29 +0300
committerTimo Teräs <timo.teras@iki.fi>2010-09-14 13:22:08 +0300
commit4be1e8fd5e352a54e87a81979d5ad303efdcbffe (patch)
tree1a1271bea793e3914e1e2b6846db251186313ddb /addr.c
parent36a24c1ffd961b263e392d8167fa4799865c08f6 (diff)
downloadsquark-4be1e8fd5e352a54e87a81979d5ad303efdcbffe.tar.bz2
squark-4be1e8fd5e352a54e87a81979d5ad303efdcbffe.tar.xz
auth-ip: print information in shell compatible format
so we can dump information from http cgi-bin scripts.
Diffstat (limited to 'addr.c')
-rw-r--r--addr.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/addr.c b/addr.c
index 1dddaff..47013f2 100644
--- a/addr.c
+++ b/addr.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include <string.h>
#include "addr.h"
@@ -51,3 +52,23 @@ blob_t addr_get_hostaddr_blob(const sockaddr_any *addr)
return BLOB_NULL;
}
}
+
+void addr_push_hostaddr(blob_t *b, const sockaddr_any *addr)
+{
+ char buf[64];
+ blob_t f;
+ unsigned int t;
+
+ switch (addr->any.sa_family) {
+ case AF_INET:
+ t = ntohl(addr->ipv4.sin_addr.s_addr);
+ f.ptr = buf;
+ f.len = sprintf(buf, "%d.%d.%d.%d",
+ (t ) & 0xff, (t >> 8) & 0xff,
+ (t >> 16) & 0xff, (t >> 24) & 0xff);
+ break;
+ default:
+ return;
+ }
+ blob_push(b, f);
+}