|
|
|
@ -1370,6 +1370,51 @@ static char *builtin_function_regex(struct ast_channel *chan, char *cmd, char *d
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *builtin_function_md5(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
|
|
|
|
{
|
|
|
|
|
char md5[33];
|
|
|
|
|
|
|
|
|
|
if (!data || ast_strlen_zero(data)) {
|
|
|
|
|
ast_log(LOG_WARNING, "Syntax: MD5(<data>) - missing argument!\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ast_md5_hash(md5, data);
|
|
|
|
|
ast_copy_string(buf, md5, len);
|
|
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *builtin_function_checkmd5(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
|
|
|
|
{
|
|
|
|
|
int argc;
|
|
|
|
|
char *argv[2];
|
|
|
|
|
char *args;
|
|
|
|
|
char newmd5[33];
|
|
|
|
|
|
|
|
|
|
if (!data || ast_strlen_zero(data)) {
|
|
|
|
|
ast_log(LOG_WARNING, "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
args = ast_strdupa(data);
|
|
|
|
|
argc = ast_separate_app_args(args, '|', argv, sizeof(argv) / sizeof(argv[0]));
|
|
|
|
|
|
|
|
|
|
if (argc < 2) {
|
|
|
|
|
ast_log(LOG_WARNING, "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ast_md5_hash(newmd5, argv[1]);
|
|
|
|
|
|
|
|
|
|
if (!strcasecmp(newmd5, argv[0])) /* they match */
|
|
|
|
|
ast_copy_string(buf, "1", len);
|
|
|
|
|
else
|
|
|
|
|
ast_copy_string(buf, "0", len);
|
|
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void pbx_substitute_variables_helper_full(struct ast_channel *c, const char *cp1, char *cp2, int count, struct varshead *headp)
|
|
|
|
|
{
|
|
|
|
|
char *cp4;
|
|
|
|
@ -3554,6 +3599,21 @@ static struct ast_custom_function_obj cdr_function = {
|
|
|
|
|
.write = builtin_function_cdr_write,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static struct ast_custom_function_obj md5_function = {
|
|
|
|
|
.name = "MD5",
|
|
|
|
|
.desc = "Computes an MD5 digest",
|
|
|
|
|
.syntax = "MD5(<data>)",
|
|
|
|
|
.read = builtin_function_md5,
|
|
|
|
|
.write = NULL,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static struct ast_custom_function_obj checkmd5_function = {
|
|
|
|
|
.name = "CHECK_MD5",
|
|
|
|
|
.desc = "Checks an MD5 digest. Returns 1 on a match, 0 otherwise",
|
|
|
|
|
.syntax = "CHECK_MD5(<digest>,<data>)",
|
|
|
|
|
.read = builtin_function_checkmd5,
|
|
|
|
|
.write = NULL,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* CLI entries for upper commands ...
|
|
|
|
@ -6000,6 +6060,8 @@ int load_pbx(void)
|
|
|
|
|
ast_custom_function_register(&env_function);
|
|
|
|
|
ast_custom_function_register(&len_function);
|
|
|
|
|
ast_custom_function_register(&cdr_function);
|
|
|
|
|
ast_custom_function_register(&md5_function);
|
|
|
|
|
ast_custom_function_register(&checkmd5_function);
|
|
|
|
|
|
|
|
|
|
/* Register builtin applications */
|
|
|
|
|
for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) {
|
|
|
|
|