From: Ted Lemon Date: Tue, 16 Mar 1999 00:56:02 +0000 (+0000) Subject: Differentiate between spawning and subclass matching. X-Git-Tag: V3-ALPHA-19990315~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8b5001850f959986c33056d8aca58443afeca6bf;p=thirdparty%2Fdhcp.git Differentiate between spawning and subclass matching. --- diff --git a/server/class.c b/server/class.c index 1b96372f9..bcd31c79c 100644 --- a/server/class.c +++ b/server/class.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: class.c,v 1.8 1999/02/24 17:56:51 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: class.c,v 1.9 1999/03/16 00:54:09 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -201,10 +201,10 @@ int check_collection (packet, collection) memset (&data, 0, sizeof data); /* If a class is for billing, don't put the client in the class if we've already billed it to a different class. */ - if (class -> spawn) { + if (class -> submatch) { status = evaluate_data_expression (&data, packet, &packet -> options, - class -> spawn); + class -> submatch); if (status) { if ((nc = ((struct class *) hash_lookup (class -> hash, @@ -221,6 +221,8 @@ int check_collection (packet, collection) matched = 1; continue; } + if (!class -> spawning) + continue; #if defined (DEBUG_CLASS_MATCHING) log_info ("spawning subclass %s.", print_hex_1 (data.len, data.data, 60)); diff --git a/server/confpars.c b/server/confpars.c index 2c4cdd389..f5bec8adb 100644 --- a/server/confpars.c +++ b/server/confpars.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: confpars.c,v 1.62 1999/03/09 23:43:36 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: confpars.c,v 1.63 1999/03/16 00:56:02 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -985,7 +985,7 @@ struct class *parse_class_declaration (cfile, group, type) backward compatibility, we have an implicit-vendor-class and an implicit-user-class. vendor-class and user-class declarations are turned into subclasses of the implicit classes, and the - spawn expression of the implicit classes extracts the contents of + submatch expression of the implicit classes extracts the contents of the vendor class or user class. */ if (type == 0 || type == 1) { data.len = strlen (val); @@ -1130,11 +1130,8 @@ struct class *parse_class_declaration (cfile, group, type) } token = next_token (&val, cfile); token = next_token (&val, cfile); - if (token != IF) { - parse_warn ("expecting if after match"); - skip_to_semi (cfile); - break; - } + if (token != IF) + goto submatch; parse_boolean_expression (&class -> expr, cfile, &lose); if (lose) @@ -1149,11 +1146,6 @@ struct class *parse_class_declaration (cfile, group, type) skip_to_semi (cfile); break; } - if (class -> spawn) { - parse_warn ("can't override spawn."); - skip_to_semi (cfile); - break; - } token = next_token (&val, cfile); token = next_token (&val, cfile); if (token != WITH) { @@ -1161,11 +1153,21 @@ struct class *parse_class_declaration (cfile, group, type) skip_to_semi (cfile); break; } - parse_data_expression (&class -> spawn, cfile, &lose); + class -> spawning = 1; + submatch: + if (class -> submatch) { + parse_warn ("can't override existing %s.", + "submatch/spawn"); + skip_to_semi (cfile); + break; + } + parse_data_expression (&class -> submatch, + cfile, &lose); if (lose) break; #if defined (DEBUG_EXPRESSION_PARSE) - print_expression ("class match", class -> spawn); + print_expression ("class submatch", + class -> submatch); #endif parse_semi (cfile); } else if (token == LEASE) {