]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Fix (I hope!) the billing-class bug.
authorTed Lemon <source@isc.org>
Mon, 30 Apr 2001 22:38:34 +0000 (22:38 +0000)
committerTed Lemon <source@isc.org>
Mon, 30 Apr 2001 22:38:34 +0000 (22:38 +0000)
server/confpars.c
server/mdb.c

index 15e8ec7814bac81541f8d1ebbd82aca47c8d0b00..28d7955ef3729e30ad4986a69162cfa3233f20d7 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: confpars.c,v 1.141 2001/04/27 22:23:44 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: confpars.c,v 1.142 2001/04/30 22:38:32 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -2654,8 +2654,8 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
                                        break;
                                }
                                if (lease -> billing_class)
-                                       unbill_class (lease,
-                                                     lease -> billing_class);
+                                   class_dereference (&lease -> billing_class,
+                                                      MDL);
                                find_class (&class, val, MDL);
                                if (!class)
                                        parse_warn (cfile,
@@ -2663,8 +2663,8 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
                                parse_semi (cfile);
                        } else if (token == SUBCLASS) {
                                if (lease -> billing_class)
-                                       unbill_class (lease,
-                                                     lease -> billing_class);
+                                   class_dereference (&lease -> billing_class,
+                                                      MDL);
                                parse_class_declaration
                                        (&class,
                                         cfile, (struct group *)0, 3);
@@ -2674,7 +2674,8 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
                                        skip_to_semi (cfile);
                        }
                        if (class) {
-                               bill_class (lease, class);
+                               class_reference (&lease -> billing_class,
+                                                class, MDL);
                                class_dereference (&class, MDL);
                        }
                        break;
index 281d6e7b0604cba23344580fa7bcd0192c602740..447838c7cb00ede4cbd55242cb6fc3041e3c9170 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: mdb.c,v 1.65 2001/04/27 21:30:59 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: mdb.c,v 1.66 2001/04/30 22:38:34 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -1858,7 +1858,7 @@ int lease_enqueue (struct lease *comp)
 void lease_instantiate (const unsigned char *val, unsigned len,
                        struct lease *lease)
 {
-
+       struct class *class;
        /* XXX If the lease doesn't have a pool at this point, it's an
           XXX orphan, which we *should* keep around until it expires,
           XXX but which right now we just forget. */
@@ -1882,6 +1882,22 @@ void lease_instantiate (const unsigned char *val, unsigned len,
                hw_hash_add (lease);
        }
        
+       /* If the lease has a billing class, set up the billing. */
+       if (lease -> billing_class) {
+               class = (struct class *)0;
+               class_reference (&class, lease -> billing_class, MDL);
+               class_dereference (&lease -> billing_class, MDL);
+               /* If the lease is available for allocation, the billing
+                  is invalid, so we don't keep it. */
+               if (lease -> binding_state == FTS_ACTIVE ||
+                   lease -> binding_state == FTS_EXPIRED ||
+                   lease -> binding_state == FTS_RELEASED ||
+                   lease -> binding_state == FTS_RESET ||
+                   lease -> binding_state == FTS_RESERVED ||
+                   lease -> binding_state == FTS_BOOTP)
+                       bill_class (lease, class);
+               class_dereference (&class, MDL);
+       }
        return;
 }