Commit 2d248018 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Moved belle_sip_address_remove_v4_mapping() to bctoolbox.

parent 7c2ca893
......@@ -99,12 +99,6 @@ BELLESIP_EXPORT void belle_sip_resolver_context_cancel(belle_sip_resolver_contex
BELLESIP_EXPORT void belle_sip_get_src_addr_for(const struct sockaddr *dest, socklen_t destlen, struct sockaddr *src, socklen_t *srclen, int local_port);
* This function will transform a V4 to V6 mapped address to a pure V4 and write it into result, or will just copy it otherwise.
* The memory for v6 and result may be the same, in which case processing is done in place or no copy is done.
* The pointer to result must have sufficient storage, typically a struct sockaddr_storage.
BELLESIP_EXPORT void belle_sip_address_remove_v4_mapping(const struct sockaddr *v6, struct sockaddr *result, socklen_t *result_len);
......@@ -1144,32 +1144,3 @@ fail:
if (sock!=(belle_sip_socket_t)-1) close_socket(sock);
#define IN6_GET_ADDR_V4MAPPED(sin6_addr) *(unsigned int*)((unsigned char*)(sin6_addr)+12)
void belle_sip_address_remove_v4_mapping(const struct sockaddr *v6, struct sockaddr *result, socklen_t *result_len){
if (v6->sa_family==AF_INET6){
struct sockaddr_in6 *in6=(struct sockaddr_in6*)v6;
if (IN6_IS_ADDR_V4MAPPED(&in6->sin6_addr)){
struct sockaddr_in *in=(struct sockaddr_in*)result;
in->sin_addr.s_addr = IN6_GET_ADDR_V4MAPPED(&in6->sin6_addr);
*result_len=sizeof(struct sockaddr_in);
if (v6!=result) memcpy(result,v6,sizeof(struct sockaddr_in6));
*result_len=sizeof(struct sockaddr_in6);
*result_len=sizeof(struct sockaddr_in);
if (v6!=result) memcpy(result,v6,sizeof(struct sockaddr_in));
......@@ -147,7 +147,7 @@ static void fix_incoming_via(belle_sip_request_t *msg, const struct addrinfo* or
belle_sip_warning("cannot fix via for message [%p], probably a test",msg);
belle_sip_address_remove_v4_mapping(origin->ai_addr, (struct sockaddr*)&saddr, &slen);
bctbx_sockaddr_remove_v4_mapping(origin->ai_addr, (struct sockaddr*)&saddr, &slen);
err=getnameinfo((struct sockaddr*)&saddr,slen,received,sizeof(received),
if (err!=0){
......@@ -1346,7 +1346,7 @@ void belle_sip_channel_set_ready(belle_sip_channel_t *obj, const struct sockaddr
socklen_t slen2=sizeof(saddr);
int err;
belle_sip_address_remove_v4_mapping(addr,(struct sockaddr*) &saddr,&slen2);
bctbx_sockaddr_remove_v4_mapping(addr,(struct sockaddr*) &saddr,&slen2);
err=getnameinfo((struct sockaddr*)&saddr,slen2,name,sizeof(name),serv,sizeof(serv),NI_NUMERICHOST|NI_NUMERICSERV);
if (err!=0){
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