2 * This file is part of secnet.
3 * See README for full list of copyright holders.
5 * secnet is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * secnet is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * version 3 along with secnet; if not, see
17 * https://www.gnu.org/licenses/gpl.html.
21 #include "comm-common.h"
23 struct comm_clientinfo *comm_clientinfo_ignore(void *state, dict_t *dict,
29 void comm_request_notify(void *commst, void *nst, comm_notify_fn *fn)
31 struct commcommon *st=commst;
32 struct comm_notify_entry *n;
37 LIST_INSERT_HEAD(&st->notify, n, entry);
40 void comm_release_notify(void *commst, void *nst, comm_notify_fn *fn)
42 struct commcommon *st=commst;
43 struct comm_notify_entry *n, *t;
46 LIST_FOREACH_SAFE(n, &st->notify, entry, t) {
47 if (n->state==nst && n->fn==fn) {
48 LIST_REMOVE(n, entry);
54 bool_t comm_notify(struct comm_notify_list *notify,
55 struct buffer_if *buf, const struct comm_addr *ca)
57 struct comm_notify_entry *n;
59 LIST_FOREACH(n, notify, entry) {
60 if (n->fn(n->state, buf, ca)) {
67 void comm_apply(struct commcommon *cc, void *st)
72 cc->cl.interface=&cc->ops;
74 cc->ops.request_notify=comm_request_notify;
75 cc->ops.release_notify=comm_release_notify;
76 LIST_INIT(&cc->notify);