diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2011-12-14 21:44:35 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-12-16 13:48:27 -0500 |
commit | 22931d3b906cd0a1726a49a09713f9220a5fab8a (patch) | |
tree | 33e303ac5be89b1490e6beabd311ca3e6d6860bc /net/unix/diag.c | |
parent | fa7ff56f75add89bbedaf2dfcfa8f6661e8e8b3a (diff) |
unix_diag: Basic module skeleton
Includes basic module_init/_exit functionality, dump/get_exact stubs
and declares the basic API structures for request and response.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/unix/diag.c')
-rw-r--r-- | net/unix/diag.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/net/unix/diag.c b/net/unix/diag.c new file mode 100644 index 000000000000..6be16c0ad38f --- /dev/null +++ b/net/unix/diag.c | |||
@@ -0,0 +1,57 @@ | |||
1 | #include <linux/types.h> | ||
2 | #include <linux/spinlock.h> | ||
3 | #include <linux/sock_diag.h> | ||
4 | #include <linux/unix_diag.h> | ||
5 | #include <linux/skbuff.h> | ||
6 | #include <net/netlink.h> | ||
7 | #include <net/af_unix.h> | ||
8 | #include <net/tcp_states.h> | ||
9 | |||
10 | #define UNIX_DIAG_PUT(skb, attrtype, attrlen) \ | ||
11 | RTA_DATA(__RTA_PUT(skb, attrtype, attrlen)) | ||
12 | |||
13 | static int unix_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) | ||
14 | { | ||
15 | return 0; | ||
16 | } | ||
17 | |||
18 | static int unix_diag_get_exact(struct sk_buff *in_skb, | ||
19 | const struct nlmsghdr *nlh, | ||
20 | struct unix_diag_req *req) | ||
21 | { | ||
22 | return -EAFNOSUPPORT; | ||
23 | } | ||
24 | |||
25 | static int unix_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h) | ||
26 | { | ||
27 | int hdrlen = sizeof(struct unix_diag_req); | ||
28 | |||
29 | if (nlmsg_len(h) < hdrlen) | ||
30 | return -EINVAL; | ||
31 | |||
32 | if (h->nlmsg_flags & NLM_F_DUMP) | ||
33 | return netlink_dump_start(sock_diag_nlsk, skb, h, | ||
34 | unix_diag_dump, NULL, 0); | ||
35 | else | ||
36 | return unix_diag_get_exact(skb, h, (struct unix_diag_req *)NLMSG_DATA(h)); | ||
37 | } | ||
38 | |||
39 | static struct sock_diag_handler unix_diag_handler = { | ||
40 | .family = AF_UNIX, | ||
41 | .dump = unix_diag_handler_dump, | ||
42 | }; | ||
43 | |||
44 | static int __init unix_diag_init(void) | ||
45 | { | ||
46 | return sock_diag_register(&unix_diag_handler); | ||
47 | } | ||
48 | |||
49 | static void __exit unix_diag_exit(void) | ||
50 | { | ||
51 | sock_diag_unregister(&unix_diag_handler); | ||
52 | } | ||
53 | |||
54 | module_init(unix_diag_init); | ||
55 | module_exit(unix_diag_exit); | ||
56 | MODULE_LICENSE("GPL"); | ||
57 | MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 1 /* AF_LOCAL */); | ||