]> andersk Git - moira.git/blobdiff - gen/dhcp.pc
Add containers table and mcntmp table.
[moira.git] / gen / dhcp.pc
index 71bca886cd998032f2cfacb33020e6c39db7e0b6..ebdfba55a37664dc8f6006ecfd2b37586bce7258 100644 (file)
@@ -1,6 +1,6 @@
 /* $Id$
  *
- * This generates the dhcpd.conf.pring and associated files.
+ * This generates the dhcpd.conf.print and associated files.
  *
  * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.
  * For copying and distribution information, please see the file
@@ -20,6 +20,8 @@
 
 #include "util.h"
 
+#define MACHINE_CHWADDR_SIZE 18
+
 EXEC SQL INCLUDE sqlca;
 
 RCSID("$Header$");
@@ -27,12 +29,15 @@ RCSID("$Header$");
 char *whoami = "dhcp.gen";
 char *db = "moira/moira";
 
+void hwcolonify(char *from, char *to);
+
 void sqlerr(void);
 
 int main(int argc, char **argv)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   char name[MACHINE_NAME_SIZE], hwaddr[MACHINE_HWADDR_SIZE];
+  char chwaddr[MACHINE_CHWADDR_SIZE];
   char ohwaddr[MACHINE_HWADDR_SIZE], hwtype[PRINTERS_HWTYPE_SIZE];
   char addr[MACHINE_ADDRESS_SIZE], location[PRINTERS_LOCATION_SIZE];
   char contact[PRINTERS_CONTACT_SIZE], logaddr[MACHINE_ADDRESS_SIZE];
@@ -80,9 +85,9 @@ int main(int argc, char **argv)
   sprintf(filename, "%s/dhcp.out", DCM_DIR);
   tf = tarfile_open(filename);
 
-  /* Build dhcp.conf.print */
+  /* Build dhcpd.conf.print */
 
-  out = tarfile_start(tf, "/var/boot/dhcp.conf.print", 0755, 0, 0,
+  out = tarfile_start(tf, "/var/boot/dhcpd.conf.print", 0755, 0, 0,
                      "root", "root", now);
   ohwaddr[0] = '\0';
   EXEC SQL DECLARE csr_boot CURSOR FOR
@@ -110,6 +115,8 @@ int main(int argc, char **argv)
        }
       strcpy(ohwaddr, hwaddr);
 
+      hwcolonify(hwaddr, chwaddr); 
+
       strtrim(name);
       strtrim(addr);
       strtrim(logaddr);
@@ -129,9 +136,12 @@ int main(int argc, char **argv)
        continue;
 
       fprintf(out, "# %s: %s\n# contact: %s\nhost %s {\n\t"
-             "hardware ethernet %s;\n\tfixed-address %s;\n"
-             "\toption log-servers %s;\n",
-             shortname, location, contact, name, hwaddr, addr, logaddr);
+             "hardware ethernet %s;\n\tfixed-address %s;\n",
+             shortname, location, contact, name, chwaddr, addr);
+      
+      if (strlen(logaddr) != 0)
+             fprintf(out, "\toption log-servers %s;\n", logaddr);
+             
       if (!strncmp(hwtype, "HP", 2))
        fprintf(out, "\toption option-144 \"/hp/%s\";\n", shortname);
       fprintf(out, "}\n\n");
@@ -219,6 +229,23 @@ int main(int argc, char **argv)
   exit(MR_SUCCESS);
 }
 
+void hwcolonify(char *from, char *to)
+{
+  int f = 0, t = 0;
+  int mod = 2;
+
+  for (f = 0 ; f < MACHINE_HWADDR_SIZE - 1 ; )
+    {
+      to[t++] = from[f++];
+      if (f % mod == 0)
+       to[t++] = ':';
+    }
+       
+  if (f % mod == 0)
+    t--;
+  to[t] = '\0';
+}
+
 void sqlerr(void)
 {
   db_error(sqlca.sqlcode);
This page took 0.773912 seconds and 4 git commands to generate.