42 #include <dns/result.h> 52 extern int asprintf(
char **strp,
const char *fmt, ...);
83 #define ASSERT_STATE(state_is, state_shouldbe) {} 86 static const char copyright[] =
"Copyright 2004-2017 Internet Systems Consortium.";
87 static const char arr [] =
"All rights reserved.";
88 static const char message [] =
"Internet Systems Consortium DHCP Client";
89 static const char url [] =
"For info, please visit https://www.isc.org/software/dhcp/";
94 #if defined(DHCPv6) && defined(DHCP4o6) 95 int dhcp4o6_state = -1;
121 static isc_result_t write_duid(
struct data_string *duid);
124 static int check_domain_name(
const char *ptr,
size_t len,
int dots);
125 static int check_domain_name_list(
const char *ptr,
size_t len,
int dots);
127 const char *ptr,
size_t len);
148 #if defined(DHCPv6) && defined(DHCP4o6) 149 static void dhcp4o6_poll(
void *dummy);
150 static void dhcp4o6_resume(
void);
151 static void recv_dhcpv4_response(
struct data_string *raw);
152 static int send_dhcpv4_query(
struct client_state *client,
int broadcast);
154 static void dhcp4o6_stop(
void);
155 static void forw_dhcpv4_response(
struct packet *
packet);
156 static void forw_dhcpv4_query(
struct data_string *raw);
163 static const char use_noarg[] =
"No argument for command: %s";
165 static const char use_v6command[] =
"Command not used for DHCPv4: %s";
171 usage(
const char *sfmt,
const char *sarg)
179 #ifdef PRINT_SPECIFIC_CL_ERRORS 187 "[-4|-6] [-SNTPRI1dvrxi] [-nw] -4o6 <port>] [-p <port>]\n" 188 " [-D LL|LLT] [--dad-wait-time seconds]\n" 190 "[-4|-6] [-SNTPRI1dvrxi] [-nw] [-p <port>]\n" 191 " [-D LL|LLT] [--dad-wait-time seconds]\n" 194 "[-I1dvrxi] [-nw] [-p <port>] [-D LL|LLT] \n" 196 " [-s server-addr] [-cf config-file]\n" 197 " [-df duid-file] [-lf lease-file]\n" 198 " [-pf pid-file] [--no-pid] [-e VAR=val]\n" 199 " [-sf script-file] [interface]*\n" 200 " [-C <dhcp-client-identifier>] [-B]\n" 201 " [-H <host-name> | -F <fqdn.fqdn>] [--timeout <timeout>]\n" 202 " [-V <vendor-class-identifier>]\n" 203 " [--request-options <request option list>]",
217 int release_mode = 0;
222 int no_dhclient_conf = 0;
223 int no_dhclient_db = 0;
224 int no_dhclient_pid = 0;
225 int no_dhclient_script = 0;
227 int local_family_set = 0;
229 u_int16_t dhcp4o6_port = 0;
240 char *dhcp_client_identifier_arg = NULL;
241 char *dhcp_host_name_arg = NULL;
242 char *dhcp_fqdn_arg = NULL;
243 char *dhcp_vendor_class_identifier_arg = NULL;
244 char *dhclient_request_options = NULL;
247 char *arg_conf = NULL;
248 int arg_conf_len = 0;
249 #ifdef HAVE_LIBCAP_NG 250 int keep_capabilities = 0;
259 fd = open(
"/dev/null", O_RDWR | O_CLOEXEC);
261 fd = open(
"/dev/null", O_RDWR | O_CLOEXEC);
263 fd = open(
"/dev/null", O_RDWR | O_CLOEXEC);
271 #if !(defined(DEBUG) || defined(__CYGWIN32__)) 272 setlogmask(LOG_UPTO(LOG_INFO));
278 if (status != ISC_R_SUCCESS)
279 log_fatal(
"Can't initialize context: %s",
280 isc_result_totext(status));
284 if (status != ISC_R_SUCCESS)
286 isc_result_totext(status));
296 for (i = 1; i < argc; i++) {
297 if (!strcmp(argv[i],
"-r")) {
301 }
else if (!strcmp(argv[i],
"-4")) {
303 log_fatal(
"Client can only do v4 or v6, not " 305 local_family_set = 1;
307 }
else if (!strcmp(argv[i],
"-6")) {
309 log_fatal(
"Client can only do v4 or v6, not " 311 local_family_set = 1;
314 }
else if (!strcmp(argv[i],
"-4o6")) {
316 usage(use_noarg, argv[i-1]);
319 log_debug(
"DHCPv4 over DHCPv6 over ::1 port %d and %d",
321 ntohs(dhcp4o6_port) + 1);
325 }
else if (!strcmp(argv[i],
"-x")) {
329 }
else if (!strcmp(argv[i],
"-p")) {
331 usage(use_noarg, argv[i-1]);
333 log_debug(
"binding to user-specified port %d",
335 }
else if (!strcmp(argv[i],
"-d")) {
338 }
else if (!strcmp(argv[i],
"-pf")) {
340 usage(use_noarg, argv[i-1]);
343 }
else if (!strcmp(argv[i],
"--no-pid")) {
345 }
else if (!strcmp(argv[i],
"-cf")) {
347 usage(use_noarg, argv[i-1]);
349 no_dhclient_conf = 1;
350 }
else if (!strcmp(argv[i],
"-df")) {
352 usage(use_noarg, argv[i-1]);
354 }
else if (!strcmp(argv[i],
"-lf")) {
356 usage(use_noarg, argv[i-1]);
359 }
else if (!strcmp(argv[i],
"-sf")) {
361 usage(use_noarg, argv[i-1]);
363 no_dhclient_script = 1;
364 }
else if (!strcmp(argv[i],
"-1")) {
366 }
else if (!strcmp(argv[i],
"-q")) {
368 }
else if (!strcmp(argv[i],
"-s")) {
370 usage(use_noarg, argv[i-1]);
372 }
else if (!strcmp(argv[i],
"-g")) {
374 usage(use_noarg, argv[i-1]);
376 }
else if (!strcmp(argv[i],
"-nw")) {
378 }
else if (!strcmp(argv[i],
"-n")) {
381 }
else if (!strcmp(argv[i],
"-w")) {
384 }
else if (!strcmp(argv[i],
"-e")) {
387 usage(use_noarg, argv[i-1]);
388 tmp =
dmalloc(strlen(argv[i]) +
sizeof *tmp,
MDL);
391 strcpy(tmp->
string, argv[i]);
396 }
else if (!strcmp(argv[i],
"-S")) {
398 usage(use_v6command, argv[i]);
400 local_family_set = 1;
404 }
else if (!strcmp(argv[i],
"-N")) {
406 usage(use_v6command, argv[i]);
408 local_family_set = 1;
414 }
else if (!strcmp(argv[i],
"-T")) {
416 usage(use_v6command, argv[i]);
418 local_family_set = 1;
424 }
else if (!strcmp(argv[i],
"-P")) {
426 usage(use_v6command, argv[i]);
428 local_family_set = 1;
434 }
else if (!strcmp(argv[i],
"-R")) {
436 usage(use_v6command, argv[i]);
438 local_family_set = 1;
441 }
else if (!strcmp(argv[i],
"--dad-wait-time")) {
443 usage(use_noarg, argv[i-1]);
447 usage(
"Invalid value for --dad-wait-time: %s", argv[i]);
451 }
else if (!strcmp(argv[i],
"-D")) {
454 usage(use_noarg, argv[i-1]);
455 if (!strcasecmp(argv[i],
"LL")) {
457 }
else if (!strcasecmp(argv[i],
"LLT")) {
460 usage(
"Unknown argument to -D: %s", argv[i]);
462 }
else if (!strcmp(argv[i],
"-i")) {
465 }
else if (!strcmp(argv[i],
"-I")) {
468 }
else if (!strcmp(argv[i],
"-v")) {
470 }
else if (!strcmp(argv[i],
"--version")) {
471 const char vstring[] =
"isc-dhclient-";
479 }
else if (!strcmp(argv[i],
"-C")) {
480 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
481 usage(use_noarg, argv[i-1]);
490 dhcp_client_identifier_arg = argv[i];
491 }
else if (!strcmp(argv[i],
"-B")) {
493 }
else if (!strcmp(argv[i],
"-H")) {
494 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
495 usage(use_noarg, argv[i-1]);
504 if (dhcp_host_name_arg != NULL) {
505 log_error(
"The -H <host-name> and -F <fqdn> arguments are mutually exclusive");
509 dhcp_host_name_arg = argv[i];
510 }
else if (!strcmp(argv[i],
"-F")) {
511 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
512 usage(use_noarg, argv[i-1]);
521 if (dhcp_fqdn_arg != NULL) {
522 log_error(
"Only one -F <fqdn> argument can be specified");
526 if (dhcp_host_name_arg != NULL) {
527 log_error(
"The -F <fqdn> and -H <host-name> arguments are mutually exclusive");
531 dhcp_fqdn_arg = argv[i];
532 }
else if (!strcmp(argv[i],
"--timeout")) {
533 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
534 usage(use_noarg, argv[i-1]);
538 if ((timeout_arg = atoi(argv[i])) <= 0) {
539 log_error(
"timeout option must be > 0 - bad value: %s",argv[i]);
542 }
else if (!strcmp(argv[i],
"-V")) {
543 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
544 usage(use_noarg, argv[i-1]);
553 dhcp_vendor_class_identifier_arg = argv[i];
554 }
else if (!strcmp(argv[i],
"--request-options")) {
555 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
556 usage(use_noarg, argv[i-1]);
560 dhclient_request_options = argv[i];
561 }
else if (!strcmp(argv[i],
"-nc")) {
562 #ifdef HAVE_LIBCAP_NG 563 keep_capabilities = 1;
565 }
else if (argv[i][0] ==
'-') {
566 usage(
"Unknown command: %s", argv[i]);
568 usage(
"No interfaces comamnd -n and " 569 " requested interface %s", argv[i]);
573 status = interface_allocate(&tmp,
MDL);
574 if (status != ISC_R_SUCCESS)
575 log_fatal(
"Can't record interface %s:%s",
576 argv[i], isc_result_totext(status));
577 if (strlen(argv[i]) >=
sizeof(tmp->
name))
578 log_fatal(
"%s: interface name too long (is %ld)",
579 argv[i], (
long)strlen(argv[i]));
580 strcpy(tmp->
name, argv[i]);
582 interface_reference(&tmp->
next,
598 usage(
"PD %s only supports one requested interface",
"-P");
601 #if defined(DHCPv6) && defined(DHCP4o6) 603 (exit_mode || release_mode))
604 log_error(
"Can't relay DHCPv4-over-DHCPv6 " 605 "without a persistent DHCPv6 client");
608 log_fatal(
"DHCPv4-over-DHCPv6 requires an explicit " 609 "interface on which to be applied");
612 if (!no_dhclient_conf && (s = getenv(
"PATH_DHCLIENT_CONF"))) {
615 if (!no_dhclient_db && (s = getenv(
"PATH_DHCLIENT_DB"))) {
618 if (!no_dhclient_pid && (s = getenv(
"PATH_DHCLIENT_PID"))) {
621 if (!no_dhclient_script && (s = getenv(
"PATH_DHCLIENT_SCRIPT"))) {
625 #ifdef HAVE_LIBCAP_NG 627 if (!keep_capabilities) {
628 capng_clear(CAPNG_SELECT_CAPS);
629 capng_update(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED,
631 capng_updatev(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED,
632 CAP_NET_ADMIN, CAP_NET_RAW,
633 CAP_NET_BIND_SERVICE, CAP_SYS_ADMIN, -1);
634 capng_apply(CAPNG_SELECT_CAPS);
659 log_fatal(
"Failed to get realpath for %s: %s", old_path, strerror(errno));
666 log_fatal(
"Failed to get realpath for %s: %s", old_path, strerror(errno));
675 if ((release_mode || exit_mode) && (
no_pid_file == ISC_FALSE)) {
682 e = fscanf(pidfd,
"%ld\n", &temp);
683 oldpid = (pid_t)temp;
685 if (e != 0 && e != EOF && oldpid) {
686 if (kill(oldpid, SIGTERM) == 0) {
687 log_info(
"Killed old client process");
697 }
else if (errno == ESRCH) {
711 char *new_path_dhclient_pid;
730 int n_len = strlen(
ip->name);
732 new_path_dhclient_pid = (
char*) malloc(pfx + n_len + 6);
734 sprintf(new_path_dhclient_pid + pfx,
"-%s.pid",
ip->name);
736 if ((pidfd = fopen(new_path_dhclient_pid,
"re")) != NULL) {
737 e = fscanf(pidfd,
"%ld\n", &temp);
738 oldpid = (pid_t)temp;
740 if (e != 0 && e != EOF) {
742 if (kill(oldpid, SIGTERM) == 0)
750 free(new_path_dhclient_pid);
759 char procfn[256] =
"";
762 if ((fscanf(pidfp,
"%ld", &temp)==1) && ((dhcpid=(pid_t)temp) > 0)) {
763 snprintf(procfn,256,
"/proc/%u",dhcpid);
764 dhc_running = (access(procfn, F_OK) == 0);
771 log_fatal(
"dhclient(%u) is already running - exiting. ", dhcpid);
796 memcpy(&
giaddr, he->h_addr_list[0],
805 gettimeofday(&
cur_tv, NULL);
812 he = gethostbyname(server);
838 usage(
"Stateless commnad: %s incompatibile with " 839 "other commands",
"-S");
841 #if defined(DHCPv6) && defined(DHCP4o6) 850 if ((dhcp_client_identifier_arg != NULL) && (*dhcp_client_identifier_arg !=
'\0')) {
851 arg_conf_len =
asprintf(&arg_conf,
"send dhcp-client-identifier \"%s\";", dhcp_client_identifier_arg);
853 if ((arg_conf == 0) || (arg_conf_len <= 0))
854 log_fatal(
"Unable to send -C option dhcp-client-identifier");
857 if ((dhcp_host_name_arg != NULL) && (*dhcp_host_name_arg !=
'\0')) {
859 arg_conf_len =
asprintf(&arg_conf,
"send host-name \"%s\";", dhcp_host_name_arg);
861 if ((arg_conf == 0) || (arg_conf_len <= 0))
862 log_fatal(
"Unable to send -H option host-name");
864 char *last_arg_conf = arg_conf;
866 arg_conf_len =
asprintf(&arg_conf,
"%s\nsend host-name \"%s\";", last_arg_conf, dhcp_host_name_arg);
868 if ((arg_conf == 0) || (arg_conf_len <= 0))
869 log_fatal(
"Unable to send -H option host-name");
875 if ((dhcp_fqdn_arg != NULL) && (*dhcp_fqdn_arg !=
'\0')) {
877 arg_conf_len =
asprintf(&arg_conf,
"send fqdn.fqdn \"%s\";", dhcp_fqdn_arg);
879 if ((arg_conf == 0) || (arg_conf_len <= 0))
880 log_fatal(
"Unable to send -F option fqdn.fqdn");
882 char *last_arg_conf = arg_conf;
884 arg_conf_len =
asprintf(&arg_conf,
"%s\nsend fqdn.fqdn \"%s\";", last_arg_conf, dhcp_fqdn_arg);
886 if ((arg_conf == 0) || (arg_conf_len <= 0))
887 log_fatal(
"Unable to send -F option fqdn.fqdn");
895 arg_conf_len =
asprintf(&arg_conf,
"timeout %d;", timeout_arg);
897 if ((arg_conf == 0) || (arg_conf_len <= 0))
898 log_fatal(
"Unable to process --timeout timeout argument");
900 char *last_arg_conf = arg_conf;
902 arg_conf_len =
asprintf(&arg_conf,
"%s\ntimeout %d;", last_arg_conf, timeout_arg);
904 if ((arg_conf == 0) || (arg_conf_len == 0))
905 log_fatal(
"Unable to process --timeout timeout argument");
911 if ((dhcp_vendor_class_identifier_arg != NULL) && (*dhcp_vendor_class_identifier_arg !=
'\0')) {
913 arg_conf_len =
asprintf(&arg_conf,
"send vendor-class-identifier \"%s\";", dhcp_vendor_class_identifier_arg);
915 if ((arg_conf == 0) || (arg_conf_len <= 0))
916 log_fatal(
"Unable to send -V option vendor-class-identifier");
918 char *last_arg_conf = arg_conf;
920 arg_conf_len =
asprintf(&arg_conf,
"%s\nsend vendor-class-identifier \"%s\";", last_arg_conf, dhcp_vendor_class_identifier_arg);
922 if ((arg_conf == 0) || (arg_conf_len <= 0))
923 log_fatal(
"Unable to send -V option vendor-class-identifier");
929 if (dhclient_request_options != NULL) {
931 arg_conf_len =
asprintf(&arg_conf,
"request %s;", dhclient_request_options);
933 if ((arg_conf == 0) || (arg_conf_len <= 0))
934 log_fatal(
"Unable to parse --request-options <request options list> argument");
936 char *last_arg_conf = arg_conf;
938 arg_conf_len =
asprintf(&arg_conf,
"%s\nrequest %s;", last_arg_conf, dhclient_request_options);
940 if ((arg_conf == 0) || (arg_conf_len <= 0))
941 log_fatal(
"Unable to parse --request-options <request options list> argument");
948 if (arg_conf_len == 0)
949 if ((arg_conf_len = strlen(arg_conf)) == 0)
951 log_fatal(
"Unable to process -C/-H/-F/--timeout/-V/--request-options configuration arguments");
956 const char *val = NULL;
959 status =
new_parse(&cfile, -1, arg_conf, arg_conf_len,
"extra dhclient -C/-H/-F/--timeout/-V/--request-options configuration arguments", 0);
962 log_fatal(
"Cannot parse -C/-H/-F/--timeout/-V/--request-options configuration arguments !");
974 log_fatal(
"Cannot parse -C/-H/-F/--timeout/-V/--request-options configuration arguments !");
982 if (
ip->client->config->timeout == 60)
983 ip->client->config->timeout = timeout_arg;
1031 log_info(
"No broadcast interfaces found - exiting.");
1034 }
else if (!release_mode && !exit_mode) {
1051 if (
ip->client->alias != NULL)
1068 unsigned backup_seed = 0;
1071 if (
ip -> hw_address.hlen <=
sizeof seed )
1074 &
ip -> hw_address.hbuf [
ip -> hw_address.hlen -
1075 sizeof seed],
sizeof seed);
1097 if (
ip -> hw_address.hlen <=
sizeof seed )
1100 &
ip->hw_address.hbuf[
ip->hw_address.hlen -
1101 sizeof seed],
sizeof seed);
1105 if ( seed_flag == 0 ) {
1106 if ( backup_seed != 0 ) {
1108 log_info (
"xid: rand init seed (0x%x) built using all" 1109 " available interfaces",seed);
1112 seed =
cur_time^((unsigned) gethostid()) ;
1113 log_info (
"xid: warning: no netdev with useable HWADDR found" 1114 " for seed's uniqueness enforcement");
1115 log_info (
"xid: rand init seed (0x%x) built using gethostid",
1120 srandom(seed + ((
unsigned)(
cur_tv.tv_usec * 1000000)) + (
unsigned)getpid());
1123 srandom(seed + ((
unsigned)(
cur_tv.tv_usec * 1000000)) + (
unsigned)getpid());
1129 setup_ib_interface(
ip);
1148 #if defined(DHCPv6) && defined(DHCP4o6) 1150 dhcp4o6_setup(dhcp4o6_port);
1157 for (client =
ip->client ; client != NULL ;
1158 client = client->
next) {
1162 }
else if (exit_mode) {
1182 for (client =
ip->client ; client ;
1183 client = client->
next) {
1200 tv.tv_usec = random()
1235 if (result != ISC_R_SUCCESS)
1236 log_fatal(
"Can't allocate new generic object: %s\n",
1237 isc_result_totext(result));
1242 if (result != ISC_R_SUCCESS)
1243 log_fatal(
"Can't start OMAPI protocol: %s",
1244 isc_result_totext (result));
1253 #if defined(DEBUG_MEMORY_LEAKAGE) || defined(DEBUG_MALLOC_POOL) || \ 1254 defined(DEBUG_MEMORY_LEAKAGE_ON_EXIT) 1255 dmalloc_cutoff_generation = dmalloc_generation;
1256 dmalloc_longterm = dmalloc_outstanding;
1257 dmalloc_outstanding = 0;
1260 #if defined(ENABLE_GENTLE_SHUTDOWN) 1297 isc_result_t result;
1306 usage(
"No interfaces available for stateless command: %s",
"-S");
1349 dhcp4o6_setup(port);
1369 if (result != ISC_R_SUCCESS)
1370 log_fatal(
"Can't allocate new generic object: %s\n",
1371 isc_result_totext(result));
1376 if (result != ISC_R_SUCCESS)
1377 log_fatal(
"Can't start OMAPI protocol: %s",
1378 isc_result_totext(result));
1384 #if defined(DEBUG_MEMORY_LEAKAGE) || defined(DEBUG_MALLOC_POOL) || \ 1385 defined(DEBUG_MEMORY_LEAKAGE_ON_EXIT) 1386 dmalloc_cutoff_generation = dmalloc_generation;
1387 dmalloc_longterm = dmalloc_outstanding;
1388 dmalloc_outstanding = 0;
1410 const char *s,
const char *
file,
int line)
1445 ip->client->config->bootp_broadcast_always = 1;
1451 for (g =
ip->client->config->on_transmission; g != NULL; g = g->
next) {
1454 "dhcp-client-identifier") == 0)) {
1497 #if defined(DHCPv6) && defined(DHCP4o6) 1499 if (dhcp4o6_state < 0)
1510 client ->
active -> is_bootp ||
1524 client ->
xid = random ();
1557 client -> xid = client ->
packet.xid;
1560 client -> first_sending =
cur_time;
1561 client -> interval = client -> config -> initial_interval;
1604 for (lp = client -> offered_leases; lp; lp =
next) {
1613 picked ->
next = NULL;
1618 client -> offered_leases = NULL;
1625 client -> state =
S_INIT;
1632 client ->
new = picked;
1650 client -> first_sending =
cur_time;
1651 client -> interval = client -> config -> initial_interval;
1655 client -> xid = client ->
packet.xid;
1678 for (client =
ip -> client; client; client = client -> next) {
1679 if (client -> xid ==
packet -> raw -> xid)
1683 (
packet -> interface -> hw_address.hlen - 1 !=
1684 packet -> raw -> hlen) ||
1685 (memcmp (&
packet -> interface -> hw_address.hbuf [1],
1688 log_debug (
"DHCPACK in wrong transaction.");
1707 log_info (
"packet_to_lease failed.");
1711 client ->
new =
lease;
1719 memset (&ds, 0,
sizeof ds);
1722 packet -> options, client ->
new -> options,
1727 client ->
new -> expiry = 0;
1730 client ->
new -> expiry = 0;
1735 log_error (
"no expiry time on offered lease.");
1741 tv.tv_sec =
cur_tv.tv_sec;
1742 tv.tv_usec =
cur_tv.tv_usec + 500000;
1744 if (tv.tv_usec >= 1000000) {
1746 tv.tv_usec -= 1000000;
1765 packet -> options, client ->
new -> options,
1770 client ->
new -> renewal = 0;
1773 client ->
new -> renewal = 0;
1776 if (!client ->
new -> renewal)
1777 client ->
new -> renewal = client ->
new -> expiry / 2 + 1;
1779 if (client ->
new -> renewal <= 0)
1780 client ->
new -> renewal =
TIME_MAX;
1785 (((random() % client->
new->
renewal) + 3) / 4);
1792 packet -> options, client ->
new -> options,
1797 client ->
new -> rebind = 0;
1800 client ->
new -> rebind = 0;
1802 if (client ->
new -> rebind <= 0) {
1803 if (client ->
new -> expiry <=
TIME_MAX / 7)
1804 client ->
new -> rebind =
1805 client ->
new -> expiry * 7 / 8;
1807 client ->
new -> rebind =
1808 client ->
new -> expiry / 8 * 7;
1813 if (client ->
new -> renewal > client ->
new -> rebind) {
1814 if (client ->
new -> rebind <=
TIME_MAX / 3)
1815 client ->
new -> renewal =
1816 client ->
new -> rebind * 3 / 4;
1818 client ->
new -> renewal =
1819 client ->
new -> rebind / 4 * 3;
1822 client ->
new -> expiry +=
cur_time;
1824 if (client ->
new -> expiry <
cur_time)
1825 client ->
new -> expiry =
TIME_MAX;
1826 client ->
new -> renewal +=
cur_time;
1827 if (client ->
new -> renewal <
cur_time)
1828 client ->
new -> renewal =
TIME_MAX;
1829 client ->
new -> rebind +=
cur_time;
1830 if (client ->
new -> rebind <
cur_time)
1831 client ->
new -> rebind =
TIME_MAX;
1867 log_info(
"Unable to obtain a lease on first " 1868 "try (declined). Exiting.");
1871 #if defined (CALL_SCRIPT_ON_ONETRY_FAIL) 1898 random() % 1000000 :
cur_tv.tv_usec;
1901 log_info(
"bound to %s -- renewal in %ld seconds.",
1907 #if defined (NSUPDATE) 1929 client -> xid = client ->
packet.xid;
1931 memset (&ds, 0,
sizeof ds);
1937 client -> active -> options,
1940 memcpy (client -> destination.iabuf, ds.
data, 4);
1941 client -> destination.len = 4;
1949 client -> first_sending =
cur_time;
1950 client -> interval = client -> config -> initial_interval;
2018 for (ap =
packet -> interface -> client -> config -> reject_list;
2019 ap; ap = ap ->
next) {
2028 log_info(
"BOOTREPLY from %s rejected by rule %s " 2043 void (*handler) (
struct packet *);
2071 ap; ap = ap -> next) {
2080 log_info(
"%s from %s rejected by rule %s mask %s.",
2094 char addrbuf[
sizeof(
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")];
2102 ap ; ap = ap->
next) {
2105 log_info(
"%s from %s rejected by rule %s",
2118 log_info(
"RCV: %s message on %s from %s.",
2122 forw_dhcpv4_response(
packet);
2132 log_info(
"RCV: %s message on %s from %s.",
2143 client = client->
next) {
2152 log_info(
"Packet received, but nothing done with it.");
2168 static void forw_dhcpv4_response(
struct packet *
packet)
2178 if (dhcp4o6_state == -1) {
2179 log_info(
"forw_dhcpv4_response: not ready.");
2184 log_error(
"forw_dhcpv4_response: bad address");
2193 log_info(
"DHCPv4-response from %s missing " 2194 "DHCPv4 Message option.",
2199 memset(&enc_opt_data, 0,
sizeof(enc_opt_data));
2202 log_error(
"forw_dhcpv4_response: error evaluating " 2210 "no memory for encapsulated packet.");
2218 memset(&ds, 0,
sizeof(ds));
2220 log_error(
"forw_dhcpv4_response: no memory buffer.");
2224 ds.data = ds.buffer->data;
2225 ds.len = enc_opt_data.len + 16;
2226 memcpy(ds.buffer->data, enc_opt_data.data, enc_opt_data.len);
2227 memcpy(ds.buffer->data + enc_opt_data.len,
2234 cc = send(dhcp4o6_fd, ds.data, ds.len, 0);
2236 log_error(
"forw_dhcpv4_response: send(): %m");
2250 static void recv_dhcpv4_response(
struct data_string *raw)
2256 log_error(
"recv_dhcpv4_response: no interfaces.");
2261 memcpy(from.iabuf, raw->
data + (raw->
len - 16), 16);
2268 log_error(
"recv_dhcpv4_response: no memory for packet.");
2280 log_error(
"recv_dhcpv4_response: no memory for options.");
2301 memset(&dp, 0,
sizeof dp);
2335 const char *
name =
packet -> packet_type ?
"DHCPOFFER" :
"BOOTREPLY";
2344 for (client =
ip -> client; client; client = client -> next)
2345 if (client -> xid ==
packet -> raw -> xid)
2352 (
packet -> interface -> hw_address.hlen - 1 !=
2353 packet -> raw -> hlen) ||
2354 (memcmp (&
packet -> interface -> hw_address.hbuf [1],
2357 log_debug (
"%s in wrong transaction.", name);
2362 sprintf (obuf,
"%s from %s", name,
piaddr (
packet -> client_addr));
2370 for (i = 0 ; req[i] != NULL ; i++) {
2377 option_code_hash_lookup(&
option,
2382 log_info(
"%s: no %s option.", obuf,
2385 log_info(
"%s: no unknown-%u option.",
2397 if (
lease -> address.len ==
sizeof packet -> raw -> yiaddr &&
2398 !memcmp (
lease -> address.iabuf,
2399 &
packet -> raw -> yiaddr,
lease -> address.len)) {
2407 log_info (
"%s: packet_to_lease failed.", obuf);
2413 if (!
packet -> options_valid || !
packet -> packet_type)
2414 lease -> is_bootp = 1;
2417 lease -> medium = client -> medium;
2420 stop_selecting = (client -> first_sending +
2421 client -> config -> select_interval);
2425 if (
lease -> address.len == client -> requested_address.len &&
2426 !memcmp (
lease -> address.iabuf,
2427 client -> requested_address.iabuf,
2428 client -> requested_address.len)) {
2429 lease -> next = client -> offered_leases;
2430 client -> offered_leases =
lease;
2434 if (!client -> offered_leases)
2435 client -> offered_leases =
lease;
2437 for (lp = client -> offered_leases; lp ->
next;
2447 if (stop_selecting <=
cur_tv.tv_sec)
2450 tv.tv_sec = stop_selecting;
2451 tv.tv_usec =
cur_tv.tv_usec;
2474 log_error(
"packet_to_lease: no memory to record lease.\n");
2485 lease->address.len);
2489 lease->next_srv_addr.len);
2491 memset(&data, 0,
sizeof(data));
2493 if (client -> config -> vendor_space_name) {
2499 client -> config -> vendor_space_name &&
2501 (
struct lease *)0, client,
2505 if (!option_code_hash_lookup(&
option,
2509 "option (%s:%d).",
MDL);
2513 client -> config -> vendor_space_name
2539 if (!(i & 2) &&
packet -> raw -> sname [0]) {
2543 if (!
packet -> raw -> sname [len])
2547 log_error (
"dhcpoffer: no memory for server name.\n");
2552 packet -> raw -> sname, len);
2566 log_error (
"dhcpoffer: no memory for filename.\n");
2591 for (client =
ip -> client; client; client = client ->
next)
2599 packet -> raw -> hlen) ||
2603 log_debug (
"DHCPNAK in wrong transaction.");
2622 log_info (
"DHCPNAK with no active lease.\n");
2655 client -> state =
S_INIT;
2674 interval =
cur_time - client -> first_sending;
2678 if (interval > client -> config ->
timeout) {
2686 if (!client -> offered_leases &&
2687 client -> config -> media) {
2690 if (client -> medium) {
2691 client -> medium = client -> medium -> next;
2694 if (!client -> medium) {
2696 log_fatal (
"No valid media types for %s!",
2697 client -> interface -> name);
2699 client -> config -> media;
2703 log_info (
"Trying medium \"%s\" %d",
2704 client -> medium ->
string, increase);
2732 if (
cur_time + client -> interval >
2733 client -> first_sending + client -> config ->
timeout)
2734 client -> interval =
2735 (client -> first_sending +
2739 if (interval < 65536)
2740 client ->
packet.secs = htons (interval);
2742 client ->
packet.secs = htons (65535);
2743 client -> secs = client ->
packet.secs;
2745 #if defined(DHCPv6) && defined(DHCP4o6) 2747 log_info (
"DHCPDISCOVER interval %ld",
2748 (
long)(client -> interval));
2751 log_info (
"DHCPDISCOVER on %s to %s port %d interval %ld (xid=0x%x)",
2752 client -> name ? client -> name : client -> interface -> name,
2754 ntohs (
sockaddr_broadcast.sin_port), (
long)(client -> interval), ntohl(client -> xid));
2757 #if defined(DHCPv6) && defined(DHCP4o6) 2759 result = send_dhcpv4_query(client, 1);
2766 #if defined(DHCPv6) && defined(DHCP4o6) 2768 log_error(
"%s:%d: Failed to send %d byte long packet.",
2772 log_error(
"%s:%d: Failed to send %d byte long packet over %s " 2784 tv.tv_usec = client->
interval > 1 ? random() % 1000000 :
cur_tv.tv_usec;
2801 loop = lp = client -> active;
2803 log_info (
"No DHCPOFFERS received.");
2807 if (!client -> active && client -> leases)
2811 while (client -> active) {
2812 if (client -> active -> expiry >
cur_time) {
2813 log_info (
"Trying recorded lease %s",
2814 piaddr (client -> active -> address));
2818 client -> active -> medium);
2821 if (client -> alias)
2829 if (cur_time < client -> active -> renewal) {
2831 log_info (
"bound: renewal in %ld %s.",
2832 (
long)(client -> active -> renewal -
2837 random() % 1000000 :
2842 log_info (
"bound: immediate renewal.");
2852 if (!client -> leases) {
2853 client -> leases = client -> active;
2861 for (lp = client -> leases; lp ->
next; lp = lp ->
next)
2863 lp ->
next = client -> active;
2867 client -> active = client -> leases;
2868 client -> leases = client -> leases ->
next;
2873 if (client -> active == loop)
2876 loop = client -> active;
2884 log_info (
"Unable to obtain a lease on first try.%s",
2888 #if defined (CALL_SCRIPT_ON_ONETRY_FAIL) 2896 log_info (
"No working leases in persistent database - sleeping.");
2898 if (client -> alias)
2901 client -> state =
S_INIT;
2904 tv.tv_usec = ((tv.tv_sec -
cur_tv.tv_sec) > 1) ?
2905 random() % 1000000 :
cur_tv.tv_usec;
2917 struct sockaddr_in destination;
2918 struct in_addr from;
2922 interval =
cur_time - client -> first_sending;
2936 interval > client -> config -> reboot_timeout) {
2938 client -> state =
S_INIT;
2947 !client -> medium &&
2948 client -> active -> medium ) {
2949 script_init(client,
"MEDIUM", client -> active -> medium);
2956 client -> medium = client -> active -> medium;
2962 cur_time > client -> active -> expiry) {
2967 if (client -> alias)
2975 if (client -> alias)
2980 client -> state =
S_INIT;
2986 if (!client -> interval)
2987 client -> interval = client -> config -> initial_interval;
2989 client -> interval += ((random () >> 2) %
2990 (2 * client -> interval));
2994 if (client -> interval >
2995 client -> config -> backoff_cutoff)
2996 client -> interval =
2997 ((client -> config -> backoff_cutoff / 2)
2998 + ((random () >> 2) %
2999 client -> config -> backoff_cutoff));
3004 cur_time + client -> interval > client -> active -> expiry)
3005 client -> interval =
3006 client -> active -> expiry -
cur_time + 1;
3012 cur_time > client -> active -> rebind)
3015 memcpy (&destination.sin_addr.s_addr,
3016 client -> destination.iabuf,
3017 sizeof destination.sin_addr.s_addr);
3019 destination.sin_family = AF_INET;
3021 destination.sin_len =
sizeof destination;
3026 memcpy (&from, client -> active -> address.iabuf,
3029 from.s_addr = INADDR_ANY;
3033 client ->
packet.secs = client -> secs;
3035 if (interval < 65536)
3036 client ->
packet.secs = htons (interval);
3038 client ->
packet.secs = htons (65535);
3041 #if defined(DHCPv6) && defined(DHCP4o6) 3046 log_info (
"DHCPREQUEST on %s to %s port %d (xid=0x%x)",
3047 client -> name ? client -> name : client -> interface -> name,
3048 inet_ntoa (destination.sin_addr),
3049 ntohs (destination.sin_port), ntohl(client -> xid));
3051 #if defined(DHCPv6) && defined(DHCP4o6) 3054 if (destination.sin_addr.s_addr == INADDR_BROADCAST)
3056 result = send_dhcpv4_query(client, broadcast);
3058 log_error(
"%s:%d: Failed to send %d byte long packet.",
3063 if (destination.sin_addr.s_addr != INADDR_BROADCAST &&
3065 #if defined(SO_BINDTODEVICE) 3069 log_error(
"%s:%d: Failed to bind fallback interface" 3077 log_error(
"%s:%d: Failed to send %d byte long packet " 3078 "over %s interface.",
MDL,
3082 #if defined(SO_BINDTODEVICE) 3084 SO_BINDTODEVICE, NULL, 0) < 0) {
3085 log_fatal(
"%s:%d: Failed to unbind fallback interface:" 3096 log_error(
"%s:%d: Failed to send %d byte long packet" 3097 " over %s interface.",
MDL,
3104 tv.tv_usec = ((tv.tv_sec -
cur_tv.tv_sec) > 1) ?
3105 random() % 1000000 :
cur_tv.tv_usec;
3116 #if defined(DHCPv6) && defined(DHCP4o6) 3121 log_info (
"DHCPDECLINE on %s to %s port %d (xid=0x%x)",
3127 #if defined(DHCPv6) && defined(DHCP4o6) 3129 result = send_dhcpv4_query(client, 1);
3136 #if defined(DHCPv6) && defined(DHCP4o6) 3138 log_error(
"%s:%d: Failed to send %d byte long packet.",
3142 log_error(
"%s:%d: Failed to send %d byte long packet over %s" 3154 struct sockaddr_in destination;
3155 struct in_addr from;
3157 memcpy (&from, client -> active -> address.iabuf,
3159 memcpy (&destination.sin_addr.s_addr,
3160 client -> destination.iabuf,
3161 sizeof destination.sin_addr.s_addr);
3163 destination.sin_family = AF_INET;
3165 destination.sin_len =
sizeof destination;
3170 client -> active -> expiry =
3171 client -> active -> renewal =
3172 client -> active -> rebind =
cur_time;
3174 log_error (
"Can't release lease: lease write failed.");
3178 #if defined(DHCPv6) && defined(DHCP4o6) 3183 log_info (
"DHCPRELEASE on %s to %s port %d (xid=0x%x)",
3184 client -> name ? client -> name : client -> interface -> name,
3185 inet_ntoa (destination.sin_addr),
3186 ntohs (destination.sin_port), ntohl(client -> xid));
3188 #if defined(DHCPv6) && defined(DHCP4o6) 3191 if (destination.sin_addr.s_addr == INADDR_BROADCAST)
3193 result = send_dhcpv4_query(client, broadcast);
3195 log_error(
"%s:%d: Failed to send %d byte long packet.",
3201 #if defined(SO_BINDTODEVICE) 3205 log_error(
"%s:%d: Failed to bind fallback interface" 3213 log_error(
"%s:%d: Failed to send %d byte long packet" 3214 " over %s interface.",
MDL,
3218 #if defined(SO_BINDTODEVICE) 3220 SO_BINDTODEVICE, NULL, 0) < 0) {
3221 log_fatal(
"%s:%d: Failed to unbind fallback interface:" 3231 log_error (
"%s:%d: Failed to send %d byte long packet" 3232 " over %s interface.",
MDL,
3240 #if defined(DHCPv6) && defined(DHCP4o6) 3252 static int send_dhcpv4_query(
struct client_state *client,
int broadcast) {
3257 if (dhcp4o6_state <= 0) {
3258 log_info(
"send_dhcpv4_query: not ready.");
3268 memset(&ds, 0,
sizeof(ds));
3270 log_error(
"Unable to allocate memory for DHCPv4-query.");
3273 ds.data = ds.buffer->data;
3298 cc = send(dhcp4o6_fd, ds.data, ds.len, 0);
3300 log_error(
"send_dhcpv4_query: send(): %m");
3313 static void forw_dhcpv4_query(
struct data_string *raw) {
3319 struct sockaddr_in6 sin6;
3320 int i, send_ret, attempt, success;
3322 attempt = success = 0;
3323 memset(&sin6, 0,
sizeof(sin6));
3324 sin6.sin6_family = AF_INET6;
3327 sin6.sin6_len =
sizeof(sin6);
3329 memset(&addrs, 0,
sizeof(addrs));
3331 for (client =
ip->client; client != NULL;
3332 client = client->
next) {
3345 lease->options, NULL,
3347 ((addrs.len %
sizeof(sin6.sin6_addr)) != 0)) {
3351 if (addrs.len == 0) {
3359 if (send_ret == raw->
len)
3363 for (i = 0; i < addrs.len;
3364 i +=
sizeof(sin6.sin6_addr)) {
3365 memcpy(&sin6.sin6_addr, addrs.data + i,
3366 sizeof(sin6.sin6_addr));
3370 if (send_ret == raw->
len)
3377 log_info(
"forw_dhcpv4_query: sent(%d): %d/%d",
3378 raw->
len, success, attempt);
3394 struct buffer *bp = NULL;
3417 log_error (
"can't make requested address cache.");
3443 for (i = 0 ; prl[i] != NULL ; i++)
3448 log_error(
"can't make parameter list buffer.");
3453 for (i = 0 ; prl[i] != NULL ; i++)
3457 if (!(option_code_hash_lookup(&
option,
3482 memset(&client_identifier, 0,
sizeof(client_identifier));
3485 client_identifier.
len,
MDL))
3486 log_fatal(
"no memory for default DUID!");
3504 memcpy(&client_identifier.
buffer->
data + 5 - hw_len,
3509 memcpy(&client_identifier.
buffer->
data+(1+4),
3516 (u_int8_t *)client_identifier.
data,
3517 client_identifier.
len,
3519 log_error (
"can't make requested client id cache..");
3543 memset (&client ->
packet, 0,
sizeof (client ->
packet));
3548 client -> config -> requested_options,
3552 client -> packet_length =
3554 (
struct lease *)0, client,
3563 client -> config -> vendor_space_name);
3570 client ->
packet.htype = client ->
interface -> hw_address.hbuf [0];
3572 client ->
packet.hlen = client ->
interface -> hw_address.hlen - 1;
3573 client ->
packet.hops = 0;
3574 client ->
packet.xid = random ();
3575 client ->
packet.secs = 0;
3579 client ->
packet.flags = 0;
3583 memset (&(client ->
packet.ciaddr),
3584 0,
sizeof client ->
packet.ciaddr);
3585 memset (&(client ->
packet.yiaddr),
3586 0,
sizeof client ->
packet.yiaddr);
3587 memset (&(client ->
packet.siaddr),
3588 0,
sizeof client ->
packet.siaddr);
3590 if (client -> interface -> hw_address.hlen > 0)
3591 memcpy (client ->
packet.chaddr,
3592 &client -> interface -> hw_address.hbuf [1],
3593 (
unsigned)(client -> interface -> hw_address.hlen - 1));
3596 dump_raw ((
unsigned char *)&client ->
packet, client -> packet_length);
3608 memset (&client ->
packet, 0,
sizeof (client ->
packet));
3616 if (client -> sent_options)
3623 : (
struct iaddr *)0),
3624 client -> config -> requested_options,
3625 &client -> sent_options);
3628 client -> packet_length =
3630 (
struct lease *)0, client,
3633 client -> sent_options,
3639 client -> config -> vendor_space_name);
3645 client ->
packet.htype = client ->
interface -> hw_address.hbuf [0];
3647 client ->
packet.hlen = client ->
interface -> hw_address.hlen - 1;
3648 client ->
packet.hops = 0;
3649 client ->
packet.xid = client -> xid;
3650 client ->
packet.secs = 0;
3654 if (client -> state ==
S_BOUND ||
3657 memcpy (&client ->
packet.ciaddr,
3658 lease -> address.iabuf,
lease -> address.len);
3659 client ->
packet.flags = 0;
3661 memset (&client ->
packet.ciaddr, 0,
3662 sizeof client ->
packet.ciaddr);
3664 client ->config->bootp_broadcast_always)) &&
3666 client ->
packet.flags = 0;
3671 memset (&client ->
packet.yiaddr, 0,
3672 sizeof client ->
packet.yiaddr);
3673 memset (&client ->
packet.siaddr, 0,
3674 sizeof client ->
packet.siaddr);
3675 if (client -> state !=
S_BOUND &&
3679 memset (&client ->
packet.giaddr, 0,
3680 sizeof client ->
packet.giaddr);
3681 if (client -> interface -> hw_address.hlen > 0)
3682 memcpy (client ->
packet.chaddr,
3683 &client -> interface -> hw_address.hbuf [1],
3684 (
unsigned)(client -> interface -> hw_address.hlen - 1));
3687 dump_raw ((
unsigned char *)&client ->
packet, client -> packet_length);
3707 memset (&client ->
packet, 0,
sizeof (client ->
packet));
3708 client -> packet_length =
3710 (
struct lease *)0, client, 0,
3713 client -> config -> vendor_space_name);
3722 client ->
packet.htype = client ->
interface -> hw_address.hbuf [0];
3724 client ->
packet.hlen = client ->
interface -> hw_address.hlen - 1;
3725 client ->
packet.hops = 0;
3726 client ->
packet.xid = client -> xid;
3727 client ->
packet.secs = 0;
3730 client ->
packet.flags = 0;
3735 memset (&client ->
packet.ciaddr, 0,
3736 sizeof client ->
packet.ciaddr);
3737 memset (&client ->
packet.yiaddr, 0,
3738 sizeof client ->
packet.yiaddr);
3739 memset (&client ->
packet.siaddr, 0,
3740 sizeof client ->
packet.siaddr);
3742 memcpy (client ->
packet.chaddr,
3743 &client -> interface -> hw_address.hbuf [1],
3744 client -> interface -> hw_address.hlen);
3747 dump_raw ((
unsigned char *)&client ->
packet, client -> packet_length);
3760 memset (&client ->
packet, 0,
sizeof (client ->
packet));
3767 client -> packet_length =
3769 (
struct lease *)0, client,
3778 client -> config -> vendor_space_name);
3785 client ->
packet.htype = client ->
interface -> hw_address.hbuf [0];
3787 client ->
packet.hlen = client ->
interface -> hw_address.hlen - 1;
3788 client ->
packet.hops = 0;
3789 client ->
packet.xid = random ();
3790 client ->
packet.secs = 0;
3791 client ->
packet.flags = 0;
3792 memcpy (&client ->
packet.ciaddr,
3793 lease -> address.iabuf,
lease -> address.len);
3794 memset (&client ->
packet.yiaddr, 0,
3795 sizeof client ->
packet.yiaddr);
3796 memset (&client ->
packet.siaddr, 0,
3797 sizeof client ->
packet.siaddr);
3799 memcpy (client ->
packet.chaddr,
3800 &client -> interface -> hw_address.hbuf [1],
3801 client -> interface -> hw_address.hlen);
3804 dump_raw ((
unsigned char *)&client ->
packet, client -> packet_length);
3843 for (client =
ip -> client; client; client = client ->
next) {
3844 for (lp = client -> leases; lp; lp = lp ->
next) {
3847 if (client -> active)
3849 client -> active, 1, 0);
3864 for (client =
ip -> client; client; client = client ->
next) {
3865 for (lp = client -> leases; lp; lp = lp ->
next) {
3868 if (client -> active)
3870 client -> active, 1, 0);
3892 const char *name, *dot;
3894 char *preamble = stuff;
3896 memset (&ds, 0,
sizeof ds);
3906 in_options, cfg_options, scope, oc,
MDL)) {
3908 fprintf(
leaseFile,
"%soption %s%s%s", preamble,
3929 const char *preamble)
3942 if (c >=
'0' && c <=
'9')
3945 if (c >=
'a' && c <=
'f')
3946 return c -
'a' + 10;
3948 if (c >=
'A' && c <=
'F')
3949 return c -
'A' + 10;
3956 const char *id_fname =
"/etc/machine-id";
3959 FILE *
file = fopen( id_fname ,
"r");
3962 return ISC_R_IOERROR;
3964 nread = fread(
id, 1,
sizeof id,
file);
3968 log_debug(
"Not enough data in %s", id_fname);
3969 return ISC_R_IOERROR;
3972 for (j = 0; j < 16; j++) {
3978 if (a < 0 || b < 0) {
3979 log_debug(
"Wrong data in %s", id_fname);
3980 return ISC_R_IOERROR;
3982 uuid[j] = a << 4 | b;
3986 uuid[6] = (uuid[6] & 0x0F) | 0x40;
3988 uuid[8] = (uuid[8] & 0x3F) | 0x80;
3990 return ISC_R_SUCCESS;
4023 log_debug(
"Cannot form default DUID from interface %s.",
ip->name);
4027 return ISC_R_UNEXPECTED;
4030 if ((
ip->hw_address.hlen == 0) ||
4031 (
ip->hw_address.hlen >
sizeof(
ip->hw_address.hbuf)))
4032 log_fatal(
"Impossible hardware address length at %s:%d.",
MDL);
4042 len = 2 +
sizeof (uuid);
4051 len = 4 + (
ip->hw_address.hlen - 1);
4056 log_fatal(
"no memory for default DUID!");
4062 memcpy(duid->
buffer->
data + 2, uuid,
sizeof(uuid));
4069 memcpy(duid->
buffer->
data + 8,
ip->hw_address.hbuf + 1,
4070 ip->hw_address.hlen - 1);
4074 memcpy(duid->
buffer->
data + 4,
ip->hw_address.hbuf + 1,
4075 ip->hw_address.hlen - 1);
4082 log_info(
"form_duid: Couldn't allocate memory to log duid!");
4088 return ISC_R_SUCCESS;
4098 if ((duid == NULL) || (duid->
len <= 2))
4105 return ISC_R_IOERROR;
4113 return ISC_R_NOMEMORY;
4115 stat = fprintf(
leaseFile,
"default-duid %s;\n", str);
4118 return ISC_R_IOERROR;
4121 return ISC_R_IOERROR;
4123 return ISC_R_SUCCESS;
4129 int rewrite,
int sync)
4140 return ISC_R_SUCCESS;
4143 if (client == NULL ||
lease == NULL)
4150 return ISC_R_IOERROR;
4154 stat = fprintf(
leaseFile,
"lease6 {\n");
4156 return ISC_R_IOERROR;
4158 stat = fprintf(
leaseFile,
" interface \"%s\";\n",
4161 return ISC_R_IOERROR;
4163 for (ia =
lease->bindings ; ia != NULL ; ia = ia->
next) {
4184 (
const unsigned char *) &ia->
iaid, 4,
4189 return ISC_R_IOERROR;
4200 stat = fprintf(
leaseFile,
" %s %s {\n", ianame,
4206 return ISC_R_IOERROR;
4209 stat = fprintf(
leaseFile,
" starts %d;\n" 4214 stat = fprintf(
leaseFile,
" starts %d;\n",
4217 return ISC_R_IOERROR;
4219 for (addr = ia->
addrs ; addr != NULL ; addr = addr->
next) {
4226 " iaprefix %s/%d {\n",
4230 return ISC_R_IOERROR;
4232 stat = fprintf(
leaseFile,
" starts %d;\n" 4233 " preferred-life %u;\n" 4238 return ISC_R_IOERROR;
4241 write_options(client, addr->
options,
" ");
4245 return ISC_R_IOERROR;
4249 write_options(client, ia->
options,
" ");
4253 return ISC_R_IOERROR;
4256 if (
lease->released) {
4257 stat = fprintf(
leaseFile,
" released;\n");
4259 return ISC_R_IOERROR;
4262 if (
lease->options != NULL)
4263 write_options(client,
lease->options,
" ");
4267 return ISC_R_IOERROR;
4270 return ISC_R_IOERROR;
4274 log_error(
"write_client_lease: fsync(): %m");
4275 return ISC_R_IOERROR;
4279 return ISC_R_SUCCESS;
4302 if (
lease -> is_static)
4315 if (
lease -> is_bootp) {
4322 fprintf (
leaseFile,
" interface \"%s\";\n",
4323 client -> interface -> name);
4328 if (client -> name) {
4329 fprintf (
leaseFile,
" name \"%s\";\n", client -> name);
4335 fprintf (
leaseFile,
" fixed-address %s;\n",
4341 if (
lease -> filename) {
4344 fprintf (
leaseFile,
" filename \"%s\";\n", s);
4354 if (
lease->server_name != NULL) {
4357 fprintf(
leaseFile,
" server-name \"%s\";\n", s);
4366 if (
lease -> medium) {
4369 fprintf (
leaseFile,
" medium \"%s\";\n", s);
4383 memset (&ds, 0,
sizeof ds);
4385 write_options(client,
lease->options,
" ");
4389 fprintf(
leaseFile,
" renew %s\n", tval) < 0)
4394 fprintf(
leaseFile,
" rebind %s\n", tval) < 0)
4399 fprintf(
leaseFile,
" expire %s\n", tval) < 0)
4410 if (!errors && makesure) {
4412 log_info (
"write_client_lease: %m");
4417 return errors ? 0 : 1;
4444 for (sl = client -> env; sl; sl =
next) {
4451 if (client -> interface) {
4453 client -> interface -> name);
4457 "",
"client",
"%s", client -> name);
4460 "",
"medium",
"%s", medium ->
string);
4463 client_envadd (client,
"",
"pid",
"%ld", (
long int)getpid ());
4482 in_options, cfg_options, scope, oc,
MDL)) {
4492 length = strlen(value);
4496 value, length) == 0) {
4501 "option - discarded",
4545 if (
lease->next_srv_addr.len != 0) {
4557 memset (&data, 0,
sizeof data);
4588 (&data, (
struct packet *)0,
4589 (
struct lease *)0, client,
4594 if (broadcast.
len) {
4596 prefix,
"broadcast_address",
4597 "%s",
piaddr (broadcast));
4605 if (
lease->filename) {
4608 strlen(
lease->filename)) == 0) {
4610 "%s",
lease->filename);
4613 "option - discarded",
4618 if (
lease->server_name) {
4621 strlen(
lease->server_name)) == 0 ) {
4623 "%s",
lease->server_name);
4626 "option - discarded",
4627 lease->server_name);
4640 (
unsigned long)(
lease -> expiry));
4662 for (i = 0 ; req[i] != NULL ; i++) {
4687 char reason [] =
"REASON=NBI";
4688 static char client_path [] = CLIENT_PATH;
4691 int pid, wpid, wstatus;
4694 scriptName = client -> config -> script_name;
4698 envp =
dmalloc (((client ? client -> envc : 2) +
4701 log_error (
"No memory for client script environment.");
4708 envp [i++] = sp ->
string;
4712 for (sp = client -> env; sp; sp = sp ->
next) {
4713 envp [i++] = sp ->
string;
4716 envp [i++] = reason;
4719 envp [i++] = client_path;
4720 envp [i] = (
char *)0;
4723 argv [1] = (
char *)0;
4731 wpid = wait (&wstatus);
4732 }
while (wpid != pid && wpid > 0);
4749 for (sp = client -> env; sp; sp =
next) {
4757 gettimeofday(&
cur_tv, NULL);
4758 return (WIFEXITED (wstatus) ?
4759 WEXITSTATUS (wstatus) : -WTERMSIG (wstatus));
4763 const char *prefix,
const char *name,
const char *fmt, ...)
4771 va_start (list, fmt);
4772 len = vsnprintf (spbuf,
sizeof spbuf, fmt, list);
4775 val =
dmalloc (strlen (prefix) + strlen (name) + 1 +
4776 len +
sizeof *val,
MDL);
4778 log_error (
"client_envadd: cannot allocate space for variable");
4787 if (len >=
sizeof spbuf) {
4788 va_start (list, fmt);
4789 vsnprintf (s, len + 1, fmt, list);
4795 val ->
next = client -> env;
4796 client -> env = val;
4819 if (j + 1 == buflen)
4829 if (j + 1 == buflen)
4842 static int state = 0;
4860 if ((pid = fork ()) < 0)
4873 (void) open(
"/dev/null", O_RDWR | O_CLOEXEC);
4874 (void) open(
"/dev/null", O_RDWR | O_CLOEXEC);
4875 (void) open(
"/dev/null", O_RDWR | O_CLOEXEC);
4892 pfdesc = open (
path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644);
4899 pf = fdopen (pfdesc,
"we");
4904 fprintf (pf,
"%ld\n", (
long)getpid ());
4915 for (client =
ip -> client; client; client = client ->
next) {
4916 switch (client ->
state) {
4949 #if defined(DHCPv6) && defined(DHCP4o6) 4951 if (dhcp4o6_state < 0)
4959 client -> xid = random ();
4962 if (client -> active) {
4967 memset (&ds, 0,
sizeof ds);
4969 client -> active -> options,
4973 (
struct lease *)0, client,
4975 client -> active -> options,
4978 memcpy (client -> destination.iabuf,
4980 client -> destination.len = 4;
4987 client -> first_sending =
cur_time;
4988 client -> interval = client -> config -> initial_interval;
4999 if (client -> alias)
5015 #if defined(DHCPv6) && defined(DHCP4o6) 5038 interface_reference (&
ip, last ->
next,
MDL);
5039 interface_dereference (&last ->
next,
MDL);
5041 interface_reference (&last ->
next,
5043 interface_dereference (&
ip ->
next,
5048 interface_reference (&
ip,
5054 interface_dereference (&
ip ->
next,
5061 tmp ->
client ->
interface = tmp;
5063 interface_dereference (&
ip,
MDL);
5112 for (client =
ip->client ; client ; client = client->
next) {
5117 return ISC_R_SUCCESS;
5143 static void shutdown_exit (
void *foo)
5151 #if defined (NSUPDATE) 5168 isc_result_t eresult)
5171 isc_result_t result;
5173 if ((eresult == ISC_R_SUCCESS) &&
5179 if (result == ISC_R_SUCCESS) {
5185 dhclient_ddns_cb_free(ddns_cb,
MDL);
5194 isc_result_t result;
5197 if (client->
ddns_cb != NULL) {
5203 if (ddns_cb != NULL) {
5209 ddns_cb->
cur_func = client_dns_remove_action;
5213 if (result != ISC_R_TIMEDOUT) {
5214 dhclient_ddns_cb_free(ddns_cb,
MDL);
5230 return ISC_R_SUCCESS;
5234 log_info(
"Received signal %d, initiating shutdown.",
5243 for (client =
ip -> client; client; client = client -> next) {
5246 return ISC_R_SUCCESS;
5249 return ISC_R_SUCCESS;
5252 if (client -> active &&
5253 client -> active -> expiry >
cur_time) {
5254 #if defined (NSUPDATE) 5282 tv.tv_sec =
cur_tv.tv_sec;
5283 tv.tv_usec =
cur_tv.tv_usec + 1;
5286 return ISC_R_SUCCESS;
5289 #if defined (NSUPDATE) 5300 isc_result_t status = ISC_R_FAILURE;
5302 if ((client != NULL) &&
5303 ((client->
active != NULL) ||
5316 if (status != ISC_R_TIMEDOUT) {
5352 isc_result_t eresult)
5354 isc_result_t result;
5371 ddns_cb->
cur_func = client_dns_update_action;
5374 if (result == ISC_R_SUCCESS) {
5380 case ISC_R_TIMEDOUT:
5388 if (ddns_cb->
zone != NULL) {
5394 ddns_cb->
cur_func = client_dns_update_action;
5400 tv.tv_usec =
cur_tv.tv_usec;
5402 ddns_cb, NULL, NULL);
5406 dhclient_ddns_cb_free(ddns_cb,
MDL);
5424 if (!client -> sent_options)
5425 return ISC_R_SUCCESS;
5429 return ISC_R_SUCCESS;
5435 (
struct lease *)0, client,
5436 client -> sent_options,
5439 return ISC_R_SUCCESS;
5446 (
struct lease *)0, client,
5447 client -> sent_options,
5450 return ISC_R_SUCCESS;
5456 (
struct lease *)0, client,
5457 client -> sent_options,
5460 return ISC_R_SUCCESS;
5472 memset(&client_identifier, 0,
sizeof(client_identifier));
5496 client_identifier.data,
5497 client_identifier.len);
5515 (client_identifier.data[0] == 255)) {
5520 if (client_identifier.len <= 5)
5521 log_fatal(
"Impossible condition at %s:%d.",
5524 client_identifier.data + 5,
5525 client_identifier.len - 5);
5527 result =
get_dhcid(ddns_cb, ddns_v4_type,
5528 client_identifier.data,
5529 client_identifier.len);
5539 return ISC_R_SUCCESS;
5548 rcode = ISC_R_FAILURE;
5554 if (rcode == ISC_R_SUCCESS) {
5555 rcode = ISC_R_TIMEDOUT;
5578 if (client->
ddns_cb != NULL) {
5585 if (ddns_cb != NULL) {
5586 ddns_cb->
lease = (
void *)client;
5599 ddns_cb->
cur_func = client_dns_update_action;
5603 tv.tv_sec =
cur_tv.tv_sec + offset;
5604 tv.tv_usec =
cur_tv.tv_usec;
5606 ddns_cb, NULL, NULL);
5608 log_error(
"Unable to allocate dns update state for %s",
5617 struct servent *ent;
5631 ent = getservbyname(
"dhcpc",
"udp");
5633 ent = getservbyname(
"bootpc",
"udp");
5638 #ifndef __CYGWIN32__ 5662 static int check_domain_name(
const char *ptr,
size_t len,
int dots)
5667 if ((len == 0) || (len > 256))
5672 for (p=ptr; (*p != 0) && (len-- > 0); p++) {
5673 if ((*p ==
'-') || (*p ==
'_')) {
5675 if (((p - ptr) == 0) || (len == 0) || (p[1] ==
'.'))
5677 }
else if (*p ==
'.') {
5681 if ((d <= 0) || (d >= 64))
5684 if ((dots > 0) && (len > 0))
5686 }
else if (isalnum((
unsigned char)*p) == 0) {
5691 return(dots ? -1 : 0);
5694 static int check_domain_name_list(
const char *ptr,
size_t len,
int dots)
5699 if ((ptr == NULL) || (len == 0))
5702 for (p=ptr; (*p != 0) && (len > 0); p++, len--) {
5706 if (check_domain_name(ptr, p - ptr, dots) != 0)
5713 return(check_domain_name(ptr, p - ptr, dots));
5730 #ifdef ACCEPT_LIST_IN_DOMAIN_NAME 5731 return check_domain_name_list(ptr, len, 0);
5733 return check_domain_name(ptr, len, 0);
5738 return check_domain_name(ptr, len, 0);
5741 return check_domain_name_list(ptr, len, 0);
5746 for (; (*ptr != 0) && (len-- > 0); ptr++) {
5747 if(!(isalnum((
unsigned char)*ptr) ||
5748 *ptr ==
'#' || *ptr ==
'%' ||
5749 *ptr ==
'+' || *ptr ==
'-' ||
5750 *ptr ==
'_' || *ptr ==
':' ||
5751 *ptr ==
'.' || *ptr ==
',' ||
5752 *ptr ==
'@' || *ptr ==
'~' ||
5753 *ptr ==
'\\' || *ptr ==
'/' ||
5754 *ptr ==
'[' || *ptr ==
']' ||
5755 *ptr ==
'=' || *ptr ==
' '))
5770 return check_domain_name_list(ptr, len, 0);
5785 log_fatal (
"no memory for reject list!");
5804 log_info(
"Server added to list of rejected servers.");
5813 if (client != NULL) {
5821 #if defined(DHCPv6) && defined(DHCP4o6) 5840 char start_msg[5] = {
'S',
'T',
'A',
'R',
'T' };
5841 char stop_msg[4] = {
'S',
'T',
'O',
'P' };
5842 char poll_msg[4] = {
'P',
'O',
'L',
'L' };
5846 if (h->type != dhcp4o6_type)
5849 cc = recv(dhcp4o6_fd, buf,
sizeof(buf), 0);
5851 return ISC_R_UNEXPECTED;
5855 (memcmp(buf, poll_msg,
sizeof(poll_msg)) == 0)) {
5857 if (dhcp4o6_state < 0)
5858 cc = send(dhcp4o6_fd, stop_msg,
5859 sizeof(stop_msg), 0);
5861 cc = send(dhcp4o6_fd, start_msg,
5862 sizeof(start_msg), 0);
5864 log_error(
"dhcpv4o6_handler: send(): %m");
5865 return ISC_R_IOERROR;
5869 return ISC_R_UNEXPECTED;
5870 memset(&raw, 0,
sizeof(raw));
5873 "no memory buffer.");
5874 return ISC_R_NOMEMORY;
5880 forw_dhcpv4_query(&raw);
5886 (memcmp(buf, stop_msg,
sizeof(stop_msg)) == 0)) {
5888 if (dhcp4o6_state > 0) {
5892 }
else if ((cc == 5) &&
5893 (memcmp(buf, start_msg,
sizeof(start_msg)) == 0)) {
5895 if (dhcp4o6_state == 0)
5901 return ISC_R_UNEXPECTED;
5902 memset(&raw, 0,
sizeof(raw));
5905 "no memory buffer.");
5906 return ISC_R_NOMEMORY;
5912 recv_dhcpv4_response(&raw);
5918 return ISC_R_SUCCESS;
5929 static void dhcp4o6_poll(
void *dummy) {
5930 char msg[4] = {
'P',
'O',
'L',
'L' };
5936 if (dhcp4o6_state < 0)
5941 cc = send(dhcp4o6_fd, msg,
sizeof(msg), 0);
5946 tv.tv_usec = random() % 1000000;
5958 static void dhcp4o6_resume() {
5963 for (client =
ip->client; client != NULL;
5964 client = client->
next) {
5987 char msg[5] = {
'S',
'T',
'A',
'R',
'T' };
5990 memset(&addrs, 0,
sizeof(addrs));
5992 for (client =
ip->client; client != NULL;
5993 client = client->
next) {
6006 lease->options, NULL,
6009 if ((addrs.len % 16) != 0) {
6022 if (dhcp4o6_state == 1)
6024 log_info(
"dhcp4o6_start: go to UP");
6027 cc = send(dhcp4o6_fd, msg,
sizeof(msg), 0);
6029 log_info(
"dhcp4o6_start: send(): %m");
6039 static void dhcp4o6_stop() {
6040 char msg[4] = {
'S',
'T',
'O',
'P' };
6043 if (dhcp4o6_state == -1)
6046 log_info(
"dhcp4o6_stop: go to DOWN");
6049 cc = send(dhcp4o6_fd, msg,
sizeof(msg), 0);
void do_packet6(struct interface_info *, const char *, int, int, const struct iaddr *, isc_boolean_t)
void state_selecting(void *cpp)
#define DHCP_FIXED_NON_UDP
#define _PATH_DHCLIENT_CONF
void(* dhcpv6_packet_handler)(struct interface_info *, const char *, int, int, const struct iaddr *, isc_boolean_t)
void send_discover(void *cpp)
void unbill_class(struct lease *lease)
struct client_lease * alias
int parse_encapsulated_suboptions(struct option_state *options, struct option *eopt, const unsigned char *buffer, unsigned len, struct universe *eu, const char *uname)
isc_result_t omapi_protocol_listen(omapi_object_t *, unsigned, int)
struct binding_scope * global_scope
#define _PATH_DHCLIENT_PID
struct universe * universe
void make_client_options(struct client_state *client, struct client_lease *lease, u_int8_t *type, struct option_cache *sid, struct iaddr *rip, struct option **prl, struct option_state **op)
struct group * on_receipt
unsigned char dhcpv6_transaction_id[3]
#define _PATH_DHCLIENT_SCRIPT
void save_option(struct universe *universe, struct option_state *options, struct option_cache *oc)
struct client_lease * new
void do_release(struct client_state *client)
const char * piaddr(const struct iaddr addr)
void rewrite_client_leases()
#define FQDN_NO_CLIENT_UPDATE
#define DHO_DOMAIN_SEARCH
#define DDNS_STATE_ADD_FW_NXDOMAIN
void dhcpoffer(struct packet *packet)
unsigned char dhcpv6_transaction_id[3]
int make_const_option_cache(struct option_cache **oc, struct buffer **buffer, u_int8_t *data, unsigned len, struct option *option, const char *file, int line)
void dhcpnak(struct packet *packet)
int get_dhcid(dhcp_ddns_cb_t *, int, const u_int8_t *, unsigned)
isc_result_t end_parse(struct parse **cfile)
const char * path_dhclient_db
void(* bootp_packet_handler)(struct interface_info *, struct dhcp_packet *, unsigned, unsigned int, struct iaddr, struct hardware *)
#define All_DHCP_Relay_Agents_and_Servers
void start_release6(struct client_state *client)
char * piaddrmask(struct iaddr *addr, struct iaddr *mask)
int option_cache_dereference(struct option_cache **ptr, const char *file, int line)
void start_info_request6(struct client_state *client)
void send_decline(void *cpp)
void client_dns_update_timeout(void *cp)
void cancel_timeout(void(*)(void *) where, void *what)
#define print_hex_1(len, data, limit)
#define DHO_DHCP_PARAMETER_REQUEST_LIST
int dhcp_max_agent_option_packet_length
struct client_lease * packet_to_lease(struct packet *packet, struct client_state *client)
#define DHCP_R_INVALIDARG
struct group * on_transmission
#define DISCOVER_REQUESTED
int script_go(struct client_state *client)
Calls external script.
struct iaddr requested_address
const char * dhcpv6_type_names[]
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
int write_client_lease(struct client_state *client, struct client_lease *lease, int rewrite, int makesure)
struct client_state * client
int can_receive_unicast_unconfigured(struct interface_info *)
struct iaddr iaddr_broadcast
void reinitialize_interfaces()
#define DHCPV6_RECONFIGURE
struct client_state * next
#define DHCP_CONTEXT_PRE_DB
#define DHO_DHCP_LEASE_TIME
void dhcpack(struct packet *packet)
unsigned cons_agent_information_options(struct option_state *cfg_options, struct dhcp_packet *outpacket, unsigned agentix, unsigned length)
struct universe dhcp_universe
struct option_state * options
dhcp_ddns_cb_t * ddns_cb_alloc(const char *file, int line)
void data_string_forget(struct data_string *data, const char *file, int line)
void bootp(struct packet *packet)
const char * pretty_print_option(struct option *option, const unsigned char *data, unsigned len, int emit_commas, int emit_quotes)
#define INTERFACE_RUNNING
void send_release(void *cpp)
int log_error(const char *,...) __attribute__((__format__(__printf__
struct string_list * client_env
#define DDNS_INCLUDE_RRSET
void client_envadd(struct client_state *client, const char *prefix, const char *name, const char *fmt,...)
void add_timeout(struct timeval *when, void(*)(void *) where, void *what, tvref_t ref, tvunref_t unref)
void dump_packet(struct packet *)
#define DDNS_STATE_REM_FW_YXDHCID
#define DHO_DHCP_REBINDING_TIME
#define DHO_NETBIOS_SCOPE
#define DHCPV6_DHCPV4_QUERY
const char * path_dhclient_duid
enum dhcp_token peek_token(const char **rval, unsigned *rlen, struct parse *cfile)
struct data_string fwd_name
void write_client_pid_file()
void state_panic(void *cpp)
void forget_zone(struct dns_zone **)
struct data_string default_duid
struct option_state * options
void ddns_cb_free(dhcp_ddns_cb_t *ddns_cb, const char *file, int line)
void do_packet(struct interface_info *interface, struct dhcp_packet *packet, unsigned len, unsigned int from_port, struct iaddr from, struct hardware *hfrom)
#define D6O_NIS_DOMAIN_NAME
unsigned char dhcpv6_msg_type
#define DHO_DHCP_SERVER_IDENTIFIER
void log_fatal(const char *,...) __attribute__((__format__(__printf__
void(* v6_handler)(struct packet *, struct client_state *)
#define DHCP_CONTEXT_POST_DB
enum dhcp_pending pending
isc_result_t form_duid(struct data_string *duid, const char *file, int line)
struct executable_statement * statements
void state_init(void *cpp)
#define INTERFACE_AUTOMATIC
int option_state_reference(struct option_state **ptr, struct option_state *bp, const char *file, int line)
const char * print_time(TIME t)
struct option * default_requested_options[]
void read_client_leases()
struct iaddr subnet_number(struct iaddr addr, struct iaddr mask)
u_int16_t validate_port(char *port)
void dhcp_signal_handler(int signal)
int find_subnet(struct subnet **sp, struct iaddr addr, const char *file, int line)
void execute_statements_in_scope(struct binding_value **result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope, struct group *group, struct group *limiting_group, struct on_star *on_star)
void make_request(struct client_state *client, struct client_lease *lease)
struct interface_info * fallback_interface
isc_result_t dhclient_interface_startup_hook(struct interface_info *interface)
int option_state_allocate(struct option_state **ptr, const char *file, int line)
const char * path_dhclient_pid
struct iaddrmatchlist * next
void client_option_envadd(struct option_cache *oc, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff)
isc_result_t dhcp_context_create(int flags, struct in_addr *local4, struct in6_addr *local6)
int evaluate_option_cache(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct option_cache *oc, const char *file, int line)
#define DHCPV6_DHCPV4_RESPONSE
int write_host(struct host_decl *host)
struct option_state * options
struct option ** requested_options
void classify(struct packet *packet, struct class *class)
void script_init(struct client_state *client, const char *reason, struct string_list *medium)
Initializes basic variables for a script.
#define DHCP_MAX_OPTION_LEN
int main(int argc, char **argv)
void(* store_length)(unsigned char *, u_int32_t)
dns_rdataclass_t dhcid_class
void make_decline(struct client_state *client, struct client_lease *lease)
#define DHCP_DNS_CLIENT_LAZY_INIT
void bind_lease(struct client_state *client)
int buffer_allocate(struct buffer **ptr, unsigned len, const char *file, int line)
#define DHO_BROADCAST_ADDRESS
struct option_cache * option
struct interface_info * interface
isc_result_t read_uuid(u_int8_t *uuid)
ssize_t send_packet6(struct interface_info *, const unsigned char *, size_t, struct sockaddr_in6 *)
int write_lease(struct lease *lease)
void putULong(unsigned char *, u_int32_t)
void run_stateless(int exit_mode, u_int16_t port)
void send_request(void *cpp)
isc_result_t omapi_generic_new(omapi_object_t **, const char *, int)
#define D6O_DOMAIN_SEARCH
ssize_t send_packet(struct interface_info *, struct packet *, struct dhcp_packet *, size_t, struct in_addr, struct sockaddr_in *, struct hardware *)
int cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, struct lease *lease, struct client_state *client_state, int mms, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, int overload_avail, int terminate, int bootpp, struct data_string *prl, const char *vuname)
void start_confirm6(struct client_state *client)
void dfree(void *, const char *, int)
isc_boolean_t no_pid_file
struct client_lease * next
void ddns_cancel(dhcp_ddns_cb_t *ddns_cb, const char *file, int line)
struct option_state * sent_options
const char * path_dhclient_conf
struct hardware hw_address
struct option_cache * lookup_option(struct universe *universe, struct option_state *options, unsigned code)
int dhclient_interface_discovery_hook(struct interface_info *tmp)
struct client_state * client
struct option_state * options
int asprintf(char **strp, const char *fmt,...)
int int log_info(const char *,...) __attribute__((__format__(__printf__
int bootp_broadcast_always
u_int16_t validate_port_pair(char *port)
void * dmalloc(size_t, const char *, int)
int parse_options(struct packet *packet)
struct interface_info * interfaces
void free_client_lease(struct client_lease *lease, const char *file, int line)
#define _PATH_DHCLIENT_DB
u_int32_t getULong(const unsigned char *)
int validate_packet(struct packet *packet)
struct client_config top_level_config
struct iaddr broadcast_addr(struct iaddr subnet, struct iaddr mask)
struct option ** required_options
union executable_statement::@7 data
void state_reboot(void *cpp)
int check_collection(struct packet *packet, struct lease *lease, struct collection *collection)
void destroy_client_lease(struct client_lease *lease)
void db_startup(int testp)
int parse_agent_information_option(struct packet *packet, int len, u_int8_t *data)
#define ASSERT_STATE(state_is, state_shouldbe)
char * path_dhclient_script
void parse_client_statement(struct parse *cfile, struct interface_info *ip, struct client_config *config)
struct universe ** universes
char * format_lease_id(const unsigned char *s, unsigned len, int format, const char *file, int line)
#define DHCP4O6_QUERY_UNICAST
int quiet_interface_discovery
isc_result_t(* dhcp_interface_startup_hook)(struct interface_info *)
#define DISCOVER_UNCONFIGURED
struct client_lease * active
isc_result_t client_dns_update(struct client_state *client, dhcp_ddns_cb_t *ddns_cb)
int option_state_dereference(struct option_state **ptr, const char *file, int line)
void start_init6(struct client_state *client)
void option_space_foreach(struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff, void(*func)(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *))
void initialize_common_option_spaces()
void make_discover(struct client_state *client, struct client_lease *lease)
void dhcpv6(struct packet *)
void unconfigure6(struct client_state *client, const char *reason)
void client_dns_remove(struct client_state *client, struct iaddr *addr)
const int dhcpv6_type_name_max
int addr_match(struct iaddr *addr, struct iaddrmatch *match)
struct dhcp_packet packet
void state_bound(void *cpp)
struct interface_info * next
struct universe dhcpv6_universe
int evaluate_boolean_option_cache(int *ignorep, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct option_cache *oc, const char *file, int line)
int packet_dereference(struct packet **ptr, const char *file, int line)
int packet_allocate(struct packet **ptr, const char *file, int line)
void make_release(struct client_state *client, struct client_lease *lease)
struct string_list * next
isc_result_t read_client_conf()
struct interface_info * dummy_interfaces
isc_result_t find_class(struct class **c, const char *s, const char *file, int line)
void script_write_requested(struct client_state *client)
Write out the environent variable the client requested. Write out the environment variables for the o...
#define FQDN_SERVER_UPDATE
struct client_lease * new_client_lease(char *file, int line) const
#define DDNS_STATE_ADD_FW_YXDHCID
#define D6O_DHCP4_O_DHCP6_SERVER
void dhcpv4_client_assignments(void)
void dump_raw(unsigned char *buf, unsigned len) const
void dhcpv6_client_assignments(void)
u_int8_t hbuf[HARDWARE_ADDR_LEN+1]
struct iaddrmatchlist * reject_list
struct string_list * medium
struct client_config * config
#define D6O_SIP_SERVERS_DNS
struct sockaddr_in sockaddr_broadcast
void dhclient_schedule_updates(struct client_state *client, struct iaddr *addr, int offset)
int dhcp_option_ev_name(char *buf, size_t buflen, struct option *option)
int(* dhcp_interface_discovery_hook)(struct interface_info *)
struct in_addr inaddr_any
struct universe fqdn_universe
void dhcp(struct packet *packet)
#define DHO_DHCP_OPTION_OVERLOAD
#define D6O_NISP_DOMAIN_NAME
option_code_hash_t * code_hash
#define DHO_DHCP_RENEWAL_TIME
struct string_list * medium
#define DHO_DHCP_CLIENT_IDENTIFIER
struct dhcp_ddns_cb * ddns_cb
void putUShort(unsigned char *, u_int32_t)
isc_result_t dhcp_set_control_state(control_object_state_t oldstate, control_object_state_t newstate)
char * quotify_string(const char *s, const char *file, int line)
unsigned char options[FLEXIBLE_ARRAY_MEMBER]
const unsigned char * data
struct interface_info * interface
#define DHO_DHCP_MESSAGE_TYPE
void dhcp_common_objects_setup(void)
void(* store_tag)(unsigned char *, u_int32_t)
void write_lease_option(struct option_cache *oc, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff)
#define DDNS_STATE_REM_FW_NXRR
int(* dhcp_interface_shutdown_hook)(struct interface_info *)
void discover_interfaces(int state)
isc_result_t new_parse(struct parse **cfile, int file, char *inbuf, unsigned buflen, const char *name, int eolp)
struct dhc6_lease * active_lease
#define INTERFACE_REQUESTED
int dhclient_interface_shutdown_hook(struct interface_info *interface)
void script_write_params(struct client_state *client, const char *prefix, struct client_lease *lease)
Adds parameters to environment variables for a script.
int option_dereference(struct option **dest, const char *file, int line)
#define DHO_VENDOR_ENCAPSULATED_OPTIONS
void client_location_changed()
void state_stop(void *cpp)
isc_result_t omapi_init(void)
#define DHO_DHCP_REQUESTED_ADDRESS
int buffer_dereference(struct buffer **ptr, const char *file, int line)
isc_result_t ddns_modify_fwd(dhcp_ddns_cb_t *ddns_cb, const char *file, int line)
isc_result_t write_client6_lease(struct client_state *client, struct dhc6_lease *lease, int rewrite, int sync)
int bootp_broadcast_always