]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - src/install+setup/libsmooth/netstuff.c
Merge branch 'next' into fifteen
[people/teissler/ipfire-2.x.git] / src / install+setup / libsmooth / netstuff.c
index eb0c4e7990ba41874285b3f9d2e4e1fe240abbc9..1c6eb42e6ae1bffab5b608f16d777bd12c337966 100644 (file)
@@ -31,6 +31,7 @@ newtComponent statictyperadio;
 newtComponent dhcptyperadio;
 newtComponent pppoetyperadio;
 newtComponent dhcphostnameentry;
+newtComponent dhcpforcemtuentry;
 
 /* acceptable character filter for IP and netmaks entry boxes */
 static int ip_input_filter(newtComponent entry, void * data, int ch, int cursor)
@@ -49,11 +50,13 @@ int changeaddress(struct keyvalue *kv, char *colour, int typeflag,
        char *addressresult;
        char *netmaskresult;
        char *dhcphostnameresult;
+       char *dhcpforcemturesult;
        struct newtExitStruct es;
        newtComponent header;
        newtComponent addresslabel;
        newtComponent netmasklabel;
        newtComponent dhcphostnamelabel;
+       newtComponent dhcpforcemtulabel;
        newtComponent ok, cancel;       
        char message[1000];
        char temp[STRING_SIZE];
@@ -61,6 +64,7 @@ int changeaddress(struct keyvalue *kv, char *colour, int typeflag,
        char netmaskfield[STRING_SIZE];
        char typefield[STRING_SIZE];
        char dhcphostnamefield[STRING_SIZE];
+       char dhcpforcemtufield[STRING_SIZE];
        int error;
        int result = 0;
        char type[STRING_SIZE];
@@ -73,6 +77,7 @@ int changeaddress(struct keyvalue *kv, char *colour, int typeflag,
        sprintf(netmaskfield, "%s_NETMASK", colour);
        sprintf(typefield, "%s_TYPE", colour);
        sprintf(dhcphostnamefield, "%s_DHCP_HOSTNAME", colour);
+       sprintf(dhcpforcemtufield, "%s_DHCP_FORCE_MTU", colour);
                
        sprintf(message, ctr[TR_INTERFACE], colour);
        newtCenteredWindow(44, (typeflag ? 18 : 12), message);
@@ -99,15 +104,25 @@ int changeaddress(struct keyvalue *kv, char *colour, int typeflag,
                newtComponentAddCallback(statictyperadio, networkdialogcallbacktype, NULL);
                newtComponentAddCallback(dhcptyperadio, networkdialogcallbacktype, NULL);
                newtComponentAddCallback(pppoetyperadio, networkdialogcallbacktype, NULL);
-               dhcphostnamelabel = newtTextbox(2, 9, 18, 1, 0);
+               dhcphostnamelabel = newtTextbox(2, 8, 18, 1, 0);
                newtTextboxSetText(dhcphostnamelabel, ctr[TR_DHCP_HOSTNAME]);
+               dhcpforcemtulabel = newtTextbox(2, 9, 18, 1, 0);
+               newtTextboxSetText(dhcpforcemtulabel, ctr[TR_DHCP_FORCE_MTU]);
                strcpy(temp, defaultdhcphostname);
                findkey(kv, dhcphostnamefield, temp);
-               dhcphostnameentry = newtEntry(20, 9, temp, 20, &dhcphostnameresult, 0);
-               newtFormAddComponent(networkform, dhcphostnamelabel);           
-               newtFormAddComponent(networkform, dhcphostnameentry);   
+               dhcphostnameentry = newtEntry(20, 8, temp, 20, &dhcphostnameresult, 0);
+               strcpy(temp, "");
+               findkey(kv, dhcpforcemtufield, temp);
+               dhcpforcemtuentry = newtEntry(20, 9, temp, 20, &dhcpforcemturesult, 0);
+               newtFormAddComponent(networkform, dhcphostnamelabel);
+               newtFormAddComponent(networkform, dhcphostnameentry);
+               newtFormAddComponent(networkform, dhcpforcemtulabel);
+               newtFormAddComponent(networkform, dhcpforcemtuentry);
                if (startdhcptype == 0)
-                       newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
+                       {
+                               newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
+                               newtEntrySetFlags(dhcpforcemtuentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
+                       }
        }
        /* Address */
        addresslabel = newtTextbox(2, (typeflag ? 11 : 4) + 0, 18, 1, 0);
@@ -184,6 +199,7 @@ int changeaddress(struct keyvalue *kv, char *colour, int typeflag,
                                if (typeflag)
                                {
                                        replacekeyvalue(kv, dhcphostnamefield, dhcphostnameresult);
+                                       replacekeyvalue(kv, dhcpforcemtufield, dhcpforcemturesult);
                                        if (strcmp(type, "STATIC") != 0)
                                        {
                                                replacekeyvalue(kv, addressfield, "0.0.0.0");
@@ -205,7 +221,14 @@ int changeaddress(struct keyvalue *kv, char *colour, int typeflag,
                                setnetaddress(kv, colour);
                                result = 1;
                        }
-               }                       
+               }
+               /* Workaround for a bug that dhcp radiobutton also end the dialog at arm
+               */
+               else {
+                       if (es.u.co != cancel) {
+                               error = 1;
+                       }
+               }
        }
        while (error);
 
@@ -296,12 +319,17 @@ void networkdialogcallbacktype(newtComponent cm, void *data)
                newtEntrySetFlags(netmaskentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET);
        }
        if (strcmp(type, "DHCP") == 0)
+       {
                newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET);
+               newtEntrySetFlags(dhcpforcemtuentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET);
+       }
        else
+       {
                newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);               
-               
+               newtEntrySetFlags(dhcpforcemtuentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);               
+       }
        newtRefresh();
-       newtDrawForm(networkform);      
+       newtDrawForm(networkform);
 }
 
 int interfacecheck(struct keyvalue *kv, char *colour)
