Home | History | Annotate | Download | only in dhcpcd

Lines Matching refs:ifo

128 add_environ(struct if_options *ifo, const char *value, int uniq)
131 char **lst = ifo->environ;
164 ifo->environ = newlist;
327 parse_option(struct if_options *ifo, int opt, const char *arg)
345 ifo->options |= DHCPCD_BACKGROUND;
348 strlcpy(ifo->script, arg, sizeof(ifo->script));
351 ifo->options |= DHCPCD_DEBUG;
354 add_environ(ifo, arg, 1);
358 s = parse_string(ifo->hostname,
364 if (s != 0 && ifo->hostname[0] == '.') {
369 ifo->hostname[s] = '\0';
371 if (ifo->hostname[0] == '\0')
372 ifo->options &= ~DHCPCD_HOSTNAME;
374 ifo->options |= DHCPCD_HOSTNAME;
378 s = parse_string((char *)ifo->vendorclassid + 1,
386 *ifo->vendorclassid = (uint8_t)s;
389 ifo->options |= DHCPCD_RELEASE;
398 ifo->leasetime = (uint32_t)strtol(arg, NULL, 0);
405 ifo->metric = atoint(arg);
406 if (ifo->metric < 0) {
412 if (make_option_mask(ifo->requestmask, arg, 1) != 0) {
418 ifo->options |= DHCPCD_PERSISTENT;
421 ifo->options |= DHCPCD_QUIET;
424 if (parse_addr(&ifo->req_addr, NULL, arg) != 0)
426 ifo->options |= DHCPCD_REQUEST;
427 ifo->req_mask.s_addr = 0;
431 if (parse_addr(&ifo->req_addr, &ifo->req_mask,
435 ifo->req_addr.s_addr = 0;
436 ifo->req_mask.s_addr = 0;
438 ifo->options |= DHCPCD_INFORM | DHCPCD_PERSISTENT;
439 ifo->options &= ~(DHCPCD_ARP | DHCPCD_STATIC);
442 ifo->timeout = atoint(arg);
443 if (ifo->timeout < 0) {
449 s = USERCLASS_MAX_LEN - ifo->userclass[0] - 1;
450 s = parse_string((char *)ifo->userclass +
451 ifo->userclass[0] + 2,
458 ifo->userclass[ifo->userclass[0] + 1] = s;
459 ifo->userclass[0] += s + 1;
472 s = parse_string((char *)ifo->vendor + 1,
478 ifo->vendor[0] = (uint8_t)s;
479 ifo->options |= DHCPCD_VENDORRAW;
484 if (ifo->options & DHCPCD_VENDORRAW) {
485 ifo->options &= ~DHCPCD_VENDORRAW;
486 ifo->vendor[0] = 0;
497 s = VENDOR_MAX_LEN - ifo->vendor[0] - 2;
503 memcpy(ifo->vendor + ifo->vendor[0] + 3,
506 s = parse_string((char *)ifo->vendor +
507 ifo->vendor[0] + 3, s, arg);
514 ifo->vendor[ifo->vendor[0] + 1] = i;
515 ifo->vendor[ifo->vendor[0] + 2] = s;
516 ifo->vendor[0] += s + 2;
520 ifo->options |= DHCPCD_WAITIP;
523 ifo->reboot = atoint(arg);
524 if (ifo->reboot < 0) {
533 ifo->options &= ~DHCPCD_ARP;
535 ifo->options &= ~DHCPCD_IPV4LL;
538 ifo->options &= ~DHCPCD_DAEMONISE;
547 add_environ(ifo, p, 0);
551 ifo->options |= DHCPCD_CLIENTID | DHCPCD_DUID;
554 ifo->options |= DHCPCD_LASTLEASE;
558 ifo->fqdn = FQDN_BOTH;
562 ifo->fqdn = FQDN_NONE;
564 ifo->fqdn = FQDN_PTR;
566 ifo->fqdn = FQDN_BOTH;
568 ifo->fqdn = FQDN_DISABLE;
575 ifo->options &= ~DHCPCD_GATEWAY;
578 ifo->options |= DHCPCD_XID_HWADDR;
582 ifo->clientid[1] = 0;
584 s = parse_string_hwaddr((char *)ifo->clientid + 1,
592 ifo->options |= DHCPCD_CLIENTID;
593 ifo->clientid[0] = (uint8_t)s;
596 ifo->options |= DHCPCD_BROADCAST;
599 ifo->options &= ~DHCPCD_LINK;
602 ifo->options &= ~DHCPCD_IPV4LL;
605 if (make_option_mask(ifo->requestmask, arg, -1) != 0 ||
606 make_option_mask(ifo->requiremask, arg, -1) != 0 ||
607 make_option_mask(ifo->nomask, arg, 1) != 0)
614 if (make_option_mask(ifo->requiremask, arg, 1) != 0 ||
615 make_option_mask(ifo->requestmask, arg, 1) != 0)
629 if (parse_addr(&ifo->req_addr, &ifo->req_mask, p) != 0)
632 ifo->options |= DHCPCD_STATIC;
633 ifo->options &= ~DHCPCD_INFORM;
647 if (ifo->routes == NULL) {
648 rt = ifo->routes = xmalloc(sizeof(*rt));
650 rt = ifo->routes;
661 if (ifo
662 rt = ifo->routes = xzalloc(sizeof(*rt));
664 rt = ifo->routes;
677 if (ifo->config != NULL) {
678 while (ifo->config[s] != NULL) {
679 if (strncmp(ifo->config[s], arg,
682 free(ifo->config[s]);
683 ifo->config[s] = xstrdup(arg);
689 ifo->config = xrealloc(ifo->config,
691 ifo->config[s] = xstrdup(arg);
692 ifo->config[s + 1] = NULL;
700 ifo->whitelist = xrealloc(ifo->whitelist,
701 sizeof(in_addr_t) * (ifo->whitelist_len + 2));
702 ifo->whitelist[ifo->whitelist_len++] = addr.s_addr;
703 ifo->whitelist[ifo->whitelist_len++] = addr2.s_addr;
710 ifo->blacklist = xrealloc(ifo->blacklist,
711 sizeof(in_addr_t) * (ifo->blacklist_len + 2));
712 ifo->blacklist[ifo->blacklist_len++] = addr.s_addr;
713 ifo->blacklist[ifo->blacklist_len++] = addr2.s_addr;
721 ifo->arping = xrealloc(ifo->arping,
722 sizeof(in_addr_t) * (ifo->arping_len + 1));
723 ifo->arping[ifo->arping_len++] = addr.s_addr;
726 if (make_option_mask(ifo->dstmask, arg, 2) != 0) {
736 free(ifo->fallback);
737 ifo->fallback = xstrdup(arg);
747 parse_config_line(struct if_options *ifo, const char *opt, char *line)
763 return parse_option(ifo, cf_options[i].val, line);
774 struct if_options *ifo;
781 ifo = xzalloc(sizeof(*ifo));
782 ifo->options |= DHCPCD_GATEWAY | DHCPCD_DAEMONISE;
783 ifo->options |= DHCPCD_ARP | DHCPCD_IPV4LL | DHCPCD_LINK;
784 ifo->timeout = DEFAULT_TIMEOUT;
785 ifo->reboot = DEFAULT_REBOOT;
786 ifo->metric = -1;
787 strlcpy(ifo->script, SCRIPT, sizeof(ifo->script));
788 gethostname(ifo->hostname, HOSTNAME_MAX_LEN);
790 ifo->hostname[HOSTNAME_MAX_LEN] = '\0';
791 if (strcmp(ifo->hostname, "(none)") == 0 ||
792 strcmp(ifo->hostname, "localhost") == 0)
793 ifo->hostname[0] = '\0';
797 ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1,
803 ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1,
811 return ifo;
851 parse_config_line(ifo, option, line);
856 free_options(ifo);
858 ifo = NULL;
862 if (ifo && ifo->vendor[0] && !(ifo->options & DHCPCD_VENDORRAW)) {
863 ifo->vendor[0]++;
864 ifo->vendor[ifo->vendor[0]] = DHO_END;
866 return ifo;
870 add_options(struct if_options *ifo, int argc, char **argv)
877 r = parse_option(ifo, opt, optarg);
882 if (r == 1 && ifo->vendor[0] && !(ifo->options & DHCPCD_VENDORRAW)) {
883 ifo->vendor[0]++;
884 ifo->vendor[ifo->vendor[0]] = DHO_END;
890 free_options(struct if_options *ifo)
894 if (ifo) {
895 if (ifo->environ) {
897 while (ifo->environ[i])
898 free(ifo->environ[i++]);
899 free(ifo->environ);
901 if (ifo->config) {
903 while (ifo->config[i])
904 free(ifo->config[i++]);
905 free(ifo->config);
907 free_routes(ifo->routes);
908 free(ifo->arping);
909 free(ifo->blacklist);
910 free(ifo->fallback);
911 free(ifo);