Thomas Gleixner | 04672fe | 2019-05-29 07:12:42 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Paulius Zaleckas | 7f0333e | 2009-05-13 06:20:29 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Linux WiMAX |
| 4 | * Implement and export a method for getting a WiMAX device current state |
| 5 | * |
| 6 | * Copyright (C) 2009 Paulius Zaleckas <paulius.zaleckas@teltonika.lt> |
| 7 | * |
| 8 | * Based on previous WiMAX core work by: |
| 9 | * Copyright (C) 2008 Intel Corporation <linux-wimax@intel.com> |
| 10 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> |
Paulius Zaleckas | 7f0333e | 2009-05-13 06:20:29 -0700 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <net/wimax.h> |
| 14 | #include <net/genetlink.h> |
| 15 | #include <linux/wimax.h> |
| 16 | #include <linux/security.h> |
| 17 | #include "wimax-internal.h" |
| 18 | |
| 19 | #define D_SUBMODULE op_state_get |
| 20 | #include "debug-levels.h" |
| 21 | |
| 22 | |
Paulius Zaleckas | 7f0333e | 2009-05-13 06:20:29 -0700 | [diff] [blame] | 23 | /* |
| 24 | * Exporting to user space over generic netlink |
| 25 | * |
| 26 | * Parse the state get command from user space, return a combination |
| 27 | * value that describe the current state. |
| 28 | * |
| 29 | * No attributes. |
| 30 | */ |
Paulius Zaleckas | 7f0333e | 2009-05-13 06:20:29 -0700 | [diff] [blame] | 31 | int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info) |
| 32 | { |
| 33 | int result, ifindex; |
| 34 | struct wimax_dev *wimax_dev; |
Paulius Zaleckas | 7f0333e | 2009-05-13 06:20:29 -0700 | [diff] [blame] | 35 | |
| 36 | d_fnstart(3, NULL, "(skb %p info %p)\n", skb, info); |
| 37 | result = -ENODEV; |
| 38 | if (info->attrs[WIMAX_GNL_STGET_IFIDX] == NULL) { |
Fabian Frederick | 28b7dea | 2014-10-07 22:12:03 +0200 | [diff] [blame] | 39 | pr_err("WIMAX_GNL_OP_STATE_GET: can't find IFIDX attribute\n"); |
Paulius Zaleckas | 7f0333e | 2009-05-13 06:20:29 -0700 | [diff] [blame] | 40 | goto error_no_wimax_dev; |
| 41 | } |
| 42 | ifindex = nla_get_u32(info->attrs[WIMAX_GNL_STGET_IFIDX]); |
| 43 | wimax_dev = wimax_dev_get_by_genl_info(info, ifindex); |
| 44 | if (wimax_dev == NULL) |
| 45 | goto error_no_wimax_dev; |
Paulius Zaleckas | 7f0333e | 2009-05-13 06:20:29 -0700 | [diff] [blame] | 46 | /* Execute the operation and send the result back to user space */ |
| 47 | result = wimax_state_get(wimax_dev); |
| 48 | dev_put(wimax_dev->net_dev); |
| 49 | error_no_wimax_dev: |
| 50 | d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result); |
| 51 | return result; |
| 52 | } |