Thread: [dhcp-agent-commits] dhcp-agent/src dhcp-server-client-info.c,NONE,1.1 dhcp-server-client-info.h,NON
Status: Alpha
Brought to you by:
actmodern
From: <act...@us...> - 2003-08-07 01:14:30
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv28241/src Modified Files: Makefile.am dhcp-server-guile.c dhcp-server-guile.h dhcp-server-lease-manager.c dhcp-server-lease-manager.h dhcp-server-states.c dhcp-server.c Added Files: dhcp-server-client-info.c dhcp-server-client-info.h Log Message: added new client_info datum to hold information on client --- NEW FILE: dhcp-server-client-info.c --- /* $Header: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-client-info.c,v 1.1 2003/08/07 01:14:27 actmodern Exp $ * * Copyright 2002 Thamer Alharbash <tm...@wh...> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * The client info datum allows us to pack all the information * from the client in one place just by looking at the incoming * dhcp packet. * */ #define MODULE_NAME "dhcp-server-client-info" #include "dhcp-local.h" #include "dhcp-limits.h" #include "dhcp-libutil.h" #include "dhcp-librawnet.h" #include "dhcp-option.h" #include "dhcp-server-conf.h" #include "dhcp-server.h" #include "dhcp-server-client-info.h" /******************************* * utilities * *******************************/ /* given a pointer to a max message size, which may be NULL, do * the logic to find the right max message size. */ static uint16_t get_max_message_size(dhcp_server_control_t *sc, uint16_t *max_message_size_ptr) { uint16_t configured_max_message_size; /* get the configured max message size: we use this in the * absence of a max message size from the client, and if it * is smaller than our mtu. */ configured_max_message_size = server_conf_get_max_message_size(sc->server_conf); /* we get a null pointer if the client never passed us a max message. */ if(max_message_size_ptr == NULL) /* none passed. */ { if(configured_max_message_size < rawnet_get_mtu(sc->rawnet)) return configured_max_message_size; else return rawnet_get_mtu(sc->rawnet); } else if(*max_message_size_ptr > rawnet_get_mtu(sc->rawnet)) /* use mtu if the max message size is greater. */ return rawnet_get_mtu(sc->rawnet); /* otherwise use the max message size. */ else return *max_message_size_ptr; } /******************************* * create/destroy * *******************************/ /* create a client info from an incoming dhcp packet. */ client_info_t *client_info_create(dhcp_server_control_t *sc, dhcp_obj *dhcp) { client_info_t *client_info; char *hostname = NULL; uint8_t *chaddr; dhcp_opt_t *client_id = NULL; dhcp_opt_t *opt; uint16_t *max_message_size = NULL; client_info = xcalloc(sizeof(client_info_t)); client_info->giaddr = dhcp_get_giaddr(dhcp); chaddr = dhcp_get_chaddr(dhcp); memcpy(&client_info->chaddr, chaddr, ETH_ADDR_LEN); dhcp_reset_option_seek(dhcp); while((opt = dhcp_get_next_option(dhcp)) != NULL) { switch(dhcp_opt_get_tag(opt)) { case TAG_DHCP_CLIENT_ID: client_id = opt; break; case TAG_DHCP_MAX_DHCP_SIZE: max_message_size = dhcp_opt_get_host_data(opt); break; case TAG_DHCP_HOST_NAME: hostname = dhcp_opt_get_host_data(opt); break; default: break; } } if(client_id != NULL) client_info->client_id = dhcp_opt_get_user_string(client_id); client_info->max_message_size = get_max_message_size(sc, max_message_size); if(hostname != NULL) { client_info->hostname = xstrdup(hostname); } return client_info; } /* destroy a client info. */ void client_info_destroy(client_info_t *client_info) { if(client_info->client_id != NULL) xfree(client_info->client_id); if(client_info->hostname != NULL) xfree(client_info->hostname); xfree(client_info); return; } client_info_t *client_info_copy(client_info_t *client_info) { client_info_t *new_client_info; new_client_info = xcalloc(sizeof(client_info_t)); if(client_info->client_id != NULL) new_client_info->client_id = xstrdup(client_info->client_id); if(client_info->hostname != NULL) new_client_info->hostname = xstrdup(client_info->hostname); new_client_info->giaddr = client_info->giaddr; new_client_info->chaddr = client_info->chaddr; return new_client_info; } /******************************* * accessors * *******************************/ const char *client_info_get_hostname(client_info_t *client_info) { return client_info->hostname; } const char *client_info_get_client_id(client_info_t *client_info) { return client_info->client_id; } eth_addr_t client_info_get_chaddr(client_info_t *client_info) { return client_info->chaddr; } ip_addr_t client_info_get_giaddr(client_info_t *client_info) { return client_info->giaddr; } uint16_t client_info_get_max_message_size(client_info_t *client_info) { return client_info->max_message_size; } --- NEW FILE: dhcp-server-client-info.h --- /* $Header: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-client-info.h,v 1.1 2003/08/07 01:14:27 actmodern Exp $ * * Copyright 2002 Thamer Alharbash <tm...@wh...> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * These are the individual server state functions, * along with their utility routines. * */ #ifndef DHCP_SERVER_CLIENT_INFO_H #define DHCP_SERVER_CLIENT_INFO_H typedef struct { char *hostname; /* hostname provided by client if any. */ char *client_id; /* client id provided by client if any. */ eth_addr_t chaddr; /* the chaddr provided by the client. */ ip_addr_t giaddr; /* ip address of relay agent. */ uint16_t max_message_size; /* max message size if any. */ } client_info_t; extern client_info_t *client_info_create(dhcp_server_control_t *sc, dhcp_obj *dhcp); extern void client_info_destroy(client_info_t *client_info); extern client_info_t *client_info_copy(client_info_t *client_info); extern const char *client_info_get_hostname(client_info_t *client_info); extern const char *client_info_get_client_id(client_info_t *client_info); extern eth_addr_t client_info_get_chaddr(client_info_t *client_info); extern ip_addr_t client_info_get_giaddr(client_info_t *client_info); extern uint16_t client_info_get_max_message_size(client_info_t *client_info); #endif /* DHCP_SERVER_CLIENT_INFO_H */ Index: Makefile.am =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/Makefile.am,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** Makefile.am 5 Aug 2003 04:49:09 -0000 1.34 --- Makefile.am 7 Aug 2003 01:14:27 -0000 1.35 *************** *** 23,27 **** dhcp-client-guile.h dhcp-sniff-defaults.h dhcp-client-defaults.h dhcp-lease.h \ dhcp-server.h dhcp-server-guile.h dhcp-server-conf.h dhcp-server-defaults.h \ ! dhcp-server-guile.h dhcp-server-lease-manager.h dhcp-guile-util.h libdhcputil_la_SOURCES = dhcp-util.c \ --- 23,28 ---- dhcp-client-guile.h dhcp-sniff-defaults.h dhcp-client-defaults.h dhcp-lease.h \ dhcp-server.h dhcp-server-guile.h dhcp-server-conf.h dhcp-server-defaults.h \ ! dhcp-server-guile.h dhcp-server-lease-manager.h dhcp-guile-util.h \ ! dhcp-server-client-info.h libdhcputil_la_SOURCES = dhcp-util.c \ *************** *** 79,83 **** dhcp-server-guile.c \ dhcp-guile-util.c \ ! dhcp-server-lease-manager.c dhcp_client_LDADD = -ldhcputil ${GUILE_LIB} --- 80,85 ---- dhcp-server-guile.c \ dhcp-guile-util.c \ ! dhcp-server-lease-manager.c \ ! dhcp-server-client-info.c dhcp_client_LDADD = -ldhcputil ${GUILE_LIB} Index: dhcp-server-guile.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-guile.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-server-guile.c 6 Aug 2003 04:29:16 -0000 1.4 --- dhcp-server-guile.c 7 Aug 2003 01:14:27 -0000 1.5 *************** *** 33,67 **** #include "dhcp-server-conf.h" #include "dhcp-server.h" #include "dhcp-guile-util.h" #include "dhcp-server-guile.h" ! static scm_t_bits server_control_tag, lease_tag; SCM leases_initialize, lease_available, lease_lookup, lease_acquire, lease_release, lease_expire; /* * * * * * * * * * * * * * * * * * * * ! * misc utilities * * * * * * * * * * * * * * * * * * * * */ ! /* make a lease data list to pass to the user: fixme, make it a record. */ ! static SCM make_lease_data_list(const char *hostname, eth_addr_t mac_addr, ip_addr_t giaddr, dhcp_opt_t *client_id) { ! SCM data_list; ! char *eth_addr_string, *giaddr_string, *client_id_string; ! eth_addr_string = eth_addr_to_string(mac_addr); ! giaddr_string = ip_addr_to_string(giaddr); ! client_id_string = dhcp_opt_get_user_string(client_id); ! data_list = SCM_EOL; ! data_list = scm_cons(scm_makfrom0str(client_id_string), data_list); ! data_list = scm_cons(scm_makfrom0str(giaddr_string), data_list); ! data_list = scm_cons(scm_makfrom0str(eth_addr_string), data_list); ! data_list = scm_cons(scm_makfrom0str(hostname), data_list); ! xfree(eth_addr_string); ! xfree(giaddr_string); ! xfree(client_id_string); ! return data_list; } --- 33,95 ---- #include "dhcp-server-conf.h" #include "dhcp-server.h" + #include "dhcp-server-client-info.h" #include "dhcp-guile-util.h" #include "dhcp-server-guile.h" ! static scm_t_bits server_control_tag, lease_tag, client_info_tag; SCM leases_initialize, lease_available, lease_lookup, lease_acquire, lease_release, lease_expire; /* * * * * * * * * * * * * * * * * * * * ! * client info smob * * * * * * * * * * * * * * * * * * * * */ ! /* mark a client_info: we don't need to do any marking. */ ! static SCM scm_client_info_mark(SCM scm_client_info) { ! return SCM_BOOL_F; ! } ! /* free a client_info. */ ! static size_t scm_client_info_free(SCM scm_client_info) ! { ! client_info_smob_t *client_info_smob; ! client_info_smob = (client_info_smob_t *)SCM_SMOB_DATA(scm_client_info); ! client_info_destroy(client_info_smob->client_info); ! xfree(client_info_smob); ! return sizeof(client_info_smob); ! } ! /* print out a client info scm. */ ! static int scm_client_info_print(SCM scm_client_info, SCM port, scm_print_state *pstate) ! { ! scm_puts("#<client_info>", port); ! return 1; ! } ! ! /* create a client info scm. */ ! static SCM scm_client_info_c_make(client_info_t *client_info) ! { ! client_info_smob_t *client_info_smob; ! client_info_t *new_client_info; ! ! new_client_info = client_info_copy(client_info); ! client_info_smob = scm_must_malloc(sizeof(client_info_smob_t), "client-info-make"); ! client_info_smob->client_info = new_client_info; ! ! SCM_RETURN_NEWSMOB(client_info_tag, client_info_smob); ! } ! ! /* initialization routines for client info smob. */ ! static void init_client_info_smob(void) ! { ! client_info_tag = scm_make_smob_type("client_info_smob", sizeof(client_info_smob_t)); ! ! scm_set_smob_free(client_info_tag, scm_client_info_free); ! scm_set_smob_mark(client_info_tag, scm_client_info_mark); ! scm_set_smob_print(client_info_tag, scm_client_info_print); ! ! return; } *************** *** 178,182 **** } ! /* initialization routines for lease SMOB. */ static void init_lease_smob(void) { --- 206,210 ---- } ! /* initialization routines for lease smob. */ static void init_lease_smob(void) { *************** *** 291,294 **** --- 319,325 ---- init_lease_smob(); + /* initialize client info smob. */ + init_client_info_smob(); + /* bind symbols to top level so that the user defined script can hook into them. */ *************** *** 330,341 **** /* ask if any leases are available. */ ! lease_t *dhcp_guile_lease_available(const char *hostname, eth_addr_t mac_addr, ! ip_addr_t giaddr, dhcp_opt_t *client_id) { ! SCM data_list, scm_lease; lease_t *lease; ! data_list = make_lease_data_list(hostname, mac_addr, giaddr, client_id); ! scm_lease = scm_call_1(scm_variable_ref(lease_available), data_list); lease = scm_c_get_lease(scm_lease); --- 361,371 ---- /* ask if any leases are available. */ ! lease_t *dhcp_guile_lease_available(client_info_t *client_info) { ! SCM scm_client_info, scm_lease; lease_t *lease; ! scm_client_info = scm_client_info_c_make(client_info); ! scm_lease = scm_call_1(scm_variable_ref(lease_available), scm_client_info); lease = scm_c_get_lease(scm_lease); *************** *** 344,355 **** /* lookup a lease: lookup a lease. */ ! lease_t *dhcp_guile_lookup_lease(ip_addr_t ip_addr, const char *hostname, eth_addr_t mac_addr, ! ip_addr_t giaddr, dhcp_opt_t *client_id) { ! SCM data_list, scm_lease; lease_t *lease; ! data_list = make_lease_data_list(hostname, mac_addr, giaddr, client_id); ! scm_lease = scm_call_1(scm_variable_ref(lease_lookup), data_list); lease = scm_c_get_lease(scm_lease); --- 374,386 ---- /* lookup a lease: lookup a lease. */ ! lease_t *dhcp_guile_lookup_lease(ip_addr_t ip_addr, client_info_t *client_info) { ! SCM scm_client_info, scm_lease, scm_ip_addr; lease_t *lease; ! scm_client_info = scm_client_info_c_make(client_info); ! scm_ip_addr = SCM_MAKINUM(ip_addr); ! ! scm_lease = scm_call_2(scm_variable_ref(lease_lookup), scm_ip_addr, scm_client_info); lease = scm_c_get_lease(scm_lease); Index: dhcp-server-guile.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-guile.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-server-guile.h 5 Aug 2003 04:59:32 -0000 1.4 --- dhcp-server-guile.h 7 Aug 2003 01:14:27 -0000 1.5 *************** *** 26,45 **** #define DHCP_SERVER_GUILE_H ! typedef struct client_control_smob { dhcp_server_control_t *sc; } server_control_smob_t; ! typedef struct lease_smob { lease_t *lease; } lease_smob_t; /* prototypes. */ extern void dhcp_guile_init(dhcp_server_control_t *sc); extern int dhcp_guile_initialize_leases(void); ! extern lease_t *dhcp_guile_lease_available(const char *hostname, eth_addr_t mac_addr, ! ip_addr_t giaddr, dhcp_opt_t *client_id); ! extern lease_t *dhcp_guile_lookup_lease(ip_addr_t ip_addr, const char *hostname, eth_addr_t mac_addr, ! ip_addr_t giaddr, dhcp_opt_t *client_id); extern int dhcp_guile_acquire_lease(lease_t *definition); extern int dhcp_guile_release_lease(lease_t *definition); --- 26,47 ---- #define DHCP_SERVER_GUILE_H ! typedef struct { dhcp_server_control_t *sc; } server_control_smob_t; ! typedef struct { lease_t *lease; } lease_smob_t; + typedef struct { + client_info_t *client_info; + } client_info_smob_t; + /* prototypes. */ extern void dhcp_guile_init(dhcp_server_control_t *sc); extern int dhcp_guile_initialize_leases(void); ! extern lease_t *dhcp_guile_lease_available(client_info_t *client_info); ! extern lease_t *dhcp_guile_lookup_lease(ip_addr_t ip_addr, client_info_t *client_info); extern int dhcp_guile_acquire_lease(lease_t *definition); extern int dhcp_guile_release_lease(lease_t *definition); Index: dhcp-server-lease-manager.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-lease-manager.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-server-lease-manager.c 5 Aug 2003 05:00:00 -0000 1.2 --- dhcp-server-lease-manager.c 7 Aug 2003 01:14:27 -0000 1.3 *************** *** 31,34 **** --- 31,35 ---- #include "dhcp-server-conf.h" #include "dhcp-server.h" + #include "dhcp-server-client-info.h" #include "dhcp-lease.h" #include "dhcp-server-lease-manager.h" *************** *** 40,55 **** } ! lease_t *lease_manager_lease_available(const char *hostname, eth_addr_t mac_addr, ! ip_addr_t giaddr, dhcp_opt_t *client_id) { ! return dhcp_guile_lease_available(hostname, mac_addr, ! giaddr, client_id); } ! lease_t *lease_manager_lookup_lease(ip_addr_t ip_addr, const char *hostname, eth_addr_t mac_addr, ! ip_addr_t giaddr, dhcp_opt_t *client_id) { ! return dhcp_guile_lookup_lease(ip_addr, hostname, mac_addr, ! giaddr, client_id); } --- 41,52 ---- } ! lease_t *lease_manager_lease_available(client_info_t *client_info) { ! return dhcp_guile_lease_available(client_info); } ! lease_t *lease_manager_lookup_lease(ip_addr_t ip_addr, client_info_t *client_info) { ! return dhcp_guile_lookup_lease(ip_addr, client_info); } Index: dhcp-server-lease-manager.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-lease-manager.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-server-lease-manager.h 5 Aug 2003 05:00:00 -0000 1.2 --- dhcp-server-lease-manager.h 7 Aug 2003 01:14:27 -0000 1.3 *************** *** 26,33 **** extern int initialize_lease_manager(void); ! extern lease_t *lease_manager_lease_available(const char *hostname, eth_addr_t mac_addr, ! ip_addr_t giaddr, dhcp_opt_t *client_id); ! extern lease_t *lease_manager_lookup_lease(ip_addr_t ip_addr, const char *hostname, eth_addr_t mac_addr, ! ip_addr_t giaddr, dhcp_opt_t *client_id); extern int lease_manager_acquire_lease(lease_t *lease); extern int lease_manager_release_lease(lease_t *lease); --- 26,31 ---- extern int initialize_lease_manager(void); ! extern lease_t *lease_manager_lease_available(client_info_t *client_info); ! extern lease_t *lease_manager_lookup_lease(ip_addr_t ip_addr, client_info_t *client_info); extern int lease_manager_acquire_lease(lease_t *lease); extern int lease_manager_release_lease(lease_t *lease); Index: dhcp-server-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-states.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dhcp-server-states.c 6 Aug 2003 04:29:39 -0000 1.6 --- dhcp-server-states.c 7 Aug 2003 01:14:27 -0000 1.7 *************** *** 35,41 **** #include "dhcp-lease.h" - #include "dhcp-server-lease-manager.h" #include "dhcp-server-conf.h" #include "dhcp-server.h" /******************************* --- 35,42 ---- #include "dhcp-lease.h" #include "dhcp-server-conf.h" #include "dhcp-server.h" + #include "dhcp-server-client-info.h" + #include "dhcp-server-lease-manager.h" /******************************* *************** *** 65,96 **** } - /* given a pointer to a max message size, which may be NULL, do - * the logic to find the right max message size. */ - uint16_t get_max_message_size(dhcp_server_control_t *sc, uint16_t *max_message_size_ptr) - { - uint16_t configured_max_message_size; - - /* get the configured max message size: we use this in the - * absence of a max message size from the client, and if it - * is smaller than our mtu. */ - - configured_max_message_size = server_conf_get_max_message_size(sc->server_conf); - - /* we get a null pointer if the client never passed us a max message. */ - if(max_message_size_ptr == NULL) /* none passed. */ { - - if(configured_max_message_size < rawnet_get_mtu(sc->rawnet)) - return configured_max_message_size; - else - return rawnet_get_mtu(sc->rawnet); - } - else if(*max_message_size_ptr > rawnet_get_mtu(sc->rawnet)) /* use mtu if the max message size is greater. */ - return rawnet_get_mtu(sc->rawnet); - - /* otherwise use the max message size. */ - else - return *max_message_size_ptr; - } - /* utility routine to get a list of options from a lease. */ static list_t *create_options_from_lease(dhcp_server_control_t *sc, lease_t *lease) --- 66,69 ---- *************** *** 187,242 **** int server_handle_discover(dhcp_server_control_t *sc) { ! char *hostname = NULL; ! eth_addr_t mac_addr; ! uint8_t *chaddr; ! ip_addr_t giaddr; ! dhcp_opt_t *client_id = NULL; ! dhcp_opt_t *opt; lease_t *lease; - uint16_t *max_message_size = NULL; dhcp_obj *dhcp = sc->rawnet->dhcp_p; ! /* a client wants to discover possible leases. get the ! * information we need to pass to the lease manager and ask ! * the manager if any leases are available for it. */ ! ! giaddr = dhcp_get_giaddr(dhcp); ! ! chaddr = dhcp_get_chaddr(dhcp); ! memcpy(&mac_addr, chaddr, ETH_ADDR_LEN); ! ! dhcp_reset_option_seek(dhcp); ! while((opt = dhcp_get_next_option(dhcp)) != NULL) { ! ! switch(dhcp_opt_get_tag(opt)) { ! ! case TAG_DHCP_CLIENT_ID: ! client_id = opt; ! break; ! ! case TAG_DHCP_MAX_DHCP_SIZE: ! max_message_size = dhcp_opt_get_host_data(opt); ! break; ! ! case TAG_DHCP_HOST_NAME: ! hostname = dhcp_opt_get_host_data(opt); ! break; ! ! default: ! break; ! } ! } ! lease = lease_manager_lease_available(hostname, mac_addr, ! giaddr, client_id); if(lease == NULL) ! return STATE_LISTEN; /* we have no possible leases. */ /* otherwise we do have a lease, send out an OFFER. */ ! if(server_do_offer(sc, lease, get_max_message_size(sc, max_message_size), mac_addr, dhcp_get_xid(dhcp))) return STATE_SHUTDOWN; return STATE_LISTEN; } --- 160,186 ---- int server_handle_discover(dhcp_server_control_t *sc) { ! client_info_t *client_info; lease_t *lease; dhcp_obj *dhcp = sc->rawnet->dhcp_p; ! /* get the information from the dhcp packet which describes the client. */ ! client_info = client_info_create(sc, dhcp); ! /* check for lease availability for this client. */ ! lease = lease_manager_lease_available(client_info); if(lease == NULL) ! return STATE_LISTEN; /* we have no possible leases: we drop the packet. */ /* otherwise we do have a lease, send out an OFFER. */ ! if(server_do_offer(sc, lease, client_info_get_max_message_size(client_info), client_info_get_chaddr(client_info), dhcp_get_xid(dhcp))) return STATE_SHUTDOWN; + /* clean up. */ + client_info_destroy(client_info); + lease_destroy(lease); + + /* and return to listen state after we're done. */ return STATE_LISTEN; } *************** *** 244,247 **** --- 188,192 ---- int server_handle_request(dhcp_server_control_t *sc) { + /* a client is requesting a lease, find out from the lease * manager if we can give it the lease. */ Index: dhcp-server.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dhcp-server.c 5 Aug 2003 05:01:02 -0000 1.11 --- dhcp-server.c 7 Aug 2003 01:14:27 -0000 1.12 *************** *** 32,35 **** --- 32,36 ---- #include "dhcp-server-conf.h" #include "dhcp-server.h" + #include "dhcp-server-client-info.h" #include "dhcp-guile-util.h" #include "dhcp-server-guile.h" |