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 d 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 void comm_request_notify(void *commst
, void *nst
, comm_notify_fn
*fn
)
25 struct commcommon
*st
=commst
;
26 struct comm_notify_entry
*n
;
31 LIST_INSERT_HEAD(&st
->notify
, n
, entry
);
34 void comm_release_notify(void *commst
, void *nst
, comm_notify_fn
*fn
)
36 struct commcommon
*st
=commst
;
37 struct comm_notify_entry
*n
, *t
;
40 LIST_FOREACH_SAFE(n
, &st
->notify
, entry
, t
) {
41 if (n
->state
==nst
&& n
->fn
==fn
) {
42 LIST_REMOVE(n
, entry
);
48 bool_t
comm_notify(struct comm_notify_list
*notify
,
49 struct buffer_if
*buf
, const struct comm_addr
*ca
)
51 struct comm_notify_entry
*n
;
53 LIST_FOREACH(n
, notify
, entry
) {
54 if (n
->fn(n
->state
, buf
, ca
)) {
61 void comm_apply(struct commcommon
*cc
, void *st
)
66 cc
->cl
.interface
=&cc
->ops
;
68 cc
->ops
.request_notify
=comm_request_notify
;
69 cc
->ops
.release_notify
=comm_release_notify
;
70 LIST_INIT(&cc
->notify
);