[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] teach us to recognize internal IPs



Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common

Modified Files:
	util.c util.h 
Log Message:
teach us to recognize internal IPs


Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- util.c	12 Mar 2004 13:02:16 -0000	1.59
+++ util.c	14 Mar 2004 18:07:46 -0000	1.60
@@ -686,6 +686,18 @@
   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;
 

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- util.h	11 Mar 2004 06:35:03 -0000	1.34
+++ util.h	14 Mar 2004 18:07:46 -0000	1.35
@@ -84,6 +84,8 @@
 
 int tor_socketpair(int family, int type, int protocol, int fd[2]);
 
+int is_internal_IP(uint32_t ip);
+
 const char *get_uname(void);
 
 /* Start putting the process into daemon mode: fork and drop all resources