Revision: 2697
          http://ipcop.svn.sourceforge.net/ipcop/?rev=2697&view=rev
Author:   gespinasse
Date:     2009-04-11 18:18:49 +0000 (Sat, 11 Apr 2009)

Log Message:
-----------
Fix reading local IP, server IP from dhcp
Work only well with one dhcp server or it concatenate the values found on the 
different servers

I will fix that later

Add reading the domain name from the dhcp server

Modified Paths:
--------------
    ipcop/trunk/src/installer/installer.c

Modified: ipcop/trunk/src/installer/installer.c
===================================================================
--- ipcop/trunk/src/installer/installer.c       2009-04-11 17:39:22 UTC (rev 
2696)
+++ ipcop/trunk/src/installer/installer.c       2009-04-11 18:18:49 UTC (rev 
2697)
@@ -67,9 +67,10 @@
 static char netboot_dhcp_IP[STRING_SIZE] = "";
 static char netmask[STRING_SIZE] = "";
 static char netboot_mac[STRING_SIZE] = "";
+static char domain[STRING_SIZE] = "";
 static struct network_s *networks;
-//char **interfacelist = NULL;
 
+
 /* On x86 netboot, read cmdline value
    With sparc netboot cdmline is empty,
    we may find something looking at openpromfs (currently built-in)
@@ -178,18 +179,31 @@
         snprintf(string, STRING_SIZE, "/etc/dhcp-eth%d.params", itf);
         if (read_kv_from_file(&kv_dhcp_params, string)) {
             return FAILURE;
+        }
+        snprintf(itf_name, STRING_SIZE, "eth%d", itf);
+        if (find_kv(kv_dhcp_params, "SERVERID") == NULL) {
+            fprintf(flog, "udhcpc SERVERID not found\n");
+            return FAILURE;
+        }
+        strcat(server_IP, find_kv(kv_dhcp_params, "SERVERID"));
+        if (find_kv(kv_dhcp_params, "IP") == NULL) {
+            fprintf(flog, "udhcpc IP not found\n");
+            return FAILURE;
+        }
+        strcat(local_IP, find_kv(kv_dhcp_params, "IP"));
+        if (find_kv(kv_dhcp_params, "NETMASK") == NULL) {
+            fprintf(flog, "udhcpc NETMASK not found\n");
+            return FAILURE;
+        }
+        strcat(netmask, find_kv(kv_dhcp_params, "NETMASK"));
+        /* domain is not mandatory */
+        if (find_kv(kv_dhcp_params, "DOMAIN") == NULL) {
+            fprintf(flog, "udhcpc DOMAIN not found\n");
         } else {
-            if (find_kv(kv_dhcp_params, "SERVERID")) {
-                free_kv(&kv_dhcp_params);
-                return FAILURE;
-            } else {
-                strcat(server_IP, find_kv(kv_dhcp_params, "SERVERID"));
-                free_kv(&kv_dhcp_params);
-                /* keep the good interface */
-                snprintf(itf_name, STRING_SIZE, "eth%d", itf);
-                return SUCCESS;
-            }
+            strcat(domain, find_kv(kv_dhcp_params, "DOMAIN"));
         }
+        free_kv(&kv_dhcp_params);
+        return SUCCESS;
     }
 }
 
@@ -337,8 +351,10 @@
         return FAILURE;
     }
 
-    snprintf(command, STRING_SIZE, "http://%s/iso";, server_IP);
-    values[0] = command;
+    if (strlen(server_IP) > 0) {
+        snprintf(command, STRING_SIZE, "http://%s/iso";, server_IP);
+        values[0] = command;
+    }
 
     char filename[STRING_SIZE];
     while (1) {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Ipcop-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ipcop-svn

Reply via email to