89 #define REFRESH_DEFAULT 300 109 int total_size =
sizeof(*entry) + strlen(name) + (service ? strlen(service) + 1 : 0);
117 strcpy(entry->name, name);
119 entry->
service = ((
char *) entry) +
sizeof(*entry) + strlen(name);
120 strcpy(entry->
service, service);
145 ast_debug(6,
"removing dns manager for '%s'\n", entry->name);
159 if (*dnsmgr && !strcasecmp((*dnsmgr)->name, name)) {
164 family = result->
ss.ss_family;
174 ast_debug(6,
"doing dnsmgr_lookup for '%s'\n", name);
184 ast_debug(6,
"adding dns manager for '%s'\n", name);
186 (*dnsmgr)->update_func = func;
187 (*dnsmgr)->data =
data;
211 ast_debug(6,
"refreshing '%s'\n", entry->name);
226 entry->name, old_addr, new_addr);
264 pthread_testcancel();
266 pthread_testcancel();
285 ast_debug(6,
"Refreshing DNS lookups.\n");
318 "Usage: dnsmgr reload\n" 319 " Reloads the DNS manager configuration.\n";
342 "Usage: dnsmgr refresh [pattern]\n" 343 " Peforms an immediate refresh of the managed DNS entries.\n" 344 " Optional regular expression pattern is used to filter the entries to refresh.\n";
351 ast_cli(a->
fd,
"DNS Manager is disabled.\n");
360 if (regcomp(&info.
filter, a->
argv[2], REG_EXTENDED | REG_NOSUB)) {
384 "Usage: dnsmgr status\n" 385 " Displays the DNS manager status.\n";
401 ast_cli(a->
fd,
"Number of entries: %d\n", count);
478 if (!strcasecmp(v->
name,
"enable")) {
480 }
else if (!strcasecmp(v->
name,
"refreshinterval")) {
481 if (sscanf(v->
value,
"%30d", &interval) < 1) {
483 }
else if (interval < 0) {
484 ast_log(
LOG_WARNING,
"Invalid refresh interval '%d' specified, using default\n", interval);
526 .requires =
"extconfig",
struct ast_variable * next
struct sockaddr_storage ss
#define AST_CLI_DEFINE(fn, txt,...)
static struct refresh_info master_refresh_info
Asterisk main include file. File version handling, generic pbx functions.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
static int refresh_interval
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
struct entry_list * entries
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
int ast_cli_unregister(struct ast_cli_entry *e)
Unregisters a command or an array of commands.
descriptor for a cli entry.
#define CONFIG_STATUS_FILEINVALID
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
void(* dns_update_func)(struct ast_sockaddr *old_addr, struct ast_sockaddr *new_addr, void *data)
static struct ast_sched_context * sched
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
static struct ast_cli_entry cli_reload
Structure for variables, used for configurations and for channel variables.
static char * handle_cli_refresh(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data, int variable) attribute_warn_unused_result
Adds a scheduled event with rescheduling support.
static pthread_t refresh_thread
Background DNS update manager.
#define ast_mutex_lock(a)
static struct ast_cli_entry cli_refresh
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
void ast_cli(int fd, const char *fmt,...)
Socket address structure.
int ast_dnsmgr_refresh(struct ast_dnsmgr_entry *entry)
Force a refresh of a dnsmgr entry.
#define ast_strlen_zero(foo)
#define ast_cli_register(e)
Registers a command or an array of commands.
#define ast_pthread_create_background(a, b, c, d)
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
Configuration File Parser.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#define AST_RWLIST_INSERT_HEAD
#define ast_debug(level,...)
Log a DEBUG message.
dns_update_func update_func
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
#define ast_mutex_trylock(a)
#define AST_PTHREADT_NULL
Access Control of various sorts.
static int do_reload(int loading)
#define AST_RWLIST_TRAVERSE
int ast_dnsmgr_lookup_cb(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service, dns_update_func func, void *data)
Allocate and initialize a DNS manager entry, with update callback.
Scheduler Routines (derived from cheops)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
#define ast_strdupa(s)
duplicate a string in memory from the stack
struct ast_sockaddr * result
A set of macros to manage forward-linked lists.
static int load_module(void)
#define CONFIG_STATUS_FILEUNCHANGED
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
static struct ast_cli_entry cli_status
static ast_mutex_t refresh_lock
void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry)
Free a DNS manager entry.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
unsigned int regex_present
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
static int refresh_list(const void *data)
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
static int dnsmgr_refresh(struct ast_dnsmgr_entry *entry, int verbose)
static int unload_module(void)
static int reload_module(void)
#define ast_calloc(num, len)
A wrapper for calloc()
void dnsmgr_start_refresh(void)
Module could not be loaded properly.
Prototypes for public functions only of internal interest,.
static char * handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Structure used to handle boolean flags.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
int ast_get_ip_or_srv(struct ast_sockaddr *addr, const char *hostname, const char *service)
Get the IP address given a hostname and optional service.
static int internal_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service, dns_update_func func, void *data)
#define CONFIG_STATUS_FILEMISSING
Standard Command Line Interface.
int ast_sched_wait(struct ast_sched_context *con) attribute_warn_unused_result
Determines number of seconds until the next outstanding event to take place.
struct ast_dnsmgr_entry * ast_dnsmgr_get_family(const char *name, struct ast_sockaddr *result, const char *service, unsigned int family)
Allocate a new DNS manager entry.
static char * handle_cli_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_RWLIST_REMOVE
#define ast_mutex_init(pmutex)
#define ast_mutex_destroy(a)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
static struct entry_list entry_list
struct ast_dnsmgr_entry * ast_dnsmgr_get(const char *name, struct ast_sockaddr *result, const char *service)
Allocate a new DNS manager entry.
int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service)
Allocate and initialize a DNS manager entry.
static void * do_refresh(void *data)
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
#define AST_MUTEX_DEFINE_STATIC(mutex)
Structure for mutex and tracking information.
#define ast_mutex_unlock(a)
int ast_dnsmgr_changed(struct ast_dnsmgr_entry *entry)
Check is see if a dnsmgr entry has changed.