Project "Tuxbox-GIT: apps": The branch, master has been updated via ac506b8080684e05d10462dcbd89e0195cdb361f (commit) from a549944c911773488fa8138adb61a39e3ebfd295 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ac506b8080684e05d10462dcbd89e0195cdb361f Author: GetAway <get-a...@t-online.de> Date: Tue May 26 15:11:16 2015 +0200 network: use netGetMacAddr() remove CNetAdapter class Signed-off-by: GetAway <get-a...@t-online.de> diff --git a/tuxbox/neutrino/src/gui/network_setup.cpp b/tuxbox/neutrino/src/gui/network_setup.cpp index 2bc8054..994aeb1 100644 --- a/tuxbox/neutrino/src/gui/network_setup.cpp +++ b/tuxbox/neutrino/src/gui/network_setup.cpp @@ -39,8 +39,6 @@ #include <signal.h> #include "libnet.h" -#include <sstream> -#include <iomanip> #include <sys/ioctl.h> #include <sys/socket.h> #include <netinet/in.h> @@ -464,8 +462,7 @@ void CNetworkSetup::testNetworkSettings() std::string defaultsite = "www.google.de", wiki_IP = "91.224.67.93", wiki_URL = "wiki.tuxbox.org"; //set physical adress - static CNetAdapter netadapter; - ethID = netadapter.getMacAddr(); + std::string mac_addr = networkConfig->mac_addr; //get www-domain testsite from /.version CConfigFile config('\t'); @@ -491,7 +488,7 @@ void CNetworkSetup::testNetworkSettings() } printf("testNw IP: %s\n", our_ip.c_str()); - printf("testNw MAC-address: %s\n", ethID.c_str()); + printf("testNw MAC-address: %s\n", 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()); @@ -505,7 +502,7 @@ void CNetworkSetup::testNetworkSettings() else { // Box - text = "dbox (" + ethID + "):\n"; + text = "dbox (" + mac_addr + "):\n"; text += offset + our_ip + ": " + mypinghost(our_ip) + "\n"; // Gateway text += (std::string)g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY) + " (Router):\n"; @@ -582,66 +579,3 @@ bool CDHCPNotifier::changeNotify(const neutrino_locale_t, void * data) toDisable[x]->setActive(CNetworkConfig::getInstance()->inet_static); return false; } - -long CNetAdapter::mac_addr_sys ( u_char *addr) //only for function getMacAddr() -{ - struct ifreq ifr; - struct ifreq *IFR; - struct ifconf ifc; - char buf[1024]; - int s, i; - int ok = 0; - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s==-1) - { - return -1; - } - - ifc.ifc_len = sizeof(buf); - ifc.ifc_buf = buf; - ioctl(s, SIOCGIFCONF, &ifc); - IFR = ifc.ifc_req; - for (i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; IFR++) - { - strcpy(ifr.ifr_name, IFR->ifr_name); - if (ioctl(s, SIOCGIFFLAGS, &ifr) == 0) - { - if (! (ifr.ifr_flags & IFF_LOOPBACK)) - { - if (ioctl(s, SIOCGIFHWADDR, &ifr) == 0) - { - ok = 1; - break; - } - } - } - } - close(s); - if (ok) - { - memmove(addr, ifr.ifr_hwaddr.sa_data, 6); - } - else - { - return -1; - } - return 0; -} - -std::string CNetAdapter::getMacAddr(void) -{ - long stat; - u_char addr[6]; - stat = mac_addr_sys( addr); - if (0 == stat) - { - std::stringstream mac_tmp; - for(int i=0;i<6;++i) - mac_tmp<<std::hex<<std::setfill('0')<<std::setw(2)<<(int)addr[i]<<':'; - return mac_tmp.str().substr(0,17); - } - else - { - return "not found"; - } -} diff --git a/tuxbox/neutrino/src/gui/network_setup.h b/tuxbox/neutrino/src/gui/network_setup.h index 9bcfe35..f77aa30 100644 --- a/tuxbox/neutrino/src/gui/network_setup.h +++ b/tuxbox/neutrino/src/gui/network_setup.h @@ -110,13 +110,4 @@ class CDHCPNotifier : public CChangeObserver CDHCPNotifier(CMenuForwarder*, CMenuForwarder*, CMenuForwarder*, CMenuForwarder*); bool changeNotify(const neutrino_locale_t, void * data); }; - -class CNetAdapter -{ - private: - long mac_addr_sys ( u_char *addr); - public: - std::string getMacAddr(void); -}; - #endif diff --git a/tuxbox/neutrino/src/system/configure_network.cpp b/tuxbox/neutrino/src/system/configure_network.cpp index fb8425d..a737347 100644 --- a/tuxbox/neutrino/src/system/configure_network.cpp +++ b/tuxbox/neutrino/src/system/configure_network.cpp @@ -24,11 +24,15 @@ #include "network_interfaces.h" /* getInetAttributes, setInetAttributes */ #include <stdlib.h> /* system */ #include <stdio.h> +#include <iomanip> +#include <sstream> CNetworkConfig::CNetworkConfig(void) { netGetNameserver(nameserver); inet_static = getInetAttributes("eth0", automatic_start, address, netmask, broadcast, gateway); + + init_vars(); copy_to_orig(); } @@ -49,6 +53,20 @@ CNetworkConfig::~CNetworkConfig() } +void CNetworkConfig::init_vars(void) +{ + std::string ifname = "eth0"; + unsigned char addr[6]; + + netGetMacAddr(ifname, addr); + + std::stringstream mac_tmp; + for(int i=0;i<6;++i) + mac_tmp<<std::hex<<std::setfill('0')<<std::setw(2)<<(int)addr[i]<<':'; + + mac_addr = mac_tmp.str().substr(0,17); +} + void CNetworkConfig::copy_to_orig(void) { orig_automatic_start = automatic_start; diff --git a/tuxbox/neutrino/src/system/configure_network.h b/tuxbox/neutrino/src/system/configure_network.h index 8e7844f..7b7f6c4 100644 --- a/tuxbox/neutrino/src/system/configure_network.h +++ b/tuxbox/neutrino/src/system/configure_network.h @@ -36,6 +36,7 @@ class CNetworkConfig bool orig_inet_static; void copy_to_orig(void); + void init_vars(void); public: bool automatic_start; @@ -44,6 +45,7 @@ class CNetworkConfig std::string broadcast; std::string gateway; std::string nameserver; + std::string mac_addr; bool inet_static; CNetworkConfig(); ----------------------------------------------------------------------- Summary of changes: tuxbox/neutrino/src/gui/network_setup.cpp | 72 +--------------------- tuxbox/neutrino/src/gui/network_setup.h | 9 --- tuxbox/neutrino/src/system/configure_network.cpp | 18 ++++++ tuxbox/neutrino/src/system/configure_network.h | 2 + 4 files changed, 23 insertions(+), 78 deletions(-) -- Tuxbox-GIT: apps ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ Tuxbox-cvs-commits mailing list Tuxbox-cvs-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tuxbox-cvs-commits