Lines Matching refs:statp

159 res_ninit(res_state statp) {  in res_ninit()  argument
162 return (__res_vinit(statp, 0)); in res_ninit()
167 __res_vinit(res_state statp, int preinit) { in __res_vinit() argument
190 if ((statp->options & RES_INIT) != 0U) in __res_vinit()
191 res_ndestroy(statp); in __res_vinit()
194 statp->netid = NETID_UNSET; in __res_vinit()
195 statp->retrans = RES_TIMEOUT; in __res_vinit()
196 statp->retry = RES_DFLRETRY; in __res_vinit()
197 statp->options = RES_DEFAULT; in __res_vinit()
198 statp->id = res_randomid(); in __res_vinit()
199 statp->_mark = MARK_UNSET; in __res_vinit()
227 statp->nscount = 0; in __res_vinit()
228 statp->ndots = 1; in __res_vinit()
229 statp->pfcode = 0; in __res_vinit()
230 statp->_vcsock = -1; in __res_vinit()
231 statp->_flags = 0; in __res_vinit()
232 statp->qhook = NULL; in __res_vinit()
233 statp->rhook = NULL; in __res_vinit()
234 statp->_u._ext.nscount = 0; in __res_vinit()
235 statp->_u._ext.ext = malloc(sizeof(*statp->_u._ext.ext)); in __res_vinit()
236 if (statp->_u._ext.ext != NULL) { in __res_vinit()
237 memset(statp->_u._ext.ext, 0, sizeof(*statp->_u._ext.ext)); in __res_vinit()
238 statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr; in __res_vinit()
239 strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa"); in __res_vinit()
240 strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int"); in __res_vinit()
242 statp->nsort = 0; in __res_vinit()
243 res_setservers(statp, u, nserv); in __res_vinit()
250 (void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1); in __res_vinit()
251 statp->defdname[sizeof(statp->defdname) - 1] = '\0'; in __res_vinit()
261 cp = statp->defdname; in __res_vinit()
262 pp = statp->dnsrch; in __res_vinit()
264 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) { in __res_vinit()
283 statp->nscount = nserv; in __res_vinit()
308 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1); in __res_vinit()
309 statp->defdname[sizeof(statp->defdname) - 1] = '\0'; in __res_vinit()
310 if ((cp = strpbrk(statp->defdname, " \t\n")) != NULL) in __res_vinit()
324 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1); in __res_vinit()
325 statp->defdname[sizeof(statp->defdname) - 1] = '\0'; in __res_vinit()
326 if ((cp = strchr(statp->defdname, '\n')) != NULL) in __res_vinit()
332 cp = statp->defdname; in __res_vinit()
333 pp = statp->dnsrch; in __res_vinit()
335 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) { in __res_vinit()
357 sizeof(statp->_u._ext.ext->nsaddrs[0]); in __res_vinit()
371 if (statp->_u._ext.ext != NULL) { in __res_vinit()
372 memcpy(&statp->_u._ext.ext->nsaddrs[nserv], in __res_vinit()
376 sizeof(statp->nsaddr_list[nserv])) { in __res_vinit()
377 memcpy(&statp->nsaddr_list[nserv], in __res_vinit()
380 statp->nsaddr_list[nserv].sin_family = 0; in __res_vinit()
403 statp->sort_list[nsort].addr = a; in __res_vinit()
414 statp->sort_list[nsort].mask = a.s_addr; in __res_vinit()
416 statp->sort_list[nsort].mask = in __res_vinit()
417 net_mask(statp->sort_list[nsort].addr); in __res_vinit()
420 statp->sort_list[nsort].mask = in __res_vinit()
421 net_mask(statp->sort_list[nsort].addr); in __res_vinit()
430 res_setoptions(statp, buf + sizeof("options") - 1, "conf"); in __res_vinit()
435 statp->nscount = nserv; in __res_vinit()
436 statp->nsort = nsort; in __res_vinit()
446 nserv = get_nameservers(statp); in __res_vinit()
449 if (statp->defdname[0] == 0 && in __res_vinit()
450 gethostname(buf, sizeof(statp->defdname) - 1) == 0 && in __res_vinit()
452 strcpy(statp->defdname, cp + 1); in __res_vinit()
456 pp = statp->dnsrch; in __res_vinit()
457 *pp++ = statp->defdname; in __res_vinit()
461 for (cp = statp->defdname; *cp; cp++) in __res_vinit()
464 cp = statp->defdname; in __res_vinit()
465 while (pp < statp->dnsrch + MAXDFLSRCH) { in __res_vinit()
474 if (statp->options & RES_DEBUG) { in __res_vinit()
476 for (pp = statp->dnsrch; *pp; pp++) in __res_vinit()
484 res_setoptions(statp, cp, "env"); in __res_vinit()
486 statp->nscount = nserv; in __res_vinit()
487 statp->options |= RES_INIT; in __res_vinit()
493 res_setoptions(res_state statp, const char *options, const char *source) in res_setoptions() argument
497 struct __res_state_ext *ext = statp->_u._ext.ext; in res_setoptions()
500 if (statp->options & RES_DEBUG) in res_setoptions()
512 statp->ndots = i; in res_setoptions()
514 statp->ndots = RES_MAXNDOTS; in res_setoptions()
516 if (statp->options & RES_DEBUG) in res_setoptions()
517 printf(";;\tndots=%d\n", statp->ndots); in res_setoptions()
522 statp->retrans = i; in res_setoptions()
524 statp->retrans = RES_MAXRETRANS; in res_setoptions()
526 if (statp->options & RES_DEBUG) in res_setoptions()
527 printf(";;\ttimeout=%d\n", statp->retrans); in res_setoptions()
532 statp->retry = i; in res_setoptions()
534 statp->retry = RES_MAXRETRY; in res_setoptions()
536 if (statp->options & RES_DEBUG) in res_setoptions()
537 printf(";;\tattempts=%d\n", statp->retry); in res_setoptions()
541 if (!(statp->options & RES_DEBUG)) { in res_setoptions()
544 statp->options |= RES_DEBUG; in res_setoptions()
552 statp->options |= RES_NOTLDQUERY; in res_setoptions()
554 statp->options |= RES_USE_INET6; in res_setoptions()
556 statp->options |= RES_ROTATE; in res_setoptions()
559 statp->options |= RES_NOCHECKNAME; in res_setoptions()
563 statp->options |= RES_USE_EDNS0; in res_setoptions()
567 statp->options |= RES_USE_DNAME; in res_setoptions()
589 statp->options |= RES_NO_NIBBLE2; in res_setoptions()
591 statp->options &= in res_setoptions()
628 res_nclose(res_state statp) in res_nclose() argument
632 if (statp->_vcsock >= 0) { in res_nclose()
633 (void) close(statp->_vcsock); in res_nclose()
634 statp->_vcsock = -1; in res_nclose()
635 statp->_flags &= ~(RES_F_VC | RES_F_CONN); in res_nclose()
637 for (ns = 0; ns < statp->_u._ext.nscount; ns++) { in res_nclose()
638 if (statp->_u._ext.nssocks[ns] != -1) { in res_nclose()
639 (void) close(statp->_u._ext.nssocks[ns]); in res_nclose()
640 statp->_u._ext.nssocks[ns] = -1; in res_nclose()
646 res_ndestroy(res_state statp) in res_ndestroy() argument
648 res_nclose(statp); in res_ndestroy()
649 if (statp->_u._ext.ext != NULL) in res_ndestroy()
650 free(statp->_u._ext.ext); in res_ndestroy()
651 statp->options &= ~RES_INIT; in res_ndestroy()
652 statp->_u._ext.ext = NULL; in res_ndestroy()
656 res_get_nibblesuffix(res_state statp) in res_get_nibblesuffix() argument
658 if (statp->_u._ext.ext) in res_get_nibblesuffix()
659 return (statp->_u._ext.ext->nsuffix); in res_get_nibblesuffix()
664 res_get_nibblesuffix2(res_state statp) in res_get_nibblesuffix2() argument
666 if (statp->_u._ext.ext) in res_get_nibblesuffix2()
667 return (statp->_u._ext.ext->nsuffix2); in res_get_nibblesuffix2()
672 res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) in res_setservers() argument
678 res_nclose(statp); in res_setservers()
681 statp->_u._ext.nscount = 0; in res_setservers()
688 if (statp->_u._ext.ext) in res_setservers()
689 memcpy(&statp->_u._ext.ext->nsaddrs[nserv], in res_setservers()
691 if (size <= sizeof(statp->nsaddr_list[nserv])) in res_setservers()
692 memcpy(&statp->nsaddr_list[nserv], in res_setservers()
695 statp->nsaddr_list[nserv].sin_family = 0; in res_setservers()
702 if (statp->_u._ext.ext) in res_setservers()
703 memcpy(&statp->_u._ext.ext->nsaddrs[nserv], in res_setservers()
705 if (size <= sizeof(statp->nsaddr_list[nserv])) in res_setservers()
706 memcpy(&statp->nsaddr_list[nserv], in res_setservers()
709 statp->nsaddr_list[nserv].sin_family = 0; in res_setservers()
719 statp->nscount = nserv; in res_setservers()
724 res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) in res_getservers() argument
730 for (i = 0; i < statp->nscount && i < cnt; i++) { in res_getservers()
731 if (statp->_u._ext.ext) in res_getservers()
732 family = statp->_u._ext.ext->nsaddrs[i].sin.sin_family; in res_getservers()
734 family = statp->nsaddr_list[i].sin_family; in res_getservers()
739 if (statp->_u._ext.ext) in res_getservers()
741 &statp->_u._ext.ext->nsaddrs[i], in res_getservers()
744 memcpy(&set->sin, &statp->nsaddr_list[i], in res_getservers()
751 if (statp->_u._ext.ext) in res_getservers()
753 &statp->_u._ext.ext->nsaddrs[i], in res_getservers()
756 memcpy(&set->sin6, &statp->nsaddr_list[i], in res_getservers()
767 return (statp->nscount); in res_getservers()
771 void res_setnetid(res_state statp, unsigned netid) in res_setnetid() argument
773 if (statp != NULL) { in res_setnetid()
774 statp->netid = netid; in res_setnetid()
778 void res_setmark(res_state statp, unsigned mark) in res_setmark() argument
780 if (statp != NULL) { in res_setmark()
781 statp->_mark = mark; in res_setmark()