aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-03-14 18:07:46 +0000
committerRoger Dingledine <arma@torproject.org>2004-03-14 18:07:46 +0000
commitf55ff5b8d20259484020c1d9790bd024ecec896d (patch)
treefa93134cf267a3bcd4f3040de8410a8901392c29 /src/common/util.c
parent74ef3a63ae791f8a688171568486334a73b4e7aa (diff)
downloadtor-f55ff5b8d20259484020c1d9790bd024ecec896d.tar
tor-f55ff5b8d20259484020c1d9790bd024ecec896d.tar.gz
teach us to recognize internal IPs
svn:r1271
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 98930a639..c00406338 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -686,6 +686,18 @@ try_next_line:
return 1;
}
+int is_internal_IP(uint32_t ip) {
+
+ if (((ip & 0xff000000) == 0xa0000000) || /* 10/8 */
+ ((ip & 0xff000000) == 0x00000000) || /* 0/8 */
+ ((ip & 0xff000000) == 0x7f000000) || /* 127/8 */
+ ((ip & 0xffff0000) == 0xa9fe0000) || /* 169.254/16 */
+ ((ip & 0xfff00000) == 0xac100000) || /* 172.16/12 */
+ ((ip & 0xffff0000) == 0xc0a80000)) /* 192.168/16 */
+ return 1;
+ return 0;
+}
+
static char uname_result[256];
static int uname_result_is_set = 0;