Exemple #1
0
int vmdb_cli_single_step_enable(unsigned argc, char *args[])
    {
    GUEST_CPU_HANDLE    gcpu;
    BOOLEAN             enable;
    BOOLEAN             apply_to_all;

    if (argc < 3) {
        return -1;
        }

    gcpu = vmdb_cli_locate_gcpu(args[1], &apply_to_all);
    if (NULL == gcpu) {
        CLI_PRINT("Invalid Guest %s\n", args[1]);
        return -1;
        }

    if (CLI_IS_SUBSTR("enable", args[2])) {
        enable = TRUE;
        }
    else if (CLI_IS_SUBSTR("disable", args[2])) {
        enable = FALSE;
        }
    else {
        return -1;
        }

    vmdb_single_step_enable(gcpu, enable);

    if (apply_to_all) {
        vmdb_remote_single_step_enable(gcpu, enable);
        }

    return 0;
    }
Exemple #2
0
int vmdb_cli_debug_attach(unsigned argc, char *args[])
    {
    GUEST_CPU_HANDLE    gcpu;
    BOOLEAN             apply_to_all;
    GUEST_ID            guest_id;

    if (argc < 2) {
        return -1;
        }

    gcpu = vmdb_cli_locate_gcpu(args[1], &apply_to_all);
    if (NULL == gcpu) {
        CLI_PRINT("Invalid Guest %s\n", args[1]);
        return -1;
        }

    guest_id = guest_vcpu(gcpu)->guest_id;
    vmdb_guest_initialize(guest_id);
    vmdb_thread_attach(gcpu);
    if (apply_to_all) {
            vmdb_remote_thread_attach(gcpu);
        }

    return 0;
    }
Exemple #3
0
int vmdb_cli_breakpoint_delete(unsigned argc, char *args[])
    {
    GUEST_CPU_HANDLE    gcpu;
    ADDRESS             linear_address;
    BOOLEAN             apply_to_all;

    if (argc < 3) return -1;

    gcpu = vmdb_cli_locate_gcpu(args[1], &apply_to_all);
    if (NULL == gcpu) {
        CLI_PRINT("Invalid Guest %s\n", args[1]);
        return -1;
        }

    if (0 == CLI_STRCMP("all", args[2])) {
        linear_address = (ADDRESS)-1;
        }
    else {
        linear_address = CLI_ATOL64(args[2]);
        }

    vmdb_breakpoint_delete(gcpu, linear_address);

    if (apply_to_all) {
        vmdb_remote_breakpoint_delete(gcpu, linear_address);
        }

    return 0;
    }
Exemple #4
0
/*
 * A valid command has been inputed, call its callback function.
 */
