FreeBSD/contrib/ofed/libsdp/src/match.c
/* return 0 if the addresses match */
return 0 if the addresses match
return 0 if the addresses match
static inline int
match_addr(
	struct use_family_rule *rule,
	const struct sockaddr *addr_in )
{
	const struct sockaddr_in *sin = ( const struct sockaddr_in * )addr_in;
	const struct sockaddr_in6 *sin6 = ( const struct sockaddr_in6 * )addr_in;
	const struct sockaddr_in *rule_sin = ( const struct sockaddr_in * )(&rule->ip);
	const struct sockaddr_in6 *rule_sin6 = ( const struct sockaddr_in6 * )(&rule->ip);
	if (rule_sin->sin_family == AF_INET && !rule_sin->sin_addr.s_addr)
		return 0;
	if (addr_in->sa_family != rule->ip.ss_family)
		return -1;
	if (addr_in->sa_family == AF_INET) {
		return ( rule_sin->sin_addr.s_addr !=
				( sin->sin_addr.s_addr &
				 htonl( SDP_NETMASK( rule->prefixlen ) ) ) );
	}
	return !ipv6_prefix_equal(&sin6->sin6_addr, &rule_sin6->sin6_addr, rule->prefixlen);
}
static inline int match_addr ( struct use_family_rule * rule , const struct sockaddr * addr_in ) { const struct sockaddr_in * sin = ( const struct sockaddr_in * ) addr_in ; const struct sockaddr_in6 * sin6 = ( const struct sockaddr_in6 * ) addr_in ; const struct sockaddr_in * rule_sin = ( const struct sockaddr_in * ) ( & rule -> ip ) ; const struct sockaddr_in6 * rule_sin6 = ( const struct sockaddr_in6 * ) ( & rule -> ip ) ; if ( rule_sin -> sin_family == AF_INET && ! rule_sin -> sin_addr . s_addr ) return 0 ; if ( addr_in -> sa_family != rule -> ip . ss_family ) return -1 ; if ( addr_in -> sa_family == AF_INET ) { return ( rule_sin -> sin_addr . s_addr != ( sin -> sin_addr . s_addr & htonl ( SDP_NETMASK ( rule -> prefixlen ) ) ) ) ; } return ! ipv6_prefix_equal ( & sin6 -> sin6_addr , & rule_sin6 -> sin6_addr , rule -> prefixlen ) ; }
return 0 if the addresses match
return 0 if the addresses match
/* IPv6 */