|
|
c987ce5 |
diff -up dhcp-4.0.0/configure.ac.libdhcp4client dhcp-4.0.0/configure.ac
|
|
|
c987ce5 |
--- dhcp-4.0.0/configure.ac.libdhcp4client 2007-12-14 08:24:56.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/configure.ac 2008-01-02 18:27:51.000000000 -1000
|
|
|
c987ce5 |
@@ -20,9 +20,37 @@ if test "$GCC" = "yes"; then
|
|
|
c987ce5 |
fi
|
|
|
c987ce5 |
fi
|
|
|
c987ce5 |
|
|
|
c987ce5 |
-AC_PROG_RANLIB
|
|
|
c987ce5 |
+AC_PROG_LIBTOOL
|
|
|
c987ce5 |
+
|
|
|
c987ce5 |
AC_CONFIG_HEADERS([includes/config.h])
|
|
|
c987ce5 |
|
|
|
c987ce5 |
+dnl Versioning
|
|
|
c987ce5 |
+dnl (from glib's configure.in ...)
|
|
|
c987ce5 |
+dnl Making releases:
|
|
|
c987ce5 |
+dnl DHCP_MICRO_VERSION += 1;
|
|
|
c987ce5 |
+dnl DHCP_INTERFACE_AGE += 1;
|
|
|
c987ce5 |
+dnl DHCP_BINARY_AGE += 1;
|
|
|
c987ce5 |
+dnl if any functions have been added, set DHCP_INTERFACE_AGE to 0.
|
|
|
c987ce5 |
+dnl if backwards compatibility has been broken (e.g., functions removed,
|
|
|
c987ce5 |
+dnl function signatures changed),
|
|
|
c987ce5 |
+dnl set DHCP_BINARY_AGE and DHCP_INTERFACE_AGE to 0.
|
|
|
c987ce5 |
+DHCP_MAJOR_VERSION=4
|
|
|
c987ce5 |
+DHCP_MINOR_VERSION=0
|
|
|
c987ce5 |
+DHCP_MICRO_VERSION=0
|
|
|
c987ce5 |
+DHCP_INTERFACE_AGE=0
|
|
|
c987ce5 |
+DHCP_BINARY_AGE=0
|
|
|
c987ce5 |
+DHCP_VERSION_SUFFIX=
|
|
|
c987ce5 |
+DHCP_VERSION=$DHCP_MAJOR_VERSION.$DHCP_MINOR_VERSION.$DHCP_MICRO_VERSION$DHCP_VERSION_SUFFIX
|
|
|
c987ce5 |
+
|
|
|
c987ce5 |
+LT_RELEASE=$DHCP_MAJOR_VERSION.$DHCP_MINOR_VERSION
|
|
|
c987ce5 |
+LT_CURRENT=`expr $DHCP_MICRO_VERSION - $DHCP_INTERFACE_AGE`
|
|
|
c987ce5 |
+LT_REVISION=$DHCP_INTERFACE_AGE
|
|
|
c987ce5 |
+AC_SUBST(DHCP_VERSION)
|
|
|
c987ce5 |
+AC_SUBST(LT_RELEASE)
|
|
|
c987ce5 |
+AC_SUBST(LT_CURRENT)
|
|
|
c987ce5 |
+AC_SUBST(LT_REVISION)
|
|
|
c987ce5 |
+AC_SUBST(LT_AGE)
|
|
|
c987ce5 |
+
|
|
|
c987ce5 |
# we sometimes need to know byte order for building packets
|
|
|
c987ce5 |
AC_C_BIGENDIAN(AC_SUBST(byte_order, BIG_ENDIAN),
|
|
|
c987ce5 |
AC_SUBST(byte_order, LITTLE_ENDIAN))
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/omapip/Makefile.am.libdhcp4client dhcp-4.0.0/omapip/Makefile.am
|
|
|
c987ce5 |
--- dhcp-4.0.0/omapip/Makefile.am.libdhcp4client 2007-05-29 06:32:11.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/omapip/Makefile.am 2008-01-02 19:05:36.000000000 -1000
|
|
|
c987ce5 |
@@ -1,10 +1,18 @@
|
|
|
c987ce5 |
lib_LIBRARIES = libomapi.a
|
|
|
c987ce5 |
+noinst_LIBRARIES = libomapiLIBDHCP.a
|
|
|
c987ce5 |
noinst_PROGRAMS = svtest
|
|
|
c987ce5 |
|
|
|
c987ce5 |
libomapi_a_SOURCES = protocol.c buffer.c alloc.c result.c connection.c \
|
|
|
c987ce5 |
errwarn.c listener.c dispatch.c generic.c support.c \
|
|
|
c987ce5 |
handle.c message.c convert.c hash.c auth.c inet_addr.c \
|
|
|
c987ce5 |
array.c trace.c mrtrace.c toisc.c iscprint.c
|
|
|
c987ce5 |
+
|
|
|
c987ce5 |
+libomapiLIBDHCP_a_CFLAGS = -DLIBDHCP
|
|
|
c987ce5 |
+libomapiLIBDHCP_a_SOURCES = alloc.c array.c auth.c buffer.c connection.c \
|
|
|
c987ce5 |
+ convert.c dispatch.c errwarn.c handle.c hash.c listener.c \
|
|
|
c987ce5 |
+ mrtrace.c result.c support.c toisc.c trace.c generic.c message.c \
|
|
|
c987ce5 |
+ protocol.c
|
|
|
c987ce5 |
+
|
|
|
c987ce5 |
man_MANS = omapi.3
|
|
|
c987ce5 |
EXTRA_DIST = $(man_MANS)
|
|
|
af39808 |
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/omapip/dispatch.c.libdhcp4client dhcp-4.0.0/omapip/dispatch.c
|
|
|
c987ce5 |
--- dhcp-4.0.0/omapip/dispatch.c.libdhcp4client 2007-11-30 11:51:43.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/omapip/dispatch.c 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
@@ -37,7 +37,7 @@
|
|
|
af39808 |
#include <omapip/omapip_p.h>
|
|
|
c987ce5 |
#include <sys/time.h>
|
|
|
af39808 |
|
|
|
af39808 |
-static omapi_io_object_t omapi_io_states;
|
|
|
af39808 |
+omapi_io_object_t omapi_io_states;
|
|
|
c987ce5 |
time_t cur_time;
|
|
|
af39808 |
|
|
|
af39808 |
OMAPI_OBJECT_ALLOC (omapi_io,
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/omapip/errwarn.c.libdhcp4client dhcp-4.0.0/omapip/errwarn.c
|
|
|
c987ce5 |
--- dhcp-4.0.0/omapip/errwarn.c.libdhcp4client 2008-01-02 17:18:01.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/omapip/errwarn.c 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
@@ -37,6 +37,11 @@
|
|
|
af39808 |
#include <errno.h>
|
|
|
c987ce5 |
#include <syslog.h>
|
|
|
3b727ca |
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
adafcc2 |
+#include <isc-dhcp/libdhcp_control.h>
|
|
|
af39808 |
+extern LIBDHCP_Control *libdhcp_control;
|
|
|
3c1d581 |
+#endif
|
|
|
3b727ca |
+
|
|
|
af39808 |
#ifdef DEBUG
|
|
|
af39808 |
int log_perror = -1;
|
|
|
af39808 |
#else
|
|
|
c987ce5 |
@@ -46,7 +51,9 @@ int log_priority;
|
|
|
af39808 |
void (*log_cleanup) (void);
|
|
|
3b727ca |
|
|
|
af39808 |
#define CVT_BUF_MAX 1023
|
|
|
af39808 |
+#ifndef LIBDHCP
|
|
|
af39808 |
static char mbuf [CVT_BUF_MAX + 1];
|
|
|
af39808 |
+#endif
|
|
|
af39808 |
static char fbuf [CVT_BUF_MAX + 1];
|
|
|
3c1d581 |
|
|
|
af39808 |
/* Log an error message, then exit... */
|
|
|
c987ce5 |
@@ -56,6 +63,16 @@ void log_fatal (const char * fmt, ... )
|
|
|
af39808 |
va_list list;
|
|
|
3c1d581 |
|
|
|
af39808 |
do_percentm (fbuf, fmt);
|
|
|
af39808 |
+
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ if (libdhcp_control && (libdhcp_control->eh)) {
|
|
|
af39808 |
+ va_start (list, fmt);
|
|
|
af39808 |
+ libdhcp_control->eh(libdhcp_control, LOG_FATAL, fbuf, list);
|
|
|
af39808 |
+ va_end(list);
|
|
|
af39808 |
+ libdhcp_control->finished = 1;
|
|
|
af39808 |
+ return;
|
|
|
af39808 |
+ }
|
|
|
3c1d581 |
+#else
|
|
|
3b727ca |
|
|
|
af39808 |
/* %Audit% This is log output. %2004.06.17,Safe%
|
|
|
af39808 |
* If we truncate we hope the user can get a hint from the log.
|
|
|
c987ce5 |
@@ -89,6 +106,7 @@ void log_fatal (const char * fmt, ... )
|
|
|
af39808 |
if (log_cleanup)
|
|
|
af39808 |
(*log_cleanup) ();
|
|
|
af39808 |
exit (1);
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
}
|
|
|
3b727ca |
|
|
|
af39808 |
/* Log an error message... */
|
|
|
c987ce5 |
@@ -99,6 +117,13 @@ int log_error (const char * fmt, ...)
|
|
|
af39808 |
|
|
|
af39808 |
do_percentm (fbuf, fmt);
|
|
|
3b727ca |
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ if (libdhcp_control && libdhcp_control->eh) {
|
|
|
af39808 |
+ va_start (list, fmt);
|
|
|
af39808 |
+ libdhcp_control->eh(libdhcp_control, LOG_ERR, fbuf, list);
|
|
|
af39808 |
+ va_end(list);
|
|
|
af39808 |
+ }
|
|
|
af39808 |
+#else
|
|
|
af39808 |
/* %Audit% This is log output. %2004.06.17,Safe%
|
|
|
af39808 |
* If we truncate we hope the user can get a hint from the log.
|
|
|
af39808 |
*/
|
|
|
c987ce5 |
@@ -114,7 +139,7 @@ int log_error (const char * fmt, ...)
|
|
|
af39808 |
write (STDERR_FILENO, mbuf, strlen (mbuf));
|
|
|
af39808 |
write (STDERR_FILENO, "\n", 1);
|
|
|
af39808 |
}
|
|
|
af39808 |
-
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
return 0;
|
|
|
af39808 |
}
|
|
|
3b727ca |
|
|
|
c987ce5 |
@@ -126,6 +151,13 @@ int log_info (const char *fmt, ...)
|
|
|
3b727ca |
|
|
|
af39808 |
do_percentm (fbuf, fmt);
|
|
|
3b727ca |
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ if (libdhcp_control && libdhcp_control->eh) {
|
|
|
af39808 |
+ va_start (list, fmt);
|
|
|
af39808 |
+ libdhcp_control->eh(libdhcp_control, LOG_INFO, fbuf, list);
|
|
|
af39808 |
+ va_end(list);
|
|
|
af39808 |
+ }
|
|
|
af39808 |
+#else
|
|
|
af39808 |
/* %Audit% This is log output. %2004.06.17,Safe%
|
|
|
af39808 |
* If we truncate we hope the user can get a hint from the log.
|
|
|
af39808 |
*/
|
|
|
c987ce5 |
@@ -141,7 +173,7 @@ int log_info (const char *fmt, ...)
|
|
|
af39808 |
write (STDERR_FILENO, mbuf, strlen (mbuf));
|
|
|
af39808 |
write (STDERR_FILENO, "\n", 1);
|
|
|
af39808 |
}
|
|
|
af39808 |
-
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
return 0;
|
|
|
af39808 |
}
|
|
|
3c1d581 |
|
|
|
c987ce5 |
@@ -152,7 +184,13 @@ int log_debug (const char *fmt, ...)
|
|
|
af39808 |
va_list list;
|
|
|
af39808 |
|
|
|
af39808 |
do_percentm (fbuf, fmt);
|
|
|
af39808 |
-
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ if (libdhcp_control && libdhcp_control->eh) {
|
|
|
af39808 |
+ va_start (list, fmt);
|
|
|
af39808 |
+ libdhcp_control->eh(libdhcp_control, LOG_DEBUG, fbuf, list);
|
|
|
af39808 |
+ va_end(list);
|
|
|
af39808 |
+ }
|
|
|
af39808 |
+#else
|
|
|
af39808 |
/* %Audit% This is log output. %2004.06.17,Safe%
|
|
|
af39808 |
* If we truncate we hope the user can get a hint from the log.
|
|
|
af39808 |
*/
|
|
|
c987ce5 |
@@ -168,7 +206,7 @@ int log_debug (const char *fmt, ...)
|
|
|
af39808 |
write (STDERR_FILENO, mbuf, strlen (mbuf));
|
|
|
af39808 |
write (STDERR_FILENO, "\n", 1);
|
|
|
af39808 |
}
|
|
|
af39808 |
-
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
return 0;
|
|
|
af39808 |
}
|
|
|
3b727ca |
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/omapip/alloc.c.libdhcp4client dhcp-4.0.0/omapip/alloc.c
|
|
|
c987ce5 |
--- dhcp-4.0.0/omapip/alloc.c.libdhcp4client 2007-07-12 20:43:42.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/omapip/alloc.c 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
@@ -37,6 +37,33 @@
|
|
|
3b727ca |
|
|
|
af39808 |
#include <omapip/omapip_p.h>
|
|
|
3c1d581 |
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+/* OK, we need a quick and dirty way of freeing all memory used by libdhcp.
|
|
|
af39808 |
+ All pointers will be stored in a glibc tree on alloc, and removed on free.
|
|
|
af39808 |
+ This is not too expensive for light single-call library use.
|
|
|
af39808 |
+*/
|
|
|
af39808 |
+#include <search.h>
|
|
|
af39808 |
+extern void tdestroy (void *root, void (*free_node)(void *nodep));
|
|
|
af39808 |
+static void *all_pointers=0L;
|
|
|
af39808 |
+static int ptr_comparator(const void *p1, const void *p2) {
|
|
|
af39808 |
+ return ((p1 == p2) ? 0 : ((p1 > p2) ? 1 : -1));
|
|
|
af39808 |
+}
|
|
|
3b727ca |
+
|
|
|
af39808 |
+static void record_pointer(void *ptr) {
|
|
|
af39808 |
+ tsearch(ptr, &(all_pointers), ptr_comparator);
|
|
|
af39808 |
+}
|
|
|
3b727ca |
+
|
|
|
af39808 |
+static void forget_pointer(void *ptr) {
|
|
|
af39808 |
+ tdelete(ptr, &(all_pointers), ptr_comparator);
|
|
|
af39808 |
+}
|
|
|
86a07e1 |
+
|
|
|
af39808 |
+void omapi_free_all_pointers(void) {
|
|
|
af39808 |
+ if (all_pointers != NULL)
|
|
|
af39808 |
+ tdestroy(all_pointers, free);
|
|
|
af39808 |
+ all_pointers = NULL;
|
|
|
af39808 |
+}
|
|
|
af39808 |
+#endif
|
|
|
3b727ca |
+
|
|
|
af39808 |
#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
|
|
|
af39808 |
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
|
|
|
af39808 |
struct dmalloc_preamble *dmalloc_list;
|
|
|
c987ce5 |
@@ -72,7 +99,9 @@ dmalloc(unsigned size, const char *file,
|
|
|
c987ce5 |
return NULL;
|
|
|
af39808 |
|
|
|
af39808 |
foo = malloc(len);
|
|
|
af39808 |
-
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ record_pointer(foo);
|
|
|
af39808 |
+#endif
|
|
|
af39808 |
if (!foo)
|
|
|
c987ce5 |
return NULL;
|
|
|
c987ce5 |
bar = (void *)(foo + DMDOFFSET);
|
|
|
c987ce5 |
@@ -191,6 +220,9 @@ dfree(void *ptr, const char *file, int l
|
|
|
af39808 |
0, (unsigned char *)ptr + DMDOFFSET, 0, 1, RC_MALLOC);
|
|
|
af39808 |
#endif
|
|
|
af39808 |
free (ptr);
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ forget_pointer(ptr);
|
|
|
af39808 |
+#endif
|
|
|
af39808 |
}
|
|
|
af39808 |
|
|
|
af39808 |
#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/dst/Makefile.am.libdhcp4client dhcp-4.0.0/dst/Makefile.am
|
|
|
c987ce5 |
--- dhcp-4.0.0/dst/Makefile.am.libdhcp4client 2008-01-02 17:18:01.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/dst/Makefile.am 2008-01-02 17:45:26.000000000 -1000
|
|
|
c987ce5 |
@@ -2,11 +2,15 @@ AM_CPPFLAGS = -DMINIRES_LIB -DHMAC_MD5
|
|
|
af39808 |
|
|
|
c987ce5 |
lib_LIBRARIES = libdst.a
|
|
|
af39808 |
|
|
|
c987ce5 |
-noinst_LIBRARIES = libdstnomd5.a
|
|
|
c987ce5 |
+noinst_LIBRARIES = libdstnomd5.a libdstLIBDHCP.a
|
|
|
c987ce5 |
|
|
|
c987ce5 |
libdst_a_SOURCES = dst_support.c dst_api.c hmac_link.c md5_dgst.c \
|
|
|
c987ce5 |
base64.c prandom.c
|
|
|
c987ce5 |
|
|
|
c987ce5 |
+libdstLIBDHCP_a_CFLAGS = -DLIBDHCP
|
|
|
c987ce5 |
+libdstLIBDHCP_a_SOURCES = dst_support.c dst_api.c hmac_link.c md5_dgst.c \
|
|
|
c987ce5 |
+ base64.c prandom.c
|
|
|
c987ce5 |
+
|
|
|
c987ce5 |
libdstnomd5_a_SOURCES = dst_support.c dst_api.c hmac_link.c \
|
|
|
c987ce5 |
base64.c prandom.c
|
|
|
c987ce5 |
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/dst/hmac_link.c.libdhcp4client dhcp-4.0.0/dst/hmac_link.c
|
|
|
c987ce5 |
--- dhcp-4.0.0/dst/hmac_link.c.libdhcp4client 2007-12-05 14:50:22.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/dst/hmac_link.c 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
@@ -39,6 +39,10 @@ static const char rcsid[] = "$Header: /p
|
|
|
af39808 |
|
|
|
af39808 |
#include "dst_internal.h"
|
|
|
af39808 |
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+extern void* dmalloc(size_t,char *,int);
|
|
|
af39808 |
+#endif
|
|
|
3b727ca |
+
|
|
|
af39808 |
#ifdef USE_MD5
|
|
|
af39808 |
# include "md5.h"
|
|
|
af39808 |
# ifndef _MD5_H_
|
|
|
c987ce5 |
@@ -87,7 +91,11 @@ dst_hmac_md5_sign(const int mode, DST_KE
|
|
|
af39808 |
MD5_CTX *ctx = NULL;
|
|
|
1270fb8 |
|
|
|
af39808 |
if (mode & SIG_MODE_INIT)
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ ctx = (MD5_CTX *) dmalloc(sizeof(*ctx),__FILE__,__LINE__);
|
|
|
af39808 |
+#else
|
|
|
af39808 |
ctx = (MD5_CTX *) malloc(sizeof(*ctx));
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
else if (context)
|
|
|
af39808 |
ctx = (MD5_CTX *) *context;
|
|
|
af39808 |
if (ctx == NULL)
|
|
|
c987ce5 |
@@ -154,7 +162,11 @@ dst_hmac_md5_verify(const int mode, DST_
|
|
|
af39808 |
MD5_CTX *ctx = NULL;
|
|
|
af39808 |
|
|
|
af39808 |
if (mode & SIG_MODE_INIT)
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ ctx = (MD5_CTX *) dmalloc(sizeof(*ctx),__FILE__,__LINE__);
|
|
|
af39808 |
+#else
|
|
|
af39808 |
ctx = (MD5_CTX *) malloc(sizeof(*ctx));
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
else if (context)
|
|
|
af39808 |
ctx = (MD5_CTX *) *context;
|
|
|
af39808 |
if (ctx == NULL)
|
|
|
c987ce5 |
@@ -218,8 +230,11 @@ dst_buffer_to_hmac_md5(DST_KEY *dkey, co
|
|
|
3c1d581 |
|
|
|
af39808 |
if (dkey == NULL || key == NULL || keylen < 0)
|
|
|
af39808 |
return (-1);
|
|
|
af39808 |
-
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ if ((hkey = (HMAC_Key *) dmalloc(sizeof(HMAC_Key),__FILE__,__LINE__)) == NULL)
|
|
|
af39808 |
+#else
|
|
|
af39808 |
if ((hkey = (HMAC_Key *) malloc(sizeof(HMAC_Key))) == NULL)
|
|
|
af39808 |
+#endif
|
|
|
af39808 |
return (-2);
|
|
|
3c1d581 |
|
|
|
af39808 |
memset(hkey->hk_ipad, 0, sizeof(hkey->hk_ipad));
|
|
|
c987ce5 |
@@ -348,7 +363,11 @@ dst_hmac_md5_key_from_file_format(DST_KE
|
|
|
af39808 |
if (eol == NULL)
|
|
|
af39808 |
return (-4);
|
|
|
af39808 |
len = eol - p;
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ tmp = dmalloc(len + 2,__FILE__,__LINE__);
|
|
|
af39808 |
+#else
|
|
|
af39808 |
tmp = malloc(len + 2);
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
memcpy(tmp, p, len);
|
|
|
af39808 |
*(tmp + len) = 0x0;
|
|
|
af39808 |
key_len = b64_pton((char *)tmp, key, HMAC_LEN+1); /* see above */
|
|
|
c987ce5 |
@@ -440,8 +459,11 @@ dst_hmac_md5_generate_key(DST_KEY *key,
|
|
|
af39808 |
return(0);
|
|
|
af39808 |
|
|
|
af39808 |
len = size > 64 ? 64 : size;
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ buff = dmalloc(len+8,__FILE__,__LINE__);
|
|
|
af39808 |
+#else
|
|
|
af39808 |
buff = malloc(len+8);
|
|
|
af39808 |
-
|
|
|
af39808 |
+#endif
|
|
|
af39808 |
n = dst_random(DST_RAND_SEMI, len, buff);
|
|
|
af39808 |
n += dst_random(DST_RAND_KEY, len, buff);
|
|
|
af39808 |
if (n <= len) { /* failed getting anything */
|
|
|
c987ce5 |
@@ -464,7 +486,11 @@ dst_hmac_md5_init()
|
|
|
3c1d581 |
{
|
|
|
af39808 |
if (dst_t_func[KEY_HMAC_MD5] != NULL)
|
|
|
af39808 |
return (1);
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ dst_t_func[KEY_HMAC_MD5] = dmalloc(sizeof(struct dst_func),__FILE__,__LINE__);
|
|
|
af39808 |
+#else
|
|
|
af39808 |
dst_t_func[KEY_HMAC_MD5] = malloc(sizeof(struct dst_func));
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
if (dst_t_func[KEY_HMAC_MD5] == NULL)
|
|
|
af39808 |
return (0);
|
|
|
af39808 |
memset(dst_t_func[KEY_HMAC_MD5], 0, sizeof(struct dst_func));
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/common/Makefile.am.libdhcp4client dhcp-4.0.0/common/Makefile.am
|
|
|
c987ce5 |
--- dhcp-4.0.0/common/Makefile.am.libdhcp4client 2007-11-16 01:04:11.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/common/Makefile.am 2008-01-02 17:23:13.000000000 -1000
|
|
|
c987ce5 |
@@ -1,11 +1,17 @@
|
|
|
c987ce5 |
AM_CPPFLAGS = -I.. -DLOCALSTATEDIR='"@localstatedir@"'
|
|
|
c987ce5 |
|
|
|
c987ce5 |
-noinst_LIBRARIES = libdhcp.a
|
|
|
c987ce5 |
+noinst_LIBRARIES = libdhcp.a libdhcpLIBDHCP.a
|
|
|
c987ce5 |
libdhcp_a_SOURCES = alloc.c bpf.c comapi.c conflex.c ctrace.c discover.c \
|
|
|
c987ce5 |
dispatch.c dlpi.c dns.c ethernet.c execute.c fddi.c \
|
|
|
c987ce5 |
icmp.c inet.c lpf.c memory.c nit.c options.c packet.c \
|
|
|
c987ce5 |
parse.c print.c raw.c resolv.c socket.c tables.c tr.c \
|
|
|
c987ce5 |
tree.c upf.c heap.c
|
|
|
c987ce5 |
+libdhcpLIBDHCP_a_CFLAGS = -DLIBDHCP
|
|
|
c987ce5 |
+libdhcpLIBDHCP_a_SOURCES = alloc.c bpf.c comapi.c conflex.c ctrace.c \
|
|
|
c987ce5 |
+ discover.c dispatch.c dlpi.c dns.c ethernet.c \
|
|
|
c987ce5 |
+ execute.c inet.c lpf.c memory.c nit.c options.c \
|
|
|
c987ce5 |
+ packet.c parse.c print.c socket.c tables.c tr.c \
|
|
|
c987ce5 |
+ tree.c upf.c
|
|
|
c987ce5 |
man_MANS = dhcp-eval.5 dhcp-options.5
|
|
|
c987ce5 |
EXTRA_DIST = $(man_MANS)
|
|
|
c987ce5 |
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/common/discover.c.libdhcp4client dhcp-4.0.0/common/discover.c
|
|
|
c987ce5 |
--- dhcp-4.0.0/common/discover.c.libdhcp4client 2007-10-05 12:29:51.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/common/discover.c 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
@@ -883,6 +883,10 @@ add_ipv6_addr_to_interface(struct interf
|
|
|
af39808 |
register that interface with the network I/O software, figure out what
|
|
|
af39808 |
subnet it's on, and add it to the list of interfaces. */
|
|
|
3b727ca |
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+int have_setup_fallback = 0;
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
+
|
|
|
c987ce5 |
void
|
|
|
c987ce5 |
discover_interfaces(int state) {
|
|
|
c987ce5 |
struct iface_conf_list ifaces;
|
|
|
c987ce5 |
@@ -902,7 +906,9 @@ discover_interfaces(int state) {
|
|
|
af39808 |
isc_result_t status;
|
|
|
c987ce5 |
int wifcount = 0;
|
|
|
c987ce5 |
|
|
|
3c1d581 |
+#ifndef LIBDHCP
|
|
|
af39808 |
static int setup_fallback = 0;
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
|
|
|
c987ce5 |
if (!begin_iface_scan(&ifaces)) {
|
|
|
c987ce5 |
log_fatal("Can't get list of interfaces.");
|
|
|
c987ce5 |
@@ -1242,10 +1248,17 @@ discover_interfaces(int state) {
|
|
|
af39808 |
log_fatal ("Not configured to listen on any interfaces!");
|
|
|
af39808 |
}
|
|
|
3c1d581 |
|
|
|
1270fb8 |
+#ifdef LIBDHCP
|
|
|
c987ce5 |
+ if ((local_family == AF_INET) && !have_setup_fallback) {
|
|
|
af39808 |
+ have_setup_fallback = 1;
|
|
|
af39808 |
+ maybe_setup_fallback ();
|
|
|
3b727ca |
+ }
|
|
|
3c1d581 |
+#else
|
|
|
c987ce5 |
if ((local_family == AF_INET) && !setup_fallback) {
|
|
|
af39808 |
setup_fallback = 1;
|
|
|
c987ce5 |
maybe_setup_fallback();
|
|
|
af39808 |
}
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
|
|
|
c987ce5 |
#if defined (F_SETFD)
|
|
|
af39808 |
if (fallback_interface) {
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/common/tree.c.libdhcp4client dhcp-4.0.0/common/tree.c
|
|
|
c987ce5 |
--- dhcp-4.0.0/common/tree.c.libdhcp4client 2007-08-22 03:41:37.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/common/tree.c 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
@@ -41,7 +41,7 @@
|
|
|
c987ce5 |
# include <regex.h>
|
|
|
c987ce5 |
#endif
|
|
|
af39808 |
|
|
|
af39808 |
-struct binding_scope *global_scope;
|
|
|
af39808 |
+struct binding_scope __attribute__ ((visibility ("default"))) *global_scope;
|
|
|
af39808 |
|
|
|
af39808 |
static int do_host_lookup PROTO ((struct data_string *,
|
|
|
af39808 |
struct dns_host_entry *));
|
|
|
c987ce5 |
@@ -2859,6 +2859,7 @@ int evaluate_numeric_expression (result,
|
|
|
af39808 |
result of that evaluation. There should never be both an expression
|
|
|
af39808 |
and a valid data_string. */
|
|
|
af39808 |
|
|
|
af39808 |
+__attribute__ ((visibility ("default")))
|
|
|
af39808 |
int evaluate_option_cache (result, packet, lease, client_state,
|
|
|
af39808 |
in_options, cfg_options, scope, oc, file, line)
|
|
|
af39808 |
struct data_string *result;
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/common/options.c.libdhcp4client dhcp-4.0.0/common/options.c
|
|
|
c987ce5 |
--- dhcp-4.0.0/common/options.c.libdhcp4client 2007-11-30 11:51:43.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/common/options.c 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
@@ -3392,6 +3392,7 @@ fqdn6_universe_decode(struct option_stat
|
|
|
c987ce5 |
return 0;
|
|
|
3c1d581 |
}
|
|
|
3c1d581 |
|
|
|
af39808 |
+__attribute__ ((visibility ("default")))
|
|
|
af39808 |
void option_space_foreach (struct packet *packet, struct lease *lease,
|
|
|
af39808 |
struct client_state *client_state,
|
|
|
af39808 |
struct option_state *in_options,
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/common/dispatch.c.libdhcp4client dhcp-4.0.0/common/dispatch.c
|
|
|
c987ce5 |
--- dhcp-4.0.0/common/dispatch.c.libdhcp4client 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/common/dispatch.c 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
@@ -34,8 +34,24 @@
|
|
|
3c1d581 |
|
|
|
af39808 |
#include "dhcpd.h"
|
|
|
3b727ca |
|
|
|
af39808 |
-struct timeout *timeouts;
|
|
|
af39808 |
-static struct timeout *free_timeouts;
|
|
|
af39808 |
+struct timeout {
|
|
|
af39808 |
+#ifndef LIBDHCP
|
|
|
af39808 |
+ struct timeout *next;
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
+ TIME when;
|
|
|
af39808 |
+ void (*func) PROTO ((void *));
|
|
|
af39808 |
+ void *what;
|
|
|
af39808 |
+ tvref_t ref;
|
|
|
af39808 |
+ tvunref_t unref;
|
|
|
af39808 |
+};
|
|
|
3b727ca |
+
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+static struct timeout *timeouts = NULL;
|
|
|
af39808 |
+static int ntimeouts = 0;
|
|
|
af39808 |
+#else
|
|
|
af39808 |
+static struct timeout *timeouts = NULL;
|
|
|
af39808 |
+static struct timeout *free_timeouts = NULL;
|
|
|
af39808 |
+#endif
|
|
|
c637bc5 |
|
|
|
af39808 |
void set_time(TIME t)
|
|
|
af39808 |
{
|
|
|
c987ce5 |
@@ -48,9 +64,41 @@ void set_time(TIME t)
|
|
|
c637bc5 |
|
|
|
af39808 |
struct timeval *process_outstanding_timeouts (struct timeval *tvp)
|
|
|
af39808 |
{
|
|
|
c637bc5 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ int i;
|
|
|
af39808 |
+ struct timeout t = { 0 };
|
|
|
af39808 |
+#endif
|
|
|
af39808 |
/* Call any expired timeouts, and then if there's
|
|
|
af39808 |
still a timeout registered, time out the select
|
|
|
af39808 |
call then. */
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ if (!ntimeouts)
|
|
|
af39808 |
+ return NULL;
|
|
|
c637bc5 |
+
|
|
|
af39808 |
+ for (i = 0; i < ntimeouts && timeouts[i].when <= cur_time;) {
|
|
|
af39808 |
+ struct timeout *new_timeouts;
|
|
|
af39808 |
+ size_t n;
|
|
|
c637bc5 |
+
|
|
|
af39808 |
+ memmove(&t, &timeouts[i], sizeof (t));
|
|
|
c637bc5 |
+
|
|
|
af39808 |
+ n = (ntimeouts - i - 1) * sizeof (t);
|
|
|
af39808 |
+ memmove(&timeouts[i+1], &timeouts[i], n);
|
|
|
c637bc5 |
+
|
|
|
af39808 |
+ n = --ntimeouts * sizeof (t);
|
|
|
af39808 |
+ new_timeouts = realloc(timeouts, n);
|
|
|
af39808 |
+ /* XXX broken API, no way to return error here */
|
|
|
af39808 |
+ if (new_timeouts || !n)
|
|
|
af39808 |
+ timeouts = new_timeouts;
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (t.func)
|
|
|
af39808 |
+ t.func(t.what);
|
|
|
af39808 |
+ if (t.unref)
|
|
|
af39808 |
+ t.unref(t.what, MDL);
|
|
|
af39808 |
+ }
|
|
|
af39808 |
+ if (tvp && ntimeouts) {
|
|
|
af39808 |
+ tvp->tv_sec = timeouts[0].when;
|
|
|
af39808 |
+ tvp->tv_usec = 0;
|
|
|
af39808 |
+#else
|
|
|
af39808 |
another:
|
|
|
af39808 |
if (timeouts) {
|
|
|
af39808 |
struct timeout *t;
|
|
|
c987ce5 |
@@ -68,9 +116,15 @@ struct timeval *process_outstanding_time
|
|
|
af39808 |
tvp -> tv_sec = timeouts -> when;
|
|
|
af39808 |
tvp -> tv_usec = 0;
|
|
|
af39808 |
}
|
|
|
c637bc5 |
+#endif
|
|
|
af39808 |
return tvp;
|
|
|
c637bc5 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ }
|
|
|
af39808 |
+ return NULL;
|
|
|
af39808 |
+#else
|
|
|
af39808 |
} else
|
|
|
af39808 |
return (struct timeval *)0;
|
|
|
c637bc5 |
+#endif
|
|
|
c637bc5 |
}
|
|
|
c637bc5 |
|
|
|
af39808 |
/* Wait for packets to come in using select(). When one does, call
|
|
|
c987ce5 |
@@ -99,13 +153,28 @@ void add_timeout (when, where, what, ref
|
|
|
af39808 |
tvref_t ref;
|
|
|
af39808 |
tvunref_t unref;
|
|
|
af39808 |
{
|
|
|
c637bc5 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ struct timeout t = {
|
|
|
af39808 |
+ .when = when,
|
|
|
af39808 |
+ .func = where,
|
|
|
af39808 |
+ .what = what,
|
|
|
af39808 |
+ .ref = ref,
|
|
|
af39808 |
+ .unref = unref
|
|
|
af39808 |
+ };
|
|
|
af39808 |
+ struct timeout *new_timeouts;
|
|
|
af39808 |
+ int i, pos = 0;
|
|
|
af39808 |
+#else
|
|
|
af39808 |
struct timeout *t, *q;
|
|
|
c637bc5 |
+#endif
|
|
|
c637bc5 |
|
|
|
af39808 |
/* See if this timeout supersedes an existing timeout. */
|
|
|
c637bc5 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ for (i = 0; i < ntimeouts; i++) {
|
|
|
af39808 |
+ struct timeout *q = &timeouts[i];
|
|
|
c637bc5 |
+#else
|
|
|
af39808 |
t = (struct timeout *)0;
|
|
|
af39808 |
for (q = timeouts; q; q = q -> next) {
|
|
|
af39808 |
- if ((where == NULL || q -> func == where) &&
|
|
|
af39808 |
- q -> what == what) {
|
|
|
af39808 |
+ if ((where == NULL || q -> func == where) && q -> what == what) {
|
|
|
af39808 |
if (t)
|
|
|
af39808 |
t -> next = q -> next;
|
|
|
af39808 |
else
|
|
|
c987ce5 |
@@ -114,7 +183,29 @@ void add_timeout (when, where, what, ref
|
|
|
af39808 |
}
|
|
|
af39808 |
t = q;
|
|
|
af39808 |
}
|
|
|
af39808 |
+#endif
|
|
|
c637bc5 |
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ /* If this one is already in the list with a different time,
|
|
|
af39808 |
+ * remove it and re-add */
|
|
|
af39808 |
+ if ((where == NULL || q->func == where) &&
|
|
|
af39808 |
+ q->what == what) {
|
|
|
af39808 |
+ size_t n = (--ntimeouts - i) * sizeof (*q);
|
|
|
af39808 |
+ memmove(&t, q, sizeof (t));
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (n)
|
|
|
af39808 |
+ memmove(&timeouts[i], &timeouts[i+1], n);
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (ntimeouts) {
|
|
|
af39808 |
+ new_timeouts = realloc(timeouts, ntimeouts * sizeof (*q));
|
|
|
af39808 |
+ /* XXX broken API, no way to return error here */
|
|
|
af39808 |
+ if (new_timeouts)
|
|
|
af39808 |
+ timeouts = new_timeouts;
|
|
|
af39808 |
+ } else {
|
|
|
af39808 |
+ timeouts = NULL;
|
|
|
af39808 |
+ }
|
|
|
af39808 |
+ add_timeout(when, where, what, ref, unref);
|
|
|
af39808 |
+#else
|
|
|
af39808 |
/* If we didn't supersede a timeout, allocate a timeout
|
|
|
af39808 |
structure now. */
|
|
|
af39808 |
if (!q) {
|
|
|
c987ce5 |
@@ -123,7 +214,7 @@ void add_timeout (when, where, what, ref
|
|
|
af39808 |
free_timeouts = q -> next;
|
|
|
af39808 |
} else {
|
|
|
af39808 |
q = ((struct timeout *)
|
|
|
af39808 |
- dmalloc (sizeof (struct timeout), MDL));
|
|
|
af39808 |
+ dmalloc (sizeof (struct timeout), MDL));
|
|
|
af39808 |
if (!q)
|
|
|
af39808 |
log_fatal ("add_timeout: no memory!");
|
|
|
af39808 |
}
|
|
|
c987ce5 |
@@ -153,22 +244,76 @@ void add_timeout (when, where, what, ref
|
|
|
af39808 |
if (t -> next -> when > q -> when) {
|
|
|
af39808 |
q -> next = t -> next;
|
|
|
af39808 |
t -> next = q;
|
|
|
c637bc5 |
+#endif
|
|
|
af39808 |
return;
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ } else if (timeouts[i].when > when) {
|
|
|
af39808 |
+ pos = i;
|
|
|
af39808 |
+#endif
|
|
|
af39808 |
}
|
|
|
af39808 |
}
|
|
|
c637bc5 |
|
|
|
c637bc5 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ /* If we didn't supersede an existing timeout, then pos is set
|
|
|
af39808 |
+ * to the timeout which will post after this one. Insert this
|
|
|
af39808 |
+ * one before it. */
|
|
|
af39808 |
+
|
|
|
af39808 |
+ new_timeouts = realloc(timeouts, sizeof (t) * (ntimeouts+1));
|
|
|
af39808 |
+ /* XXX broken API, no way to return error here */
|
|
|
af39808 |
+ if (new_timeouts) {
|
|
|
af39808 |
+ /* ntimeouts = 10
|
|
|
af39808 |
+ * pos = 3;
|
|
|
af39808 |
+ * n = 10-3 * sizeof (t) = 7 * sizeof (t)
|
|
|
af39808 |
+ */
|
|
|
af39808 |
+ size_t n = (ntimeouts - pos) * sizeof (t);
|
|
|
af39808 |
+
|
|
|
af39808 |
+ timeouts = new_timeouts;
|
|
|
af39808 |
+ memmove(&timeouts[pos+1], &timeouts[pos], n);
|
|
|
af39808 |
+ memmove(&timeouts[pos], &t, sizeof (t));
|
|
|
af39808 |
+ ntimeouts++;
|
|
|
af39808 |
+ }
|
|
|
c637bc5 |
+#else
|
|
|
af39808 |
/* End of list. */
|
|
|
af39808 |
t -> next = q;
|
|
|
af39808 |
q -> next = (struct timeout *)0;
|
|
|
c637bc5 |
+#endif
|
|
|
c637bc5 |
}
|
|
|
c637bc5 |
|
|
|
af39808 |
void cancel_timeout (where, what)
|
|
|
af39808 |
void (*where) PROTO ((void *));
|
|
|
af39808 |
void *what;
|
|
|
af39808 |
{
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ struct timeout t;
|
|
|
af39808 |
+ int i = 0;
|
|
|
af39808 |
+#else
|
|
|
af39808 |
struct timeout *t, *q;
|
|
|
af39808 |
+#endif
|
|
|
c637bc5 |
|
|
|
af39808 |
/* Look for this timeout on the list, and unlink it if we find it. */
|
|
|
c637bc5 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ for (i = 0; i < ntimeouts; i++) {
|
|
|
af39808 |
+ struct timeout *new_timeouts, *q = &timeouts[i];
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (q->func == where && q->what == what) {
|
|
|
af39808 |
+ size_t n;
|
|
|
af39808 |
+
|
|
|
af39808 |
+ memmove(&t, q, sizeof (t));
|
|
|
af39808 |
+
|
|
|
af39808 |
+ n = (ntimeouts - i - 1) * sizeof (t);
|
|
|
af39808 |
+ memmove(&timeouts[i+1], &timeouts[i], n);
|
|
|
af39808 |
+
|
|
|
af39808 |
+ n = --ntimeouts * sizeof (t);
|
|
|
af39808 |
+ new_timeouts = realloc(timeouts, n);
|
|
|
af39808 |
+ /* XXX broken API, no way to return error here */
|
|
|
af39808 |
+ if (new_timeouts || !n)
|
|
|
af39808 |
+ timeouts = new_timeouts;
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (t.unref)
|
|
|
af39808 |
+ t.unref(t.what, MDL);
|
|
|
af39808 |
+ }
|
|
|
af39808 |
+ }
|
|
|
c637bc5 |
+#else
|
|
|
af39808 |
t = (struct timeout *)0;
|
|
|
af39808 |
for (q = timeouts; q; q = q -> next) {
|
|
|
af39808 |
if (q -> func == where && q -> what == what) {
|
|
|
c987ce5 |
@@ -188,10 +333,15 @@ void cancel_timeout (where, what)
|
|
|
af39808 |
q -> next = free_timeouts;
|
|
|
af39808 |
free_timeouts = q;
|
|
|
af39808 |
}
|
|
|
c637bc5 |
+#endif
|
|
|
c637bc5 |
}
|
|
|
c637bc5 |
|
|
|
af39808 |
void cancel_all_timeouts ()
|
|
|
af39808 |
{
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ cur_time = TIME_MAX;
|
|
|
af39808 |
+ process_outstanding_timeouts(NULL);
|
|
|
af39808 |
+#else
|
|
|
af39808 |
struct timeout *t, *n;
|
|
|
af39808 |
for (t = timeouts; t; t = n) {
|
|
|
af39808 |
n = t -> next;
|
|
|
c987ce5 |
@@ -200,13 +350,20 @@ void cancel_all_timeouts ()
|
|
|
af39808 |
t -> next = free_timeouts;
|
|
|
af39808 |
free_timeouts = t;
|
|
|
af39808 |
}
|
|
|
af39808 |
+#endif
|
|
|
af39808 |
}
|
|
|
c637bc5 |
|
|
|
af39808 |
+__attribute__ ((visibility ("default")))
|
|
|
af39808 |
void relinquish_timeouts ()
|
|
|
af39808 |
{
|
|
|
c637bc5 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ while (ntimeouts)
|
|
|
af39808 |
+ cancel_timeout(timeouts[0].func, timeouts[0].what);
|
|
|
c637bc5 |
+#else
|
|
|
af39808 |
struct timeout *t, *n;
|
|
|
af39808 |
for (t = free_timeouts; t; t = n) {
|
|
|
af39808 |
n = t -> next;
|
|
|
af39808 |
dfree (t, MDL);
|
|
|
af39808 |
}
|
|
|
c637bc5 |
+#endif
|
|
|
c637bc5 |
}
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/common/alloc.c.libdhcp4client dhcp-4.0.0/common/alloc.c
|
|
|
c987ce5 |
--- dhcp-4.0.0/common/alloc.c.libdhcp4client 2007-10-23 14:54:11.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/common/alloc.c 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
@@ -1004,7 +1004,11 @@ int executable_statement_reference (ptr,
|
|
|
af39808 |
return 1;
|
|
|
af39808 |
}
|
|
|
af39808 |
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+struct packet *free_packets;
|
|
|
af39808 |
+#else
|
|
|
af39808 |
static struct packet *free_packets;
|
|
|
af39808 |
+#endif
|
|
|
c637bc5 |
|
|
|
af39808 |
#if defined (DEBUG_MEMORY_LEAKAGE) || \
|
|
|
af39808 |
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/includes/dhcpd.h.libdhcp4client dhcp-4.0.0/includes/dhcpd.h
|
|
|
c987ce5 |
--- dhcp-4.0.0/includes/dhcpd.h.libdhcp4client 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/includes/dhcpd.h 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
@@ -1199,14 +1199,6 @@ struct hardware_link {
|
|
|
c637bc5 |
|
|
|
c637bc5 |
typedef void (*tvref_t)(void *, void *, const char *, int);
|
|
|
c637bc5 |
typedef void (*tvunref_t)(void *, const char *, int);
|
|
|
c637bc5 |
-struct timeout {
|
|
|
c637bc5 |
- struct timeout *next;
|
|
|
c637bc5 |
- TIME when;
|
|
|
c637bc5 |
- void (*func) PROTO ((void *));
|
|
|
c637bc5 |
- void *what;
|
|
|
c637bc5 |
- tvref_t ref;
|
|
|
c637bc5 |
- tvunref_t unref;
|
|
|
c637bc5 |
-};
|
|
|
c637bc5 |
|
|
|
c637bc5 |
struct protocol {
|
|
|
c637bc5 |
struct protocol *next;
|
|
|
c987ce5 |
@@ -1664,7 +1656,6 @@ extern const char *path_dhcpd_pid;
|
|
|
c987ce5 |
|
|
|
c987ce5 |
extern int dhcp_max_agent_option_packet_length;
|
|
|
c987ce5 |
|
|
|
c987ce5 |
-int main(int, char **);
|
|
|
c987ce5 |
void postconf_initialization(int);
|
|
|
c987ce5 |
void postdb_startup(void);
|
|
|
c987ce5 |
void cleanup PROTO ((void));
|
|
|
c987ce5 |
@@ -2337,7 +2328,6 @@ extern void (*bootp_packet_handler) PROT
|
|
|
c987ce5 |
extern void (*dhcpv6_packet_handler)(struct interface_info *,
|
|
|
c987ce5 |
const char *, int,
|
|
|
c987ce5 |
int, const struct iaddr *, isc_boolean_t);
|
|
|
c637bc5 |
-extern struct timeout *timeouts;
|
|
|
c637bc5 |
extern omapi_object_type_t *dhcp_type_interface;
|
|
|
c637bc5 |
#if defined (TRACING)
|
|
|
c987ce5 |
extern trace_type_t *interface_trace;
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/client/Makefile.am.libdhcp4client dhcp-4.0.0/client/Makefile.am
|
|
|
c987ce5 |
--- dhcp-4.0.0/client/Makefile.am.libdhcp4client 2007-12-12 09:23:42.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/client/Makefile.am 2008-01-02 19:06:30.000000000 -1000
|
|
|
c987ce5 |
@@ -1,10 +1,18 @@
|
|
|
c987ce5 |
dist_sysconf_DATA = dhclient.conf
|
|
|
c987ce5 |
sbin_PROGRAMS = dhclient
|
|
|
c987ce5 |
+lib_LTLIBRARIES = libdhcp4client.la
|
|
|
c987ce5 |
dhclient_SOURCES = clparse.c dhclient.c dhc6.c \
|
|
|
c987ce5 |
scripts/bsdos scripts/freebsd scripts/linux scripts/netbsd \
|
|
|
c987ce5 |
scripts/nextstep scripts/openbsd scripts/solaris
|
|
|
c987ce5 |
dhclient_LDADD = ../common/libdhcp.a ../minires/libres.a \
|
|
|
c987ce5 |
../omapip/libomapi.a ../dst/libdst.a
|
|
|
c987ce5 |
+libdhcp4client_la_CFLAGS = -DLIBDHCP -DLOCALSTATEDIR='"@localstatedir@"'
|
|
|
c987ce5 |
+libdhcp4client_la_LDFLAGS = -version-info \
|
|
|
c987ce5 |
+ $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
|
|
|
c987ce5 |
+ -release $(LT_RELEASE)
|
|
|
c987ce5 |
+libdhcp4client_la_SOURCES = clparse.c dhclient.c
|
|
|
c987ce5 |
+libdhcp4client_la_LIBADD = ../common/libdhcpLIBDHCP.a ../dst/libdstLIBDHCP.a \
|
|
|
c987ce5 |
+ ../omapip/libomapiLIBDHCP.a ../minires/libres.a
|
|
|
c987ce5 |
man_MANS = dhclient.8 dhclient-script.8 dhclient.conf.5 dhclient.leases.5
|
|
|
c987ce5 |
EXTRA_DIST = $(man_MANS)
|
|
|
c987ce5 |
|
|
|
c987ce5 |
diff -up dhcp-4.0.0/client/dhclient.c.libdhcp4client dhcp-4.0.0/client/dhclient.c
|
|
|
c987ce5 |
--- dhcp-4.0.0/client/dhclient.c.libdhcp4client 2008-01-02 17:18:02.000000000 -1000
|
|
|
c987ce5 |
+++ dhcp-4.0.0/client/dhclient.c 2008-01-02 19:02:04.000000000 -1000
|
|
|
c987ce5 |
@@ -83,14 +83,50 @@ int nowait=0;
|
|
|
c987ce5 |
char *mockup_relay = NULL;
|
|
|
af39808 |
int bootp_broadcast_always = 0;
|
|
|
1270fb8 |
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+FILE *leaseFile = NULL;
|
|
|
3c1d581 |
+#endif
|
|
|
1270fb8 |
+
|
|
|
af39808 |
extern u_int32_t default_requested_options[];
|
|
|
3c1d581 |
|
|
|
af39808 |
static void usage PROTO ((void));
|
|
|
3b727ca |
|
|
|
c987ce5 |
static isc_result_t write_duid(struct data_string *duid);
|
|
|
c987ce5 |
|
|
|
c987ce5 |
-int
|
|
|
c987ce5 |
-main(int argc, char **argv) {
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
adafcc2 |
+#include "isc-dhcp/libdhcp_control.h"
|
|
|
af39808 |
+LIBDHCP_Control *libdhcp_control;
|
|
|
af39808 |
+static void libdhcp_dispatch(void)
|
|
|
af39808 |
+{
|
|
|
af39808 |
+ struct timeval tv = { 0, 0 }, *tvp;
|
|
|
af39808 |
+ isc_result_t status;
|
|
|
af39808 |
+
|
|
|
af39808 |
+ /* Wait for a packet, or a timeout, or libdhcp being finished */
|
|
|
af39808 |
+ do {
|
|
|
af39808 |
+ tvp = process_outstanding_timeouts(&tv;;
|
|
|
af39808 |
+ status = omapi_one_dispatch(0, tvp);
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (libdhcp_control && ((status == ISC_R_TIMEDOUT) || (libdhcp_control->timeout && (time(NULL) >= (libdhcp_control->timeout + libdhcp_control->now))))) {
|
|
|
af39808 |
+ if (libdhcp_control->callback)
|
|
|
af39808 |
+ libdhcp_control->callback(libdhcp_control, DHC_TIMEDOUT, NULL);
|
|
|
af39808 |
+
|
|
|
af39808 |
+ break;
|
|
|
af39808 |
+ }
|
|
|
af39808 |
+ } while ((status != ISC_R_TIMEDOUT) && ((!libdhcp_control) || (!(libdhcp_control->finished))));
|
|
|
af39808 |
+}
|
|
|
af39808 |
+
|
|
|
af39808 |
+extern void omapi_free_all_pointers(void);
|
|
|
af39808 |
+
|
|
|
af39808 |
+__attribute__ ((visibility ("default")))
|
|
|
c987ce5 |
+int dhcpv4_client (LIBDHCP_Control *libdhcp_ctl, int argc, char **argv,
|
|
|
c987ce5 |
+ char **envp)
|
|
|
3c1d581 |
+#else
|
|
|
c987ce5 |
+int main(int argc, char **argv, char **envp)
|
|
|
3c1d581 |
+#endif
|
|
|
c987ce5 |
+{
|
|
|
1270fb8 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ libdhcp_control = libdhcp_ctl;
|
|
|
1270fb8 |
+#endif
|
|
|
af39808 |
int fd;
|
|
|
af39808 |
int i;
|
|
|
c987ce5 |
struct interface_info *ip;
|
|
|
c987ce5 |
@@ -122,6 +158,7 @@ main(int argc, char **argv) {
|
|
|
c987ce5 |
/* Initialize client globals. */
|
|
|
c987ce5 |
memset(&default_duid, 0, sizeof(default_duid));
|
|
|
50e3571 |
|
|
|
3b727ca |
+#ifndef LIBDHCP
|
|
|
af39808 |
/* Make sure that file descriptors 0 (stdin), 1, (stdout), and
|
|
|
af39808 |
2 (stderr) are open. To do this, we assume that when we
|
|
|
c987ce5 |
open a file the lowest available file descriptor is used. */
|
|
|
c987ce5 |
@@ -140,6 +177,7 @@ main(int argc, char **argv) {
|
|
|
c987ce5 |
#if !(defined (DEBUG) || defined (__CYGWIN32__))
|
|
|
af39808 |
setlogmask (LOG_UPTO (LOG_INFO));
|
|
|
af39808 |
#endif
|
|
|
3b727ca |
+#endif
|
|
|
3b727ca |
|
|
|
af39808 |
/* Set up the OMAPI. */
|
|
|
af39808 |
status = omapi_init ();
|
|
|
c987ce5 |
@@ -485,8 +523,12 @@ main(int argc, char **argv) {
|
|
|
3b727ca |
}
|
|
|
af39808 |
}
|
|
|
af39808 |
|
|
|
3b727ca |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_PID_FILE))
|
|
|
3b727ca |
+#endif
|
|
|
af39808 |
write_client_pid_file();
|
|
|
3b727ca |
|
|
|
af39808 |
+#ifndef LIBDHCP
|
|
|
af39808 |
if (!quiet) {
|
|
|
c987ce5 |
log_info ("%s %s", message, PACKAGE_VERSION);
|
|
|
af39808 |
log_info (copyright);
|
|
|
c987ce5 |
@@ -497,6 +539,7 @@ main(int argc, char **argv) {
|
|
|
af39808 |
log_perror = 0;
|
|
|
c987ce5 |
quiet_interface_discovery = 1;
|
|
|
c987ce5 |
}
|
|
|
3b727ca |
+#endif
|
|
|
3b727ca |
|
|
|
af39808 |
/* If we're given a relay agent address to insert, for testing
|
|
|
af39808 |
purposes, figure out what it is. */
|
|
|
c987ce5 |
@@ -702,11 +745,17 @@ main(int argc, char **argv) {
|
|
|
af39808 |
arg_conf_len = 0;
|
|
|
3b727ca |
}
|
|
|
3b727ca |
|
|
|
3b727ca |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_LEASE_DATABASE)) {
|
|
|
3b727ca |
+#endif
|
|
|
af39808 |
/* Parse the lease database. */
|
|
|
af39808 |
read_client_leases ();
|
|
|
af39808 |
|
|
|
af39808 |
/* Rewrite the lease database... */
|
|
|
af39808 |
rewrite_client_leases ();
|
|
|
3b727ca |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ }
|
|
|
3b727ca |
+#endif
|
|
|
af39808 |
|
|
|
af39808 |
/* XXX */
|
|
|
af39808 |
/* config_counter(&snd_counter, &rcv_counter); */
|
|
|
c987ce5 |
@@ -725,7 +774,7 @@ main(int argc, char **argv) {
|
|
|
af39808 |
if (!persist) {
|
|
|
af39808 |
/* Nothing more to do. */
|
|
|
af39808 |
log_info ("No broadcast interfaces found - exiting.");
|
|
|
af39808 |
- exit (0);
|
|
|
af39808 |
+ return (0);
|
|
|
3b727ca |
}
|
|
|
af39808 |
} else if (!release_mode && !exit_mode) {
|
|
|
af39808 |
/* Call the script with the list of interfaces. */
|
|
|
c987ce5 |
@@ -863,6 +912,7 @@ main(int argc, char **argv) {
|
|
|
af39808 |
dmalloc_outstanding = 0;
|
|
|
af39808 |
#endif
|
|
|
3b727ca |
|
|
|
af39808 |
+#ifndef LIBDHCP
|
|
|
af39808 |
/* If we're not supposed to wait before getting the address,
|
|
|
af39808 |
don't. */
|
|
|
af39808 |
if (nowait)
|
|
|
c987ce5 |
@@ -875,6 +925,126 @@ main(int argc, char **argv) {
|
|
|
af39808 |
|
|
|
af39808 |
/* Start dispatching packets and timeouts... */
|
|
|
af39808 |
dispatch ();
|
|
|
af39808 |
+#else
|
|
|
af39808 |
+ if (libdhcp_control) {
|
|
|
af39808 |
+ if (libdhcp_control->timeout)
|
|
|
af39808 |
+ libdhcp_control->now = time(NULL);
|
|
|
af39808 |
+ else
|
|
|
af39808 |
+ libdhcp_control->now = 0;
|
|
|
af39808 |
+ }
|
|
|
3b727ca |
+
|
|
|
af39808 |
+ libdhcp_dispatch();
|
|
|
3b727ca |
+
|
|
|
af39808 |
+ /* libdhcp is finished with us. */
|
|
|
af39808 |
+
|
|
|
af39808 |
+ /* close all file descriptors: */
|
|
|
af39808 |
+ for (ip = interfaces; ip; ip = ip->next) {
|
|
|
af39808 |
+ shutdown(ip->wfdesc, SHUT_RDWR);
|
|
|
af39808 |
+ close(ip->wfdesc);
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (ip->rfdesc != ip->wfdesc)
|
|
|
af39808 |
+ close(ip->rfdesc);
|
|
|
3b727ca |
+ }
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (fallback_interface != 0) {
|
|
|
af39808 |
+ ip = fallback_interface;
|
|
|
af39808 |
+ shutdown(ip->wfdesc, SHUT_RDWR);
|
|
|
af39808 |
+ close(ip->wfdesc);
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (ip->rfdesc != ip->wfdesc)
|
|
|
af39808 |
+ close(ip->rfdesc);
|
|
|
af39808 |
+ }
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (leaseFile)
|
|
|
af39808 |
+ fclose (leaseFile);
|
|
|
af39808 |
+
|
|
|
af39808 |
+ closelog();
|
|
|
af39808 |
+
|
|
|
af39808 |
+ char *current_pid_file = _PATH_DHCLIENT_PID;
|
|
|
af39808 |
+
|
|
|
af39808 |
+ /* Free ALL allocated memory: */
|
|
|
af39808 |
+ omapi_free_all_pointers();
|
|
|
af39808 |
+
|
|
|
af39808 |
+ /* Re-Initialize globals: */
|
|
|
af39808 |
+ client_env = 0;
|
|
|
af39808 |
+ client_env_count = 0;
|
|
|
af39808 |
+ default_lease_time = 43200;
|
|
|
af39808 |
+
|
|
|
af39808 |
+ dhcp_max_agent_option_packet_length = 0;
|
|
|
af39808 |
+ iaddr_any.len = 4;
|
|
|
af39808 |
+ memset(&(iaddr_any.iabuf[0]), '\0', 4);
|
|
|
af39808 |
+ iaddr_broadcast.len = 4;
|
|
|
af39808 |
+ memset(&(iaddr_broadcast.iabuf[0]), 0xff, 4);
|
|
|
af39808 |
+ interfaces_requested = 0;
|
|
|
af39808 |
+ leaseFile = 0;
|
|
|
af39808 |
+
|
|
|
af39808 |
+ libdhcp_control = 0;
|
|
|
af39808 |
+
|
|
|
af39808 |
+ local_port = 0;
|
|
|
af39808 |
+ no_daemon = 0;
|
|
|
af39808 |
+ nowait = 0;
|
|
|
af39808 |
+ onetry = 0;
|
|
|
af39808 |
+ quiet = 0;
|
|
|
af39808 |
+ max_lease_time = 86400;
|
|
|
af39808 |
+ path_dhclient_conf = _PATH_DHCLIENT_CONF;
|
|
|
af39808 |
+ path_dhclient_db = _PATH_DHCLIENT_DB;
|
|
|
af39808 |
+ path_dhclient_pid = _PATH_DHCLIENT_PID;
|
|
|
af39808 |
+ strcpy(&(path_dhclient_script_array[0]), _PATH_DHCLIENT_SCRIPT);
|
|
|
af39808 |
+ path_dhclient_script = path_dhclient_script_array;
|
|
|
af39808 |
+ remote_port = 0;
|
|
|
af39808 |
+ resolver_inited = 0;
|
|
|
af39808 |
+ log_perror = 1;
|
|
|
af39808 |
+ global_scope = NULL;
|
|
|
af39808 |
+ root_group = NULL;
|
|
|
af39808 |
+ group_name_hash = NULL;
|
|
|
af39808 |
+ interfaces = NULL;
|
|
|
af39808 |
+ dummy_interfaces = NULL;
|
|
|
af39808 |
+ fallback_interface = NULL;
|
|
|
af39808 |
+ extern int have_setup_fallback;
|
|
|
af39808 |
+ have_setup_fallback = 0;
|
|
|
af39808 |
+ quiet_interface_discovery = 1;
|
|
|
af39808 |
+#ifndef LIBDHCP
|
|
|
af39808 |
+ timeouts = NULL;
|
|
|
af39808 |
+#endif
|
|
|
af39808 |
+ dhcp_type_interface = NULL;
|
|
|
af39808 |
+ interface_vector = NULL;
|
|
|
af39808 |
+ interface_count = 0;
|
|
|
af39808 |
+ interface_max = 0;
|
|
|
af39808 |
+ name_servers = 0;
|
|
|
af39808 |
+ domains = 0;
|
|
|
af39808 |
+ dhcp_type_interface = NULL;
|
|
|
af39808 |
+ dhcp_type_group = NULL;
|
|
|
af39808 |
+ dhcp_type_shared_network = NULL;
|
|
|
af39808 |
+ dhcp_type_control = NULL;
|
|
|
af39808 |
+ memset(&dhcp_universe, '\0', sizeof(struct universe));
|
|
|
af39808 |
+ memset(&nwip_universe, '\0', sizeof(struct universe));
|
|
|
af39808 |
+ memset(&fqdn_universe, '\0', sizeof(struct universe));
|
|
|
af39808 |
+ universe_hash = 0;
|
|
|
af39808 |
+ universes = 0;
|
|
|
af39808 |
+ universe_count = 0;
|
|
|
af39808 |
+ universe_max = 0;
|
|
|
c987ce5 |
+ config_universe = 0;
|
|
|
af39808 |
+ extern struct hash_bucket *free_hash_buckets;
|
|
|
af39808 |
+ free_hash_buckets = NULL;
|
|
|
af39808 |
+ extern struct dhcp_packet *dhcp_free_list;
|
|
|
af39808 |
+ dhcp_free_list = NULL;
|
|
|
af39808 |
+ extern struct packet *packet_free_list;
|
|
|
af39808 |
+ packet_free_list = NULL;
|
|
|
af39808 |
+ extern struct binding_value *free_binding_values;
|
|
|
af39808 |
+ free_binding_values = NULL;
|
|
|
af39808 |
+ extern struct expression *free_expressions;
|
|
|
af39808 |
+ free_expressions = NULL;
|
|
|
af39808 |
+ extern struct option_cache *free_option_caches;
|
|
|
af39808 |
+ free_option_caches = NULL;
|
|
|
af39808 |
+ extern struct packet *free_packets;
|
|
|
af39808 |
+ free_packets = NULL;
|
|
|
af39808 |
+ extern pair free_pairs;
|
|
|
af39808 |
+ free_pairs = NULL;
|
|
|
af39808 |
+ extern omapi_io_object_t omapi_io_states;
|
|
|
af39808 |
+ memset(&omapi_io_states, '\0', sizeof(omapi_io_states));
|
|
|
af39808 |
+ dhcp_control_object = NULL;
|
|
|
af39808 |
+ unlink(current_pid_file);
|
|
|
3b727ca |
+#endif
|
|
|
3b727ca |
|
|
|
af39808 |
/*NOTREACHED*/
|
|
|
af39808 |
return 0;
|
|
|
c987ce5 |
@@ -1270,7 +1440,20 @@ void dhcpack (packet)
|
|
|
af39808 |
if (client -> new -> rebind < cur_time)
|
|
|
af39808 |
client -> new -> rebind = TIME_MAX;
|
|
|
3b727ca |
|
|
|
3b727ca |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ /* We need the server's siaddr for the 'bootServer'
|
|
|
af39808 |
+ * pump option
|
|
|
af39808 |
+ */
|
|
|
af39808 |
+ u_int32_t set_siaddr = 0;
|
|
|
af39808 |
+ set_siaddr = client->packet.siaddr.s_addr;
|
|
|
af39808 |
+ client->packet.siaddr.s_addr = packet->raw->siaddr.s_addr;
|
|
|
af39808 |
+#endif
|
|
|
3b727ca |
+
|
|
|
af39808 |
bind_lease (client);
|
|
|
3b727ca |
+
|
|
|
af39808 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ client->packet.siaddr.s_addr = set_siaddr;
|
|
|
3b727ca |
+#endif
|
|
|
3b727ca |
}
|
|
|
3b727ca |
|
|
|
af39808 |
void bind_lease (client)
|
|
|
c987ce5 |
@@ -1306,6 +1489,9 @@ void bind_lease (client)
|
|
|
af39808 |
return;
|
|
|
3b727ca |
}
|
|
|
f6f89c9 |
|
|
|
3b727ca |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_LEASE_DATABASE))
|
|
|
3b727ca |
+#endif
|
|
|
af39808 |
/* Write out the new lease. */
|
|
|
af39808 |
write_client_lease (client, client -> new, 0, 0);
|
|
|
af39808 |
|
|
|
c987ce5 |
@@ -1398,10 +1584,12 @@ void state_stop (cpp)
|
|
|
c987ce5 |
}
|
|
|
c987ce5 |
}
|
|
|
3c1d581 |
|
|
|
af39808 |
+#ifndef LIBDHCP
|
|
|
c987ce5 |
int commit_leases ()
|
|
|
af39808 |
{
|
|
|
af39808 |
return 0;
|
|
|
af39808 |
}
|
|
|
af39808 |
+#endif
|
|
|
3c1d581 |
|
|
|
c987ce5 |
int write_lease (lease)
|
|
|
c987ce5 |
struct lease *lease;
|
|
|
c987ce5 |
@@ -2074,6 +2262,10 @@ void state_panic (cpp)
|
|
|
af39808 |
tell the shell script that we failed to allocate an address,
|
|
|
af39808 |
and try again later. */
|
|
|
af39808 |
if (onetry) {
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ script_init (client, "FAIL", (struct string_list *)0);
|
|
|
af39808 |
+ return;
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
if (!quiet)
|
|
|
af39808 |
log_info ("Unable to obtain a lease on first try.%s",
|
|
|
af39808 |
" Exiting.");
|
|
|
c987ce5 |
@@ -2691,7 +2883,9 @@ void destroy_client_lease (lease)
|
|
|
af39808 |
free_client_lease (lease, MDL);
|
|
|
af39808 |
}
|
|
|
3c1d581 |
|
|
|
af39808 |
+#ifndef LIBDHCP
|
|
|
c987ce5 |
FILE *leaseFile = NULL;
|
|
|
3c1d581 |
+#endif
|
|
|
c987ce5 |
int leases_written = 0;
|
|
|
3c1d581 |
|
|
|
af39808 |
void rewrite_client_leases ()
|
|
|
c987ce5 |
@@ -3218,6 +3412,54 @@ void script_write_params (client, prefix
|
|
|
af39808 |
int script_go (client)
|
|
|
af39808 |
struct client_state *client;
|
|
|
af39808 |
{
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ struct string_list *sp;
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (libdhcp_control && libdhcp_control->callback) {
|
|
|
af39808 |
+ int dhcmsg;
|
|
|
af39808 |
+ char *reason="";
|
|
|
af39808 |
+
|
|
|
af39808 |
+ for (sp = client->env; sp; sp = sp->next)
|
|
|
af39808 |
+ if (strncmp(sp->string, "reason=", 7) == 0) {
|
|
|
af39808 |
+ reason = sp->string + 7;
|
|
|
af39808 |
+ break;
|
|
|
af39808 |
+ }
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (strcmp(reason,"NBI") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_NBI;
|
|
|
af39808 |
+ else if (strcmp(reason,"PREINIT") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_PREINIT;
|
|
|
af39808 |
+ else if (strcmp(reason,"BOUND") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_BOUND;
|
|
|
af39808 |
+ else if (strcmp(reason,"RENEW") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_RENEW;
|
|
|
af39808 |
+ else if (strcmp(reason,"REBOOT") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_REBOOT;
|
|
|
af39808 |
+ else if (strcmp(reason,"REBIND") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_REBIND;
|
|
|
af39808 |
+ else if (strcmp(reason,"STOP") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_STOP;
|
|
|
af39808 |
+ else if (strcmp(reason,"MEDIUM") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_MEDIUM;
|
|
|
af39808 |
+ else if (strcmp(reason,"TIMEOUT") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_TIMEOUT;
|
|
|
af39808 |
+ else if (strcmp(reason,"FAIL") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_FAIL;
|
|
|
af39808 |
+ else if (strcmp(reason,"EXPIRE") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_EXPIRE;
|
|
|
af39808 |
+ else if (strcmp(reason,"RELEASE") == 0)
|
|
|
af39808 |
+ dhcmsg = DHC4_RELEASE;
|
|
|
af39808 |
+ else
|
|
|
af39808 |
+ dhcmsg = DHC4_NBI;
|
|
|
af39808 |
+
|
|
|
af39808 |
+ (*libdhcp_control->callback) (libdhcp_control, dhcmsg, client);
|
|
|
af39808 |
+
|
|
|
af39808 |
+ if (libdhcp_control->decline)
|
|
|
af39808 |
+ return 1;
|
|
|
af39808 |
+ }
|
|
|
af39808 |
+
|
|
|
af39808 |
+ return 0;
|
|
|
3c1d581 |
+#else
|
|
|
af39808 |
char *scriptName;
|
|
|
af39808 |
char *argv [2];
|
|
|
c987ce5 |
char **envp;
|
|
|
c987ce5 |
@@ -3294,6 +3536,7 @@ int script_go (client)
|
|
|
c987ce5 |
time(&cur_time);
|
|
|
af39808 |
return (WIFEXITED (wstatus) ?
|
|
|
af39808 |
WEXITSTATUS (wstatus) : -WTERMSIG (wstatus));
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
}
|
|
|
3c1d581 |
|
|
|
af39808 |
void client_envadd (struct client_state *client,
|
|
|
c987ce5 |
@@ -3376,6 +3619,9 @@ void go_daemon ()
|
|
|
3c1d581 |
|
|
|
af39808 |
/* Don't become a daemon if the user requested otherwise. */
|
|
|
af39808 |
if (no_daemon) {
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_PID_FILE ))
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
write_client_pid_file ();
|
|
|
af39808 |
return;
|
|
|
af39808 |
}
|
|
|
c987ce5 |
@@ -3385,6 +3631,10 @@ void go_daemon ()
|
|
|
af39808 |
return;
|
|
|
af39808 |
state = 1;
|
|
|
af39808 |
|
|
|
3c1d581 |
+#ifdef LIBDHCP
|
|
|
af39808 |
+ return;
|
|
|
3c1d581 |
+#endif
|
|
|
af39808 |
+
|
|
|
af39808 |
/* Stop logging to stderr... */
|
|
|
af39808 |
log_perror = 0;
|
|
|
af39808 |
|