3 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>
6 * Faculty of Computer Science, Mathematics and Natural Sciences,
7 * Leipzig University of Applied Sciences (HTWK Leipzig)
17 * Event notification framework based on the idea of the Linux kernel
18 * notification chains by Alan Cox which have originally been written
19 * for event delivery within the networking subsystem.
22 int register_event_hook(struct event_block
**head
,
23 struct event_block
*block
)
30 while ((*head
) != NULL
) {
31 if (block
->prio
> (*head
)->prio
)
34 head
= &((*head
)->next
);
37 block
->next
= (*head
);
44 int register_event_hook_once(struct event_block
**head
,
45 struct event_block
*block
)
52 while ((*head
) != NULL
) {
53 if (unlikely(block
== (*head
)))
56 if (block
->prio
> (*head
)->prio
)
59 head
= &((*head
)->next
);
62 block
->next
= (*head
);
69 int unregister_event_hook(struct event_block
**head
,
70 struct event_block
*block
)
75 while ((*head
) != NULL
) {
76 if (unlikely(block
== (*head
))) {
77 (*head
) = block
->next
;
82 head
= &((*head
)->next
);
88 int call_event_hooks(struct event_block
**head
, unsigned long event
,
89 const void *arg
, int *called
)
91 int ret
= BLOCK_SUCC_DONE
;
92 struct event_block
*block
= *head
, *next_block
;
100 next_block
= block
->next
;
102 ret
= block
->hook(block
, event
, arg
);
103 if (ret
& BLOCK_STOP_CHAIN
)