Lines Matching refs:ifo
132 add_environ(struct if_options *ifo, const char *value, int uniq) in add_environ() argument
135 char **lst = ifo->environ; in add_environ()
168 ifo->environ = newlist; in add_environ()
331 parse_option(struct if_options *ifo, int opt, const char *arg) in parse_option() argument
349 ifo->options |= DHCPCD_BACKGROUND; in parse_option()
352 strlcpy(ifo->script, arg, sizeof(ifo->script)); in parse_option()
355 ifo->options |= DHCPCD_DEBUG; in parse_option()
358 add_environ(ifo, arg, 1); in parse_option()
362 s = parse_string(ifo->hostname, in parse_option()
368 if (s != 0 && ifo->hostname[0] == '.') { in parse_option()
373 ifo->hostname[s] = '\0'; in parse_option()
375 if (ifo->hostname[0] == '\0') in parse_option()
376 ifo->options &= ~DHCPCD_HOSTNAME; in parse_option()
378 ifo->options |= DHCPCD_HOSTNAME; in parse_option()
382 s = parse_string((char *)ifo->vendorclassid + 1, in parse_option()
390 *ifo->vendorclassid = (uint8_t)s; in parse_option()
393 ifo->options |= DHCPCD_RELEASE; in parse_option()
402 ifo->leasetime = (uint32_t)strtol(arg, NULL, 0); in parse_option()
409 ifo->metric = atoint(arg); in parse_option()
410 if (ifo->metric < 0) { in parse_option()
416 if (make_option_mask(ifo->requestmask, arg, 1) != 0) { in parse_option()
422 ifo->options |= DHCPCD_PERSISTENT; in parse_option()
425 ifo->options |= DHCPCD_QUIET; in parse_option()
428 if (parse_addr(&ifo->req_addr, NULL, arg) != 0) in parse_option()
430 ifo->options |= DHCPCD_REQUEST; in parse_option()
431 ifo->req_mask.s_addr = 0; in parse_option()
435 if (parse_addr(&ifo->req_addr, &ifo->req_mask, in parse_option()
439 ifo->req_addr.s_addr = 0; in parse_option()
440 ifo->req_mask.s_addr = 0; in parse_option()
442 ifo->options |= DHCPCD_INFORM | DHCPCD_PERSISTENT; in parse_option()
443 ifo->options &= ~(DHCPCD_ARP | DHCPCD_STATIC); in parse_option()
446 ifo->timeout = atoint(arg); in parse_option()
447 if (ifo->timeout < 0) { in parse_option()
453 s = USERCLASS_MAX_LEN - ifo->userclass[0] - 1; in parse_option()
454 s = parse_string((char *)ifo->userclass + in parse_option()
455 ifo->userclass[0] + 2, in parse_option()
462 ifo->userclass[ifo->userclass[0] + 1] = s; in parse_option()
463 ifo->userclass[0] += s + 1; in parse_option()
476 s = parse_string((char *)ifo->vendor + 1, in parse_option()
482 ifo->vendor[0] = (uint8_t)s; in parse_option()
483 ifo->options |= DHCPCD_VENDORRAW; in parse_option()
488 if (ifo->options & DHCPCD_VENDORRAW) { in parse_option()
489 ifo->options &= ~DHCPCD_VENDORRAW; in parse_option()
490 ifo->vendor[0] = 0; in parse_option()
501 s = VENDOR_MAX_LEN - ifo->vendor[0] - 2; in parse_option()
507 memcpy(ifo->vendor + ifo->vendor[0] + 3, in parse_option()
510 s = parse_string((char *)ifo->vendor + in parse_option()
511 ifo->vendor[0] + 3, s, arg); in parse_option()
518 ifo->vendor[ifo->vendor[0] + 1] = i; in parse_option()
519 ifo->vendor[ifo->vendor[0] + 2] = s; in parse_option()
520 ifo->vendor[0] += s + 2; in parse_option()
524 ifo->options |= DHCPCD_WAITIP; in parse_option()
527 ifo->reboot = atoint(arg); in parse_option()
528 if (ifo->reboot < 0) { in parse_option()
537 ifo->options &= ~DHCPCD_ARP; in parse_option()
539 ifo->options &= ~DHCPCD_IPV4LL; in parse_option()
542 ifo->options &= ~DHCPCD_DAEMONISE; in parse_option()
551 add_environ(ifo, p, 0); in parse_option()
555 ifo->options |= DHCPCD_CLIENTID | DHCPCD_DUID; in parse_option()
558 ifo->options |= DHCPCD_LASTLEASE; in parse_option()
562 ifo->fqdn = FQDN_BOTH; in parse_option()
566 ifo->fqdn = FQDN_NONE; in parse_option()
568 ifo->fqdn = FQDN_PTR; in parse_option()
570 ifo->fqdn = FQDN_BOTH; in parse_option()
572 ifo->fqdn = FQDN_DISABLE; in parse_option()
579 ifo->options &= ~DHCPCD_GATEWAY; in parse_option()
582 ifo->options |= DHCPCD_XID_HWADDR; in parse_option()
586 ifo->clientid[1] = 0; in parse_option()
588 s = parse_string_hwaddr((char *)ifo->clientid + 1, in parse_option()
596 ifo->options |= DHCPCD_CLIENTID; in parse_option()
597 ifo->clientid[0] = (uint8_t)s; in parse_option()
600 ifo->options |= DHCPCD_BROADCAST; in parse_option()
603 ifo->options &= ~DHCPCD_LINK; in parse_option()
606 ifo->options &= ~DHCPCD_IPV4LL; in parse_option()
609 if (make_option_mask(ifo->requestmask, arg, -1) != 0 || in parse_option()
610 make_option_mask(ifo->requiremask, arg, -1) != 0 || in parse_option()
611 make_option_mask(ifo->nomask, arg, 1) != 0) in parse_option()
618 if (make_option_mask(ifo->requiremask, arg, 1) != 0 || in parse_option()
619 make_option_mask(ifo->requestmask, arg, 1) != 0) in parse_option()
633 if (parse_addr(&ifo->req_addr, in parse_option()
634 ifo->req_mask.s_addr == 0 ? &ifo->req_mask : NULL, in parse_option()
638 ifo->options |= DHCPCD_STATIC; in parse_option()
639 ifo->options &= ~DHCPCD_INFORM; in parse_option()
641 if (parse_addr(&ifo->req_mask, NULL, p) != 0) in parse_option()
656 if (ifo->routes == NULL) { in parse_option()
657 rt = ifo->routes = xmalloc(sizeof(*rt)); in parse_option()
659 rt = ifo->routes; in parse_option()
670 if (ifo->routes == NULL) { in parse_option()
671 rt = ifo->routes = xzalloc(sizeof(*rt)); in parse_option()
673 rt = ifo->routes; in parse_option()
686 if (ifo->config != NULL) { in parse_option()
687 while (ifo->config[s] != NULL) { in parse_option()
688 if (strncmp(ifo->config[s], arg, in parse_option()
691 free(ifo->config[s]); in parse_option()
692 ifo->config[s] = xstrdup(arg); in parse_option()
698 ifo->config = xrealloc(ifo->config, in parse_option()
700 ifo->config[s] = xstrdup(arg); in parse_option()
701 ifo->config[s + 1] = NULL; in parse_option()
709 ifo->whitelist = xrealloc(ifo->whitelist, in parse_option()
710 sizeof(in_addr_t) * (ifo->whitelist_len + 2)); in parse_option()
711 ifo->whitelist[ifo->whitelist_len++] = addr.s_addr; in parse_option()
712 ifo->whitelist[ifo->whitelist_len++] = addr2.s_addr; in parse_option()
719 ifo->blacklist = xrealloc(ifo->blacklist, in parse_option()
720 sizeof(in_addr_t) * (ifo->blacklist_len + 2)); in parse_option()
721 ifo->blacklist[ifo->blacklist_len++] = addr.s_addr; in parse_option()
722 ifo->blacklist[ifo->blacklist_len++] = addr2.s_addr; in parse_option()
730 ifo->arping = xrealloc(ifo->arping, in parse_option()
731 sizeof(in_addr_t) * (ifo->arping_len + 1)); in parse_option()
732 ifo->arping[ifo->arping_len++] = addr.s_addr; in parse_option()
735 if (make_option_mask(ifo->dstmask, arg, 2) != 0) { in parse_option()
745 free(ifo->fallback); in parse_option()
746 ifo->fallback = xstrdup(arg); in parse_option()
749 ifo->options &= ~DHCPCD_IPV6RS; in parse_option()
752 ifo->options &= ~DHCPCD_IPV6RA_REQRDNSS; in parse_option()
762 parse_config_line(struct if_options *ifo, const char *opt, char *line) in parse_config_line() argument
778 return parse_option(ifo, cf_options[i].val, line); in parse_config_line()
789 struct if_options *ifo; in read_config() local
796 ifo = xzalloc(sizeof(*ifo)); in read_config()
797 ifo->options |= DHCPCD_GATEWAY | DHCPCD_DAEMONISE | DHCPCD_LINK; in read_config()
798 ifo->options |= DHCPCD_ARP | DHCPCD_IPV4LL; in read_config()
804 ifo->options |= DHCPCD_IPV6RS | DHCPCD_IPV6RA_REQRDNSS; in read_config()
806 ifo->timeout = DEFAULT_TIMEOUT; in read_config()
807 ifo->reboot = DEFAULT_REBOOT; in read_config()
808 ifo->metric = -1; in read_config()
809 strlcpy(ifo->script, SCRIPT, sizeof(ifo->script)); in read_config()
810 gethostname(ifo->hostname, HOSTNAME_MAX_LEN); in read_config()
812 ifo->hostname[HOSTNAME_MAX_LEN] = '\0'; in read_config()
813 if (strcmp(ifo->hostname, "(none)") == 0 || in read_config()
814 strcmp(ifo->hostname, "localhost") == 0) in read_config()
815 ifo->hostname[0] = '\0'; in read_config()
820 ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1, in read_config()
827 ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1, in read_config()
835 return ifo; in read_config()
875 parse_config_line(ifo, option, line); in read_config()
880 free_options(ifo); in read_config()
882 ifo = NULL; in read_config()
886 if (ifo && ifo->vendor[0] && !(ifo->options & DHCPCD_VENDORRAW)) { in read_config()
887 ifo->vendor[0]++; in read_config()
888 ifo->vendor[ifo->vendor[0]] = DHO_END; in read_config()
890 return ifo; in read_config()
894 add_options(struct if_options *ifo, int argc, char **argv) in add_options() argument
901 r = parse_option(ifo, opt, optarg); in add_options()
906 if (r == 1 && ifo->vendor[0] && !(ifo->options & DHCPCD_VENDORRAW)) { in add_options()
907 ifo->vendor[0]++; in add_options()
908 ifo->vendor[ifo->vendor[0]] = DHO_END; in add_options()
914 free_options(struct if_options *ifo) in free_options() argument
918 if (ifo) { in free_options()
919 if (ifo->environ) { in free_options()
921 while (ifo->environ[i]) in free_options()
922 free(ifo->environ[i++]); in free_options()
923 free(ifo->environ); in free_options()
925 if (ifo->config) { in free_options()
927 while (ifo->config[i]) in free_options()
928 free(ifo->config[i++]); in free_options()
929 free(ifo->config); in free_options()
931 free_routes(ifo->routes); in free_options()
932 free(ifo->arping); in free_options()
933 free(ifo->blacklist); in free_options()
934 free(ifo->fallback); in free_options()
935 free(ifo); in free_options()