Lines Matching +defs:p +defs:c
1 /* $OpenBSD: control.c,v 1.45 2024/11/21 13:35:20 claudio Exp $ */
4 * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
5 * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
60 control(struct privsep *ps, struct privsep_proc *p)
62 proc_run(ps, p, procs, nitems(procs), control_run, NULL);
66 control_run(struct privsep *ps, struct privsep_proc *p, void *arg)
163 struct ctl_conn *c;
188 if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) {
194 if (imsgbuf_init(&c->iev.ibuf, connfd) == -1) {
197 free(c);
200 c->iev.handler = control_dispatch_imsg;
201 c->iev.events = EV_READ;
202 c->iev.data = cs;
203 event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events,
204 c->iev.handler, c->iev.data);
205 event_add(&c->iev.ev, NULL);
208 c->peerid = ctl_peerid++;
210 if (c->peerid == other->peerid)
211 c->peerid = ctl_peerid++;
213 TAILQ_INSERT_TAIL(&ctl_conns, c, entry);
219 struct ctl_conn *c;
221 TAILQ_FOREACH(c, &ctl_conns, entry) {
222 if (c->iev.ibuf.fd == fd)
226 return (c);
232 struct ctl_conn *c;
234 if ((c = control_connbyfd(fd)) == NULL) {
239 imsgbuf_clear(&c->iev.ibuf);
240 TAILQ_REMOVE(&ctl_conns, c, entry);
242 event_del(&c->iev.ev);
243 close(c->iev.ibuf.fd);
251 free(c);
259 struct ctl_conn *c;
263 if ((c = control_connbyfd(fd)) == NULL) {
269 if (imsgbuf_read(&c->iev.ibuf) != 1) {
275 if (imsgbuf_write(&c->iev.ibuf) == -1) {
282 if ((n = imsg_get(&c->iev.ibuf, &imsg)) == -1) {
293 imsg.hdr.peerid = c->peerid;
297 if (c->flags & CTL_CONN_NOTIFY) {
301 imsg_compose_event(&c->iev, IMSG_CTL_FAIL,
305 c->flags |= CTL_CONN_NOTIFY;
341 imsg_event_add(&c->iev);
347 struct ctl_conn *c;
349 TAILQ_FOREACH(c, &ctl_conns, entry)
350 if (c->flags & CTL_CONN_NOTIFY)
351 imsg_compose_event(&c->iev, imsg->hdr.type,
359 struct ctl_conn *c;
361 TAILQ_FOREACH(c, &ctl_conns, entry)
362 if (c->peerid == imsg->hdr.peerid)
363 imsg_compose_event(&c->iev, imsg->hdr.type,
369 control_dispatch_ikev2(int fd, struct privsep_proc *p, struct imsg *imsg)
384 control_dispatch_ca(int fd, struct privsep_proc *p, struct imsg *imsg)