Home | History | Annotate | Download | only in dhcpcd-6.8.2

Lines Matching refs:ifp

214 	const struct interface *ifp;
216 TAILQ_FOREACH(ifp, ctx->ifaces, next) {
217 if (D_STATE_RUNNING(ifp) ||
218 RS_STATE_RUNNING(ifp) ||
219 D6_STATE_RUNNING(ifp))
323 dhcpcd_drop(struct interface *ifp, int stop)
326 dhcp6_drop(ifp, stop ? NULL : "EXPIRE6");
327 ipv6nd_drop(ifp);
328 ipv6_drop(ifp);
329 dhcp_drop(ifp, stop ? "STOP" : "EXPIRE");
330 arp_close(ifp);
334 stop_interface(struct interface *ifp)
338 ctx = ifp->ctx;
339 logger(ctx, LOG_INFO, "%s: removing interface", ifp->name);
340 ifp->options->options |= DHCPCD_STOPPING;
342 dhcpcd_drop(ifp, 1);
343 if (ifp->options->options & DHCPCD_DEPARTED)
344 script_runreason(ifp, "DEPARTED");
346 script_runreason(ifp, "STOPPED");
349 eloop_q_timeout_delete(ctx->eloop, 0, NULL, ifp);
352 TAILQ_REMOVE(ifp->ctx->ifaces, ifp, next);
353 if_free(ifp);
360 configure_interface1(struct interface *ifp)
362 struct if_options *ifo = ifp->options;
369 if_conf(ifp);
376 if (ifp->flags & IFF_POINTOPOINT && !(ifo->options & DHCPCD_INFORM))
378 if (ifp->flags & IFF_NOARP ||
381 if (ifp->flags & (IFF_POINTOPOINT | IFF_LOOPBACK) ||
382 !(ifp->flags & IFF_MULTICAST))
386 ifp->metric = (unsigned int)ifo->metric;
395 !(ifp->ctx->options & (DHCPCD_DUMPLEASE | DHCPCD_TEST)))
399 if (ifp->options->options & DHCPCD_PFXDLGONLY)
400 ifp->options->options &= ~(DHCPCD_IPV4 | DHCPCD_IPV6RS);
404 !(ifp->ctx->options & DHCPCD_DUMPLEASE))
409 ra_global = if_checkipv6(ifp->ctx, NULL,
410 ifp->ctx->options & DHCPCD_IPV6RA_OWN ? 1 : 0);
411 ra_iface = if_checkipv6(ifp->ctx, ifp,
412 ifp->options->options & DHCPCD_IPV6RA_OWN ? 1 : 0);
416 !(ifp->ctx->options & DHCPCD_TEST))
425 if (ifp->hwlen > DHCP_CHADDR_LEN)
427 else if (ifp->hwlen == 0 && !(ifo->options & DHCPCD_CLIENTID))
432 switch (ifp->family) {
475 if (ifp->hwlen >= sizeof(ifo->iaid))
477 ifp->hwaddr + ifp->hwlen - sizeof(ifo->iaid),
482 len = (uint32_t)strlen(ifp->name);
484 memcpy(ifo->iaid, ifp->name, len);
490 len = htonl(ifp->index);
499 ifp->name[0] != '\0')
503 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
529 dhcpcd_selectprofile(struct interface *ifp, const char *profile)
534 if (ifp->ssid_len) {
538 ifp->ssid, ifp->ssid_len);
540 logger(ifp->ctx, LOG_ERR,
541 "%s: %s: %m", ifp->name, __func__);
546 ifo = read_config(ifp->ctx, ifp->name, pssid, profile);
548 logger(ifp->ctx, LOG_DEBUG, "%s: no profile %s",
549 ifp->name, profile);
553 strlcpy(ifp->profile, profile, sizeof(ifp->profile));
554 logger(ifp->ctx, LOG_INFO, "%s: selected profile %s",
555 ifp->name, profile);
557 *ifp->profile = '\0';
559 free_options(ifp->options);
560 ifp->options = ifo;
562 configure_interface1(ifp);
567 configure_interface(struct interface *ifp, int argc, char **argv,
572 old = ifp->options ? ifp->options->mtime : 0;
573 dhcpcd_selectprofile(ifp, NULL);
574 add_options(ifp->ctx, ifp->name, ifp->options, argc, argv);
575 ifp->options->options |= options;
576 configure_interface1(ifp);
579 if (ifp->options && old != 0 && ifp->options->mtime != old) {
580 logger(ifp->ctx, LOG_WARNING,
581 "%s: confile file changed, expiring leases", ifp->name);
582 dhcpcd_drop(ifp, 0);
589 struct interface *ifp = arg;
592 carrier = if_carrier(ifp); /* will set ifp->flags */
593 if (carrier == LINK_UP && !(ifp->flags & IFF_UP)) {
598 eloop_timeout_add_tv(ifp->ctx->eloop, &tv, dhcpcd_pollup, ifp);
602 dhcpcd_handlecarrier(ifp->ctx, carrier, ifp->flags, ifp->name);
609 struct interface *ifp;
611 ifp = if_find(ctx->ifaces, ifname);
612 if (ifp == NULL || !(ifp->options->options & DHCPCD_LINK))
617 carrier = if_carrier(ifp); /* will set ifp->flags */
622 ifp->flags = flags;
626 dhcpcd_pollup(ifp);
631 ifp->flags = flags;
636 eloop_timeout_delete(ifp->ctx->eloop, dhcpcd_pollup, ifp);
641 } else if (carrier == LINK_DOWN || (ifp->flags & IFF_UP) == 0) {
642 if (ifp->carrier != LINK_DOWN) {
643 if (ifp->carrier == LINK_UP)
645 ifp->name);
646 ifp->carrier = LINK_DOWN;
647 script_runreason(ifp, "NOCARRIER");
649 arp_close(ifp);
650 ipv4_buildroutes(ifp->ctx);
651 ipv6nd_expire(ifp, 0);
653 dhcpcd_drop(ifp, 0);
656 } else if (carrier == LINK_UP && ifp->flags & IFF_UP) {
657 if (ifp->carrier != LINK_UP) {
659 ifp->name);
660 ifp->carrier = LINK_UP;
665 dhcpcd_handleinterface(ctx, 0, ifp->name);
667 if (ifp->wireless) {
672 olen = ifp->ssid_len;
674 memcpy(ossid, ifp->ssid, ifp->ssid_len);
675 if_getssid(ifp);
678 if (ifp->ssid_len != olen ||
679 memcmp(ifp->ssid, ossid, ifp->ssid_len))
680 dhcpcd_drop(ifp, 0);
683 dhcpcd_initstate(ifp, 0);
684 script_runreason(ifp, "CARRIER");
689 ipv6nd_expire(ifp, RTR_CARRIER_EXPIRE);
692 if (ifp->options->options & DHCPCD_IPV6RA_OWN)
693 ipv6_gentempifid(ifp);
694 dhcpcd_startinterface(ifp);
700 warn_iaid_conflict(struct interface *ifp, uint8_t *iaid)
705 TAILQ_FOREACH(ifn, ifp->ctx->ifaces, next) {
706 if (ifn == ifp)
721 if (ifn && strcmp(ifp->name, ifn->name))
722 logger(ifp->ctx, LOG_ERR,
724 ifp->name, ifn->name);
728 pre_start(struct interface *ifp)
735 if (ifp->options->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) {
736 logger(ifp->ctx, LOG_ERR, "%s: ipv6_start: %m", ifp->name);
737 ifp->options->options &= ~DHCPCD_IPV6;
744 struct interface *ifp = arg;
745 struct if_options *ifo = ifp->options;
752 switch (ifp->carrier) {
756 logger(ifp->ctx, LOG_INFO, "%s: waiting for carrier",
757 ifp->name);
762 if ((carrier = if_carrier(ifp)) == LINK_UNKNOWN) {
765 eloop_timeout_add_tv(ifp->ctx->eloop,
766 &tv, dhcpcd_startinterface, ifp);
768 dhcpcd_handlecarrier(ifp->ctx, carrier,
769 ifp->flags, ifp->name);
776 if (ifp->ctx->duid == NULL) {
777 if (duid_init(ifp) == 0)
780 logger(ifp->ctx, LOG_INFO, "DUID %s",
781 hwaddr_ntoa(ifp->ctx->duid,
782 ifp->ctx->duid_len,
791 logger(ifp->ctx, LOG_INFO, "%s: IAID %s", ifp->name,
794 warn_iaid_conflict(ifp, ifo->iaid);
799 logger(ifp->ctx, LOG_INFO, "%s: IAID %s",
800 ifp->name, hwaddr_ntoa(ifo->ia[i].iaid,
803 warn_iaid_conflict(ifp, ifo->ia[i].iaid);
811 ipv6nd_startrs(ifp);
814 dhcp6_find_delegates(ifp);
822 nolease = dhcp6_start(ifp, DH6S_INIT);
836 nolease = dhcp6_start(ifp, DH6S_INIT);
840 logger(ifp->ctx, LOG_ERR,
841 "%s: dhcp6_start: %m", ifp->name);
846 dhcp_start(ifp);
852 struct interface *ifp = arg;
854 pre_start(ifp);
855 if (if_up(ifp) == -1)
856 logger(ifp->ctx, LOG_ERR, "%s: if_up: %m", ifp->name);
858 if (ifp->options->options & DHCPCD_LINK &&
859 ifp->carrier == LINK_UNKNOWN)
863 if ((carrier = if_carrier(ifp)) != LINK_UNKNOWN) {
864 dhcpcd_handlecarrier(ifp->ctx, carrier,
865 ifp->flags, ifp->name);
868 logger(ifp->ctx, LOG_INFO,
870 ifp->name);
873 dhcpcd_startinterface(ifp);
891 dhcpcd_initstate1(struct interface *ifp, int argc, char **argv,
896 configure_interface(ifp, argc, argv, options);
897 ifo = ifp->options;
899 if (ifo->options & DHCPCD_IPV4 && ipv4_init(ifp->ctx) == -1) {
900 logger(ifp->ctx, LOG_ERR, "ipv4_init: %m");
903 if (ifo->options & DHCPCD_IPV6 && ipv6_init(ifp->ctx) == NULL) {
904 logger(ifp->ctx, LOG_ERR, "ipv6_init: %m");
912 if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) {
913 logger(ifp->ctx, LOG_ERR, "%s: ipv6_start: %m", ifp->name);
919 dhcpcd_initstate(struct interface *ifp, unsigned long long options)
922 dhcpcd_initstate1(ifp, ifp->ctx->argc, ifp->ctx->argv, options);
926 run_preinit(struct interface *ifp)
929 pre_start(ifp);
930 if (ifp->ctx->options & DHCPCD_TEST)
933 script_runreason(ifp, "PREINIT");
935 if (ifp->options->options & DHCPCD_LINK && ifp->carrier != LINK_UNKNOWN)
936 script_runreason(ifp,
937 ifp->carrier == LINK_UP ? "CARRIER" : "NOCARRIER");
945 struct interface *ifp, *iff, *ifn;
951 ifp = if_find(ctx->ifaces, ifname);
952 if (ifp == NULL) {
956 logger(ctx, LOG_DEBUG, "%s: interface departed", ifp->name);
957 ifp->options->options |= DHCPCD_DEPARTED;
958 stop_interface(ifp);
977 TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) {
978 if (strcmp(ifp->name, ifname) != 0)
982 iff = if_find(ctx->ifaces, ifp->name);
986 iff->flags = ifp->flags;
987 iff->hwlen = ifp->hwlen;
988 if (ifp->hwlen != 0)
989 memcpy(iff->hwaddr, ifp->hwaddr, iff->hwlen);
991 logger(ctx, LOG_DEBUG, "%s: interface added", ifp->name);
992 TAILQ_REMOVE(ifs, ifp, next);
993 TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next);
994 dhcpcd_initstate(ifp, 0);
995 run_preinit(ifp);
996 iff = ifp;
1003 while ((ifp = TAILQ_FIRST(ifs))) {
1004 TAILQ_REMOVE(ifs, ifp, next);
1005 if_free(ifp);
1018 struct interface *ifp;
1019 char buf[sizeof(ifp->hwaddr) * 3];
1021 ifp = if_find(ctx->ifaces, ifname);
1022 if (ifp == NULL)
1025 if (hwlen > sizeof(ifp->hwaddr)) {
1027 logger(ctx, LOG_ERR, "%s: %s: %m", ifp->name, __func__);
1031 if (ifp->hwlen == hwlen && memcmp(ifp->hwaddr, hwaddr, hwlen) == 0)
1034 logger(ctx, LOG_INFO, "%s: new hardware address: %s", ifp->name,
1036 ifp->hwlen = hwlen;
1037 memcpy(ifp->hwaddr, hwaddr, hwlen);
1043 struct interface *ifp;
1044 ifp = if_find(ctx->ifaces, ifname);
1045 if (ifp == NULL)
1051 dhcpcd_startinterface(ifp);
1057 struct interface *ifp;
1058 ifp = if_find(ctx->ifaces, ifname);
1059 if (ifp == NULL)
1065 stop_interface(ifp);
1071 struct interface *ifp;
1072 TAILQ_FOREACH(ifp, ctx->ifaces, next) {
1073 stop_interface(ifp);
1080 struct interface *ifp;
1082 ifp = if_find(ctx->ifaces, ifname);
1083 if (ifp == NULL)
1089 dhcp_drop(ifp, "RELEASE");
1093 if_reboot(struct interface *ifp, int argc, char **argv)
1097 oldopts = ifp->options->options;
1098 script_runreason(ifp, "RECONFIGURE");
1099 dhcpcd_initstate1(ifp, argc, argv, 0);
1100 dhcp_reboot_newopts(ifp, oldopts);
1101 dhcp6_reboot(ifp);
1102 dhcpcd_prestartinterface(ifp);
1126 struct interface *ifn, *ifp;
1134 while ((ifp = TAILQ_FIRST(ifs))) {
1135 TAILQ_REMOVE(ifs, ifp, next);
1136 ifn = if_find(ctx->ifaces, ifp->name);
1142 if_free(ifp);
1144 TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next);
1145 dhcpcd_initstate1(ifp, argc, argv, 0);
1146 run_preinit(ifp);
1147 dhcpcd_prestartinterface(ifp);
1156 struct interface *ifp;
1162 TAILQ_FOREACH_REVERSE(ifp, ctx->ifaces, if_head, next) {
1163 if (!(ifp->options->options & DHCPCD_PFXDLGONLY))
1166 if (ifp == NULL)
1169 ifp->options->options |= DHCPCD_RELEASE;
1170 ifp->options->options &= ~DHCPCD_PERSISTENT;
1172 ifp->options->options |= DHCPCD_EXITING;
1173 stop_interface(ifp);
1185 struct interface *ifp;
1215 TAILQ_FOREACH(ifp, ctx->ifaces, next) {
1216 ipv4_applyaddr(ifp);
1286 struct interface *ifp;
1290 TAILQ_FOREACH(ifp, fd->ctx->ifaces, next) {
1292 if (D_STATE_RUNNING(ifp))
1294 if (RS_STATE_RUNNING(ifp))
1296 if (D6_STATE_RUNNING(ifp))
1302 TAILQ_FOREACH(ifp, fd->ctx->ifaces, next) {
1303 if (send_interface(fd, ifp) == -1)
1304 logger(ifp->ctx, LOG_ERR,
1313 struct interface *ifp;
1389 if ((ifp = if_find(ctx->ifaces, argv[oi])) == NULL)
1392 ifp->options->options |= DHCPCD_RELEASE;
1393 ifp->options->options &= ~DHCPCD_PERSISTENT;
1395 ifp->options->options |= DHCPCD_EXITING;
1396 stop_interface(ifp);
1436 struct interface *ifp;
1668 ifp = TAILQ_FIRST(ctx.ifaces);
1669 if (ifp == NULL) {
1670 ifp = calloc(1, sizeof(*ifp));
1671 if (ifp == NULL) {
1676 ifp->ctx = &ctx;
1677 TAILQ_INSERT_HEAD(ctx.ifaces, ifp, next);
1685 configure_interface(ifp, ctx.argc, ctx.argv, 0);
1687 ifp->options->options |= DHCPCD_PFXDLGONLY;
1689 if (dhcp_dump(ifp) == -1)
1693 if (dhcp6_dump(ifp) == -1)
1909 TAILQ_FOREACH(ifp, ctx.ifaces, next) {
1910 dhcpcd_initstate1(ifp, argc, argv, 0);
1917 TAILQ_FOREACH(ifp, ctx.ifaces, next) {
1918 run_preinit(ifp);
1919 if (ifp->carrier != LINK_DOWN)
1926 else if ((ifp = TAILQ_FIRST(ctx.ifaces)))
1927 t = ifp->options->timeout;
1950 TAILQ_FOREACH(ifp, ctx.ifaces, next) {
1952 dhcpcd_prestartinterface, ifp);
1968 while ((ifp = TAILQ_FIRST(ctx.ifaces))) {
1969 TAILQ_REMOVE(ctx.ifaces, ifp, next);
1970 if_free(ifp);