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

Lines Matching defs:ap

405 	const struct ipv6_addr *ap;
429 if ((ap = ipv6_linklocal(ifp)) == NULL) {
438 addr->s6_addr32[2] = ap->addr.s6_addr32[2];
439 addr->s6_addr32[3] = ap->addr.s6_addr32[3];
586 struct ipv6_addr *ap;
589 ap = arg;
590 ifa_flags = if_addrflags6(&ap->addr, ap->iface);
592 logger(ap->iface->ctx, LOG_ERR,
593 "%s: if_addrflags6: %m", ap->iface->name);
595 ipv6_handleifa(ap->iface->ctx, RTM_NEWADDR,
596 ap->iface->ctx->ifaces, ap->iface->name,
597 &ap->addr, ap->prefix_len, ifa_flags);
602 eloop_timeout_add_tv(ap->iface->ctx->eloop, &tv,
603 ipv6_checkaddrflags, ap);
614 struct ipv6_addr *ap;
623 TAILQ_FOREACH(ap, &state->addrs, next) {
624 if (IN6_ARE_ADDR_EQUAL(&ap->addr, &ia->addr)) {
625 TAILQ_REMOVE(&state->addrs, ap, next);
626 ipv6_freeaddr(ap);
634 ipv6_addaddr(struct ipv6_addr *ap, const struct timespec *now)
643 TAILQ_FOREACH(ifp, ap->iface->ctx->ifaces, next) {
644 if (ifp == ap->iface || strcmp(ifp->name, ap->iface->name) == 0)
650 if (IN6_ARE_ADDR_EQUAL(&nap->addr, &ap->addr)) {
657 if (!(ap->flags & IPV6_AF_DADCOMPLETED) &&
658 ipv6_iffindaddr(ap->iface, &ap->addr))
659 ap->flags |= IPV6_AF_DADCOMPLETED;
661 logger(ap->iface->ctx, ap->flags & IPV6_AF_NEW ? LOG_INFO : LOG_DEBUG,
662 "%s: adding address %s", ap->iface->name, ap->saddr);
663 if (ap->prefix_pltime == ND6_INFINITE_LIFETIME &&
664 ap->prefix_vltime == ND6_INFINITE_LIFETIME)
665 logger(ap->iface->ctx, LOG_DEBUG,
667 ap->iface->name);
668 else if (ap->prefix_pltime == ND6_INFINITE_LIFETIME)
669 logger(ap->iface->ctx, LOG_DEBUG,
671 ap->iface->name, ap->prefix_vltime);
672 else if (ap->prefix_vltime == ND6_INFINITE_LIFETIME)
673 logger(ap->iface->ctx, LOG_DEBUG,
675 ap->iface->name, ap->prefix_pltime);
677 logger(ap
679 ap->iface->name, ap->prefix_pltime, ap->prefix_vltime);
682 pltime = ap->prefix_pltime;
683 vltime = ap->prefix_vltime;
684 if (timespecisset(&ap->acquired) &&
685 (ap->prefix_pltime != ND6_INFINITE_LIFETIME ||
686 ap->prefix_vltime != ND6_INFINITE_LIFETIME))
694 timespecsub(now, &ap->acquired, &n);
695 if (ap->prefix_pltime != ND6_INFINITE_LIFETIME)
696 ap->prefix_pltime -= (uint32_t)n.tv_sec;
697 if (ap->prefix_vltime != ND6_INFINITE_LIFETIME)
698 ap->prefix_vltime -= (uint32_t)n.tv_sec;
701 if (if_addaddress6(ap) == -1) {
702 logger(ap->iface->ctx, LOG_ERR, "if_addaddress6: %m");
704 logger(ap->iface->ctx, LOG_DEBUG,
707 ap->iface->name, ap->prefix_pltime, ap->prefix_vltime);
710 ap->prefix_pltime = pltime;
711 ap->prefix_vltime = vltime;
717 if (ap->flags & IPV6_AF_TEMPORARY &&
718 ap->prefix_pltime &&
719 ap->prefix_vltime &&
720 ap->iface->options->options & DHCPCD_IPV6RA_OWN &&
721 ip6_use_tempaddr(ap->iface->name))
722 eloop_timeout_add_sec(ap->iface->ctx->eloop,
723 (time_t)ap->prefix_pltime - REGEN_ADVANCE,
724 ipv6_regentempaddr, ap);
728 ap->prefix_pltime = pltime;
729 ap->prefix_vltime = vltime;
731 ap->flags &= ~IPV6_AF_NEW;
732 ap->flags |= IPV6_AF_ADDED;
733 if (ap->delegating_iface)
734 ap->flags |= IPV6_AF_DELEGATED;
737 eloop_timeout_delete(ap->iface->ctx->eloop,
738 ipv6_checkaddrflags, ap);
739 if (!(ap->flags & IPV6_AF_DADCOMPLETED)) {
743 eloop_timeout_add_tv(ap->iface->ctx->eloop,
744 &tv, ipv6_checkaddrflags, ap);
781 struct ipv6_addr *ap, *apn, *apf;
787 TAILQ_FOREACH_SAFE(ap, addrs, next, apn) {
788 if (ap->prefix_vltime == 0) {
789 if (ap->flags & IPV6_AF_ADDED) {
790 ipv6_deleteaddr(ap);
793 eloop_q_timeout_delete(ap->iface->ctx->eloop,
794 0, NULL, ap);
795 if (ap->flags & IPV6_AF_REQUEST) {
796 ap->flags &= ~IPV6_AF_ADDED;
798 TAILQ_REMOVE(addrs, ap, next);
799 ipv6_freeaddr(ap);
801 } else if (!(ap->flags & IPV6_AF_STALE) &&
802 !IN6_IS_ADDR_UNSPECIFIED(&ap->addr))
804 apf = ipv6_findaddr(ap->iface->ctx,
805 &ap->addr, IPV6_AF_ADDED);
806 if (apf && apf->iface != ap->iface &&
807 strcmp(apf->iface->name, ap->iface->name))
809 if (apf->iface->metric <= ap->iface->metric) {
812 ap->iface->name,
813 ap->saddr,
820 ap->saddr,
821 ap->iface->name);
830 if (ap->flags & IPV6_AF_NEW)
834 ipv6_addaddr(ap, &now);
842 ipv6_freeaddr(struct ipv6_addr *ap)
845 eloop_q_timeout_delete(ap->iface->ctx->eloop, 0, NULL, ap);
846 free(ap);
853 struct ipv6_addr *ap, *apn, *apf;
857 TAILQ_FOREACH_SAFE(ap, addrs, next, apn) {
858 if (ifd && ap->delegating_iface != ifd)
861 TAILQ_REMOVE(addrs, ap, next);
862 if (drop && ap->flags & IPV6_AF_ADDED &&
863 (ap->iface->options->options &
868 TAILQ_REMOVE(addrs, ap, next);
870 apf = ipv6_findaddr(ap->iface->ctx, &ap->addr, 0);
872 (apf->iface != ap->iface &&
873 strcmp(apf->iface->name, ap->iface->name)))
874 ipv6_deleteaddr(ap);
875 if (!(ap->iface->options->options &
883 ipv6_freeaddr(ap);
886 ipv6_freeaddr(ap);
922 struct ipv6_addr *ap;
952 TAILQ_FOREACH(ap, &state->addrs, next) {
953 if (IN6_ARE_ADDR_EQUAL(&ap->addr, addr))
959 if (ap) {
960 TAILQ_REMOVE(&state->addrs, ap, next);
961 ipv6_freeaddr(ap);
965 if (ap == NULL) {
969 ap = calloc(1, sizeof(*ap));
970 ap->iface = ifp;
971 ap->addr = *addr;
972 ap->prefix_len = prefix_len;
973 ipv6_makeprefix(&ap->prefix, &ap->addr,
974 ap->prefix_len);
978 snprintf(ap->saddr, sizeof(ap->saddr),
980 if (if_getlifetime6(ap) == -1) {
989 ap->prefix_pltime = 0;
990 ap->prefix_vltime =
1003 ap->acquired = ap->created;
1005 ap, next);
1007 ap->addr_flags = flags;
1009 if (ap->addr_flags & IN6_IFF_TEMPORARY)
1010 ap->flags |= IPV6_AF_TEMPORARY;
1012 if (IN6_IS_ADDR_LINKLOCAL(&ap->addr)) {
1014 if (ap->addr_flags & IN6_IFF_TENTATIVE) {
1019 ap->iface->ctx->eloop,
1020 &tv, ipv6_checkaddrflags, ap);
1025 if (!(ap->addr_flags & IN6_IFF_NOTUSEABLE)) {
1048 const struct ipv6_addr *ap;
1052 TAILQ_FOREACH(ap, &state->addrs, next) {
1054 if (IN6_IS_ADDR_LINKLOCAL(&ap->addr) &&
1055 !(ap->addr_flags & IN6_IFF_NOTUSEABLE))
1056 return ap;
1058 if (IN6_ARE_ADDR_EQUAL(&ap->addr, addr) &&
1059 !(ap->addr_flags & IN6_IFF_TENTATIVE))
1060 return ap;
1095 struct ipv6_addr *ap;
1097 ap = calloc(1, sizeof(*ap));
1098 if (ap != NULL) {
1099 ap->iface = ifp;
1100 ap->prefix.s6_addr32[0] = htonl(0xfe800000);
1101 ap->prefix.s6_addr32[1] = 0;
1102 ap->prefix_len = 64;
1103 ap->dadcounter = 0;
1104 ap->prefix_pltime = ND6_INFINITE_LIFETIME;
1105 ap->prefix_vltime = ND6_INFINITE_LIFETIME;
1106 ap->flags = IPV6_AF_NEW;
1107 ap->addr_flags = IN6_IFF_TENTATIVE;
1109 return ap;
1120 struct ipv6_addr *ap, *ap2;
1149 ap = ipv6_newlinklocal(ifp);
1150 if (ap == NULL)
1156 if (ipv6_makestableprivate(&ap->addr,
1157 &ap->prefix, ap->prefix_len, ifp, &dadcounter) == -1)
1159 free(ap);
1162 ap->dadcounter = dadcounter;
1164 memcpy(ap->addr.s6_addr, ap->prefix.s6_addr, 8);
1168 ap->addr.s6_addr[ 8] = ifp->hwaddr[0];
1169 ap->addr.s6_addr[ 9] = ifp->hwaddr[1];
1170 ap->addr.s6_addr[10] = ifp->hwaddr[2];
1171 ap->addr.s6_addr[11] = 0xff;
1172 ap->addr.s6_addr[12] = 0xfe;
1173 ap->addr.s6_addr[13] = ifp->hwaddr[3];
1174 ap->addr.s6_addr[14] = ifp->hwaddr[4];
1175 ap->addr.s6_addr[15] = ifp->hwaddr[5];
1177 memcpy(&ap->addr.s6_addr[8], ifp->hwaddr, 8);
1179 free(ap);
1187 if (EUI64_GROUP(&ap->addr)) {
1188 free(ap);
1192 EUI64_TO_IFID(&ap->addr);
1197 if (IN6_ARE_ADDR_EQUAL(&ap->addr, &ap2->addr)) {
1205 free(ap);
1213 free(ap);
1219 inet_ntop(AF_INET6, &ap->addr, ap->saddr, sizeof(ap->saddr));
1220 TAILQ_INSERT_TAIL(&state->addrs, ap, next);
1221 ipv6_addaddr(ap, NULL);
1230 const struct ipv6_addr *ap;
1239 TAILQ_FOREACH(ap, &state->addrs, next) {
1240 if (IN6_IS_ADDR_LINKLOCAL(&ap->addr) &&
1241 !(ap->addr_flags & IN6_IFF_DUPLICATED))
1249 ap = NULL;
1251 if (ap == NULL && ipv6_addlinklocal(ifp) == -1)
1304 struct ipv6_addr *ap, *apn;
1309 TAILQ_FOREACH_SAFE(ap, addrs, next, apn) {
1310 if (!IN6_ARE_ADDR_EQUAL(addr, &ap->addr)) {
1311 if (ap->flags & IPV6_AF_ADDED &&
1312 !(ap->flags & IPV6_AF_DADCOMPLETED))
1318 if (ap->flags & IPV6_AF_ADDED) {
1319 logger(ap->iface->ctx, LOG_INFO,
1321 ap->iface->name, ap->saddr);
1322 ap->flags &= ~IPV6_AF_ADDED;
1329 if ((ap->flags & IPV6_AF_DADCOMPLETED) == 0) {
1332 ap->flags |= IPV6_AF_DUPLICATED;
1334 ap->flags &= ~IPV6_AF_DUPLICATED;
1335 if (ap->dadcallback)
1336 ap->dadcallback(ap);
1339 ap->flags |= IPV6_AF_DADCOMPLETED;
1491 const struct ipv6_addr *ap;
1529 TAILQ_FOREACH(ap, &cstate->addrs, next) {
1530 if (IN6_ARE_ADDR_EQUAL(&ap->addr, &addr)) {
1600 struct ipv6_addr *ap, *first;
1604 TAILQ_FOREACH_REVERSE(ap, &state->addrs, ipv6_addrhead, next) {
1605 if (ap->flags & IPV6_AF_TEMPORARY &&
1606 ap->prefix_pltime &&
1607 IN6_ARE_ADDR_EQUAL(&ia->prefix, &ap->prefix))
1612 if (ap->prefix_pltime -
1614 ap->acquired.tv_sec)
1618 return ap;
1621 if (!(ap->flags & IPV6_AF_ADDED))
1622 ap->flags |= IPV6_AF_NEW | IPV6_AF_AUTOCONF;
1623 ap->flags &= ~IPV6_AF_STALE;
1628 ap->prefix_pltime = 0;
1633 ipv6_regen_desync(ap->iface, 0);
1639 max = ap->created.tv_sec +
1640 ip6_temp_preferred_lifetime(ap->iface->name) -
1643 ap->prefix_pltime = ia->prefix_pltime;
1645 ap->prefix_pltime =
1650 max = ap->created.tv_sec +
1651 ip6_temp_valid_lifetime(ap->iface->name);
1653 ap->prefix_vltime = ia->prefix_vltime;
1655 ap->prefix_vltime =
1659 ap->acquired = ia->acquired;
1666 return ap;
1668 first = ap;