diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 3f5da96cf..c36bb1f0f 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -1210,16 +1210,12 @@ void sal_use_no_initial_route(Sal *ctx, bool_t enabled){ ctx->no_initial_route=enabled; } -SalResolverContext * sal_resolve_a(Sal* sal, const char *name, int port, int family, SalResolverCallback cb, void *data){ - return (SalResolverContext*)belle_sip_stack_resolve_a(sal->stack,name,port,family,(belle_sip_resolver_callback_t)cb,data); +belle_sip_resolver_context_t * sal_resolve_a(Sal* sal, const char *name, int port, int family, belle_sip_resolver_callback_t cb, void *data){ + return belle_sip_stack_resolve_a(sal->stack,name,port,family,cb,data); } -SalResolverContext * sal_resolve(Sal *sal, const char *service, const char *transport, const char *name, int port, int family, SalResolverCallback cb, void *data) { - return (SalResolverContext *)belle_sip_stack_resolve(sal->stack, service, transport, name, port, family, (belle_sip_resolver_callback_t)cb, data); -} - -void sal_resolve_cancel(SalResolverContext* ctx){ - belle_sip_resolver_context_cancel((belle_sip_resolver_context_t*)ctx); +belle_sip_resolver_context_t * sal_resolve(Sal *sal, const char *service, const char *transport, const char *name, int port, int family, belle_sip_resolver_callback_t cb, void *data) { + return belle_sip_stack_resolve(sal->stack, service, transport, name, port, family, cb, data); } diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index 9e20286bf..7cc05fc6d 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -40,8 +40,8 @@ static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) { if (policy->stun_server_username) belle_sip_free(policy->stun_server_username); if (policy->stun_addrinfo) bctbx_freeaddrinfo(policy->stun_addrinfo); if (policy->stun_resolver_context) { - sal_resolve_cancel(policy->stun_resolver_context); - sal_resolver_context_unref(policy->stun_resolver_context); + belle_sip_resolver_context_cancel(policy->stun_resolver_context); + belle_sip_object_unref(policy->stun_resolver_context); } } @@ -204,7 +204,8 @@ void linphone_nat_policy_set_stun_server_username(LinphoneNatPolicy *policy, con if (new_username != NULL) policy->stun_server_username = new_username; } -static void stun_server_resolved(LinphoneNatPolicy *policy, const char *name, struct addrinfo *addrinfo) { +static void stun_server_resolved(void *data, const char *name, struct addrinfo *addrinfo, uint32_t ttl) { + LinphoneNatPolicy *policy = (LinphoneNatPolicy *)data; if (policy->stun_addrinfo) { bctbx_freeaddrinfo(policy->stun_addrinfo); policy->stun_addrinfo = NULL; @@ -216,7 +217,7 @@ static void stun_server_resolved(LinphoneNatPolicy *policy, const char *name, st } policy->stun_addrinfo = addrinfo; if (policy->stun_resolver_context){ - sal_resolver_context_unref(policy->stun_resolver_context); + belle_sip_object_unref(policy->stun_resolver_context); policy->stun_resolver_context = NULL; } } @@ -233,8 +234,8 @@ void linphone_nat_policy_resolve_stun_server(LinphoneNatPolicy *policy) { if (service != NULL) { int family = AF_INET; if (linphone_core_ipv6_enabled(policy->lc) == TRUE) family = AF_INET6; - policy->stun_resolver_context = sal_resolve(policy->lc->sal, service, "udp", host, port, family, (SalResolverCallback)stun_server_resolved, policy); - if (policy->stun_resolver_context) sal_resolver_context_ref(policy->stun_resolver_context); + policy->stun_resolver_context = sal_resolve(policy->lc->sal, service, "udp", host, port, family, stun_server_resolved, policy); + if (policy->stun_resolver_context) belle_sip_object_ref(policy->stun_resolver_context); } } } diff --git a/coreapi/private.h b/coreapi/private.h index cd8d49a4b..52e5da49d 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1357,7 +1357,7 @@ struct _LinphoneNatPolicy { belle_sip_object_t base; void *user_data; LinphoneCore *lc; - SalResolverContext *stun_resolver_context; + belle_sip_resolver_context_t *stun_resolver_context; struct addrinfo *stun_addrinfo; char *stun_server; char *stun_server_username; diff --git a/coreapi/sal.c b/coreapi/sal.c index 133241be1..ee823e87d 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -927,6 +927,3 @@ void sal_op_set_entity_tag(SalOp *op, const char* entity_tag) { op_base->entity_tag = NULL; } -#ifdef BELLE_SIP_H -#error "You included belle-sip header other than just belle-sip/object.h in sal.c. This breaks design rules !" -#endif diff --git a/include/sal/sal.h b/include/sal/sal.h index 9179ec78b..ed861c204 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -32,8 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "mediastreamer2/mediastream.h" #include "ortp/rtpsession.h" -#include "belle-sip/object.h" -#include "belle-sip/mainloop.h" +#include "belle-sip/belle-sip.h" #ifndef LINPHONE_PUBLIC #if defined(_MSC_VER) @@ -853,15 +852,9 @@ SalPrivacy sal_op_get_privacy(const SalOp* op); /*misc*/ void sal_get_default_local_ip(Sal *sal, int address_family, char *ip, size_t iplen); -typedef void (*SalResolverCallback)(void *data, const char *name, struct addrinfo *ai_list); - -typedef struct SalResolverContext SalResolverContext; -#define sal_resolver_context_ref(obj) belle_sip_object_ref(obj) -#define sal_resolver_context_unref(obj) belle_sip_object_unref(obj) -LINPHONE_PUBLIC SalResolverContext * sal_resolve_a(Sal* sal, const char *name, int port, int family, SalResolverCallback cb, void *data); -LINPHONE_PUBLIC SalResolverContext * sal_resolve(Sal *sal, const char *service, const char *transport, const char *name, int port, int family, SalResolverCallback cb, void *data); -void sal_resolve_cancel(SalResolverContext *ctx); +LINPHONE_PUBLIC belle_sip_resolver_context_t * sal_resolve_a(Sal* sal, const char *name, int port, int family, belle_sip_resolver_callback_t cb, void *data); +LINPHONE_PUBLIC belle_sip_resolver_context_t * sal_resolve(Sal *sal, const char *service, const char *transport, const char *name, int port, int family, belle_sip_resolver_callback_t cb, void *data); SalCustomHeader *sal_custom_header_ref(SalCustomHeader *ch); void sal_custom_header_unref(SalCustomHeader *ch); diff --git a/tester/complex_sip_case_tester.c b/tester/complex_sip_case_tester.c index f50996b5a..a8bbd5377 100644 --- a/tester/complex_sip_case_tester.c +++ b/tester/complex_sip_case_tester.c @@ -90,7 +90,7 @@ static FILE *sip_start_recv(const char *senario) { return file; } -static void dest_server_server_resolved(void *data, const char *name, struct addrinfo *ai_list) { +static void dest_server_server_resolved(void *data, const char *name, struct addrinfo *ai_list, uint32_t ttl) { *(struct addrinfo **)data =ai_list; } @@ -105,7 +105,7 @@ LinphoneAddress * linphone_core_manager_resolve(LinphoneCoreManager *mgr, const ,linphone_address_get_domain(source) ,linphone_address_get_port(source) ,AF_INET - ,(SalResolverCallback)dest_server_server_resolved + ,dest_server_server_resolved ,&addrinfo); dest=linphone_address_new(NULL);