mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 06:48:25 +00:00
- Add error handling to ast_parse_allow_disallow
- Use this in chan_sip configuration parsing git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49093 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -15806,9 +15806,13 @@ static struct sip_user *build_user(const char *name, struct ast_variable *v, int
|
|||||||
user->amaflags = format;
|
user->amaflags = format;
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(v->name, "allow")) {
|
} else if (!strcasecmp(v->name, "allow")) {
|
||||||
ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, 1);
|
int error = ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, TRUE);
|
||||||
|
if (error)
|
||||||
|
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
|
||||||
} else if (!strcasecmp(v->name, "disallow")) {
|
} else if (!strcasecmp(v->name, "disallow")) {
|
||||||
ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, 0);
|
int error = ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, FALSE);
|
||||||
|
if (error)
|
||||||
|
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
|
||||||
} else if (!strcasecmp(v->name, "autoframing")) {
|
} else if (!strcasecmp(v->name, "autoframing")) {
|
||||||
user->autoframing = ast_true(v->value);
|
user->autoframing = ast_true(v->value);
|
||||||
} else if (!strcasecmp(v->name, "callingpres")) {
|
} else if (!strcasecmp(v->name, "callingpres")) {
|
||||||
@@ -16079,9 +16083,13 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
|
|||||||
} else if (!strcasecmp(v->name, "pickupgroup")) {
|
} else if (!strcasecmp(v->name, "pickupgroup")) {
|
||||||
peer->pickupgroup = ast_get_group(v->value);
|
peer->pickupgroup = ast_get_group(v->value);
|
||||||
} else if (!strcasecmp(v->name, "allow")) {
|
} else if (!strcasecmp(v->name, "allow")) {
|
||||||
ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, 1);
|
int error = ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, TRUE);
|
||||||
|
if (error)
|
||||||
|
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
|
||||||
} else if (!strcasecmp(v->name, "disallow")) {
|
} else if (!strcasecmp(v->name, "disallow")) {
|
||||||
ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, 0);
|
int error = ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, FALSE);
|
||||||
|
if (error)
|
||||||
|
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
|
||||||
} else if (!strcasecmp(v->name, "autoframing")) {
|
} else if (!strcasecmp(v->name, "autoframing")) {
|
||||||
peer->autoframing = ast_true(v->value);
|
peer->autoframing = ast_true(v->value);
|
||||||
} else if (!strcasecmp(v->name, "rtptimeout")) {
|
} else if (!strcasecmp(v->name, "rtptimeout")) {
|
||||||
@@ -16440,9 +16448,13 @@ static int reload_config(enum channelreloadreason reason)
|
|||||||
externrefresh = 10;
|
externrefresh = 10;
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(v->name, "allow")) {
|
} else if (!strcasecmp(v->name, "allow")) {
|
||||||
ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, 1);
|
int error = ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, TRUE);
|
||||||
|
if (error)
|
||||||
|
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
|
||||||
} else if (!strcasecmp(v->name, "disallow")) {
|
} else if (!strcasecmp(v->name, "disallow")) {
|
||||||
ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, 0);
|
int error = ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, FALSE);
|
||||||
|
if (error)
|
||||||
|
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
|
||||||
} else if (!strcasecmp(v->name, "autoframing")) {
|
} else if (!strcasecmp(v->name, "autoframing")) {
|
||||||
global_autoframing = ast_true(v->value);
|
global_autoframing = ast_true(v->value);
|
||||||
} else if (!strcasecmp(v->name, "allowexternaldomains")) {
|
} else if (!strcasecmp(v->name, "allowexternaldomains")) {
|
||||||
|
|||||||
@@ -533,8 +533,9 @@ struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int f
|
|||||||
/*! \brief Parse an "allow" or "deny" line in a channel or device configuration
|
/*! \brief Parse an "allow" or "deny" line in a channel or device configuration
|
||||||
and update the capabilities mask and pref if provided.
|
and update the capabilities mask and pref if provided.
|
||||||
Video codecs are not added to codec preference lists, since we can not transcode
|
Video codecs are not added to codec preference lists, since we can not transcode
|
||||||
|
\return Returns number of errors encountered during parsing
|
||||||
*/
|
*/
|
||||||
void ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing);
|
int ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing);
|
||||||
|
|
||||||
/*! \brief Dump audio codec preference list into a string */
|
/*! \brief Dump audio codec preference list into a string */
|
||||||
int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size);
|
int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size);
|
||||||
|
|||||||
10
main/frame.c
10
main/frame.c
@@ -1143,8 +1143,9 @@ int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
|
|||||||
return find_best ? ast_best_codec(formats) : 0;
|
return find_best ? ast_best_codec(formats) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing)
|
int ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing)
|
||||||
{
|
{
|
||||||
|
int errors = 0;
|
||||||
char *parse = NULL, *this = NULL, *psize = NULL;
|
char *parse = NULL, *this = NULL, *psize = NULL;
|
||||||
int format = 0, framems = 0;
|
int format = 0, framems = 0;
|
||||||
|
|
||||||
@@ -1156,11 +1157,15 @@ void ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char
|
|||||||
if (option_debug)
|
if (option_debug)
|
||||||
ast_log(LOG_DEBUG,"Packetization for codec: %s is %s\n", this, psize);
|
ast_log(LOG_DEBUG,"Packetization for codec: %s is %s\n", this, psize);
|
||||||
framems = atoi(psize);
|
framems = atoi(psize);
|
||||||
if (framems < 0)
|
if (framems < 0) {
|
||||||
framems = 0;
|
framems = 0;
|
||||||
|
errors++;
|
||||||
|
ast_log(LOG_WARNING, "Bad packetization value for codec %s\n", this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!(format = ast_getformatbyname(this))) {
|
if (!(format = ast_getformatbyname(this))) {
|
||||||
ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", allowing ? "allow" : "disallow", this);
|
ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", allowing ? "allow" : "disallow", this);
|
||||||
|
errors++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1187,6 +1192,7 @@ void ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int g723_len(unsigned char buf)
|
static int g723_len(unsigned char buf)
|
||||||
|
|||||||
Reference in New Issue
Block a user