FreeBSD/sys/netinet/in.c
/*
 * Return 1 if an internet address is for the local host and configured
 * on one of its interfaces.
 */
Return 1 if an internet address is for the local host and configured
on one of its interfaces.
Return 1 if an internet address is for the local host and configured on one of its interfaces .
int
in_localip(struct in_addr in)
{
	struct rm_priotracker in_ifa_tracker;
	struct in_ifaddr *ia;
	IN_IFADDR_RLOCK(&in_ifa_tracker);
	LIST_FOREACH(ia, INADDR_HASH(in.s_addr), ia_hash) {
		if (IA_SIN(ia)->sin_addr.s_addr == in.s_addr) {
			IN_IFADDR_RUNLOCK(&in_ifa_tracker);
			return (1);
		}
	}
	IN_IFADDR_RUNLOCK(&in_ifa_tracker);
	return (0);
}
int in_localip ( struct in_addr in ) { struct rm_priotracker in_ifa_tracker ; struct in_ifaddr * ia ; IN_IFADDR_RLOCK ( & in_ifa_tracker ) ; LIST_FOREACH ( ia , INADDR_HASH ( in . s_addr ) , ia_hash ) { if ( IA_SIN ( ia ) -> sin_addr . s_addr == in . s_addr ) { IN_IFADDR_RUNLOCK ( & in_ifa_tracker ) ; return ( 1 ) ; } } IN_IFADDR_RUNLOCK ( & in_ifa_tracker ) ; return ( 0 ) ; }
Return 1 if an internet address is for the local host and configured
 on one of its interfaces.
Return 1 if an internet address is for the local host and configured on one of its interfaces .