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
Kirill Smelkov
linux
Commits
99f4808d
Commit
99f4808d
authored
Feb 04, 2011
by
Gustavo F. Padovan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bluetooth: move l2cap_sock_getsockopt() to l2cap_sock.c
Signed-off-by:
Gustavo F. Padovan
<
padovan@profusion.mobi
>
parent
33575df7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
145 additions
and
146 deletions
+145
-146
include/net/bluetooth/l2cap.h
include/net/bluetooth/l2cap.h
+0
-1
net/bluetooth/l2cap_core.c
net/bluetooth/l2cap_core.c
+0
-145
net/bluetooth/l2cap_sock.c
net/bluetooth/l2cap_sock.c
+145
-0
No files found.
include/net/bluetooth/l2cap.h
View file @
99f4808d
...
@@ -442,7 +442,6 @@ int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int
...
@@ -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_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_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_shutdown
(
struct
socket
*
sock
,
int
how
);
int
l2cap_sock_getsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
__user
*
optlen
);
void
l2cap_load
(
void
);
void
l2cap_load
(
void
);
...
...
net/bluetooth/l2cap_core.c
View file @
99f4808d
...
@@ -1596,151 +1596,6 @@ int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m
...
@@ -1596,151 +1596,6 @@ int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m
return
bt_sock_recvmsg
(
iocb
,
sock
,
msg
,
len
,
flags
);
return
bt_sock_recvmsg
(
iocb
,
sock
,
msg
,
len
,
flags
);
}
}
static
int
l2cap_sock_getsockopt_old
(
struct
socket
*
sock
,
int
optname
,
char
__user
*
optval
,
int
__user
*
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
l2cap_options
opts
;
struct
l2cap_conninfo
cinfo
;
int
len
,
err
=
0
;
u32
opt
;
BT_DBG
(
"sk %p"
,
sk
);
if
(
get_user
(
len
,
optlen
))
return
-
EFAULT
;
lock_sock
(
sk
);
switch
(
optname
)
{
case
L2CAP_OPTIONS
:
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
,
len
,
sizeof
(
opts
));
if
(
copy_to_user
(
optval
,
(
char
*
)
&
opts
,
len
))
err
=
-
EFAULT
;
break
;
case
L2CAP_LM
:
switch
(
l2cap_pi
(
sk
)
->
sec_level
)
{
case
BT_SECURITY_LOW
:
opt
=
L2CAP_LM_AUTH
;
break
;
case
BT_SECURITY_MEDIUM
:
opt
=
L2CAP_LM_AUTH
|
L2CAP_LM_ENCRYPT
;
break
;
case
BT_SECURITY_HIGH
:
opt
=
L2CAP_LM_AUTH
|
L2CAP_LM_ENCRYPT
|
L2CAP_LM_SECURE
;
break
;
default:
opt
=
0
;
break
;
}
if
(
l2cap_pi
(
sk
)
->
role_switch
)
opt
|=
L2CAP_LM_MASTER
;
if
(
l2cap_pi
(
sk
)
->
force_reliable
)
opt
|=
L2CAP_LM_RELIABLE
;
if
(
put_user
(
opt
,
(
u32
__user
*
)
optval
))
err
=
-
EFAULT
;
break
;
case
L2CAP_CONNINFO
:
if
(
sk
->
sk_state
!=
BT_CONNECTED
&&
!
(
sk
->
sk_state
==
BT_CONNECT2
&&
bt_sk
(
sk
)
->
defer_setup
))
{
err
=
-
ENOTCONN
;
break
;
}
cinfo
.
hci_handle
=
l2cap_pi
(
sk
)
->
conn
->
hcon
->
handle
;
memcpy
(
cinfo
.
dev_class
,
l2cap_pi
(
sk
)
->
conn
->
hcon
->
dev_class
,
3
);
len
=
min_t
(
unsigned
int
,
len
,
sizeof
(
cinfo
));
if
(
copy_to_user
(
optval
,
(
char
*
)
&
cinfo
,
len
))
err
=
-
EFAULT
;
break
;
default:
err
=
-
ENOPROTOOPT
;
break
;
}
release_sock
(
sk
);
return
err
;
}
int
l2cap_sock_getsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
__user
*
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
bt_security
sec
;
int
len
,
err
=
0
;
BT_DBG
(
"sk %p"
,
sk
);
if
(
level
==
SOL_L2CAP
)
return
l2cap_sock_getsockopt_old
(
sock
,
optname
,
optval
,
optlen
);
if
(
level
!=
SOL_BLUETOOTH
)
return
-
ENOPROTOOPT
;
if
(
get_user
(
len
,
optlen
))
return
-
EFAULT
;
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
=
l2cap_pi
(
sk
)
->
sec_level
;
len
=
min_t
(
unsigned
int
,
len
,
sizeof
(
sec
));
if
(
copy_to_user
(
optval
,
(
char
*
)
&
sec
,
len
))
err
=
-
EFAULT
;
break
;
case
BT_DEFER_SETUP
:
if
(
sk
->
sk_state
!=
BT_BOUND
&&
sk
->
sk_state
!=
BT_LISTEN
)
{
err
=
-
EINVAL
;
break
;
}
if
(
put_user
(
bt_sk
(
sk
)
->
defer_setup
,
(
u32
__user
*
)
optval
))
err
=
-
EFAULT
;
break
;
case
BT_FLUSHABLE
:
if
(
put_user
(
l2cap_pi
(
sk
)
->
flushable
,
(
u32
__user
*
)
optval
))
err
=
-
EFAULT
;
break
;
default:
err
=
-
ENOPROTOOPT
;
break
;
}
release_sock
(
sk
);
return
err
;
}
int
l2cap_sock_shutdown
(
struct
socket
*
sock
,
int
how
)
int
l2cap_sock_shutdown
(
struct
socket
*
sock
,
int
how
)
{
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sock
*
sk
=
sock
->
sk
;
...
...
net/bluetooth/l2cap_sock.c
View file @
99f4808d
...
@@ -277,6 +277,151 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l
...
@@ -277,6 +277,151 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l
return
0
;
return
0
;
}
}
static
int
l2cap_sock_getsockopt_old
(
struct
socket
*
sock
,
int
optname
,
char
__user
*
optval
,
int
__user
*
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
l2cap_options
opts
;
struct
l2cap_conninfo
cinfo
;
int
len
,
err
=
0
;
u32
opt
;
BT_DBG
(
"sk %p"
,
sk
);
if
(
get_user
(
len
,
optlen
))
return
-
EFAULT
;
lock_sock
(
sk
);
switch
(
optname
)
{
case
L2CAP_OPTIONS
:
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
,
len
,
sizeof
(
opts
));
if
(
copy_to_user
(
optval
,
(
char
*
)
&
opts
,
len
))
err
=
-
EFAULT
;
break
;
case
L2CAP_LM
:
switch
(
l2cap_pi
(
sk
)
->
sec_level
)
{
case
BT_SECURITY_LOW
:
opt
=
L2CAP_LM_AUTH
;
break
;
case
BT_SECURITY_MEDIUM
:
opt
=
L2CAP_LM_AUTH
|
L2CAP_LM_ENCRYPT
;
break
;
case
BT_SECURITY_HIGH
:
opt
=
L2CAP_LM_AUTH
|
L2CAP_LM_ENCRYPT
|
L2CAP_LM_SECURE
;
break
;
default:
opt
=
0
;
break
;
}
if
(
l2cap_pi
(
sk
)
->
role_switch
)
opt
|=
L2CAP_LM_MASTER
;
if
(
l2cap_pi
(
sk
)
->
force_reliable
)
opt
|=
L2CAP_LM_RELIABLE
;
if
(
put_user
(
opt
,
(
u32
__user
*
)
optval
))
err
=
-
EFAULT
;
break
;
case
L2CAP_CONNINFO
:
if
(
sk
->
sk_state
!=
BT_CONNECTED
&&
!
(
sk
->
sk_state
==
BT_CONNECT2
&&
bt_sk
(
sk
)
->
defer_setup
))
{
err
=
-
ENOTCONN
;
break
;
}
cinfo
.
hci_handle
=
l2cap_pi
(
sk
)
->
conn
->
hcon
->
handle
;
memcpy
(
cinfo
.
dev_class
,
l2cap_pi
(
sk
)
->
conn
->
hcon
->
dev_class
,
3
);
len
=
min_t
(
unsigned
int
,
len
,
sizeof
(
cinfo
));
if
(
copy_to_user
(
optval
,
(
char
*
)
&
cinfo
,
len
))
err
=
-
EFAULT
;
break
;
default:
err
=
-
ENOPROTOOPT
;
break
;
}
release_sock
(
sk
);
return
err
;
}
static
int
l2cap_sock_getsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
__user
*
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
struct
bt_security
sec
;
int
len
,
err
=
0
;
BT_DBG
(
"sk %p"
,
sk
);
if
(
level
==
SOL_L2CAP
)
return
l2cap_sock_getsockopt_old
(
sock
,
optname
,
optval
,
optlen
);
if
(
level
!=
SOL_BLUETOOTH
)
return
-
ENOPROTOOPT
;
if
(
get_user
(
len
,
optlen
))
return
-
EFAULT
;
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
=
l2cap_pi
(
sk
)
->
sec_level
;
len
=
min_t
(
unsigned
int
,
len
,
sizeof
(
sec
));
if
(
copy_to_user
(
optval
,
(
char
*
)
&
sec
,
len
))
err
=
-
EFAULT
;
break
;
case
BT_DEFER_SETUP
:
if
(
sk
->
sk_state
!=
BT_BOUND
&&
sk
->
sk_state
!=
BT_LISTEN
)
{
err
=
-
EINVAL
;
break
;
}
if
(
put_user
(
bt_sk
(
sk
)
->
defer_setup
,
(
u32
__user
*
)
optval
))
err
=
-
EFAULT
;
break
;
case
BT_FLUSHABLE
:
if
(
put_user
(
l2cap_pi
(
sk
)
->
flushable
,
(
u32
__user
*
)
optval
))
err
=
-
EFAULT
;
break
;
default:
err
=
-
ENOPROTOOPT
;
break
;
}
release_sock
(
sk
);
return
err
;
}
static
int
l2cap_sock_setsockopt_old
(
struct
socket
*
sock
,
int
optname
,
char
__user
*
optval
,
unsigned
int
optlen
)
static
int
l2cap_sock_setsockopt_old
(
struct
socket
*
sock
,
int
optname
,
char
__user
*
optval
,
unsigned
int
optlen
)
{
{
struct
sock
*
sk
=
sock
->
sk
;
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