#ifndef lint
static char copyright[] =
-"$Id: bootp.c,v 1.33 1998/11/06 00:15:51 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: bootp.c,v 1.34 1998/11/09 02:45:59 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
}
}
- /* If a lease has already been assigned to this client
- and it's still okay to use dynamic bootp on
- that lease, reassign it. */
+ /* If a lease has already been assigned to this client,
+ use it. */
if (lease) {
- /* If this lease can be used for dynamic bootp,
- do so. */
- if ((lease -> flags & DYNAMIC_BOOTP_OK)) {
-
- /* If it's not a DYNAMIC_BOOTP lease,
- release it before reassigning it
- so that we don't get a lease
- conflict. */
- if (!(lease -> flags & BOOTP_LEASE))
- release_lease (lease);
-
- lease -> host = host;
- ack_lease (packet, lease, 0, 0);
- return;
- }
-
- /* If dynamic BOOTP is no longer allowed for
- this lease, set it free. */
- release_lease (lease);
+ ack_lease (packet, lease, 0, 0);
+ return;
}
- /* If there are dynamic bootp addresses that might be
- available, try to snag one. */
- for (lease = packet -> shared_network -> last_lease;
- lease && lease -> ends <= cur_time;
- lease = lease -> prev) {
- if ((lease -> flags & DYNAMIC_BOOTP_OK)) {
- lease -> host = host;
- ack_lease (packet, lease, 0, 0);
- return;
- }
+ /* Otherwise, try to allocate one. */
+ lease = allocate_lease (packet,
+ packet -> shared_network -> pools, 0);
+ if (lease) {
+ lease -> host = host;
+ ack_lease (packet, lease, 0, 0);
+ return;
}
- note ("No dynamic leases for BOOTP client %s",
+ note ("No available leases for BOOTP client %s",
print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
packet -> raw -> chaddr));
+ return;
}
/* Run the executable statements to compute the client and server
#ifndef lint
static char copyright[] =
-"$Id: dhcpdi.c,v 1.1 1998/04/09 05:19:26 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhcpdi.c,v 1.2 1998/11/09 02:47:29 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
static void shared_network_cdup PROTO ((struct interact_client *));
static void *shared_network_next PROTO ((struct interact_client *, void *));
+static void pool_ls PROTO ((struct interact_client *));
+static void pool_class_ls PROTO ((struct interact_client *));
+static void pool_class_print PROTO ((struct interact_client *, char *));
+static void pool_class_set PROTO ((struct interact_client *, char *));
+static void pool_class_rm PROTO ((struct interact_client *, char *));
+static void pool_class_cd PROTO ((struct interact_client *, char *));
+static void pool_class_cdup PROTO ((struct interact_client *));
+static void *pool_class_next PROTO ((struct interact_client *, void *));
+
+static void pool_print PROTO ((struct interact_client *, char *));
+static void pool_set PROTO ((struct interact_client *, char *));
+static void pool_rm PROTO ((struct interact_client *, char *));
+static void pool_cd PROTO ((struct interact_client *, char *));
+static void pool_cdup PROTO ((struct interact_client *));
+static void *pool_next PROTO ((struct interact_client *, void *));
+
static void subnet_class_ls PROTO ((struct interact_client *));
static void subnet_class_print PROTO ((struct interact_client *, char *));
static void subnet_class_set PROTO ((struct interact_client *, char *));
shared_network_cdup,
shared_network_next };
+static struct interact_actions pool_class_actions = {
+ pool_class_ls,
+ pool_class_print,
+ pool_class_set,
+ pool_class_rm,
+ pool_class_cd,
+ pool_class_cdup,
+ pool_class_next };
+
+static struct interact_actions pool_actions = {
+ pool_ls,
+ pool_print,
+ pool_set,
+ pool_rm,
+ pool_cd,
+ pool_cdup,
+ pool_next };
+
static struct interact_actions subnet_class_actions = {
subnet_class_ls,
subnet_class_print,
client -> cur_node = share -> group;
client -> cur_node_actions = group_actions;
client -> cur_node_actions.cdup = group_cdup_share;
- } else if (!strcmp (string, "leases")) {
- client -> cur_node = share -> leases;
- client -> cur_node_actions = lease_actions;
- } else if (!strcmp (string, "active leases")) {
- client -> cur_node = share -> leases;
- client -> cur_node_actions = lease_actions;
- client -> cur_node_actions.next = lease_next_active;
- } else if (!strcmp (string, "free leases")) {
- client -> cur_node = share -> leases;
- client -> cur_node_actions = lease_actions;
- client -> cur_node_actions.next = lease_next_free;
- } else if (!strcmp (string, "abandoned leases")) {
- client -> cur_node = share -> leases;
- client -> cur_node_actions = lease_actions;
- client -> cur_node_actions.next = lease_next_abandoned;
+ } else if (!strcmp (string, "pools")) {
+ client -> cur_node = share -> pools;
+ client -> cur_node_actions = pool_actions;
} else {
interact_client_write (client, "can't cd to that.", 1);
return;
interact_client_write (client, "name", 0);
interact_client_write (client, "subnets", 0);
interact_client_write (client, "group", 0);
- interact_client_write (client, "leases", 0);
- interact_client_write (client, "active leases", 0);
- interact_client_write (client, "free leases", 0);
- interact_client_write (client, "abandoned leases", 1);
+ interact_client_write (client, "pools", 0);
}
static void shared_network_set (client, string)
client -> cur_node = share -> group;
client -> cur_node_actions = group_actions;
client -> cur_node_actions.cdup = group_cdup_share;
- } else if (!strcmp (string, "leases")) {
- client -> cur_node = share -> leases;
+ } else if (!strcmp (string, "pools")) {
+ client -> cur_node = share -> pools;
+ client -> cur_node_actions = pool_actions;
+ } else {
+ interact_client_write (client, "can't cd to that.", 1);
+ return;
+ }
+ interact_client_write (client, "done.", 1);
+}
+
+static void shared_network_cdup (client)
+ struct interact_client *client;
+{
+ struct shared_network *share = client -> cur_node;
+
+ if (share -> interface)
+ client -> cur_node = share -> interface;
+ else
+ top_level_cdup (client);
+}
+
+static void *shared_network_next (client, ptr)
+ struct interact_client *client;
+ void *ptr;
+{
+ return (void *)0;
+}
+
+static void pool_class_ls (client)
+ struct interact_client *client;
+{
+ interact_client_write (client, "active leases", 0);
+ interact_client_write (client, "free leases", 0);
+ interact_client_write (client, "abandoned leases", 1);
+}
+
+static void pool_class_print (client, string)
+ struct interact_client *client;
+ char *string;
+{
+ interact_client_write (client, "nothing to print.", 1);
+}
+
+static void pool_class_set (client, string)
+ struct interact_client *client;
+ char *string;
+{
+ interact_client_write (client, "can't set that.", 1);
+}
+
+static void pool_class_rm (client, string)
+ struct interact_client *client;
+ char *string;
+{
+ interact_client_write (client, "can't remove that.", 1);
+}
+
+static void pool_class_cd (client, string)
+ struct interact_client *client;
+ char *string;
+{
+ struct pool *pool = client -> cur_node;
+
+ if (!strcmp (string, "active leases")) {
+ client -> cur_node = pool -> leases;
client -> cur_node_actions = lease_actions;
- } else if (!strcmp (string, "active leases")) {
- client -> cur_node = share -> leases;
+ client -> cur_node_actions.next = lease_next_active;
+ } else if (!strcmp (string, "free leases")) {
+ client -> cur_node = pool -> leases;
+ client -> cur_node_actions = lease_actions;
+ client -> cur_node_actions.next = lease_next_free;
+ } else if (!strcmp (string, "abandoned leases")) {
+ client -> cur_node = pool -> leases;
+ client -> cur_node_actions = lease_actions;
+ client -> cur_node_actions.next = lease_next_abandoned;
+ } else {
+ interact_client_write (client, "can't cd to that.", 1);
+ return;
+ }
+ interact_client_write (client, "done.", 1);
+}
+
+static void pool_class_cdup (client)
+ struct interact_client *client;
+{
+ struct pool *pool = client -> cur_node;
+
+ if (pool -> shared_network)
+ client -> cur_node = pool -> shared_network;
+ else
+ top_level_cdup (client);
+}
+
+static void *pool_class_next (client, ptr)
+ struct interact_client *client;
+ void *ptr;
+{
+ return (void *)0;
+}
+
+static void pool_ls (client)
+ struct interact_client *client;
+{
+}
+
+static void pool_print (client, string)
+ struct interact_client *client;
+ char *string;
+{
+ interact_client_write (client, "active leases", 0);
+ interact_client_write (client, "free leases", 0);
+ interact_client_write (client, "abandoned leases", 1);
+}
+
+static void pool_set (client, string)
+ struct interact_client *client;
+ char *string;
+{
+ interact_client_write (client, "can't set that.", 1);
+}
+
+static void pool_rm (client, string)
+ struct interact_client *client;
+ char *string;
+{
+ interact_client_write (client, "can't remove that.", 1);
+}
+
+static void pool_cd (client, string)
+ struct interact_client *client;
+ char *string;
+{
+ struct pool *pool = client -> cur_node;
+
+ if (!strcmp (string, "active leases")) {
+ client -> cur_node = pool -> leases;
client -> cur_node_actions = lease_actions;
client -> cur_node_actions.next = lease_next_active;
} else if (!strcmp (string, "free leases")) {
- client -> cur_node = share -> leases;
+ client -> cur_node = pool -> leases;
client -> cur_node_actions = lease_actions;
client -> cur_node_actions.next = lease_next_free;
} else if (!strcmp (string, "abandoned leases")) {
- client -> cur_node = share -> leases;
+ client -> cur_node = pool -> leases;
client -> cur_node_actions = lease_actions;
client -> cur_node_actions.next = lease_next_abandoned;
} else {
interact_client_write (client, "done.", 1);
}
-static void shared_network_cdup (client)
+static void pool_cdup (client)
struct interact_client *client;
{
- struct shared_network *share = client -> cur_node;
+ struct pool *pool = client -> cur_node;
- if (share -> interface)
- client -> cur_node = share -> interface;
+ if (pool -> shared_network)
+ client -> cur_node = pool -> shared_network;
else
top_level_cdup (client);
}
-static void *shared_network_next (client, ptr)
+static void *pool_next (client, ptr)
struct interact_client *client;
void *ptr;
{
struct interact_client *client;
{
struct lease *lease = client -> cur_node;
- client -> cur_node = lease -> shared_network;
- client -> cur_node_actions = shared_network_actions;
+ client -> cur_node = lease -> pool;
+ client -> cur_node_actions = pool_actions;
}
static void lease_cdup_host (client)