aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/iw_handler.h11
-rw-r--r--include/net/wext.h24
-rw-r--r--net/core/dev.c34
-rw-r--r--net/wireless/wext.c28
4 files changed, 53 insertions, 44 deletions
diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h
index 909ca87d13b7..f23d07ca7c59 100644
--- a/include/net/iw_handler.h
+++ b/include/net/iw_handler.h
@@ -431,16 +431,7 @@ struct iw_public_data {
431 * Those may be called only within the kernel. 431 * Those may be called only within the kernel.
432 */ 432 */
433 433
434/* First : function strictly used inside the kernel */ 434/* functions that may be called by driver modules */
435
436/* Handle /proc/net/wireless, called in net/code/dev.c */
437extern int dev_get_wireless_info(char * buffer, char **start, off_t offset,
438 int length);
439
440/* Handle IOCTLs, called in net/core/dev.c */
441extern int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd);
442
443/* Second : functions that may be called by driver modules */
444 435
445/* Send a single event to user space */ 436/* Send a single event to user space */
446extern void wireless_send_event(struct net_device * dev, 437extern void wireless_send_event(struct net_device * dev,
diff --git a/include/net/wext.h b/include/net/wext.h
new file mode 100644
index 000000000000..55741836a675
--- /dev/null
+++ b/include/net/wext.h
@@ -0,0 +1,24 @@
1#ifndef __NET_WEXT_H
2#define __NET_WEXT_H
3
4/*
5 * wireless extensions interface to the core code
6 */
7
8#ifdef CONFIG_WIRELESS_EXT
9extern int wext_proc_init(void);
10extern int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
11 void __user *arg);
12#else
13static inline int wext_proc_init()
14{
15 return 0;
16}
17static inline int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
18 void __user *arg)
19{
20 return -EINVAL;
21}
22#endif
23
24#endif /* __NET_WEXT_H */
diff --git a/net/core/dev.c b/net/core/dev.c
index 700e4b5081b6..d5e42d13bd67 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -109,7 +109,7 @@
109#include <linux/netpoll.h> 109#include <linux/netpoll.h>
110#include <linux/rcupdate.h> 110#include <linux/rcupdate.h>
111#include <linux/delay.h> 111#include <linux/delay.h>
112#include <linux/wireless.h> 112#include <net/wext.h>
113#include <net/iw_handler.h> 113#include <net/iw_handler.h>
114#include <asm/current.h> 114#include <asm/current.h>
115#include <linux/audit.h> 115#include <linux/audit.h>
@@ -2348,12 +2348,6 @@ static const struct file_operations ptype_seq_fops = {
2348}; 2348};
2349 2349
2350 2350
2351#ifdef CONFIG_WIRELESS_EXT
2352extern int wireless_proc_init(void);
2353#else
2354#define wireless_proc_init() 0
2355#endif
2356
2357static int __init dev_proc_init(void) 2351static int __init dev_proc_init(void)
2358{ 2352{
2359 int rc = -ENOMEM; 2353 int rc = -ENOMEM;
@@ -2365,7 +2359,7 @@ static int __init dev_proc_init(void)
2365 if (!proc_net_fops_create("ptype", S_IRUGO, &ptype_seq_fops)) 2359 if (!proc_net_fops_create("ptype", S_IRUGO, &ptype_seq_fops))
2366 goto out_dev2; 2360 goto out_dev2;
2367 2361
2368 if (wireless_proc_init()) 2362 if (wext_proc_init())
2369 goto out_softnet; 2363 goto out_softnet;
2370 rc = 0; 2364 rc = 0;
2371out: 2365out:
@@ -2923,29 +2917,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
2923 ret = -EFAULT; 2917 ret = -EFAULT;
2924 return ret; 2918 return ret;
2925 } 2919 }
2926#ifdef CONFIG_WIRELESS_EXT
2927 /* Take care of Wireless Extensions */ 2920 /* Take care of Wireless Extensions */
2928 if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) { 2921 if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST)
2929 /* If command is `set a parameter', or 2922 return wext_handle_ioctl(&ifr, cmd, arg);
2930 * `get the encoding parameters', check if
2931 * the user has the right to do it */
2932 if (IW_IS_SET(cmd) || cmd == SIOCGIWENCODE
2933 || cmd == SIOCGIWENCODEEXT) {
2934 if (!capable(CAP_NET_ADMIN))
2935 return -EPERM;
2936 }
2937 dev_load(ifr.ifr_name);
2938 rtnl_lock();
2939 /* Follow me in net/wireless/wext.c */
2940 ret = wireless_process_ioctl(&ifr, cmd);
2941 rtnl_unlock();
2942 if (IW_IS_GET(cmd) &&
2943 copy_to_user(arg, &ifr,
2944 sizeof(struct ifreq)))
2945 ret = -EFAULT;
2946 return ret;
2947 }
2948#endif /* CONFIG_WIRELESS_EXT */
2949 return -EINVAL; 2923 return -EINVAL;
2950 } 2924 }
2951} 2925}
diff --git a/net/wireless/wext.c b/net/wireless/wext.c
index fba295e05e7a..a6cf1034e07c 100644
--- a/net/wireless/wext.c
+++ b/net/wireless/wext.c
@@ -97,6 +97,7 @@
97#include <linux/wireless.h> /* Pretty obvious */ 97#include <linux/wireless.h> /* Pretty obvious */
98#include <net/iw_handler.h> /* New driver API */ 98#include <net/iw_handler.h> /* New driver API */
99#include <net/netlink.h> 99#include <net/netlink.h>
100#include <net/wext.h>
100 101
101#include <asm/uaccess.h> /* copy_to_user() */ 102#include <asm/uaccess.h> /* copy_to_user() */
102 103
@@ -696,7 +697,7 @@ static const struct file_operations wireless_seq_fops = {
696 .release = seq_release, 697 .release = seq_release,
697}; 698};
698 699
699int __init wireless_proc_init(void) 700int __init wext_proc_init(void)
700{ 701{
701 /* Create /proc/net/wireless entry */ 702 /* Create /proc/net/wireless entry */
702 if (!proc_net_fops_create("wireless", S_IRUGO, &wireless_seq_fops)) 703 if (!proc_net_fops_create("wireless", S_IRUGO, &wireless_seq_fops))
@@ -1075,11 +1076,10 @@ static inline int ioctl_private_call(struct net_device * dev,
1075 1076
1076/* ---------------------------------------------------------------- */ 1077/* ---------------------------------------------------------------- */
1077/* 1078/*
1078 * Main IOCTl dispatcher. Called from the main networking code 1079 * Main IOCTl dispatcher.
1079 * (dev_ioctl() in net/core/dev.c).
1080 * Check the type of IOCTL and call the appropriate wrapper... 1080 * Check the type of IOCTL and call the appropriate wrapper...
1081 */ 1081 */
1082int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) 1082static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
1083{ 1083{
1084 struct net_device *dev; 1084 struct net_device *dev;
1085 iw_handler handler; 1085 iw_handler handler;
@@ -1143,6 +1143,26 @@ int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
1143 return -EINVAL; 1143 return -EINVAL;
1144} 1144}
1145 1145
1146/* entry point from dev ioctl */
1147int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
1148 void __user *arg)
1149{
1150 int ret;
1151
1152 /* If command is `set a parameter', or
1153 * `get the encoding parameters', check if
1154 * the user has the right to do it */
1155 if (IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)
1156 if (!capable(CAP_NET_ADMIN))
1157 return -EPERM;
1158 dev_load(ifr->ifr_name);
1159 rtnl_lock();
1160 ret = wireless_process_ioctl(ifr, cmd);
1161 rtnl_unlock();
1162 if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct ifreq)))
1163 return -EFAULT;
1164 return ret;
1165}
1146 1166
1147/************************* EVENT PROCESSING *************************/ 1167/************************* EVENT PROCESSING *************************/
1148/* 1168/*