Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
84149b0f
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
84149b0f
编写于
12月 21, 2007
作者:
D
David S. Miller
提交者:
David S. Miller
6月 16, 2008
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wext: Extract standard call iw_point handling into seperate function.
Signed-off-by:
N
David S. Miller
<
davem@davemloft.net
>
上级
208887d4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
134 addition
and
124 deletion
+134
-124
net/wireless/wext.c
net/wireless/wext.c
+134
-124
未找到文件。
net/wireless/wext.c
浏览文件 @
84149b0f
...
...
@@ -694,6 +694,138 @@ void wext_proc_exit(struct net *net)
*/
/* ---------------------------------------------------------------- */
static
int
ioctl_standard_iw_point
(
struct
iw_point
*
iwp
,
unsigned
int
cmd
,
const
struct
iw_ioctl_description
*
descr
,
iw_handler
handler
,
struct
net_device
*
dev
,
struct
iw_request_info
*
info
)
{
int
err
,
extra_size
,
user_length
=
0
,
essid_compat
=
0
;
char
*
extra
;
/* Calculate space needed by arguments. Always allocate
* for max space.
*/
extra_size
=
descr
->
max_tokens
*
descr
->
token_size
;
/* Check need for ESSID compatibility for WE < 21 */
switch
(
cmd
)
{
case
SIOCSIWESSID
:
case
SIOCGIWESSID
:
case
SIOCSIWNICKN
:
case
SIOCGIWNICKN
:
if
(
iwp
->
length
==
descr
->
max_tokens
+
1
)
essid_compat
=
1
;
else
if
(
IW_IS_SET
(
cmd
)
&&
(
iwp
->
length
!=
0
))
{
char
essid
[
IW_ESSID_MAX_SIZE
+
1
];
err
=
copy_from_user
(
essid
,
iwp
->
pointer
,
iwp
->
length
*
descr
->
token_size
);
if
(
err
)
return
-
EFAULT
;
if
(
essid
[
iwp
->
length
-
1
]
==
'\0'
)
essid_compat
=
1
;
}
break
;
default:
break
;
}
iwp
->
length
-=
essid_compat
;
/* Check what user space is giving us */
if
(
IW_IS_SET
(
cmd
))
{
/* Check NULL pointer */
if
(
!
iwp
->
pointer
&&
iwp
->
length
!=
0
)
return
-
EFAULT
;
/* Check if number of token fits within bounds */
if
(
iwp
->
length
>
descr
->
max_tokens
)
return
-
E2BIG
;
if
(
iwp
->
length
<
descr
->
min_tokens
)
return
-
EINVAL
;
}
else
{
/* Check NULL pointer */
if
(
!
iwp
->
pointer
)
return
-
EFAULT
;
/* Save user space buffer size for checking */
user_length
=
iwp
->
length
;
/* Don't check if user_length > max to allow forward
* compatibility. The test user_length < min is
* implied by the test at the end.
*/
/* Support for very large requests */
if
((
descr
->
flags
&
IW_DESCR_FLAG_NOMAX
)
&&
(
user_length
>
descr
->
max_tokens
))
{
/* Allow userspace to GET more than max so
* we can support any size GET requests.
* There is still a limit : -ENOMEM.
*/
extra_size
=
user_length
*
descr
->
token_size
;
/* Note : user_length is originally a __u16,
* and token_size is controlled by us,
* so extra_size won't get negative and
* won't overflow...
*/
}
}
/* kzalloc() ensures NULL-termination for essid_compat. */
extra
=
kzalloc
(
extra_size
,
GFP_KERNEL
);
if
(
!
extra
)
return
-
ENOMEM
;
/* If it is a SET, get all the extra data in here */
if
(
IW_IS_SET
(
cmd
)
&&
(
iwp
->
length
!=
0
))
{
if
(
copy_from_user
(
extra
,
iwp
->
pointer
,
iwp
->
length
*
descr
->
token_size
))
{
err
=
-
EFAULT
;
goto
out
;
}
}
err
=
handler
(
dev
,
info
,
(
union
iwreq_data
*
)
iwp
,
extra
);
iwp
->
length
+=
essid_compat
;
/* If we have something to return to the user */
if
(
!
err
&&
IW_IS_GET
(
cmd
))
{
/* Check if there is enough buffer up there */
if
(
user_length
<
iwp
->
length
)
{
err
=
-
E2BIG
;
goto
out
;
}
if
(
copy_to_user
(
iwp
->
pointer
,
extra
,
iwp
->
length
*
descr
->
token_size
))
{
err
=
-
EFAULT
;
goto
out
;
}
}
/* Generate an event to notify listeners of the change */
if
((
descr
->
flags
&
IW_DESCR_FLAG_EVENT
)
&&
err
==
-
EIWCOMMIT
)
{
union
iwreq_data
*
data
=
(
union
iwreq_data
*
)
iwp
;
if
(
descr
->
flags
&
IW_DESCR_FLAG_RESTRICT
)
/* If the event is restricted, don't
* export the payload.
*/
wireless_send_event
(
dev
,
cmd
,
data
,
NULL
);
else
wireless_send_event
(
dev
,
cmd
,
data
,
extra
);
}
out:
kfree
(
extra
);
return
err
;
}
/*
* Wrapper to call a standard Wireless Extension handler.
* We do various checks and also take care of moving data between
...
...
@@ -729,130 +861,8 @@ static int ioctl_standard_call(struct net_device * dev,
((
ret
==
0
)
||
(
ret
==
-
EIWCOMMIT
)))
wireless_send_event
(
dev
,
cmd
,
&
(
iwr
->
u
),
NULL
);
}
else
{
char
*
extra
;
int
extra_size
;
int
user_length
=
0
;
int
err
;
int
essid_compat
=
0
;
/* Calculate space needed by arguments. Always allocate
* for max space. Easier, and won't last long... */
extra_size
=
descr
->
max_tokens
*
descr
->
token_size
;
/* Check need for ESSID compatibility for WE < 21 */
switch
(
cmd
)
{
case
SIOCSIWESSID
:
case
SIOCGIWESSID
:
case
SIOCSIWNICKN
:
case
SIOCGIWNICKN
:
if
(
iwr
->
u
.
data
.
length
==
descr
->
max_tokens
+
1
)
essid_compat
=
1
;
else
if
(
IW_IS_SET
(
cmd
)
&&
(
iwr
->
u
.
data
.
length
!=
0
))
{
char
essid
[
IW_ESSID_MAX_SIZE
+
1
];
err
=
copy_from_user
(
essid
,
iwr
->
u
.
data
.
pointer
,
iwr
->
u
.
data
.
length
*
descr
->
token_size
);
if
(
err
)
return
-
EFAULT
;
if
(
essid
[
iwr
->
u
.
data
.
length
-
1
]
==
'\0'
)
essid_compat
=
1
;
}
break
;
default:
break
;
}
iwr
->
u
.
data
.
length
-=
essid_compat
;
/* Check what user space is giving us */
if
(
IW_IS_SET
(
cmd
))
{
/* Check NULL pointer */
if
((
iwr
->
u
.
data
.
pointer
==
NULL
)
&&
(
iwr
->
u
.
data
.
length
!=
0
))
return
-
EFAULT
;
/* Check if number of token fits within bounds */
if
(
iwr
->
u
.
data
.
length
>
descr
->
max_tokens
)
return
-
E2BIG
;
if
(
iwr
->
u
.
data
.
length
<
descr
->
min_tokens
)
return
-
EINVAL
;
}
else
{
/* Check NULL pointer */
if
(
iwr
->
u
.
data
.
pointer
==
NULL
)
return
-
EFAULT
;
/* Save user space buffer size for checking */
user_length
=
iwr
->
u
.
data
.
length
;
/* Don't check if user_length > max to allow forward
* compatibility. The test user_length < min is
* implied by the test at the end. */
/* Support for very large requests */
if
((
descr
->
flags
&
IW_DESCR_FLAG_NOMAX
)
&&
(
user_length
>
descr
->
max_tokens
))
{
/* Allow userspace to GET more than max so
* we can support any size GET requests.
* There is still a limit : -ENOMEM. */
extra_size
=
user_length
*
descr
->
token_size
;
/* Note : user_length is originally a __u16,
* and token_size is controlled by us,
* so extra_size won't get negative and
* won't overflow... */
}
}
/* Create the kernel buffer */
/* kzalloc ensures NULL-termination for essid_compat */
extra
=
kzalloc
(
extra_size
,
GFP_KERNEL
);
if
(
extra
==
NULL
)
return
-
ENOMEM
;
/* If it is a SET, get all the extra data in here */
if
(
IW_IS_SET
(
cmd
)
&&
(
iwr
->
u
.
data
.
length
!=
0
))
{
err
=
copy_from_user
(
extra
,
iwr
->
u
.
data
.
pointer
,
iwr
->
u
.
data
.
length
*
descr
->
token_size
);
if
(
err
)
{
kfree
(
extra
);
return
-
EFAULT
;
}
}
/* Call the handler */
ret
=
handler
(
dev
,
&
info
,
&
(
iwr
->
u
),
extra
);
iwr
->
u
.
data
.
length
+=
essid_compat
;
/* If we have something to return to the user */
if
(
!
ret
&&
IW_IS_GET
(
cmd
))
{
/* Check if there is enough buffer up there */
if
(
user_length
<
iwr
->
u
.
data
.
length
)
{
kfree
(
extra
);
return
-
E2BIG
;
}
err
=
copy_to_user
(
iwr
->
u
.
data
.
pointer
,
extra
,
iwr
->
u
.
data
.
length
*
descr
->
token_size
);
if
(
err
)
ret
=
-
EFAULT
;
}
/* Generate an event to notify listeners of the change */
if
((
descr
->
flags
&
IW_DESCR_FLAG_EVENT
)
&&
((
ret
==
0
)
||
(
ret
==
-
EIWCOMMIT
)))
{
if
(
descr
->
flags
&
IW_DESCR_FLAG_RESTRICT
)
/* If the event is restricted, don't
* export the payload */
wireless_send_event
(
dev
,
cmd
,
&
(
iwr
->
u
),
NULL
);
else
wireless_send_event
(
dev
,
cmd
,
&
(
iwr
->
u
),
extra
);
}
/* Cleanup - I told you it wasn't that long ;-) */
kfree
(
extra
);
ret
=
ioctl_standard_iw_point
(
&
iwr
->
u
.
data
,
cmd
,
descr
,
handler
,
dev
,
&
info
);
}
/* Call commit handler if needed and defined */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录