36 #include <dns/result.h> 52 extern int asprintf(
char **strp,
const char *fmt, ...);
85 #define ASSERT_STATE(state_is, state_shouldbe) {} 88 static const char copyright[] =
"Copyright 2004-2018 Internet Systems Consortium.";
89 static const char arr [] =
"All rights reserved.";
90 static const char message [] =
"Internet Systems Consortium DHCP Client";
91 static const char url [] =
"For info, please visit https://www.isc.org/software/dhcp/";
96 #if defined(DHCPv6) && defined(DHCP4o6) 97 int dhcp4o6_state = -1;
114 int dad_wait_time = 0;
115 int prefix_len_hint = 0;
129 static isc_result_t write_duid(
struct data_string *duid);
132 static int check_domain_name(
const char *ptr,
size_t len,
int dots);
133 static int check_domain_name_list(
const char *ptr,
size_t len,
int dots);
135 const char *ptr,
size_t len);
156 #if defined(DHCPv6) && defined(DHCP4o6) 157 static void dhcp4o6_poll(
void *dummy);
158 static void dhcp4o6_resume(
void);
159 static void recv_dhcpv4_response(
struct data_string *raw);
160 static int send_dhcpv4_query(
struct client_state *client,
int broadcast);
162 static void dhcp4o6_stop(
void);
163 static void forw_dhcpv4_response(
struct packet *
packet);
164 static void forw_dhcpv4_query(
struct data_string *raw);
171 static const char use_noarg[] =
"No argument for command: %s";
173 static const char use_v6command[] =
"Command not used for DHCPv4: %s";
178 #define DHCLIENT_USAGE0 \ 179 "[-4|-6] [-SNTPRI1dvrxi] [-nw] -4o6 <port>] [-p <port>] [-D LL|LLT]\n" \ 180 " [--dad-wait-time <seconds>] [--prefix-len-hint <length>]\n" \ 181 " [--decline-wait-time <seconds>]\n" \ 182 " [--address-prefix-len <length>]\n" 184 #define DHCLIENT_USAGE0 \ 185 "[-4|-6] [-SNTPRI1dvrxi] [-nw] [-p <port>] [-D LL|LLT]\n" \ 186 " [--dad-wait-time <seconds>] [--prefix-len-hint <length>]\n" \ 187 " [--decline-wait-time <seconds>]\n" \ 188 " [--address-prefix-len <length>]\n" 191 #define DHCLIENT_USAGE0 \ 192 "[-I1dvrxi] [-nw] [-p <port>] [-D LL|LLT] \n" \ 193 " [--decline-wait-time <seconds>]\n" 196 #define DHCLIENT_USAGEC \ 197 " [-s server-addr] [-cf config-file]\n" \ 198 " [-df duid-file] [-lf lease-file]\n" \ 199 " [-pf pid-file] [--no-pid] [-e VAR=val]\n" \ 200 " [-sf script-file] [interface]*\n" \ 201 " [-C <dhcp-client-identifier>] [-B]\n" \ 202 " [-H <host-name> | -F <fqdn.fqdn>] [--timeout <timeout>]\n" \ 203 " [-V <vendor-class-identifier>]\n" \ 204 " [--request-options <request option list>]" 206 #define DHCLIENT_USAGEH "{--version|--help|-h}" 211 usage(
const char *sfmt,
const char *sarg)
219 #ifdef PRINT_SPECIFIC_CL_ERRORS 244 int release_mode = 0;
249 int no_dhclient_conf = 0;
250 int no_dhclient_db = 0;
251 int no_dhclient_pid = 0;
252 int no_dhclient_script = 0;
254 int local_family_set = 0;
256 u_int16_t dhcp4o6_port = 0;
266 char *dhcp_client_identifier_arg = NULL;
267 char *dhcp_host_name_arg = NULL;
268 char *dhcp_fqdn_arg = NULL;
269 char *dhcp_vendor_class_identifier_arg = NULL;
270 char *dhclient_request_options = NULL;
273 char *arg_conf = NULL;
274 int arg_conf_len = 0;
275 #ifdef HAVE_LIBCAP_NG 276 int keep_capabilities = 0;
285 fd = open(
"/dev/null", O_RDWR | O_CLOEXEC);
287 fd = open(
"/dev/null", O_RDWR | O_CLOEXEC);
289 fd = open(
"/dev/null", O_RDWR | O_CLOEXEC);
297 #if !(defined(DEBUG) || defined(__CYGWIN32__)) 298 setlogmask(LOG_UPTO(LOG_INFO));
302 for (i = 1; i < argc; i++) {
303 if (!strcmp(argv[i],
"-r")) {
305 }
else if (!strcmp(argv[i],
"-x")) {
307 }
else if (!strcmp(argv[i],
"-d")) {
309 }
else if (!strcmp(argv[i],
"--version")) {
310 const char vstring[] =
"isc-dhclient-";
318 }
else if (!strcmp(argv[i],
"--help") ||
319 !strcmp(argv[i],
"-h")) {
320 const char *pname = isc_file_basename(
progname);
344 if ((pid = fork ()) < 0)
350 (void) close(
dfd[1]);
354 n = read(
dfd[0], &buf, 1);
357 }
while (n == -1 && errno == EINTR);
361 (void) close(
dfd[0]);
367 if (status != ISC_R_SUCCESS)
368 log_fatal(
"Can't initialize context: %s",
369 isc_result_totext(status));
373 if (status != ISC_R_SUCCESS)
375 isc_result_totext(status));
385 for (i = 1; i < argc; i++) {
386 if (!strcmp(argv[i],
"-r")) {
390 }
else if (!strcmp(argv[i],
"-4")) {
392 log_fatal(
"Client can only do v4 or v6, not " 394 local_family_set = 1;
396 }
else if (!strcmp(argv[i],
"-6")) {
398 log_fatal(
"Client can only do v4 or v6, not " 400 local_family_set = 1;
403 }
else if (!strcmp(argv[i],
"-4o6")) {
405 usage(use_noarg, argv[i-1]);
408 log_debug(
"DHCPv4 over DHCPv6 over ::1 port %d and %d",
410 ntohs(dhcp4o6_port) + 1);
414 }
else if (!strcmp(argv[i],
"-x")) {
418 }
else if (!strcmp(argv[i],
"-p")) {
420 usage(use_noarg, argv[i-1]);
422 log_debug(
"binding to user-specified port %d",
424 }
else if (!strcmp(argv[i],
"-d")) {
427 }
else if (!strcmp(argv[i],
"-pf")) {
429 usage(use_noarg, argv[i-1]);
432 }
else if (!strcmp(argv[i],
"--no-pid")) {
434 }
else if (!strcmp(argv[i],
"-cf")) {
436 usage(use_noarg, argv[i-1]);
438 no_dhclient_conf = 1;
439 }
else if (!strcmp(argv[i],
"-df")) {
441 usage(use_noarg, argv[i-1]);
443 }
else if (!strcmp(argv[i],
"-lf")) {
445 usage(use_noarg, argv[i-1]);
448 }
else if (!strcmp(argv[i],
"-sf")) {
450 usage(use_noarg, argv[i-1]);
452 no_dhclient_script = 1;
453 }
else if (!strcmp(argv[i],
"-1")) {
455 }
else if (!strcmp(argv[i],
"-q")) {
457 }
else if (!strcmp(argv[i],
"-s")) {
459 usage(use_noarg, argv[i-1]);
461 }
else if (!strcmp(argv[i],
"-g")) {
463 usage(use_noarg, argv[i-1]);
465 }
else if (!strcmp(argv[i],
"-nw")) {
467 }
else if (!strcmp(argv[i],
"-n")) {
470 }
else if (!strcmp(argv[i],
"-w")) {
473 }
else if (!strcmp(argv[i],
"-e")) {
476 usage(use_noarg, argv[i-1]);
477 tmp =
dmalloc(strlen(argv[i]) +
sizeof *tmp,
MDL);
480 strcpy(tmp->
string, argv[i]);
485 }
else if (!strcmp(argv[i],
"-S")) {
487 usage(use_v6command, argv[i]);
489 local_family_set = 1;
493 }
else if (!strcmp(argv[i],
"-N")) {
495 usage(use_v6command, argv[i]);
497 local_family_set = 1;
503 }
else if (!strcmp(argv[i],
"-T")) {
505 usage(use_v6command, argv[i]);
507 local_family_set = 1;
513 }
else if (!strcmp(argv[i],
"-P")) {
515 usage(use_v6command, argv[i]);
517 local_family_set = 1;
523 }
else if (!strcmp(argv[i],
"-R")) {
525 usage(use_v6command, argv[i]);
527 local_family_set = 1;
530 }
else if (!strcmp(argv[i],
"--dad-wait-time")) {
532 usage(use_noarg, argv[i-1]);
535 dad_wait_time = (
int)strtol(argv[i], &s, 10);
536 if (errno || (*s !=
'\0') || (dad_wait_time < 0)) {
537 usage(
"Invalid value for --dad-wait-time: %s",
540 }
else if (!strcmp(argv[i],
"--prefix-len-hint")) {
542 usage(use_noarg, argv[i-1]);
546 prefix_len_hint = (
int)strtol(argv[i], &s, 10);
547 if (errno || (*s !=
'\0') || (prefix_len_hint < 0)) {
548 usage(
"Invalid value for --prefix-len-hint: %s",
551 }
else if (!strcmp(argv[i],
"--address-prefix-len")) {
553 usage(use_noarg, argv[i-1]);
557 if (errno || (*s !=
'\0') ||
559 usage(
"Invalid value for" 560 " --address-prefix-len: %s", argv[i]);
563 }
else if (!strcmp(argv[i],
"--decline-wait-time")) {
565 usage(use_noarg, argv[i-1]);
570 if (errno || (*s !=
'\0') ||
572 usage(
"Invalid value for " 573 "--decline-wait-time: %s", argv[i]);
575 }
else if (!strcmp(argv[i],
"-D")) {
578 usage(use_noarg, argv[i-1]);
579 if (!strcasecmp(argv[i],
"LL")) {
581 }
else if (!strcasecmp(argv[i],
"LLT")) {
584 usage(
"Unknown argument to -D: %s", argv[i]);
586 }
else if (!strcmp(argv[i],
"-i")) {
589 }
else if (!strcmp(argv[i],
"-I")) {
592 }
else if (!strcmp(argv[i],
"-v")) {
594 }
else if (!strcmp(argv[i],
"-C")) {
595 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
596 usage(use_noarg, argv[i-1]);
605 dhcp_client_identifier_arg = argv[i];
606 }
else if (!strcmp(argv[i],
"-B")) {
608 }
else if (!strcmp(argv[i],
"-H")) {
609 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
610 usage(use_noarg, argv[i-1]);
619 if (dhcp_host_name_arg != NULL) {
620 log_error(
"The -H <host-name> and -F <fqdn> arguments are mutually exclusive");
624 dhcp_host_name_arg = argv[i];
625 }
else if (!strcmp(argv[i],
"-F")) {
626 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
627 usage(use_noarg, argv[i-1]);
636 if (dhcp_fqdn_arg != NULL) {
637 log_error(
"Only one -F <fqdn> argument can be specified");
641 if (dhcp_host_name_arg != NULL) {
642 log_error(
"The -F <fqdn> and -H <host-name> arguments are mutually exclusive");
646 dhcp_fqdn_arg = argv[i];
647 }
else if (!strcmp(argv[i],
"--timeout")) {
648 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
649 usage(use_noarg, argv[i-1]);
653 if ((timeout_arg = atoi(argv[i])) <= 0) {
654 log_error(
"timeout option must be > 0 - bad value: %s",argv[i]);
657 }
else if (!strcmp(argv[i],
"-V")) {
658 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
659 usage(use_noarg, argv[i-1]);
668 dhcp_vendor_class_identifier_arg = argv[i];
669 }
else if (!strcmp(argv[i],
"--request-options")) {
670 if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])==
'\0')) {
671 usage(use_noarg, argv[i-1]);
675 dhclient_request_options = argv[i];
677 }
else if (!strcmp(argv[i],
"-nc")) {
678 #ifdef HAVE_LIBCAP_NG 679 keep_capabilities = 1;
681 }
else if (argv[i][0] ==
'-') {
682 usage(
"Unknown command: %s", argv[i]);
684 usage(
"No interfaces comamnd -n and " 685 " requested interface %s", argv[i]);
689 status = interface_allocate(&tmp,
MDL);
690 if (status != ISC_R_SUCCESS)
691 log_fatal(
"Can't record interface %s:%s",
692 argv[i], isc_result_totext(status));
693 if (strlen(argv[i]) >=
sizeof(tmp->
name))
694 log_fatal(
"%s: interface name too long (is %ld)",
695 argv[i], (
long)strlen(argv[i]));
696 strcpy(tmp->
name, argv[i]);
698 interface_reference(&tmp->
next,
714 usage(
"PD %s only supports one requested interface",
"-P");
717 #if defined(DHCPv6) && defined(DHCP4o6) 719 (exit_mode || release_mode))
720 log_error(
"Can't relay DHCPv4-over-DHCPv6 " 721 "without a persistent DHCPv6 client");
724 log_fatal(
"DHCPv4-over-DHCPv6 requires an explicit " 725 "interface on which to be applied");
728 if (!no_dhclient_conf && (s = getenv(
"PATH_DHCLIENT_CONF"))) {
731 if (!no_dhclient_db && (s = getenv(
"PATH_DHCLIENT_DB"))) {
734 if (!no_dhclient_pid && (s = getenv(
"PATH_DHCLIENT_PID"))) {
737 if (!no_dhclient_script && (s = getenv(
"PATH_DHCLIENT_SCRIPT"))) {
741 #ifdef HAVE_LIBCAP_NG 743 if (!keep_capabilities) {
744 capng_clear(CAPNG_SELECT_CAPS);
745 capng_update(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED,
747 capng_updatev(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED,
748 CAP_NET_ADMIN, CAP_NET_RAW,
749 CAP_NET_BIND_SERVICE, CAP_SYS_ADMIN, -1);
750 capng_apply(CAPNG_SELECT_CAPS);
788 if ((release_mode || exit_mode) && (
no_pid_file == ISC_FALSE)) {
795 e = fscanf(pidfd,
"%ld\n", &temp);
796 oldpid = (pid_t)temp;
798 if (e != 0 && e != EOF && oldpid) {
799 if (kill(oldpid, SIGTERM) == 0) {
800 log_info(
"Killed old client process");
810 }
else if (errno == ESRCH) {
824 char *new_path_dhclient_pid;
843 int n_len = strlen(
ip->name);
845 new_path_dhclient_pid = (
char*) malloc(pfx + n_len + 6);
847 sprintf(new_path_dhclient_pid + pfx,
"-%s.pid",
ip->name);
849 if ((pidfd = fopen(new_path_dhclient_pid,
"re")) != NULL) {
850 e = fscanf(pidfd,
"%ld\n", &temp);
851 oldpid = (pid_t)temp;
853 if (e != 0 && e != EOF) {
855 if (kill(oldpid, SIGTERM) == 0)
863 free(new_path_dhclient_pid);
872 char procfn[256] =
"";
875 if ((fscanf(pidfp,
"%ld", &temp)==1) && ((dhcpid=(pid_t)temp) > 0)) {
876 snprintf(procfn,256,
"/proc/%u",dhcpid);
877 dhc_running = (access(procfn, F_OK) == 0);
884 log_fatal(
"dhclient(%u) is already running - exiting. ", dhcpid);
909 memcpy(&
giaddr, he->h_addr_list[0],
918 gettimeofday(&
cur_tv, NULL);
925 he = gethostbyname(server);
951 usage(
"Stateless command: %s incompatibile with " 952 "other commands",
"-S");
954 #if defined(DHCPv6) && defined(DHCP4o6) 963 if ((dhcp_client_identifier_arg != NULL) && (*dhcp_client_identifier_arg !=
'\0')) {
964 arg_conf_len =
asprintf(&arg_conf,
"send dhcp-client-identifier \"%s\";", dhcp_client_identifier_arg);
966 if ((arg_conf == 0) || (arg_conf_len <= 0))
967 log_fatal(
"Unable to send -C option dhcp-client-identifier");
970 if ((dhcp_host_name_arg != NULL) && (*dhcp_host_name_arg !=
'\0')) {
972 arg_conf_len =
asprintf(&arg_conf,
"send host-name \"%s\";", dhcp_host_name_arg);
974 if ((arg_conf == 0) || (arg_conf_len <= 0))
975 log_fatal(
"Unable to send -H option host-name");
977 char *last_arg_conf = arg_conf;
979 arg_conf_len =
asprintf(&arg_conf,
"%s\nsend host-name \"%s\";", last_arg_conf, dhcp_host_name_arg);
981 if ((arg_conf == 0) || (arg_conf_len <= 0))
982 log_fatal(
"Unable to send -H option host-name");
988 if ((dhcp_fqdn_arg != NULL) && (*dhcp_fqdn_arg !=
'\0')) {
990 arg_conf_len =
asprintf(&arg_conf,
"send fqdn.fqdn \"%s\";", dhcp_fqdn_arg);
992 if ((arg_conf == 0) || (arg_conf_len <= 0))
993 log_fatal(
"Unable to send -F option fqdn.fqdn");
995 char *last_arg_conf = arg_conf;
997 arg_conf_len =
asprintf(&arg_conf,
"%s\nsend fqdn.fqdn \"%s\";", last_arg_conf, dhcp_fqdn_arg);
999 if ((arg_conf == 0) || (arg_conf_len <= 0))
1000 log_fatal(
"Unable to send -F option fqdn.fqdn");
1002 free(last_arg_conf);
1007 if (arg_conf == 0) {
1008 arg_conf_len =
asprintf(&arg_conf,
"timeout %d;", timeout_arg);
1010 if ((arg_conf == 0) || (arg_conf_len <= 0))
1011 log_fatal(
"Unable to process --timeout timeout argument");
1013 char *last_arg_conf = arg_conf;
1015 arg_conf_len =
asprintf(&arg_conf,
"%s\ntimeout %d;", last_arg_conf, timeout_arg);
1017 if ((arg_conf == 0) || (arg_conf_len == 0))
1018 log_fatal(
"Unable to process --timeout timeout argument");
1020 free(last_arg_conf);
1024 if ((dhcp_vendor_class_identifier_arg != NULL) && (*dhcp_vendor_class_identifier_arg !=
'\0')) {
1025 if (arg_conf == 0) {
1026 arg_conf_len =
asprintf(&arg_conf,
"send vendor-class-identifier \"%s\";", dhcp_vendor_class_identifier_arg);
1028 if ((arg_conf == 0) || (arg_conf_len <= 0))
1029 log_fatal(
"Unable to send -V option vendor-class-identifier");
1031 char *last_arg_conf = arg_conf;
1033 arg_conf_len =
asprintf(&arg_conf,
"%s\nsend vendor-class-identifier \"%s\";", last_arg_conf, dhcp_vendor_class_identifier_arg);
1035 if ((arg_conf == 0) || (arg_conf_len <= 0))
1036 log_fatal(
"Unable to send -V option vendor-class-identifier");
1038 free(last_arg_conf);
1042 if (dhclient_request_options != NULL) {
1043 if (arg_conf == 0) {
1044 arg_conf_len =
asprintf(&arg_conf,
"request %s;", dhclient_request_options);
1046 if ((arg_conf == 0) || (arg_conf_len <= 0))
1047 log_fatal(
"Unable to parse --request-options <request options list> argument");
1049 char *last_arg_conf = arg_conf;
1051 arg_conf_len =
asprintf(&arg_conf,
"%s\nrequest %s;", last_arg_conf, dhclient_request_options);
1053 if ((arg_conf == 0) || (arg_conf_len <= 0))
1054 log_fatal(
"Unable to parse --request-options <request options list> argument");
1056 free(last_arg_conf);
1061 if (arg_conf_len == 0)
1062 if ((arg_conf_len = strlen(arg_conf)) == 0)
1064 log_fatal(
"Unable to process -C/-H/-F/--timeout/-V/--request-options configuration arguments");
1069 const char *val = NULL;
1072 status =
new_parse(&cfile, -1, arg_conf, arg_conf_len,
"extra dhclient -C/-H/-F/--timeout/-V/--request-options configuration arguments", 0);
1075 log_fatal(
"Cannot parse -C/-H/-F/--timeout/-V/--request-options configuration arguments !");
1087 log_fatal(
"Cannot parse -C/-H/-F/--timeout/-V/--request-options configuration arguments !");
1095 if (
ip->client->config->timeout == 60)
1096 ip->client->config->timeout = timeout_arg;
1144 log_info(
"No broadcast interfaces found - exiting.");
1147 }
else if (!release_mode && !exit_mode) {
1164 if (
ip->client->alias != NULL)
1181 unsigned backup_seed = 0;
1184 if (
ip -> hw_address.hlen <=
sizeof seed )
1187 &
ip -> hw_address.hbuf [
ip -> hw_address.hlen -
1188 sizeof seed],
sizeof seed);
1210 if (
ip -> hw_address.hlen <=
sizeof seed )
1213 &
ip->hw_address.hbuf[
ip->hw_address.hlen -
1214 sizeof seed],
sizeof seed);
1218 if ( seed_flag == 0 ) {
1219 if ( backup_seed != 0 ) {
1221 log_info (
"xid: rand init seed (0x%x) built using all" 1222 " available interfaces",seed);
1225 seed =
cur_time^((unsigned) gethostid()) ;
1226 log_info (
"xid: warning: no netdev with useable HWADDR found" 1227 " for seed's uniqueness enforcement");
1228 log_info (
"xid: rand init seed (0x%x) built using gethostid",
1233 srandom(seed + ((
unsigned)(
cur_tv.tv_usec * 1000000)) + (
unsigned)getpid());
1236 srandom(seed + ((
unsigned)(
cur_tv.tv_usec * 1000000)) + (
unsigned)getpid());
1242 setup_ib_interface(
ip);
1261 #if defined(DHCPv6) && defined(DHCP4o6) 1263 dhcp4o6_setup(dhcp4o6_port);
1270 for (client =
ip->client ; client != NULL ;
1271 client = client->
next) {
1275 }
else if (exit_mode) {
1295 for (client =
ip->client ; client ;
1296 client = client->
next) {
1313 tv.tv_usec = random()
1348 if (result != ISC_R_SUCCESS)
1349 log_fatal(
"Can't allocate new generic object: %s\n",
1350 isc_result_totext(result));
1355 if (result != ISC_R_SUCCESS)
1356 log_fatal(
"Can't start OMAPI protocol: %s",
1357 isc_result_totext (result));
1366 #if defined(DEBUG_MEMORY_LEAKAGE) || defined(DEBUG_MALLOC_POOL) || \ 1367 defined(DEBUG_MEMORY_LEAKAGE_ON_EXIT) 1368 dmalloc_cutoff_generation = dmalloc_generation;
1369 dmalloc_longterm = dmalloc_outstanding;
1370 dmalloc_outstanding = 0;
1373 #if defined(ENABLE_GENTLE_SHUTDOWN) 1410 isc_result_t result;
1419 usage(
"No interfaces available for stateless command: %s",
"-S");
1462 dhcp4o6_setup(port);
1482 if (result != ISC_R_SUCCESS)
1483 log_fatal(
"Can't allocate new generic object: %s\n",
1484 isc_result_totext(result));
1489 if (result != ISC_R_SUCCESS)
1490 log_fatal(
"Can't start OMAPI protocol: %s",
1491 isc_result_totext(result));
1497 #if defined(DEBUG_MEMORY_LEAKAGE) || defined(DEBUG_MALLOC_POOL) || \ 1498 defined(DEBUG_MEMORY_LEAKAGE_ON_EXIT) 1499 dmalloc_cutoff_generation = dmalloc_generation;
1500 dmalloc_longterm = dmalloc_outstanding;
1501 dmalloc_outstanding = 0;
1523 const char *s,
const char *
file,
int line)
1558 ip->client->config->bootp_broadcast_always = 1;
1564 for (g =
ip->client->config->on_transmission; g != NULL; g = g->
next) {
1567 "dhcp-client-identifier") == 0)) {
1573 log_fatal(
"dhcp-client-identifier must be specified for InfiniBand");
1610 #if defined(DHCPv6) && defined(DHCP4o6) 1612 if (dhcp4o6_state < 0)
1623 client ->
active -> is_bootp ||
1637 client ->
xid = random ();
1706 for (lp = client -> offered_leases; lp; lp =
next) {
1715 picked ->
next = NULL;
1720 client -> offered_leases = NULL;
1727 client -> state =
S_INIT;
1734 client ->
new = picked;
1752 client -> first_sending =
cur_time;
1753 client -> interval = client -> config -> initial_interval;
1757 client -> xid = client ->
packet.xid;
1780 for (client =
ip -> client; client; client = client -> next) {
1781 if (client -> xid ==
packet -> raw -> xid)
1785 (
packet -> interface -> hw_address.hlen - 1 !=
1786 packet -> raw -> hlen) ||
1787 (memcmp (&
packet -> interface -> hw_address.hbuf [1],
1790 log_debug (
"DHCPACK in wrong transaction.");
1804 log_info (
"DHCPACK of %s from %s (xid=0x%x)",
1807 ntohl(client -> xid));
1811 log_info (
"packet_to_lease failed.");
1815 client ->
new =
lease;
1823 memset (&ds, 0,
sizeof ds);
1826 packet -> options, client ->
new -> options,
1831 client ->
new -> expiry = 0;
1834 client ->
new -> expiry = 0;
1839 log_error (
"no expiry time on offered lease.");
1845 tv.tv_sec =
cur_tv.tv_sec;
1846 tv.tv_usec =
cur_tv.tv_usec + 500000;
1848 if (tv.tv_usec >= 1000000) {
1850 tv.tv_usec -= 1000000;
1869 packet -> options, client ->
new -> options,
1874 client ->
new -> renewal = 0;
1877 client ->
new -> renewal = 0;
1880 if (!client ->
new -> renewal)
1881 client ->
new -> renewal = client ->
new -> expiry / 2 + 1;
1883 if (client ->
new -> renewal <= 0)
1884 client ->
new -> renewal =
TIME_MAX;
1889 (((random() % client->
new->
renewal) + 3) / 4);
1896 packet -> options, client ->
new -> options,
1901 client ->
new -> rebind = 0;
1904 client ->
new -> rebind = 0;
1906 if (client ->
new -> rebind <= 0) {
1907 if (client ->
new -> expiry <=
TIME_MAX / 7)
1908 client ->
new -> rebind =
1909 client ->
new -> expiry * 7 / 8;
1911 client ->
new -> rebind =
1912 client ->
new -> expiry / 8 * 7;
1917 if (client ->
new -> renewal > client ->
new -> rebind) {
1918 if (client ->
new -> rebind <=
TIME_MAX / 3)
1919 client ->
new -> renewal =
1920 client ->
new -> rebind * 3 / 4;
1922 client ->
new -> renewal =
1923 client ->
new -> rebind / 4 * 3;
1926 client ->
new -> expiry +=
cur_time;
1928 if (client ->
new -> expiry <
cur_time)
1929 client ->
new -> expiry =
TIME_MAX;
1930 client ->
new -> renewal +=
cur_time;
1931 if (client ->
new -> renewal <
cur_time)
1932 client ->
new -> renewal =
TIME_MAX;
1933 client ->
new -> rebind +=
cur_time;
1934 if (client ->
new -> rebind <
cur_time)
1935 client ->
new -> rebind =
TIME_MAX;
1971 log_info(
"Unable to obtain a lease on first " 1972 "try (declined). Exiting.");
1975 #if defined (CALL_SCRIPT_ON_ONETRY_FAIL) 1984 tv.tv_usec =
cur_tv.tv_usec;
2004 random() % 1000000 :
cur_tv.tv_usec;
2007 log_info(
"bound to %s -- renewal in %ld seconds.",
2013 #if defined (NSUPDATE) 2035 client -> xid = client ->
packet.xid;
2037 memset (&ds, 0,
sizeof ds);
2043 client -> active -> options,
2046 memcpy (client -> destination.iabuf, ds.
data, 4);
2047 client -> destination.len = 4;
2055 client -> first_sending =
cur_time;
2056 client -> interval = client -> config -> initial_interval;
2124 for (ap =
packet -> interface -> client -> config -> reject_list;
2125 ap; ap = ap ->
next) {
2134 log_info(
"BOOTREPLY from %s rejected by rule %s " 2149 void (*handler) (
struct packet *);
2177 ap; ap = ap -> next) {
2186 log_info(
"%s from %s rejected by rule %s mask %s.",
2200 char addrbuf[
sizeof(
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")];
2208 ap ; ap = ap->
next) {
2211 log_info(
"%s from %s rejected by rule %s",
2224 log_info(
"RCV: %s message on %s from %s.",
2228 forw_dhcpv4_response(
packet);
2238 log_info(
"RCV: %s message on %s from %s.",
2249 client = client->
next) {
2258 log_info(
"Packet received, but nothing done with it.");
2274 static void forw_dhcpv4_response(
struct packet *
packet)
2284 if (dhcp4o6_state == -1) {
2285 log_info(
"forw_dhcpv4_response: not ready.");
2290 log_error(
"forw_dhcpv4_response: bad address");
2299 log_info(
"DHCPv4-response from %s missing " 2300 "DHCPv4 Message option.",
2305 memset(&enc_opt_data, 0,
sizeof(enc_opt_data));
2308 log_error(
"forw_dhcpv4_response: error evaluating " 2316 "no memory for encapsulated packet.");
2324 memset(&ds, 0,
sizeof(ds));
2326 log_error(
"forw_dhcpv4_response: no memory buffer.");
2330 ds.data = ds.buffer->data;
2331 ds.len = enc_opt_data.len + 16;
2332 memcpy(ds.buffer->data, enc_opt_data.data, enc_opt_data.len);
2333 memcpy(ds.buffer->data + enc_opt_data.len,
2340 cc = send(dhcp4o6_fd, ds.data, ds.len, 0);
2342 log_error(
"forw_dhcpv4_response: send(): %m");
2356 static void recv_dhcpv4_response(
struct data_string *raw)
2362 log_error(
"recv_dhcpv4_response: no interfaces.");
2367 memcpy(from.iabuf, raw->
data + (raw->
len - 16), 16);
2374 log_error(
"recv_dhcpv4_response: no memory for packet.");
2386 log_error(
"recv_dhcpv4_response: no memory for options.");
2407 memset(&dp, 0,
sizeof dp);
2441 const char *
name =
packet -> packet_type ?
"DHCPOFFER" :
"BOOTREPLY";
2450 for (client =
ip -> client; client; client = client -> next)
2451 if (client -> xid ==
packet -> raw -> xid)
2458 (
packet -> interface -> hw_address.hlen - 1 !=
2459 packet -> raw -> hlen) ||
2460 (memcmp (&
packet -> interface -> hw_address.hbuf [1],
2463 log_debug (
"%s in wrong transaction.", name);
2468 sprintf (obuf,
"%s of %s from %s", name,
2477 for (i = 0 ; req[i] != NULL ; i++) {
2484 option_code_hash_lookup(&
option,
2489 log_info(
"%s: no %s option.", obuf,
2492 log_info(
"%s: no unknown-%u option.",
2504 if (
lease -> address.len ==
sizeof packet -> raw -> yiaddr &&
2505 !memcmp (
lease -> address.iabuf,
2506 &
packet -> raw -> yiaddr,
lease -> address.len)) {
2514 log_info (
"%s: packet_to_lease failed.", obuf);
2523 if (!
packet -> options_valid || !
packet -> packet_type)
2524 lease -> is_bootp = 1;
2527 lease -> medium = client -> medium;
2530 stop_selecting = (client -> first_sending +
2531 client -> config -> select_interval);
2535 if (
lease -> address.len == client -> requested_address.len &&
2536 !memcmp (
lease -> address.iabuf,
2537 client -> requested_address.iabuf,
2538 client -> requested_address.len)) {
2539 lease -> next = client -> offered_leases;
2540 client -> offered_leases =
lease;
2544 if (!client -> offered_leases)
2545 client -> offered_leases =
lease;
2547 for (lp = client -> offered_leases; lp ->
next;
2557 if (stop_selecting <=
cur_tv.tv_sec)
2560 tv.tv_sec = stop_selecting;
2561 tv.tv_usec =
cur_tv.tv_usec;
2583 log_error(
"packet_to_lease: no memory to record lease.\n");
2594 lease->address.len);
2598 lease->next_srv_addr.len);
2600 memset(&data, 0,
sizeof(data));
2602 if (client -> config -> vendor_space_name) {
2608 client -> config -> vendor_space_name &&
2610 (
struct lease *)0, client,
2614 if (!option_code_hash_lookup(&
option,
2618 "option (%s:%d).",
MDL);
2622 client -> config -> vendor_space_name
2648 if (!(i & 2) &&
packet -> raw -> sname [0]) {
2652 if (!
packet -> raw -> sname [len])
2656 log_error (
"dhcpoffer: no memory for server name.\n");
2661 packet -> raw -> sname, len);
2675 log_error (
"dhcpoffer: no memory for filename.\n");
2700 for (client =
ip -> client; client; client = client ->
next)
2708 packet -> raw -> hlen) ||
2712 log_debug (
"DHCPNAK in wrong transaction.");
2731 log_info (
"DHCPNAK with no active lease.\n");
2764 client -> state =
S_INIT;
2783 interval =
cur_time - client -> first_sending;
2787 if (interval > client -> config ->
timeout) {
2795 if (!client -> offered_leases &&
2796 client -> config -> media) {
2799 if (client -> medium) {
2800 client -> medium = client -> medium -> next;
2803 if (!client -> medium) {
2805 log_fatal (
"No valid media types for %s!",
2806 client -> interface -> name);
2808 client -> config -> media;
2812 log_info (
"Trying medium \"%s\" %d",
2813 client -> medium ->
string, increase);
2841 if (
cur_time + client -> interval >
2842 client -> first_sending + client -> config ->
timeout)
2843 client -> interval =
2844 (client -> first_sending +
2848 if (interval < 65536)
2849 client ->
packet.secs = htons (interval);
2851 client ->
packet.secs = htons (65535);
2852 client -> secs = client ->
packet.secs;
2854 #if defined(DHCPv6) && defined(DHCP4o6) 2856 log_info (
"DHCPDISCOVER interval %ld",
2857 (
long)(client -> interval));
2860 log_info (
"DHCPDISCOVER on %s to %s port %d interval %ld (xid=0x%x)",
2861 client -> name ? client -> name : client -> interface -> name,
2863 ntohs (
sockaddr_broadcast.sin_port), (
long)(client -> interval), ntohl(client -> xid));
2866 #if defined(DHCPv6) && defined(DHCP4o6) 2868 result = send_dhcpv4_query(client, 1);
2875 #if defined(DHCPv6) && defined(DHCP4o6) 2877 log_error(
"%s:%d: Failed to send %d byte long packet.",
2881 log_error(
"%s:%d: Failed to send %d byte long packet over %s " 2893 tv.tv_usec = client->
interval > 1 ? random() % 1000000 :
cur_tv.tv_usec;
2910 loop = lp = client -> active;
2912 log_info (
"No DHCPOFFERS received.");
2916 if (!client -> active && client -> leases)
2920 while (client -> active) {
2921 if (client -> active -> expiry >
cur_time) {
2922 log_info (
"Trying recorded lease %s",
2923 piaddr (client -> active -> address));
2927 client -> active -> medium);
2930 if (client -> alias)
2938 if (cur_time < client -> active -> renewal) {
2940 log_info (
"bound: renewal in %ld %s.",
2941 (
long)(client -> active -> renewal -
2946 random() % 1000000 :
2951 log_info (
"bound: immediate renewal.");
2961 if (!client -> leases) {
2962 client -> leases = client -> active;
2970 for (lp = client -> leases; lp ->
next; lp = lp ->
next)
2972 lp ->
next = client -> active;
2976 client -> active = client -> leases;
2977 client -> leases = client -> leases ->
next;
2982 if (client -> active == loop)
2985 loop = client -> active;
2993 log_info (
"Unable to obtain a lease on first try.%s",
2997 #if defined (CALL_SCRIPT_ON_ONETRY_FAIL) 3005 log_info (
"No working leases in persistent database - sleeping.");
3007 if (client -> alias)
3010 client -> state =
S_INIT;
3013 tv.tv_usec = ((tv.tv_sec -
cur_tv.tv_sec) > 1) ?
3014 random() % 1000000 :
cur_tv.tv_usec;
3026 struct sockaddr_in destination;
3027 struct in_addr from;
3030 const char* rip_str =
"";
3033 interval =
cur_time - client -> first_sending;
3047 interval > client -> config -> reboot_timeout) {
3049 client -> state =
S_INIT;
3058 !client -> medium &&
3059 client -> active -> medium ) {
3060 script_init(client,
"MEDIUM", client -> active -> medium);
3067 client -> medium = client -> active -> medium;
3073 cur_time > client -> active -> expiry) {
3078 if (client -> alias)
3086 if (client -> alias)
3091 client -> state =
S_INIT;
3097 if (!client -> interval)
3098 client -> interval = client -> config -> initial_interval;
3100 client -> interval += ((random () >> 2) %
3101 (2 * client -> interval));
3105 if (client -> interval >
3106 client -> config -> backoff_cutoff)
3107 client -> interval =
3108 ((client -> config -> backoff_cutoff / 2)
3109 + ((random () >> 2) %
3110 client -> config -> backoff_cutoff));
3115 cur_time + client -> interval > client -> active -> expiry)
3116 client -> interval =
3117 client -> active -> expiry -
cur_time + 1;
3123 cur_time > client -> active -> rebind)
3126 memcpy (&destination.sin_addr.s_addr,
3127 client -> destination.iabuf,
3128 sizeof destination.sin_addr.s_addr);
3130 destination.sin_family = AF_INET;
3132 destination.sin_len =
sizeof destination;
3137 memcpy (&from, client -> active -> address.iabuf,
3140 from.s_addr = INADDR_ANY;
3144 client ->
packet.secs = client -> secs;
3146 if (interval < 65536)
3147 client ->
packet.secs = htons (interval);
3149 client ->
packet.secs = htons (65535);
3152 #if defined(DHCPv6) && defined(DHCP4o6) 3157 memset(rip_buf, 0x0,
sizeof(rip_buf));
3165 strncpy(rip_buf, rip_str,
sizeof(rip_buf)-1);
3166 log_info (
"DHCPREQUEST for %s on %s to %s port %d (xid=0x%x)",
3169 inet_ntoa(destination.sin_addr),
3170 ntohs (destination.sin_port),
3171 ntohl(client -> xid));
3173 #if defined(DHCPv6) && defined(DHCP4o6) 3176 if (destination.sin_addr.s_addr == INADDR_BROADCAST)
3178 result = send_dhcpv4_query(client, broadcast);
3180 log_error(
"%s:%d: Failed to send %d byte long packet.",
3185 if (destination.sin_addr.s_addr != INADDR_BROADCAST &&
3187 #if defined(SO_BINDTODEVICE) 3191 log_error(
"%s:%d: Failed to bind fallback interface" 3199 log_error(
"%s:%d: Failed to send %d byte long packet " 3200 "over %s interface.",
MDL,
3204 #if defined(SO_BINDTODEVICE) 3206 SO_BINDTODEVICE, NULL, 0) < 0) {
3207 log_fatal(
"%s:%d: Failed to unbind fallback interface:" 3218 log_error(
"%s:%d: Failed to send %d byte long packet" 3219 " over %s interface.",
MDL,
3226 tv.tv_usec = ((tv.tv_sec -
cur_tv.tv_sec) > 1) ?
3227 random() % 1000000 :
cur_tv.tv_usec;
3238 #if defined(DHCPv6) && defined(DHCP4o6) 3243 log_info (
"DHCPDECLINE of %s on %s to %s port %d (xid=0x%x)",
3248 ntohl(client ->
xid));
3252 #if defined(DHCPv6) && defined(DHCP4o6) 3254 result = send_dhcpv4_query(client, 1);
3261 #if defined(DHCPv6) && defined(DHCP4o6) 3263 log_error(
"%s:%d: Failed to send %d byte long packet.",
3267 log_error(
"%s:%d: Failed to send %d byte long packet over %s" 3279 struct sockaddr_in destination;
3280 struct in_addr from;
3282 memcpy (&from, client -> active -> address.iabuf,
3284 memcpy (&destination.sin_addr.s_addr,
3285 client -> destination.iabuf,
3286 sizeof destination.sin_addr.s_addr);
3288 destination.sin_family = AF_INET;
3290 destination.sin_len =
sizeof destination;
3295 client -> active -> expiry =
3296 client -> active -> renewal =
3297 client -> active -> rebind =
cur_time;
3299 log_error (
"Can't release lease: lease write failed.");
3303 #if defined(DHCPv6) && defined(DHCP4o6) 3308 log_info (
"DHCPRELEASE of %s on %s to %s port %d (xid=0x%x)",
3311 inet_ntoa (destination.sin_addr),
3312 ntohs (destination.sin_port),
3313 ntohl(client -> xid));
3315 #if defined(DHCPv6) && defined(DHCP4o6) 3318 if (destination.sin_addr.s_addr == INADDR_BROADCAST)
3320 result = send_dhcpv4_query(client, broadcast);
3322 log_error(
"%s:%d: Failed to send %d byte long packet.",
3328 #if defined(SO_BINDTODEVICE) 3332 log_error(
"%s:%d: Failed to bind fallback interface" 3340 log_error(
"%s:%d: Failed to send %d byte long packet" 3341 " over %s interface.",
MDL,
3345 #if defined(SO_BINDTODEVICE) 3347 SO_BINDTODEVICE, NULL, 0) < 0) {
3348 log_fatal(
"%s:%d: Failed to unbind fallback interface:" 3358 log_error (
"%s:%d: Failed to send %d byte long packet" 3359 " over %s interface.",
MDL,
3367 #if defined(DHCPv6) && defined(DHCP4o6) 3379 static int send_dhcpv4_query(
struct client_state *client,
int broadcast) {
3384 if (dhcp4o6_state <= 0) {
3385 log_info(
"send_dhcpv4_query: not ready.");
3395 memset(&ds, 0,
sizeof(ds));
3397 log_error(
"Unable to allocate memory for DHCPv4-query.");
3400 ds.data = ds.buffer->data;
3425 cc = send(dhcp4o6_fd, ds.data, ds.len, 0);
3427 log_error(
"send_dhcpv4_query: send(): %m");
3440 static void forw_dhcpv4_query(
struct data_string *raw) {
3446 struct sockaddr_in6 sin6;
3447 int i, send_ret, attempt, success;
3449 attempt = success = 0;
3450 memset(&sin6, 0,
sizeof(sin6));
3451 sin6.sin6_family = AF_INET6;
3454 sin6.sin6_len =
sizeof(sin6);
3456 memset(&addrs, 0,
sizeof(addrs));
3458 for (client =
ip->client; client != NULL;
3459 client = client->
next) {
3472 lease->options, NULL,
3474 ((addrs.len %
sizeof(sin6.sin6_addr)) != 0)) {
3478 if (addrs.len == 0) {
3486 if (send_ret == raw->
len)
3490 for (i = 0; i < addrs.len;
3491 i +=
sizeof(sin6.sin6_addr)) {
3492 memcpy(&sin6.sin6_addr, addrs.data + i,
3493 sizeof(sin6.sin6_addr));
3497 if (send_ret == raw->
len)
3504 log_info(
"forw_dhcpv4_query: sent(%d): %d/%d",
3505 raw->
len, success, attempt);
3521 struct buffer *bp = NULL;
3544 log_error (
"can't make requested address cache.");
3570 for (i = 0 ; prl[i] != NULL ; i++)
3575 log_error(
"can't make parameter list buffer.");
3580 for (i = 0 ; prl[i] != NULL ; i++)
3584 if (!(option_code_hash_lookup(&
option,
3609 memset(&client_identifier, 0,
sizeof(client_identifier));
3612 client_identifier.
len,
MDL))
3613 log_fatal(
"no memory for default DUID!");
3631 memcpy(&client_identifier.
buffer->
data + 5 - hw_len,
3636 memcpy(&client_identifier.
buffer->
data+(1+4),
3643 (u_int8_t *)client_identifier.
data,
3644 client_identifier.
len,
3646 log_error (
"can't make requested client id cache..");
3670 memset (&client ->
packet, 0,
sizeof (client ->
packet));
3675 client -> config -> requested_options,
3679 client -> packet_length =
3681 (
struct lease *)0, client,
3690 client -> config -> vendor_space_name);
3697 client ->
packet.htype = client ->
interface -> hw_address.hbuf [0];
3699 client ->
packet.hlen = client ->
interface -> hw_address.hlen - 1;
3700 client ->
packet.hops = 0;
3701 client ->
packet.xid = random ();
3702 client ->
packet.secs = 0;
3706 client ->
packet.flags = 0;
3710 memset (&(client ->
packet.ciaddr),
3711 0,
sizeof client ->
packet.ciaddr);
3712 memset (&(client ->
packet.yiaddr),
3713 0,
sizeof client ->
packet.yiaddr);
3714 memset (&(client ->
packet.siaddr),
3715 0,
sizeof client ->
packet.siaddr);
3717 if (client -> interface -> hw_address.hlen > 0)
3718 memcpy (client ->
packet.chaddr,
3719 &client -> interface -> hw_address.hbuf [1],
3720 (
unsigned)(client -> interface -> hw_address.hlen - 1));
3723 dump_raw ((
unsigned char *)&client ->
packet, client -> packet_length);
3735 memset (&client ->
packet, 0,
sizeof (client ->
packet));
3743 if (client -> sent_options)
3750 : (
struct iaddr *)0),
3751 client -> config -> requested_options,
3752 &client -> sent_options);
3755 client -> packet_length =
3757 (
struct lease *)0, client,
3760 client -> sent_options,
3766 client -> config -> vendor_space_name);
3772 client ->
packet.htype = client ->
interface -> hw_address.hbuf [0];
3774 client ->
packet.hlen = client ->
interface -> hw_address.hlen - 1;
3775 client ->
packet.hops = 0;
3776 client ->
packet.xid = client -> xid;
3777 client ->
packet.secs = 0;
3781 if (client -> state ==
S_BOUND ||
3784 memcpy (&client ->
packet.ciaddr,
3785 lease -> address.iabuf,
lease -> address.len);
3786 client ->
packet.flags = 0;
3788 memset (&client ->
packet.ciaddr, 0,
3789 sizeof client ->
packet.ciaddr);
3791 client ->config->bootp_broadcast_always)) &&
3793 client ->
packet.flags = 0;
3798 memset (&client ->
packet.yiaddr, 0,
3799 sizeof client ->
packet.yiaddr);
3800 memset (&client ->
packet.siaddr, 0,
3801 sizeof client ->
packet.siaddr);
3802 if (client -> state !=
S_BOUND &&
3806 memset (&client ->
packet.giaddr, 0,
3807 sizeof client ->
packet.giaddr);
3808 if (client -> interface -> hw_address.hlen > 0)
3809 memcpy (client ->
packet.chaddr,
3810 &client -> interface -> hw_address.hbuf [1],
3811 (
unsigned)(client -> interface -> hw_address.hlen - 1));
3814 dump_raw ((
unsigned char *)&client ->
packet, client -> packet_length);
3834 memset (&client ->
packet, 0,
sizeof (client ->
packet));
3835 client -> packet_length =
3837 (
struct lease *)0, client, 0,
3840 client -> config -> vendor_space_name);
3849 client ->
packet.htype = client ->
interface -> hw_address.hbuf [0];
3851 client ->
packet.hlen = client ->
interface -> hw_address.hlen - 1;
3852 client ->
packet.hops = 0;
3853 client ->
packet.xid = client -> xid;
3854 client ->
packet.secs = 0;
3857 client ->
packet.flags = 0;
3862 memset (&client ->
packet.ciaddr, 0,
3863 sizeof client ->
packet.ciaddr);
3864 memset (&client ->
packet.yiaddr, 0,
3865 sizeof client ->
packet.yiaddr);
3866 memset (&client ->
packet.siaddr, 0,
3867 sizeof client ->
packet.siaddr);
3869 memcpy (client ->
packet.chaddr,
3870 &client -> interface -> hw_address.hbuf [1],
3871 client -> interface -> hw_address.hlen);
3874 dump_raw ((
unsigned char *)&client ->
packet, client -> packet_length);
3887 memset (&client ->
packet, 0,
sizeof (client ->
packet));
3894 client -> packet_length =
3896 (
struct lease *)0, client,
3905 client -> config -> vendor_space_name);
3912 client ->
packet.htype = client ->
interface -> hw_address.hbuf [0];
3914 client ->
packet.hlen = client ->
interface -> hw_address.hlen - 1;
3915 client ->
packet.hops = 0;
3916 client ->
packet.xid = random ();
3917 client ->
packet.secs = 0;
3918 client ->
packet.flags = 0;
3919 memcpy (&client ->
packet.ciaddr,
3920 lease -> address.iabuf,
lease -> address.len);
3921 memset (&client ->
packet.yiaddr, 0,
3922 sizeof client ->
packet.yiaddr);
3923 memset (&client ->
packet.siaddr, 0,
3924 sizeof client ->
packet.siaddr);
3926 memcpy (client ->
packet.chaddr,
3927 &client -> interface -> hw_address.hbuf [1],
3928 client -> interface -> hw_address.hlen);
3931 dump_raw ((
unsigned char *)&client ->
packet, client -> packet_length);
3970 for (client =
ip -> client; client; client = client ->
next) {
3971 for (lp = client -> leases; lp; lp = lp ->
next) {
3974 if (client -> active)
3976 client -> active, 1, 0);
3991 for (client =
ip -> client; client; client = client ->
next) {
3992 for (lp = client -> leases; lp; lp = lp ->
next) {
3995 if (client -> active)
3997 client -> active, 1, 0);
4019 const char *name, *dot;
4021 char *preamble = stuff;
4023 memset (&ds, 0,
sizeof ds);
4033 in_options, cfg_options, scope, oc,
MDL)) {
4035 fprintf(
leaseFile,
"%soption %s%s%s", preamble,
4056 const char *preamble)
4069 if (c >=
'0' && c <=
'9')
4072 if (c >=
'a' && c <=
'f')
4073 return c -
'a' + 10;
4075 if (c >=
'A' && c <=
'F')
4076 return c -
'A' + 10;
4083 const char *id_fname =
"/etc/machine-id";
4086 FILE *
file = fopen( id_fname ,
"r");
4089 return ISC_R_IOERROR;
4091 nread = fread(
id, 1,
sizeof id,
file);
4095 log_debug(
"Not enough data in %s", id_fname);
4096 return ISC_R_IOERROR;
4099 for (j = 0; j < 16; j++) {
4105 if (a < 0 || b < 0) {
4106 log_debug(
"Wrong data in %s", id_fname);
4107 return ISC_R_IOERROR;
4109 uuid[j] = a << 4 | b;
4113 uuid[6] = (uuid[6] & 0x0F) | 0x40;
4115 uuid[8] = (uuid[8] & 0x3F) | 0x80;
4117 return ISC_R_SUCCESS;
4150 log_debug(
"Cannot form default DUID from interface %s.",
ip->name);
4154 return ISC_R_UNEXPECTED;
4157 if ((
ip->hw_address.hlen == 0) ||
4158 (
ip->hw_address.hlen >
sizeof(
ip->hw_address.hbuf)))
4159 log_fatal(
"Impossible hardware address length at %s:%d.",
MDL);
4169 len = 2 +
sizeof (uuid);
4178 len = 4 + (
ip->hw_address.hlen - 1);
4183 log_fatal(
"no memory for default DUID!");
4189 memcpy(duid->
buffer->
data + 2, uuid,
sizeof(uuid));
4196 memcpy(duid->
buffer->
data + 8,
ip->hw_address.hbuf + 1,
4197 ip->hw_address.hlen - 1);
4201 memcpy(duid->
buffer->
data + 4,
ip->hw_address.hbuf + 1,
4202 ip->hw_address.hlen - 1);
4209 log_info(
"form_duid: Couldn't allocate memory to log duid!");
4215 return ISC_R_SUCCESS;
4225 if ((duid == NULL) || (duid->
len <= 2))
4232 return ISC_R_IOERROR;
4240 return ISC_R_NOMEMORY;
4242 stat = fprintf(
leaseFile,
"default-duid %s;\n", str);
4245 return ISC_R_IOERROR;
4248 return ISC_R_IOERROR;
4250 return ISC_R_SUCCESS;
4256 int rewrite,
int sync)
4267 return ISC_R_SUCCESS;
4270 if (client == NULL ||
lease == NULL)
4277 return ISC_R_IOERROR;
4281 stat = fprintf(
leaseFile,
"lease6 {\n");
4283 return ISC_R_IOERROR;
4285 stat = fprintf(
leaseFile,
" interface \"%s\";\n",
4288 return ISC_R_IOERROR;
4290 for (ia =
lease->bindings ; ia != NULL ; ia = ia->
next) {
4311 (
const unsigned char *) &ia->
iaid, 4,
4316 return ISC_R_IOERROR;
4327 stat = fprintf(
leaseFile,
" %s %s {\n", ianame,
4333 return ISC_R_IOERROR;
4336 stat = fprintf(
leaseFile,
" starts %d;\n" 4341 stat = fprintf(
leaseFile,
" starts %d;\n",
4344 return ISC_R_IOERROR;
4346 for (addr = ia->
addrs ; addr != NULL ; addr = addr->
next) {
4353 " iaprefix %s/%d {\n",
4357 return ISC_R_IOERROR;
4359 stat = fprintf(
leaseFile,
" starts %d;\n" 4360 " preferred-life %u;\n" 4365 return ISC_R_IOERROR;
4368 write_options(client, addr->
options,
" ");
4372 return ISC_R_IOERROR;
4376 write_options(client, ia->
options,
" ");
4380 return ISC_R_IOERROR;
4383 if (
lease->released) {
4384 stat = fprintf(
leaseFile,
" released;\n");
4386 return ISC_R_IOERROR;
4389 if (
lease->options != NULL)
4390 write_options(client,
lease->options,
" ");
4394 return ISC_R_IOERROR;
4397 return ISC_R_IOERROR;
4401 log_error(
"write_client_lease: fsync(): %m");
4402 return ISC_R_IOERROR;
4406 return ISC_R_SUCCESS;
4429 if (
lease -> is_static)
4442 if (
lease -> is_bootp) {
4449 fprintf (
leaseFile,
" interface \"%s\";\n",
4450 client -> interface -> name);
4455 if (client -> name) {
4456 fprintf (
leaseFile,
" name \"%s\";\n", client -> name);
4462 fprintf (
leaseFile,
" fixed-address %s;\n",
4468 if (
lease -> filename) {
4471 fprintf (
leaseFile,
" filename \"%s\";\n", s);
4481 if (
lease->server_name != NULL) {
4484 fprintf(
leaseFile,
" server-name \"%s\";\n", s);
4493 if (
lease -> medium) {
4496 fprintf (
leaseFile,
" medium \"%s\";\n", s);
4510 memset (&ds, 0,
sizeof ds);
4512 write_options(client,
lease->options,
" ");
4516 fprintf(
leaseFile,
" renew %s\n", tval) < 0)
4521 fprintf(
leaseFile,
" rebind %s\n", tval) < 0)
4526 fprintf(
leaseFile,
" expire %s\n", tval) < 0)
4537 if (!errors && makesure) {
4539 log_info (
"write_client_lease: %m");
4544 return errors ? 0 : 1;
4571 for (sl = client -> env; sl; sl =
next) {
4578 if (client -> interface) {
4580 client -> interface -> name);
4584 "",
"client",
"%s", client -> name);
4587 "",
"medium",
"%s", medium ->
string);
4590 client_envadd (client,
"",
"pid",
"%ld", (
long int)getpid ());
4593 (
long int)dad_wait_time);
4611 in_options, cfg_options, scope, oc,
MDL)) {
4621 length = strlen(value);
4625 value, length) == 0) {
4630 "option - discarded",
4674 if (
lease->next_srv_addr.len != 0) {
4686 memset (&data, 0,
sizeof data);
4717 (&data, (
struct packet *)0,
4718 (
struct lease *)0, client,
4723 if (broadcast.
len) {
4725 prefix,
"broadcast_address",
4726 "%s",
piaddr (broadcast));
4734 if (
lease->filename) {
4737 strlen(
lease->filename)) == 0) {
4739 "%s",
lease->filename);
4742 "option - discarded",
4747 if (
lease->server_name) {
4750 strlen(
lease->server_name)) == 0 ) {
4752 "%s",
lease->server_name);
4755 "option - discarded",
4756 lease->server_name);
4769 (
unsigned long)(
lease -> expiry));
4791 for (i = 0 ; req[i] != NULL ; i++) {
4816 char reason [] =
"REASON=NBI";
4817 static char client_path [] = CLIENT_PATH;
4820 int pid, wpid, wstatus;
4823 scriptName = client -> config -> script_name;
4827 envp =
dmalloc (((client ? client -> envc : 2) +
4830 log_error (
"No memory for client script environment.");
4837 envp [i++] = sp ->
string;
4841 for (sp = client -> env; sp; sp = sp ->
next) {
4842 envp [i++] = sp ->
string;
4845 envp [i++] = reason;
4848 envp [i++] = client_path;
4849 envp [i] = (
char *)0;
4852 argv [1] = (
char *)0;
4860 wpid = wait (&wstatus);
4861 }
while (wpid != pid && wpid > 0);
4878 for (sp = client -> env; sp; sp =
next) {
4886 gettimeofday(&
cur_tv, NULL);
4887 return (WIFEXITED (wstatus) ?
4888 WEXITSTATUS (wstatus) : -WTERMSIG (wstatus));
4892 const char *prefix,
const char *name,
const char *fmt, ...)
4900 va_start (list, fmt);
4901 len = vsnprintf (spbuf,
sizeof spbuf, fmt, list);
4904 val =
dmalloc (strlen (prefix) + strlen (name) + 1 +
4905 len +
sizeof *val,
MDL);
4907 log_error (
"client_envadd: cannot allocate space for variable");
4916 if (len >=
sizeof spbuf) {
4917 va_start (list, fmt);
4918 vsnprintf (s, len + 1, fmt, list);
4924 val ->
next = client -> env;
4925 client -> env = val;
4948 if (j + 1 == buflen)
4958 if (j + 1 == buflen)
4973 if (write(
dfd[1], &ret, 1) != 1)
4975 (void) close(
dfd[1]);
4991 if (
dfd[0] == -1 ||
dfd[1] == -1)
4995 if (write(
dfd[1], &buf, 1) != 1)
4997 (void) close(
dfd[1]);
5012 (void) open(
"/dev/null", O_RDWR | O_CLOEXEC);
5013 (void) open(
"/dev/null", O_RDWR | O_CLOEXEC);
5014 (void) open(
"/dev/null", O_RDWR | O_CLOEXEC);
5032 pfdesc = open (
path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644);
5039 pf = fdopen (pfdesc,
"we");
5044 fprintf (pf,
"%ld\n", (
long)getpid ());
5055 for (client =
ip -> client; client; client = client ->
next) {
5056 switch (client ->
state) {
5089 #if defined(DHCPv6) && defined(DHCP4o6) 5091 if (dhcp4o6_state < 0)
5099 client -> xid = random ();
5102 if (client -> active) {
5107 memset (&ds, 0,
sizeof ds);
5109 client -> active -> options,
5113 (
struct lease *)0, client,
5115 client -> active -> options,
5118 memcpy (client -> destination.iabuf,
5120 client -> destination.len = 4;
5127 client -> first_sending =
cur_time;
5128 client -> interval = client -> config -> initial_interval;
5139 if (client -> alias)
5155 #if defined(DHCPv6) && defined(DHCP4o6) 5178 interface_reference (&
ip, last ->
next,
MDL);
5179 interface_dereference (&last ->
next,
MDL);
5181 interface_reference (&last ->
next,
5183 interface_dereference (&
ip ->
next,
5188 interface_reference (&
ip,
5194 interface_dereference (&
ip ->
next,
5201 tmp ->
client ->
interface = tmp;
5203 interface_dereference (&
ip,
MDL);
5252 for (client =
ip->client ; client ; client = client->
next) {
5257 return ISC_R_SUCCESS;
5283 static void shutdown_exit (
void *foo)
5291 #if defined (NSUPDATE) 5308 isc_result_t eresult)
5311 isc_result_t result;
5313 if ((eresult == ISC_R_SUCCESS) &&
5319 if (result == ISC_R_SUCCESS) {
5325 dhclient_ddns_cb_free(ddns_cb,
MDL);
5334 isc_result_t result;
5337 if (client->
ddns_cb != NULL) {
5343 if (ddns_cb != NULL) {
5349 ddns_cb->
cur_func = client_dns_remove_action;
5353 if (result != ISC_R_TIMEDOUT) {
5354 dhclient_ddns_cb_free(ddns_cb,
MDL);
5370 return ISC_R_SUCCESS;
5374 log_info(
"Received signal %d, initiating shutdown.",
5383 for (client =
ip -> client; client; client = client -> next) {
5386 return ISC_R_SUCCESS;
5389 return ISC_R_SUCCESS;
5392 if (client -> active &&
5393 client -> active -> expiry >
cur_time) {
5394 #if defined (NSUPDATE) 5422 tv.tv_sec =
cur_tv.tv_sec;
5423 tv.tv_usec =
cur_tv.tv_usec + 1;
5426 return ISC_R_SUCCESS;
5429 #if defined (NSUPDATE) 5440 isc_result_t status = ISC_R_FAILURE;
5442 if ((client != NULL) &&
5443 ((client->
active != NULL) ||
5456 if (status != ISC_R_TIMEDOUT) {
5492 isc_result_t eresult)
5494 isc_result_t result;
5511 ddns_cb->
cur_func = client_dns_update_action;
5514 if (result == ISC_R_SUCCESS) {
5520 case ISC_R_TIMEDOUT:
5528 if (ddns_cb->
zone != NULL) {
5534 ddns_cb->
cur_func = client_dns_update_action;
5540 tv.tv_usec =
cur_tv.tv_usec;
5542 ddns_cb, NULL, NULL);
5546 dhclient_ddns_cb_free(ddns_cb,
MDL);
5564 if (!client -> sent_options)
5565 return ISC_R_SUCCESS;
5569 return ISC_R_SUCCESS;
5575 (
struct lease *)0, client,
5576 client -> sent_options,
5579 return ISC_R_SUCCESS;
5586 (
struct lease *)0, client,
5587 client -> sent_options,
5590 return ISC_R_SUCCESS;
5596 (
struct lease *)0, client,
5597 client -> sent_options,
5600 return ISC_R_SUCCESS;
5612 memset(&client_identifier, 0,
sizeof(client_identifier));
5636 client_identifier.data,
5637 client_identifier.len);
5655 (client_identifier.data[0] == 255)) {
5660 if (client_identifier.len <= 5)
5661 log_fatal(
"Impossible condition at %s:%d.",
5664 client_identifier.data + 5,
5665 client_identifier.len - 5);
5667 result =
get_dhcid(ddns_cb, ddns_v4_type,
5668 client_identifier.data,
5669 client_identifier.len);
5679 return ISC_R_SUCCESS;
5688 rcode = ISC_R_FAILURE;
5694 if (rcode == ISC_R_SUCCESS) {
5695 rcode = ISC_R_TIMEDOUT;
5718 if (client->
ddns_cb != NULL) {
5725 if (ddns_cb != NULL) {
5726 ddns_cb->
lease = (
void *)client;
5739 ddns_cb->
cur_func = client_dns_update_action;
5743 tv.tv_sec =
cur_tv.tv_sec + offset;
5744 tv.tv_usec =
cur_tv.tv_usec;
5746 ddns_cb, NULL, NULL);
5748 log_error(
"Unable to allocate dns update state for %s",
5757 struct servent *ent;
5771 ent = getservbyname(
"dhcpc",
"udp");
5773 ent = getservbyname(
"bootpc",
"udp");
5778 #ifndef __CYGWIN32__ 5802 static int check_domain_name(
const char *ptr,
size_t len,
int dots)
5807 if ((len == 0) || (len > 256))
5812 for (p=ptr; (*p != 0) && (len-- > 0); p++) {
5813 if ((*p ==
'-') || (*p ==
'_')) {
5815 if (((p - ptr) == 0) || (len == 0) || (p[1] ==
'.'))
5817 }
else if (*p ==
'.') {
5821 if ((d <= 0) || (d >= 64))
5824 if ((dots > 0) && (len > 0))
5826 }
else if (isalnum((
unsigned char)*p) == 0) {
5831 return(dots ? -1 : 0);
5834 static int check_domain_name_list(
const char *ptr,
size_t len,
int dots)
5839 if ((ptr == NULL) || (len == 0))
5842 for (p=ptr; (*p != 0) && (len > 0); p++, len--) {
5846 if (check_domain_name(ptr, p - ptr, dots) != 0)
5853 return(check_domain_name(ptr, p - ptr, dots));
5870 #ifdef ACCEPT_LIST_IN_DOMAIN_NAME 5871 return check_domain_name_list(ptr, len, 0);
5873 return check_domain_name(ptr, len, 0);
5878 return check_domain_name(ptr, len, 0);
5881 return check_domain_name_list(ptr, len, 0);
5886 for (; (*ptr != 0) && (len-- > 0); ptr++) {
5887 if(!(isalnum((
unsigned char)*ptr) ||
5888 *ptr ==
'#' || *ptr ==
'%' ||
5889 *ptr ==
'+' || *ptr ==
'-' ||
5890 *ptr ==
'_' || *ptr ==
':' ||
5891 *ptr ==
'.' || *ptr ==
',' ||
5892 *ptr ==
'@' || *ptr ==
'~' ||
5893 *ptr ==
'\\' || *ptr ==
'/' ||
5894 *ptr ==
'[' || *ptr ==
']' ||
5895 *ptr ==
'=' || *ptr ==
' '))
5910 return check_domain_name_list(ptr, len, 0);
5925 log_fatal (
"no memory for reject list!");
5944 log_info(
"Server added to list of rejected servers.");
5953 if (client != NULL) {
5961 #if defined(DHCPv6) && defined(DHCP4o6) 5980 char start_msg[5] = {
'S',
'T',
'A',
'R',
'T' };
5981 char stop_msg[4] = {
'S',
'T',
'O',
'P' };
5982 char poll_msg[4] = {
'P',
'O',
'L',
'L' };
5986 if (h->type != dhcp4o6_type)
5989 cc = recv(dhcp4o6_fd, buf,
sizeof(buf), 0);
5991 return ISC_R_UNEXPECTED;
5995 (memcmp(buf, poll_msg,
sizeof(poll_msg)) == 0)) {
5997 if (dhcp4o6_state < 0)
5998 cc = send(dhcp4o6_fd, stop_msg,
5999 sizeof(stop_msg), 0);
6001 cc = send(dhcp4o6_fd, start_msg,
6002 sizeof(start_msg), 0);
6004 log_error(
"dhcpv4o6_handler: send(): %m");
6005 return ISC_R_IOERROR;
6009 return ISC_R_UNEXPECTED;
6010 memset(&raw, 0,
sizeof(raw));
6013 "no memory buffer.");
6014 return ISC_R_NOMEMORY;
6020 forw_dhcpv4_query(&raw);
6026 (memcmp(buf, stop_msg,
sizeof(stop_msg)) == 0)) {
6028 if (dhcp4o6_state > 0) {
6032 }
else if ((cc == 5) &&
6033 (memcmp(buf, start_msg,
sizeof(start_msg)) == 0)) {
6035 if (dhcp4o6_state == 0)
6041 return ISC_R_UNEXPECTED;
6042 memset(&raw, 0,
sizeof(raw));
6045 "no memory buffer.");
6046 return ISC_R_NOMEMORY;
6052 recv_dhcpv4_response(&raw);
6058 return ISC_R_SUCCESS;
6069 static void dhcp4o6_poll(
void *dummy) {
6070 char msg[4] = {
'P',
'O',
'L',
'L' };
6076 if (dhcp4o6_state < 0)
6081 cc = send(dhcp4o6_fd, msg,
sizeof(msg), 0);
6086 tv.tv_usec = random() % 1000000;
6098 static void dhcp4o6_resume() {
6103 for (client =
ip->client; client != NULL;
6104 client = client->
next) {
6127 char msg[5] = {
'S',
'T',
'A',
'R',
'T' };
6130 memset(&addrs, 0,
sizeof(addrs));
6132 for (client =
ip->client; client != NULL;
6133 client = client->
next) {
6146 lease->options, NULL,
6149 if ((addrs.len % 16) != 0) {
6162 if (dhcp4o6_state == 1)
6164 log_info(
"dhcp4o6_start: go to UP");
6167 cc = send(dhcp4o6_fd, msg,
sizeof(msg), 0);
6169 log_info(
"dhcp4o6_start: send(): %m");
6179 static void dhcp4o6_stop() {
6180 char msg[4] = {
'S',
'T',
'O',
'P' };
6183 if (dhcp4o6_state == -1)
6186 log_info(
"dhcp4o6_stop: go to DOWN");
6189 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 initialize_client_option_spaces()
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)
#define DHCLIENT_DEFAULT_PREFIX_LEN
char * absolute_path(const char *orgpath)
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