@@ -587,6 +615,7 @@ int nicmenu(int colour)
        int rc, choise = 0, count = 0, kcount = 0, mcount = 0, i, j, nic_in_use;
        int found_NIC_as_Card[4];
        char message[STRING_SIZE];
+       char temp[STRING_SIZE];
 
        char cMenuInhalt[STRING_SIZE];
        char MenuInhalt[20][180];
@@ -629,8 +658,20 @@ int nicmenu(int colour)
                pMenuInhalt[mcount] = NULL;
 
                sprintf(message, ctr[TR_CHOOSE_NETCARD], ucolourcard[colour]);
-               rc = newtWinMenu( ctr[TR_NETCARDMENU2], message, 50, 5, 5, 6, pMenuInhalt, &choise, ctr[TR_OK], ctr[TR_SELECT], ctr[TR_CANCEL], NULL);
-                               
+               rc=2;
+               while ( rc == 2 ) {
+                       rc = newtWinMenu( ctr[TR_NETCARDMENU2], message, 50, 5, 5, 6, pMenuInhalt, &choise, ctr[TR_SELECT], ctr[TR_IDENTIFY], ctr[TR_CANCEL], NULL);
+                       if ( rc == 2 ) {
+                               sprintf(temp, "/sbin/ip link set %s up", nics[found_NIC_as_Card[choise]].nic);
+                               mysystem(temp);
+                               sprintf(temp, "/usr/sbin/ethtool -p %s 10", nics[found_NIC_as_Card[choise]].nic);
+                               if (runcommandwithstatus(temp,ctr[TR_IDENTIFY_SHOULD_BLINK]) != 0) {      
+                                       errorbox(ctr[TR_IDENTIFY_NOT_SUPPORTED]);
+                               sprintf(temp, "/sbin/ip link set %s down", nics[found_NIC_as_Card[choise]].nic);
+                               mysystem(temp);
+                               }
+                       }
+               }
                if ( rc == 0 || rc == 1) {
                        write_configs_netudev(found_NIC_as_Card[choise], colour);
                }