Project "Tuxbox-GIT: apps":

The branch, master has been updated
       via  fa967f9f085f85ee99a7280b31d104d6d2987f5b (commit)
      from  17875b740770903ec906f159a1bbb016256d50b1 (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 fa967f9f085f85ee99a7280b31d104d6d2987f5b
Author: m4r...@gmx.de <m4r...@gmx.de>
Date:   Tue May 12 16:31:41 2015 +0200

    network setup: calculate broadcast based on ip and netmask
    
    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 42886de..29d1cd2 100644
--- a/tuxbox/neutrino/src/gui/network_setup.cpp
+++ b/tuxbox/neutrino/src/gui/network_setup.cpp
@@ -44,6 +44,7 @@
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <arpa/inet.h>
 #include <linux/if.h>
 
 #include "gui/network_setup.h"
@@ -145,6 +146,15 @@ int CNetworkSetup::exec(CMenuTarget* parent, const 
std::string &actionKey)
        
        return res;
 }
+void CNetworkSetup::setBroadcast(void)
+{
+       in_addr_t na = inet_addr(network_address.c_str());
+       in_addr_t nm = inet_addr(network_netmask.c_str());
+       struct in_addr in;
+       in.s_addr = na | ~nm;
+       char tmp[40];
+       network_broadcast = (inet_ntop(AF_INET, &in, tmp, sizeof(tmp))) ? 
std::string(tmp) : "0.0.0.0";
+}
 
 #define OPTIONS_NTPENABLE_OPTION_COUNT 2
 const CMenuOptionChooser::keyval 
OPTIONS_NTPENABLE_OPTIONS[OPTIONS_NTPENABLE_OPTION_COUNT] =
@@ -183,7 +193,8 @@ int CNetworkSetup::showNetworkSetup()
        
                CMenuForwarder *m1 = new 
CMenuForwarder(LOCALE_NETWORKMENU_IPADDRESS , networkConfig->inet_static, 
network_address   , &networkSettings_NetworkIP );
                CMenuForwarder *m2 = new 
CMenuForwarder(LOCALE_NETWORKMENU_NETMASK   , networkConfig->inet_static, 
network_netmask   , &networkSettings_NetMask   );
-               CMenuForwarder *m3 = new 
CMenuForwarder(LOCALE_NETWORKMENU_BROADCAST , networkConfig->inet_static, 
network_broadcast , &networkSettings_Broadcast );
+               setBroadcast();
+               CMenuForwarder *m3 = new 
CMenuForwarder(LOCALE_NETWORKMENU_BROADCAST , false,                      
network_broadcast);
                CMenuForwarder *m4 = new 
CMenuForwarder(LOCALE_NETWORKMENU_GATEWAY   , networkConfig->inet_static, 
network_gateway   , &networkSettings_Gateway   );
                CMenuForwarder *m5 = new 
CMenuForwarder(LOCALE_NETWORKMENU_NAMESERVER, networkConfig->inet_static, 
network_nameserver, &networkSettings_NameServer);
                
@@ -437,7 +448,7 @@ void CNetworkSetup::restoreNetworkSettings(bool 
show_message)
                network_dhcp            = old_network_dhcp;
                network_address         = old_network_address;
                network_netmask         = old_network_netmask;
-               network_broadcast       = old_network_broadcast;
+               setBroadcast();
                network_nameserver      = old_network_nameserver;
                network_gateway         = old_network_gateway;
 
@@ -545,20 +556,13 @@ void CNetworkSetup::showCurrentNetworkSettings()
        ShowMsgUTF(LOCALE_NETWORKMENU_SHOW, text, CMessageBox::mbrBack, 
CMessageBox::mbBack); // UTF-8
 }
 
-bool CNetworkSetup::changeNotify(const neutrino_locale_t OptionName, void * 
Data)
+bool CNetworkSetup::changeNotify(const neutrino_locale_t OptionName, void * 
/*Data*/)
 {
-       if (ARE_LOCALES_EQUAL(OptionName, LOCALE_NETWORKMENU_IPADDRESS))
-       {
-               char ip[16];
-               unsigned char _ip[4];
-               sscanf((char*) Data, "%hhu.%hhu.%hhu.%hhu", &_ip[0], &_ip[1], 
&_ip[2], &_ip[3]);
-
-               sprintf(ip, "%hhu.%hhu.%hhu.255", _ip[0], _ip[1], _ip[2]);
-               networkConfig->broadcast = ip;
-               network_broadcast = networkConfig->broadcast;
-
-               networkConfig->netmask = (_ip[0] == 10) ? "255.0.0.0" : 
"255.255.255.0";
-               network_netmask = networkConfig->netmask;
+       if (ARE_LOCALES_EQUAL(OptionName, LOCALE_NETWORKMENU_IPADDRESS)) {
+               setBroadcast();
+       }
+       else if(OptionName == LOCALE_NETWORKMENU_NETMASK) {
+               setBroadcast();
        }
        else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_NETWORKMENU_NTPSERVER) ||
                 ARE_LOCALES_EQUAL(OptionName, LOCALE_NETWORKMENU_NTPREFRESH) ||
diff --git a/tuxbox/neutrino/src/gui/network_setup.h 
b/tuxbox/neutrino/src/gui/network_setup.h
index cb0fc24..2723eb7 100644
--- a/tuxbox/neutrino/src/gui/network_setup.h
+++ b/tuxbox/neutrino/src/gui/network_setup.h
@@ -71,6 +71,7 @@ class CNetworkSetup : public CMenuTarget, CChangeObserver
                bool checkForIP();
                bool settingsChanged();
                const char * mypinghost(const char * const host);
+               void setBroadcast(void);
                                
        public: 
                enum NETWORK_DHCP_MODE

-----------------------------------------------------------------------

Summary of changes:
 tuxbox/neutrino/src/gui/network_setup.cpp |   34 ++++++++++++++++------------
 tuxbox/neutrino/src/gui/network_setup.h   |    1 +
 2 files changed, 20 insertions(+), 15 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

Reply via email to