Commit e9780ba3 authored by Simon Morlat's avatar Simon Morlat

work in progress

parent 2c236a7e
......@@ -796,15 +796,17 @@ belle_sip_channel_t *belle_sip_channel_find_from_list_with_addrinfo(belle_sip_li
}
return NULL;
}
belle_sip_channel_t *belle_sip_channel_find_from_list(belle_sip_list_t *l ,const belle_sip_hop_t *hop){
/* search a matching channel from a list according to supplied hop. The ai_family tells which address family is supported by the list of channels*/
belle_sip_channel_t *belle_sip_channel_find_from_list(belle_sip_list_t *l, int ai_family, const belle_sip_hop_t *hop){
struct addrinfo *res=NULL;
struct addrinfo hints={0};
char portstr[20];
belle_sip_channel_t *chan;
hints.ai_family=lp->ai_family;
hints.ai_family=ai_family;
hints.ai_flags=AI_NUMERICHOST|AI_NUMERICSERV;
if (ai_family==AF_INET6) hints.ai_flags=AI_V4MAPPED;
snprintf(portstr,sizeof(portstr),"%i",hop->port);
getaddrinfo(hop->host,portstr,&hints,&res);
chan=belle_sip_channel_find_from_list_with_addrinfo(l,hop,res);
......
......@@ -76,8 +76,8 @@ typedef struct belle_sip_tls_channel belle_sip_tls_channel_t;
struct belle_sip_channel{
belle_sip_source_t base;
belle_sip_listening_point_t *lp; /*the listening point that owns this channel*/
belle_sip_stack_t *stack;
belle_sip_listening_point_t *lp; /*the listening point that owns this channel*/
belle_sip_channel_state_t state;
belle_sip_list_t *listeners;
char *peer_cname;
......@@ -183,7 +183,7 @@ void belle_sip_tls_channel_set_client_certificates_chain(belle_sip_tls_channel_t
void belle_sip_tls_channel_set_client_certificate_key(belle_sip_tls_channel_t *obj, belle_sip_signing_key_t* key);
belle_sip_channel_t *belle_sip_channel_find_from_list_with_addrinfo(belle_sip_list_t *l, const belle_sip_hop_t *hop, const struct addrinfo *addr);
belle_sip_channel_t *belle_sip_channel_find_from_list(belle_sip_list_t *l ,const belle_sip_hop_t *hop);
belle_sip_channel_t *belle_sip_channel_find_from_list(belle_sip_list_t *l, int ai_family, const belle_sip_hop_t *hop);
#define BELLE_SIP_TLS_CHANNEL(obj) BELLE_SIP_CAST(obj,belle_sip_tls_channel_t)
......
......@@ -31,6 +31,7 @@ struct belle_http_channel_context{
struct belle_http_provider{
belle_sip_stack_t *stack;
char *bind_ip;
int ai_family;
belle_sip_list_t *tcp_channels;
belle_sip_list_t *tls_channels;
};
......@@ -108,6 +109,7 @@ belle_http_provider_t *belle_http_provider_new(belle_sip_stack_t *s, const char
belle_http_provider_t *p=belle_sip_object_new(belle_http_provider_t);
p->stack=s;
p->bind_ip=belle_sip_strdup(bind_ip);
p->ai_family=strchr(p->bind_ip,':') ? AF_INET6 : AF_INET;
return p;
}
......@@ -125,7 +127,7 @@ int belle_http_provider_send_request(belle_http_provider_t *obj, belle_http_requ
belle_http_request_set_listener(req,listener);
chan=belle_sip_channel_find_from_list(*channels,hop);
chan=belle_sip_channel_find_from_list(*channels,obj->ai_family, hop);
if (!chan){
chan=belle_sip_stream_channel_new_client(obj->stack,obj->bind_ip,0,hop->cname,hop->host,hop->port);
......
......@@ -133,7 +133,7 @@ belle_sip_channel_t *_belle_sip_listening_point_get_channel(belle_sip_listening_
}
belle_sip_channel_t *belle_sip_listening_point_get_channel(belle_sip_listening_point_t *lp,const belle_sip_hop_t *hop){
return belle_sip_channel_find_from_list(lp->channels,hop);
return belle_sip_channel_find_from_list(lp->channels,lp->ai_family,hop);
}
static int send_keep_alive(belle_sip_channel_t* obj) {
......
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