FreeBSD/sys/netipsec/key.c
/* 
 * Get port from sockaddr. Port is in network byte order.
 */
Get port from sockaddr. Port is in network byte order.
Get port from sockaddr . Port is in network byte order .
u_int16_t
key_portfromsaddr(struct sockaddr *sa)
{
	switch (sa->sa_family) {
#ifdef INET
	case AF_INET:
		return ((struct sockaddr_in *)sa)->sin_port;
#endif
#ifdef INET6
	case AF_INET6:
		return ((struct sockaddr_in6 *)sa)->sin6_port;
#endif
	}
	KEYDEBUG(KEYDEBUG_IPSEC_STAMP,
		printf("DP %s unexpected address family %d\n",
			__func__, sa->sa_family));
	return (0);
}
u_int16_t key_portfromsaddr ( struct sockaddr * sa ) { switch ( sa -> sa_family ) { #ifdef INET case AF_INET : return ( ( struct sockaddr_in * ) sa ) -> sin_port ; #endif #ifdef INET6 case AF_INET6 : return ( ( struct sockaddr_in6 * ) sa ) -> sin6_port ; #endif } KEYDEBUG ( KEYDEBUG_IPSEC_STAMP , printf ( " \n " , __func__ , sa -> sa_family ) ) ; return ( 0 ) ; }
Get port from sockaddr.
Get port from sockaddr .