Commit addfb159 authored by Simon Morlat's avatar Simon Morlat
Browse files

fix issues with ipv6 on windows

parent 15fc6034
......@@ -978,12 +978,15 @@ void belle_sip_get_src_addr_for(const struct sockaddr *dest, socklen_t destlen,
int af_type=dest->sa_family;
int sock=socket(af_type,SOCK_DGRAM,IPPROTO_UDP);
belle_sip_message("belle_sip_get_src_addr_for(): af_inet6=%i",af_type==AF_INET6);
if (sock==(belle_sip_socket_t)-1){
belle_sip_fatal("Could not create socket: %s",belle_sip_get_socket_error_string());
goto fail;
if (af_type==AF_INET6){
if (af_type==AF_INET6 && (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6*)dest)->sin6_addr))){
/*this is actually required only for windows, who is enable to provide an ipv4 mapped local address if the remote is ipv4 mapped,
and unable to provide a correct local address if the remote address is true ipv6 address when in dual stack mode*/
......@@ -63,7 +63,7 @@ static int udp_channel_recv(belle_sip_channel_t *obj, void *buf, size_t buflen){
int udp_channel_connect(belle_sip_channel_t *obj, const struct addrinfo *ai){
struct sockaddr_storage laddr;
struct sockaddr_storage laddr={0};
socklen_t lslen=sizeof(laddr);
if (obj->local_ip==NULL){
belle_sip_get_src_addr_for(ai->ai_addr,ai->ai_addrlen,(struct sockaddr*)&laddr,&lslen,obj->local_port);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment