]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Fixes for QoS support.
authorJames Brister <source@isc.org>
Tue, 10 Jul 2001 20:36:06 +0000 (20:36 +0000)
committerJames Brister <source@isc.org>
Tue, 10 Jul 2001 20:36:06 +0000 (20:36 +0000)
includes/dhcpd.h
server/confpars.c
server/db.c
server/mdb.c
server/omapi.c

index 3723b3421edaec304d03fed5f7ba777507ad1736..acbe68aa64add1982a8d3f06f175a98af1d035b6 100644 (file)
@@ -2390,6 +2390,9 @@ extern struct hash_table *lease_hw_addr_hash;
 
 extern omapi_object_type_t *dhcp_type_host;
 
+extern int numclasseswritten;
+
+
 isc_result_t enter_class PROTO ((struct class *, int, int));
 isc_result_t delete_class PROTO ((struct class *, int));
 isc_result_t enter_host PROTO ((struct host_decl *, int, int));
index 4b78f29bb026a309d5fdd19a7d4aaa9de128e0a0..7c3d4512790ce40fc7149d788acb8d13b9a6315a 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: confpars.c,v 1.145 2001/06/27 00:31:03 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: confpars.c,v 1.146 2001/07/10 20:36:02 brister Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -2029,7 +2029,10 @@ int parse_class_declaration (cp, cfile, group, type)
                                ;
                        class_reference (&c -> nic, class, MDL);
                }
+       } else if (type == 3 && dynamic) {
+               class->flags |= CLASS_DECL_DYNAMIC;
        }
+               
        if (cp)                         /* should always be 0??? */
                status = class_reference (cp, class, MDL);
        class_dereference (&class, MDL);
index 515f98e8df6729c5131a32cc91c44f8c6f71c590..e7500ad967590906ff9197f9aca9acc1a7ebbdcd 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: db.c,v 1.66 2001/06/27 00:31:04 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: db.c,v 1.67 2001/07/10 20:36:03 brister Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -616,7 +616,7 @@ static int print_hash_string(FILE *fp, struct class *class)
 
        if (i == class -> hash_string.len) {
                errno = 0;
-               fprintf (fp, " \"%.*s\";",
+               fprintf (fp, " \"%.*s\"",
                         (int)class -> hash_string.len,
                         class -> hash_string.data);
                if (errno)
@@ -643,59 +643,63 @@ static int print_hash_string(FILE *fp, struct class *class)
 
 
        
-
 /* XXXJAB this needs to return non-zero on error. */
 void write_named_billing_class (const char *name, unsigned len,
                                struct class *class)
 {
-       if (class->superclass == 0) {
-               fprintf(db_file, "class \"%s\" {\n", name);
-       } else {
-               fprintf(db_file, "subclass \"%s\"", class->superclass->name);
-               print_hash_string(db_file, class);
-               fprintf(db_file, " {\n");
-       }
+       if (class->flags & CLASS_DECL_DYNAMIC) {
+               numclasseswritten++;
+               if (class->superclass == 0) {
+                       fprintf(db_file, "class \"%s\" {\n", name);
+               } else {
+                       fprintf(db_file, "subclass \"%s\"",
+                               class->superclass->name);
+                       print_hash_string(db_file, class);
+                       fprintf(db_file, " {\n");
+               }
 
-       if ((class->flags & CLASS_DECL_DELETED) != 0) {
-               fprintf(db_file, "  deleted;\n");
-       } else {
-               fprintf(db_file, "  dynamic;\n");
-       }
+               if ((class->flags & CLASS_DECL_DELETED) != 0) {
+                       fprintf(db_file, "  deleted;\n");
+               } else {
+                       fprintf(db_file, "  dynamic;\n");
+               }
        
+               if (class->lease_limit > 0) {
+                       fprintf(db_file, "  lease limit %d;\n", class->lease_limit);
+               }
 
-       if (class->lease_limit > 0) {
-               fprintf(db_file, "  lease limit %d;\n", class->lease_limit);
-       }
+               if (class->expr != 0) {
+                       fprintf(db_file, "  match if ");
+                       write_expression(db_file, class->expr, 5, 5, 0);
+                       fprintf(db_file, ";\n");
+               }
 
-       if (class->expr != 0) {
-               fprintf(db_file, "  match if ");
-               write_expression(db_file, class->expr, 5, 5, 0);
-       }
+               if (class->submatch != 0) {
+                       if (class->spawning) {
+                               fprintf(db_file, "  spawn ");
+                       } else {
+                               fprintf(db_file, "  match ");
+                       }
 
-       if (class->submatch != 0) {
-               if (class->spawning) {
-                       fprintf(db_file, "  spawn ");
-               } else {
-                       fprintf(db_file, "  match ");
+                       write_expression(db_file, class->submatch, 5, 5, 0);
+                       fprintf(db_file, ";\n");
                }
        
-               write_expression(db_file, class->submatch, 5, 5, 0);
-       }
-       
-       if (class->statements != 0) {
-               write_statements(db_file, class->statements, 8);
-       }
+               if (class->statements != 0) {
+                       write_statements(db_file, class->statements, 8);
+               }
 
-       /* XXXJAB this isn't right, but classes read in off the leases file
-          don't get the root group assigned to them (due to clone_group()
-          call). */
-       if (class->group != 0 && class->group->authoritative != 0) {
-               write_statements (db_file,
-                                 class -> group -> statements, 8);
+               /* XXXJAB this isn't right, but classes read in off the leases file
+                  don't get the root group assigned to them (due to clone_group()
+                  call). */
+               if (class->group != 0 && class->group->authoritative != 0) {
+                       write_statements (db_file,
+                                         class -> group -> statements, 8);
+               }
+       
+               fprintf(db_file, "}\n\n");
        }
        
-       fprintf(db_file, "}\n\n");
-
        if (class -> hash != NULL) {    /* yep. recursive. god help us. */
                class_hash_foreach (class -> hash, write_named_billing_class);
        }
index b690645fc5ebe9b9cafb57091c0c8087dc08bd1a..123e05e88f9004cb08811f18d0148d12f88fa79a 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: mdb.c,v 1.70 2001/06/27 00:31:13 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: mdb.c,v 1.71 2001/07/10 20:36:05 brister Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -57,6 +57,8 @@ struct hash_table *lease_ip_addr_hash;
 struct hash_table *lease_hw_addr_hash;
 struct hash_table *host_name_hash;
 
+int numclasseswritten;
+
 omapi_object_type_t *dhcp_type_host;
 
 isc_result_t enter_class(cd, dynamicp, commit)
@@ -1794,17 +1796,17 @@ int write_leases ()
 
        /* write all the dynamically-created class declarations. */
        if (collections->classes) {
-               num_written = 0;
+               numclasseswritten = 0;
                for (colp = collections ; colp ; colp = colp->next) {
                        for (cp = colp->classes ; cp ; cp = cp->nic) {
                                write_named_billing_class(cp->name,
                                                          0, cp);
-                               ++num_written;
                        }
                }
 
                /* XXXJAB this number doesn't include subclasses... */ 
-               log_info ("Wrote %d class decls to leases file.", num_written);
+               log_info ("Wrote %d class decls to leases file.",
+                         numclasseswritten);
        }
        
                        
index bc2ea12310af3084e2e574965b4750d08b42708f..819d7f1df3eec5463fd9e76fde8de1b51ad9540b 100644 (file)
@@ -50,7 +50,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: omapi.c,v 1.49 2001/06/27 00:31:15 mellon Exp $ Copyright (c) 1999-2001 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: omapi.c,v 1.50 2001/07/10 20:36:06 brister Exp $ Copyright (c) 1999-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -1762,11 +1762,27 @@ class_set_value (omapi_object_t *h,
        }
 
 
+       /* note we do not support full expressions via omapi because the
+          expressions parser needs to be re-done to support parsing from
+          strings and not just files. */
+       
        if (!omapi_ds_strcmp (name, "match")) {
                if (value -> type == omapi_datatype_data ||
                    value -> type == omapi_datatype_string) {
-                       /* XXXJAB support 'match hardware' here. */
-                       return ISC_R_INVALIDARG; /* XXX tmp */
+                       int minlen = (value -> u.buffer.len > 8 ?
+                                     8 : value -> u.buffer.len);
+                       
+                       if (strncmp("hardware", value -> u.buffer.value,
+                                   minlen) == 0) {
+                               if (!expression_allocate(&class->submatch,
+                                                        MDL)) {
+                                       return ISC_R_NOMEMORY;
+                               }
+                       
+                               class->expr->op = expr_hardware;
+                       } else {
+                               return ISC_R_INVALIDARG;
+                       }
                } else {
                        return ISC_R_INVALIDARG;
                }