|
@@ -145,33 +145,37 @@ static void *server_worker(void* vArgs)
|
|
|
|
|
|
cli_state_t *cli_state;
|
|
|
// create the new CLI context
|
|
|
- if (ret == WS_SUCCESS && (cli_state = alloc_state())) {
|
|
|
- cli_state->num_connect = threadCtx->ssh;
|
|
|
- cli_state->input_state = CLI_CMD;
|
|
|
- cli_state->send = cli_send;
|
|
|
- cli_hello(cli_state);
|
|
|
-
|
|
|
- bool stop = false;
|
|
|
- do {
|
|
|
- uint8_t buf[EXAMPLE_BUFFER_SZ];
|
|
|
- int rxSz = 0;
|
|
|
+ if (ret == WS_SUCCESS) {
|
|
|
+ if ((cli_state = alloc_state())) {
|
|
|
+ cli_state->num_connect = threadCtx->ssh;
|
|
|
+ cli_state->input_state = CLI_CMD;
|
|
|
+ cli_state->send = cli_send;
|
|
|
+ cli_hello(cli_state);
|
|
|
+
|
|
|
+ bool stop = false;
|
|
|
do {
|
|
|
- rxSz = wolfSSH_stream_read(threadCtx->ssh, buf, sizeof(buf));
|
|
|
- if (rxSz <= 0) {
|
|
|
- rxSz = wolfSSH_get_error(threadCtx->ssh);
|
|
|
- }
|
|
|
- } while (rxSz == WS_WANT_READ || rxSz == WS_WANT_WRITE);
|
|
|
-
|
|
|
- if (rxSz > 0) {
|
|
|
- cli_getchar(cli_state, buf[0]); // TODO handle rxSz > 1
|
|
|
- if (buf[0] == 3 || buf[0] == 4 || cli_state->state == STATE_CLOSE) {
|
|
|
+ uint8_t buf[EXAMPLE_BUFFER_SZ];
|
|
|
+ int rxSz = 0;
|
|
|
+ do {
|
|
|
+ rxSz = wolfSSH_stream_read(threadCtx->ssh, buf, sizeof(buf));
|
|
|
+ if (rxSz <= 0) {
|
|
|
+ rxSz = wolfSSH_get_error(threadCtx->ssh);
|
|
|
+ }
|
|
|
+ } while (rxSz == WS_WANT_READ || rxSz == WS_WANT_WRITE);
|
|
|
+
|
|
|
+ if (rxSz > 0) {
|
|
|
+ cli_getchar(cli_state, buf[0]); // TODO handle rxSz > 1
|
|
|
+ if (buf[0] == 3 || buf[0] == 4 || cli_state->state == STATE_CLOSE) {
|
|
|
+ stop = 1;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
stop = 1;
|
|
|
}
|
|
|
- } else {
|
|
|
- stop = 1;
|
|
|
- }
|
|
|
- } while (!stop);
|
|
|
- free_state(cli_state);
|
|
|
+ } while (!stop);
|
|
|
+ free_state(cli_state);
|
|
|
+ } else {
|
|
|
+ cli_send(threadCtx->ssh, pcWarningMessage, pcWarningMessageLen);
|
|
|
+ }
|
|
|
} else if (ret == WS_SCP_COMPLETE) {
|
|
|
printf("scp file transfer completed\n");
|
|
|
} else if (ret == WS_SFTP_COMPLETE) {
|