Lines Matching full:hp
72 hostent_free(struct hostent *hp) in hostent_free() argument
76 free(hp->h_name); in hostent_free()
77 hp->h_name = NULL; in hostent_free()
78 if (hp->h_aliases != NULL) { in hostent_free()
79 for (ii = 0; hp->h_aliases[ii] != NULL; ii++) in hostent_free()
80 free(hp->h_aliases[ii]); in hostent_free()
81 free(hp->h_aliases); in hostent_free()
82 hp->h_aliases = NULL; in hostent_free()
84 if (hp->h_addr_list != NULL) { in hostent_free()
85 for (ii = 0; hp->h_addr_list[ii] != NULL; ii++) in hostent_free()
86 free(hp->h_addr_list[ii]); in hostent_free()
87 free(hp->h_addr_list); in hostent_free()
88 hp->h_addr_list = NULL; in hostent_free()
93 hostent_unpack(const nvlist_t *nvl, struct hostent *hp) in hostent_unpack() argument
99 hostent_free(hp); in hostent_unpack()
101 hp->h_name = strdup(nvlist_get_string(nvl, "name")); in hostent_unpack()
102 if (hp->h_name == NULL) in hostent_unpack()
104 hp->h_addrtype = (int)nvlist_get_number(nvl, "addrtype"); in hostent_unpack()
105 hp->h_length = (int)nvlist_get_number(nvl, "length"); in hostent_unpack()
108 hp->h_aliases = calloc(nitems + 1, sizeof(hp->h_aliases[0])); in hostent_unpack()
109 if (hp->h_aliases == NULL) in hostent_unpack()
114 hp->h_aliases[ii] = in hostent_unpack()
116 if (hp->h_aliases[ii] == NULL) in hostent_unpack()
119 hp->h_aliases[ii] = NULL; in hostent_unpack()
122 hp->h_addr_list = calloc(nitems + 1, sizeof(hp->h_addr_list[0])); in hostent_unpack()
123 if (hp->h_addr_list == NULL) in hostent_unpack()
126 hp->h_addr_list[ii] = malloc(hp->h_length); in hostent_unpack()
127 if (hp->h_addr_list[ii] == NULL) in hostent_unpack()
132 hp->h_addr_list[ii], hp->h_length); in hostent_unpack()
134 hp->h_addr_list[ii] = NULL; in hostent_unpack()
136 return (hp); in hostent_unpack()
138 hostent_free(hp); in hostent_unpack()
199 struct hostent *hp; in cap_gethostbyname2() local
217 hp = hostent_unpack(nvl, &hent); in cap_gethostbyname2()
219 return (hp); in cap_gethostbyname2()
226 struct hostent *hp; in cap_gethostbyaddr() local
243 hp = hostent_unpack(nvl, &hent); in cap_gethostbyaddr()
245 return (hp); in cap_gethostbyaddr()
746 hostent_pack(const struct hostent *hp, nvlist_t *nvl, bool addtocache) in hostent_pack() argument
752 nvlist_add_string(nvl, "name", hp->h_name); in hostent_pack()
753 nvlist_add_number(nvl, "addrtype", (uint64_t)hp->h_addrtype); in hostent_pack()
754 nvlist_add_number(nvl, "length", (uint64_t)hp->h_length); in hostent_pack()
756 if (hp->h_aliases == NULL) { in hostent_pack()
759 for (ii = 0; hp->h_aliases[ii] != NULL; ii++) { in hostent_pack()
762 nvlist_add_string(nvl, nvlname, hp->h_aliases[ii]); in hostent_pack()
767 if (hp->h_addr_list == NULL) { in hostent_pack()
770 for (ii = 0; hp->h_addr_list[ii] != NULL; ii++) { in hostent_pack()
773 nvlist_add_binary(nvl, nvlname, hp->h_addr_list[ii], in hostent_pack()
774 (size_t)hp->h_length); in hostent_pack()
776 net_add_hostent_to_cache(hp->h_addr_list[ii], in hostent_pack()
777 hp->h_length, hp->h_addrtype); in hostent_pack()
788 struct hostent *hp; in net_gethostbyname() local
812 hp = gethostbyname2(name, family); in net_gethostbyname()
813 if (hp == NULL) in net_gethostbyname()
815 hostent_pack(hp, nvlout, dnscache); in net_gethostbyname()
823 struct hostent *hp; in net_gethostbyaddr() local
846 hp = gethostbyaddr(addr, (socklen_t)addrsize, family); in net_gethostbyaddr()
847 if (hp == NULL) in net_gethostbyaddr()
849 hostent_pack(hp, nvlout, false); in net_gethostbyaddr()