FreeBSD/sys/netinet/sctp_asconf.c
/*
 * does the address match? returns 0 if not, 1 if so
 */
does the address match. returns 0 if not, 1 if so
does the address match . returns 0 if not 1 if so
static uint32_t
sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa)
{
#if defined(INET) || defined(INET6)
	uint16_t param_type, param_length;
	param_type = ntohs(ph->param_type);
	param_length = ntohs(ph->param_length);
#endif
	switch (sa->sa_family) {
#ifdef INET6
	case AF_INET6:
		{
			struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
			struct sctp_ipv6addr_param *v6addr;
			v6addr = (struct sctp_ipv6addr_param *)ph;
			if ((param_type == SCTP_IPV6_ADDRESS) &&
			    (param_length == sizeof(struct sctp_ipv6addr_param)) &&
			    (memcmp(&v6addr->addr, &sin6->sin6_addr,
			    sizeof(struct in6_addr)) == 0)) {
				return (1);
			}
			break;
		}
#endif
#ifdef INET
	case AF_INET:
		{
			struct sockaddr_in *sin = (struct sockaddr_in *)sa;
			struct sctp_ipv4addr_param *v4addr;
			v4addr = (struct sctp_ipv4addr_param *)ph;
			if ((param_type == SCTP_IPV4_ADDRESS) &&
			    (param_length == sizeof(struct sctp_ipv4addr_param)) &&
			    (memcmp(&v4addr->addr, &sin->sin_addr,
			    sizeof(struct in_addr)) == 0)) {
				return (1);
			}
			break;
		}
#endif
	default:
		break;
	}
	return (0);
}
static uint32_t sctp_addr_match ( struct sctp_paramhdr * ph , struct sockaddr * sa ) { #if defined ( INET ) || defined ( INET6 ) uint16_t param_type , param_length ; param_type = ntohs ( ph -> param_type ) ; param_length = ntohs ( ph -> param_length ) ; #endif switch ( sa -> sa_family ) { #ifdef INET6 case AF_INET6 : { struct sockaddr_in6 * sin6 = ( struct sockaddr_in6 * ) sa ; struct sctp_ipv6addr_param * v6addr ; v6addr = ( struct sctp_ipv6addr_param * ) ph ; if ( ( param_type == SCTP_IPV6_ADDRESS ) && ( param_length == sizeof ( struct sctp_ipv6addr_param ) ) && ( memcmp ( & v6addr -> addr , & sin6 -> sin6_addr , sizeof ( struct in6_addr ) ) == 0 ) ) { return ( 1 ) ; } break ; } #endif #ifdef INET case AF_INET : { struct sockaddr_in * sin = ( struct sockaddr_in * ) sa ; struct sctp_ipv4addr_param * v4addr ; v4addr = ( struct sctp_ipv4addr_param * ) ph ; if ( ( param_type == SCTP_IPV4_ADDRESS ) && ( param_length == sizeof ( struct sctp_ipv4addr_param ) ) && ( memcmp ( & v4addr -> addr , & sin -> sin_addr , sizeof ( struct in_addr ) ) == 0 ) ) { return ( 1 ) ; } break ; } #endif default : break ; } return ( 0 ) ; }
does the address match?
does the address match?
/* XXX scopeid */