summaryrefslogtreecommitdiff
path: root/omapip
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2013-12-11 08:08:42 -0800
committerShawn Routhier <sar@isc.org>2013-12-11 08:08:42 -0800
commit61ef216b8dc05bc4245b61eee812038757d12ffe (patch)
tree5ad2e69325a491a95cbdf6bbb44be23c61764992 /omapip
parent51e2e60626f0b86e4303ad4c68ba5106a7de8152 (diff)
downloadisc-dhcp-61ef216b8dc05bc4245b61eee812038757d12ffe.tar.gz
[master] Add support for user selection of the from address for DDNS transactions
Diffstat (limited to 'omapip')
-rw-r--r--omapip/isclib.c165
-rw-r--r--omapip/test.c5
2 files changed, 95 insertions, 75 deletions
diff --git a/omapip/isclib.c b/omapip/isclib.c
index 7ef1591f..700bd88c 100644
--- a/omapip/isclib.c
+++ b/omapip/isclib.c
@@ -121,91 +121,110 @@ isclib_cleanup(void)
}
isc_result_t
-dhcp_context_create(void) {
+dhcp_context_create(int flags,
+ struct in_addr *local4,
+ struct in6_addr *local6) {
isc_result_t result;
- /*
- * Set up the error messages, this isn't the right place
- * for this call but it is convienent for now.
- */
- result = dhcp_result_register();
- if (result != ISC_R_SUCCESS) {
- log_fatal("register_table() %s: %u", "failed", result);
- }
+ if ((flags & DHCP_CONTEXT_PRE_DB) != 0) {
+ /*
+ * Set up the error messages, this isn't the right place
+ * for this call but it is convienent for now.
+ */
+ result = dhcp_result_register();
+ if (result != ISC_R_SUCCESS) {
+ log_fatal("register_table() %s: %u", "failed", result);
+ }
- memset(&dhcp_gbl_ctx, 0, sizeof (dhcp_gbl_ctx));
+ memset(&dhcp_gbl_ctx, 0, sizeof (dhcp_gbl_ctx));
- isc_lib_register();
+ isc_lib_register();
- /* get the current time for use as the random seed */
- gettimeofday(&cur_tv, (struct timezone *)0);
- isc_random_seed(cur_tv.tv_sec);
+ /* get the current time for use as the random seed */
+ gettimeofday(&cur_tv, (struct timezone *)0);
+ isc_random_seed(cur_tv.tv_sec);
#if defined (NSUPDATE)
- result = dns_lib_init();
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-#endif
-
- result = isc_mem_create(0, 0, &dhcp_gbl_ctx.mctx);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
- result = isc_appctx_create(dhcp_gbl_ctx.mctx, &dhcp_gbl_ctx.actx);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
+ result = dns_lib_init();
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+#else
+ /* The dst library is inited as part of dns_lib_init, we don't
+ * need it if NSUPDATE is enabled */
+ result = dst_lib_init(dhcp_gbl_ctx.mctx, NULL, 0);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
- result = isc_app_ctxstart(dhcp_gbl_ctx.actx);
- if (result != ISC_R_SUCCESS)
- return (result);
- dhcp_gbl_ctx.actx_started = ISC_TRUE;
-
- result = isc_taskmgr_createinctx(dhcp_gbl_ctx.mctx,
- dhcp_gbl_ctx.actx,
- 1, 0,
- &dhcp_gbl_ctx.taskmgr);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
- result = isc_socketmgr_createinctx(dhcp_gbl_ctx.mctx,
- dhcp_gbl_ctx.actx,
- &dhcp_gbl_ctx.socketmgr);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
- result = isc_timermgr_createinctx(dhcp_gbl_ctx.mctx,
- dhcp_gbl_ctx.actx,
- &dhcp_gbl_ctx.timermgr);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
- result = isc_task_create(dhcp_gbl_ctx.taskmgr, 0, &dhcp_gbl_ctx.task);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
+#endif
+ result = isc_mem_create(0, 0, &dhcp_gbl_ctx.mctx);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = isc_appctx_create(dhcp_gbl_ctx.mctx,
+ &dhcp_gbl_ctx.actx);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = isc_app_ctxstart(dhcp_gbl_ctx.actx);
+ if (result != ISC_R_SUCCESS)
+ return (result);
+ dhcp_gbl_ctx.actx_started = ISC_TRUE;
+
+ result = isc_taskmgr_createinctx(dhcp_gbl_ctx.mctx,
+ dhcp_gbl_ctx.actx,
+ 1, 0,
+ &dhcp_gbl_ctx.taskmgr);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = isc_socketmgr_createinctx(dhcp_gbl_ctx.mctx,
+ dhcp_gbl_ctx.actx,
+ &dhcp_gbl_ctx.socketmgr);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = isc_timermgr_createinctx(dhcp_gbl_ctx.mctx,
+ dhcp_gbl_ctx.actx,
+ &dhcp_gbl_ctx.timermgr);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = isc_task_create(dhcp_gbl_ctx.taskmgr, 0, &dhcp_gbl_ctx.task);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+ }
#if defined (NSUPDATE)
- result = dns_client_createx(dhcp_gbl_ctx.mctx,
- dhcp_gbl_ctx.actx,
- dhcp_gbl_ctx.taskmgr,
- dhcp_gbl_ctx.socketmgr,
- dhcp_gbl_ctx.timermgr,
- 0,
- &dhcp_gbl_ctx.dnsclient);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
- result = dhcp_dns_client_setservers();
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
-#else
- /* The dst library is inited as part of dns_lib_init, we don't
- * need it if NSUPDATE is enabled */
- result = dst_lib_init(dhcp_gbl_ctx.mctx, NULL, 0);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
+ if ((flags & DHCP_CONTEXT_POST_DB) != 0) {
+ isc_sockaddr_t localaddr4, *localaddr4_ptr = NULL;
+ isc_sockaddr_t localaddr6, *localaddr6_ptr = NULL;
+ if (local4 != NULL) {
+ isc_sockaddr_fromin(&localaddr4, local4, 0);
+ localaddr4_ptr = &localaddr4;
+ }
+ if (local6 != NULL) {
+ isc_sockaddr_fromin6(&localaddr6, local6, 0);
+ localaddr6_ptr = &localaddr6;
+ }
+ result = dns_client_createx2(dhcp_gbl_ctx.mctx,
+ dhcp_gbl_ctx.actx,
+ dhcp_gbl_ctx.taskmgr,
+ dhcp_gbl_ctx.socketmgr,
+ dhcp_gbl_ctx.timermgr,
+ 0,
+ &dhcp_gbl_ctx.dnsclient,
+ localaddr4_ptr,
+ localaddr6_ptr);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = dhcp_dns_client_setservers();
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+ }
#endif
+
return(ISC_R_SUCCESS);
cleanup:
diff --git a/omapip/test.c b/omapip/test.c
index 1171317b..9aadb9ba 100644
--- a/omapip/test.c
+++ b/omapip/test.c
@@ -3,7 +3,7 @@
Test code for omapip... */
/*
- * Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009-2010,2013 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
@@ -51,7 +51,8 @@ int main (int argc, char **argv)
omapi_object_t *connection = (omapi_object_t*)0;
isc_result_t status;
- status = dhcp_context_create();
+ status = dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
if (status != ISC_R_SUCCESS) {
fprintf(stderr, "Can't initialize context: %s\n",
isc_result_totext(status));