summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-01-02 16:12:02 +0100
committerFelix Fietkau <nbd@openwrt.org>2013-01-02 16:12:02 +0100
commit6dfd8f67760b977ec7e345aece872c2a40a3be1e (patch)
tree7c8610278da9f7aabe0dc209b1adf1ba3318677e /utils.c
parent7aec47491eb4b77361d8618cb3860607e2ec80e1 (diff)
add uh_addr_rfc1918()
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index d2ad296..742e280 100644
--- a/utils.c
+++ b/utils.c
@@ -217,3 +217,18 @@ char *uh_split_header(char *str)
return val;
}
+
+bool uh_addr_rfc1918(struct uh_addr *addr)
+{
+ uint32_t a;
+
+ if (addr->family != AF_INET)
+ return false;
+
+ a = htonl(addr->in.s_addr);
+ return ((a >= 0x0A000000) && (a <= 0x0AFFFFFF)) ||
+ ((a >= 0xAC100000) && (a <= 0xAC1FFFFF)) ||
+ ((a >= 0xC0A80000) && (a <= 0xC0A8FFFF));
+
+ return 0;
+}