static LS_VOID _excuteCmd(CLASS_CLI_T *pThis)
{
    PRIVATE_T *pPriv = pThis->pPriv;
    CLASS_LIST_T *pList = NULL;
    CLI_TOKEN_T *pstToken = NULL;
    LS_S32 i = 0;

    _parseCmd(pThis);

    pList = pPriv->apCmdList[pPriv->eCurrGrp];

    /* Search for the token and excute the callback function. */
    while (NULL != pPriv->apszArgv[i])
    {
        if (NULL == (pstToken = _walkCmdList(pList, pPriv->apszArgv[i])))
        {
            break;
        }

        pList = pstToken->pChild;
        i++;
    }

    if (NULL == pPriv->apszArgv[i] && NULL != pstToken->pfCallBack)
    {
        pstToken->pfCallBack(pPriv->apszArgv);
    }
    else
    {
        CLI_PRINT("Unknown command.\r\n");
    }

    return;
}
Exemple #5
0
int initRevThread(void)
{

	int result,retval = RET_OK;
	pthread_t pid;
	
	/* 线程初始化 */
	printf("#############  rev thread init  ##################\n");
	result = pthread_create(&pid,NULL,(void *)revHandler,NULL);
	if(result < 0)
	{
		CLI_PRINT("receive thread create fail.\n");
		retval = RET_FAIL;
	}
	CLI_PRINT("receive thread create success.\n");
	return retval;
}
Exemple #6
0
int vmdb_cli_breakpoint_show(unsigned argc, char *args[])
    {
    GUEST_CPU_HANDLE    gcpu;
    VMDB_THREAD_CONTEXT *vmdb;
    ADDRESS             bp_address;
    int                 i;

    if (argc < 2) return -1;

    gcpu = vmdb_cli_locate_gcpu(args[1], NULL);

    if (NULL == gcpu) {
        CLI_PRINT("Invalid Guest %s\n", args[1]);
        return -1;
        }

    vmdb = gcpu_get_vmdb(gcpu);
    if (NULL == vmdb) {
        CLI_PRINT("VMDB is not attached to thread %s,%d\n", args[1], hw_cpu_id());
        return -1;
        }

    CLI_PRINT("======================================\n");
    CLI_PRINT("Single step:  %s\n", vmdb->sstep   ? "enabled" : "disabled");
    CLI_PRINT("======================================\n");
    CLI_PRINT("BP  linear address  type  len  counter\n");
    CLI_PRINT("======================================\n");

    for (i = 0; i < NUMBER_OF_HW_BREAKPOINTS; ++i) {
        CLI_PRINT("%d: ", i);

        bp_address = vmdb->dr[i];

        if (0 != bp_address && DR7_GLOBAL_GET(vmdb->dr7, i)) {
#if defined DEBUG || defined ENABLE_RELEASE_VMM_LOG
            VMDB_BREAKPOINT_TYPE     bp_type = (VMDB_BREAKPOINT_TYPE)DR7_RW_GET(vmdb->dr7, i);
            VMDB_BREAK_LENGTH_TYPE   bp_len = (VMDB_BREAK_LENGTH_TYPE)DR7_LEN_GET(vmdb->dr7, i);
#endif
            CLI_PRINT ( "%16P %5s   %d   %d", bp_address, bp_type_name[bp_type],
                bp_actual_length[bp_len], vmdb->skip_counter[i]);
            }
        CLI_PRINT("\n");
        }
    return 0;
    }
Exemple #7
0
/* 组包函数 */
PST_MSG makePack(EN_MSG_TYPE type,void *buf)
{
	//int ret = RET_OK;
	/* 根据update.h中定义构造数据包 */
	if(msg == NULL)
	{
		msg = malloc(sizeof(ST_MSG));
	}
	CLI_PRINT("msg malloc done,size %d.\n",sizeof(ST_MSG));
	if(msg == NULL)
	{
		CLI_PRINT("Msg malloc fail.\n");
	}
	memset(msg,0,sizeof(ST_MSG));
	msg->mType = type;
	switch(type)
	{
		case TYPE_MSG_HEAD:
			/* 确定数据类型 */
			memcpy(msg->buf,buf,sizeof(ST_FILE_HEADER));
			break;

		case TYPE_MSG_CONTENT:
			memcpy(msg->buf,buf,sizeof(ST_FILE_PKG));
			break;

		case TYPE_MSG_RPT_PROC:
			memcpy(msg->buf,buf,sizeof(ST_RPT_PKG));
			break;

		default:
			//ret = RET_FAIL;
			CLI_PRINT("Package type error,please check out.\n");
			break;
	}
	
	return msg;
}
Exemple #8
0
int vmdb_cli_breakpoint_add(unsigned argc, char *args[])
    {
    ADDRESS                 linear_address;
    VMDB_BREAKPOINT_TYPE    bp_type;
    VMDB_BREAK_LENGTH_TYPE  bp_len;
    UINT32                  skip_counter = 0;
    BOOLEAN                 apply_to_all;
    GUEST_CPU_HANDLE        gcpu;

    if (argc < 5) return -1;

    gcpu = vmdb_cli_locate_gcpu(args[1], &apply_to_all);
    if (NULL == gcpu) {
        CLI_PRINT("Invalid Guest %s\n", args[1]);
        return -1;
        }

    linear_address = CLI_ATOL64(args[2]);

    switch (args[3][0]) {
        case 'e': bp_type = VMDB_BREAK_ON_EXE; break;
        case 'w': bp_type = VMDB_BREAK_ON_WO;  break;
        case 'i': bp_type = VMDB_BREAK_ON_IO;  break;
        case 'r': bp_type = VMDB_BREAK_ON_RW;  break;
        default: return -1;
        }

    switch (args[4][0]) {
        case '1': bp_len = VMDB_BREAK_LENGTH_1; break;
        case '2': bp_len = VMDB_BREAK_LENGTH_2; break;
        case '4': bp_len = VMDB_BREAK_LENGTH_4; break;
        case '8': bp_len = VMDB_BREAK_LENGTH_8; break;
        default: return -1;
        }

    if (argc > 5) {
        skip_counter = CLI_ATOL(args[5]);
        }

    vmdb_breakpoint_add ( gcpu, linear_address, bp_type,
        bp_len, (UINT16) skip_counter);

    if (apply_to_all)
        {
        vmdb_remote_breakpoint_add ( gcpu, linear_address,
            bp_type, bp_len, (UINT16) skip_counter);
        }

    return 0;
    }
