summaryrefslogtreecommitdiffstats
path: root/blob.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-08-19 13:40:31 +0300
committerTimo Teräs <timo.teras@iki.fi>2010-08-19 13:40:31 +0300
commit2c4ddb6620101ebad2bff0c007a99aea97a15de1 (patch)
tree7c91a5a2eb874edddc26fdc468d5706789c2f831 /blob.c
parent2e58fc0a7a69ecbe4a48b296bcf6313825fcfa7c (diff)
downloadsquark-2c4ddb6620101ebad2bff0c007a99aea97a15de1.tar.bz2
squark-2c4ddb6620101ebad2bff0c007a99aea97a15de1.tar.xz
filter: properly filter ipv4 address form urls
properly match them against db data.
Diffstat (limited to 'blob.c')
-rw-r--r--blob.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/blob.c b/blob.c
index 81722d2..f6daef1 100644
--- a/blob.c
+++ b/blob.c
@@ -52,6 +52,24 @@ int blob_cmp(blob_t a, blob_t b)
return memcmp(a.ptr, b.ptr, a.len);
}
+unsigned long blob_inet_addr(blob_t b)
+{
+ unsigned long ip = 0;
+ int i;
+
+ for (i = 0; i < 3; i++) {
+ ip += blob_pull_uint(&b, 10);
+ ip <<= 8;
+ if (!blob_pull_matching(&b, BLOB_STR(".")))
+ return 0;
+ }
+ ip += blob_pull_uint(&b, 10);
+ if (b.len != 0)
+ return 0;
+ return ip;
+}
+
+
blob_t blob_pushed(blob_t buffer, blob_t left)
{
if (buffer.ptr + buffer.len != left.ptr + left.len)