Exemplo n.º 1
1
//  ------------------------------------------------------------------------
//  ------------------------------------------------------------------------
void entering_info( DWORD SesId, DWORD SesTyp, HANDLE token, LPVOID param ){	//определение пользователя
    char *wuser = NULL;
    char *bufa = NULL;
    char *whost = NULL;
    DWORD usersize = 0;
    DWORD hostsize = 0;
    DWORD size = 0;
//  --
    if((!WTSQuerySessionInformation( WTS_CURRENT_SERVER_HANDLE, SesId, WTSUserName, &wuser, &usersize ))
    ||(!WTSQuerySessionInformation( WTS_CURRENT_SERVER_HANDLE, SesId, WTSClientAddress, &bufa, &size ))){
        prn_err( "WTSQuerySessionInformation failed.", GetLastError() );
        return;
    }else if( bufa ){
        WTS_CLIENT_ADDRESS *pAddr = (WTS_CLIENT_ADDRESS *) bufa;
        if(!WTSQuerySessionInformation( WTS_CURRENT_SERVER_HANDLE, SesId, WTSClientName, &whost, &hostsize )){
            prn_err( "WTSQuerySessionInformation failed.", GetLastError() );
        }else{
            char bs[10];
            ZeroMemory(&bs, 12 );
            char ba[25];
            ZeroMemory(&ba, 26 );
            sprintf( ba, "%u.%u.%u.%u", pAddr->Address[2], pAddr->Address[3], pAddr->Address[4], pAddr->Address[5] );
// ipv6     sprintf( ba, "%u.%u.%u.%u.%u.%u", pAddr->Address[0], pAddr->Address[1], pAddr->Address[2], pAddr->Address[3], pAddr->Address[4], pAddr->Address[5] );
//  --
            if(( SesTyp == 1 )||( SesTyp == 2 )){
                strcpy( bs, "Console" );
            }else if(( SesTyp == 3 )||( SesTyp == 4 )){
                strcpy( bs, "Remote" );
            }else if(( SesTyp == 5 )||( SesTyp == 6 )){
                strcpy( bs, "Logon" );
            }else if(( SesTyp == 7 )||( SesTyp == 8 )){
                strcpy( bs, "Lock" );
            }else{
                sprintf( bs, "Type-%u", SesTyp );
            }
//  --
            if( strlen( ba ) < 8 ) strcpy( ba, "localhost" );

            char pc[128];		// char *pc = malloc( sizeof( char ) * 64 );
            ZeroMemory(&pc, 128 );
            if( hostsize > 1 ) strcpy( pc, whost );
            else strcpy( pc, "localhost" );
//  --
            if( SesTyp % 2 ){	// если не кратна двум то начало
                sprintf( msg_err, "Begin Session Id-%i, Type-%i (%s), User:%s, Host:%s, IP:%s.", SesId, SesTyp, bs, wuser, pc, ba );
                prn_log( msg_err );
                if(( JOB > 100 )&&( SesTyp < 7 )) new_session( SesId, SesTyp, bs, wuser, token, pc, ba );
            }else{
                sprintf( msg_err, "End Session Id-%i, Type-%i (%s), User:%s.", SesId, SesTyp, bs, wuser );
                prn_log( msg_err );
                if(( JOB > 100 )&&( SesTyp < 7 )) end_session( SesId, SesTyp, bs, wuser );
            }
//  --
            WTSFreeMemory( whost );
        }
//  --
        WTSFreeMemory( bufa );
        WTSFreeMemory( wuser );
    }
}
Exemplo n.º 2
0
int VPN_setVPN_route(int netmode)
{
#if (_CONFIG_VPN_MODULE != 0)
    int hostNum=0;
    INT8 tmpbuf[128];
    memset((void *)tmpbuf,0 ,sizeof(tmpbuf));

    //添加VPN路由节点
    prn_log3("s_VPN_IP=%s, s_ori_gw=%s",s_VPN_IP, s_ori_gw_IP);
    if(strcmp(s_VPN_IP,""))
    {
        prn_log("执行 添加VPN路由节点");
        if (netmode == NET_LAN)
        {
            sprintf(tmpbuf, "route add %s gw %s eth0", s_VPN_IP, s_ori_gw_IP);
        }
        else
        {
            sprintf(tmpbuf, "route add %s gw %s ppp0", s_VPN_IP, s_ori_gw_IP);
        }
        prn_log2("tmpbuf= %s",tmpbuf);
        system(tmpbuf);
    }

    //删除原默认网关
    if(strcmp(s_ori_gw_IP,""))
    {
        prn_log("执行 删除原默认网关");
        if (netmode == NET_LAN)
        {
            sprintf(tmpbuf, "route del default eth0");
        }
        else
        {
            sprintf(tmpbuf, "route del default ppp0");
        }
        prn_log2("tmpbuf= %s",tmpbuf);
        system(tmpbuf);
    }

    return VPN_SUCCESS;

#else
    return VPN_SUCCESS;
#endif
}
Exemplo n.º 3
0
UINT8 ReadPrintTemplate(UINT8 TemplateNo)
{
	prn_log("CGlobalArg::ReadPrintTemplate");

	UINT8 *TemplateBuf;
	TemplateBuf = templateBuffer;
	UINT32 len = PRINT_TEMPLATE_BUF_LEN;
#ifndef WIN32
	INT8 tmp[16];
	INT8 name[32];
	INT32 fd;
	
	memset(name, 0, sizeof(name));
	sprintf(name, "%s%02u.txt", PRINT_TEMPLATE_FILE_NAME, TemplateNo);
	prn_log2("Template file: %s", name);
	
	if ( (fd = open(name, O_RDONLY)) == -1 )
	{
		prn_log("open Template file err");
		return FAILURE;
	}
	else
	{
		memset(TemplateBuf, 0, PRINT_TEMPLATE_BUF_LEN);
		read(fd, TemplateBuf, len);
	}
	
	close(fd);
	
#else
	int i;
	for (i=0;i<200;i++)
		TemplateBuf[i] = i+1;
	for (i=0;i<200;i++)
		TemplateBuf[i+200] = i+1;
	for (i=0;i<200;i++)
		TemplateBuf[i+400] = i+1;
	TemplateBuf[0]='B';
#endif
	
	return SUCCESS;
}
Exemplo n.º 4
0
int VPN_connent(const char *ip, const char *userName, const char* passwd)
{
#if (_CONFIG_VPN_MODULE != 0)

    int ret=0;

    prn_log("enter VPN_Connet");
    if((ret=setLocalVar(ip,userName,passwd))!=VPN_SUCCESS)
    {
        prn_log2("ret = %d", ret);
        return ret;
    }


    prn_log("execute xl2tpd");
#if (_DBG_PRINT_TRANSDATA == 0)
    ret = system("../xl2tpd &");
#else
    ret = system("../xl2tpd -D &");
#endif
    if(ret != 0)
    {
        return VPN_RUN_XL2TPD_ER;
    }
    CommonSleep(2000);

    prn_log("execute l2tp");
    ret = system("../l2tp");
    if(ret != 0)
    {
        return VPN_RUN_L2TP_ER;
    }
    CommonSleep(2000); //3000
    prn_log("connectProc complate");

    return VPN_SUCCESS;
#else
    return VPN_SUCCESS;
#endif
}
Exemplo n.º 5
0
//  ------------------------------------------------------------------------
VOID WINAPI ServiceCtrlHandlerEx( DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext){// callback-функция, вызывается ОС
    WTSSESSION_NOTIFICATION *wn;
    HANDLE hToken;
//  -------------------------
    switch( dwControl ){
        case SERVICE_CONTROL_SESSIONCHANGE:
            wn = (WTSSESSION_NOTIFICATION*)lpEventData;
            if( WTSQueryUserToken( wn->dwSessionId, &hToken )) entering_info( wn->dwSessionId, dwEventType, hToken, lpContext );
            break;
//  --
        case SERVICE_CONTROL_STOP:
            send_sm_string( "SM;SyMon;STOP;!" );
            prn_log( "WARNING! STOP SERVICE." );
            kill_all_user_proc();
            JOB = 3;
            prn_log( "End." );
            sleep(1);
            service_status.dwCurrentState = SERVICE_STOPPED;
            SetServiceStatus(hServiceStatus, &service_status);
            break;
//  --
        case SERVICE_CONTROL_SHUTDOWN:
            send_sm_string( "SM;SYSTEM;SHUTDOWN;!" );
            prn_log( "WARNING! SYSTEM SHUTDOWN." );
            kill_all_user_proc();
            prn_log( "End." );
            sleep(1);
            service_status.dwCurrentState = SERVICE_STOPPED;
            SetServiceStatus(hServiceStatus, &service_status);
            break;
//  --
        default:
            ++service_status.dwCheckPoint;
            SetServiceStatus(hServiceStatus, &service_status);
            break;
    }
  return;
}
Exemplo n.º 6
0
int getIPandMASK(const char *keyword, IPinfo *info)
{
	int sock_get_ip;  
	struct   sockaddr_in *sin;  
	struct   ifreq ifr_ip;     

	if ((sock_get_ip=socket(AF_INET, SOCK_STREAM, 0)) == -1)  
	{  
		prn_log("create socket failse! (GetLocalIp)");  
		return OPEN_SOCKET_ER;  
	}  

	memset(&ifr_ip, 0, sizeof(ifr_ip));     
	strncpy(ifr_ip.ifr_name, keyword, sizeof(ifr_ip.ifr_name) - 1);     

	if( ioctl( sock_get_ip, SIOCGIFADDR, &ifr_ip) < 0 )     
	{     
		prn_log("ioctl SIOCGIFADDR fail!");  
		close( sock_get_ip );  
		return GET_IP_FAIL;     
	}       
	sin = (struct sockaddr_in *)&ifr_ip.ifr_addr;     
	strncpy(info->IP, inet_ntoa(sin->sin_addr), sizeof(info->IP));         

	if( ioctl( sock_get_ip, SIOCGIFNETMASK, &ifr_ip) < 0 )     
	{     
		prn_log("ioctl SIOCGIFNETMASK fail!");  
		close( sock_get_ip );  
		return GET_MASK_FAIL;     
	}       
	sin = (struct sockaddr_in *)&ifr_ip.ifr_addr;     
	strncpy(info->Mask, inet_ntoa(sin->sin_addr), sizeof(info->Mask));         

	
	close( sock_get_ip );  

	return GET_IPINFO_SUCCESS;  	
}
Exemplo n.º 7
0
//  ------------------------------------------------------------------------
//  ------------------------------------------------------------------------
LONG WINAPI UnhandledException(LPEXCEPTION_POINTERS exceptionInfo){// Exception идут сюда
    prn_log(msg_err);
    prn_log("\nFATAL_ERROR: UnhandledException(!!!)\n");
return EXCEPTION_EXECUTE_HANDLER;
}
Exemplo n.º 8
0
//  ------------------------------------------------------------------------
//  ------------------------------------------------------------------------
VOID WINAPI ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv){
    sprintf( msg_err, "ServiceMain - init." );
    DWORD xParam = 1;
    JOB = 1;
//  --
    hServiceStatus = RegisterServiceCtrlHandlerEx( service_name, (LPHANDLER_FUNCTION_EX)ServiceCtrlHandlerEx, (PVOID)&xParam );
    if( !hServiceStatus ){
        prn_err( "RegisterServiceCtrlHandlerEx failed.", GetLastError() );
        return;
    }
// init
    service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
    service_status.dwCurrentState = SERVICE_START_PENDING;
    service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_SESSIONCHANGE;
    service_status.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
    service_status.dwServiceSpecificExitCode = 0;
    service_status.dwCheckPoint = 0;
    service_status.dwWaitHint = 5000;

    if( !SetServiceStatus( hServiceStatus, &service_status )){
        prn_err( "SetServiceStatus 'NULL' failed.", GetLastError() );
        return;
    }

// Rabota
    service_status.dwCurrentState = SERVICE_RUNNING;
    service_status.dwWin32ExitCode = NO_ERROR;
// Set New
    if( !SetServiceStatus( hServiceStatus, &service_status )){
        prn_err( "SetServiceStatus 'SERVICE_START_PENDING' failed.", GetLastError() );
        return;
    }
//  --
    usleep(10000);
//  ------------------------------------------------------------------------
prn_log( "." );
    SetPriorityClass( GetCurrentProcess(), HIGH_PRIORITY_CLASS );
prn_log( "START SERVICE." );
//  ---------------------------------
    if( !init_conf( service_work, service_name, &conf )){	// возврат всегда "1"
        prn_err( "Init config-data failed. This message can not be", 0 );
    }else{
        if( strcasecmp( conf.log_debug, "Off" ) == 0 ) DEBUG = 0;
        else prn_log( "Logger - DEBUG" );
//  --
        if( strcasecmp( conf.user_proc,   "0" ) == 0 ) prn_log( "WARNING! User Process - disabled." );
        if( strcasecmp( conf.maintenance, "0" ) == 0 ) prn_log( "WARNING! Maintenances - disabled." );
        if( strcasecmp( conf.git_exec,    "0" ) == 0 ) prn_log( "WARNING! Git status   - disabled." );
    }
//  --
    JOB = 2;
// Создаем поток логирования cygwin (сокет /dev/log) для ssh-сессий
    HANDLE hCygWinLogThread = CreateThread( NULL, 0, &CygWinLogThread, (LPVOID)&conf, 0, NULL );
    if( !hCygWinLogThread ){
        prn_err( "LogSocket: Create CygWinLogThread - failed.", GetLastError() );
    }
//  ---------------------------------
    JOB = 3;
    if( !open_send( conf.zbx_server, conf.zbx_port, conf.zbx_host )){
        prn_log( "WARNING! Sender not available: Maintenances - will not be available." );
        strcpy( conf.maintenance, "0" );
    }
//  ---------------------------------
    JOB = 22;
// потоки обслуживания
//    HANDLE hGTimeThread = CreateThread( NULL, 0, &GTimeThread, NULL, 0, NULL );// поток
//  ---------------------------------

    usleep(10000);
    JOB = 101;
    send_sm_string( "SM;SyMon;START;!" );
//  --
//  проверка активных сессий
    DWORD pCount;
    HANDLE hToken;
    PWTS_SESSION_INFO ppSessionInfo = NULL;
    HANDLE hTS = WTSOpenServer( "" );
//  --
    if( WTSEnumerateSessions(hTS, 0, 1, &ppSessionInfo, &pCount )){
        while( pCount ){
            if( ppSessionInfo->State == 0 ){
                if( WTSQueryUserToken( ppSessionInfo->SessionId, &hToken )) entering_info( ppSessionInfo->SessionId, 5, hToken, NULL );
                else prn_err( "WTS Token failed.", GetLastError() );
            }

            ppSessionInfo++;
            pCount--;
        }
    }

//  -----------------------------------
    while( JOB > 100 ){ // главный цикл
        git_test();	// выполнение отложенных (тормозных) функций

        sleep(1);
    }
//  --
//    CloseHandle( hGTimeThread );
    sleep( 2 );
    close_send();
    sprintf( msg_err, "ServiceMain - return." );
//  ------------------------------------------------------------------------
}
Exemplo n.º 9
0
UINT8  ParseTempLine(TPrnInvoiceInfo *pInv,TPrnLineInfo **pPrnLine)
{
	
	UINT8 *tempLineBuf=NULL;	
	UINT8 chBegin=0;
	UINT8 hzNum = 0;
	UINT8 HZCounte = 0;
	UINT8 ascNum = 0;
	UINT8 gbhz = 0;	
	UINT8 ii = 0;
    prn_log("start ParseTempLine ");

	if(pPrnLineInfo == NULL)
	{
	    pPrnLineInfo = &PrintLineInfo;	
	}

    if( pInv == NULL )
    {
        return 1;
    } 
	
	InitPrinLineInfo(pPrnLineInfo);
	
		
	memset(pprnTempLine2,0,sizeof(TPrnTempRow));
	
	    
    //打印电子存根
    if (stubFlag == 1)
	{	
		strncpy(&(pPrnLineInfo->chContent[stubPlace]),"电  子  存  根",strlen("电  子  存  根"));
	    stubFlag =0;
	    pPrnLineInfo->FontW = prnTempLine1.FontW;
		pPrnLineInfo->FontH = prnTempLine1.FontH;
		pPrnLineInfo->Bhigh = 16;		//为了打印完 电子存根  后有段距离,写死为16不太合适
			
    	*pPrnLine= pPrnLineInfo;
        prn_log("end ParseTempLine ");
        return 0;
	}

	if((stubFlag ==2) && (pSaveTemplateInfo->workMode != WORK_MODE))
	{
		strncpy(&(pPrnLineInfo->chContent[stubPlace]),"不 可 报 销",strlen("不 可 报 销"));
	    stubFlag =0;
	    pPrnLineInfo->FontW = prnTempLine1.FontW;
		pPrnLineInfo->FontH = prnTempLine1.FontH;
	
    	*pPrnLine= pPrnLineInfo;
        prn_log("end ParseTempLine ");
        return 0;
	}
	//折行打印
    if( (continueWriteFlag == 1) || (continueWriteFlag == 2))
	{
		continueWriteFlag = 0;	
		conWriteBuffer->FontW = prnTempLine1.FontW;
		conWriteBuffer->FontH = prnTempLine1.FontH;
        *pPrnLine= conWriteBuffer;
       
        prn_log("end ParseTempLine ");
        return 0;
	}

	if (continueWriteFlag == 3)
	{
		prn_log2("CorpNameCounte = %u", CorpNameCounte);
		if (CorpNameCounte == 0)
		{
			continueWriteFlag = 0;	
			conWriteBuffer->FontW = prnTempLine1.FontW;
			conWriteBuffer->FontH = prnTempLine1.FontH;
        }
        else
        {
        	while(1)
			{
				if (*endPointer == '\0')
				{
					CorpNameCounte = 0;
					break;
				}
				if (HZCounte == (42 - continueWriteLocation) / 2)
				{
					break;
				}
				gbhz = is_gb_4byte(endPointer);
				prn_log2("gbhz = %u", gbhz);
				if (gbhz == 2)
				{
					endPointer += 4;
					HZCounte++;
				}
				if (gbhz == 1)
				{
					endPointer += 2;
					HZCounte++;
				}
				if (gbhz == 0)
				{
					endPointer += 1;
					ascNum++;
					if (ascNum == 2)
					{
						HZCounte++;
						ascNum = 0;
					}
				}
				prn_log2("endPointer = %x", endPointer);
			}
			prn_log2("HZCounte = %u", HZCounte);
			prn_log2("endPointer-startPointer = %u", endPointer-startPointer);
			strncpy(&(conWriteBuffer->chContent[continueWriteLocation-1]), (INT8 *)startPointer, endPointer-startPointer);
			conWriteBuffer->chContent[continueWriteLocation-1+endPointer-startPointer] = 0x00;
			prn_log2("conwritebuffer内容  %s", conWriteBuffer->chContent);
			startPointer = endPointer;
			HZCounte = 0;
			*pPrnLine = conWriteBuffer;
			
			return 0;
        }
	}
	
	InitPrinLineInfo(conWriteBuffer);
	

	tempLineBuf = NULL;
	GetTemplateLineBuffer((void **)&tempLineBuf);
    	
	if (!tempLineBuf)
	{
		prn_log("tempLineBuf == NULL");
		return 1;
	}
	
	if(CycleTempFlag == 0)
	{
		if( (ii = GetPtLine(&prnTempBuf,tempLineBuf)) != 0)
		{
			prn_log("获取下一个模板行");
			prn_log2("ii = %d", ii);
			
			return 2;
		}	
    }
    //如果循环行开始标志为1,则将tempLineBuf内容拷到另一个模板行缓存中
	if(BeginCycleTemp == 1)
	{
		memset((void *)CycleTempLineBuf, 0, TEMPLATE_LINE_BUF_LEN);
		memcpy((void *)CycleTempLineBuf, (void *)tempLineBuf, TEMPLATE_LINE_BUF_LEN);
		BeginCycleTemp = 0;
	}
	//循环行内容标志为1,直接调用解析存储的另一个模板行
	if(CycleTempFlag == 1)
	{
		templateNo += 1;
		
		if( ParsePtLine2(CycleTempLineBuf,pprnTempLine2,pPrnLineInfo,&prnTempLine1) != 0)
        {
            return 3;
        }
        
        prn_log2("pPrnLineInfo->Property = %d",pPrnLineInfo->Property);
        
        
		if( GetPrnLineData(pprnTempLine2,conWriteBuffer,
                          &prnTempLine1,pPrnLineInfo,pInv) != 0)
        {
            return 4;
        }	
        
		
		//将输出的打印行中的'\0'替换为空格,除了行的末尾;
		ScanReplaceSpace(pPrnLineInfo);
		prn_log2("pPrnLineInfo->chContent = %s",pPrnLineInfo->chContent);
		prn_log2("pPrnLineInfo->FontH = %d", pPrnLineInfo->FontH);
		*pPrnLine= pPrnLineInfo;
        prn_log("end ParseTempLine ");
        return 0;	
	}
	
	//通过判断模板行第一个字符,选择处理函数;
	chBegin = *tempLineBuf;
	
	//模板行解析结束,将打印行结构和模板行缓存置为初始状态,等待下一次调用;			
	if (*tempLineBuf == 'E')
	{
        prn_log("模板行最后一行");      
		pPrnLineInfo = NULL;
		memset(tempLineBuf,0,TEMPLATE_LINE_BUF_LEN);
		prnTempBuf = templateBuffer;
		templateNo = 0;              
	}	
	
	else
	{		
		
		switch(chBegin)
		{
		case '2':		
			 
			
			if( ParsePtLine2(tempLineBuf,pprnTempLine2,pPrnLineInfo,&prnTempLine1) != 0)
            {
                return 3;
            }

			if( GetPrnLineData(pprnTempLine2,conWriteBuffer,
                              &prnTempLine1,pPrnLineInfo,pInv) != 0)
            {
                return 4;
	        }				
	        				
			//将输出的打印行中的'\0'替换为空格,除了行的末尾;
			ScanReplaceSpace(pPrnLineInfo);
			
			prn_log2("pPrnLineInfo->chContent = %s",pPrnLineInfo->chContent);
			prn_log2("pPrnLineInfo->FontH = %d", pPrnLineInfo->FontH);
						
			break;
			
		case '1': 
			if( ParsePtLine1(tempLineBuf,&prnTempLine1) != 0)
            {
                   return 3;
            }
			
			/*解析后,将模板行1结构体中的相应属性值赋给打印行结构体,包括
			 * 行属性,开始走纸距离,结束走纸距离和是否找黑标,字体的高度和宽度 */
			 
			pPrnLineInfo->Property = NEED_SAVE_TEMPLATE_LINE;
			pPrnLineInfo->BeginForwardPoint = (INT16)prnTempLine1.BeginForwardPoint;
			pPrnLineInfo->EndForwardPoint = (INT16)prnTempLine1.EndForwardPoint;
			pPrnLineInfo->MarkFlag = prnTempLine1.MarkFlag;
			//pPrnLineInfo->Tymhead = prnTempLine1.Tymhead;
			//pPrnLineInfo->Tymtail = prnTempLine1.Tymtail;

			pPrnLineInfo->FontW = prnTempLine1.FontW;
			pPrnLineInfo->FontH = prnTempLine1.FontH;

			pPrnLineInfo->BackwardPoint = prnTempLine1.BackwardPoint;
			
			prn_log2("pPrnLineInfo->BackwardPoint = %d",pPrnLineInfo->BackwardPoint);
	
			
			break;
			
		case '0':
		
			if( ParsePtLine0(tempLineBuf,&prnTempLine0) != 0 )
            {
                  return 3;
            }
			
			pPrnLineInfo->Property = INVALID_TEMPLATE_LINE;	
			
			break;
			
		case 'B':	
		
			pPrnLineInfo->Property = INVALID_TEMPLATE_LINE;	
			break;
		default:
		    return 5;
		}		

		memset(tempLineBuf,0,TEMPLATE_LINE_BUF_LEN);
		
	}//end of else
	
	*pPrnLine= pPrnLineInfo;
   prn_log("end ParseTempLine ");
    return 0;	
}
Exemplo n.º 10
0
int VPN_getOri_route()
{
#if (_CONFIG_VPN_MODULE != 0)
    prn_log("enter getOri_route");
    INT32 num=0, hostNum=0;
    INT32 ret=0;
    UINT32 tmpdesi=0, tmpgw=0;
    RouteInfo route;
    INT8 tmpBuf[128];
    FILE *fp=NULL;

    memset(s_ori_host_IP, 0, sizeof(s_ori_host_IP));
    memset(s_ori_host_type, 0, sizeof(s_ori_host_type));

    //打开文件
    fp = fopen("/proc/net/route", "r");
    if (fp==NULL)
    {
        return VPN_READ_ROUTE_ER;
    }
    prn_log("读取s_ori_gw_IP");
    //逐行读取,直到文件结束
    num=0;
    hostNum = 0;
    while (1)
    {
        memset(tmpBuf, 0, sizeof(tmpBuf));
        if ((ret=getLinefromFile(fp, (UINT8*)tmpBuf, sizeof(tmpBuf))) == VPN_FILE_EOF)
        {
            prn_log2("ret= %d",ret);
            break;
        }
        if (num==0 || strlen(tmpBuf)<10)
        {
            num++;
            continue;
        }

        sscanf(tmpBuf, "%s %X %X %X", route.Iface, &tmpdesi, &tmpgw, &route.Flags);
        route.Destination[0] = (UINT8)(tmpdesi & 0x000000ff);
        route.Destination[1] = (UINT8)(tmpdesi>>8 & 0x000000ff);
        route.Destination[2] = (UINT8)(tmpdesi>>16 & 0x000000ff);
        route.Destination[3] = (UINT8)(tmpdesi>>24 & 0x000000ff);

        route.Gateway[0] = (UINT8)(tmpgw & 0x000000ff);
        route.Gateway[1] = (UINT8)(tmpgw>>8 & 0x000000ff);
        route.Gateway[2] = (UINT8)(tmpgw>>16 & 0x000000ff);
        route.Gateway[3] = (UINT8)(tmpgw>>24 & 0x000000ff);

        prn_log2("Iface = %s", route.Iface);
        prn_log2("Flags = %x", route.Flags);
        prn_log5("%d.%d.%d.%d", route.Destination[0], route.Destination[1], route.Destination[2], route.Destination[3]);
        prn_log5("%d.%d.%d.%d", route.Gateway[0], route.Gateway[1], route.Gateway[2], route.Gateway[3]);

        if ((route.Destination[0]==0) && (route.Destination[1]==0) && (route.Destination[2]==0) && (route.Destination[3]==0))
        {
            prn_log5("%d.%d.%d.%d", route.Gateway[0], route.Gateway[1], route.Gateway[2], route.Gateway[3]);
            sprintf(s_ori_gw_IP, "%d.%d.%d.%d", route.Gateway[0], route.Gateway[1],route.Gateway[2], route.Gateway[3]);
            prn_log2("s_ori_gw_IP= %s",s_ori_gw_IP);
        }
        else
        {
            if (route.Flags == 0x0001)
            {
                num++;
                continue;
            }

            sprintf(s_ori_host_IP[hostNum], "%d.%d.%d.%d", route.Destination[0], route.Destination[1],
                    route.Destination[2], route.Destination[3]);
            prn_log2("s_ori_host_IP[hostNum]= %s",s_ori_host_IP[hostNum]);
            sprintf(s_ori_host_type[hostNum], "%s", route.Iface);
            prn_log2("s_ori_host_type[hostNum]= %s",s_ori_host_type[hostNum]);
            hostNum++;
        }

        num++;
    }
    fclose(fp);

    return VPN_SUCCESS;

#else
    return VPN_SUCCESS;
#endif
}