blob: 75e4e4ada54552ea968896610181d8a5ad32b0b6 [file] [log] [blame]
Pavel Emelyanov52b7c592011-12-09 06:23:51 +00001/*
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
21static 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
27static 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
32static 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
38static 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
44static 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
50static 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
56static 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
62static 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
68static 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;
78out:
79 return err;
80out_lite:
81 inet_diag_unregister(&udp_diag_handler);
82 goto out;
83}
84
85static void __exit udp_diag_exit(void)
86{
87 inet_diag_unregister(&udplite_diag_handler);
88 inet_diag_unregister(&udp_diag_handler);
89}
90
91module_init(udp_diag_init);
92module_exit(udp_diag_exit);
93MODULE_LICENSE("GPL");
94MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 17);
95MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 136);