Lines Matching refs:statp

170 res_ninit(res_state statp) {  in res_ninit()  argument
172 return (__res_vinit(statp, 0)); in res_ninit()
177 __res_vinit(res_state statp, int preinit) { in __res_vinit() argument
193 RES_SET_H_ERRNO(statp, 0); in __res_vinit()
194 if (statp->_u._ext.ext != NULL) in __res_vinit()
195 res_ndestroy(statp); in __res_vinit()
198 statp->retrans = RES_TIMEOUT; in __res_vinit()
199 statp->retry = RES_DFLRETRY; in __res_vinit()
200 statp->options = RES_DEFAULT; in __res_vinit()
201 res_rndinit(statp); in __res_vinit()
202 statp->id = res_nrandomid(statp); in __res_vinit()
230 statp->nscount = 0; in __res_vinit()
231 statp->ndots = 1; in __res_vinit()
232 statp->pfcode = 0; in __res_vinit()
233 statp->_vcsock = -1; in __res_vinit()
234 statp->_flags = 0; in __res_vinit()
235 statp->qhook = NULL; in __res_vinit()
236 statp->rhook = NULL; in __res_vinit()
237 statp->_u._ext.nscount = 0; in __res_vinit()
238 statp->_u._ext.ext = malloc(sizeof(*statp->_u._ext.ext)); in __res_vinit()
239 if (statp->_u._ext.ext != NULL) { in __res_vinit()
240 memset(statp->_u._ext.ext, 0, sizeof(*statp->_u._ext.ext)); in __res_vinit()
241 statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr; in __res_vinit()
242 strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa"); in __res_vinit()
243 strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int"); in __res_vinit()
257 RES_SET_H_ERRNO(statp, NETDB_INTERNAL); in __res_vinit()
261 statp->nsort = 0; in __res_vinit()
263 res_setservers(statp, u, nserv); in __res_vinit()
356 char buf[sizeof(statp->defdname)], *cp; in __res_vinit()
365 strncpy(statp->defdname, cp, in __res_vinit()
366 sizeof(statp->defdname) - 1); in __res_vinit()
367 statp->defdname[sizeof(statp->defdname) - 1] = '\0'; in __res_vinit()
374 (void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1); in __res_vinit()
375 statp->defdname[sizeof(statp->defdname) - 1] = '\0'; in __res_vinit()
385 cp = statp->defdname; in __res_vinit()
386 pp = statp->dnsrch; in __res_vinit()
388 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) { in __res_vinit()
428 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1); in __res_vinit()
429 statp->defdname[sizeof(statp->defdname) - 1] = '\0'; in __res_vinit()
430 if ((cp = strpbrk(statp->defdname, " \t\n")) != NULL) in __res_vinit()
444 strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1); in __res_vinit()
445 statp->defdname[sizeof(statp->defdname) - 1] = '\0'; in __res_vinit()
446 if ((cp = strchr(statp->defdname, '\n')) != NULL) in __res_vinit()
452 cp = statp->defdname; in __res_vinit()
453 pp = statp->dnsrch; in __res_vinit()
455 for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) { in __res_vinit()
477 sizeof(statp->_u._ext.ext->nsaddrs[0]); in __res_vinit()
491 if (statp->_u._ext.ext != NULL) { in __res_vinit()
492 memcpy(&statp->_u._ext.ext->nsaddrs[nserv], in __res_vinit()
496 sizeof(statp->nsaddr_list[nserv])) { in __res_vinit()
497 memcpy(&statp->nsaddr_list[nserv], in __res_vinit()
500 statp->nsaddr_list[nserv].sin_family = 0; in __res_vinit()
524 statp->sort_list[nsort].addr = a; in __res_vinit()
535 statp->sort_list[nsort].mask = a.s_addr; in __res_vinit()
537 statp->sort_list[nsort].mask = in __res_vinit()
538 net_mask(statp->sort_list[nsort].addr); in __res_vinit()
541 statp->sort_list[nsort].mask = in __res_vinit()
542 net_mask(statp->sort_list[nsort].addr); in __res_vinit()
552 res_setoptions(statp, buf + sizeof("options") - 1, "conf"); in __res_vinit()
557 statp->nscount = nserv; in __res_vinit()
559 statp->nsort = nsort; in __res_vinit()
569 nserv = get_nameservers(statp); in __res_vinit()
572 if (statp->defdname[0] == 0 && in __res_vinit()
573 gethostname(buf, sizeof(statp->defdname) - 1) == 0 && in __res_vinit()
575 strcpy(statp->defdname, cp + 1); in __res_vinit()
579 pp = statp->dnsrch; in __res_vinit()
580 *pp++ = statp->defdname; in __res_vinit()
584 for (cp = statp->defdname; *cp; cp++) in __res_vinit()
587 cp = statp->defdname; in __res_vinit()
588 while (pp < statp->dnsrch + MAXDFLSRCH) { in __res_vinit()
597 if (statp->options & RES_DEBUG) { in __res_vinit()
599 for (pp = statp->dnsrch; *pp; pp++) in __res_vinit()
607 res_setoptions(statp, cp, "env"); in __res_vinit()
608 statp->options |= RES_INIT; in __res_vinit()
609 return (statp->res_h_errno); in __res_vinit()
612 RES_SET_H_ERRNO(statp, NETDB_INTERNAL); in __res_vinit()
613 if (statp->_u._ext.ext != NULL) { in __res_vinit()
614 free(statp->_u._ext.ext); in __res_vinit()
615 statp->_u._ext.ext = NULL; in __res_vinit()
623 res_setoptions(res_state statp, const char *options, const char *source) in res_setoptions() argument
627 struct __res_state_ext *ext = statp->_u._ext.ext; in res_setoptions()
630 if (statp->options & RES_DEBUG) in res_setoptions()
642 statp->ndots = i; in res_setoptions()
644 statp->ndots = RES_MAXNDOTS; in res_setoptions()
646 if (statp->options & RES_DEBUG) in res_setoptions()
647 printf(";;\tndots=%d\n", statp->ndots); in res_setoptions()
652 statp->retrans = i; in res_setoptions()
654 statp->retrans = RES_MAXRETRANS; in res_setoptions()
656 if (statp->options & RES_DEBUG) in res_setoptions()
657 printf(";;\ttimeout=%d\n", statp->retrans); in res_setoptions()
666 statp->retrans = atoi(cp + sizeof("retrans:") - 1); in res_setoptions()
673 statp->retry = atoi(cp + sizeof("retry:") - 1); in res_setoptions()
678 statp->retry = i; in res_setoptions()
680 statp->retry = RES_MAXRETRY; in res_setoptions()
682 if (statp->options & RES_DEBUG) in res_setoptions()
683 printf(";;\tattempts=%d\n", statp->retry); in res_setoptions()
687 if (!(statp->options & RES_DEBUG)) { in res_setoptions()
690 statp->options |= RES_DEBUG; in res_setoptions()
698 statp->options |= RES_NOTLDQUERY; in res_setoptions()
700 statp->options |= RES_USE_INET6; in res_setoptions()
702 statp->options |= RES_ROTATE; in res_setoptions()
705 statp->options |= RES_NOCHECKNAME; in res_setoptions()
709 statp->options |= RES_USE_EDNS0; in res_setoptions()
713 statp->options |= RES_USE_DNAME; in res_setoptions()
735 statp->options |= RES_NO_NIBBLE2; in res_setoptions()
737 statp->options &= in res_setoptions()
768 res_rndinit(res_state statp) in res_rndinit() argument
776 memcpy(statp->_u._ext._rnd, &u32, 4); in res_rndinit()
778 memcpy(statp->_u._ext._rnd + 4, &u32, 4); in res_rndinit()
780 memcpy(statp->_u._ext._rnd + 8, &u32, 4); in res_rndinit()
782 memcpy(statp->_u._ext._rnd + 12, &u16, 2); in res_rndinit()
787 res_nrandomid(res_state statp) { in res_nrandomid() argument
795 memcpy(statp->_u._ext._rnd + 14, &u16, 2); in res_nrandomid()
798 MD5_Update(&ctx, statp->_u._ext._rnd, 16); in res_nrandomid()
799 MD5_Final(statp->_u._ext._rnd, &ctx); in res_nrandomid()
802 MD5Update(&ctx, statp->_u._ext._rnd, 16); in res_nrandomid()
803 MD5Final(statp->_u._ext._rnd, &ctx); in res_nrandomid()
805 memcpy(&u16, statp->_u._ext._rnd + 14, 2); in res_nrandomid()
817 res_nclose(res_state statp) { in res_nclose() argument
820 if (statp->_vcsock >= 0) { in res_nclose()
821 (void) close(statp->_vcsock); in res_nclose()
822 statp->_vcsock = -1; in res_nclose()
823 statp->_flags &= ~(RES_F_VC | RES_F_CONN); in res_nclose()
825 for (ns = 0; ns < statp->_u._ext.nscount; ns++) { in res_nclose()
826 if (statp->_u._ext.nssocks[ns] != -1) { in res_nclose()
827 (void) close(statp->_u._ext.nssocks[ns]); in res_nclose()
828 statp->_u._ext.nssocks[ns] = -1; in res_nclose()
834 res_ndestroy(res_state statp) { in res_ndestroy() argument
835 res_nclose(statp); in res_ndestroy()
836 if (statp->_u._ext.ext != NULL) in res_ndestroy()
837 free(statp->_u._ext.ext); in res_ndestroy()
838 statp->options &= ~RES_INIT; in res_ndestroy()
839 statp->_u._ext.ext = NULL; in res_ndestroy()
843 res_get_nibblesuffix(res_state statp) { in res_get_nibblesuffix() argument
844 if (statp->_u._ext.ext) in res_get_nibblesuffix()
845 return (statp->_u._ext.ext->nsuffix); in res_get_nibblesuffix()
850 res_get_nibblesuffix2(res_state statp) { in res_get_nibblesuffix2() argument
851 if (statp->_u._ext.ext) in res_get_nibblesuffix2()
852 return (statp->_u._ext.ext->nsuffix2); in res_get_nibblesuffix2()
857 res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) { in res_setservers() argument
862 res_nclose(statp); in res_setservers()
865 statp->_u._ext.nscount = 0; in res_setservers()
872 if (statp->_u._ext.ext) in res_setservers()
873 memcpy(&statp->_u._ext.ext->nsaddrs[nserv], in res_setservers()
875 if (size <= sizeof(statp->nsaddr_list[nserv])) in res_setservers()
876 memcpy(&statp->nsaddr_list[nserv], in res_setservers()
879 statp->nsaddr_list[nserv].sin_family = 0; in res_setservers()
886 if (statp->_u._ext.ext) in res_setservers()
887 memcpy(&statp->_u._ext.ext->nsaddrs[nserv], in res_setservers()
889 if (size <= sizeof(statp->nsaddr_list[nserv])) in res_setservers()
890 memcpy(&statp->nsaddr_list[nserv], in res_setservers()
893 statp->nsaddr_list[nserv].sin_family = 0; in res_setservers()
903 statp->nscount = nserv; in res_setservers()
908 res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) { in res_getservers() argument
913 for (i = 0; i < statp->nscount && i < cnt; i++) { in res_getservers()
914 if (statp->_u._ext.ext) in res_getservers()
915 family = statp->_u._ext.ext->nsaddrs[i].sin.sin_family; in res_getservers()
917 family = statp->nsaddr_list[i].sin_family; in res_getservers()
922 if (statp->_u._ext.ext) in res_getservers()
924 &statp->_u._ext.ext->nsaddrs[i], in res_getservers()
927 memcpy(&set->sin, &statp->nsaddr_list[i], in res_getservers()
934 if (statp->_u._ext.ext) in res_getservers()
936 &statp->_u._ext.ext->nsaddrs[i], in res_getservers()
939 memcpy(&set->sin6, &statp->nsaddr_list[i], in res_getservers()
950 return (statp->nscount); in res_getservers()