Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
4e34c50b
Commit
4e34c50b
authored
Feb 04, 2011
by
Gustavo F. Padovan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bluetooth: move l2cap_sock_connect() to l2cap_sock.c
Signed-off-by:
Gustavo F. Padovan
<
padovan@profusion.mobi
>
parent
99f4808d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
87 deletions
+87
-87
include/net/bluetooth/l2cap.h
include/net/bluetooth/l2cap.h
+1
-1
net/bluetooth/l2cap_core.c
net/bluetooth/l2cap_core.c
+1
-86
net/bluetooth/l2cap_sock.c
net/bluetooth/l2cap_sock.c
+85
-0
No files found.
include/net/bluetooth/l2cap.h
View file @
4e34c50b
...
...
@@ -437,8 +437,8 @@ void l2cap_sock_kill(struct sock *sk);
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_do_connect
(
struct
sock
*
sk
);
int
l2cap_sock_connect
(
struct
socket
*
sock
,
struct
sockaddr
*
addr
,
int
alen
,
int
flags
);
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
);
...
...
net/bluetooth/l2cap_core.c
View file @
4e34c50b
...
...
@@ -848,7 +848,7 @@ static void l2cap_sock_close(struct sock *sk)
l2cap_sock_kill
(
sk
);
}
static
int
l2cap_do_connect
(
struct
sock
*
sk
)
int
l2cap_do_connect
(
struct
sock
*
sk
)
{
bdaddr_t
*
src
=
&
bt_sk
(
sk
)
->
src
;
bdaddr_t
*
dst
=
&
bt_sk
(
sk
)
->
dst
;
...
...
@@ -908,91 +908,6 @@ static int l2cap_do_connect(struct sock *sk)
return
err
;
}
int
l2cap_sock_connect
(
struct
socket
*
sock
,
struct
sockaddr
*
addr
,
int
alen
,
int
flags
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sockaddr_l2
la
;
int
len
,
err
=
0
;
BT_DBG
(
"sk %p"
,
sk
);
if
(
!
addr
||
alen
<
sizeof
(
addr
->
sa_family
)
||
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_type
==
SOCK_SEQPACKET
||
sk
->
sk_type
==
SOCK_STREAM
)
&&
!
la
.
l2_psm
)
{
err
=
-
EINVAL
;
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
;
}
switch
(
sk
->
sk_state
)
{
case
BT_CONNECT
:
case
BT_CONNECT2
:
case
BT_CONFIG
:
/* Already connecting */
goto
wait
;
case
BT_CONNECTED
:
/* Already connected */
err
=
-
EISCONN
;
goto
done
;
case
BT_OPEN
:
case
BT_BOUND
:
/* Can connect */
break
;
default:
err
=
-
EBADFD
;
goto
done
;
}
/* PSM must be odd and lsb of upper byte must be 0 */
if
((
__le16_to_cpu
(
la
.
l2_psm
)
&
0x0101
)
!=
0x0001
&&
sk
->
sk_type
!=
SOCK_RAW
)
{
err
=
-
EINVAL
;
goto
done
;
}
/* Set destination address and psm */
bacpy
(
&
bt_sk
(
sk
)
->
dst
,
&
la
.
l2_bdaddr
);
l2cap_pi
(
sk
)
->
psm
=
la
.
l2_psm
;
err
=
l2cap_do_connect
(
sk
);
if
(
err
)
goto
done
;
wait:
err
=
bt_sock_wait_state
(
sk
,
BT_CONNECTED
,
sock_sndtimeo
(
sk
,
flags
&
O_NONBLOCK
));
done:
release_sock
(
sk
);
return
err
;
}
static
int
__l2cap_wait_ack
(
struct
sock
*
sk
)
{
DECLARE_WAITQUEUE
(
wait
,
current
);
...
...
net/bluetooth/l2cap_sock.c
View file @
4e34c50b
...
...
@@ -139,6 +139,91 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
return
err
;
}
static
int
l2cap_sock_connect
(
struct
socket
*
sock
,
struct
sockaddr
*
addr
,
int
alen
,
int
flags
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sockaddr_l2
la
;
int
len
,
err
=
0
;
BT_DBG
(
"sk %p"
,
sk
);
if
(
!
addr
||
alen
<
sizeof
(
addr
->
sa_family
)
||
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_type
==
SOCK_SEQPACKET
||
sk
->
sk_type
==
SOCK_STREAM
)
&&
!
la
.
l2_psm
)
{
err
=
-
EINVAL
;
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
;
}
switch
(
sk
->
sk_state
)
{
case
BT_CONNECT
:
case
BT_CONNECT2
:
case
BT_CONFIG
:
/* Already connecting */
goto
wait
;
case
BT_CONNECTED
:
/* Already connected */
err
=
-
EISCONN
;
goto
done
;
case
BT_OPEN
:
case
BT_BOUND
:
/* Can connect */
break
;
default:
err
=
-
EBADFD
;
goto
done
;
}
/* PSM must be odd and lsb of upper byte must be 0 */
if
((
__le16_to_cpu
(
la
.
l2_psm
)
&
0x0101
)
!=
0x0001
&&
sk
->
sk_type
!=
SOCK_RAW
)
{
err
=
-
EINVAL
;
goto
done
;
}
/* Set destination address and psm */
bacpy
(
&
bt_sk
(
sk
)
->
dst
,
&
la
.
l2_bdaddr
);
l2cap_pi
(
sk
)
->
psm
=
la
.
l2_psm
;
err
=
l2cap_do_connect
(
sk
);
if
(
err
)
goto
done
;
wait:
err
=
bt_sock_wait_state
(
sk
,
BT_CONNECTED
,
sock_sndtimeo
(
sk
,
flags
&
O_NONBLOCK
));
done:
release_sock
(
sk
);
return
err
;
}
static
int
l2cap_sock_listen
(
struct
socket
*
sock
,
int
backlog
)
{
struct
sock
*
sk
=
sock
->
sk
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment