From: James Brister Date: Tue, 10 Jul 2001 20:36:06 +0000 (+0000) Subject: Fixes for QoS support. X-Git-Tag: HEAD-MERGE-V3-0-3B1~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3fe382d68e1a4bbf56cffa93a44306a906bba26;p=thirdparty%2Fdhcp.git Fixes for QoS support. --- diff --git a/includes/dhcpd.h b/includes/dhcpd.h index 3723b3421..acbe68aa6 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -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)); diff --git a/server/confpars.c b/server/confpars.c index 4b78f29bb..7c3d45127 100644 --- a/server/confpars.c +++ b/server/confpars.c @@ -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); diff --git a/server/db.c b/server/db.c index 515f98e8d..e7500ad96 100644 --- a/server/db.c +++ b/server/db.c @@ -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); } diff --git a/server/mdb.c b/server/mdb.c index b690645fc..123e05e88 100644 --- a/server/mdb.c +++ b/server/mdb.c @@ -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); } diff --git a/server/omapi.c b/server/omapi.c index bc2ea1231..819d7f1df 100644 --- a/server/omapi.c +++ b/server/omapi.c @@ -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; }