|
@@ -156,7 +156,6 @@
|
|
|
* A telnet connection structure.
|
|
|
*/
|
|
|
typedef struct{
|
|
|
- TimerHandle_t RepeatSensorInfoTimer;
|
|
|
uint8_t state;
|
|
|
uint8_t code;
|
|
|
char buf[cmdMAX_INPUT_SIZE];
|
|
@@ -258,12 +257,12 @@ void parseopt(telnetd_state_t *ts, uint8_t code, uint8_t option)
|
|
|
break;
|
|
|
|
|
|
case TELOPT_TIMING_MARK:
|
|
|
- xTimerStop(ts->RepeatSensorInfoTimer, 0);
|
|
|
+ //xTimerStop(ts->RepeatSensorInfoTimer, 0);
|
|
|
ts->flag_telnet_ip_option = true;
|
|
|
- sendopt(ts, TELNET_WILL, TELOPT_TIMING_MARK);
|
|
|
- sendopt(ts, TELNET_MARK, 0);
|
|
|
- if(ts->telnetState != TELNET_CHANGE_PWD && ts->telnetState != TELNET_CHANGE_PWD_ACK)
|
|
|
- send( ts->num_connect, pcEndOfCommandOutputString, strlen( ( const char * ) pcEndOfCommandOutputString ), 0 );
|
|
|
+ sendopt(ts, TELNET_WILL, TELOPT_TIMING_MARK);
|
|
|
+ sendopt(ts, TELNET_MARK, 0);
|
|
|
+ if(ts->telnetState != TELNET_CHANGE_PWD && ts->telnetState != TELNET_CHANGE_PWD_ACK)
|
|
|
+ send( ts->num_connect, pcEndOfCommandOutputString, strlen( ( const char * ) pcEndOfCommandOutputString ), 0 );
|
|
|
break;
|
|
|
|
|
|
default:
|
|
@@ -452,6 +451,10 @@ static bool start_server(uint16_t port)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+static void cli_send(intptr_t fd, const char *str, unsigned len)
|
|
|
+{
|
|
|
+ send(fd, str, len, 0);
|
|
|
+}
|
|
|
|
|
|
void vBasicSocketsCommandInterpreterTask( void *pvParameters )
|
|
|
{
|
|
@@ -592,11 +595,15 @@ void vBasicSocketsCommandInterpreterTask( void *pvParameters )
|
|
|
// Send initial options
|
|
|
if(cnt_conn < NUMBER_TELNET_CONNECT){
|
|
|
for(uint8_t k = 0; k < NUMBER_TELNET_CONNECT; k ++){
|
|
|
- if(auth_tlnt_srvr_param[k].active_conn == false){
|
|
|
+ cli_state_t *cli_state;
|
|
|
+ if(auth_tlnt_srvr_param[k].active_conn == false && (cli_state = alloc_state())){
|
|
|
auth_tlnt_srvr_param[k].active_conn = true;
|
|
|
auth_tlnt_srvr_param[k].num_connect = new_sd;
|
|
|
auth_tlnt_srvr_param[k].telnetState = TELNET_AUTH;
|
|
|
auth_tlnt_srvr_param[k].state = STATE_NORMAL;
|
|
|
+ cli_state->num_connect = new_sd;
|
|
|
+ cli_state->send = cli_send;
|
|
|
+ auth_tlnt_srvr_param[k].cli_state = cli_state;
|
|
|
|
|
|
while(recv( new_sd, &auth_tlnt_srvr_param[k].buf[auth_tlnt_srvr_param[k].bufptr], 1, MSG_DONTWAIT ) > 0){
|
|
|
newdata(&auth_tlnt_srvr_param[k]);
|
|
@@ -614,9 +621,8 @@ void vBasicSocketsCommandInterpreterTask( void *pvParameters )
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- cnt_conn ++;
|
|
|
- }
|
|
|
- else{
|
|
|
+ cnt_conn++;
|
|
|
+ } else{
|
|
|
send( new_sd, pcWarningMessage, strlen( ( const char * ) pcWarningMessage ), 0 );
|
|
|
closesocket(new_sd);
|
|
|
FD_CLR(new_sd, &master_set);
|
|
@@ -700,6 +706,7 @@ void vBasicSocketsCommandInterpreterTask( void *pvParameters )
|
|
|
/* based on the bits that are still turned on in */
|
|
|
/* the master set. */
|
|
|
if (auth_tlnt_srvr_param[cur_cnt].state == STATE_CLOSE) {
|
|
|
+ free_state(auth_tlnt_srvr_param[cur_cnt].cli_state);
|
|
|
memset(auth_tlnt_srvr_param[cur_cnt].buf, 0, cmdMAX_INPUT_SIZE);
|
|
|
memset(auth_tlnt_srvr_param[cur_cnt].prev_cmd, 0, cmdMAX_INPUT_SIZE);
|
|
|
memset(auth_tlnt_srvr_param[cur_cnt].optdata, 0, cmdMAX_INPUT_SIZE);
|
|
@@ -710,7 +717,6 @@ void vBasicSocketsCommandInterpreterTask( void *pvParameters )
|
|
|
auth_tlnt_srvr_param[cur_cnt].telnetState = TELNET_AUTH;
|
|
|
auth_tlnt_srvr_param[cur_cnt].telnet_code_auth = USER;
|
|
|
auth_tlnt_srvr_param[cur_cnt].flag_telnet_ip_option = false;
|
|
|
- xTimerStop(auth_tlnt_srvr_param[cur_cnt].RepeatSensorInfoTimer, 0);
|
|
|
cnt_conn -= 1;
|
|
|
closesocket(i);
|
|
|
FD_CLR(i, &master_set);
|