Browse Source

add is_local_IP() function to help distinguish which bandwidth "matters"

svn:r2040
Roger Dingledine 21 years ago
parent
commit
7e344f191a
2 changed files with 9 additions and 0 deletions
  1. 8 0
      src/common/util.c
  2. 1 0
      src/common/util.h

+ 8 - 0
src/common/util.c

@@ -1468,6 +1468,14 @@ int is_internal_IP(uint32_t ip) {
   return 0;
   return 0;
 }
 }
 
 
+/** Return true iff <b>ip</b> (in host order) is judged to be on the
+ * same network as us. For now, check if it's an internal IP. For XXX008,
+ * also check if it's on the same class C network as our public IP.
+ */
+int is_local_IP(uint32_t ip) {
+  return is_internal_IP(ip);
+}
+
 /* Hold the result of our call to <b>uname</b>. */
 /* Hold the result of our call to <b>uname</b>. */
 static char uname_result[256];
 static char uname_result[256];
 /* True iff uname_result is set. */
 /* True iff uname_result is set. */

+ 1 - 0
src/common/util.h

@@ -232,6 +232,7 @@ void tor_mutex_free(tor_mutex_t *m);
 int tor_socketpair(int family, int type, int protocol, int fd[2]);
 int tor_socketpair(int family, int type, int protocol, int fd[2]);
 
 
 int is_internal_IP(uint32_t ip);
 int is_internal_IP(uint32_t ip);
+int is_local_IP(uint32_t ip);
 
 
 const char *get_uname(void);
 const char *get_uname(void);