This source file includes following definitions.
- notifier_chain_register
- notifier_chain_unregister
- notifier_call_chain
1
2
3
4
5
6
7
8
9
10 #ifndef _LINUX_NOTIFIER_H
11 #define _LINUX_NOTIFIER_H
12 #include <linux/errno.h>
13
14 struct notifier_block
15 {
16 int (*notifier_call)(struct notifier_block *this, unsigned long, void *);
17 struct notifier_block *next;
18 int priority;
19 };
20
21
22 #ifdef __KERNEL__
23
24 #define NOTIFY_DONE 0x0000
25 #define NOTIFY_OK 0x0001
26 #define NOTIFY_STOP_MASK 0x8000
27 #define NOTIFY_BAD (NOTIFY_STOP_MASK|0x0002)
28
29 extern __inline__ int notifier_chain_register(struct notifier_block **list, struct notifier_block *n)
30 {
31 while(*list)
32 {
33 if(n->priority > (*list)->priority)
34 break;
35 list= &((*list)->next);
36 }
37 n->next = *list;
38 *list=n;
39 return 0;
40 }
41
42
43
44
45
46
47 extern __inline__ int notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n)
48 {
49 while((*nl)!=NULL)
50 {
51 if((*nl)==n)
52 {
53 *nl=n->next;
54 return 0;
55 }
56 nl=&((*nl)->next);
57 }
58 return -ENOENT;
59 }
60
61
62
63
64
65 extern __inline__ int notifier_call_chain(struct notifier_block **n, unsigned long val, void *v)
66 {
67 int ret=NOTIFY_DONE;
68 struct notifier_block *nb = *n;
69 while(nb)
70 {
71 ret=nb->notifier_call(nb,val,v);
72 if(ret&NOTIFY_STOP_MASK)
73 return ret;
74 nb=nb->next;
75 }
76 return ret;
77 }
78
79
80
81
82
83
84
85
86
87
88
89 #define NETDEV_UP 0x0001
90 #define NETDEV_DOWN 0x0002
91 #define NETDEV_REBOOT 0x0003
92
93
94
95 #endif
96 #endif