diff options
author | Paulius Zaleckas <paulius.zaleckas@teltonika.lt> | 2009-05-13 09:20:29 -0400 |
---|---|---|
committer | Inaky Perez-Gonzalez <inaky@linux.intel.com> | 2009-05-28 21:02:20 -0400 |
commit | 7f0333eb2f98bbfece4fbfe21076d0a3e49f0bb0 (patch) | |
tree | 6dcfd052fccde051f56600a7cea095a8f1479d74 /net | |
parent | a0a4c4c9e54ee4255f46eedb572ad69ee34c77b6 (diff) |
wimax: Add netlink interface to get device state
wimax connection manager / daemon has to know what is current
state of the device. Previously it was only possible to get
notification whet state has changed.
Note:
By mistake, the new generic netlink's number for
WIMAX_GNL_OP_STATE_GET was declared inserting into the existing list
of API calls, not appending; thus, it'd break existing API.
Fixed by Inaky Perez-Gonzalez <inaky@linux.intel.com> by moving to
the tail, where we add to the interface, not modify the interface.
Thanks to Stephen Hemminger <shemminger@vyatta.com> for catching this.
Signed-off-by: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
Diffstat (limited to 'net')
-rw-r--r-- | net/wimax/Makefile | 1 | ||||
-rw-r--r-- | net/wimax/debug-levels.h | 1 | ||||
-rw-r--r-- | net/wimax/debugfs.c | 1 | ||||
-rw-r--r-- | net/wimax/op-state-get.c | 86 | ||||
-rw-r--r-- | net/wimax/stack.c | 5 |
5 files changed, 93 insertions, 1 deletions
diff --git a/net/wimax/Makefile b/net/wimax/Makefile index 5b80b941c2c9..8f1510d0cc2b 100644 --- a/net/wimax/Makefile +++ b/net/wimax/Makefile | |||
@@ -6,6 +6,7 @@ wimax-y := \ | |||
6 | op-msg.o \ | 6 | op-msg.o \ |
7 | op-reset.o \ | 7 | op-reset.o \ |
8 | op-rfkill.o \ | 8 | op-rfkill.o \ |
9 | op-state-get.o \ | ||
9 | stack.o | 10 | stack.o |
10 | 11 | ||
11 | wimax-$(CONFIG_DEBUG_FS) += debugfs.o | 12 | wimax-$(CONFIG_DEBUG_FS) += debugfs.o |
diff --git a/net/wimax/debug-levels.h b/net/wimax/debug-levels.h index 1c29123a3aa9..0975adba6b71 100644 --- a/net/wimax/debug-levels.h +++ b/net/wimax/debug-levels.h | |||
@@ -36,6 +36,7 @@ enum d_module { | |||
36 | D_SUBMODULE_DECLARE(op_msg), | 36 | D_SUBMODULE_DECLARE(op_msg), |
37 | D_SUBMODULE_DECLARE(op_reset), | 37 | D_SUBMODULE_DECLARE(op_reset), |
38 | D_SUBMODULE_DECLARE(op_rfkill), | 38 | D_SUBMODULE_DECLARE(op_rfkill), |
39 | D_SUBMODULE_DECLARE(op_state_get), | ||
39 | D_SUBMODULE_DECLARE(stack), | 40 | D_SUBMODULE_DECLARE(stack), |
40 | }; | 41 | }; |
41 | 42 | ||
diff --git a/net/wimax/debugfs.c b/net/wimax/debugfs.c index 94d216a46407..6c9bedb7431e 100644 --- a/net/wimax/debugfs.c +++ b/net/wimax/debugfs.c | |||
@@ -61,6 +61,7 @@ int wimax_debugfs_add(struct wimax_dev *wimax_dev) | |||
61 | __debugfs_register("wimax_dl_", op_msg, dentry); | 61 | __debugfs_register("wimax_dl_", op_msg, dentry); |
62 | __debugfs_register("wimax_dl_", op_reset, dentry); | 62 | __debugfs_register("wimax_dl_", op_reset, dentry); |
63 | __debugfs_register("wimax_dl_", op_rfkill, dentry); | 63 | __debugfs_register("wimax_dl_", op_rfkill, dentry); |
64 | __debugfs_register("wimax_dl_", op_state_get, dentry); | ||
64 | __debugfs_register("wimax_dl_", stack, dentry); | 65 | __debugfs_register("wimax_dl_", stack, dentry); |
65 | result = 0; | 66 | result = 0; |
66 | out: | 67 | out: |
diff --git a/net/wimax/op-state-get.c b/net/wimax/op-state-get.c new file mode 100644 index 000000000000..a76b8fcb056d --- /dev/null +++ b/net/wimax/op-state-get.c | |||
@@ -0,0 +1,86 @@ | |||
1 | /* | ||
2 | * Linux WiMAX | ||
3 | * Implement and export a method for getting a WiMAX device current state | ||
4 | * | ||
5 | * Copyright (C) 2009 Paulius Zaleckas <paulius.zaleckas@teltonika.lt> | ||
6 | * | ||
7 | * Based on previous WiMAX core work by: | ||
8 | * Copyright (C) 2008 Intel Corporation <linux-wimax@intel.com> | ||
9 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License version | ||
13 | * 2 as published by the Free Software Foundation. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
23 | * 02110-1301, USA. | ||
24 | */ | ||
25 | |||
26 | #include <net/wimax.h> | ||
27 | #include <net/genetlink.h> | ||
28 | #include <linux/wimax.h> | ||
29 | #include <linux/security.h> | ||
30 | #include "wimax-internal.h" | ||
31 | |||
32 | #define D_SUBMODULE op_state_get | ||
33 | #include "debug-levels.h" | ||
34 | |||
35 | |||
36 | static const | ||
37 | struct nla_policy wimax_gnl_state_get_policy[WIMAX_GNL_ATTR_MAX + 1] = { | ||
38 | [WIMAX_GNL_STGET_IFIDX] = { | ||
39 | .type = NLA_U32, | ||
40 | }, | ||
41 | }; | ||
42 | |||
43 | |||
44 | /* | ||
45 | * Exporting to user space over generic netlink | ||
46 | * | ||
47 | * Parse the state get command from user space, return a combination | ||
48 | * value that describe the current state. | ||
49 | * | ||
50 | * No attributes. | ||
51 | */ | ||
52 | static | ||
53 | int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info) | ||
54 | { | ||
55 | int result, ifindex; | ||
56 | struct wimax_dev *wimax_dev; | ||
57 | struct device *dev; | ||
58 | |||
59 | d_fnstart(3, NULL, "(skb %p info %p)\n", skb, info); | ||
60 | result = -ENODEV; | ||
61 | if (info->attrs[WIMAX_GNL_STGET_IFIDX] == NULL) { | ||
62 | printk(KERN_ERR "WIMAX_GNL_OP_STATE_GET: can't find IFIDX " | ||
63 | "attribute\n"); | ||
64 | goto error_no_wimax_dev; | ||
65 | } | ||
66 | ifindex = nla_get_u32(info->attrs[WIMAX_GNL_STGET_IFIDX]); | ||
67 | wimax_dev = wimax_dev_get_by_genl_info(info, ifindex); | ||
68 | if (wimax_dev == NULL) | ||
69 | goto error_no_wimax_dev; | ||
70 | dev = wimax_dev_to_dev(wimax_dev); | ||
71 | /* Execute the operation and send the result back to user space */ | ||
72 | result = wimax_state_get(wimax_dev); | ||
73 | dev_put(wimax_dev->net_dev); | ||
74 | error_no_wimax_dev: | ||
75 | d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result); | ||
76 | return result; | ||
77 | } | ||
78 | |||
79 | |||
80 | struct genl_ops wimax_gnl_state_get = { | ||
81 | .cmd = WIMAX_GNL_OP_STATE_GET, | ||
82 | .flags = GENL_ADMIN_PERM, | ||
83 | .policy = wimax_gnl_state_get_policy, | ||
84 | .doit = wimax_gnl_doit_state_get, | ||
85 | .dumpit = NULL, | ||
86 | }; | ||
diff --git a/net/wimax/stack.c b/net/wimax/stack.c index 933e1422b09f..79fb7d7c640f 100644 --- a/net/wimax/stack.c +++ b/net/wimax/stack.c | |||
@@ -402,13 +402,15 @@ EXPORT_SYMBOL_GPL(wimax_dev_init); | |||
402 | extern struct genl_ops | 402 | extern struct genl_ops |
403 | wimax_gnl_msg_from_user, | 403 | wimax_gnl_msg_from_user, |
404 | wimax_gnl_reset, | 404 | wimax_gnl_reset, |
405 | wimax_gnl_rfkill; | 405 | wimax_gnl_rfkill, |
406 | wimax_gnl_state_get; | ||
406 | 407 | ||
407 | static | 408 | static |
408 | struct genl_ops *wimax_gnl_ops[] = { | 409 | struct genl_ops *wimax_gnl_ops[] = { |
409 | &wimax_gnl_msg_from_user, | 410 | &wimax_gnl_msg_from_user, |
410 | &wimax_gnl_reset, | 411 | &wimax_gnl_reset, |
411 | &wimax_gnl_rfkill, | 412 | &wimax_gnl_rfkill, |
413 | &wimax_gnl_state_get, | ||
412 | }; | 414 | }; |
413 | 415 | ||
414 | 416 | ||
@@ -533,6 +535,7 @@ struct d_level D_LEVEL[] = { | |||
533 | D_SUBMODULE_DEFINE(op_msg), | 535 | D_SUBMODULE_DEFINE(op_msg), |
534 | D_SUBMODULE_DEFINE(op_reset), | 536 | D_SUBMODULE_DEFINE(op_reset), |
535 | D_SUBMODULE_DEFINE(op_rfkill), | 537 | D_SUBMODULE_DEFINE(op_rfkill), |
538 | D_SUBMODULE_DEFINE(op_state_get), | ||
536 | D_SUBMODULE_DEFINE(stack), | 539 | D_SUBMODULE_DEFINE(stack), |
537 | }; | 540 | }; |
538 | size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL); | 541 | size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL); |