Browse Source

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

Alexander von Gluck IV 10 years ago
parent
commit
cea41ed409
2 changed files with 19 additions and 12 deletions
  1. 18
    11
      src/ntk-console-server.c
  2. 1
    1
      src/ntk-console.c

+ 18
- 11
src/ntk-console-server.c View File

@@ -94,41 +94,48 @@ send_response(int session_fd, char response[CONSOLE_BUFFER_LENGTH], ...)
94 94
 static void
95 95
 request_processing(int session_fd, cmd_packet_t packet)
96 96
 {
97
+	char buffer[CONSOLE_BUFFER_LENGTH];
98
+	int maxBuffer = CONSOLE_BUFFER_LENGTH - 1;
99
+
97 100
 	switch (packet.command) {
98 101
 		case COMMAND_UPTIME:
99
-			send_response(session_fd, (char)time(0)-me.uptime);
102
+		{
103
+			int uptime = time(0) - me.uptime;
104
+			snprintf(buffer, maxBuffer, "node uptime: %d seconds", uptime);
100 105
 			break;
106
+		}
101 107
 		case COMMAND_VERSION:
102
-			send_response(session_fd, VERSION_STR);
108
+			snprintf(buffer, maxBuffer, "ntkd version: %s", VERSION_STR);
103 109
 			break;
104 110
 		case COMMAND_CURIFS:
105
-			send_response(session_fd, (char)me.cur_ifs);
111
+			//send_response(session_fd, (char)me.cur_ifs);
106 112
 			break;
107 113
 		case COMMAND_CURIFSCT:
108
-			send_response(session_fd, (char)me.cur_ifs_n);
114
+			snprintf(buffer, maxBuffer, "current interface count: %d", me.cur_ifs_n);
109 115
 			break;
110 116
 		case COMMAND_INETCONN:
111
-			send_response(session_fd, (char)me.inet_connected);
117
+			//send_response(session_fd, (char)me.inet_connected);
112 118
 			break;
113 119
 		case COMMAND_CURQSPNID:
114
-			send_response(session_fd, (char)me.cur_qspn_id);
120
+			//send_response(session_fd, (char)me.cur_qspn_id);
115 121
 			break;
116 122
 		case COMMAND_CURIP:
117
-			send_response(session_fd, (char)me.cur_ip.data);
123
+			//send_response(session_fd, (char)me.cur_ip.data);
118 124
 			break;
119 125
 		case COMMAND_CURNODE:
120
-			send_response(session_fd, (char)me.cur_node);
126
+			//send_response(session_fd, (char)me.cur_node);
121 127
 			break;
122 128
 		case COMMAND_IFS:
123
-			send_response(session_fd, "IFS: TODO");
129
+			//send_response(session_fd, "IFS: TODO");
124 130
 			break;
125 131
 		case COMMAND_IFSCT:
126
-			send_response(session_fd, "IFS: TODO");
132
+			//send_response(session_fd, "IFS: TODO");
127 133
 			break;
128 134
 		default:
129
-			send_response(session_fd, "Provided command is invalid or yet to be implemented.");
135
+			snprintf(buffer, maxBuffer, "Provided command is invalid or not implemented in this API");
130 136
 			break;
131 137
 	}
138
+	send_response(session_fd, buffer);
132 139
 }
133 140
 
134 141
 

+ 1
- 1
src/ntk-console.c View File

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

Loading…
Cancel
Save