let is_internal_IP() know whether you're asking about an IP

address for connecting or an IP address for binding, because
in the latter, 0.0.0.0 is a special case.


svn:r5543
This commit is contained in:
Roger Dingledine 2005-12-09 02:45:33 +00:00
parent d57029ffe8
commit c0a6e2232c

View File

@ -1304,8 +1304,10 @@ tor_listdir(const char *dirname)
* or reserved for local networks by RFC 1918.
*/
int
is_internal_IP(uint32_t ip)
is_internal_IP(uint32_t ip, int for_listening)
{
if (for_listening && !ip) /* special case for binding to 0.0.0.0 */
return 0;
if (((ip & 0xff000000) == 0x0a000000) || /* 10/8 */
((ip & 0xff000000) == 0x00000000) || /* 0/8 */
((ip & 0xff000000) == 0x7f000000) || /* 127/8 */
@ -1324,7 +1326,7 @@ is_internal_IP(uint32_t ip)
int
is_local_IP(uint32_t ip)
{
return is_internal_IP(ip);
return is_internal_IP(ip, 0);
}
/** Parse a string of the form "host[:port]" from <b>addrport</b>. If