Lines Matching +full:hdr +full:- +full:engine
4 * Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org>
68 log_info("dns engine exiting"); in dns_shutdown()
82 case -1: in ypldap_dns()
91 setproctitle("dns engine"); in ypldap_dns()
94 if (setgroups(1, &pw->pw_gid) || in ypldap_dns()
95 setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) || in ypldap_dns()
96 setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) in ypldap_dns()
111 env.sc_iev->events = EV_READ; in ypldap_dns()
112 env.sc_iev->data = &env; in ypldap_dns()
113 imsg_init(&env.sc_iev->ibuf, pipe_ntp[1]); in ypldap_dns()
114 env.sc_iev->handler = dns_dispatch_imsg; in ypldap_dns()
115 event_set(&env.sc_iev->ev, env.sc_iev->ibuf.fd, env.sc_iev->events, in ypldap_dns()
116 env.sc_iev->handler, &env); in ypldap_dns()
117 event_add(&env.sc_iev->ev, NULL); in ypldap_dns()
135 struct imsgev *iev = env->sc_iev; in dns_dispatch_imsg()
136 struct imsgbuf *ibuf = &iev->ibuf; in dns_dispatch_imsg()
143 if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) in dns_dispatch_imsg()
149 if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) in dns_dispatch_imsg()
157 if ((n = imsg_get(ibuf, &imsg)) == -1) in dns_dispatch_imsg()
162 switch (imsg.hdr.type) { in dns_dispatch_imsg()
165 if (imsg.hdr.len < 1 + IMSG_HEADER_SIZE) in dns_dispatch_imsg()
167 imsg.hdr.len -= 1 + IMSG_HEADER_SIZE; in dns_dispatch_imsg()
168 if (name[imsg.hdr.len] != '\0' || in dns_dispatch_imsg()
169 strlen(name) != imsg.hdr.len) in dns_dispatch_imsg()
171 if ((cnt = host_dns(name, &hn)) == -1) in dns_dispatch_imsg()
174 imsg.hdr.peerid, 0, in dns_dispatch_imsg()
182 imsg_add(buf, &h->ss, sizeof(h->ss)); in dns_dispatch_imsg()
200 event_del(&iev->ev); in dns_dispatch_imsg()
223 return (-1); in host_dns()
226 for (res = res0; res && cnt < MAX_SERVERS_DNS; res = res->ai_next) { in host_dns()
227 if (res->ai_family != AF_INET && in host_dns()
228 res->ai_family != AF_INET6) in host_dns()
232 h->ss.ss_family = res->ai_family; in host_dns()
233 if (res->ai_family == AF_INET) { in host_dns()
234 sa_in = (struct sockaddr_in *)&h->ss; in host_dns()
235 sa_in->sin_len = sizeof(struct sockaddr_in); in host_dns()
236 sa_in->sin_addr.s_addr = ((struct sockaddr_in *) in host_dns()
237 res->ai_addr)->sin_addr.s_addr; in host_dns()
239 sa_in6 = (struct sockaddr_in6 *)&h->ss; in host_dns()
240 sa_in6->sin6_len = sizeof(struct sockaddr_in6); in host_dns()
241 memcpy(&sa_in6->sin6_addr, &((struct sockaddr_in6 *) in host_dns()
242 res->ai_addr)->sin6_addr, sizeof(struct in6_addr)); in host_dns()