Commit 245bdae5 authored by Ghislain MARY's avatar Ghislain MARY

Add stack parameter to enable/disable DNS search.

parent 30415ca8
......@@ -61,6 +61,10 @@ BELLESIP_EXPORT unsigned char belle_sip_stack_dns_srv_enabled(const belle_sip_st
BELLESIP_EXPORT void belle_sip_stack_enable_dns_srv(belle_sip_stack_t *stack, unsigned char enable);
BELLESIP_EXPORT unsigned char belle_sip_stack_dns_search_enabled(const belle_sip_stack_t *stack);
BELLESIP_EXPORT void belle_sip_stack_enable_dns_search(belle_sip_stack_t *stack, unsigned char enable);
/**
* Override system's DNS servers used for DNS resolving by app-supplied list of dns servers.
* @param stack the stack
......
......@@ -525,7 +525,7 @@ struct belle_sip_stack{
char *http_proxy_passwd; /*for future use*/
unsigned char dns_srv_enabled;
unsigned char dns_search_enabled;
};
belle_sip_hop_t* belle_sip_hop_new(const char* transport, const char *cname, const char* host,int port);
......
......@@ -447,6 +447,7 @@ static int resolver_process_data(belle_sip_simple_resolver_context_t *ctx, unsig
int error;
unsigned char simulated_timeout=0;
int timeout=belle_sip_stack_get_dns_timeout(ctx->base.stack);
unsigned char search_enabled = belle_sip_stack_dns_search_enabled(ctx->base.stack);
/*Setting timeout to 0 can be used to simulate DNS timeout*/
if ((revents!=0) && timeout==0){
......@@ -459,6 +460,7 @@ static int resolver_process_data(belle_sip_simple_resolver_context_t *ctx, unsig
notify_results(ctx);
return BELLE_SIP_STOP;
}
dns_res_enable_search(ctx->R, search_enabled);
/*belle_sip_message("resolver_process_data(): revents=%i",revents);*/
error = dns_res_check(ctx->R);
if (!error) {
......
......@@ -7047,6 +7047,8 @@ struct dns_resolver {
struct dns_rr_i hints_i, hints_j;
struct dns_rr hints_ns, ans_cname;
} stack[DNS_R_MAXDEPTH];
unsigned char search_enabled;
}; /* struct dns_resolver */
......@@ -7726,7 +7728,10 @@ exec:
if (!R->nodata)
dns_p_movptr(&R->nodata, &F->answer);
dgoto(R->sp, DNS_R_SEARCH);
if (R->search_enabled)
dgoto(R->sp, DNS_R_SEARCH);
else
dgoto(R->sp, DNS_R_FINISH);
}
dns_rr_foreach(&rr, F->answer, .section = DNS_S_NS, .type = DNS_T_NS) {
......@@ -8096,6 +8101,10 @@ void dns_res_sethints(struct dns_resolver *res, struct dns_hints *hints) {
res->hints = hints;
} /* dns_res_sethints() */
void dns_res_enable_search(struct dns_resolver *res, unsigned char enable) {
res->search_enabled = enable;
}
/*
* A D D R I N F O R O U T I N E S
......
......@@ -1200,6 +1200,8 @@ DNS_PUBLIC const struct dns_stat *dns_res_stat(struct dns_resolver *);
DNS_PUBLIC void dns_res_sethints(struct dns_resolver *, struct dns_hints *);
DNS_PUBLIC void dns_res_enable_search(struct dns_resolver *, unsigned char enable);
/*
* A D D R I N F O I N T E R F A C E
......
......@@ -120,6 +120,7 @@ belle_sip_stack_t * belle_sip_stack_new(const char *properties){
stack->transport_timeout=63000;
stack->dns_timeout=15000;
stack->dns_srv_enabled=TRUE;
stack->dns_search_enabled=TRUE;
stack->inactive_transport_timeout=3600; /*one hour*/
return stack;
}
......@@ -161,6 +162,14 @@ void belle_sip_stack_enable_dns_srv(belle_sip_stack_t *stack, unsigned char enab
stack->dns_srv_enabled = enable;
}
unsigned char belle_sip_stack_dns_search_enabled(const belle_sip_stack_t *stack) {
return stack->dns_search_enabled;
}
void belle_sip_stack_enable_dns_search(belle_sip_stack_t *stack, unsigned char enable) {
stack->dns_search_enabled = enable;
}
belle_sip_listening_point_t *belle_sip_stack_create_listening_point(belle_sip_stack_t *s, const char *ipaddress, int port, const char *transport){
belle_sip_listening_point_t *lp=NULL;
if (strcasecmp(transport,"UDP")==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