Lines Matching refs:ifo

203 add_environ(struct dhcpcd_ctx *ctx, struct if_options *ifo,  in add_environ()  argument
207 char **lst = ifo->environ; in add_environ()
273 ifo->environ = newlist; in add_environ()
520 struct if_options *ifo, in set_option_space() argument
533 *od = ifo->dhcp6_override; in set_option_space()
534 *odl = ifo->dhcp6_override_len; in set_option_space()
535 *request = ifo->requestmask6; in set_option_space()
536 *require = ifo->requiremask6; in set_option_space()
537 *no = ifo->nomask6; in set_option_space()
538 *reject = ifo->rejectmask6; in set_option_space()
546 *od = ifo->dhcp_override; in set_option_space()
547 *odl = ifo->dhcp_override_len; in set_option_space()
554 *request = ifo->requestmask; in set_option_space()
555 *require = ifo->requiremask; in set_option_space()
556 *no = ifo->nomask; in set_option_space()
557 *reject = ifo->rejectmask; in set_option_space()
633 parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, in parse_option() argument
680 ia = realloc(ifo->ia, sizeof(*ifo->ia) * (ifo->ia_len + 2)); in parse_option()
685 ifo->ia = ia; in parse_option()
688 ia = &ifo->ia[ifo->ia_len++]; in parse_option()
699 ia = &ifo->ia[ifo->ia_len++]; in parse_option()
710 ifo->options |= DHCPCD_IA_FORCED; in parse_option()
714 ifo->options |= DHCPCD_BACKGROUND; in parse_option()
717 free(ifo->script); in parse_option()
718 ifo->script = strdup(arg); in parse_option()
719 if (ifo->script == NULL) in parse_option()
723 ifo->options |= DHCPCD_DEBUG; in parse_option()
726 add_environ(ctx, ifo, arg, 1); in parse_option()
730 ifo->options |= DHCPCD_HOSTNAME; in parse_option()
733 s = parse_string(ifo->hostname, HOSTNAME_MAX_LEN, arg); in parse_option()
738 if (s != 0 && ifo->hostname[0] == '.') { in parse_option()
742 ifo->hostname[s] = '\0'; in parse_option()
743 if (ifo->hostname[0] == '\0') in parse_option()
744 ifo->options &= ~DHCPCD_HOSTNAME; in parse_option()
746 ifo->options |= DHCPCD_HOSTNAME; in parse_option()
750 s = parse_string((char *)ifo->vendorclassid + 1, in parse_option()
758 *ifo->vendorclassid = (uint8_t)s; in parse_option()
770 ifo->options |= DHCPCD_RELEASE; in parse_option()
773 ifo->leasetime = (uint32_t)strtou(arg, NULL, in parse_option()
781 ifo->metric = (int)strtoi(arg, NULL, 0, 0, INT32_MAX, &e); in parse_option()
788 arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, in parse_option()
799 arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, in parse_option()
810 ifo->options |= DHCPCD_PERSISTENT; in parse_option()
813 ifo->options |= DHCPCD_QUIET; in parse_option()
816 if (parse_addr(ctx, &ifo->req_addr, NULL, arg) != 0) in parse_option()
818 ifo->options |= DHCPCD_REQUEST; in parse_option()
819 ifo->req_mask.s_addr = 0; in parse_option()
822 if (ifo->options & DHCPCD_IPV6 && in parse_option()
823 !(ifo->options & DHCPCD_IPV4)) in parse_option()
825 ifo->options |= DHCPCD_INFORM; in parse_option()
830 &ifo->req_addr, &ifo->req_mask, arg) != 0) in parse_option()
833 ifo->req_addr.s_addr = 0; in parse_option()
834 ifo->req_mask.s_addr = 0; in parse_option()
836 ifo->options |= DHCPCD_INFORM | DHCPCD_PERSISTENT; in parse_option()
837 ifo->options &= ~(DHCPCD_ARP | DHCPCD_STATIC); in parse_option()
840 ifo->timeout = (time_t)strtoi(arg, NULL, 0, 0, INT32_MAX, &e); in parse_option()
847 s = USERCLASS_MAX_LEN - ifo->userclass[0] - 1; in parse_option()
848 s = parse_string((char *)ifo->userclass + in parse_option()
849 ifo->userclass[0] + 2, (size_t)s, arg); in parse_option()
855 ifo->userclass[ifo->userclass[0] + 1] = (uint8_t)s; in parse_option()
856 ifo->userclass[0] = (uint8_t)(ifo->userclass[0] + s +1); in parse_option()
869 s = parse_string((char *)ifo->vendor + 1, in parse_option()
875 ifo->vendor[0] = (uint8_t)s; in parse_option()
876 ifo->options |= DHCPCD_VENDORRAW; in parse_option()
881 if (ifo->options & DHCPCD_VENDORRAW) { in parse_option()
882 ifo->options &= ~DHCPCD_VENDORRAW; in parse_option()
883 ifo->vendor[0] = 0; in parse_option()
897 s = VENDOR_MAX_LEN - ifo->vendor[0] - 2; in parse_option()
903 memcpy(ifo->vendor + ifo->vendor[0] + 3, in parse_option()
908 s = parse_string((char *)ifo->vendor + in parse_option()
909 ifo->vendor[0] + 3, (size_t)s, arg); in parse_option()
916 ifo->vendor[ifo->vendor[0] + 1] = (uint8_t)i; in parse_option()
917 ifo->vendor[ifo->vendor[0] + 2] = (uint8_t)s; in parse_option()
918 ifo->vendor[0] = (uint8_t)(ifo->vendor[0] + s + 2); in parse_option()
922 ifo->options |= DHCPCD_WAITIP; in parse_option()
925 ifo->options |= DHCPCD_WAITIP4; in parse_option()
927 ifo->options |= DHCPCD_WAITIP6; in parse_option()
931 ifo->reboot = (time_t)strtoi(arg, NULL, 0, 0, UINT32_MAX, &e); in parse_option()
942 ifo->options &= ~DHCPCD_ARP; in parse_option()
944 ifo->options &= ~DHCPCD_IPV4LL; in parse_option()
947 ifo->options &= ~DHCPCD_DAEMONISE; in parse_option()
960 add_environ(ctx, ifo, p, 0); in parse_option()
964 ifo->options |= DHCPCD_CLIENTID | DHCPCD_DUID; in parse_option()
967 ifo->options |= DHCPCD_LASTLEASE; in parse_option()
971 ifo->fqdn = FQDN_BOTH; in parse_option()
975 ifo->fqdn = FQDN_NONE; in parse_option()
977 ifo->fqdn = FQDN_PTR; in parse_option()
979 ifo->fqdn = FQDN_BOTH; in parse_option()
981 ifo->fqdn = FQDN_DISABLE; in parse_option()
988 ifo->options &= ~DHCPCD_GATEWAY; in parse_option()
991 ifo->options |= DHCPCD_XID_HWADDR; in parse_option()
995 ifo->clientid[1] = 0; in parse_option()
997 s = parse_string_hwaddr((char *)ifo->clientid + 1, in parse_option()
1005 ifo->options |= DHCPCD_CLIENTID; in parse_option()
1006 ifo->clientid[0] = (uint8_t)s; in parse_option()
1009 ifo->options |= DHCPCD_BROADCAST; in parse_option()
1012 ifo->options &= ~DHCPCD_LINK; in parse_option()
1015 ifo->options &= ~DHCPCD_IPV4LL; in parse_option()
1018 ifo->options |= DHCPCD_MASTER; in parse_option()
1021 arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, in parse_option()
1032 ifo->options |= DHCPCD_UNICAST_ARP; in parse_option()
1035 arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, in parse_option()
1047 ifo->options |= DHCPCD_ARPGW; in parse_option()
1057 if (parse_addr(ctx, &ifo->req_addr, in parse_option()
1058 ifo->req_mask.s_addr == 0 ? &ifo->req_mask : NULL, in parse_option()
1062 ifo->options |= DHCPCD_STATIC; in parse_option()
1063 ifo->options &= ~DHCPCD_INFORM; in parse_option()
1067 if (parse_addr(ctx, &ifo->req_mask, NULL, p) != 0) in parse_option()
1085 if (ifo->routes == NULL) { in parse_option()
1086 ifo->routes = malloc(sizeof(*ifo->routes)); in parse_option()
1087 if (ifo->routes == NULL) { in parse_option()
1092 TAILQ_INIT(ifo->routes); in parse_option()
1107 TAILQ_INSERT_TAIL(ifo->routes, rt, next); in parse_option()
1110 if (ifo->routes == NULL) { in parse_option()
1111 ifo->routes = malloc(sizeof(*ifo->routes)); in parse_option()
1112 if (ifo->routes == NULL) { in parse_option()
1117 TAILQ_INIT(ifo->routes); in parse_option()
1130 TAILQ_INSERT_TAIL(ifo->routes, rt, next); in parse_option()
1133 if (ifo->config != NULL) { in parse_option()
1134 while (ifo->config[dl] != NULL) { in parse_option()
1135 if (strncmp(ifo->config[dl], arg, in parse_option()
1144 free(ifo->config[dl]); in parse_option()
1145 ifo->config[dl] = p; in parse_option()
1156 nconf = realloc(ifo->config, sizeof(char *) * (dl + 2)); in parse_option()
1161 ifo->config = nconf; in parse_option()
1162 ifo->config[dl] = p; in parse_option()
1163 ifo->config[dl + 1] = NULL; in parse_option()
1171 naddr = realloc(ifo->whitelist, in parse_option()
1172 sizeof(in_addr_t) * (ifo->whitelist_len + 2)); in parse_option()
1177 ifo->whitelist = naddr; in parse_option()
1178 ifo->whitelist[ifo->whitelist_len++] = addr.s_addr; in parse_option()
1179 ifo->whitelist[ifo->whitelist_len++] = addr2.s_addr; in parse_option()
1186 naddr = realloc(ifo->blacklist, in parse_option()
1187 sizeof(in_addr_t) * (ifo->blacklist_len + 2)); in parse_option()
1192 ifo->blacklist = naddr; in parse_option()
1193 ifo->blacklist[ifo->blacklist_len++] = addr.s_addr; in parse_option()
1194 ifo->blacklist[ifo->blacklist_len++] = addr2.s_addr; in parse_option()
1201 ifo->options &= ~DHCPCD_IPV6; in parse_option()
1202 ifo->options |= DHCPCD_IPV4; in parse_option()
1205 ifo->options &= ~DHCPCD_IPV4; in parse_option()
1206 ifo->options |= DHCPCD_IPV6; in parse_option()
1209 ifo->options |= DHCPCD_IPV4; in parse_option()
1212 ifo->options &= ~DHCPCD_IPV4; in parse_option()
1215 ifo->options |= DHCPCD_IPV6; in parse_option()
1218 ifo->options &= ~DHCPCD_IPV6; in parse_option()
1228 naddr = realloc(ifo->arping, in parse_option()
1229 sizeof(in_addr_t) * (ifo->arping_len + 1)); in parse_option()
1234 ifo->arping = naddr; in parse_option()
1235 ifo->arping[ifo->arping_len++] = addr.s_addr; in parse_option()
1240 arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, in parse_option()
1243 ifo->dstmask, arg, 2) != 0) in parse_option()
1254 free(ifo->fallback); in parse_option()
1255 ifo->fallback = strdup(arg); in parse_option()
1256 if (ifo->fallback == NULL) { in parse_option()
1268 if (parse_iaid(ifo->iaid, arg, sizeof(ifo->iaid)) == -1) { in parse_option()
1272 ifo->options |= DHCPCD_IAID; in parse_option()
1275 ifo->options |= DHCPCD_IPV6RS; in parse_option()
1278 ifo->options &= ~DHCPCD_IPV6RS; in parse_option()
1281 ifo->options &= ~DHCPCD_IPV6RA_REQRDNSS; in parse_option()
1284 ifo->options |= DHCPCD_IPV6RA_OWN; in parse_option()
1287 ifo->options |= DHCPCD_IPV6RA_OWN_DEFAULT; in parse_option()
1290 ifo->options |= DHCPCD_IPV6RA_ACCEPT_NOPUBLIC; in parse_option()
1293 ifo->options |= DHCPCD_IPV6RA_AUTOCONF; in parse_option()
1296 ifo->options &= ~DHCPCD_IPV6RA_AUTOCONF; in parse_option()
1299 ifo->options |= DHCPCD_NOALIAS; in parse_option()
1323 ifo->options |= DHCPCD_IA_FORCED; in parse_option()
1339 for (sl = 0; sl < ifo->ia_len; sl++) { in parse_option()
1340 if ((arg == NULL && !ifo->ia[sl].iaid_set) || in parse_option()
1341 (ifo->ia[sl].iaid_set && in parse_option()
1342 ifo->ia[sl].iaid[0] == iaid[0] && in parse_option()
1343 ifo->ia[sl].iaid[1] == iaid[1] && in parse_option()
1344 ifo->ia[sl].iaid[2] == iaid[2] && in parse_option()
1345 ifo->ia[sl].iaid[3] == iaid[3])) in parse_option()
1347 ia = &ifo->ia[sl]; in parse_option()
1356 ia = realloc(ifo->ia, in parse_option()
1357 sizeof(*ifo->ia) * (ifo->ia_len + 1)); in parse_option()
1362 ifo->ia = ia; in parse_option()
1363 ia = &ifo->ia[ifo->ia_len++]; in parse_option()
1500 ifo->options |= DHCPCD_HOSTNAME | DHCPCD_HOSTNAME_SHORT; in parse_option()
1510 ifo->options &= ~DHCPCD_DEV; in parse_option()
1513 dop = &ifo->dhcp_override; in parse_option()
1514 dop_len = &ifo->dhcp_override_len; in parse_option()
1518 dop = &ifo->dhcp6_override; in parse_option()
1519 dop_len = &ifo->dhcp6_override_len; in parse_option()
1524 dop = &ifo->vivso_override; in parse_option()
1525 dop_len = &ifo->vivso_override_len; in parse_option()
1774 vivco = realloc(ifo->vivco, sizeof(*ifo->vivco) * in parse_option()
1775 (ifo->vivco_len + 1)); in parse_option()
1780 ifo->vivco = vivco; in parse_option()
1781 ifo->vivco_en = (uint32_t)u; in parse_option()
1782 vivco = &ifo->vivco[ifo->vivco_len++]; in parse_option()
1791 ifo->auth.protocol = AUTH_PROTO_TOKEN; in parse_option()
1793 ifo->auth.protocol = AUTH_PROTO_DELAYED; in parse_option()
1795 ifo->auth.protocol = AUTH_PROTO_DELAYEDREALM; in parse_option()
1803 ifo->auth.options |= DHCPCD_AUTH_SEND; in parse_option()
1804 ifo->auth.algorithm = AUTH_ALG_HMAC_MD5; in parse_option()
1805 ifo->auth.rdm = AUTH_RDM_MONOTONIC; in parse_option()
1812 ifo->auth.algorithm = AUTH_ALG_HMAC_MD5; in parse_option()
1819 ifo->auth.options |= DHCPCD_AUTH_SEND; in parse_option()
1820 ifo->auth.rdm = AUTH_RDM_MONOTONIC; in parse_option()
1824 ifo->auth.rdm = AUTH_RDM_MONOTONIC; in parse_option()
1825 ifo->auth.options |= DHCPCD_AUTH_RDM_COUNTER; in parse_option()
1828 ifo->auth.rdm = AUTH_RDM_MONOTONIC; in parse_option()
1833 ifo->auth.options |= DHCPCD_AUTH_SEND; in parse_option()
1927 TAILQ_INSERT_TAIL(&ifo->auth.tokens, token, next); in parse_option()
1930 ifo->auth.options &= ~DHCPCD_AUTH_REQUIRE; in parse_option()
1933 ifo->options |= DHCPCD_DHCP | DHCPCD_IPV4; in parse_option()
1936 ifo->options &= ~DHCPCD_DHCP; in parse_option()
1939 ifo->options |= DHCPCD_DHCP6 | DHCPCD_IPV6; in parse_option()
1942 ifo->options &= ~DHCPCD_DHCP6; in parse_option()
1997 ifo->options |= DHCPCD_GATEWAY; in parse_option()
2003 ifo->options |= DHCPCD_SLAACPRIVATE; in parse_option()
2005 ifo->options &= ~DHCPCD_SLAACPRIVATE; in parse_option()
2008 ifo->options |= DHCPCD_PFXDLGMIX; in parse_option()
2011 ifo->options |= DHCPCD_BOOTP; in parse_option()
2022 struct if_options *ifo, const char *opt, char *line, in parse_config_line() argument
2039 return parse_option(ctx, ifname, ifo, cf_options[i].val, line, in parse_config_line()
2048 finish_config(struct if_options *ifo) in finish_config() argument
2052 if (ifo->vendor[0] && !(ifo->options & DHCPCD_VENDORRAW)) { in finish_config()
2053 ifo->vendor[0]++; in finish_config()
2054 ifo->vendor[ifo->vendor[0]] = DHO_END; in finish_config()
2058 ifo->options |= DHCPCD_VENDORRAW; in finish_config()
2089 struct if_options *ifo; local
2107 ifo = calloc(1, sizeof(*ifo));
2108 if (ifo == NULL) {
2112 ifo->options |= DHCPCD_DAEMONISE | DHCPCD_LINK;
2114 ifo->options |= DHCPCD_DEV;
2117 ifo->options |= DHCPCD_IPV4 | DHCPCD_DHCP | DHCPCD_IPV4LL;
2118 ifo->options |= DHCPCD_GATEWAY | DHCPCD_ARP;
2121 ifo->options |= DHCPCD_IPV6 | DHCPCD_IPV6RS;
2122 ifo->options |= DHCPCD_IPV6RA_AUTOCONF | DHCPCD_IPV6RA_REQRDNSS;
2123 ifo->options |= DHCPCD_DHCP6;
2125 ifo->timeout = DEFAULT_TIMEOUT;
2126 ifo->reboot = DEFAULT_REBOOT;
2127 ifo->metric = -1;
2128 ifo->auth.options |= DHCPCD_AUTH_REQUIRE;
2129 TAILQ_INIT(&ifo->auth.tokens);
2131 vlen = dhcp_vendor((char *)ifo->vendorclassid + 1,
2132 sizeof(ifo->vendorclassid) - 1);
2133 ifo->vendorclassid[0] = (uint8_t)(vlen == -1 ? 0 : vlen);
2142 ifo->dhcp_override =
2143 calloc(INITDEFINES, sizeof(*ifo->dhcp_override));
2144 if (ifo->dhcp_override == NULL)
2147 ifo->dhcp_override_len = INITDEFINES;
2151 ifo->dhcp6_override =
2152 calloc(INITDEFINE6S, sizeof(*ifo->dhcp6_override));
2153 if (ifo->dhcp6_override == NULL)
2156 ifo->dhcp6_override_len = INITDEFINE6S;
2199 parse_config_line(ctx, NULL, ifo, option, line,
2209 ctx->dhcp_opts = ifo->dhcp_override;
2210 ctx->dhcp_opts_len = ifo->dhcp_override_len;
2212 for (i = 0, opt = ifo->dhcp_override;
2213 i < ifo->dhcp_override_len;
2216 free(ifo->dhcp_override);
2218 ifo->dhcp_override = NULL;
2219 ifo->dhcp_override_len = 0;
2222 ctx->dhcp6_opts = ifo->dhcp6_override;
2223 ctx->dhcp6_opts_len = ifo->dhcp6_override_len;
2225 for (i = 0, opt = ifo->dhcp6_override;
2226 i < ifo->dhcp6_override_len;
2229 free(ifo->dhcp6_override);
2231 ifo->dhcp6_override = NULL;
2232 ifo->dhcp6_override_len = 0;
2234 ctx->vivso = ifo->vivso_override;
2235 ctx->vivso_len = ifo->vivso_override_len;
2236 ifo->vivso_override = NULL;
2237 ifo->vivso_override_len = 0;
2246 return ifo;
2249 ifo->mtime = sb.st_mtime;
2315 parse_config_line(ctx, ifname, ifo, option, line, &ldop, &edop);
2321 free_options(ifo);
2326 finish_config(ifo);
2327 return ifo;
2332 struct if_options *ifo, int argc, char **argv) argument
2343 r = parse_option(ctx, ifname, ifo, opt, optarg, NULL, NULL);
2348 finish_config(ifo);
2353 free_options(struct if_options *ifo) argument
2360 if (ifo) {
2361 if (ifo->environ) {
2363 while (ifo->environ[i])
2364 free(ifo->environ[i++]);
2365 free(ifo->environ);
2367 if (ifo->config) {
2369 while (ifo->config[i])
2370 free(ifo->config[i++]);
2371 free(ifo->config);
2373 ipv4_freeroutes(ifo->routes);
2374 free(ifo->script);
2375 free(ifo->arping);
2376 free(ifo->blacklist);
2377 free(ifo->fallback);
2379 for (opt = ifo->dhcp_override;
2380 ifo->dhcp_override_len > 0;
2381 opt++, ifo->dhcp_override_len--)
2383 free(ifo->dhcp_override);
2384 for (opt = ifo->dhcp6_override;
2385 ifo->dhcp6_override_len > 0;
2386 opt++, ifo->dhcp6_override_len--)
2388 free(ifo->dhcp6_override);
2389 for (vo = ifo->vivco;
2390 ifo->vivco_len > 0;
2391 vo++, ifo->vivco_len--)
2393 free(ifo->vivco);
2394 for (opt = ifo->vivso_override;
2395 ifo->vivso_override_len > 0;
2396 opt++, ifo->vivso_override_len--)
2398 free(ifo->vivso_override);
2401 for (; ifo->ia_len > 0; ifo->ia_len--)
2402 free(ifo->ia[ifo->ia_len - 1].sla);
2404 free(ifo->ia);
2406 while ((token = TAILQ_FIRST(&ifo->auth.tokens))) {
2407 TAILQ_REMOVE(&ifo->auth.tokens, token, next);
2413 free(ifo);