aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_crypto.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-11 19:03:06 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-11 19:03:06 +0000
commit13b9c5237c9f5b8b3d72634d575665b1d1147ba3 (patch)
tree44dcb2c14abed6932db4f248b17626a01a38f59b /res/res_crypto.c
parenta8506328befc2a11643cea88772609610ec11c33 (diff)
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :)
(closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@85460 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_crypto.c')
-rw-r--r--res/res_crypto.c64
1 files changed, 41 insertions, 23 deletions
diff --git a/res/res_crypto.c b/res/res_crypto.c
index 65c5b768d..b0b34bd7c 100644
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -499,27 +499,43 @@ static void md52sum(char *sum, unsigned char *md5)
* \param argv list of arguements
* \return RESULT_SUCCESS
*/
-static int show_keys(int fd, int argc, char *argv[])
+static char *handle_cli_keys_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
+#define FORMAT "%-18s %-8s %-16s %-33s\n"
+
struct ast_key *key;
char sum[16 * 2 + 1];
int count_keys = 0;
- ast_cli(fd, "%-18s %-8s %-16s %-33s\n", "Key Name", "Type", "Status", "Sum");
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "keys show";
+ e->usage =
+ "Usage: keys show\n"
+ " Displays information about RSA keys known by Asterisk\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ ast_cli(a->fd, FORMAT, "Key Name", "Type", "Status", "Sum");
+ ast_cli(a->fd, FORMAT, "------------------", "--------", "----------------", "--------------------------------");
AST_RWLIST_RDLOCK(&keys);
AST_RWLIST_TRAVERSE(&keys, key, list) {
md52sum(sum, key->digest);
- ast_cli(fd, "%-18s %-8s %-16s %-33s\n", key->name,
+ ast_cli(a->fd, FORMAT, key->name,
(key->ktype & 0xf) == AST_KEY_PUBLIC ? "PUBLIC" : "PRIVATE",
key->ktype & KEY_NEEDS_PASSCODE ? "[Needs Passcode]" : "[Loaded]", sum);
count_keys++;
}
AST_RWLIST_UNLOCK(&keys);
- ast_cli(fd, "%d known RSA keys.\n", count_keys);
+ ast_cli(a->fd, "\n%d known RSA keys.\n", count_keys);
+
+ return CLI_SUCCESS;
- return RESULT_SUCCESS;
+#undef FORMAT
}
/*!
@@ -529,43 +545,45 @@ static int show_keys(int fd, int argc, char *argv[])
* \param argv list of arguements
* \return RESULT_SUCCESS
*/
-static int init_keys(int fd, int argc, char *argv[])
+static char *handle_cli_keys_init(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ast_key *key;
int ign;
char *kn, tmp[256] = "";
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "keys init";
+ e->usage =
+ "Usage: keys init\n"
+ " Initializes private keys (by reading in pass code from\n"
+ " the user)\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 2)
+ return CLI_SHOWUSAGE;
+
AST_RWLIST_WRLOCK(&keys);
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&keys, key, list) {
/* Reload keys that need pass codes now */
if (key->ktype & KEY_NEEDS_PASSCODE) {
kn = key->fn + strlen(ast_config_AST_KEY_DIR) + 1;
ast_copy_string(tmp, kn, sizeof(tmp));
- try_load_key((char *)ast_config_AST_KEY_DIR, tmp, fd, fd, &ign);
+ try_load_key((char *) ast_config_AST_KEY_DIR, tmp, a->fd, a->fd, &ign);
}
}
AST_RWLIST_TRAVERSE_SAFE_END
AST_RWLIST_UNLOCK(&keys);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static const char show_key_usage[] =
-"Usage: keys show\n"
-" Displays information about RSA keys known by Asterisk\n";
-
-static const char init_keys_usage[] =
-"Usage: keys init\n"
-" Initializes private keys (by reading in pass code from the user)\n";
-
static struct ast_cli_entry cli_crypto[] = {
- { { "keys", "show", NULL },
- show_keys, "Displays RSA key information",
- show_key_usage },
-
- { { "keys", "init", NULL },
- init_keys, "Initialize RSA key passcodes",
- init_keys_usage },
+ NEW_CLI(handle_cli_keys_show, "Displays RSA key information"),
+ NEW_CLI(handle_cli_keys_init, "Initialize RSA key passcodes")
};
/*! \brief initialise the res_crypto module */