Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
33575df7
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
33575df7
编写于
2月 04, 2011
作者:
G
Gustavo F. Padovan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bluetooth: move l2cap_sock_setsockopt() to l2cap_sock.c
Signed-off-by:
N
Gustavo F. Padovan
<
padovan@profusion.mobi
>
上级
d7175d55
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
175 addition
and
175 deletion
+175
-175
include/net/bluetooth/l2cap.h
include/net/bluetooth/l2cap.h
+0
-1
net/bluetooth/l2cap_core.c
net/bluetooth/l2cap_core.c
+0
-174
net/bluetooth/l2cap_sock.c
net/bluetooth/l2cap_sock.c
+175
-0
未找到文件。
include/net/bluetooth/l2cap.h
浏览文件 @
33575df7
...
...
@@ -442,7 +442,6 @@ int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int
int
l2cap_sock_sendmsg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
msg
,
size_t
len
);
int
l2cap_sock_recvmsg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
msg
,
size_t
len
,
int
flags
);
int
l2cap_sock_shutdown
(
struct
socket
*
sock
,
int
how
);
int
l2cap_sock_setsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
unsigned
int
optlen
);
int
l2cap_sock_getsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
__user
*
optlen
);
...
...
net/bluetooth/l2cap_core.c
浏览文件 @
33575df7
...
...
@@ -1596,180 +1596,6 @@ int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m
return
bt_sock_recvmsg
(
iocb
,
sock
,
msg
,
len
,
flags
);
}
static
int
l2cap_sock_setsockopt_old
(
struct
socket
*
sock
,
int
optname
,
char
__user
*
optval
,
unsigned
int
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
l2cap_options
opts
;
int
len
,
err
=
0
;
u32
opt
;
BT_DBG
(
"sk %p"
,
sk
);
lock_sock
(
sk
);
switch
(
optname
)
{
case
L2CAP_OPTIONS
:
if
(
sk
->
sk_state
==
BT_CONNECTED
)
{
err
=
-
EINVAL
;
break
;
}
opts
.
imtu
=
l2cap_pi
(
sk
)
->
imtu
;
opts
.
omtu
=
l2cap_pi
(
sk
)
->
omtu
;
opts
.
flush_to
=
l2cap_pi
(
sk
)
->
flush_to
;
opts
.
mode
=
l2cap_pi
(
sk
)
->
mode
;
opts
.
fcs
=
l2cap_pi
(
sk
)
->
fcs
;
opts
.
max_tx
=
l2cap_pi
(
sk
)
->
max_tx
;
opts
.
txwin_size
=
(
__u16
)
l2cap_pi
(
sk
)
->
tx_win
;
len
=
min_t
(
unsigned
int
,
sizeof
(
opts
),
optlen
);
if
(
copy_from_user
((
char
*
)
&
opts
,
optval
,
len
))
{
err
=
-
EFAULT
;
break
;
}
if
(
opts
.
txwin_size
>
L2CAP_DEFAULT_TX_WINDOW
)
{
err
=
-
EINVAL
;
break
;
}
l2cap_pi
(
sk
)
->
mode
=
opts
.
mode
;
switch
(
l2cap_pi
(
sk
)
->
mode
)
{
case
L2CAP_MODE_BASIC
:
l2cap_pi
(
sk
)
->
conf_state
&=
~
L2CAP_CONF_STATE2_DEVICE
;
break
;
case
L2CAP_MODE_ERTM
:
case
L2CAP_MODE_STREAMING
:
if
(
!
disable_ertm
)
break
;
/* fall through */
default:
err
=
-
EINVAL
;
break
;
}
l2cap_pi
(
sk
)
->
imtu
=
opts
.
imtu
;
l2cap_pi
(
sk
)
->
omtu
=
opts
.
omtu
;
l2cap_pi
(
sk
)
->
fcs
=
opts
.
fcs
;
l2cap_pi
(
sk
)
->
max_tx
=
opts
.
max_tx
;
l2cap_pi
(
sk
)
->
tx_win
=
(
__u8
)
opts
.
txwin_size
;
break
;
case
L2CAP_LM
:
if
(
get_user
(
opt
,
(
u32
__user
*
)
optval
))
{
err
=
-
EFAULT
;
break
;
}
if
(
opt
&
L2CAP_LM_AUTH
)
l2cap_pi
(
sk
)
->
sec_level
=
BT_SECURITY_LOW
;
if
(
opt
&
L2CAP_LM_ENCRYPT
)
l2cap_pi
(
sk
)
->
sec_level
=
BT_SECURITY_MEDIUM
;
if
(
opt
&
L2CAP_LM_SECURE
)
l2cap_pi
(
sk
)
->
sec_level
=
BT_SECURITY_HIGH
;
l2cap_pi
(
sk
)
->
role_switch
=
(
opt
&
L2CAP_LM_MASTER
);
l2cap_pi
(
sk
)
->
force_reliable
=
(
opt
&
L2CAP_LM_RELIABLE
);
break
;
default:
err
=
-
ENOPROTOOPT
;
break
;
}
release_sock
(
sk
);
return
err
;
}
int
l2cap_sock_setsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
unsigned
int
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
bt_security
sec
;
int
len
,
err
=
0
;
u32
opt
;
BT_DBG
(
"sk %p"
,
sk
);
if
(
level
==
SOL_L2CAP
)
return
l2cap_sock_setsockopt_old
(
sock
,
optname
,
optval
,
optlen
);
if
(
level
!=
SOL_BLUETOOTH
)
return
-
ENOPROTOOPT
;
lock_sock
(
sk
);
switch
(
optname
)
{
case
BT_SECURITY
:
if
(
sk
->
sk_type
!=
SOCK_SEQPACKET
&&
sk
->
sk_type
!=
SOCK_STREAM
&&
sk
->
sk_type
!=
SOCK_RAW
)
{
err
=
-
EINVAL
;
break
;
}
sec
.
level
=
BT_SECURITY_LOW
;
len
=
min_t
(
unsigned
int
,
sizeof
(
sec
),
optlen
);
if
(
copy_from_user
((
char
*
)
&
sec
,
optval
,
len
))
{
err
=
-
EFAULT
;
break
;
}
if
(
sec
.
level
<
BT_SECURITY_LOW
||
sec
.
level
>
BT_SECURITY_HIGH
)
{
err
=
-
EINVAL
;
break
;
}
l2cap_pi
(
sk
)
->
sec_level
=
sec
.
level
;
break
;
case
BT_DEFER_SETUP
:
if
(
sk
->
sk_state
!=
BT_BOUND
&&
sk
->
sk_state
!=
BT_LISTEN
)
{
err
=
-
EINVAL
;
break
;
}
if
(
get_user
(
opt
,
(
u32
__user
*
)
optval
))
{
err
=
-
EFAULT
;
break
;
}
bt_sk
(
sk
)
->
defer_setup
=
opt
;
break
;
case
BT_FLUSHABLE
:
if
(
get_user
(
opt
,
(
u32
__user
*
)
optval
))
{
err
=
-
EFAULT
;
break
;
}
if
(
opt
>
BT_FLUSHABLE_ON
)
{
err
=
-
EINVAL
;
break
;
}
if
(
opt
==
BT_FLUSHABLE_OFF
)
{
struct
l2cap_conn
*
conn
=
l2cap_pi
(
sk
)
->
conn
;
/* proceed futher only when we have l2cap_conn and
No Flush support in the LM */
if
(
!
conn
||
!
lmp_no_flush_capable
(
conn
->
hcon
->
hdev
))
{
err
=
-
EINVAL
;
break
;
}
}
l2cap_pi
(
sk
)
->
flushable
=
opt
;
break
;
default:
err
=
-
ENOPROTOOPT
;
break
;
}
release_sock
(
sk
);
return
err
;
}
static
int
l2cap_sock_getsockopt_old
(
struct
socket
*
sock
,
int
optname
,
char
__user
*
optval
,
int
__user
*
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
...
...
net/bluetooth/l2cap_sock.c
浏览文件 @
33575df7
...
...
@@ -27,6 +27,7 @@
/* Bluetooth L2CAP sockets. */
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/l2cap.h>
static
void
l2cap_sock_timeout
(
unsigned
long
arg
)
...
...
@@ -276,6 +277,180 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l
return
0
;
}
static
int
l2cap_sock_setsockopt_old
(
struct
socket
*
sock
,
int
optname
,
char
__user
*
optval
,
unsigned
int
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
l2cap_options
opts
;
int
len
,
err
=
0
;
u32
opt
;
BT_DBG
(
"sk %p"
,
sk
);
lock_sock
(
sk
);
switch
(
optname
)
{
case
L2CAP_OPTIONS
:
if
(
sk
->
sk_state
==
BT_CONNECTED
)
{
err
=
-
EINVAL
;
break
;
}
opts
.
imtu
=
l2cap_pi
(
sk
)
->
imtu
;
opts
.
omtu
=
l2cap_pi
(
sk
)
->
omtu
;
opts
.
flush_to
=
l2cap_pi
(
sk
)
->
flush_to
;
opts
.
mode
=
l2cap_pi
(
sk
)
->
mode
;
opts
.
fcs
=
l2cap_pi
(
sk
)
->
fcs
;
opts
.
max_tx
=
l2cap_pi
(
sk
)
->
max_tx
;
opts
.
txwin_size
=
(
__u16
)
l2cap_pi
(
sk
)
->
tx_win
;
len
=
min_t
(
unsigned
int
,
sizeof
(
opts
),
optlen
);
if
(
copy_from_user
((
char
*
)
&
opts
,
optval
,
len
))
{
err
=
-
EFAULT
;
break
;
}
if
(
opts
.
txwin_size
>
L2CAP_DEFAULT_TX_WINDOW
)
{
err
=
-
EINVAL
;
break
;
}
l2cap_pi
(
sk
)
->
mode
=
opts
.
mode
;
switch
(
l2cap_pi
(
sk
)
->
mode
)
{
case
L2CAP_MODE_BASIC
:
l2cap_pi
(
sk
)
->
conf_state
&=
~
L2CAP_CONF_STATE2_DEVICE
;
break
;
case
L2CAP_MODE_ERTM
:
case
L2CAP_MODE_STREAMING
:
if
(
!
disable_ertm
)
break
;
/* fall through */
default:
err
=
-
EINVAL
;
break
;
}
l2cap_pi
(
sk
)
->
imtu
=
opts
.
imtu
;
l2cap_pi
(
sk
)
->
omtu
=
opts
.
omtu
;
l2cap_pi
(
sk
)
->
fcs
=
opts
.
fcs
;
l2cap_pi
(
sk
)
->
max_tx
=
opts
.
max_tx
;
l2cap_pi
(
sk
)
->
tx_win
=
(
__u8
)
opts
.
txwin_size
;
break
;
case
L2CAP_LM
:
if
(
get_user
(
opt
,
(
u32
__user
*
)
optval
))
{
err
=
-
EFAULT
;
break
;
}
if
(
opt
&
L2CAP_LM_AUTH
)
l2cap_pi
(
sk
)
->
sec_level
=
BT_SECURITY_LOW
;
if
(
opt
&
L2CAP_LM_ENCRYPT
)
l2cap_pi
(
sk
)
->
sec_level
=
BT_SECURITY_MEDIUM
;
if
(
opt
&
L2CAP_LM_SECURE
)
l2cap_pi
(
sk
)
->
sec_level
=
BT_SECURITY_HIGH
;
l2cap_pi
(
sk
)
->
role_switch
=
(
opt
&
L2CAP_LM_MASTER
);
l2cap_pi
(
sk
)
->
force_reliable
=
(
opt
&
L2CAP_LM_RELIABLE
);
break
;
default:
err
=
-
ENOPROTOOPT
;
break
;
}
release_sock
(
sk
);
return
err
;
}
static
int
l2cap_sock_setsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
unsigned
int
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
bt_security
sec
;
int
len
,
err
=
0
;
u32
opt
;
BT_DBG
(
"sk %p"
,
sk
);
if
(
level
==
SOL_L2CAP
)
return
l2cap_sock_setsockopt_old
(
sock
,
optname
,
optval
,
optlen
);
if
(
level
!=
SOL_BLUETOOTH
)
return
-
ENOPROTOOPT
;
lock_sock
(
sk
);
switch
(
optname
)
{
case
BT_SECURITY
:
if
(
sk
->
sk_type
!=
SOCK_SEQPACKET
&&
sk
->
sk_type
!=
SOCK_STREAM
&&
sk
->
sk_type
!=
SOCK_RAW
)
{
err
=
-
EINVAL
;
break
;
}
sec
.
level
=
BT_SECURITY_LOW
;
len
=
min_t
(
unsigned
int
,
sizeof
(
sec
),
optlen
);
if
(
copy_from_user
((
char
*
)
&
sec
,
optval
,
len
))
{
err
=
-
EFAULT
;
break
;
}
if
(
sec
.
level
<
BT_SECURITY_LOW
||
sec
.
level
>
BT_SECURITY_HIGH
)
{
err
=
-
EINVAL
;
break
;
}
l2cap_pi
(
sk
)
->
sec_level
=
sec
.
level
;
break
;
case
BT_DEFER_SETUP
:
if
(
sk
->
sk_state
!=
BT_BOUND
&&
sk
->
sk_state
!=
BT_LISTEN
)
{
err
=
-
EINVAL
;
break
;
}
if
(
get_user
(
opt
,
(
u32
__user
*
)
optval
))
{
err
=
-
EFAULT
;
break
;
}
bt_sk
(
sk
)
->
defer_setup
=
opt
;
break
;
case
BT_FLUSHABLE
:
if
(
get_user
(
opt
,
(
u32
__user
*
)
optval
))
{
err
=
-
EFAULT
;
break
;
}
if
(
opt
>
BT_FLUSHABLE_ON
)
{
err
=
-
EINVAL
;
break
;
}
if
(
opt
==
BT_FLUSHABLE_OFF
)
{
struct
l2cap_conn
*
conn
=
l2cap_pi
(
sk
)
->
conn
;
/* proceed futher only when we have l2cap_conn and
No Flush support in the LM */
if
(
!
conn
||
!
lmp_no_flush_capable
(
conn
->
hcon
->
hdev
))
{
err
=
-
EINVAL
;
break
;
}
}
l2cap_pi
(
sk
)
->
flushable
=
opt
;
break
;
default:
err
=
-
ENOPROTOOPT
;
break
;
}
release_sock
(
sk
);
return
err
;
}
static
int
l2cap_sock_release
(
struct
socket
*
sock
)
{
struct
sock
*
sk
=
sock
->
sk
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录