Home | History | Annotate | Download | only in resolv

Lines Matching full:statp

161 res_ninit(res_state statp) {
164 return (__res_vinit(statp, 0));
169 __res_vinit(res_state statp, int preinit) {
182 if ((statp->options & RES_INIT) != 0U)
183 res_ndestroy(statp);
186 statp->retrans = RES_TIMEOUT;
187 statp->retry = RES_DFLRETRY;
188 statp->options = RES_DEFAULT;
189 statp->id = res_randomid();
217 statp->nscount = 0;
218 statp->ndots = 1;
219 statp->pfcode = 0;
220 statp->_vcsock = -1;
221 statp->_flags = 0;
222 statp->qhook = NULL;
223 statp->rhook = NULL;
224 statp->_u._ext.nscount = 0;
225 statp->_u._ext.ext = malloc(sizeof(*statp->_u._ext.ext));
226 if (statp->_u._ext.ext != NULL) {
227 memset(statp->_u._ext.ext, 0, sizeof(*statp->_u._ext.ext));
228 statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
229 strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa");
230 strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int");
232 statp->nsort = 0;
233 res_setservers(statp, u, nserv);
238 (void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
239 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
249 cp = statp->defdname;
250 pp = statp->dnsrch;
252 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) {
271 statp->nscount = nserv;
296 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
297 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
298 if ((cp = strpbrk(statp->defdname, " \t\n")) != NULL)
312 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
313 statp->defdname[sizeof(statp->defdname) - 1] = '\0';
314 if ((cp = strchr(statp->defdname, '\n')) != NULL)
320 cp = statp->defdname;
321 pp = statp->dnsrch;
323 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) {
345 sizeof(statp->_u._ext.ext->nsaddrs[0]);
359 if (statp->_u._ext.ext != NULL) {
360 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
364 sizeof(statp->nsaddr_list[nserv])) {
365 memcpy(&statp->nsaddr_list[nserv],
368 statp->nsaddr_list[nserv].sin_family = 0;
391 statp->sort_list[nsort].addr = a;
402 statp->sort_list[nsort].mask = a.s_addr;
404 statp->sort_list[nsort].mask =
405 net_mask(statp->sort_list[nsort].addr);
408 statp->sort_list[nsort].mask =
409 net_mask(statp->sort_list[nsort].addr);
418 res_setoptions(statp, buf + sizeof("options") - 1, "conf");
423 statp->nscount = nserv;
424 statp->nsort = nsort;
434 nserv = get_nameservers(statp);
437 if (statp->defdname[0] == 0 &&
438 gethostname(buf, sizeof(statp->defdname) - 1) == 0 &&
440 strcpy(statp->defdname, cp + 1);
444 pp = statp->dnsrch;
445 *pp++ = statp->defdname;
449 for (cp = statp->defdname; *cp; cp++)
452 cp = statp->defdname;
453 while (pp < statp->dnsrch + MAXDFLSRCH) {
462 if (statp->options & RES_DEBUG) {
464 for (pp = statp->dnsrch; *pp; pp++)
472 res_setoptions(statp, cp, "env");
474 statp->nscount = nserv;
475 statp->options |= RES_INIT;
481 res_setoptions(res_state statp, const char *options, const char *source)
485 struct __res_state_ext *ext = statp->_u._ext.ext;
488 if (statp->options & RES_DEBUG)
500 statp->ndots = i;
502 statp->ndots = RES_MAXNDOTS;
504 if (statp->options & RES_DEBUG)
505 printf(";;\tndots=%d\n", statp->ndots);
510 statp->retrans = i;
512 statp->retrans = RES_MAXRETRANS;
514 if (statp->options & RES_DEBUG)
515 printf(";;\ttimeout=%d\n", statp->retrans);
520 statp->retry = i;
522 statp->retry = RES_MAXRETRY;
524 if (statp->options & RES_DEBUG)
525 printf(";;\tattempts=%d\n", statp->retry);
529 if (!(statp->options & RES_DEBUG)) {
532 statp->options |= RES_DEBUG;
540 statp->options |= RES_NOTLDQUERY;
542 statp->options |= RES_USE_INET6;
544 statp->options |= RES_ROTATE;
547 statp->options |= RES_NOCHECKNAME;
551 statp->options |= RES_USE_EDNS0;
555 statp->options |= RES_USE_DNAME;
577 statp->options |= RES_NO_NIBBLE2;
579 statp->options &=
657 res_nclose(res_state statp) {
660 if (statp->_vcsock >= 0) {
661 (void) close(statp->_vcsock);
662 statp->_vcsock = -1;
663 statp->_flags &= ~(RES_F_VC | RES_F_CONN);
665 for (ns = 0; ns < statp->_u._ext.nscount; ns++) {
666 if (statp->_u._ext.nssocks[ns] != -1) {
667 (void) close(statp->_u._ext.nssocks[ns]);
668 statp->_u._ext.nssocks[ns] = -1;
674 res_ndestroy(res_state statp) {
675 res_nclose(statp);
676 if (statp->_u._ext.ext != NULL)
677 free(statp->_u._ext.ext);
678 statp->options &= ~RES_INIT;
679 statp->_u._ext.ext = NULL;
683 res_get_nibblesuffix(res_state statp) {
684 if (statp->_u._ext.ext)
685 return (statp->_u._ext.ext->nsuffix);
690 res_get_nibblesuffix2(res_state statp) {
691 if (statp->_u._ext.ext)
692 return (statp->_u._ext.ext->nsuffix2);
697 res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) {
702 res_nclose(statp);
705 statp->_u._ext.nscount = 0;
712 if (statp->_u._ext.ext)
713 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
715 if (size <= sizeof(statp->nsaddr_list[nserv]))
716 memcpy(&statp->nsaddr_list[nserv],
720 statp->nsaddr_list[nserv].sin_family = 0;
728 if (statp->_u._ext.ext)
729 memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
731 if (size <= sizeof(statp->nsaddr_list[nserv]))
732 memcpy(&statp->nsaddr_list[nserv],
735 statp->nsaddr_list[nserv].sin_family = 0;
745 statp->nscount = nserv;
750 res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) {
755 for (i = 0; i < statp->nscount && i < cnt; i++) {
756 if (statp->_u._ext.ext)
757 family = statp->_u._ext.ext->nsaddrs[i].sin.sin_family;
759 family = statp->nsaddr_list[i].sin_family;
764 if (statp->_u._ext.ext)
766 &statp->_u._ext.ext->nsaddrs[i],
769 memcpy(&set->sin, &statp->nsaddr_list[i],
776 if (statp->_u._ext.ext)
778 &statp->_u._ext.ext->nsaddrs[i],
781 memcpy(&set->sin6, &statp->nsaddr_list[i],
792 return (statp->nscount);
796 void res_setiface(res_state statp, const char* iface)
798 if (statp != NULL) {
801 int len = sizeof(statp->iface);
802 strncpy(statp->iface, iface, len - 1);
803 statp->iface[len - 1] = '\0';
805 statp->iface[0] = '\0';
810 void res_setmark(res_state statp, int mark)
812 if (statp != NULL) {
813 statp->_mark = mark;