void testNetworkSettings(const char* ip, const char* netmask, const char* broadcast, const char* gateway, const char* nameserver, bool ip_static) { char our_ip[16]; char our_mask[16]; char our_broadcast[16]; char our_gateway[16]; char our_nameserver[16]; std::string text; if (ip_static) { strcpy(our_ip,ip); strcpy(our_mask,netmask); strcpy(our_broadcast,broadcast); strcpy(our_gateway,gateway); strcpy(our_nameserver,nameserver); } else { netGetIP((char *) "eth0",our_ip,our_mask,our_broadcast); netGetDefaultRoute(our_gateway); netGetNameserver(our_nameserver); } dprintf(DEBUG_NORMAL, "testNw IP : %s\n", our_ip); dprintf(DEBUG_NORMAL, "testNw Netmask : %s\n", our_mask); dprintf(DEBUG_NORMAL, "testNw Broadcast: %s\n", our_broadcast); dprintf(DEBUG_NORMAL, "testNw Gateway: %s\n", our_gateway); dprintf(DEBUG_NORMAL, "testNw Nameserver: %s\n", our_nameserver); text = our_ip; text += ": "; text += mypinghost(our_ip); text += '\n'; text += g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY); text += ": "; text += our_gateway; text += ' '; text += mypinghost(our_gateway); text += '\n'; text += g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER); text += ": "; text += our_nameserver; text += ' '; text += mypinghost(our_nameserver); text += "\nwww.google.de: "; text += mypinghost("173.194.35.152"); MessageBox(LOCALE_NETWORKMENU_TEST, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 }
void testNetworkSettings(const char* ip, const char* netmask, const char* broadcast, const char* gateway, const char* nameserver, bool ip_static) { char our_ip[16]; char our_mask[16]; char our_broadcast[16]; char our_gateway[16]; char our_nameserver[16]; std::string text, ethID, testsite; //set default testdomain and wiki-IP std::string defaultsite = "www.google.de", wiki_IP = "88.198.50.98"; //set physical adress static CNetAdapter netadapter; ethID=netadapter.getMacAddr(); //get www-domain testsite from /.version CConfigFile config('\t'); config.loadConfig("/.version"); testsite = config.getString("homepage",defaultsite); testsite.replace( 0, testsite.find("www",0), "" ); //use default testdomain if testsite missing if (testsite.length()==0) testsite = defaultsite; if (ip_static) { strcpy(our_ip, ip); strcpy(our_mask, netmask); strcpy(our_broadcast, broadcast); strcpy(our_gateway, gateway); strcpy(our_nameserver, nameserver); } else { netGetIP("eth0", our_ip, our_mask, our_broadcast); netGetDefaultRoute(our_gateway); netGetNameserver(our_nameserver); } printf("testNw IP: %s\n", our_ip); printf("testNw MAC-address: %s\n", ethID.c_str()); printf("testNw Netmask: %s\n", our_mask); printf("testNw Broadcast: %s\n", our_broadcast); printf("testNw Gateway: %s\n", our_gateway); printf("testNw Nameserver: %s\n", our_nameserver); printf("testNw Testsite %s\n", testsite.c_str()); text = (std::string)"dbox:\n" + " " + our_ip + ": " + mypinghost(our_ip) + '\n' + " " + "eth-ID: " + ethID + '\n' + g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY) + ":\n" + " " + our_gateway + ": " + ' ' + mypinghost(our_gateway) + '\n' + g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER) + ":\n" + " " + our_nameserver + ": " + ' ' + mypinghost(our_nameserver) + '\n' + "wiki.tuxbox.org:\n" + " via IP (" + wiki_IP + "): " + mypinghost(wiki_IP.c_str()) + '\n'; if (1 == pinghost(our_nameserver)) text += (std::string) " via DNS: " + mypinghost("wiki.tuxbox.org") + '\n' + testsite + ":\n" + " via DNS: " + mypinghost(testsite.c_str()) + '\n'; ShowMsgUTF(LOCALE_NETWORKMENU_TEST, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 }
void CNetworkSetup::testNetworkSettings() { std::string our_ip, our_mask, our_broadcast, our_gateway, our_nameserver; std::string text, testsite, offset = " "; //set default testdomain std::string defaultsite = "www.google.de"; //set wiki-URL and wiki-IP std::string wiki_URL = "wiki.neutrino-hd.de"; std::string wiki_IP = "89.31.143.1"; //get www-domain testsite from /.version CConfigFile config('\t'); config.loadConfig(TARGET_PREFIX "/.version"); testsite = config.getString("homepage",defaultsite); testsite.replace( 0, testsite.find("www",0), "" ); //use default testdomain if testsite missing if (testsite.length()==0) testsite = defaultsite; if (networkConfig->inet_static) { our_ip = networkConfig->address; our_mask = networkConfig->netmask; our_broadcast = networkConfig->broadcast; our_gateway = networkConfig->gateway; our_nameserver = networkConfig->nameserver; } else { // FIXME test with current, not changed ifname ? netGetIP(old_ifname, our_ip, our_mask, our_broadcast); netGetDefaultRoute(our_gateway); netGetNameserver(our_nameserver); } printf("testNw IP: %s\n", our_ip.c_str()); printf("testNw MAC-address: %s\n", old_mac_addr.c_str()); printf("testNw Netmask: %s\n", our_mask.c_str()); printf("testNw Broadcast: %s\n", our_broadcast.c_str()); printf("testNw Gateway: %s\n", our_gateway.c_str()); printf("testNw Nameserver: %s\n", our_nameserver.c_str()); printf("testNw Testsite: %s\n", testsite.c_str()); if (our_ip.empty()) { text = g_Locale->getText(LOCALE_NETWORKMENU_INACTIVE_NETWORK); } else { //Box text = "Box (" + old_mac_addr + "):\n"; text += offset + our_ip + " " + mypinghost(our_ip) + "\n"; //Gateway text += (std::string)g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY) + " (Router):\n"; text += offset + our_gateway + " " + mypinghost(our_gateway) + "\n"; //Nameserver text += (std::string)g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER) + ":\n"; text += offset + our_nameserver + " " + mypinghost(our_nameserver) + "\n"; //NTPserver if ( (pinghost(our_nameserver) == 1) && g_settings.network_ntpenable && (!g_settings.network_ntpserver.empty()) ) { text += std::string(g_Locale->getText(LOCALE_NETWORKMENU_NTPSERVER)) + ":\n"; text += offset + g_settings.network_ntpserver + " " + mypinghost(g_settings.network_ntpserver) + "\n"; } //Wiki text += wiki_URL + ":\n"; text += offset + "via IP (" + wiki_IP + "): " + mypinghost(wiki_IP) + "\n"; if (pinghost(our_nameserver) == 1) { text += offset + "via DNS: " + mypinghost(wiki_URL) + "\n"; //testsite (or defaultsite) text += testsite + ":\n"; text += offset + "via DNS: " + mypinghost(testsite) + "\n"; } } ShowMsg(LOCALE_NETWORKMENU_TEST, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 }