Home | History | Annotate | Download | only in irs

Lines Matching defs:net_data

61 static struct net_data *init(void);
62 static struct netent *nw_to_net(struct nwent *, struct net_data *);
63 static void freepvt(struct net_data *);
64 static struct netent *fakeaddr(const char *, int af, struct net_data *);
76 struct net_data *net_data = init();
78 return (getnetent_p(net_data));
83 struct net_data *net_data = init();
85 return (getnetbyname_p(name, net_data));
90 struct net_data *net_data = init();
92 return (getnetbyaddr_p(net, type, net_data));
97 struct net_data *net_data = init();
99 setnetent_p(stayopen, net_data);
105 struct net_data *net_data = init();
107 endnetent_p(net_data);
113 getnetent_p(struct net_data *net_data) {
116 if (!net_data || !(nw = net_data->nw))
118 net_data->nww_last = (*nw->next)(nw);
119 net_data->nw_last = nw_to_net(net_data->nww_last, net_data);
120 return (net_data->nw_last);
124 getnetbyname_p(const char *name, struct net_data *net_data) {
129 if (!net_data || !(nw = net_data->nw))
131 if (net_data->nw_stayopen && net_data->nw_last) {
132 if (!strcmp(net_data->nw_last->n_name, name))
133 return (net_data->nw_last);
134 for (nap = net_data->nw_last->n_aliases; nap && *nap; nap++)
136 return (net_data->nw_last);
138 if ((np = fakeaddr(name, AF_INET, net_data)) != NULL)
140 net_data->nww_last = (*nw->byname)(nw, name, AF_INET);
141 net_data->nw_last = nw_to_net(net_data->nww_last, net_data);
142 if (!net_data->nw_stayopen)
144 return (net_data->nw_last);
148 getnetbyaddr_p(unsigned long net, int type, struct net_data *net_data) {
153 if (!net_data || !(nw = net_data->nw))
155 if (net_data->nw_stayopen && net_data->nw_last)
156 if (type == net_data->nw_last->n_addrtype &&
157 net == net_data->nw_last->n_net)
158 return (net_data->nw_last);
191 net_data->nww_last = (*nw->byaddr)(nw, addr, bits, AF_INET);
192 net_data->nw_last = nw_to_net(net_data->nww_last, net_data);
193 if (!net_data->nw_stayopen)
195 return (net_data->nw_last);
202 setnetent_p(int stayopen, struct net_data *net_data) {
205 if (!net_data || !(nw = net_data->nw))
207 freepvt(net_data);
209 net_data->nw_stayopen = (stayopen != 0);
211 net_data_minimize(net_data);
215 endnetent_p(struct net_data *net_data) {
218 if ((net_data != NULL) && ((nw = net_data->nw) != NULL))
224 static struct net_data *
226 struct net_data *net_data;
228 if (!(net_data = net_data_init(NULL)))
230 if (!net_data->nw) {
231 net_data->nw = (*net_data->irs->nw_map)(net_data->irs);
233 if (!net_data->nw || !net_data->res) {
238 (*net_data->nw->res_set)(net_data->nw, net_data->res, NULL);
241 return (net_data);
245 freepvt(struct net_data *net_data) {
246 if (net_data->nw_data) {
247 free(net_data->nw_data);
248 net_data->nw_data = NULL;
253 fakeaddr(const char *name, int af, struct net_data *net_data) {
261 RES_SET_H_ERRNO(net_data->res, NETDB_INTERNAL);
277 RES_SET_H_ERRNO(net_data->res, HOST_NOT_FOUND);
285 freepvt(net_data);
286 net_data->nw_data = malloc(sizeof (struct pvt));
287 if (!net_data->nw_data) {
289 RES_SET_H_ERRNO(net_data->res, NETDB_INTERNAL);
292 pvt = net_data->nw_data;
306 nw_to_net(struct nwent *nwent, struct net_data *net_data) {
314 freepvt(net_data);
315 net_data->nw_data = malloc(sizeof (struct pvt));
316 if (!net_data->nw_data) {
318 RES_SET_H_ERRNO(net_data->res, NETDB_INTERNAL);
321 pvt = net_data->nw_data;