Beispiel #1
0
void Detection::WorkFunc()
{
    CheckIP138();
    CheckIP();
    TestTinydrag();
    Ping();
    GetLocalIP();
    Test9KAPPPAC();
    Test9K();
    Test8888();
    boost::thread work_thread(boost::bind(&Detection::TestTracker, this));
    for (int i = 0; i < 5 * 60; ++i)
    {
        if (i % 3 == 0)
        {
            ++m_progress_pos_;
            if (i % 60 == 0)
            {
                Test9K();
            }
        }
        Sleep(1000);
    }
    Analyze();
    TestBs();
    Test9K();
    WriteTrackerResult();
    Sleep(1000);
    MessageBox("测试完毕!");
}
Beispiel #2
0
static int isModemSettingChanged(void)
{
	int n;
	char ipaddr[4][4];
	char string[MAX_NUM_LEN];
	
	if (gOptions.ModemEnable != SendMessage(ModemWnd[0], CB_GETCURSEL, 0 ,0)){
		return 1;
	}

	if (module_type != MODEM_MODULE_EM660) {
		memset(string, 0, sizeof(string));
		GetWindowText(ModemWnd[1], string, sizeof(string));
		if (strncmp(ModemAPN, string,sizeof(string)) != 0){
			return 1;
		}
	}

	memset(string, 0, sizeof(string));
	GetWindowText(ModemWnd[2], string, sizeof(string));
	if (strncmp(ModemDialNumber, string,sizeof(string)) != 0){
		return 1;
	}

	memset(string, 0, sizeof(string));
	GetWindowText(ModemWnd[3], string, sizeof(string));
	if (strncmp(ModemUserName, string,sizeof(string)) != 0){
		return 1;
	}

	memset(string, 0, sizeof(string));
	GetWindowText(ModemWnd[4], string, sizeof(string));
	if (strncmp(ModemPassWord, string,sizeof(string)) != 0){
		return 1;
	}

	memset(string, 0, sizeof(string));
	GetWindowText(ModemWnd[5], ipaddr[0], sizeof(ipaddr[0]));
	GetWindowText(ModemWnd[6], ipaddr[1], sizeof(ipaddr[1]));
	GetWindowText(ModemWnd[7], ipaddr[2], sizeof(ipaddr[2]));
	GetWindowText(ModemWnd[8], ipaddr[3], sizeof(ipaddr[3]));
	if (CheckIP(ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3], 1) || 
		((strcmp(ipaddr[0], "0")==0) && (strcmp(ipaddr[1], "0")==0) && (strcmp(ipaddr[2], "0")==0) && (strcmp(ipaddr[3], "0")==0))) {
		n = sprintf(string, "%d.%d.%d.%d", atoi(ipaddr[0]), atoi(ipaddr[1]), atoi(ipaddr[2]), atoi(ipaddr[3]));
		string[n] = '\0';
		if (strncmp(HeartBeatServer, string, sizeof(string)) != 0) {
			return 1;
		}
	}

	return 0;
}
Beispiel #3
0
static void SaveModemSetting(HWND hWnd)
{
	int n;
	char string[MAX_NUM_LEN];
	char ipaddr[4][4];

	gOptions.ModemEnable = SendMessage(ModemWnd[0], CB_GETCURSEL, 0, 0);

	if (module_type != MODEM_MODULE_EM660) {
		memset(string, 0, sizeof(string));
		GetWindowText(ModemWnd[1], string, sizeof(string));
		SaveStr("APN", string, 1);
	}

	memset(string, 0, sizeof(string));
	GetWindowText(ModemWnd[2], string, sizeof(string));
	SaveStr("ModemDialNumber", string, 1);

	memset(string, 0, sizeof(string));
	GetWindowText(ModemWnd[3], string, sizeof(string));
	SaveStr("ModemUserName", string, 1);

	memset(string, 0, sizeof(string));
	GetWindowText(ModemWnd[4], string, sizeof(string));
	SaveStr("ModemPassword", string, 1);

	GetWindowText(ModemWnd[5], ipaddr[0], sizeof(ipaddr[0]));
	GetWindowText(ModemWnd[6], ipaddr[1], sizeof(ipaddr[1]));
	GetWindowText(ModemWnd[7], ipaddr[2], sizeof(ipaddr[2]));
	GetWindowText(ModemWnd[8], ipaddr[3], sizeof(ipaddr[3]));

	if (CheckIP(ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3], 1) 
		|| ((strcmp(ipaddr[0], "0")==0) && (strcmp(ipaddr[1], "0")==0) &&(strcmp(ipaddr[2], "0")==0) && (strcmp(ipaddr[3], "0")==0))) {
		n = sprintf(string, "%d.%d.%d.%d", atoi(ipaddr[0]), atoi(ipaddr[1]), atoi(ipaddr[2]), atoi(ipaddr[3]));
		string[n] = '\0';
		SaveStr("HeartBeatServer", string, 1);
	}

	SaveOptions(&gOptions);

        reload_modem_configuration();
        modem_reconnect();
        if (gOptions.ModemEnable == 0) {
                modem_thread_exit();
        } else {
                modem_thread_init();
        }
	
	MessageBox1 (hWnd ,LoadStrByID(HID_RESTART) ,LoadStrByID(HIT_RUN),MB_OK | MB_ICONINFORMATION);
}
Beispiel #4
0
SOCKET SOCK_Connect(std::string addr, unsigned short port, std::string localaddr, unsigned short localport)
{
    sockaddr_in local;
    memset(&local, 0, sizeof(local));
    local.sin_family = AF_INET;
    local.sin_addr.s_addr = inet_addr(localaddr.c_str());
    local.sin_port = htons(localport);
    SOCKET out = socket(AF_INET, SOCK_STREAM, 0);
    if(out == INVALID_SOCKET) return SERR_NOTCREATED;
    if(bind(out, (sockaddr*)&local, sizeof(local)) != 0)
    {
        closesocket(out);
        return SERR_NOTCREATED;
    }

    sockaddr_in remote;
    memset(&remote, 0, sizeof(remote));
    remote.sin_family = AF_INET;
    if(CheckIP(addr)) remote.sin_addr.s_addr = inet_addr(addr.c_str());
	else
	{
		struct hostent* host = gethostbyname(addr.c_str());
		if(!host)
		{
			closesocket(out);
			return SERR_NOTCREATED;
		}

		remote.sin_addr.s_addr = *((unsigned long*)host->h_addr);
	}
    remote.sin_port = htons(port);
    if(connect(out, (sockaddr*)&remote, sizeof(remote)) != 0)
    {
        closesocket(out);
        return SERR_NOTCREATED;
    }

    return out;
}
static int get_new_ip(void)
{
	char str[3][50];
	char cc[3][16];
	int err=0;
	int i;
	if(wifidhcpflag) {
		return 1;
	}
	for(i=0;i<4;i++){
		GetWindowText(WifiWnd[3+i],cc[i],16);
	}
	if(CheckIP(cc[0],cc[1],cc[2],cc[3],1)) {
		sprintf(str[0],"%s.%s.%s.%s",cc[0],cc[1],cc[2],cc[3]);
	} else {
		err=1;
	}

	for(i=0;i<4;i++) {
		GetWindowText(WifiWnd[7+i],cc[i],16);
	}
	if(CheckIP(cc[0],cc[1],cc[2],cc[3],0)) {
		sprintf(str[1],"%s.%s.%s.%s",cc[0],cc[1],cc[2],cc[3]);
	} else {
		err=2;
	}

	for(i=0;i<4;i++) {
		GetWindowText(WifiWnd[11+i],cc[i],16);
	}
	if(CheckIP(cc[0],cc[1],cc[2],cc[3],0)) {
		sprintf(str[2],"%s.%s.%s.%s",cc[0],cc[1],cc[2],cc[3]);
	} else {
		err=3;
	}

	if(err) {
		switch(err)
		{
			case 1:
				MessageBox1(WififHwnd ,LoadStrByID(HIT_NETERROR1) ,LoadStrByID(HIT_ERR),MB_OK | MB_ICONINFORMATION);
				break;
			case 2:
				MessageBox1(WififHwnd ,LoadStrByID(HIT_NETERROR2) ,LoadStrByID(HIT_ERR),MB_OK | MB_ICONINFORMATION);
                                break;
			case 3:
				MessageBox1(WififHwnd ,LoadStrByID(HIT_NETERROR3) ,LoadStrByID(HIT_ERR),MB_OK | MB_ICONINFORMATION);
                                break;
			default:
				MessageBox1(WififHwnd ,LoadStrByID(HIT_ERROR0) ,LoadStrByID(HIT_ERR),MB_OK | MB_ICONINFORMATION);
                                break;
		}
		return 0;
	} else {
		memset(newip, 0, 54);
		sprintf(newip[0],"%s",str[0]);
		sprintf(newip[1],"%s",str[1]);
		sprintf(newip[2],"%s",str[2]);
	}
	return 1;
}