www.usr.com/support/gpl/USR9107_release.1.4.tar.gz
[bcm963xx.git] / userapps / opensource / udhcp / files.c
index fe1ae1f..c7f8414 100755 (executable)
@@ -33,6 +33,7 @@ static int read_str(char *line, void *arg)
        int i;
        
        if (*dest) free(*dest);
+
        *dest = strdup(line);
        
        /* elimate trailing whitespace */
@@ -163,6 +164,9 @@ static struct config_keyword keywords[] = {
        {"siaddr",      read_ip,  &(server_config.siaddr),      "0.0.0.0"},
        {"sname",       read_str, &(server_config.sname),       ""},
        {"boot_file",   read_str, &(server_config.boot_file),   ""},
+       // BRCM
+       {"vendorid",read_str, &(server_config.vendorid),        ""},
+       {"decline_file",read_str, &(server_config.decline_file),""},
        {"",            NULL,     NULL,                         ""}
 };
 
@@ -276,4 +280,51 @@ void read_leases(char *file)
        fclose(fp);
 }
                
-               
+// BRCM_begin
+/* the dummy var is here so this can be a signal handler */
+void write_decline(int dummy)
+{
+       FILE *fp;
+       
+       dummy = 0;
+       if (!(fp = fopen(server_config.decline_file, "w"))) {
+               LOG(LOG_ERR, "Unable to open %s for writing", server_config.lease_file);
+               return;
+       }
+
+       fwrite(declines->chaddr, 16, 1, fp);
+       fwrite(declines->vendorid, 64, 1, fp);
+       fclose(fp);
+}
+
+int read_vendor_id_config(char *file)
+{
+       FILE *in;
+       char buffer[64];
+       int i = 0;
+
+       if (!(in = fopen(file, "r"))) {
+               LOG(LOG_ERR, "unable to open config file: %s", file);
+               return 0;
+       }
+       
+       memset(buffer, 0, 64);
+        for (i = 0; i < MAX_VENDOR_IDS; i++) {
+               memset(vendor_id_config[i].vendorid, 0, 64);
+        }
+        i = 0;
+       while (fgets(buffer, 64, in)) {
+               if (i < MAX_VENDOR_IDS) {
+                       memset(vendor_id_config[i].vendorid, 0, 64);
+                       memcpy(vendor_id_config[i].vendorid, buffer, 64);
+                       i++;
+                       memset(buffer, 0, 64);
+               } else {
+                       break;
+               }
+       }
+       fclose(in);
+        //unlink(file);
+       return 1;
+}
+// BRCM_end