diff options
Diffstat (limited to 'net/wireless/wext.c')
-rw-r--r-- | net/wireless/wext.c | 73 |
1 files changed, 26 insertions, 47 deletions
diff --git a/net/wireless/wext.c b/net/wireless/wext.c index dabc6453518..adcb08344d5 100644 --- a/net/wireless/wext.c +++ b/net/wireless/wext.c | |||
@@ -1035,53 +1035,31 @@ static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) | |||
1035 | /* A bunch of special cases, then the generic case... | 1035 | /* A bunch of special cases, then the generic case... |
1036 | * Note that 'cmd' is already filtered in dev_ioctl() with | 1036 | * Note that 'cmd' is already filtered in dev_ioctl() with |
1037 | * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */ | 1037 | * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */ |
1038 | switch (cmd) { | 1038 | if (cmd == SIOCGIWSTATS) |
1039 | case SIOCGIWSTATS: | 1039 | return ioctl_standard_call(dev, ifr, cmd, |
1040 | /* Get Wireless Stats */ | ||
1041 | return ioctl_standard_call(dev, | ||
1042 | ifr, | ||
1043 | cmd, | ||
1044 | &iw_handler_get_iwstats); | 1040 | &iw_handler_get_iwstats); |
1045 | 1041 | ||
1046 | case SIOCGIWPRIV: | 1042 | if (cmd == SIOCGIWPRIV && dev->wireless_handlers) |
1047 | /* Check if we have some wireless handlers defined */ | 1043 | return ioctl_standard_call(dev, ifr, cmd, |
1048 | if (dev->wireless_handlers != NULL) { | 1044 | &iw_handler_get_private); |
1049 | /* We export to user space the definition of | 1045 | |
1050 | * the private handler ourselves */ | 1046 | /* Basic check */ |
1051 | return ioctl_standard_call(dev, | 1047 | if (!netif_device_present(dev)) |
1052 | ifr, | 1048 | return -ENODEV; |
1053 | cmd, | 1049 | |
1054 | &iw_handler_get_private); | 1050 | /* New driver API : try to find the handler */ |
1055 | } | 1051 | handler = get_handler(dev, cmd); |
1056 | // ## Fall-through for old API ## | 1052 | if (handler) { |
1057 | default: | 1053 | /* Standard and private are not the same */ |
1058 | /* Generic IOCTL */ | 1054 | if (cmd < SIOCIWFIRSTPRIV) |
1059 | /* Basic check */ | 1055 | return ioctl_standard_call(dev, ifr, cmd, handler); |
1060 | if (!netif_device_present(dev)) | 1056 | else |
1061 | return -ENODEV; | 1057 | return ioctl_private_call(dev, ifr, cmd, handler); |
1062 | /* New driver API : try to find the handler */ | ||
1063 | handler = get_handler(dev, cmd); | ||
1064 | if (handler != NULL) { | ||
1065 | /* Standard and private are not the same */ | ||
1066 | if (cmd < SIOCIWFIRSTPRIV) | ||
1067 | return ioctl_standard_call(dev, | ||
1068 | ifr, | ||
1069 | cmd, | ||
1070 | handler); | ||
1071 | else | ||
1072 | return ioctl_private_call(dev, | ||
1073 | ifr, | ||
1074 | cmd, | ||
1075 | handler); | ||
1076 | } | ||
1077 | /* Old driver API : call driver ioctl handler */ | ||
1078 | if (dev->do_ioctl) { | ||
1079 | return dev->do_ioctl(dev, ifr, cmd); | ||
1080 | } | ||
1081 | return -EOPNOTSUPP; | ||
1082 | } | 1058 | } |
1083 | /* Not reached */ | 1059 | /* Old driver API : call driver ioctl handler */ |
1084 | return -EINVAL; | 1060 | if (dev->do_ioctl) |
1061 | return dev->do_ioctl(dev, ifr, cmd); | ||
1062 | return -EOPNOTSUPP; | ||
1085 | } | 1063 | } |
1086 | 1064 | ||
1087 | /* entry point from dev ioctl */ | 1065 | /* entry point from dev ioctl */ |
@@ -1093,9 +1071,10 @@ int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, | |||
1093 | /* If command is `set a parameter', or | 1071 | /* If command is `set a parameter', or |
1094 | * `get the encoding parameters', check if | 1072 | * `get the encoding parameters', check if |
1095 | * the user has the right to do it */ | 1073 | * the user has the right to do it */ |
1096 | if (IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT) | 1074 | if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT) |
1097 | if (!capable(CAP_NET_ADMIN)) | 1075 | && !capable(CAP_NET_ADMIN)) |
1098 | return -EPERM; | 1076 | return -EPERM; |
1077 | |||
1099 | dev_load(ifr->ifr_name); | 1078 | dev_load(ifr->ifr_name); |
1100 | rtnl_lock(); | 1079 | rtnl_lock(); |
1101 | ret = wireless_process_ioctl(ifr, cmd); | 1080 | ret = wireless_process_ioctl(ifr, cmd); |