Linux Audio

Check our new training course

Loading...
v3.1
 
 1/*
 2 *	Network event notifiers
 3 *
 4 *	Authors:
 5 *      Tom Tucker             <tom@opengridcomputing.com>
 6 *      Steve Wise             <swise@opengridcomputing.com>
 7 *
 8 *	This program is free software; you can redistribute it and/or
 9 *      modify it under the terms of the GNU General Public License
10 *      as published by the Free Software Foundation; either version
11 *      2 of the License, or (at your option) any later version.
12 *
13 *	Fixes:
14 */
15
16#include <linux/rtnetlink.h>
17#include <linux/notifier.h>
 
18#include <net/netevent.h>
19
20static ATOMIC_NOTIFIER_HEAD(netevent_notif_chain);
21
22/**
23 *	register_netevent_notifier - register a netevent notifier block
24 *	@nb: notifier
25 *
26 *	Register a notifier to be called when a netevent occurs.
27 *	The notifier passed is linked into the kernel structures and must
28 *	not be reused until it has been unregistered. A negative errno code
29 *	is returned on a failure.
30 */
31int register_netevent_notifier(struct notifier_block *nb)
32{
33	int err;
34
35	err = atomic_notifier_chain_register(&netevent_notif_chain, nb);
36	return err;
37}
38EXPORT_SYMBOL_GPL(register_netevent_notifier);
39
40/**
41 *	netevent_unregister_notifier - unregister a netevent notifier block
42 *	@nb: notifier
43 *
44 *	Unregister a notifier previously registered by
45 *	register_neigh_notifier(). The notifier is unlinked into the
46 *	kernel structures and may then be reused. A negative errno code
47 *	is returned on a failure.
48 */
49
50int unregister_netevent_notifier(struct notifier_block *nb)
51{
52	return atomic_notifier_chain_unregister(&netevent_notif_chain, nb);
53}
54EXPORT_SYMBOL_GPL(unregister_netevent_notifier);
55
56/**
57 *	call_netevent_notifiers - call all netevent notifier blocks
58 *      @val: value passed unmodified to notifier function
59 *      @v:   pointer passed unmodified to notifier function
60 *
61 *	Call all neighbour notifier blocks.  Parameters and return value
62 *	are as for notifier_call_chain().
63 */
64
65int call_netevent_notifiers(unsigned long val, void *v)
66{
67	return atomic_notifier_call_chain(&netevent_notif_chain, val, v);
68}
69EXPORT_SYMBOL_GPL(call_netevent_notifiers);
v5.4
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 *	Network event notifiers
 4 *
 5 *	Authors:
 6 *      Tom Tucker             <tom@opengridcomputing.com>
 7 *      Steve Wise             <swise@opengridcomputing.com>
 8 *
 
 
 
 
 
 9 *	Fixes:
10 */
11
12#include <linux/rtnetlink.h>
13#include <linux/notifier.h>
14#include <linux/export.h>
15#include <net/netevent.h>
16
17static ATOMIC_NOTIFIER_HEAD(netevent_notif_chain);
18
19/**
20 *	register_netevent_notifier - register a netevent notifier block
21 *	@nb: notifier
22 *
23 *	Register a notifier to be called when a netevent occurs.
24 *	The notifier passed is linked into the kernel structures and must
25 *	not be reused until it has been unregistered. A negative errno code
26 *	is returned on a failure.
27 */
28int register_netevent_notifier(struct notifier_block *nb)
29{
30	return atomic_notifier_chain_register(&netevent_notif_chain, nb);
 
 
 
31}
32EXPORT_SYMBOL_GPL(register_netevent_notifier);
33
34/**
35 *	netevent_unregister_notifier - unregister a netevent notifier block
36 *	@nb: notifier
37 *
38 *	Unregister a notifier previously registered by
39 *	register_neigh_notifier(). The notifier is unlinked into the
40 *	kernel structures and may then be reused. A negative errno code
41 *	is returned on a failure.
42 */
43
44int unregister_netevent_notifier(struct notifier_block *nb)
45{
46	return atomic_notifier_chain_unregister(&netevent_notif_chain, nb);
47}
48EXPORT_SYMBOL_GPL(unregister_netevent_notifier);
49
50/**
51 *	call_netevent_notifiers - call all netevent notifier blocks
52 *      @val: value passed unmodified to notifier function
53 *      @v:   pointer passed unmodified to notifier function
54 *
55 *	Call all neighbour notifier blocks.  Parameters and return value
56 *	are as for notifier_call_chain().
57 */
58
59int call_netevent_notifiers(unsigned long val, void *v)
60{
61	return atomic_notifier_call_chain(&netevent_notif_chain, val, v);
62}
63EXPORT_SYMBOL_GPL(call_netevent_notifiers);