diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2013-03-13 18:43:33 +0100 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2013-03-15 23:59:32 +0400 |
commit | b2841e642d10ca80a8f3ec2b3aca9dd0ec1cf064 (patch) | |
tree | 213a04f77a217fa68891e19db965f647ac6d0e4b /accel-pppd/ctrl/l2tp | |
parent | 58eb38dd629db88d8ce0e321cbf4ba0e7ead206b (diff) | |
download | accel-ppp-b2841e642d10ca80a8f3ec2b3aca9dd0ec1cf064.tar.gz accel-ppp-b2841e642d10ca80a8f3ec2b3aca9dd0ec1cf064.zip |
l2tp: Display error message when session creation fails (CLI)
Print details about errors that can occur when using the
"l2tp create session" command line.
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd/ctrl/l2tp')
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 43c985ad..2f6a1fca 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -3283,25 +3283,39 @@ static int l2tp_create_session_exec(const char *cmd, char * const *fields, long int tid; int res; - if (fields_cnt != 5) + if (fields_cnt != 5) { + cli_send(client, "invalid number of arguments\r\n"); return CLI_CMD_SYNTAX; + } - if (strcmp("tid", fields[3]) != 0) + if (strcmp("tid", fields[3]) != 0) { + cli_sendv(client, "invalid option: \"%s\"\r\n", fields[3]); return CLI_CMD_SYNTAX; + } - if (u_readlong(&tid, fields[4], 1, L2TP_MAX_TID - 1) < 0) + if (u_readlong(&tid, fields[4], 1, L2TP_MAX_TID - 1) < 0) { + cli_sendv(client, "invalid Tunnel ID: \"%s\"\r\n", fields[4]); return CLI_CMD_INVAL; + } pthread_mutex_lock(&l2tp_lock); conn = l2tp_conn[tid]; if (conn) { - triton_context_call(&conn->ctx, - l2tp_tunnel_create_session, conn); - res = CLI_CMD_OK; - } else + if (triton_context_call(&conn->ctx, l2tp_tunnel_create_session, + conn) < 0) + res = CLI_CMD_FAILED; + else + res = CLI_CMD_OK; + } else { res = CLI_CMD_INVAL; + } pthread_mutex_unlock(&l2tp_lock); + if (res == CLI_CMD_FAILED) + cli_send(client, "session creation failed\r\n"); + else if (res == CLI_CMD_INVAL) + cli_sendv(client, "tunnel %li not found\r\n", tid); + return res; } |