FRESULT scan_files( char *path ) 
{
    FRESULT res;
    FILINFO fno;
    DIR dir;
    int i;
    char *fn;
    
#if _USE_LFN
    fno.lfname = 0;
    fno.lfsize = 0;
#endif
  
    res = f_opendir( &dir, path );
    if( res == FR_OK ) 
    {
        i = strlen( path );
        while( true )
        {
            res = f_readdir( &dir, &fno );
            if( res != FR_OK || fno.fname[ 0 ] == 0 )
                break;
            
            if( fno.fname[ 0 ] == '.' )
                continue;
            
            fn = fno.fname;
        
            if( fno.fattrib & AM_DIR ) 
            {
                path[ i++ ] = '/';
                strcpy( &path[ i ], fn );
                res = scan_files( path );
          
                if( res != FR_OK )
                    break;
                
                path[ --i ] = 0;
            }
            else 
            {
                CLI_PRINT( 1, "%s/%s\r\n", path, fn );
            }
        }
    }
    
    return res;
}
Exemple #10
0
int vmdb_cli_debug_detach(unsigned argc, char *args[])
    {
        GUEST_CPU_HANDLE    gcpu;
        BOOLEAN             apply_to_all;

        if (argc < 2) {
            return -1;
            }

        gcpu = vmdb_cli_locate_gcpu(args[1], &apply_to_all);
        if (NULL == gcpu) {
            CLI_PRINT("Invalid Guest %s\n", args[1]);
            return -1;
            }

        vmdb_thread_detach(gcpu);
        if (apply_to_all) {
                vmdb_remote_thread_detach(gcpu);
            }

        return 0;
    }
