#include "asterisk/netsock2.h"
#include "asterisk/srv.h"
Go to the source code of this file.
Typedefs | |
typedef void(*) | dns_update_func (struct ast_sockaddr *old_addr, struct ast_sockaddr *new_addr, void *data) |
Functions | |
int | ast_dnsmgr_changed (struct ast_dnsmgr_entry *entry) |
Check is see if a dnsmgr entry has changed. | |
ast_dnsmgr_entry * | ast_dnsmgr_get (const char *name, struct ast_sockaddr *result, const char *service) |
Allocate a new DNS manager entry. | |
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. | |
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. | |
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. | |
int | ast_dnsmgr_refresh (struct ast_dnsmgr_entry *entry) |
Force a refresh of a dnsmgr entry. | |
void | ast_dnsmgr_release (struct ast_dnsmgr_entry *entry) |
Free a DNS manager entry. |
Definition in file dnsmgr.h.
typedef void(*) dns_update_func(struct ast_sockaddr *old_addr, struct ast_sockaddr *new_addr, void *data) |
int ast_dnsmgr_changed | ( | struct ast_dnsmgr_entry * | entry | ) |
Check is see if a dnsmgr entry has changed.
non-zero | if the dnsmgr entry has changed since the last call to this function | |
zero | if the dnsmgr entry has not changed since the last call to this function |
Definition at line 234 of file dnsmgr.c.
References ast_mutex_lock, ast_mutex_unlock, ast_dnsmgr_entry::changed, and ast_dnsmgr_entry::lock.
Referenced by iax2_do_register().
00235 { 00236 int changed; 00237 00238 ast_mutex_lock(&entry->lock); 00239 00240 changed = entry->changed; 00241 entry->changed = 0; 00242 00243 ast_mutex_unlock(&entry->lock); 00244 00245 return changed; 00246 }
struct ast_dnsmgr_entry* ast_dnsmgr_get | ( | const char * | name, | |
struct ast_sockaddr * | result, | |||
const char * | service | |||
) |
Allocate a new DNS manager entry.
name | the hostname | |
result | where the DNS manager should store the IP address as it refreshes it. | |
service |
1.8.0 result changed from struct ast_sockaddr_in to ast_sockaddr for IPv6 support
Definition at line 117 of file dnsmgr.c.
References ast_dnsmgr_get_family(), and ast_dnsmgr_entry::result.
00118 { 00119 return ast_dnsmgr_get_family(name, result, service, 0); 00120 }
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.
name | the hostname | |
result | where the DNS manager should store the IP address as it refreshes it. | |
service | ||
family | Address family to filter DNS addresses. |
Definition at line 92 of file dnsmgr.c.
References ast_calloc, ast_mutex_init, AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), ast_dnsmgr_entry::family, ast_dnsmgr_entry::list, ast_dnsmgr_entry::lock, ast_dnsmgr_entry::name, ast_dnsmgr_entry::result, and ast_dnsmgr_entry::service.
Referenced by ast_dnsmgr_get(), and internal_dnsmgr_lookup().
00093 { 00094 struct ast_dnsmgr_entry *entry; 00095 int total_size = sizeof(*entry) + strlen(name) + (service ? strlen(service) + 1 : 0); 00096 00097 if (!result || ast_strlen_zero(name) || !(entry = ast_calloc(1, total_size))) { 00098 return NULL; 00099 } 00100 00101 entry->result = result; 00102 ast_mutex_init(&entry->lock); 00103 strcpy(entry->name, name); 00104 if (service) { 00105 entry->service = ((char *) entry) + sizeof(*entry) + strlen(name); 00106 strcpy(entry->service, service); 00107 } 00108 entry->family = family; 00109 00110 AST_RWLIST_WRLOCK(&entry_list); 00111 AST_RWLIST_INSERT_HEAD(&entry_list, entry, list); 00112 AST_RWLIST_UNLOCK(&entry_list); 00113 00114 return entry; 00115 }
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.
name | the hostname | |
result | where to store the IP address as the DNS manager refreshes it. The address family is used as an input parameter to filter the returned addresses. If it is 0, both IPv4 and IPv6 addresses can be returned. | |
dnsmgr | Where to store the allocate DNS manager entry | |
service |
0 | success | |
non-zero | failure |
Definition at line 176 of file dnsmgr.c.
References internal_dnsmgr_lookup(), and ast_dnsmgr_entry::result.
Referenced by build_peer(), and iax2_append_register().
00177 { 00178 return internal_dnsmgr_lookup(name, result, dnsmgr, service, NULL, NULL); 00179 }
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.
name | the hostname | |
result | The addr which is intended to be updated in the update callback when DNS manager calls it on refresh. The address family is used as an input parameter to filter the returned addresses. If it is 0, both IPv4 and IPv6 addresses can be returned. | |
dnsmgr | Where to store the allocate DNS manager entry | |
service | ||
func | The update callback function The update callback will be called when DNS manager detects that an IP address has been changed. Instead of updating the addr itself, DNS manager will call this callback function with the old and new addresses. It is the responsibility of the callback to perform any updates | |
data | A pointer to data that will be passed through to the callback function |
0 | success | |
non-zero | failure |
Definition at line 181 of file dnsmgr.c.
References internal_dnsmgr_lookup(), and ast_dnsmgr_entry::result.
Referenced by __sip_subscribe_mwi_do(), build_peer(), and transmit_register().
00182 { 00183 return internal_dnsmgr_lookup(name, result, dnsmgr, service, func, data); 00184 }
int ast_dnsmgr_refresh | ( | struct ast_dnsmgr_entry * | entry | ) |
Force a refresh of a dnsmgr entry.
non-zero | if the result is different than the previous result | |
zero | if the result is the same as the previous result |
Definition at line 226 of file dnsmgr.c.
References dnsmgr_refresh().
Referenced by build_peer(), iax2_do_register(), and sip_reg_timeout().
00227 { 00228 return dnsmgr_refresh(entry, 0); 00229 }
void ast_dnsmgr_release | ( | struct ast_dnsmgr_entry * | entry | ) |
Free a DNS manager entry.
entry | the DNS manager entry to free |
Definition at line 122 of file dnsmgr.c.
References ast_free, ast_mutex_destroy, AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_dnsmgr_entry::list, ast_dnsmgr_entry::lock, and ast_dnsmgr_entry::name.
Referenced by delete_users(), match_and_cleanup_peer_sched(), peer_destructor(), and unload_module().
00123 { 00124 if (!entry) 00125 return; 00126 00127 AST_RWLIST_WRLOCK(&entry_list); 00128 AST_RWLIST_REMOVE(&entry_list, entry, list); 00129 AST_RWLIST_UNLOCK(&entry_list); 00130 ast_verb(4, "removing dns manager for '%s'\n", entry->name); 00131 00132 ast_mutex_destroy(&entry->lock); 00133 ast_free(entry); 00134 }