#include "asterisk/network.h"
#include "asterisk/srv.h"


Go to the source code of this file.
Functions | |
| int | ast_dnsmgr_changed (struct ast_dnsmgr_entry *entry) |
| Check is see if a dnsmgr entry has changed. | |
| struct ast_dnsmgr_entry * | ast_dnsmgr_get (const char *name, struct sockaddr_in *result, const char *service) |
| Allocate a new DNS manager entry. | |
| int | ast_dnsmgr_lookup (const char *name, struct sockaddr_in *result, struct ast_dnsmgr_entry **dnsmgr, const char *service) |
| Allocate and initialize a DNS manager entry. | |
| 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.
| 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 193 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().
00194 { 00195 int changed; 00196 00197 ast_mutex_lock(&entry->lock); 00198 00199 changed = entry->changed; 00200 entry->changed = 0; 00201 00202 ast_mutex_unlock(&entry->lock); 00203 00204 return changed; 00205 }
| struct ast_dnsmgr_entry* ast_dnsmgr_get | ( | const char * | name, | |
| struct sockaddr_in * | result, | |||
| const char * | service | |||
| ) | [read] |
Allocate a new DNS manager entry.
| name | the hostname | |
| result | where the DNS manager should store the IP address as it refreshes it. it. |
Definition at line 86 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::lock, ast_dnsmgr_entry::name, ast_dnsmgr_entry::result, and ast_dnsmgr_entry::service.
Referenced by ast_dnsmgr_lookup().
00087 { 00088 struct ast_dnsmgr_entry *entry; 00089 int total_size = sizeof(*entry) + strlen(name) + (service ? strlen(service) + 1 : 0); 00090 00091 if (!result || ast_strlen_zero(name) || !(entry = ast_calloc(1, total_size))) 00092 return NULL; 00093 00094 entry->result = result; 00095 ast_mutex_init(&entry->lock); 00096 strcpy(entry->name, name); 00097 if (service) { 00098 entry->service = ((char *) entry) + sizeof(*entry) + strlen(name); 00099 strcpy(entry->service, service); 00100 } 00101 00102 AST_RWLIST_WRLOCK(&entry_list); 00103 AST_RWLIST_INSERT_HEAD(&entry_list, entry, list); 00104 AST_RWLIST_UNLOCK(&entry_list); 00105 00106 return entry; 00107 }
| int ast_dnsmgr_lookup | ( | const char * | name, | |
| struct sockaddr_in * | 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 | |
| dnsmgr | Where to store the allocate DNS manager entry |
| 0 | success | |
| non-zero | failure |
Definition at line 126 of file dnsmgr.c.
References ast_dnsmgr_get(), ast_get_ip_or_srv(), ast_strlen_zero(), ast_verb, enabled, and inet_aton().
Referenced by __sip_subscribe_mwi_do(), build_peer(), iax2_append_register(), and transmit_register().
00127 { 00128 if (ast_strlen_zero(name) || !result || !dnsmgr) 00129 return -1; 00130 00131 if (*dnsmgr && !strcasecmp((*dnsmgr)->name, name)) 00132 return 0; 00133 00134 /* if it's actually an IP address and not a name, 00135 there's no need for a managed lookup */ 00136 if (inet_aton(name, &result->sin_addr)) { 00137 result->sin_family = AF_INET; 00138 return 0; 00139 } 00140 00141 ast_verb(4, "doing dnsmgr_lookup for '%s'\n", name); 00142 00143 /* do a lookup now but add a manager so it will automagically get updated in the background */ 00144 ast_get_ip_or_srv(result, name, service); 00145 00146 /* if dnsmgr is not enable don't bother adding an entry */ 00147 if (!enabled) 00148 return 0; 00149 00150 ast_verb(3, "adding dns manager for '%s'\n", name); 00151 *dnsmgr = ast_dnsmgr_get(name, result, service); 00152 return !*dnsmgr; 00153 }
| 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 185 of file dnsmgr.c.
References dnsmgr_refresh().
Referenced by iax2_do_register(), and sip_reg_timeout().
00186 { 00187 return dnsmgr_refresh(entry, 0); 00188 }
| void ast_dnsmgr_release | ( | struct ast_dnsmgr_entry * | entry | ) |
Free a DNS manager entry.
| entry | the DNS manager entry to free |
Definition at line 109 of file dnsmgr.c.
References ast_free, ast_mutex_destroy(), AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_dnsmgr_entry::lock, and ast_dnsmgr_entry::name.
Referenced by delete_users(), peer_destructor(), sip_destroy_peer(), sip_registry_destroy(), and sip_subscribe_mwi_destroy().
00110 { 00111 if (!entry) 00112 return; 00113 00114 AST_RWLIST_WRLOCK(&entry_list); 00115 AST_RWLIST_REMOVE(&entry_list, entry, list); 00116 AST_RWLIST_UNLOCK(&entry_list); 00117 ast_verb(4, "removing dns manager for '%s'\n", entry->name); 00118 00119 ast_mutex_destroy(&entry->lock); 00120 ast_free(entry); 00121 }
1.5.9