⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cli_cmdpro.c

📁 可以作为路由器交换机设备的远端shell控制接口
💻 C
📖 第 1 页 / 共 5 页
字号:
/*========================================================================*/
/*                                                                        */

/*    Module Name       :cli_cmdProc.c                                         */
/*    Module Function   : execute all the system command                  */
/*                                                                        */
/*========================================================================*/
/*========================================================================*/
/*    include head file                                                   */
/*========================================================================*/
#include    "syscfg.h"

#if (AOS_INCLUDE_SMP_CLI  ==   TRUE)

#ifdef __cplusplus
extern "C" {
#endif


/*========================================================================*/
/*  系统头文件                                                            */
/*========================================================================*/
#include "aos.h"
#include "glb_def.h"
#include "version.h"
#include "os\ker\ssp_debug.h"
#include "ifnet\if_pub.h"
#include "cli/cli_pub.h"
#include "cli_func.h"
#include "cliprxy.h"
#include "cfm/cfm_pub.h"

#if( AOS_INCLUDE_SSP_DB == TRUE )
#include "db_pub.h"
#endif

#ifndef _EIA2000V3
#else
#include "config.h"
#endif

#if (AOS_INCLUDE_SERVICE_P2P_NN == TRUE || AOS_INCLUDE_SERVICE_P2P_SN_CN == TRUE)
#include "p2p_include.h"
#endif

S8    *pTooManyParam = "\r\n  Too many parameters.";
S8    *pIncompleteCmd = "\r\n  Incomplete command.";
S8    *pCarriageReturn = "\r\n  <cr>";
S8    *pIncorrectCmd = "\r\n  Incorrect command.";

extern S32 g_ulTelnetTimeOut;

extern U32 g_ulUserNum ;

extern U32 gPlatLockFlag;

extern U8   g_CurTempera ;      //define in thermo.c

extern U32  g_SDVolume,g_readBlock_usec;  //define in sd_drv.c
extern S8 g_szSnmpCliIp[64];

extern void drv_cpu_reset( void );
extern BOOL_T dev_check_mac_pwd( S8 *pwd_str  );
extern BOOL_T dev_check_unlock_plat_pwd( S8 *pwd_str  );
extern S8 *inet_get_built_time();
extern S8 *snmp_get_built_time();
extern S8 *mgcp_get_built_time();
extern S8 *sip_get_built_time();
extern S8 *p2p_get_built_time();
extern S8 *p2p2_get_built_time();
extern S8 *stun_get_built_time();
extern S8 *provision_get_built_time();
extern VOID dev_make_local_card_version( S8 *ver );
extern S8 *h323_get_built_time();
extern VOID debug_show_info(U32 argc, S8 *argv[ ] );

#if( CONFIG_BOARD_GMPU == TRUE )
 extern VOID sd_readwrite_time(void);
#endif
/*========================================================================*/
/*                                                                        */
/*    Function Name    : ul_enable_cmdpro                                        */
/*    Function Func.   : change from user level to privilege level        */
/*                                                                        */
/*========================================================================*/
VOID  ul_enable_cmdpro ( U32 argc, S8 * argv[ ] )
{
	S8 szIfName[128] = "";
	U32 ulIndex = 0;

	/*error msg*/
	if ( argc < 2)
	{
		cli_out_string (0, "\n\r error msg" ) ;
		return ;
	}

	/*get user index*/
	aos_atol(argv[0], (S32*)&ulIndex);

	/*get curent interface mode*/
	aos_strcpy(szIfName, argv[1]);

	if ( 2 == argc )
	{
		cli_change_level (ulIndex, PRIVILEGE_LEVEL ) ;
		return ;
	}
	else
	{
		cli_out_string (ulIndex, pTooManyParam ) ;
		return ;
	}

}

/*========================================================================*/
/*                                                                        */
/*    Function Name    : config_cmdpro                                       */
/*    Function Func.   : change user name and user password               */
/*========================================================================*/
VOID config_cmdpro ( U32 argc, S8 * argv[ ] )
{

	S8 szIfName[128] = "";
	U32 ulIndex = 0;

	/*error msg*/
	if ( argc < 2)
	{
		cli_out_string (0, "\n\r error msg" ) ;
		return ;
	}

	/*get user index*/
	aos_atol(argv[0], (S32*)&ulIndex);

	/*get curent interface mode*/
	aos_strcpy(szIfName, argv[1]);

	if ( argc == 2 )
	{
		cli_change_level ( ulIndex,CONFIG_LEVEL) ;
		return ;
	}
	else
	{
		cli_out_string (ulIndex, pTooManyParam ) ;
		return ;
	}


}

#if( AOS_INCLUDE_SSP_DB == TRUE )
extern BOOL_T db_user_ok(S8 *pszUserName, S8 *pszPassword);
/*========================================================================  */
/*                                                                          */
/*    Function Name    :                                                    */
/*    Function Func.   :                                                    */
/*========================================================================  */
VOID isql_cmdpro ( U32 argc, S8 * argv[ ] )
{
	USER_DATA_S *pstUserData = NULL ;
	S8 szIfName[128] = "";
	U32 ulIndex = 0;

	/*error msg*/
	if ( argc < 2)
	{
		cli_out_string (0, "\n\r error msg" ) ;
		return ;
	}

	/*get user index*/
	aos_atol(argv[0], (S32*)&ulIndex);
	pstUserData = cli_get_userdata_by_index(ulIndex);
	if(NULL == pstUserData)
	{
		return;
	}

	/*get curent interface mode*/
	aos_strcpy(szIfName, argv[1]);

	if ( argc == 2 )
	{
        S8  szUserName[CLI_USERNAME_LENGTH];
        S8  szPassword[CLI_USERPWD_LENGTH];

        /* 用户认证 */
        pstUserData->echo_flag = 0;
        cli_out_string( ulIndex , "\r\n Username: " );
        cli_get_string( ulIndex, szUserName, CLI_USERNAME_LENGTH );
        cli_out_string( ulIndex , "\r\n Password:" );
        pstUserData->echo_flag = 1;
        cli_get_string( ulIndex, szPassword, CLI_USERPWD_LENGTH);
        pstUserData->echo_flag = 0;

        if (!db_user_ok(szUserName, szPassword))
        {
            cli_out_string( ulIndex , "\r\n username or password error, permission denied ! " );
            return ;
        }

		cli_change_level ( ulIndex, DB_SQL_LEVEL) ;
		return ;
	}
	else
	{
		cli_out_string (ulIndex, pTooManyParam ) ;
		return ;
	}


}


/*
****************************************************************************
**      功能    : 退出sql模式
**      输入参数: 命令行参数
**      输出参数: 无
**      返回值  : 无
**      函数调用说明:
**      典型使用示例:
****************************************************************************
*/
VOID isql_exit_cmdpro ( U32 argc, S8 * argv[ ] )
{
	S8 szIfName[128] = "";
	U32 ulIndex = 0;

	/*error msg*/
	if ( argc < 2)
	{
		cli_out_string (0, "\n\r error msg" ) ;
		return ;
	}

	/*get user index*/
	aos_atol(argv[0], (S32*)&ulIndex);

	/*get curent interface mode*/
	aos_strcpy(szIfName, argv[1]);

	if ( argc == 2 )
	{
		cli_change_level (ulIndex, PRIVILEGE_LEVEL ) ;
		return ;
	}
	else
	{
		cli_out_string (ulIndex, pTooManyParam ) ;
		return ;
	}

}

#endif
/*========================================================================*/
/*                                                                        */
/*    Function Name    : ul_exit_cmdpro                                          */
/*    Function Func.   : Exit from configuration and disconnect           */
/*========================================================================*/
VOID ul_exit_cmdpro ( U32 argc, S8 * argv[ ] )
{
	S8 szIfName[128] = "";
	U32 ulIndex = 0;

	/*error msg*/

	if ( argc < 2)
	{
		cli_out_string (0, "\n\r error msg" ) ;
		return ;
	}

	/*get user index*/
	aos_atol(argv[0], (S32*)&ulIndex);

	/*get curent interface mode*/
	aos_strcpy(szIfName, argv[1]);



	if ( argc == 2 )
	{
		cli_disconnect (ulIndex) ;
		return ;
	}
	else
	{
		cli_out_string (ulIndex, pTooManyParam ) ;
		return ;
	}

}


/*========================================================================*/
/*                                                                        */
/*    Function Name    : pl_exit_cmdpro                                          */
/*    Function Func.   : Exit from configuration and disconnect           */
/*========================================================================*/
VOID pl_exit_cmdpro ( U32 argc, S8 * argv[ ] )
{
	S8 szIfName[128] = "";
	U32 ulIndex = 0;

	/*error msg*/
	if ( argc < 2)
	{
		cli_out_string (0, "\n\r error msg" ) ;
		return ;
	}

	/*get user index*/
	aos_atol(argv[0], (S32*)&ulIndex);

	/*get curent interface mode*/
	aos_strcpy(szIfName, argv[1]);



	if ( argc == 2 )
	{
		cli_change_level (ulIndex, USER_LEVEL ) ;
		return ;
	}
	else
	{
		cli_out_string (ulIndex, pTooManyParam ) ;
		return ;
	}

}



/*========================================================================*/
/*                                                                        */
/*    Function Name    : pl_show_user_cmdpro                                          */
/*    Function Func.   : Exit from configuration and disconnect           */
/*========================================================================*/

extern USER_DATA_S   *g_pstUserDataTable ;
extern CLI_PRXY_CLIENT_S*  g_pstCliPrxyClient[CLI_MAX_PRXY_USER];
extern U32 g_ulTelnetListenPort;

VOID pl_show_user_cmdpro ( U32 argc, S8 * argv[ ] )
{
    S8 szOutString[100] ="";
    U32 ulIndex = 0;
    U32 ulPrxyNum = 0;
    USER_DATA_S   *pstTempuserData = NULL;

    /*error msg*/
	if ( argc < 2)
	{
		cli_out_string (0, "\n\r error msg" ) ;
		return ;
	}

	/*get user index*/
	aos_atol(argv[0], (S32*)&ulIndex);

	/*get curent interface mode*/


	if ( argc == 2 )
	{
		{
			S8 buf[100];
			aos_sprintf(buf, "\r\nTelnet serverport: %d", g_ulTelnetListenPort);
			cli_out_string(ulIndex, buf);
		}

        pstTempuserData  = g_pstUserDataTable;
        aos_sprintf(szOutString , "\r\nTotal users:%d",g_ulUserNum);
        cli_out_string( ulIndex, szOutString );
        aos_sprintf(szOutString, "\r\n(usertype:0 = USER_CON; 1 = USER_TEL; 2 = USER_CLIPRXY)");
        cli_out_string( ulIndex, szOutString );
        aos_sprintf(szOutString, "\r\n  index   usertype      username     taskid    ");
        cli_out_string( ulIndex, szOutString );
        aos_sprintf(szOutString, "\r\n  _____________________________________________");
        cli_out_string( ulIndex, szOutString );
        aos_sprintf(szOutString, "\r\n%7u", pstTempuserData ->ulIndex);
        cli_out_string( ulIndex, szOutString );
        aos_sprintf(szOutString, "%11u", pstTempuserData ->ulUserType);
        cli_out_string( ulIndex, szOutString );
        aos_sprintf(szOutString, "%19s", pstTempuserData ->UserName);
        cli_out_string( ulIndex, szOutString );
        aos_sprintf(szOutString, " 0x%2x", pstTempuserData ->iTaskid);
        cli_out_string( ulIndex, szOutString );
        while (pstTempuserData ->lpNextNode)
        {
            pstTempuserData = pstTempuserData ->lpNextNode;
            aos_sprintf(szOutString, "\r\n%7u", pstTempuserData ->ulIndex);
            cli_out_string( ulIndex, szOutString );
            aos_sprintf(szOutString, "%11u", pstTempuserData ->ulUserType);
            cli_out_string( ulIndex, szOutString );
            aos_sprintf(szOutString, "%19s", pstTempuserData ->UserName);
            cli_out_string( ulIndex, szOutString );
            aos_sprintf(szOutString, " 0x%2x", pstTempuserData ->iTaskid);
            cli_out_string( ulIndex, szOutString );
        }
        aos_sprintf(szOutString, "\r\n  _____________________________________________");
        cli_out_string( ulIndex, szOutString );

        aos_sprintf(szOutString, "\r\n\r\nthe proxy user infos:");
        cli_out_string( ulIndex, szOutString );
        aos_sprintf(szOutString, "\r\n(the proxy user state instruction: 0 = idle, 1 = wait_ack, 2 = busy)");
        cli_out_string( ulIndex, szOutString );
        aos_sprintf(szOutString, "\r\n(the proxy user exflag: 4 = REMOTE_CLOSED, 8 = CUSTOM_CLOSED)");
        cli_out_string( ulIndex, szOutString );
        aos_sprintf(szOutString, "\r\nState LProceID  PProceID  LUserIndex  PUserIndex TaskID ExecpFlag TimeOuts");
        cli_out_string( ulIndex, szOutString );
        aos_sprintf(szOutString, "\r\n__________________________________________________________________________");
        cli_out_string( ulIndex, szOutString );
        for (ulPrxyNum = 0; ulPrxyNum < CLI_MAX_PRXY_USER; ulPrxyNum++)
        {
            if ( NULL != g_pstCliPrxyClient[ulPrxyNum] )
            {
                aos_sprintf(szOutString, "\r\n%5u", g_pstCliPrxyClient[ulPrxyNum]->ulState);
                cli_out_string( ulIndex, szOutString );
                aos_sprintf(szOutString, "%9u", g_pstCliPrxyClient[ulPrxyNum]->ulLocalProcessorID);
                cli_out_string( ulIndex, szOutString );
                aos_sprintf(szOutString, "%10u", g_pstCliPrxyClient[ulPrxyNum]->ulPeerProcessorID);
                cli_out_string( ulIndex, szOutString );
                aos_sprintf(szOutString, "%12u", g_pstCliPrxyClient[ulPrxyNum]->ulLocalUserIndex);
                cli_out_string( ulIndex, szOutString );
                aos_sprintf(szOutString, "%12u", g_pstCliPrxyClient[ulPrxyNum]->ulPeerUserIndex);
                cli_out_string( ulIndex, szOutString );
                aos_sprintf(szOutString, "%7u", g_pstCliPrxyClient[ulPrxyNum]->ulTaskID);
                cli_out_string( ulIndex, szOutString );
                aos_sprintf(szOutString, "0x%2x", g_pstCliPrxyClient[ulPrxyNum]->ulExecptionFlag);
                cli_out_string( ulIndex, szOutString );
                aos_sprintf(szOutString, "%9u", g_pstCliPrxyClient[ulPrxyNum]->ulTimeOuts);
                cli_out_string( ulIndex, szOutString );
            }
        }

        aos_sprintf(szOutString, "\r\n__________________________________________________________________________");
        cli_out_string( ulIndex, szOutString);
    }
    else
    {
        cli_out_string (ulIndex, pTooManyParam ) ;
    }

}

#if( CONFIG_BOARD_GMPU == TRUE )
/*========================================================================*/
/*    Function Name    : show_sdwriteread_time_cmdpro                       */
/*    Function desc.   : display sdcard read and write block time                 */
/*     modify by william 2006-10-13                                    */
/*========================================================================*/
VOID show_sdwriteread_time_cmdpro ( U32 argc, S8 * argv[ ] )
{

	S8 szTmp[ USERLENGTH ] ;
	S8 szIfName[128] = "";
	U32 ulIndex = 0;
	       /*error msg*/
	if ( argc < 2)
	{
		cli_out_string (0, "\n\r error msg" ) ;
		return ;
	}

	/*get user index*/
	aos_atol(argv[0], (S32*)&ulIndex);

	/*get curent interface mode*/
	aos_strcpy(szIfName, argv[1]);

	if ( argc == 2 )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -