- applied patch from andreas, which allows certificate listing via stroke

This commit is contained in:
Martin Willi
2006-05-19 06:44:08 +00:00
parent 3e61d63a3a
commit 86a7937b45
17 changed files with 343 additions and 117 deletions
+26 -7
View File
@@ -26,6 +26,8 @@
#include "stroke.h"
#define streq(a, b) (strcmp((a), (b)) == 0) /* clearer shorthand */
static char* push_string(stroke_msg_t **strm, char *string)
{
stroke_msg_t *stroke_msg;
@@ -166,6 +168,18 @@ static int show_status(char *mode, char *connection)
return res;
}
static int list_certs(void)
{
stroke_msg_t *msg = malloc(sizeof(stroke_msg_t));
int res;
msg->length = sizeof(stroke_msg_t);
msg->type = STR_LIST_CERTS;
res = send_stroke_msg(msg);
free(msg);
return res;
}
static int set_logtype(char *context, char *type, int enable)
{
stroke_msg_t *msg = malloc(sizeof(stroke_msg_t));
@@ -233,6 +247,8 @@ static void exit_usage(char *error)
printf(" LEVEL is 0|1|2|3\n");
printf(" Show connection status:\n");
printf(" stroke status\n");
printf(" Show list of locally loaded certificates:\n");
printf(" stroke listcerts\n");
exit_error(error);
}
@@ -248,12 +264,15 @@ int main(int argc, char *argv[])
op = argv[1];
if (strcmp(op, "status") == 0 ||
strcmp(op, "statusall") == 0)
if (streq(op, "status") || streq(op, "statusall"))
{
res = show_status(op, argc > 2 ? argv[2] : NULL);
}
else if (strcmp(op, "up") == 0)
else if (streq(op, "listcerts") || streq(op, "listall"))
{
res = list_certs();
}
else if (streq(op, "up"))
{
if (argc < 3)
{
@@ -261,7 +280,7 @@ int main(int argc, char *argv[])
}
res = initiate_connection(argv[2]);
}
else if (strcmp(op, "down") == 0)
else if (streq(op, "down"))
{
if (argc < 3)
{
@@ -269,7 +288,7 @@ int main(int argc, char *argv[])
}
res = terminate_connection(argv[2]);
}
else if (strcmp(op, "add") == 0)
else if (streq(op, "add"))
{
if (argc < 11)
{
@@ -281,7 +300,7 @@ int main(int argc, char *argv[])
argv[7], argv[8],
atoi(argv[9]), atoi(argv[10]));
}
else if (strcmp(op, "logtype") == 0)
else if (streq(op, "logtype"))
{
if (argc < 5)
{
@@ -289,7 +308,7 @@ int main(int argc, char *argv[])
}
res = set_logtype(argv[2], argv[3], atoi(argv[4]));
}
else if (strcmp(op, "loglevel") == 0)
else if (streq(op, "loglevel"))
{
if (argc < 4)
{
+5
View File
@@ -37,6 +37,7 @@ typedef struct stroke_msg_t stroke_msg_t;
struct stroke_msg_t {
/* length of this message with all strings */
u_int16_t length;
/* type of the message */
enum {
/* initiate a connection */
@@ -57,8 +58,11 @@ struct stroke_msg_t {
STR_LOGTYPE,
/* set the verbosity of a logging context */
STR_LOGLEVEL,
/* show list of locally loaded certificates */
STR_LIST_CERTS
/* more to come */
} type;
union {
/* data for STR_INITIATE, STR_INSTALL, STR_UP, STR_DOWN */
struct {
@@ -85,6 +89,7 @@ struct stroke_msg_t {
u_int level;
} loglevel;
};
u_int8_t buffer[];
};