Exemple #11
0
void* revHandler(void *arg)
{
	int len = 0;
	PST_MSG revMsg = (PST_MSG)malloc(sizeof(ST_MSG));
	if(revMsg == NULL)
	{
		CLI_PRINT("memery malloc err..\n");
		return (void *)-1;		
	}
	
	while(1)
	{
		memset(revMsg,0,sizeof(ST_MSG));
		len = recvfrom(src_fd,revMsg,sizeof(ST_MSG),0,(struct sockaddr *)&rev_addr,&addr_sz);
		if(len < 0)
		{
			CLI_PRINT("recvfrom err..\n");
			return (void *)-1;
		}
		/* 打印接收的数据 */
		switch(revMsg->mType)
		{
			case TYPE_MSG_RPT_ERR:
				CLI_PRINT("recieve TYPE_MSG_RPT_ERR msg.\n");
				CLI_PRINT("****** %s ******\n",revMsg->buf);
				break;

			case TYPE_MSG_RPT_PROC:
				CLI_PRINT("rev TYPE_MSG_RPT_PROC msg.\n");
				break;

			default:
				CLI_PRINT("Recieve type error.\n");
				break;
		}
	}

	return (void *)0;
}
Exemple #12
0
static LS_VOID feed(CLASS_CLI_T *pThis, LS_S8 cIn)
{
    PRIVATE_T *pPriv = pThis->pPriv;
    LS_S8 *pszCmd = NULL;
    LS_S32 iCmdLen = 0;
    LS_S32 iPrevCmdIdx = 0;
    LS_S32 i;

    pszCmd = pPriv->aszCmdBuf[pPriv->iCmdIdx];
    iCmdLen = strlen(pszCmd);

    /* Handle the up, down, left, right arrows input. */
    if (0x1B == cIn)
    {
        pPriv->szCtrlBuf[0] = cIn;
        pPriv->szCtrlBuf[1] = '\0';
        return;
    }

    if (0x1B == pPriv->szCtrlBuf[0] && 0x5B == cIn)
    {
        pPriv->szCtrlBuf[1] = cIn;
        return;
    }

    if (0x1B == pPriv->szCtrlBuf[0] && 0x5B == pPriv->szCtrlBuf[1])
    {
        switch (cIn)
        {
        case 0x41:
            iPrevCmdIdx = (pPriv->iCmdIdx - 1 < 0) ? (M_CLI_HTY_CMD_CNT - 1) : (pPriv->iCmdIdx - 1);
            if (iPrevCmdIdx == pPriv->iCurrCmdIdx || 0 == strlen(pPriv->aszCmdBuf[iPrevCmdIdx]))
            {
                /* No recursive. */
                return;
            }
            for (i=0; i<iCmdLen; i++)
            {
                CLI_PRINT("\b");
            }
            for (i=0; i<iCmdLen; i++)
            {
                CLI_PRINT(" ");
            }
            for (i=0; i<iCmdLen; i++)
            {
                CLI_PRINT("\b");
            }
            pPriv->iCmdIdx = (pPriv->iCmdIdx - 1 < 0) ? (M_CLI_HTY_CMD_CNT - 1) : pPriv->iCmdIdx - 1;
            pPriv->iCmdLen = strlen(pPriv->aszCmdBuf[pPriv->iCmdIdx]);
            strcpy(pPriv->szHtyCmd, pPriv->aszCmdBuf[pPriv->iCmdIdx]);
            CLI_PRINT("%s", pPriv->aszCmdBuf[pPriv->iCmdIdx]);
            return;
        case 0x42:
            if (pPriv->iCmdIdx == pPriv->iCurrCmdIdx)
            {
                /* Down to the last command, stop. */
                return;
            }
            for (i=0; i<iCmdLen; i++)
            {
                CLI_PRINT("\b");
            }
            for (i=0; i<iCmdLen; i++)
            {
                CLI_PRINT(" ");
            }
            for (i=0; i<iCmdLen; i++)
            {
                CLI_PRINT("\b");
            }
            pPriv->iCmdIdx = (pPriv->iCmdIdx + 1) % 10;
            pPriv->iCmdLen = strlen(pPriv->aszCmdBuf[pPriv->iCmdIdx]);
            strcpy(pPriv->szHtyCmd, pPriv->aszCmdBuf[pPriv->iCmdIdx]);
            CLI_PRINT("%s", pPriv->aszCmdBuf[pPriv->iCmdIdx]);
            return;
        case 0x43:
            return;
        case 0x44:
            return;
        default:
            break;
        }
    }

    _procInputChar(pThis, cIn);

    bzero(pPriv->szCtrlBuf, sizeof(pPriv->szCtrlBuf));

    return;
}
Exemple #13
0
/*
 * Process the character inputed.
 */
