Commit | Line | Data |
---|---|---|
52b7c59b PE |
1 | /* |
2 | * udp_diag.c Module for monitoring UDP transport protocols sockets. | |
3 | * | |
4 | * Authors: Pavel Emelyanov, <xemul@parallels.com> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version | |
9 | * 2 of the License, or (at your option) any later version. | |
10 | */ | |
11 | ||
12 | ||
13 | #include <linux/module.h> | |
14 | #include <linux/inet_diag.h> | |
15 | #include <linux/udp.h> | |
16 | #include <net/udp.h> | |
17 | #include <net/udplite.h> | |
18 | #include <linux/inet_diag.h> | |
19 | #include <linux/sock_diag.h> | |
20 | ||
21 | static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb, | |
22 | const struct nlmsghdr *nlh, struct inet_diag_req *req) | |
23 | { | |
24 | return 0; | |
25 | } | |
26 | ||
27 | static void udp_dump(struct udp_table *table, struct sk_buff *skb, struct netlink_callback *cb, | |
28 | struct inet_diag_req *r, struct nlattr *bc) | |
29 | { | |
30 | } | |
31 | ||
32 | static void udp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, | |
33 | struct inet_diag_req *r, struct nlattr *bc) | |
34 | { | |
35 | udp_dump(&udp_table, skb, cb, r, bc); | |
36 | } | |
37 | ||
38 | static int udp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh, | |
39 | struct inet_diag_req *req) | |
40 | { | |
41 | return udp_dump_one(&udp_table, in_skb, nlh, req); | |
42 | } | |
43 | ||
44 | static const struct inet_diag_handler udp_diag_handler = { | |
45 | .dump = udp_diag_dump, | |
46 | .dump_one = udp_diag_dump_one, | |
47 | .idiag_type = IPPROTO_UDP, | |
48 | }; | |
49 | ||
50 | static void udplite_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, | |
51 | struct inet_diag_req *r, struct nlattr *bc) | |
52 | { | |
53 | udp_dump(&udplite_table, skb, cb, r, bc); | |
54 | } | |
55 | ||
56 | static int udplite_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh, | |
57 | struct inet_diag_req *req) | |
58 | { | |
59 | return udp_dump_one(&udplite_table, in_skb, nlh, req); | |
60 | } | |
61 | ||
62 | static const struct inet_diag_handler udplite_diag_handler = { | |
63 | .dump = udplite_diag_dump, | |
64 | .dump_one = udplite_diag_dump_one, | |
65 | .idiag_type = IPPROTO_UDPLITE, | |
66 | }; | |
67 | ||
68 | static int __init udp_diag_init(void) | |
69 | { | |
70 | int err; | |
71 | ||
72 | err = inet_diag_register(&udp_diag_handler); | |
73 | if (err) | |
74 | goto out; | |
75 | err = inet_diag_register(&udplite_diag_handler); | |
76 | if (err) | |
77 | goto out_lite; | |
78 | out: | |
79 | return err; | |
80 | out_lite: | |
81 | inet_diag_unregister(&udp_diag_handler); | |
82 | goto out; | |
83 | } | |
84 | ||
85 | static void __exit udp_diag_exit(void) | |
86 | { | |
87 | inet_diag_unregister(&udplite_diag_handler); | |
88 | inet_diag_unregister(&udp_diag_handler); | |
89 | } | |
90 | ||
91 | module_init(udp_diag_init); | |
92 | module_exit(udp_diag_exit); | |
93 | MODULE_LICENSE("GPL"); | |
94 | MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 17); | |
95 | MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 136); |