[Dhcp-agent-commits] CVS: dhcp-agent config.h.in,1.4,1.5 configure,1.8,1.9 configure.in,1.8,1.9 dhcp
Status: Alpha
Brought to you by:
actmodern
|
From: Thamer Al-H. <act...@us...> - 2002-02-02 15:28:51
|
Update of /cvsroot/dhcp-agent/dhcp-agent
In directory usw-pr-cvs1:/tmp/cvs-serv27321
Modified Files:
config.h.in configure configure.in dhcp-agent.h dhcp-align.c
dhcp-client-cache.c dhcp-client-control.c dhcp-client-states.c
dhcp-client.c dhcp-files.c
Log Message:
added -c option to clear cache; fixed up some more comments;
Index: config.h.in
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/config.h.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** config.h.in 2002/02/02 11:55:08 1.4
--- config.h.in 2002/02/02 15:28:46 1.5
***************
*** 19,22 ****
--- 19,25 ----
#undef HAVE_INTTYPES_H
+ /* Define if you have the `rename' function. */
+ #undef HAVE_RENAME
+
/* Define if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
Index: configure
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/configure,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** configure 2002/02/02 11:55:08 1.8
--- configure 2002/02/02 15:28:47 1.9
***************
*** 2378,2382 ****
done
! for ac_func in strdup uname calloc daemon
do
ac_ac_var=`echo "ac_cv_func_$ac_func" | $ac_tr_sh`
--- 2378,2382 ----
done
! for ac_func in strdup uname calloc daemon rename
do
ac_ac_var=`echo "ac_cv_func_$ac_func" | $ac_tr_sh`
Index: configure.in
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/configure.in,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** configure.in 2002/02/02 11:55:08 1.8
--- configure.in 2002/02/02 15:28:47 1.9
***************
*** 32,36 ****
dnl check for functions
! AC_CHECK_FUNCS(strdup uname calloc daemon)
AC_CHECK_FUNCS(sprintf vsnprintf,
--- 32,36 ----
dnl check for functions
! AC_CHECK_FUNCS(strdup uname calloc daemon rename)
AC_CHECK_FUNCS(sprintf vsnprintf,
Index: dhcp-agent.h
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-agent.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** dhcp-agent.h 2002/02/02 12:28:05 1.14
--- dhcp-agent.h 2002/02/02 15:28:47 1.15
***************
*** 743,746 ****
--- 743,747 ----
extern void dhcp_control_use_fake_hw_addr(dhcp_client_control_t *dc,
char *fake_hw_addr);
+ extern dhcp_client_control_t *create_dhcp_client_control_dummy(char *interface);
/* dhcp client conf */
Index: dhcp-align.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-align.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** dhcp-align.c 2002/01/29 18:05:03 1.1.1.1
--- dhcp-align.c 2002/02/02 15:28:47 1.2
***************
*** 21,25 ****
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
! * Since structures may be padded we simply can't guarantee
* alignment unless we copy each member out individually.
* Yes I know this is extreme since most packet structures
--- 21,25 ----
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
! * Since structures may be padded. We simply can't guarantee
* alignment unless we copy each member out individually.
* Yes I know this is extreme since most packet structures
Index: dhcp-client-cache.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-cache.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** dhcp-client-cache.c 2002/01/30 09:26:02 1.3
--- dhcp-client-cache.c 2002/02/02 15:28:47 1.4
***************
*** 124,137 ****
int client_cache_is_empty(client_cache_t *cc)
{
! int retval;
!
! load_client_cache(cc, 0);
! if(cc->vars == NULL)
retval = 1;
! else
! retval = 0;
- purge_cache(cc);
return retval;
}
--- 124,135 ----
int client_cache_is_empty(client_cache_t *cc)
{
! int retval = 0;
! char *fname;
! fname = get_fname(cc);
! if(file_exists(fname))
retval = 1;
! xfree(fname);
return retval;
}
***************
*** 170,174 ****
void *data;
-
for(cache = cc->vars;cache;cache = cache->next) {
--- 168,171 ----
Index: dhcp-client-control.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-control.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** dhcp-client-control.c 2002/02/01 19:56:10 1.6
--- dhcp-client-control.c 2002/02/02 15:28:47 1.7
***************
*** 67,70 ****
--- 67,81 ----
}
+ dhcp_client_control_t *create_dhcp_client_control_dummy(char *interface)
+ {
+ dhcp_client_control_t *dc;
+
+ dc = xmalloc(sizeof(dhcp_client_control_t));
+ memset(dc, 0, sizeof(dhcp_client_control_t));
+ dc->interface = strdup(interface);
+
+ return dc;
+ }
+
dhcp_client_control_t *create_dhcp_client_control(char *interface)
{
Index: dhcp-client-states.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-states.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** dhcp-client-states.c 2002/02/02 12:28:05 1.10
--- dhcp-client-states.c 2002/02/02 15:28:47 1.11
***************
*** 21,25 ****
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
! * These are the individual client state functions.
*/
--- 21,27 ----
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
! * These are the individual client state functions,
! * along with their utility routines.
! *
*/
Index: dhcp-client.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** dhcp-client.c 2002/02/02 00:48:06 1.8
--- dhcp-client.c 2002/02/02 15:28:47 1.9
***************
*** 53,60 ****
if(client_cache_is_empty(dc->cache)) {
return STATE_DISCOVER_OFFER;
! } else /* If the cache isn't empty
! * we assume we're in the request stage.
! * XXX -- fixme do integrity check in
! * case of crash or corruption. */
return STATE_REQUEST_ACK;
}
--- 53,57 ----
if(client_cache_is_empty(dc->cache)) {
return STATE_DISCOVER_OFFER;
! } else /* if not empty we assume we can request the options. */
return STATE_REQUEST_ACK;
}
***************
*** 160,163 ****
--- 157,195 ----
}
+ /* A bit of a hack here since we need only parts of a control structure. */
+
+ static void do_clear_cache(char *interface)
+ {
+ pid_t pid;
+ dhcp_client_control_t *dc;
+ client_cache_t *cc;
+
+ if(!get_pid_file(interface, &pid)) {
+ /* A race condition exists between the discover and request state.
+ * So we can't hup the client and tell it the cache has been deleted. */
+ error_message("dhcpclient already running. i won't delete cache until it's shutdown.");
+ return;
+ }
+
+ /* As long as no client is being run we can go ahead and delete the cache.
+ * We need a client cache structure though, pass it a dummy structure
+ * with the interface. That's all it needs.
+ * (this is the hack).
+ */
+
+ dc = create_dhcp_client_control_dummy(interface);
+ cc = create_client_cache(dc);
+
+ /* now delete. */
+ client_cache_delete_cache(cc);
+ client_cache_delete_tmp_cache(cc);
+
+ /* all done. */
+ destroy_dhcp_client_control(dc);
+ client_cache_destroy(cc);
+
+ return;
+ }
+
static int client_process_exists(char *interface)
{
***************
*** 182,186 ****
static char *fake_hw_addr = NULL;
! while((c = getopt(argc, argv, "davim:kwh:")) != -1) {
switch(c) {
--- 214,218 ----
static char *fake_hw_addr = NULL;
! while((c = getopt(argc, argv, "cdavim:kwh:")) != -1) {
switch(c) {
***************
*** 214,217 ****
--- 246,254 ----
chdir(work_dir);
do_wake_client(interface);
+ exit(0);
+
+ case 'c':
+ chdir(work_dir);
+ do_clear_cache(interface);
exit(0);
Index: dhcp-files.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-files.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** dhcp-files.c 2002/01/29 18:05:05 1.1.1.1
--- dhcp-files.c 2002/02/02 15:28:47 1.2
***************
*** 130,137 ****
void move_file(char *fname, char *dest)
{
unlink(dest);
link(fname, dest);
unlink(fname);
!
return;
}
--- 130,140 ----
void move_file(char *fname, char *dest)
{
+ #ifdef HAVE_RENAME
+ rename(fname, dest);
+ #else /* HAVE_RENAME */
unlink(dest);
link(fname, dest);
unlink(fname);
! #endif /* HAVE_RENAME */
return;
}
|