void CNetworkSetup::showCurrentNetworkSettings()
{
	std::string ip, mask, broadcast, router, nameserver, text;
	netGetIP(g_settings.ifname, ip, mask, broadcast);
	if (ip[0] == 0) {
		text = g_Locale->getText(LOCALE_NETWORKMENU_INACTIVE_NETWORK);
	}
	else {
		netGetNameserver(nameserver);
		netGetDefaultRoute(router);
#if 0 // i think we can use current networkConfig instance for that
		CNetworkConfig  _networkConfig;
		std::string dhcp = _networkConfig.inet_static ? g_Locale->getText(LOCALE_OPTIONS_OFF) : g_Locale->getText(LOCALE_OPTIONS_ON);
#endif
		std::string dhcp = networkConfig->inet_static ? g_Locale->getText(LOCALE_OPTIONS_OFF) : g_Locale->getText(LOCALE_OPTIONS_ON);

		text = (std::string)g_Locale->getText(LOCALE_NETWORKMENU_DHCP) + ": " + dhcp + '\n'
			+ g_Locale->getText(LOCALE_NETWORKMENU_IPADDRESS ) + ": " + ip + '\n'
			+ g_Locale->getText(LOCALE_NETWORKMENU_NETMASK   ) + ": " + mask + '\n'
			+ g_Locale->getText(LOCALE_NETWORKMENU_BROADCAST ) + ": " + broadcast + '\n'
			+ g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER) + ": " + nameserver + '\n'
			+ g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY   ) + ": " + router;
	}
	ShowMsg(LOCALE_NETWORKMENU_SHOW, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8
}
Esempio n. 2
0
void showCurrentNetworkSettings()
{
	char ip[16];
	char mask[16];
	char broadcast[16];
	char router[16];
	char nameserver[16];
	std::string text;
	
	netGetIP("eth0", ip, mask, broadcast);
	if (ip[0] == 0) {
		text = g_Locale->getText(LOCALE_NETWORKMENU_INACTIVE);
	}
	else {
		netGetNameserver(nameserver);
		netGetDefaultRoute(router);
		CNetworkConfig  networkConfig;
		std::string dhcp = networkConfig.inet_static ? g_Locale->getText(LOCALE_OPTIONS_OFF) : g_Locale->getText(LOCALE_OPTIONS_ON);

		text = (std::string)g_Locale->getText(LOCALE_NETWORKMENU_DHCP) + ": " + dhcp + '\n'
				  + g_Locale->getText(LOCALE_NETWORKMENU_IPADDRESS ) + ": " + ip + '\n'
				  + g_Locale->getText(LOCALE_NETWORKMENU_NETMASK   ) + ": " + mask + '\n'
				  + g_Locale->getText(LOCALE_NETWORKMENU_BROADCAST ) + ": " + broadcast + '\n'
				  + g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER) + ": " + nameserver + '\n'
				  + g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY   ) + ": " + router;
	}
	ShowMsgUTF(LOCALE_NETWORKMENU_SHOW, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8
}
Esempio n. 3
0
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
}
Esempio n. 4
0
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
}
Esempio n. 5
0
void showCurrentNetworkSettings()
{
	char ip[16];
	char mask[16];
	char broadcast[16];
	char router[16];
	char nameserver[16];
	std::string mac;
	std::string text;

	//netGetIP((char *) "eth0",ip,mask,broadcast);
	netGetIP(g_settings.ifname, ip, mask, broadcast);
	
	if (ip[0] == 0) 
	{
		text = "Network inactive\n";
	}
	else 
	{
		netGetNameserver(nameserver);
		netGetDefaultRoute(router);

		//netGetMacAddr(g_settings.ifname, (unsigned char *)mac.c_str());
		//text = "Box: " + mac + "\n    ";
		
		text  = g_Locale->getText(LOCALE_NETWORKMENU_IPADDRESS );
		text += ": ";
		text += ip;
		text += '\n';
		text += g_Locale->getText(LOCALE_NETWORKMENU_NETMASK   );
		text += ": ";
		text += mask;
		text += '\n';
		text += g_Locale->getText(LOCALE_NETWORKMENU_BROADCAST );
		text += ": ";
		text += broadcast;
		text += '\n';
		text += g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER);
		text += ": ";
		text += nameserver;
		text += '\n';
		text += g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY   );
		text += ": ";
		text += router;
	}
	
	MessageBox(LOCALE_NETWORKMENU_SHOW, 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
}