Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
af6bcd82
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看板
提交
af6bcd82
编写于
2月 04, 2011
作者:
G
Gustavo F. Padovan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bluetooth: move l2cap_sock_bind()/listen() to l2cap_sock.c
Signed-off-by:
N
Gustavo F. Padovan
<
padovan@profusion.mobi
>
上级
554f05bb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
135 addition
and
136 deletion
+135
-136
include/net/bluetooth/l2cap.h
include/net/bluetooth/l2cap.h
+0
-2
net/bluetooth/l2cap_core.c
net/bluetooth/l2cap_core.c
+0
-134
net/bluetooth/l2cap_sock.c
net/bluetooth/l2cap_sock.c
+135
-0
未找到文件。
include/net/bluetooth/l2cap.h
浏览文件 @
af6bcd82
...
...
@@ -438,9 +438,7 @@ void l2cap_sock_init(struct sock *sk, struct sock *parent);
struct
sock
*
l2cap_sock_alloc
(
struct
net
*
net
,
struct
socket
*
sock
,
int
proto
,
gfp_t
prio
);
int
l2cap_sock_bind
(
struct
socket
*
sock
,
struct
sockaddr
*
addr
,
int
alen
);
int
l2cap_sock_connect
(
struct
socket
*
sock
,
struct
sockaddr
*
addr
,
int
alen
,
int
flags
);
int
l2cap_sock_listen
(
struct
socket
*
sock
,
int
backlog
);
int
l2cap_sock_accept
(
struct
socket
*
sock
,
struct
socket
*
newsock
,
int
flags
);
int
l2cap_sock_getname
(
struct
socket
*
sock
,
struct
sockaddr
*
addr
,
int
*
len
,
int
peer
);
int
l2cap_sock_sendmsg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
msg
,
size_t
len
);
...
...
net/bluetooth/l2cap_core.c
浏览文件 @
af6bcd82
...
...
@@ -722,17 +722,6 @@ static inline void l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, stru
}
/* ---- Socket interface ---- */
static
struct
sock
*
__l2cap_get_sock_by_addr
(
__le16
psm
,
bdaddr_t
*
src
)
{
struct
sock
*
sk
;
struct
hlist_node
*
node
;
sk_for_each
(
sk
,
node
,
&
l2cap_sk_list
.
head
)
if
(
l2cap_pi
(
sk
)
->
sport
==
psm
&&
!
bacmp
(
&
bt_sk
(
sk
)
->
src
,
src
))
goto
found
;
sk
=
NULL
;
found:
return
sk
;
}
/* Find socket with psm and source bdaddr.
* Returns closest match.
...
...
@@ -859,70 +848,6 @@ static void l2cap_sock_close(struct sock *sk)
l2cap_sock_kill
(
sk
);
}
int
l2cap_sock_bind
(
struct
socket
*
sock
,
struct
sockaddr
*
addr
,
int
alen
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sockaddr_l2
la
;
int
len
,
err
=
0
;
BT_DBG
(
"sk %p"
,
sk
);
if
(
!
addr
||
addr
->
sa_family
!=
AF_BLUETOOTH
)
return
-
EINVAL
;
memset
(
&
la
,
0
,
sizeof
(
la
));
len
=
min_t
(
unsigned
int
,
sizeof
(
la
),
alen
);
memcpy
(
&
la
,
addr
,
len
);
if
(
la
.
l2_cid
)
return
-
EINVAL
;
lock_sock
(
sk
);
if
(
sk
->
sk_state
!=
BT_OPEN
)
{
err
=
-
EBADFD
;
goto
done
;
}
if
(
la
.
l2_psm
)
{
__u16
psm
=
__le16_to_cpu
(
la
.
l2_psm
);
/* PSM must be odd and lsb of upper byte must be 0 */
if
((
psm
&
0x0101
)
!=
0x0001
)
{
err
=
-
EINVAL
;
goto
done
;
}
/* Restrict usage of well-known PSMs */
if
(
psm
<
0x1001
&&
!
capable
(
CAP_NET_BIND_SERVICE
))
{
err
=
-
EACCES
;
goto
done
;
}
}
write_lock_bh
(
&
l2cap_sk_list
.
lock
);
if
(
la
.
l2_psm
&&
__l2cap_get_sock_by_addr
(
la
.
l2_psm
,
&
la
.
l2_bdaddr
))
{
err
=
-
EADDRINUSE
;
}
else
{
/* Save source address */
bacpy
(
&
bt_sk
(
sk
)
->
src
,
&
la
.
l2_bdaddr
);
l2cap_pi
(
sk
)
->
psm
=
la
.
l2_psm
;
l2cap_pi
(
sk
)
->
sport
=
la
.
l2_psm
;
sk
->
sk_state
=
BT_BOUND
;
if
(
__le16_to_cpu
(
la
.
l2_psm
)
==
0x0001
||
__le16_to_cpu
(
la
.
l2_psm
)
==
0x0003
)
l2cap_pi
(
sk
)
->
sec_level
=
BT_SECURITY_SDP
;
}
write_unlock_bh
(
&
l2cap_sk_list
.
lock
);
done:
release_sock
(
sk
);
return
err
;
}
static
int
l2cap_do_connect
(
struct
sock
*
sk
)
{
bdaddr_t
*
src
=
&
bt_sk
(
sk
)
->
src
;
...
...
@@ -1068,65 +993,6 @@ int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int
return
err
;
}
int
l2cap_sock_listen
(
struct
socket
*
sock
,
int
backlog
)
{
struct
sock
*
sk
=
sock
->
sk
;
int
err
=
0
;
BT_DBG
(
"sk %p backlog %d"
,
sk
,
backlog
);
lock_sock
(
sk
);
if
((
sock
->
type
!=
SOCK_SEQPACKET
&&
sock
->
type
!=
SOCK_STREAM
)
||
sk
->
sk_state
!=
BT_BOUND
)
{
err
=
-
EBADFD
;
goto
done
;
}
switch
(
l2cap_pi
(
sk
)
->
mode
)
{
case
L2CAP_MODE_BASIC
:
break
;
case
L2CAP_MODE_ERTM
:
case
L2CAP_MODE_STREAMING
:
if
(
!
disable_ertm
)
break
;
/* fall through */
default:
err
=
-
ENOTSUPP
;
goto
done
;
}
if
(
!
l2cap_pi
(
sk
)
->
psm
)
{
bdaddr_t
*
src
=
&
bt_sk
(
sk
)
->
src
;
u16
psm
;
err
=
-
EINVAL
;
write_lock_bh
(
&
l2cap_sk_list
.
lock
);
for
(
psm
=
0x1001
;
psm
<
0x1100
;
psm
+=
2
)
if
(
!
__l2cap_get_sock_by_addr
(
cpu_to_le16
(
psm
),
src
))
{
l2cap_pi
(
sk
)
->
psm
=
cpu_to_le16
(
psm
);
l2cap_pi
(
sk
)
->
sport
=
cpu_to_le16
(
psm
);
err
=
0
;
break
;
}
write_unlock_bh
(
&
l2cap_sk_list
.
lock
);
if
(
err
<
0
)
goto
done
;
}
sk
->
sk_max_ack_backlog
=
backlog
;
sk
->
sk_ack_backlog
=
0
;
sk
->
sk_state
=
BT_LISTEN
;
done:
release_sock
(
sk
);
return
err
;
}
int
l2cap_sock_accept
(
struct
socket
*
sock
,
struct
socket
*
newsock
,
int
flags
)
{
DECLARE_WAITQUEUE
(
wait
,
current
);
...
...
net/bluetooth/l2cap_sock.c
浏览文件 @
af6bcd82
...
...
@@ -62,6 +62,141 @@ static void l2cap_sock_timeout(unsigned long arg)
sock_put
(
sk
);
}
static
struct
sock
*
__l2cap_get_sock_by_addr
(
__le16
psm
,
bdaddr_t
*
src
)
{
struct
sock
*
sk
;
struct
hlist_node
*
node
;
sk_for_each
(
sk
,
node
,
&
l2cap_sk_list
.
head
)
if
(
l2cap_pi
(
sk
)
->
sport
==
psm
&&
!
bacmp
(
&
bt_sk
(
sk
)
->
src
,
src
))
goto
found
;
sk
=
NULL
;
found:
return
sk
;
}
static
int
l2cap_sock_bind
(
struct
socket
*
sock
,
struct
sockaddr
*
addr
,
int
alen
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sockaddr_l2
la
;
int
len
,
err
=
0
;
BT_DBG
(
"sk %p"
,
sk
);
if
(
!
addr
||
addr
->
sa_family
!=
AF_BLUETOOTH
)
return
-
EINVAL
;
memset
(
&
la
,
0
,
sizeof
(
la
));
len
=
min_t
(
unsigned
int
,
sizeof
(
la
),
alen
);
memcpy
(
&
la
,
addr
,
len
);
if
(
la
.
l2_cid
)
return
-
EINVAL
;
lock_sock
(
sk
);
if
(
sk
->
sk_state
!=
BT_OPEN
)
{
err
=
-
EBADFD
;
goto
done
;
}
if
(
la
.
l2_psm
)
{
__u16
psm
=
__le16_to_cpu
(
la
.
l2_psm
);
/* PSM must be odd and lsb of upper byte must be 0 */
if
((
psm
&
0x0101
)
!=
0x0001
)
{
err
=
-
EINVAL
;
goto
done
;
}
/* Restrict usage of well-known PSMs */
if
(
psm
<
0x1001
&&
!
capable
(
CAP_NET_BIND_SERVICE
))
{
err
=
-
EACCES
;
goto
done
;
}
}
write_lock_bh
(
&
l2cap_sk_list
.
lock
);
if
(
la
.
l2_psm
&&
__l2cap_get_sock_by_addr
(
la
.
l2_psm
,
&
la
.
l2_bdaddr
))
{
err
=
-
EADDRINUSE
;
}
else
{
/* Save source address */
bacpy
(
&
bt_sk
(
sk
)
->
src
,
&
la
.
l2_bdaddr
);
l2cap_pi
(
sk
)
->
psm
=
la
.
l2_psm
;
l2cap_pi
(
sk
)
->
sport
=
la
.
l2_psm
;
sk
->
sk_state
=
BT_BOUND
;
if
(
__le16_to_cpu
(
la
.
l2_psm
)
==
0x0001
||
__le16_to_cpu
(
la
.
l2_psm
)
==
0x0003
)
l2cap_pi
(
sk
)
->
sec_level
=
BT_SECURITY_SDP
;
}
write_unlock_bh
(
&
l2cap_sk_list
.
lock
);
done:
release_sock
(
sk
);
return
err
;
}
static
int
l2cap_sock_listen
(
struct
socket
*
sock
,
int
backlog
)
{
struct
sock
*
sk
=
sock
->
sk
;
int
err
=
0
;
BT_DBG
(
"sk %p backlog %d"
,
sk
,
backlog
);
lock_sock
(
sk
);
if
((
sock
->
type
!=
SOCK_SEQPACKET
&&
sock
->
type
!=
SOCK_STREAM
)
||
sk
->
sk_state
!=
BT_BOUND
)
{
err
=
-
EBADFD
;
goto
done
;
}
switch
(
l2cap_pi
(
sk
)
->
mode
)
{
case
L2CAP_MODE_BASIC
:
break
;
case
L2CAP_MODE_ERTM
:
case
L2CAP_MODE_STREAMING
:
if
(
!
disable_ertm
)
break
;
/* fall through */
default:
err
=
-
ENOTSUPP
;
goto
done
;
}
if
(
!
l2cap_pi
(
sk
)
->
psm
)
{
bdaddr_t
*
src
=
&
bt_sk
(
sk
)
->
src
;
u16
psm
;
err
=
-
EINVAL
;
write_lock_bh
(
&
l2cap_sk_list
.
lock
);
for
(
psm
=
0x1001
;
psm
<
0x1100
;
psm
+=
2
)
if
(
!
__l2cap_get_sock_by_addr
(
cpu_to_le16
(
psm
),
src
))
{
l2cap_pi
(
sk
)
->
psm
=
cpu_to_le16
(
psm
);
l2cap_pi
(
sk
)
->
sport
=
cpu_to_le16
(
psm
);
err
=
0
;
break
;
}
write_unlock_bh
(
&
l2cap_sk_list
.
lock
);
if
(
err
<
0
)
goto
done
;
}
sk
->
sk_max_ack_backlog
=
backlog
;
sk
->
sk_ack_backlog
=
0
;
sk
->
sk_state
=
BT_LISTEN
;
done:
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录