static LS_VOID _procInputChar(CLASS_CLI_T *pThis, LS_S8 cIn)
{
    PRIVATE_T *pPriv = pThis->pPriv;
    LS_S32 iPrevIdx = 0;

    switch (cIn)
    {
    case '\t':
        _autoComplete(pThis);
        break;
    case '\r':
    case '\n':
        /* Process Input stream. */
        CLI_PRINT("\r\n");

        if (pPriv->iCmdLen > 0)
        {
            _excuteCmd(pThis);
            _genNewCmd(pThis, pPriv->szHtyCmd);

            /* Copy new command into history command array. */
            iPrevIdx = (pPriv->iCurrCmdIdx - 1 < 0) ? (M_CLI_HTY_CMD_CNT - 1) : (pPriv->iCurrCmdIdx - 1);
            if (LS_OK == cmnStrCmpNoCaseSpace(pPriv->aszCmdBuf[iPrevIdx], pPriv->szHtyCmd))
            {
                /* Use current commnad buffer. */
                strcpy(pPriv->aszCmdBuf[iPrevIdx], pPriv->szHtyCmd);
                pPriv->iCmdIdx = pPriv->iCurrCmdIdx;
            }
            else
            {
                /* Switch to next commnad buffer. */
                strcpy(pPriv->aszCmdBuf[pPriv->iCurrCmdIdx], pPriv->szHtyCmd);
                pPriv->iCmdIdx = (pPriv->iCurrCmdIdx + 1) % M_CLI_HTY_CMD_CNT;
                pPriv->iCurrCmdIdx = pPriv->iCmdIdx;
            }

            /* Initialize next command buffer. */
            bzero(pPriv->aszCmdBuf[pPriv->iCmdIdx], M_CLI_CMD_BUF_SIZE + 1);
            bzero(pPriv->szHtyCmd, M_CLI_CMD_BUF_SIZE + 1);
            pPriv->iCmdLen = 0;
            fflush(stdin);
        }
        CLI_PRINT("->");
        break;
    case '\b':
        /* Backspace input. */
        if (pPriv->iCmdLen > 0)
        {
            pPriv->iCmdLen--;

            /* Select current command or history command to be backspaced. */
            if (pPriv->iCmdIdx != pPriv->iCurrCmdIdx)
            {
                pPriv->szHtyCmd[pPriv->iCmdLen] = '\0';
            }
            else
            {
                pPriv->aszCmdBuf[pPriv->iCmdIdx][pPriv->iCmdLen] = '\0';
            }
            CLI_PRINT("\b \b");
        }
        break;
    default:
        /* Command buffer is full. */
        if (pPriv->iCmdLen > M_CLI_CMD_BUF_SIZE)
        {
            break;
        }

        /* Put Legal character into command buffer. */
        if (cIn < ' ' || cIn > '~')
        {
            break;
        }

        CLI_PRINT("%c", cIn);

        /* Select current command or histroy command to put the charactor in. */
        if (pPriv->iCmdIdx != pPriv->iCurrCmdIdx)
        {
            pPriv->szHtyCmd[pPriv->iCmdLen] = cIn;
        }
        else
        {
            pPriv->aszCmdBuf[pPriv->iCmdIdx][pPriv->iCmdLen] = cIn;
        }

        pPriv->iCmdLen++;
        break;
    }

    return;
}
Exemple #14
0
/*
 * Auto complete a command.
 */
