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

ipv6 management change: in channels, struct sockaddr fields now contain ipv6...

ipv6 management change: in channels, struct sockaddr fields now contain ipv6 address with ipv4 mapping.
Previously mapping was removed. It is now only removed when going to a string representation of the address, for "Contact" address or via "received".
parent 26d982b7
......@@ -85,11 +85,15 @@ static void fix_incoming_via(belle_sip_request_t *msg, const struct addrinfo* or
char rport[NI_MAXSERV];
belle_sip_header_via_t *via;
int err;
struct sockaddr_storage saddr;
socklen_t slen=sizeof(saddr);
if (!origin) {
belle_sip_warning("cannot fix via for message [%p], probably a test",msg);
return;
}
err=getnameinfo(origin->ai_addr,origin->ai_addrlen,received,sizeof(received),
belle_sip_address_remove_v4_mapping(origin->ai_addr, (struct sockaddr*)&saddr, &slen);
err=getnameinfo((struct sockaddr*)&saddr,slen,received,sizeof(received),
rport,sizeof(rport),NI_NUMERICHOST|NI_NUMERICSERV);
if (err!=0){
belle_sip_error("fix_via: getnameinfo() failed: %s",gai_strerror(errno));
......@@ -713,7 +717,12 @@ void belle_sip_channel_set_ready(belle_sip_channel_t *obj, const struct sockaddr
char serv[NI_MAXSERV];
if (obj->local_ip==NULL){
int err=getnameinfo(addr,slen,name,sizeof(name),serv,sizeof(serv),NI_NUMERICHOST|NI_NUMERICSERV);
struct sockaddr_storage saddr;
socklen_t slen2=sizeof(saddr);
belle_sip_address_remove_v4_mapping(addr,(struct sockaddr*) &saddr,&slen2);
int err=getnameinfo((struct sockaddr*)&saddr,slen,name,sizeof(name),serv,sizeof(serv),NI_NUMERICHOST|NI_NUMERICSERV);
if (err!=0){
belle_sip_error("belle_sip_channel_set_ready(): getnameinfo() failed: %s",gai_strerror(err));
}else{
......
......@@ -181,7 +181,6 @@ int finalize_stream_connection(belle_sip_stream_channel_t *obj, struct sockaddr
belle_sip_error("Failed to retrieve sockname for fd [%i]: cause [%s]",sock,belle_sip_get_socket_error_string());
return -1;
}
belle_sip_address_remove_v4_mapping(addr,addr,slen);
#if TARGET_OS_IPHONE
stream_channel_enable_ios_background_mode(obj);
#endif
......@@ -254,8 +253,6 @@ belle_sip_channel_t * belle_sip_stream_channel_new_child(belle_sip_stack_t *stac
belle_sip_error("getsockname() failed: %s",belle_sip_get_socket_error_string());
return NULL;
}
belle_sip_address_remove_v4_mapping((struct sockaddr*)&localaddr,(struct sockaddr*)&localaddr,&local_len);
belle_sip_address_remove_v4_mapping(remote_addr,remote_addr,&slen);
obj=belle_sip_object_new(belle_sip_stream_channel_t);
belle_sip_channel_init_with_addr((belle_sip_channel_t*)obj,stack,remote_addr,slen);
......
......@@ -57,7 +57,6 @@ static int tunnel_channel_connect(belle_sip_channel_t *obj, const struct addrinf
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);
belle_sip_address_remove_v4_mapping((struct sockaddr *)&laddr, (struct sockaddr *)&laddr, &lslen);
}
belle_sip_channel_set_ready(obj, (struct sockaddr *)&laddr, lslen);
return 0;
......
......@@ -67,7 +67,6 @@ int udp_channel_connect(belle_sip_channel_t *obj, const struct addrinfo *ai){
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);
belle_sip_address_remove_v4_mapping((struct sockaddr*)&laddr,(struct sockaddr*)&laddr,&lslen);
}
belle_sip_channel_set_ready(obj,(struct sockaddr*)&laddr,lslen);
return 0;
......
......@@ -415,7 +415,7 @@ static void set_custom_resolv_conf(belle_sip_stack_t *stack, const char *ns[3]){
for (i=0; i<3; ++i){
if (ns[i]!=NULL){
fprintf(f,"nameserver %s\n",ns[i]);
}
}else break;
}
fclose(f);
}
......
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