📄 cli_telnet.c
字号:
}
strcat(szFSMInfoEn, "\r\n the input character : 0x");
strcat(szFSMInfoCh, "\r\n 输入字符 : 0x");
EOS_Sprintf ( szInputChar, "%2x", c ) ;
strcat(szFSMInfoEn, szInputChar);
strcat(szFSMInfoCh, szInputChar);
strcat(szFSMInfoEn, "\r\n the next state : TSDATA \r\n");
strcat(szFSMInfoCh, "\r\n 下一状态 : TSDATA \r\n");
strcat(szFSMInfoEn, "\r\n the action : send \"IAC WONT 0x");
strcat(szFSMInfoCh, "\r\n 执行动作 : send \"IAC WONT 0x");
strcat(szFSMInfoEn, szInputChar);
strcat(szFSMInfoCh, szInputChar);
strcat(szFSMInfoEn, "\" ");
strcat(szFSMInfoCh, "\" ");
}
CLI_TelFSMDegOut(szFSMInfoEn, szFSMInfoCh);
}
return 1 ;
}
/*==================================================================*/
/* 函数名 :CLI_WillEcho */
/* 函数功能 :处理 telnet do/don't ECHO 选项 */
/* 输入参数 :PTerm_Data_S pTermStruct 任务数据 */
/* _U8 c 接收到的输入字符 */
/* 输出参数 :PTerm_Data_S pTermStruct 任务数据 */
/* 返回值 :_U32 1:成功 */
/* 调用函数 :CLI_DebugOutString ( ) */
/* 被调函数 : */
/*==================================================================*/
_U32 CLI_WillEcho ( PTerm_Data_S pTermStruct, _U8 c )
{
_S8 szFSMInfoEn[1024] = "";
_S8 szFSMInfoCh[1024] = "";
if(pTermStruct == G_NULL)
{
return 1;
}
if ( G_TRUE == m_bCliTelnetDebugOn )
{
if ( pTermStruct->iRecvLen == 1 )
{
strcat(szFSMInfoEn, "\r\n The telnet NVT FSM :");
strcat(szFSMInfoCh, "\r\n Telnet 网络虚拟终端状态机 :");
strcat(szFSMInfoEn, "\r\n the current state : TSDOPT");
strcat(szFSMInfoCh, "\r\n 当前状态 : TSDOPT");
strcat(szFSMInfoEn, "\r\n the input character : ECHO ");
strcat(szFSMInfoCh, "\r\n 输入字符 : ECHO ");
if ( pTermStruct->TelnetParam.OptionCmd == TCDO )
{
strcat(szFSMInfoEn, "\r\n the option negotiate command is : DO");
strcat(szFSMInfoCh, "\r\n 选项协商命令: DO");
}
else
{
strcat(szFSMInfoEn, "\r\n the option negotiate command is : DONT");
strcat(szFSMInfoCh, "\r\n 当前状态 : DONT");
}
if ( pTermStruct->TelnetParam.DoEcho )
{
strcat(szFSMInfoEn, "\r\n the ECHO option state : 1 ");
strcat(szFSMInfoCh, "\r\n 回显选项状态: 1 ");
}
else
{
strcat(szFSMInfoEn, "\r\n the ECHO option state : 0 ");
strcat(szFSMInfoCh, "\r\n 回显选项状态: 0 ");
}
strcat(szFSMInfoEn, "\r\n the next state : TSDATA ");
strcat(szFSMInfoCh, "\r\n 下一状态 : TSDATA ");
if ( pTermStruct->TelnetParam.OptionCmd == TCDO
&& ! pTermStruct->TelnetParam.DoEcho )
{
strcat(szFSMInfoEn, "\r\n the action : send \"IAC WILL ECHO\" ");
strcat(szFSMInfoCh, "\r\n 执行动作 : send \"IAC WILL ECHO\" ");
strcat(szFSMInfoEn, "\r\n Echo = 1\n\r ");
strcat(szFSMInfoCh, "\r\n Echo = 1\n\r ");
}
else if ( pTermStruct->TelnetParam.OptionCmd == TCDONT
&& pTermStruct->TelnetParam.DoEcho )
{
strcat(szFSMInfoEn, "\r\n the action : send \"IAC WONT ECHO\" ");
strcat(szFSMInfoCh, "\r\n 执行动作 : send \"IAC WONT ECHO\" ");
strcat(szFSMInfoEn, "\r\n Echo = 0\n\r ");
strcat(szFSMInfoCh, "\r\n Echo = 0\n\r ");
}
}
CLI_TelFSMDegOut(szFSMInfoEn, szFSMInfoCh);
}
/*--------------------------------------------------------------*/
/* 接收到 "IAC DO/DONT ECHO" */
/* 根据当前 ECHO 选项状态 */
/* 如果已经和客户端要求相符,则不动作 */
/* 否则将 ECHO 选项设置为要求,并应答客户端"IAC WILL/WONT ECHO" */
/*--------------------------------------------------------------*/
if ( pTermStruct->TelnetParam.DoEcho )
{
if ( pTermStruct->TelnetParam.OptionCmd == TCDO )
return 1 ;
}
else if ( pTermStruct->TelnetParam.OptionCmd == TCDONT )
return 1 ;
pTermStruct->TelnetParam.DoEcho = ! ( pTermStruct->TelnetParam.DoEcho ) ;
pTermStruct->szSendBuf[ pTermStruct->iSendLen++ ] = (_S8)TCIAC ;
if ( pTermStruct->TelnetParam.DoEcho )
pTermStruct->szSendBuf[ pTermStruct->iSendLen++ ] = (_S8)TCWILL ;
else
pTermStruct->szSendBuf[ pTermStruct->iSendLen++ ] = (_S8)TCWONT ;
pTermStruct->szSendBuf[ pTermStruct->iSendLen++ ] = (_S8)c ;
pTermStruct->szSendBuf[ pTermStruct->iSendLen ] = '\0' ;
CLI_SendToTerm ( pTermStruct ) ;
return 1 ;
}
/*==================================================================*/
/* 函数名 :CLI_WillNoga */
/* 函数功能 :处理telnet do/don't Supress Go-Ahead 选项 */
/* 输入参数 :PTerm_Data_S pTermStruct 任务数据 */
/* _U8 c 接收到的输入字符 */
/* 输出参数 :PTerm_Data_S pTermStruct 任务数据 */
/* 返回值 :_U32 1:成功 */
/* 调用函数 :CLI_DebugOutString ( ) */
/* 被调函数 : */
/*==================================================================*/
_U32 CLI_WillNoga ( PTerm_Data_S pTermStruct, _U8 c )
{
_S8 szFSMInfoEn[1024] = "";
_S8 szFSMInfoCh[1024] = "";
if(pTermStruct == G_NULL)
{
return 1;
}
if ( G_TRUE == m_bCliTelnetDebugOn )
{
if ( pTermStruct->iRecvLen == 1 )
{
strcat(szFSMInfoEn, "\r\n The telnet NVT FSM :");
strcat(szFSMInfoCh, "\r\n Telnet 网络虚拟终端状态机 :");
strcat(szFSMInfoEn, "\r\n the current state : TSDOPT");
strcat(szFSMInfoCh, "\r\n 当前状态 : TSDOPT");
strcat(szFSMInfoEn, "\r\n the input character : NOGA ( NO Go Ahead ) ");
strcat(szFSMInfoCh, "\r\n 输入字符 : NOGA ( NO Go Ahead ) ");
if ( pTermStruct->TelnetParam.OptionCmd == TCDO )
{
strcat(szFSMInfoEn, "\r\n the option negotiate command is : DO");
strcat(szFSMInfoCh, "\r\n 选项协商命令: DO");
}
else
{
strcat(szFSMInfoEn, "\r\n the option negotiate command is : DONT");
strcat(szFSMInfoCh, "\r\n 当前状态 : DONT");
}
if ( pTermStruct->TelnetParam.Noga )
{
strcat(szFSMInfoEn, "\r\n the NOGA option state : 1 ");
strcat(szFSMInfoCh, "\r\n 字符处理选项状态: 1 ");
}
else
{
strcat(szFSMInfoEn, "\r\n the NOGA option state : 0 ");
strcat(szFSMInfoCh, "\r\n 字符处理选项状态: 0 ");
}
strcat(szFSMInfoEn, "\r\n the next state : TSDATA ");
strcat(szFSMInfoCh, "\r\n 下一状态 : TSDATA ");
if ( pTermStruct->TelnetParam.OptionCmd == TCDO
&& ! pTermStruct->TelnetParam.Noga )
{
strcat(szFSMInfoEn, "\r\n the action : send \"IAC WILL NOGA\" ");
strcat(szFSMInfoCh, "\r\n 执行动作 : send \"IAC WILL NOGA\" ");
strcat(szFSMInfoEn, "\r\n NOGA = 1\n\r ");
strcat(szFSMInfoCh, "\r\n NOGA = 1\n\r ");
}
else if ( pTermStruct->TelnetParam.OptionCmd == TCDONT
&& pTermStruct->TelnetParam.Noga )
{
strcat(szFSMInfoEn, "\r\n the action : send \"IAC WONT NOGA\" ");
strcat(szFSMInfoCh, "\r\n 执行动作 : send \"IAC WONT NOGA\" ");
strcat(szFSMInfoEn, "\r\n NOGA = 0\n\r ");
strcat(szFSMInfoCh, "\r\n NOGA = 0\n\r ");
}
}
CLI_TelFSMDegOut(szFSMInfoEn, szFSMInfoCh);
}
/*--------------------------------------------------------------*/
/* 接收到 "IAC DO/DONT SUPRESS-GO-AHEAD" */
/* 根据当前的SUPREE-GO-AHEAD 选项状态 */
/* 如果符合客户端的要求,则不动作 */
/* 否则设置SUPRESS-GO-AHEAD选项 */
/* 并应答客户端"IAC WILL/WONT SUPRESS-GO-AHEAD" */
/*--------------------------------------------------------------*/
if ( pTermStruct->TelnetParam.Noga )
{
if ( pTermStruct->TelnetParam.OptionCmd == TCDO )
return 1 ;
}
else if ( pTermStruct->TelnetParam.OptionCmd == TCDONT )
return 1 ;
pTermStruct->TelnetParam.Noga = ! ( pTermStruct->TelnetParam.Noga ) ;
pTermStruct->szSendBuf[ pTermStruct->iSendLen++ ] = (_S8)TCIAC ;
if ( pTermStruct->TelnetParam.Noga )
pTermStruct->szSendBuf[ pTermStruct->iSendLen++ ] = (_S8)TCWILL ;
else
pTermStruct->szSendBuf[ pTermStruct->iSendLen++ ] = (_S8)TCWONT ;
pTermStruct->szSendBuf[ pTermStruct->iSendLen++ ] = (_S8)c ;
pTermStruct->szSendBuf[ pTermStruct->iSendLen ] = '\0' ;
CLI_SendToTerm ( pTermStruct ) ;
return 1 ;
}
/*==================================================================*/
/* 函数名 :CLI_DoTxBinary */
/* 函数功能 :处理telnet will/won't BINARY-TRANSMISSION选项 */
/* 输入参数 :PTerm_Data_S pTermStruct 任务数据 */
/* _U8 c 接收到的输入字符 */
/* 输出参数 :PTerm_Data_S pTermStruct 任务数据 */
/* 返回值 :_U32 1:成功 */
/* 调用函数 :CLI_DebugOutString ( ) */
/* 被调函数 : */
/*==================================================================*/
_U32 CLI_DoTxBinary ( PTerm_Data_S pTermStruct, _U8 c )
{
_S8 szFSMInfoEn[1024] = "";
_S8 szFSMInfoCh[1024] = "";
if(pTermStruct == G_NULL)
{
return 1;
}
if ( G_TRUE == m_bCliTelnetDebugOn )
{
if ( pTermStruct->iRecvLen == 1 )
{
strcat(szFSMInfoEn, "\r\n The telnet NVT FSM :");
strcat(szFSMInfoCh, "\r\n Telnet 网络虚拟终端状态机 :");
strcat(szFSMInfoEn, "\r\n the current state : TSWOPT");
strcat(szFSMInfoCh, "\r\n 当前状态 : TSWOPT");
strcat(szFSMInfoEn, "\r\n the input character : TXBINARY ( Transition Binary ) ");
strcat(szFSMInfoCh, "\r\n 输入字符 : TXBINARY ( Transition Binary ) ");
if ( pTermStruct->TelnetParam.OptionCmd == TCWILL )
{
strcat(szFSMInfoEn, "\r\n the option negotiate command is : WILL");
strcat(szFSMInfoCh, "\r\n 选项协商命令: WILL");
}
else
{
strcat(szFSMInfoEn, "\r\n the option negotiate command is : WONT");
strcat(szFSMInfoCh, "\r\n 选项协商命令: WONT");
}
if ( pTermStruct->TelnetParam.RecvBinary )
{
strcat(szFSMInfoEn, "\r\n the RecvBinary option state : 1 ");
strcat(szFSMInfoCh, "\r\n 接收二进制选项状态: 1 ");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -