Lines Matching defs:iter
46 isc_interfaceiter_t *iter;
54 iter = isc_mem_get(mctx, sizeof(*iter));
55 if (iter == NULL)
58 iter->mctx = mctx;
59 iter->buf = NULL;
60 iter->bufsize = 0;
61 iter->ifaddrs = NULL;
68 iter->proc = fopen("/proc/net/if_inet6", "r");
70 iter->proc = NULL;
71 iter->valid = ISC_R_FAILURE;
74 if (getifaddrs(&iter->ifaddrs) < 0) {
91 iter->pos = NULL;
92 iter->result = ISC_R_FAILURE;
94 iter->magic = IFITER_MAGIC;
95 *iterp = iter;
100 if (iter->proc != NULL)
101 fclose(iter->proc);
103 if (iter->ifaddrs != NULL) /* just in case */
104 freeifaddrs(iter->ifaddrs);
105 isc_mem_put(mctx, iter, sizeof(*iter));
110 * Get information about the current interface to iter->current.
117 internal_current(isc_interfaceiter_t *iter) {
122 REQUIRE(VALID_IFITER(iter));
124 ifa = iter->pos;
127 if (iter->pos == NULL)
128 return (linux_if_inet6_current(iter));
146 memset(&iter->current, 0, sizeof(iter->current));
149 if (namelen > sizeof(iter->current.name) - 1)
150 namelen = sizeof(iter->current.name) - 1;
152 memset(iter->current.name, 0, sizeof(iter->current.name));
153 memmove(iter->current.name, ifa->ifa_name, namelen);
155 iter->current.flags = 0;
158 iter->current.flags |= INTERFACE_F_UP;
161 iter->current.flags |= INTERFACE_F_POINTTOPOINT;
164 iter->current.flags |= INTERFACE_F_LOOPBACK;
166 iter->current.af = family;
168 get_addr(family, &iter->current.address, ifa->ifa_addr, ifa->ifa_name);
171 get_addr(family, &iter->current.netmask, ifa->ifa_netmask,
175 (iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0)
176 get_addr(family, &iter->current.dstaddress, ifa->ifa_dstaddr,
190 internal_next(isc_interfaceiter_t *iter) {
192 if (iter->pos != NULL)
193 iter->pos = iter->pos->ifa_next;
194 if (iter->pos == NULL) {
197 return (linux_if_inet6_next(iter));
206 internal_destroy(isc_interfaceiter_t *iter) {
209 if (iter->proc != NULL)
210 fclose(iter->proc);
211 iter->proc = NULL;
213 if (iter->ifaddrs)
214 freeifaddrs(iter->ifaddrs);
215 iter->ifaddrs = NULL;
219 void internal_first(isc_interfaceiter_t *iter) {
222 linux_if_inet6_first(iter);
224 iter->pos = iter->ifaddrs;