Commit 7cd78972 authored by Simon Morlat's avatar Simon Morlat

fix bug with channel matching when channel was connected after DNS SRV resolution.

fix test (videolan DNS changed)
parent ab66315a
......@@ -701,7 +701,7 @@ void belle_sip_channel_remove_listener(belle_sip_channel_t *obj, belle_sip_chann
}
int belle_sip_channel_matches(const belle_sip_channel_t *obj, const belle_sip_hop_t *hop, const struct addrinfo *addr){
if (hop && strcmp(hop->host,obj->peer_name)==0 && hop->port==obj->peer_port){
if (hop && strcmp(hop->host,obj->peer_name)==0 && (hop->port==obj->peer_port || obj->srv_overrides_port)){
if (hop->cname && obj->peer_cname && strcmp(hop->cname,obj->peer_cname)!=0)
return 0; /*cname mismatch*/
return 1;
......@@ -1227,9 +1227,16 @@ void belle_sip_channel_resolve(belle_sip_channel_t *obj){
void belle_sip_channel_connect(belle_sip_channel_t *obj){
char ip[64];
int port=obj->peer_port;
channel_set_state(obj,BELLE_SIP_CHANNEL_CONNECTING);
belle_sip_addrinfo_to_ip(obj->current_peer,ip,sizeof(ip),&obj->peer_port);/* update peer_port as it may have been overriden by SRV resolution*/
belle_sip_addrinfo_to_ip(obj->current_peer,ip,sizeof(ip),&port);
/* update peer_port as it may have been overriden by SRV resolution*/
if (port!=obj->peer_port){
/*the SRV resolution provided a port number that must be used*/
obj->srv_overrides_port=TRUE;
obj->peer_port=port;
}
belle_sip_message("Trying to connect to [%s://%s:%i]",belle_sip_channel_get_transport_name(obj),ip,obj->peer_port);
if(BELLE_SIP_OBJECT_VPTR(obj,belle_sip_channel_t)->connect(obj,obj->current_peer)) {
......
......@@ -124,6 +124,7 @@ struct belle_sip_channel{
unsigned char learnt_ip_port;
unsigned char has_name; /*set when the name of the peer is known, which is not the case of inboud connections*/
unsigned char about_to_be_closed;
unsigned char srv_overrides_port; /*set when this channel was connected to destination port provided by SRV resolution*/
};
#define BELLE_SIP_CHANNEL(obj) BELLE_SIP_CAST(obj,belle_sip_channel_t)
......
......@@ -30,9 +30,9 @@
#define IPV4_SIP_BAD_DOMAIN "dummy.linphone.org"
#define IPV4_MULTIRES_DOMAIN "google.com"
/* videolan.org has an IPv6 and an IPv4 IP*/
#define IPV6_SIP_DOMAIN "videolan.org"
#define IPV6_SIP_IP "2a01:e0d:1:3:58bf:fa02:0:1"
/* sip2.linphone.org has an IPv6 and an IPv4 IP*/
#define IPV6_SIP_DOMAIN "sip2.linphone.org"
#define IPV6_SIP_IP "2001:41d0:2:14b0::1"
#define IPV6_SIP_IPV4 "88.191.250.2"
#define SRV_DOMAIN "linphone.org"
......
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