[asterisk-commits] rizzo: branch rizzo/astobj2 r47687 -
/team/rizzo/astobj2/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Nov 15 12:43:05 MST 2006
Author: rizzo
Date: Wed Nov 15 13:43:04 2006
New Revision: 47687
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47687
Log:
more experiments converting config file parsing.
let's see at the end how this looks like.
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47687&r1=47686&r2=47687
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Wed Nov 15 13:43:04 2006
@@ -16469,6 +16469,7 @@
/* Read the [general] config section of sip.conf (or from realtime config) */
for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
+ M_START(v->name, v->value)
if (handle_common_options(&global_flags[0], &dummy[0], v))
continue;
/* handle jb conf */
@@ -16476,77 +16477,57 @@
continue;
/* Create the dialogs list */
- if (!strcasecmp(v->name, "context")) {
- ast_copy_string(default_context, v->value, sizeof(default_context));
- } else if (!strcasecmp(v->name, "realm")) {
- ast_copy_string(global_realm, v->value, sizeof(global_realm));
- } else if (!strcasecmp(v->name, "useragent")) {
- ast_copy_string(global_useragent, v->value, sizeof(global_useragent));
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting SIP channel User-Agent Name to %s\n", global_useragent);
- } else if (!strcasecmp(v->name, "allowtransfer")) {
- global_allowtransfer = ast_true(v->value) ? TRANSFER_OPENFORALL : TRANSFER_CLOSED;
- } else if (!strcasecmp(v->name, "rtcachefriends")) {
- ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_RTCACHEFRIENDS);
- } else if (!strcasecmp(v->name, "rtsavesysname")) {
- ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_RTSAVE_SYSNAME);
- } else if (!strcasecmp(v->name, "rtupdate")) {
- ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_RTUPDATE);
- } else if (!strcasecmp(v->name, "ignoreregexpire")) {
- ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_IGNOREREGEXPIRE);
- } else if (!strcasecmp(v->name, "t1min")) {
- global_t1min = atoi(v->value);
- } else if (!strcasecmp(v->name, "rtautoclear")) {
+ M_STR("context", default_context)
+ M_STR("realm", global_realm)
+ M_STR("useragent", global_useragent)
+ M_F("allowtransfer", global_allowtransfer = ast_true(v->value) ? TRANSFER_OPENFORALL : TRANSFER_CLOSED;)
+ M_F("rtcachefriends", ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_RTCACHEFRIENDS);)
+ M_F("rtsavesysname", ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_RTSAVE_SYSNAME);)
+ M_F("rtupdate", ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_RTUPDATE);)
+ M_F("ignoreregexpire", ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_IGNOREREGEXPIRE);)
+ M_F("t1min", global_t1min = atoi(v->value);)
+ M_F("rtautoclear", {
int i = atoi(v->value);
if (i > 0)
global_rtautoclear = i;
else
i = 0;
- ast_set2_flag(&global_flags[1], i || ast_true(v->value), SIP_PAGE2_RTAUTOCLEAR);
- } else if (!strcasecmp(v->name, "usereqphone")) {
- ast_set2_flag(&global_flags[0], ast_true(v->value), SIP_USEREQPHONE);
- } else if (!strcasecmp(v->name, "relaxdtmf")) {
- global_relaxdtmf = ast_true(v->value);
- } else if (!strcasecmp(v->name, "checkmwi")) {
+ ast_set2_flag(&global_flags[1], i || ast_true(v->value), SIP_PAGE2_RTAUTOCLEAR); } )
+ M_F("usereqphone", ast_set2_flag(&global_flags[0], ast_true(v->value), SIP_USEREQPHONE);)
+ M_BOOL("relaxdtmf", global_relaxdtmf)
+ M_F("checkmwi", {
if ((sscanf(v->value, "%d", &global_mwitime) != 1) || (global_mwitime < 0)) {
ast_log(LOG_WARNING, "'%s' is not a valid MWI time setting at line %d. Using default (10).\n", v->value, v->lineno);
global_mwitime = DEFAULT_MWITIME;
- }
- } else if (!strcasecmp(v->name, "vmexten")) {
- ast_copy_string(default_vmexten, v->value, sizeof(default_vmexten));
- } else if (!strcasecmp(v->name, "rtptimeout")) {
+ } } )
+ M_STR("vmexten", default_vmexten)
+ M_F("rtptimeout", {
if ((sscanf(v->value, "%d", &global_rtptimeout) != 1) || (global_rtptimeout < 0)) {
ast_log(LOG_WARNING, "'%s' is not a valid RTP hold time at line %d. Using default.\n", v->value, v->lineno);
global_rtptimeout = 0;
- }
- } else if (!strcasecmp(v->name, "rtpholdtimeout")) {
+ } } )
+ M_F("rtpholdtimeout", {
if ((sscanf(v->value, "%d", &global_rtpholdtimeout) != 1) || (global_rtpholdtimeout < 0)) {
ast_log(LOG_WARNING, "'%s' is not a valid RTP hold time at line %d. Using default.\n", v->value, v->lineno);
global_rtpholdtimeout = 0;
- }
- } else if (!strcasecmp(v->name, "rtpkeepalive")) {
+ } } )
+ M_F("rtpkeepalive", {
if ((sscanf(v->value, "%d", &global_rtpkeepalive) != 1) || (global_rtpkeepalive < 0)) {
ast_log(LOG_WARNING, "'%s' is not a valid RTP keepalive time at line %d. Using default.\n", v->value, v->lineno);
global_rtpkeepalive = 0;
- }
- } else if (!strcasecmp(v->name, "compactheaders")) {
- compactheaders = ast_true(v->value);
- } else if (!strcasecmp(v->name, "notifymimetype")) {
- ast_copy_string(default_notifymime, v->value, sizeof(default_notifymime));
- } else if (!strcasecmp(v->name, "notifyringing")) {
- global_notifyringing = ast_true(v->value);
- } else if (!strcasecmp(v->name, "limitpeersonly")) {
- global_limitonpeers = ast_true(v->value);
- } else if (!strcasecmp(v->name, "alwaysauthreject")) {
- global_alwaysauthreject = ast_true(v->value);
- } else if (!strcasecmp(v->name, "mohinterpret")
+ } } )
+ M_BOOL("compactheaders", compactheaders)
+ M_STR("notifymimetype", default_notifymime)
+ M_BOOL("notifyringing", global_notifyringing)
+ M_BOOL("limitpeersonly", global_limitonpeers)
+ M_BOOL("alwaysauthreject", global_alwaysauthreject)
+ if (!strcasecmp(v->name, "mohinterpret")
|| !strcasecmp(v->name, "musicclass") || !strcasecmp(v->name, "musiconhold")) {
ast_copy_string(default_mohinterpret, v->value, sizeof(default_mohinterpret));
- } else if (!strcasecmp(v->name, "mohsuggest")) {
- ast_copy_string(default_mohsuggest, v->value, sizeof(default_mohsuggest));
- } else if (!strcasecmp(v->name, "language")) {
- ast_copy_string(default_language, v->value, sizeof(default_language));
- } else if (!strcasecmp(v->name, "regcontext")) {
+ } else
+ M_STR("mohsuggest", default_mohsuggest)
+ M_STR("language", default_language)
+ M_F("regcontext", {
ast_copy_string(newcontexts, v->value, sizeof(newcontexts));
stringp = newcontexts;
/* Let's remove any contexts that are no longer defined in regcontext */
@@ -16556,27 +16537,21 @@
if (!ast_context_find(context))
ast_context_create(NULL, context,"SIP");
}
- ast_copy_string(global_regcontext, v->value, sizeof(global_regcontext));
- } else if (!strcasecmp(v->name, "callerid")) {
- ast_copy_string(default_callerid, v->value, sizeof(default_callerid));
- } else if (!strcasecmp(v->name, "fromdomain")) {
- ast_copy_string(default_fromdomain, v->value, sizeof(default_fromdomain));
- } else if (!strcasecmp(v->name, "outboundproxy")) {
+ ast_copy_string(global_regcontext, v->value, sizeof(global_regcontext)); } )
+ M_STR("callerid", default_callerid)
+ M_STR("fromdomain", default_fromdomain)
+ M_F("outboundproxy", {
if (ast_get_ip_or_srv(&outboundproxyip, v->value, global_srvlookup ? "_sip._udp" : NULL) < 0)
- ast_log(LOG_WARNING, "Unable to locate host '%s'\n", v->value);
- } else if (!strcasecmp(v->name, "outboundproxyport")) {
- /* Port needs to be after IP */
+ ast_log(LOG_WARNING, "Unable to locate host '%s'\n", v->value); } )
+ M_F("outboundproxyport", {
+ /* XXX Port needs to be after IP */
sscanf(v->value, "%d", &format);
- outboundproxyip.sin_port = htons(format);
- } else if (!strcasecmp(v->name, "autocreatepeer")) {
- autocreatepeer = ast_true(v->value);
- } else if (!strcasecmp(v->name, "match_auth_username")) {
- global_match_auth_username = ast_true(v->value);
- } else if (!strcasecmp(v->name, "global_srvlookup")) {
- global_srvlookup = ast_true(v->value);
- } else if (!strcasecmp(v->name, "pedantic")) {
- pedanticsipchecking = ast_true(v->value);
- } else if (!strcasecmp(v->name, "maxexpirey") || !strcasecmp(v->name, "maxexpiry")) {
+ outboundproxyip.sin_port = htons(format); } )
+ M_BOOL("autocreatepeer", autocreatepeer)
+ M_BOOL("match_auth_username", global_match_auth_username)
+ M_BOOL("global_srvlookup", global_srvlookup)
+ M_BOOL("pedantic", pedanticsipchecking)
+ if (!strcasecmp(v->name, "maxexpirey") || !strcasecmp(v->name, "maxexpiry")) {
max_expiry = atoi(v->value);
if (max_expiry < 1)
max_expiry = DEFAULT_MAX_EXPIRY;
@@ -16591,59 +16566,51 @@
} else if (!strcasecmp(v->name, "sipdebug")) { /* XXX maybe ast_set2_flags ? */
if (ast_true(v->value))
ast_set_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONFIG);
- } else if (!strcasecmp(v->name, "dumphistory")) {
- dumphistory = ast_true(v->value);
- } else if (!strcasecmp(v->name, "recordhistory")) {
- recordhistory = ast_true(v->value);
- } else if (!strcasecmp(v->name, "registertimeout")) {
+ } else
+ M_BOOL("dumphistory", dumphistory)
+ M_BOOL("recordhistory", recordhistory)
+ M_F("registertimeout", {
global_reg_timeout = atoi(v->value);
if (global_reg_timeout < 1)
- global_reg_timeout = DEFAULT_REGISTRATION_TIMEOUT;
- } else if (!strcasecmp(v->name, "registerattempts")) {
- global_regattempts_max = atoi(v->value);
- } else if (!strcasecmp(v->name, "bindaddr")) {
+ global_reg_timeout = DEFAULT_REGISTRATION_TIMEOUT; } )
+ M_F("registerattempts", global_regattempts_max = atoi(v->value);)
+ M_F("bindaddr", {
if (!(hp = ast_gethostbyname(v->value, &ahp))) {
ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
} else {
memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
- }
- } else if (!strcasecmp(v->name, "localnet")) {
+ } } )
+ M_F("localnet", {
struct ast_ha *na;
if (!(na = ast_append_ha("d", v->value, localaddr)))
ast_log(LOG_WARNING, "Invalid localnet value: %s\n", v->value);
else
- localaddr = na;
- } else if (!strcasecmp(v->name, "localmask")) {
- ast_log(LOG_WARNING, "Use of localmask is no long supported -- use localnet with mask syntax\n");
- } else if (!strcasecmp(v->name, "externip")) {
+ localaddr = na; } )
+ M_F("localmask", ast_log(LOG_WARNING, "Use of localmask is no long supported -- use localnet with mask syntax\n");)
+ M_F("externip", {
if (!(hp = ast_gethostbyname(v->value, &ahp)))
ast_log(LOG_WARNING, "Invalid address for externip keyword: %s\n", v->value);
else
memcpy(&externip.sin_addr, hp->h_addr, sizeof(externip.sin_addr));
- externexpire = 0;
- } else if (!strcasecmp(v->name, "externhost")) {
+ externexpire = 0; } )
+ M_F("externhost", {
ast_copy_string(externhost, v->value, sizeof(externhost));
if (!(hp = ast_gethostbyname(externhost, &ahp)))
ast_log(LOG_WARNING, "Invalid address for externhost keyword: %s\n", externhost);
else
memcpy(&externip.sin_addr, hp->h_addr, sizeof(externip.sin_addr));
- externexpire = time(NULL);
- } else if (!strcasecmp(v->name, "externrefresh")) {
+ externexpire = time(NULL); } )
+ M_F("externrefresh", {
if (sscanf(v->value, "%d", &externrefresh) != 1) {
ast_log(LOG_WARNING, "Invalid externrefresh value '%s', must be an integer >0 at line %d\n", v->value, v->lineno);
externrefresh = 10;
- }
- } else if (!strcasecmp(v->name, "allow")) {
- ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, 1);
- } else if (!strcasecmp(v->name, "disallow")) {
- ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, 0);
- } else if (!strcasecmp(v->name, "autoframing")) {
- global_autoframing = ast_true(v->value);
- } else if (!strcasecmp(v->name, "allowexternaldomains")) {
- allow_external_domains = ast_true(v->value);
- } else if (!strcasecmp(v->name, "autodomain")) {
- auto_sip_domains = ast_true(v->value);
- } else if (!strcasecmp(v->name, "domain")) {
+ } } )
+ M_F("allow", ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, 1);)
+ M_F("disallow", ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, 0);)
+ M_BOOL("autoframing", global_autoframing)
+ M_BOOL("allowexternaldomains", allow_external_domains)
+ M_BOOL("autodomain", auto_sip_domains)
+ M_F("domain", {
char *domain = ast_strdupa(v->value);
char *context = strchr(domain, ',');
@@ -16656,25 +16623,26 @@
ast_log(LOG_WARNING, "Empty domain specified at line %d\n", v->lineno);
else
add_sip_domain(ast_strip(domain), SIP_DOMAIN_CONFIG, context ? ast_strip(context) : "");
- } else if (!strcasecmp(v->name, "register")) {
+ } )
+ M_F("register", {
if (sip_register(v->value, v->lineno) == 0)
- registry_count++;
- } else if (!strcasecmp(v->name, "tos_sip")) {
+ registry_count++; } )
+ M_F("tos_sip", {
if (ast_str2tos(v->value, &global_tos_sip))
- ast_log(LOG_WARNING, "Invalid tos_sip value at line %d, recommended value is 'cs3'. See doc/ip-tos.txt.\n", v->lineno);
- } else if (!strcasecmp(v->name, "tos_audio")) {
+ ast_log(LOG_WARNING, "Invalid tos_sip value at line %d, recommended value is 'cs3'. See doc/ip-tos.txt.\n", v->lineno); } )
+ M_F("tos_audio", {
if (ast_str2tos(v->value, &global_tos_audio))
- ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, recommended value is 'ef'. See doc/ip-tos.txt.\n", v->lineno);
- } else if (!strcasecmp(v->name, "tos_video")) {
+ ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, recommended value is 'ef'. See doc/ip-tos.txt.\n", v->lineno); } )
+ M_F("tos_video", {
if (ast_str2tos(v->value, &global_tos_video))
- ast_log(LOG_WARNING, "Invalid tos_video value at line %d, recommended value is 'af41'. See doc/ip-tos.txt.\n", v->lineno);
- } else if (!strcasecmp(v->name, "bindport")) {
+ ast_log(LOG_WARNING, "Invalid tos_video value at line %d, recommended value is 'af41'. See doc/ip-tos.txt.\n", v->lineno); } )
+ M_F("bindport", {
if (sscanf(v->value, "%d", &ourport) == 1) {
bindaddr.sin_port = htons(ourport);
} else {
ast_log(LOG_WARNING, "Invalid port number '%s' at line %d of %s\n", v->value, v->lineno, config);
- }
- } else if (!strcasecmp(v->name, "qualify")) {
+ } } )
+ M_F("qualify", {
if (!strcasecmp(v->value, "no")) {
default_qualify = 0;
} else if (!strcasecmp(v->value, "yes")) {
@@ -16682,32 +16650,31 @@
} else if (sscanf(v->value, "%d", &default_qualify) != 1) {
ast_log(LOG_WARNING, "Qualification default should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", v->lineno);
default_qualify = 0;
- }
- } else if (!strcasecmp(v->name, "callevents")) {
- global_callevents = ast_true(v->value);
- } else if (!strcasecmp(v->name, "maxcallbitrate")) {
+ } } )
+ M_BOOL("callevents", global_callevents)
+ M_F("maxcallbitrate", {
default_maxcallbitrate = atoi(v->value);
if (default_maxcallbitrate < 0)
- default_maxcallbitrate = DEFAULT_MAX_CALL_BITRATE;
- } else if (!strcasecmp(v->name, "t38pt_udptl")) { /* XXX maybe ast_set2_flags ? */
+ default_maxcallbitrate = DEFAULT_MAX_CALL_BITRATE; } )
+ M_F("t38pt_udptl", { /* XXX maybe ast_set2_flags ? */
if (ast_true(v->value)) {
ast_set_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT_UDPTL);
- }
+ }} )
#ifdef WHEN_WE_HAVE_T38_FOR_OTHER_TRANSPORTS
- } else if (!strcasecmp(v->name, "t38pt_rtp")) { /* XXX maybe ast_set2_flags ? */
+ M_F("t38pt_rtp", { /* XXX maybe ast_set2_flags ? */
if (ast_true(v->value)) {
ast_set_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT_RTP);
- }
- } else if (!strcasecmp(v->name, "t38pt_tcp")) { /* XXX maybe ast_set2_flags ? */
+ } } )
+ M_F("t38pt_tcp", { /* XXX maybe ast_set2_flags ? */
if (ast_true(v->value)) {
ast_set_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT_TCP);
- }
+ } } )
#endif
- } else if (!strcasecmp(v->name, "rfc2833compensate")) { /* XXX maybe ast_set2_flags ? */
+ M_F("rfc2833compensate", { /* XXX maybe ast_set2_flags ? */
if (ast_true(v->value)) {
ast_set_flag(&global_flags[1], SIP_PAGE2_RFC2833_COMPENSATE);
- }
- }
+ } } )
+ M_END(/* */)
}
if (!allow_external_domains && AST_LIST_EMPTY(&domain_list)) {
More information about the asterisk-commits
mailing list