Commit cf900481 authored by Ghislain MARY's avatar Ghislain MARY

Enable adding a user DNS hosts file.

parent 7ae7ac4c
......@@ -76,6 +76,19 @@ BELLESIP_EXPORT void belle_sip_stack_set_resolver_tx_delay(belle_sip_stack_t *st
**/
BELLESIP_EXPORT void belle_sip_stack_set_resolver_send_error(belle_sip_stack_t *stack, int send_error);
/**
* Get the additional DNS hosts file.
* @return The path to the additional DNS hosts file.
**/
BELLESIP_EXPORT const char * belle_sip_stack_get_dns_user_hosts_file(const belle_sip_stack_t *stack);
/**
* Can be used to load an additional DNS hosts file for tests.
* @param stack
* @param hosts_file The path to the additional DNS hosts file to load.
**/
BELLESIP_EXPORT void belle_sip_stack_set_dns_user_hosts_file(belle_sip_stack_t *stack, const char *hosts_file);
/**
* Returns the time interval in seconds after which a connection must be closed when inactive.
**/
......
......@@ -478,6 +478,7 @@ struct belle_sip_stack{
int resolver_tx_delay; /*used to simulate network transmission delay, for tests*/
int resolver_send_error; /* used to simulate network error*/
int dscp;
const char *dns_user_hosts_file; /* used to load additional hosts file for tests */
};
belle_sip_hop_t* belle_sip_hop_new(const char* transport, const char *cname, const char* host,int port);
......
......@@ -86,6 +86,13 @@ static struct dns_hosts *hosts(belle_sip_resolver_context_t *ctx) {
return NULL;
}
if (ctx->stack->dns_user_hosts_file) {
error = dns_hosts_loadpath(ctx->hosts, ctx->stack->dns_user_hosts_file);
if (error) {
belle_sip_error("%s dns_hosts_loadfile(\"%s\"): %s", __FUNCTION__, dns_strerror(error));
}
}
return ctx->hosts;
}
......
......@@ -172,6 +172,14 @@ void belle_sip_stack_set_resolver_send_error(belle_sip_stack_t *stack, int send_
stack->resolver_send_error = send_error;
}
const char * belle_sip_stack_get_dns_user_hosts_file(const belle_sip_stack_t *stack) {
return stack->dns_user_hosts_file;
}
void belle_sip_stack_set_dns_user_hosts_file(belle_sip_stack_t *stack, const char *hosts_file) {
stack->dns_user_hosts_file = hosts_file;
}
const char* belle_sip_version_to_string() {
return PACKAGE_VERSION;
}
......
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