[asterisk-commits] pabelanger: branch pabelanger/OverrideIAX2 r334428 - /team/pabelanger/Overrid...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Sep 3 12:16:19 CDT 2011
Author: pabelanger
Date: Sat Sep 3 12:16:08 2011
New Revision: 334428
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=334428
Log:
Coding guidelines first
Modified:
team/pabelanger/OverrideIAX2/channels/chan_iax2.c
Modified: team/pabelanger/OverrideIAX2/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/pabelanger/OverrideIAX2/channels/chan_iax2.c?view=diff&rev=334428&r1=334427&r2=334428
==============================================================================
--- team/pabelanger/OverrideIAX2/channels/chan_iax2.c (original)
+++ team/pabelanger/OverrideIAX2/channels/chan_iax2.c Sat Sep 3 12:16:08 2011
@@ -13047,8 +13047,9 @@
return -1;
} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
ucfg = ast_config_load("users.conf", config_flags);
- if (ucfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (ucfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ }
/* Otherwise we need to reread both files */
ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
if ((cfg = ast_config_load(config_file, config_flags)) == CONFIG_STATUS_FILEINVALID) {
@@ -13073,7 +13074,7 @@
}
/* Reset global codec prefs */
- memset(&prefs, 0 , sizeof(struct ast_codec_pref));
+ memset(&prefs, 0, sizeof(struct ast_codec_pref));
/* Reset Global Flags */
memset(&globalflags, 0, sizeof(globalflags));
@@ -13101,27 +13102,31 @@
/* Seed initial tos value */
tosval = ast_variable_retrieve(cfg, "general", "tos");
if (tosval) {
- if (ast_str2tos(tosval, &qos.tos))
+ if (ast_str2tos(tosval, &qos.tos)) {
ast_log(LOG_WARNING, "Invalid tos value, refer to QoS documentation\n");
+ }
}
/* Seed initial cos value */
tosval = ast_variable_retrieve(cfg, "general", "cos");
if (tosval) {
- if (ast_str2cos(tosval, &qos.cos))
+ if (ast_str2cos(tosval, &qos.cos)) {
ast_log(LOG_WARNING, "Invalid cos value, refer to QoS documentation\n");
+ }
}
while(v) {
- if (!strcasecmp(v->name, "bindport")){
- if (reload)
+ if (!strcasecmp(v->name, "bindport")) {
+ if (reload) {
ast_log(LOG_NOTICE, "Ignoring bindport on reload\n");
- else
+ } else {
portno = atoi(v->value);
- } else if (!strcasecmp(v->name, "pingtime"))
+ }
+ } else if (!strcasecmp(v->name, "pingtime")) {
ping_time = atoi(v->value);
- else if (!strcasecmp(v->name, "iaxthreadcount")) {
+ } else if (!strcasecmp(v->name, "iaxthreadcount")) {
if (reload) {
- if (atoi(v->value) != iaxthreadcount)
+ if (atoi(v->value) != iaxthreadcount) {
ast_log(LOG_NOTICE, "Ignoring any changes to iaxthreadcount during reload\n");
+ }
} else {
iaxthreadcount = atoi(v->value);
if (iaxthreadcount < 1) {
@@ -13149,42 +13154,45 @@
}
} else if (!strcasecmp(v->name, "nochecksums")) {
#ifdef SO_NO_CHECK
- if (ast_true(v->value))
+ if (ast_true(v->value)) {
nochecksums = 1;
- else
+ } else {
nochecksums = 0;
+ }
#else
- if (ast_true(v->value))
+ if (ast_true(v->value)) {
ast_log(LOG_WARNING, "Disabling RTP checksums is not supported on this operating system!\n");
+ }
#endif
- }
- else if (!strcasecmp(v->name, "maxjitterbuffer"))
+ } else if (!strcasecmp(v->name, "maxjitterbuffer")) {
maxjitterbuffer = atoi(v->value);
- else if (!strcasecmp(v->name, "resyncthreshold"))
+ } else if (!strcasecmp(v->name, "resyncthreshold")) {
resyncthreshold = atoi(v->value);
- else if (!strcasecmp(v->name, "maxjitterinterps"))
+ } else if (!strcasecmp(v->name, "maxjitterinterps")) {
maxjitterinterps = atoi(v->value);
- else if (!strcasecmp(v->name, "jittertargetextra"))
+ } else if (!strcasecmp(v->name, "jittertargetextra")) {
jittertargetextra = atoi(v->value);
- else if (!strcasecmp(v->name, "lagrqtime"))
+ } else if (!strcasecmp(v->name, "lagrqtime")) {
lagrq_time = atoi(v->value);
- else if (!strcasecmp(v->name, "maxregexpire"))
+ } else if (!strcasecmp(v->name, "maxregexpire")) {
max_reg_expire = atoi(v->value);
- else if (!strcasecmp(v->name, "minregexpire"))
+ } else if (!strcasecmp(v->name, "minregexpire")) {
min_reg_expire = atoi(v->value);
- else if (!strcasecmp(v->name, "bindaddr")) {
+ } else if (!strcasecmp(v->name, "bindaddr")) {
if (reload) {
ast_log(LOG_NOTICE, "Ignoring bindaddr on reload\n");
} else {
if (!(ns = ast_netsock_bind(netsock, io, v->value, portno, qos.tos, qos.cos, socket_read, NULL))) {
ast_log(LOG_WARNING, "Unable apply binding to '%s' at line %d\n", v->value, v->lineno);
} else {
- if (strchr(v->value, ':'))
+ if (strchr(v->value, ':')) {
ast_verb(2, "Binding IAX2 to '%s'\n", v->value);
- else
+ } else {
ast_verb(2, "Binding IAX2 to '%s:%d'\n", v->value, portno);
- if (defaultsockfd < 0)
+ }
+ if (defaultsockfd < 0) {
defaultsockfd = ast_netsock_sockfd(ns);
+ }
ast_netsock_unref(ns);
}
}
@@ -13209,65 +13217,71 @@
ast_set_flags_to64((&globalflags), IAX_NOTRANSFER|IAX_TRANSFERMEDIA, IAX_TRANSFERMEDIA);
} else if (ast_true(v->value)) {
ast_set_flags_to64((&globalflags), IAX_NOTRANSFER|IAX_TRANSFERMEDIA, 0);
- } else
+ } else {
ast_set_flags_to64((&globalflags), IAX_NOTRANSFER|IAX_TRANSFERMEDIA, IAX_NOTRANSFER);
+ }
} else if (!strcasecmp(v->name, "codecpriority")) {
- if(!strcasecmp(v->value, "caller"))
+ if (!strcasecmp(v->value, "caller")) {
ast_set_flag64((&globalflags), IAX_CODEC_USER_FIRST);
- else if(!strcasecmp(v->value, "disabled"))
+ } else if (!strcasecmp(v->value, "disabled")) {
ast_set_flag64((&globalflags), IAX_CODEC_NOPREFS);
- else if(!strcasecmp(v->value, "reqonly")) {
+ } else if (!strcasecmp(v->value, "reqonly")) {
ast_set_flag64((&globalflags), IAX_CODEC_NOCAP);
ast_set_flag64((&globalflags), IAX_CODEC_NOPREFS);
}
- } else if (!strcasecmp(v->name, "jitterbuffer"))
+ } else if (!strcasecmp(v->name, "jitterbuffer")) {
ast_set2_flag64((&globalflags), ast_true(v->value), IAX_USEJITTERBUF);
- else if (!strcasecmp(v->name, "forcejitterbuffer"))
+ } else if (!strcasecmp(v->name, "forcejitterbuffer")) {
ast_set2_flag64((&globalflags), ast_true(v->value), IAX_FORCEJITTERBUF);
- else if (!strcasecmp(v->name, "delayreject"))
+ } else if (!strcasecmp(v->name, "delayreject")) {
delayreject = ast_true(v->value);
- else if (!strcasecmp(v->name, "allowfwdownload"))
+ } else if (!strcasecmp(v->name, "allowfwdownload")) {
ast_set2_flag64((&globalflags), ast_true(v->value), IAX_ALLOWFWDOWNLOAD);
- else if (!strcasecmp(v->name, "rtcachefriends"))
+ } else if (!strcasecmp(v->name, "rtcachefriends")) {
ast_set2_flag64((&globalflags), ast_true(v->value), IAX_RTCACHEFRIENDS);
- else if (!strcasecmp(v->name, "rtignoreregexpire"))
+ } else if (!strcasecmp(v->name, "rtignoreregexpire")) {
ast_set2_flag64((&globalflags), ast_true(v->value), IAX_RTIGNOREREGEXPIRE);
- else if (!strcasecmp(v->name, "rtupdate"))
+ } else if (!strcasecmp(v->name, "rtupdate")) {
ast_set2_flag64((&globalflags), ast_true(v->value), IAX_RTUPDATE);
- else if (!strcasecmp(v->name, "rtsavesysname"))
+ } else if (!strcasecmp(v->name, "rtsavesysname")) {
ast_set2_flag64((&globalflags), ast_true(v->value), IAX_RTSAVE_SYSNAME);
- else if (!strcasecmp(v->name, "trunktimestamps"))
+ } else if (!strcasecmp(v->name, "trunktimestamps")) {
ast_set2_flag64(&globalflags, ast_true(v->value), IAX_TRUNKTIMESTAMPS);
- else if (!strcasecmp(v->name, "rtautoclear")) {
+ } else if (!strcasecmp(v->name, "rtautoclear")) {
int i = atoi(v->value);
- if(i > 0)
+ if (i > 0) {
global_rtautoclear = i;
- else
+ } else {
i = 0;
+ }
ast_set2_flag64((&globalflags), i || ast_true(v->value), IAX_RTAUTOCLEAR);
} else if (!strcasecmp(v->name, "trunkfreq")) {
trunkfreq = atoi(v->value);
- if (trunkfreq < 10)
+ if (trunkfreq < 10) {
trunkfreq = 10;
+ }
} else if (!strcasecmp(v->name, "trunkmtu")) {
mtuv = atoi(v->value);
- if (mtuv == 0 )
+ if (mtuv == 0 ) {
global_max_trunk_mtu = 0;
- else if (mtuv >= 172 && mtuv < 4000)
+ } else if (mtuv >= 172 && mtuv < 4000) {
global_max_trunk_mtu = mtuv;
- else
+ } else {
ast_log(LOG_NOTICE, "trunkmtu value out of bounds (%d) at line %d\n",
mtuv, v->lineno);
+ }
} else if (!strcasecmp(v->name, "trunkmaxsize")) {
trunkmaxsize = atoi(v->value);
- if (trunkmaxsize == 0)
+ if (trunkmaxsize == 0) {
trunkmaxsize = MAX_TRUNKDATA;
+ }
} else if (!strcasecmp(v->name, "autokill")) {
if (sscanf(v->value, "%30d", &x) == 1) {
- if (x >= 0)
+ if (x >= 0) {
autokill = x;
- else
+ } else {
ast_log(LOG_NOTICE, "Nice try, but autokill has to be >0 or 'yes' or 'no' at line %d\n", v->lineno);
+ }
} else if (ast_true(v->value)) {
autokill = DEFAULT_MAXMS;
} else {
@@ -13280,8 +13294,9 @@
capability = IAX_CAPABILITY_MEDBANDWIDTH;
} else if (!strcasecmp(v->value, "high")) {
capability = IAX_CAPABILITY_FULLBANDWIDTH;
- } else
+ } else {
ast_log(LOG_WARNING, "bandwidth must be either low, medium, or high\n");
+ }
} else if (!strcasecmp(v->name, "allow")) {
iax2_parse_allow_disallow(&prefs, &capability, v->value, 1);
} else if (!strcasecmp(v->name, "disallow")) {
@@ -13298,8 +13313,9 @@
if (ast_str2tos(v->value, &qos.tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos")) {
- if (ast_str2cos(v->value, &qos.cos))
+ if (ast_str2cos(v->value, &qos.cos)) {
ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno);
+ }
} else if (!strcasecmp(v->name, "parkinglot")) {
ast_copy_string(default_parkinglot, v->value, sizeof(default_parkinglot));
} else if (!strcasecmp(v->name, "accountcode")) {
@@ -13319,8 +13335,9 @@
ast_copy_string(language, v->value, sizeof(language));
} else if (!strcasecmp(v->name, "maxauthreq")) {
maxauthreq = atoi(v->value);
- if (maxauthreq < 0)
+ if (maxauthreq < 0) {
maxauthreq = 0;
+ }
} else if (!strcasecmp(v->name, "adsi")) {
adsi = ast_true(v->value);
} else if (!strcasecmp(v->name, "srvlookup")) {
@@ -13401,13 +13418,13 @@
min_reg_expire = max_reg_expire;
}
iax2_capability = capability;
-
+
if (ucfg) {
struct ast_variable *gen;
int genhasiax;
int genregisteriax;
const char *hasiax, *registeriax;
-
+
genhasiax = ast_true(ast_variable_retrieve(ucfg, "general", "hasiax"));
genregisteriax = ast_true(ast_variable_retrieve(ucfg, "general", "registeriax"));
gen = ast_variable_browse(ucfg, "general");
@@ -13425,8 +13442,9 @@
}
peer = build_peer(cat, gen, ast_variable_browse(ucfg, cat), 0);
if (peer) {
- if (ast_test_flag64(peer, IAX_DYNAMIC))
+ if (ast_test_flag64(peer, IAX_DYNAMIC)) {
reg_source_db(peer);
+ }
ao2_link(peers, peer);
peer = peer_unref(peer);
}
@@ -13436,17 +13454,21 @@
const char *host = ast_variable_retrieve(ucfg, cat, "host");
const char *username = ast_variable_retrieve(ucfg, cat, "username");
const char *secret = ast_variable_retrieve(ucfg, cat, "secret");
- if (!host)
+ if (!host) {
host = ast_variable_retrieve(ucfg, "general", "host");
- if (!username)
+ }
+ if (!username) {
username = ast_variable_retrieve(ucfg, "general", "username");
- if (!secret)
+ }
+ if (!secret) {
secret = ast_variable_retrieve(ucfg, "general", "secret");
+ }
if (!ast_strlen_zero(username) && !ast_strlen_zero(host)) {
- if (!ast_strlen_zero(secret))
+ if (!ast_strlen_zero(secret)) {
snprintf(tmp, sizeof(tmp), "%s:%s@%s", username, secret, host);
- else
+ } else {
snprintf(tmp, sizeof(tmp), "%s@%s", username, host);
+ }
iax2_register(tmp, 0);
}
}
@@ -13455,9 +13477,9 @@
}
ast_config_destroy(ucfg);
}
-
+
cat = ast_category_browse(cfg, NULL);
- while(cat) {
+ while (cat) {
if (strcasecmp(cat, "general")) {
utype = ast_variable_retrieve(cfg, cat, "type");
if (!strcasecmp(cat, "callnumberlimits")) {
@@ -13473,16 +13495,18 @@
if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
peer = build_peer(cat, ast_variable_browse(cfg, cat), NULL, 0);
if (peer) {
- if (ast_test_flag64(peer, IAX_DYNAMIC))
+ if (ast_test_flag64(peer, IAX_DYNAMIC)) {
reg_source_db(peer);
+ }
ao2_link(peers, peer);
peer = peer_unref(peer);
}
} else if (strcasecmp(utype, "user")) {
ast_log(LOG_WARNING, "Unknown type '%s' for '%s' in %s\n", utype, cat, config_file);
}
- } else
+ } else {
ast_log(LOG_WARNING, "Section '%s' lacks type\n", cat);
+ }
}
cat = ast_category_browse(cfg, cat);
}
More information about the asterisk-commits
mailing list