]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/setup/netstuff.c
Merge branch 'next' of git.ipfire.org:/pub/git/ipfire-2.x into next
[ipfire-2.x.git] / src / setup / netstuff.c
index 3ab5835a894cf5702cd7391a6dfeb8780323a7de..66592bb94efb5bef84ee9e3cff7ed93d7554b570 100644 (file)
@@ -75,7 +75,8 @@ int changeaddress(struct keyvalue *kv, char *colour, int typeflag,
        int startstatictype = 0;
        int startdhcptype = 0;
        int startpppoetype = 0;
-               
+       unsigned char buffer[sizeof(struct in_addr)];
+
        /* Build some key strings. */
        sprintf(addressfield, "%s_ADDRESS", colour);
        sprintf(netmaskfield, "%s_NETMASK", colour);
@@ -184,7 +185,7 @@ int changeaddress(struct keyvalue *kv, char *colour, int typeflag,
                                        strcat(message, "\n");
                                        error = 1;
                                }
-                               if (inet_addr(netmaskresult) == INADDR_NONE)
+                               if (inet_pton(AF_INET, netmaskresult, &buffer) == 0)
                                {
                                        strcat(message, _("Network mask"));
                                        strcat(message, "\n");
@@ -422,7 +423,7 @@ int is_interface_up(char *card) {   /* Check if the interface is UP */
        char temp[STRING_SIZE];
 
        sprintf(temp,"ip link show dev %s | grep -q UP", card);
-       if (mysystem(temp)) return 0; else return 1;
+       if (mysystem(NULL, temp)) return 0; else return 1;
 }
 
 int rename_device(char *old_name, char *new_name) {
@@ -434,7 +435,7 @@ int rename_device(char *old_name, char *new_name) {
                return 0;
        }
        sprintf(temp,"/sbin/ip link set dev %s name %s",old_name ,new_name );
-       mysystem(temp);
+       mysystem(NULL, temp);
 
        return 1;
 }
@@ -486,14 +487,14 @@ int nic_shutdown(char *nic) {
        char temp[STRING_SIZE];
        
        sprintf(temp,"ip link set %s down", nic);
-       mysystem(temp);
+       mysystem(NULL, temp);
 }
 
 int nic_startup(char *nic) {
        char temp[STRING_SIZE];
        
        sprintf(temp,"ip link set %s up", nic);
-       mysystem(temp);
+       mysystem(NULL, temp);
 
 }
 
@@ -527,27 +528,6 @@ int rename_nics(void) {
                                }
 }
 
-int create_udev(void)
-{
-       #define UDEV_NET_CONF "/etc/udev/rules.d/30-persistent-network.rules"
-       FILE *fp;
-       int i;
-
-       if ( (fp = fopen(UDEV_NET_CONF, "w")) == NULL ) {
-               fprintf(stderr,"Couldn't open" UDEV_NET_CONF);
-               return 1;
-       }
-
-       for (i = 0 ; i < 4 ; i++)
-       {
-               if (strcmp(knics[i].macaddr, "")) {
-                       fprintf(fp,"\n# %s\nACTION==\"add\", SUBSYSTEM==\"net\", ATTR{type}==\"1\", ATTR{address}==\"%s\", NAME=\"%s0\"\n", knics[i].description, knics[i].macaddr, lcolourcard[i]);
-               }
-       }
-       fclose(fp);
-       return 0;
-}
-
 int write_configs_netudev(int card , int colour)
 {      
        char commandstring[STRING_SIZE];
@@ -594,7 +574,7 @@ int scan_network_cards(void)
        
        if (!(scanned_nics_read_done))
        {
-               mysystem("/bin/probenic.sh");
+               mysystem(NULL, "/usr/bin/probenic.sh");
                if( (fp = fopen(SCANNED_NICS, "r")) == NULL )
                {
                        fprintf(stderr,"Couldn't open "SCANNED_NICS);
@@ -622,16 +602,16 @@ int scan_network_cards(void)
 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];
+       int found_NIC_as_Card[MAX_NICS];
        char message[STRING_SIZE];
        char temp[STRING_SIZE];
 
        char cMenuInhalt[STRING_SIZE];
-       char MenuInhalt[20][180];
-       char *pMenuInhalt[20];
+       char MenuInhalt[MAX_NICS][STRING_SIZE];
+       char *pMenuInhalt[MAX_NICS];
        
        while (strcmp(nics[count].macaddr, "")) count++;                        // 2 find how many nics in system
-       for ( i=0 ; i<4;i++) if (strcmp(knics[i].macaddr, "")) kcount++;        // loop to find all knowing nics
+       for (i=0; i<MAX_NICS; i++) if (strcmp(knics[i].macaddr, "")) kcount++;  // loop to find all knowing nics
 
        // If new nics are found...
        if (count > kcount) {
@@ -669,16 +649,16 @@ int nicmenu(int colour)
                sprintf(message, _("Please choose a networkcard for the following interface - %s."), ucolourcard[colour]);
                rc=2;
                while ( rc == 2 ) {
-                       rc = newtWinMenu(_("Extended Network Menu"), message, 50, 5, 5, 6, pMenuInhalt, &choise,
+                       rc = newtWinMenu(_("Extended Network Menu"), message, 50, 5, 5, mcount, pMenuInhalt, &choise,
                                _("Select"), _("Identify"), _("Cancel"), NULL);
                        if ( rc == 2 ) {
                                sprintf(temp, "/sbin/ip link set %s up", nics[found_NIC_as_Card[choise]].nic);
-                               mysystem(temp);
+                               mysystem(NULL, temp);
                                sprintf(temp, "/usr/sbin/ethtool -p %s 10", nics[found_NIC_as_Card[choise]].nic);
-                               if (runcommandwithstatus(temp, _("Device Identification"), _("The lights on the selected port should flash now for 10 seconds...")) != 0) {
+                               if (runcommandwithstatus(temp, _("Device Identification"), _("The lights on the selected port should flash now for 10 seconds..."), NULL) != 0) {
                                        errorbox(_("Identification is not supported by this interface."));
                                sprintf(temp, "/sbin/ip link set %s down", nics[found_NIC_as_Card[choise]].nic);
-                               mysystem(temp);
+                               mysystem(NULL, temp);
                                }
                        }
                }
@@ -759,7 +739,7 @@ int manualdriver(char *driver, char *driveroptions)
                if (strlen(values[0]))
                {
                        sprintf(commandstring, "/sbin/modprobe %s", values[0]);
-                       if (runcommandwithstatus(commandstring, _("Loading module..."), _("Loading module...")) == 0)
+                       if (runcommandwithstatus(commandstring, _("Loading module..."), _("Loading module..."), NULL) == 0)
                        {
                                if ((driverend = strchr(values[0], ' ')))
                                {