ntk-console: Begin returning valid results in ntk-console-server

This commit is contained in:
Alexander von Gluck IV 2014-09-15 18:06:26 -05:00
parent 2694b1cda4
commit cea41ed409
2 changed files with 19 additions and 12 deletions

View File

@ -94,41 +94,48 @@ send_response(int session_fd, char response[CONSOLE_BUFFER_LENGTH], ...)
static void
request_processing(int session_fd, cmd_packet_t packet)
{
char buffer[CONSOLE_BUFFER_LENGTH];
int maxBuffer = CONSOLE_BUFFER_LENGTH - 1;
switch (packet.command) {
case COMMAND_UPTIME:
send_response(session_fd, (char)time(0)-me.uptime);
break;
case COMMAND_VERSION:
send_response(session_fd, VERSION_STR);
break;
case COMMAND_CURIFS:
send_response(session_fd, (char)me.cur_ifs);
break;
case COMMAND_CURIFSCT:
send_response(session_fd, (char)me.cur_ifs_n);
break;
case COMMAND_INETCONN:
send_response(session_fd, (char)me.inet_connected);
break;
case COMMAND_CURQSPNID:
send_response(session_fd, (char)me.cur_qspn_id);
break;
case COMMAND_CURIP:
send_response(session_fd, (char)me.cur_ip.data);
break;
case COMMAND_CURNODE:
send_response(session_fd, (char)me.cur_node);
break;
case COMMAND_IFS:
send_response(session_fd, "IFS: TODO");
break;
case COMMAND_IFSCT:
send_response(session_fd, "IFS: TODO");
break;
default:
send_response(session_fd, "Provided command is invalid or yet to be implemented.");
{
int uptime = time(0) - me.uptime;
snprintf(buffer, maxBuffer, "node uptime: %d seconds", uptime);
break;
}
case COMMAND_VERSION:
snprintf(buffer, maxBuffer, "ntkd version: %s", VERSION_STR);
break;
case COMMAND_CURIFS:
//send_response(session_fd, (char)me.cur_ifs);
break;
case COMMAND_CURIFSCT:
snprintf(buffer, maxBuffer, "current interface count: %d", me.cur_ifs_n);
break;
case COMMAND_INETCONN:
//send_response(session_fd, (char)me.inet_connected);
break;
case COMMAND_CURQSPNID:
//send_response(session_fd, (char)me.cur_qspn_id);
break;
case COMMAND_CURIP:
//send_response(session_fd, (char)me.cur_ip.data);
break;
case COMMAND_CURNODE:
//send_response(session_fd, (char)me.cur_node);
break;
case COMMAND_IFS:
//send_response(session_fd, "IFS: TODO");
break;
case COMMAND_IFSCT:
//send_response(session_fd, "IFS: TODO");
break;
default:
snprintf(buffer, maxBuffer, "Provided command is invalid or not implemented in this API");
break;
}
send_response(session_fd, buffer);
}

View File

@ -158,7 +158,7 @@ ntkd_request(command_t command)
exit(-1);
}
printf("Response: '%s'\n", response);
printf("%s\n", response);
free(response);
closesocket();
}