static LS_VOID _autoComplete(CLASS_CLI_T *pThis)
{
    PRIVATE_T *pPriv = pThis->pPriv;
    CLASS_LIST_T *pList = NULL;
    CLASS_LIST_T *pstOldList = NULL;
    CLI_TOKEN_T *pstToken = NULL;
    CLI_TOKEN_T *pstOldToken = NULL;
    CLI_TOKEN_T *pstFixToken = NULL;
    CLI_TOKEN_T *pstCtmToken = NULL;
    LS_S8 *pszCmd = NULL;
    LS_S8 szToken[M_CLI_TKN_LEN + 1] = {0};
    LS_S8 szCmpToken[M_CLI_TKN_LEN + 1] = {0};
    LS_S8 *pszLastToken = NULL;
    LS_S8 cLastChar = 0;
    LS_S32 iFixTokenCnt = 0;
    LS_S32 iCtmTokenCnt = 0;
    LS_S32 iStrlen = 0;
    LS_S32 i = 0;
    LS_S32 j = 0;

    pList = pPriv->apCmdList[pPriv->eCurrGrp];

    /* No charactor inputed, print the first level token. */
    if (0 == pPriv->iCmdLen)
    {
        LS_CALL(pList, startIter);
        while (NULL != (pstToken = LS_CALL(pList, getIterNext)))
        {
            CLI_PRINT("\r\n%-48s-%s", pstToken->pszName, pstToken->pszTip);
        }

        CLI_PRINT("\r\n->");

        return;
    }

    _parseCmd(pThis);

    /* Select current command or history commond to be completed. */
    if (pPriv->iCmdIdx != pPriv->iCurrCmdIdx)
    {
        pszCmd = pPriv->szHtyCmd;
    }
    else
    {
        pszCmd = pPriv->aszCmdBuf[pPriv->iCmdIdx];
    }

    pszLastToken = pPriv->apszArgv[pPriv->iArgc - 1];
    cLastChar = pszCmd[pPriv->iCmdLen - 1];

    /* Search for the token and excute the callback function. */
    while (NULL != pPriv->apszArgv[i])
    {
        if (NULL == (pstToken = _walkCmdList(pList, pPriv->apszArgv[i])))
        {
            break;
        }

        pstOldList = pList;
        pstOldToken = pstToken;

        pList = pstToken->pChild;
        i++;
    }

    /* Not match at all. */
    if (i < pPriv->iArgc - 1)
    {
        return;
    }

    /* Space is a terminate symbol. */
    if (' ' == cLastChar)
    {
        if (i == pPriv->iArgc)
        {
            LS_CALL(pList, startIter);
            while (NULL != (pstToken = LS_CALL(pList, getIterNext)))
            {
                CLI_PRINT("\r\n%-48s-%s", pstToken->pszName, pstToken->pszTip);
                j++;
            }

            if (0 == j)
            {
                /* All command's token is match. */
                CLI_PRINT("\r\n<End>");
            }

            CLI_PRINT("\r\n->%s", pszCmd);
        }

        return;
    }

    /* If last token is matched as a <*> type, check its sibling. */
    if (i == pPriv->iArgc && NULL != pstOldToken &&
        (E_TOKEN_TYPE_C == pstOldToken->eType || ' ' != cLastChar))
    {
        pList = pstOldList;
    }

    /* Calculate how much match token exist. */
    LS_CALL(pList, startIter);
    while (NULL != (pstToken = LS_CALL(pList, getIterNext)))
    {
        i = _getHalfMatch(pstToken, pszLastToken, szToken);
        switch (i)
        {
        case -1:
            pstCtmToken = pstToken;
            iCtmTokenCnt++;
            break;
        case 0:
            break;
        default:
            pstFixToken = pstToken;
            iFixTokenCnt += i;
            break;
        }
    }

    /* Only one fix token is match, complete it. */
    if (1 == iFixTokenCnt)
    {
        iStrlen = strlen(pszLastToken);
        _getHalfMatch(pstFixToken, pszLastToken, szToken);

        if (E_TOKEN_TYPE_M == pstFixToken->eType)
        {
            strcpy(szCmpToken, &(szToken[iStrlen + 1]));
            szCmpToken[strlen(szCmpToken) - 1] = '\0';
        }
        else
        {
            strcpy(szCmpToken, &(szToken[iStrlen]));
        }

        strcat(szCmpToken, " ");
        CLI_PRINT("%s", szCmpToken);
        strcat(pszCmd, szCmpToken);
        pPriv->iCmdLen += strlen(szCmpToken);

        iFixTokenCnt = 0;
    }

    /* Multi-match token exist, list then. */
    if (iFixTokenCnt + iCtmTokenCnt > 0)
    {
        LS_CALL(pList, startIter);
        while (NULL != (pstToken = LS_CALL(pList, getIterNext)))
        {
            if (0 != _getHalfMatch(pstToken, pszLastToken, szToken))
            {
                CLI_PRINT("\r\n%-48s-%s", pstToken->pszName, pstToken->pszTip);
            }
        }

        CLI_PRINT("\r\n->%s", pszCmd);
    }

    return;
}
Exemple #15
0
/* 主程序 */
int main(int argc,char *argv[])
{
	int src_fd,dst_fd;
	int retval = RET_FAIL;
	struct sockaddr_in src_addr,dst_addr;
	
	int addr_sz	= sizeof(struct sockaddr);
	/* 1.初始化udp */
	printf("######### Client socket initial #########\n");
	src_fd = socket(AF_INET,SOCK_DGRAM,0);
	if(src_fd < 0)
	{
		CLI_PRINT("Client socket create fail..\n");
		return RET_FAIL;
	}
	CLI_PRINT("Client udp sock create success.\n");

	/* 2.绑定 */
	printf("######### socket bind #########\n");
	src_addr.sin_family			= AF_INET;
	src_addr.sin_addr.s_addr 	= htonl(INADDR_ANY);
	src_addr.sin_port			= htons(SRC_PORT);
	retval = bind(src_fd,(struct sockaddr *)&src_addr,addr_sz);
	if(retval < 0)
	{
		CLI_PRINT("Client bind fail.\n");
		return RET_FAIL;
	}
	CLI_PRINT("Client sock bind success.\n");


	/* 3.组包 */
	printf("######### making package #########\n");	
	//EN_MSG_TYPE 	type = TYPE_MSG_HEAD;// 消息类型
	PST_FILE_HEADER	head = (PST_FILE_HEADER)malloc(sizeof(ST_FILE_HEADER));
	if(head == NULL)
	{
		CLI_PRINT("Malloc error.\n");
		close(src_fd);
		return RET_FAIL;
	}
	memset(head,0,sizeof(ST_FILE_HEADER));
	CLI_PRINT("Malloc done.\n");
	//memcpy(head->name,"pisc_v1.0",strlen("pisc_v1.0"));
	strncpy(head->name,"pisc_v1.0",strlen("pisc_v1.0"));
	head->type 	= TYPE_PISC;	// 文件类型,区别于消息类型
	head->size 	= 1024;			// 乱填的数据
	head->version = 1;			// 乱填的数据
	head->crc 	= 555;			// 乱填的数据
	CLI_PRINT("memcpy done.\n");	
	PST_MSG message = makePack(TYPE_MSG_HEAD,&head);
	CLI_PRINT("Make package done..\n");
	
	/* 4.发送测试数据 */
	printf("######### Ready to send data #########\n");
	dst_addr.sin_family 		= AF_INET;
	//dst_addr.sin_addr.s_addr	= inet_addr("192.168.16.67");
	dst_addr.sin_addr.s_addr	= inet_addr("192.168.16.181");
	dst_addr.sin_port			= htons(UDP_PORT);

	while(1)
	{
		retval = sendto(src_fd,message,sizeof(ST_MSG),0,(struct sockaddr *)&dst_addr,addr_sz);
		if(retval < 0)
		{
			CLI_PRINT("Send data error.\n");
		}
		
		CLI_PRINT("Client send %d bytes data.\n",retval);
		sleep(2);

	}

	free(head);
	free(msg);
	return RET_OK;
}