![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
sip3_domain.c File Reference
Olle E. Johansson <oej@edvina.net> (all the chan_sip3 changes)
Definition in file sip3_domain.c.
#include "asterisk.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <netdb.h>
#include <signal.h>
#include <sys/signal.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <arpa/inet.h>
#include <netinet/ip.h>
#include <regex.h>
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/options.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/rtp.h"
#include "asterisk/udptl.h"
#include "asterisk/acl.h"
#include "asterisk/manager.h"
#include "asterisk/callerid.h"
#include "asterisk/cli.h"
#include "asterisk/app.h"
#include "asterisk/musiconhold.h"
#include "asterisk/dsp.h"
#include "asterisk/features.h"
#include "asterisk/srv.h"
#include "asterisk/astdb.h"
#include "asterisk/causes.h"
#include "asterisk/utils.h"
#include "asterisk/file.h"
#include "asterisk/astobj.h"
#include "asterisk/dnsmgr.h"
#include "asterisk/devicestate.h"
#include "asterisk/linkedlists.h"
#include "asterisk/stringfields.h"
#include "asterisk/monitor.h"
#include "asterisk/localtime.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/compiler.h"
#include "sip3.h"
#include "sip3funcs.h"
Include dependency graph for sip3_domain.c:

Go to the source code of this file.
Defines | |
| #define | FORMAT "%-40.40s %-20.20s %-16.16s\n" |
Functions | |
| int | add_sip_domain (const char *domain, const enum domain_mode mode, const char *context) |
| Add SIP domain to list of domains we are responsible for. | |
| static | AST_LIST_HEAD_STATIC (domain_list, domain) |
| int | check_sip_domain (const char *domain, char *context, size_t len) |
| check_sip_domain: Check if domain part of uri is local to our server | |
| void | clear_sip_domains (void) |
| Clear our domain list (at reload). | |
| const char * | domain_mode_to_text (const enum domain_mode mode) |
| Print domain mode to cli. | |
| int | domains_configured (void) |
| return TRUE if any domains are configured for this server | |
| int | func_check_sipdomain (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
| Dial plan function to check if domain is local. | |
| int | sip_show_domains (int fd, int argc, char *argv[]) |
| CLI command to list local domains. | |
Variables | |
| ast_custom_function | checksipdomain_function |
|
|
|
|
||||||||||||||||
|
Add SIP domain to list of domains we are responsible for. sip3_domain.c: Domain handling functions (sip domain hosting, not DNS lookups) Definition at line 95 of file sip3_domain.c. References ast_calloc, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_log(), ast_strlen_zero(), LOG_DEBUG, LOG_WARNING, and option_debug. 00096 { 00097 struct domain *d; 00098 00099 if (ast_strlen_zero(domain)) { 00100 ast_log(LOG_WARNING, "Zero length domain.\n"); 00101 return 1; 00102 } 00103 00104 if (!(d = ast_calloc(1, sizeof(*d)))) 00105 return 0; 00106 00107 ast_copy_string(d->domain, domain, sizeof(d->domain)); 00108 00109 if (!ast_strlen_zero(context)) 00110 ast_copy_string(d->context, context, sizeof(d->context)); 00111 00112 d->mode = mode; 00113 00114 AST_LIST_LOCK(&domain_list); 00115 AST_LIST_INSERT_TAIL(&domain_list, d, list); 00116 AST_LIST_UNLOCK(&domain_list); 00117 00118 if (option_debug > 2) 00119 ast_log(LOG_DEBUG, "Added local SIP domain '%s'\n", domain); 00120 00121 return 1; 00122 }
|
|
||||||||||||
|
The SIP domain list |
|
||||||||||||||||
|
check_sip_domain: Check if domain part of uri is local to our server
Definition at line 132 of file sip3_domain.c. References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), domain::context, and domain::domain. 00133 { 00134 struct domain *d; 00135 int result = 0; 00136 00137 AST_LIST_LOCK(&domain_list); 00138 AST_LIST_TRAVERSE(&domain_list, d, list) { 00139 if (strcasecmp(d->domain, domain)) 00140 continue; 00141 00142 if (len && !ast_strlen_zero(d->context)) 00143 ast_copy_string(context, d->context, len); 00144 00145 result = 1; 00146 break; 00147 } 00148 AST_LIST_UNLOCK(&domain_list); 00149 00150 return result; 00151 }
|
|
|
Clear our domain list (at reload).
Definition at line 154 of file sip3_domain.c. References AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, and free. 00155 { 00156 struct domain *d; 00157 00158 AST_LIST_LOCK(&domain_list); 00159 while ((d = AST_LIST_REMOVE_HEAD(&domain_list, list))) 00160 free(d); 00161 AST_LIST_UNLOCK(&domain_list); 00162 }
|
|
|
Print domain mode to cli.
Definition at line 191 of file sip3_domain.c. References SIP_DOMAIN_AUTO, and SIP_DOMAIN_CONFIG. 00192 { 00193 switch (mode) { 00194 case SIP_DOMAIN_AUTO: 00195 return "[Automatic]"; 00196 case SIP_DOMAIN_CONFIG: 00197 return "[Configured]"; 00198 } 00199 00200 return ""; 00201 }
|
|
|
return TRUE if any domains are configured for this server
Definition at line 125 of file sip3_domain.c. References AST_LIST_EMPTY. Referenced by get_destination(), handle_request_refer(), register_verify(), sip_show_domains(), and sip_show_settings(). 00126 { 00127 return (!AST_LIST_EMPTY(&domain_list)); 00128 }
|
|
||||||||||||||||||||||||
|
Dial plan function to check if domain is local.
Definition at line 166 of file sip3_domain.c. References ast_log(), ast_strlen_zero(), check_sip_domain(), and LOG_WARNING. 00167 { 00168 if (ast_strlen_zero(data)) { 00169 ast_log(LOG_WARNING, "CHECKSIPDOMAIN requires an argument - A domain name\n"); 00170 return -1; 00171 } 00172 if (check_sip_domain(data, NULL, 0)) 00173 ast_copy_string(buf, data, len); 00174 else 00175 buf[0] = '\0'; 00176 return 0; 00177 }
|
|
||||||||||||||||
|
CLI command to list local domains.
Definition at line 204 of file sip3_domain.c. References ast_cli(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, domain::context, domain::domain, domain_mode_to_text(), domains_configured(), FORMAT, domain::mode, RESULT_SUCCESS, and S_OR. 00205 { 00206 struct domain *d; 00207 #define FORMAT "%-40.40s %-20.20s %-16.16s\n" 00208 00209 if (domains_configured()) { 00210 ast_cli(fd, "SIP Domain support not enabled.\n\n"); 00211 return RESULT_SUCCESS; 00212 } else { 00213 ast_cli(fd, FORMAT, "Our local SIP domains:", "Context", "Set by"); 00214 AST_LIST_LOCK(&domain_list); 00215 AST_LIST_TRAVERSE(&domain_list, d, list) 00216 ast_cli(fd, FORMAT, d->domain, S_OR(d->context, "(default)"), 00217 domain_mode_to_text(d->mode)); 00218 AST_LIST_UNLOCK(&domain_list); 00219 ast_cli(fd, "\n"); 00220 return RESULT_SUCCESS; 00221 } 00222 }
|
|
|
Definition at line 179 of file sip3_domain.c. |