]>
Commit | Line | Data |
---|---|---|
22931d3b PE |
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 */); |