Commit Graph

482 Commits

Author SHA1 Message Date
Luiz Augusto von Dentz
125af7e120 emulator/btdev: Fix invalid memory access 2014-09-18 17:13:14 +03:00
Johan Hedberg
0decc9df11 emulator/smp: Fix pairing response key dist. to what's actually supported 2014-09-18 10:59:57 +03:00
Johan Hedberg
5b1a876e42 emulator/smp: Set correct pairing response values 2014-09-18 10:16:01 +03:00
Johan Hedberg
6b7560c085 emulator/bthost: Add getter functions needed by SMP 2014-09-18 10:10:56 +03:00
Luiz Augusto von Dentz
3d51328b6c emulator/bthost: Add iovec support
This convert bthost_set_send_handler to take struct iovec for doing
scatter io.
2014-09-18 08:04:23 +03:00
Luiz Augusto von Dentz
a7b600b45b emulator/btdev: Add iovec support
This convert btdev_set_send_handler to take struct iovec for doing
scatter io.
2014-09-18 08:04:21 +03:00
Johan Hedberg
077abfe1e1 emulator: Add support for LE connection parameter update procedure 2014-09-17 13:38:26 +03:00
Johan Hedberg
a964070fdd emulator: Failed encryption shouldn't affect success of LTK reply 2014-09-16 22:07:51 +03:00
Johan Hedberg
de98dccca4 emulator: Indicate encryption failure if LTKs don't match 2014-09-16 16:35:46 +03:00
Johan Hedberg
a6a5100930 emulator: Fix up SMP Pairing Confirm/Random handling 2014-09-16 15:13:34 +03:00
Johan Hedberg
6c50a037c4 emulator: Add support for specifying SMP authentication requirement 2014-09-16 14:30:44 +03:00
Johan Hedberg
d086d9565a emulator: Use explicit IO capability for bthost 2014-09-13 18:04:27 +03:00
Johan Hedberg
5a40cdff80 emulator: Fix clearing advertising state when connected 2014-09-13 18:04:27 +03:00
Luiz Augusto von Dentz
a528bdce68 emulator/bthost: Fix not matching cid data properly
When using bthost_add_l2cap_server the caller expect that both scid and
dcid are the same since the callback only take one value.
2014-09-05 15:43:47 +03:00
Johan Hedberg
504f52524f emulator/btdev: Fix returning correct remote extended features 2014-09-04 14:03:12 +03:00
Jakub Tyszkowski
f3686a7fb0 emulator/btdev: Fix not disabling le advertising on connection
Le Advertising should be disabled after the le connection is
established (Core Spec. 4.1 - Part E, Sec. 7.8.9). Not doing so
results in errors while switching advertisement multiple times during
different connection states.
2014-09-01 15:18:11 +03:00
Marcin Kraglak
66e5db6021 emulator/bthost: Add hci disconnect 2014-08-25 10:57:42 +02:00
Andrei Emeltchenko
259d1febc9 emulator: Fix resource leak closing fd 2014-08-11 16:25:50 +03:00
Johan Hedberg
af31fe0d35 emulator: Fix matching up real advertising address 2014-08-05 13:44:54 +03:00
Johan Hedberg
d886b0817d emulator: Add support for Read Clock Offset 2014-08-01 12:24:19 +03:00
Marcel Holtmann
9cc6f7d88f emulator: Add support for Get MWS Transport Layer Configuration 2014-07-23 19:25:42 +02:00
Marcel Holtmann
ed5ca845b1 emulator: Add support for Read Local Supported Codecs command 2014-07-23 19:04:41 +02:00
Jakub Tyszkowski
57e63ba067 emulator: Add flags param to advertise enabling function
This allows to pass additional parameter describing wheter to set
flags parameter in advertising data.

This is needed to make device discoverable.
2014-07-18 13:21:26 +02:00
Marcel Holtmann
5182dc7c3d emulator: Reopen PTY master when slave closes it 2014-07-12 19:49:13 +02:00
Marcel Holtmann
096799fd52 emulator: Add support for providing a pseudo terminal 2014-07-12 15:53:16 +02:00
Johan Hedberg
45749f6aad emulator: Fix random address type in LE conn complete events 2014-06-02 13:09:00 +03:00
Johan Hedberg
895e0a16f1 emulator: Fix matching up connections to random addresses 2014-06-02 13:08:53 +03:00
Andrzej Kaczmarek
f5b1a7289a emulator/btdev: Add support for Read TX Power command 2014-05-20 21:55:14 +03:00
Andrzej Kaczmarek
5d1d3dc192 emulator/btdev: Add support for Read RSSI command 2014-05-20 21:55:14 +03:00
Andrzej Kaczmarek
1a4cb1a207 emulator/bthost: Add support to set auth_req for bthost
This patch makes possible to set Authentication_Requirements to be used
in io_capa_request_reply when replying for io_capa_request_evt.
2014-05-19 14:14:14 +03:00
Johan Hedberg
0e6b13b702 emulator: Minor coding style fix 2014-03-20 14:15:31 +02:00
Lukasz Rymanowski
fa34a2dc71 emulator: Add handling inquiry_lenght from inquiry command
With this patch, btdev is taking into accoung inquiry_lenght from hci
inquiry command.
Inquiry session will last that long unless number of devices parameter
has been provided different then 0
2014-03-20 14:15:14 +02:00
Lukasz Rymanowski
400cb2885c emulator: Add handling inquiry number of responses 2014-03-20 14:12:52 +02:00
Lukasz Rymanowski
ce83fbee7c emulator: Add inquiry cancel
With this patch, scheduled inquiry session in btdev can be canceled
2014-03-20 14:12:18 +02:00
Lukasz Rymanowski
f1f2ad6046 emulator: Use timeout for sending inquiry results
With this patch btdev uses timeout to schedule inquiry results
It also allows btdev to receive hci commands during inquiry.
Previously btdev was blocked since all the inquiry result were sent in
single loop
2014-03-20 14:11:25 +02:00
Johan Hedberg
18f0cdaac1 emulator/btdev: Add support for negative LTK reply 2014-03-14 13:17:09 +02:00
Johan Hedberg
01095e7774 emulator/bthost: Set advertising parameters before enabling advertising 2014-03-14 12:51:12 +02:00
Johan Hedberg
e392404950 emulator/btdev: Fix checking for non-connectable advertising 2014-03-14 12:42:14 +02:00
Johan Hedberg
2f410a63c2 emulator/btdev: Do correct matching for direct advertising when connecting 2014-03-14 09:44:37 +02:00
Johan Hedberg
c23be68fa2 emulator/btdev: Add proper matching for direct advertising 2014-03-14 09:39:13 +02:00
Johan Hedberg
d45529c987 emulator/btdev: Add helper for selecting advertising address 2014-03-14 09:35:06 +02:00
Johan Hedberg
584e9dc6e6 emulator/btdev: Track direct advertising address 2014-03-14 09:34:29 +02:00
Johan Hedberg
141c10827b emulator/btdev: Track LE scanning own address type 2014-03-14 09:32:58 +02:00
Johan Hedberg
dcf9c2a9aa emulator/btdev: Fix using correct address in advertising reports 2014-03-11 14:27:42 +02:00
Johan Hedberg
a37c747a59 emulator/btdev: Add support for sending LE Scan Response events 2014-03-11 14:25:38 +02:00
Johan Hedberg
b1b55dda9c emulator/btdev: Fix LE adv report types to match adv parameters 2014-03-11 14:16:31 +02:00
Johan Hedberg
1b4a46fec3 emulator/btdev: Store LE adv params for later use 2014-03-11 14:10:49 +02:00
Johan Hedberg
6375533b7f emulator/btdev: Add storing of LE Scan Response Data 2014-03-11 13:42:52 +02:00
Johan Hedberg
9ecff0151c emulator/btdev: Store LE Scan type for later use 2014-03-11 13:42:52 +02:00
Grzegorz Kolodziejczyk
d5ac1d2cda emulator/btdev: Add support for LE set scan response command
This adds support for btdev LE set scan response command.
2014-03-11 13:42:52 +02:00
Anderson Lizardo
6d67d8da9f emulator/btdev: Add dummy support for clearing the LE white list
Add just enough support for being able to bring up LE capable virtual
controllers using "btvirt".

Fixes this error on "btvirt -l2":

Unsupported command 0x2010

And on "hciconfig hci0 up":

Can't init device hci0: Invalid request code (56)
2014-03-07 11:25:03 +02:00
Marcel Holtmann
8e5ad50cd3 emulator: List LE commands, event and features from Bluetooth 4.1 2014-02-28 20:17:45 -08:00
Marcel Holtmann
53dde8be6c emulator: Add dummy support for clearing the LE white list 2014-02-28 15:09:55 -08:00
Marcel Holtmann
d1c6a543c7 monitor: Use 64-bit unsigned integer for random number 2014-02-27 14:37:41 -08:00
Johan Hedberg
a83d698f5a emulator: Add HCI_LE_Set_Random_Address support 2014-02-26 19:10:52 +02:00
Johan Hedberg
502407f176 emulator: Use shared crypto code instead of custom functions 2014-02-26 17:59:37 +02:00
Marcin Kraglak
f79a9e3b44 emulator/bthost: Fix command queue
Now new commands will be pushed to tail. Queue will be consumed
from head, firstly added commands will be sent. It repairs this
warning from android-tester:
==20561== 1,904 bytes in 7 blocks are definitely
lost in loss record 30 of 31
==20561==    at 0x4006AB1: malloc (in /usr/lib/valgrind/
vgpreload_memcheck-x86-linux.so)
==20561==    by 0x8050293: send_command (bthost.c:389)
==20561==    by 0x80543E1: start_stack (hciemu.c:299)
==20561==    by 0x41043D00: ??? (in /usr/lib/libglib-2.0.so.0.3600.4)
==20561==    by 0x410470E5: g_main_context_dispatch (in
/usr/lib/libglib-2.0.so.0.3600.4)
==20561==    by 0x41047497: ??? (in
/usr/lib/libglib-2.0.so.0.3600.4)
==20561==    by 0x41047912: g_main_loop_run (in
/usr/lib/libglib-2.0.so.0.3600.4)
==20561==    by 0x8055870: tester_run (tester.c:798)
==20561==    by 0x804B980: main (android-tester.c:3984)
2014-02-19 17:22:05 +02:00
Johan Hedberg
dd78814e7f tools/bthost: Fix RFCOMM channel variable type 2014-02-19 15:11:08 +02:00
Johan Hedberg
4ead1cb1ec emulator/bthost: Rename rfcomm_channel to rfcomm_chan for shorter symbol names 2014-02-19 15:09:34 +02:00
Marcin Kraglak
e157b7f28e emulator/bthost: Add function to send RFCOMM UIH frames from bthost
This will make RFCOMM UIH frame and fill with data passed by user.
It also adds bthost internal tracking of RFCOMM connections to store
cid and channel - user have to pass only conenction handle and channel.
2014-02-19 15:03:27 +02:00
Marcin Kraglak
f5e82813af emulator/bthost: Add api to handle RFCOMM data on bthost
With this change user can handle data received on RFCOMM connection.
2014-02-19 15:00:20 +02:00
Marcin Kraglak
68e94df753 emulator/bthost: Check length of received RFCOMM UIH frames
Add correct calculation of frame length. If frame is too short, ignore it.
2014-02-17 15:49:22 +02:00
Marcin Kraglak
8e9e005aa0 emulator/bthost: Check length of received RFCOMM UA frames
Check length of RFCOMM UA frames and ignore if frame is too short.
2014-02-17 14:31:20 +02:00
Marcin Kraglak
be3841b10d emulator/bthost: Check length of received RFCOMM DM frames
Ignore too short received RFCOMM DM frames.
2014-02-17 14:31:18 +02:00
Marcin Kraglak
fba18071c6 emulator/bthost: Check length of received RFCOMM DISC frame
Don't access rfcomm_hdr struct and ignore if frame is too short.
2014-02-17 14:31:16 +02:00
Marcin Kraglak
b2b4716b3c emulator/bthost: Check length of received RFCOMM SABM frame
This will check length of received SABM frame. Ignore frame if
it is too short.
2014-02-17 14:31:14 +02:00
Marcel Holtmann
69c85b61aa emulator: Add support LE_Encrypt and LE_Rand support 2014-02-17 02:06:05 -08:00
Marcel Holtmann
6898ecdf0e emulator: Update copyright and license details 2014-02-12 09:24:13 -08:00
Johan Hedberg
88373d735a emulator: Fix correct link key type generation 2014-02-03 07:49:42 +02:00
Johan Hedberg
df39364122 emulator: Add HCI_Write_SSP_Debug_Mode support 2014-02-03 07:49:25 +02:00
Anderson Lizardo
64bc96534b emulator: Fix crash if socket(AF_ALG) is not supported by the kernel
In this situation, smp_stop() was being called with NULL pointer.

Crash detected by valgrind:

==7925== Invalid read of size 4
==7925==    at 0x8052F18: smp_stop (smp.c:480)
==7925==    by 0x8052542: bthost_stop (bthost.c:2073)
==7925==    by 0x805521D: hciemu_unref (hciemu.c:372)
==7925==    by 0x8058C65: test_post_teardown (android-tester.c:464)
==7925==    by 0x8055DE7: tester_teardown_complete (tester.c:533)
==7925==    by 0x8055501: teardown_callback (tester.c:312)
==7925==    by 0x408348F: g_idle_dispatch (gmain.c:5250)
==7925==    by 0x4086A75: g_main_context_dispatch (gmain.c:3065)
==7925==    by 0x4086E14: g_main_context_iterate.isra.23 (gmain.c:3712)
==7925==    by 0x40872FA: g_main_loop_run (gmain.c:3906)
==7925==    by 0x41744D2: (below main) (libc-start.c:226)
==7925==  Address 0x8 is not stack'd, malloc'd or (recently) free'd
2014-01-27 09:59:28 -08:00
Marcel Holtmann
ccbbb8dd3c emulator: Add simple HFP emulator for testing 2014-01-25 12:17:09 -08:00
Anderson Lizardo
b23ed9bf8d emulator: Fix unaligned memory access compilation errors
The u128_xor() function does proper aligned access and accepts void *
arguments, therefore the casts are unnecessary and trigger clang errors.
2014-01-21 11:07:37 +02:00
Johan Hedberg
35b50f0f34 emulator/bthost: Add dummy entries for LTK reply completion 2014-01-20 16:28:03 +02:00
Johan Hedberg
f3db25a05b emulator/bthost: Add SMP callback to fetch LTK 2014-01-20 16:28:03 +02:00
Johan Hedberg
741d28de64 emulator/bthost: Add warning for unsupported LE Meta events 2014-01-20 16:27:57 +02:00
Johan Hedberg
fb922ee610 emulator/bthost: Add SMP support 2014-01-20 16:26:33 +02:00
Johan Hedberg
2688bf5c6e emulator/bthost: Add dummy handler for User Confirm Request Reply completion 2014-01-20 13:14:28 +02:00
Johan Hedberg
23b2191c07 emulator/bthost: Remove unnecessary printf 2014-01-17 15:29:31 +02:00
Johan Hedberg
dee79b4635 emulator/bthost: More RFCOMM code cleanups 2014-01-16 12:23:16 +02:00
Johan Hedberg
d11ac83a18 emulator/bthost: Further cleanups to the RFCOMM code 2014-01-16 12:23:15 +02:00
Johan Hedberg
bce8cc0159 emulator/bthost: Clean up RFCOMM related code 2014-01-16 12:23:15 +02:00
Johan Hedberg
a48b49121f tools/bthost: Remove useless channel parameter from RFCOMM callback 2014-01-16 12:23:15 +02:00
Marcin Kraglak
c64b9baa99 emulator/bthost: Call rfcomm_connect_cb when connected
This will call connect callback when connected or failed to connect.
2014-01-16 12:23:15 +02:00
Marcin Kraglak
37a1b0fa3d emulator/bthost: Add implementation to PN RSP
This will send sabm command if PN_RSP will be received.
2014-01-16 12:23:15 +02:00
Marcin Kraglak
287c075913 emulator/bthost: Ad implementation of rfcomm_ua_recv
This will handle ua responses in bthost.
2014-01-16 12:23:15 +02:00
Marcin Kraglak
90fd2a2f98 emulator/bthost: Implement bthost_connect_rfcomm
This method will start L2CAP connection on RFCOMM PSM and continue
connecting to rfcomm server. User can specify callback to be called
after connection.
2014-01-16 12:23:15 +02:00
Marcin Kraglak
3fbe314714 emulator/bthost: Implement recv_disc rfcomm frame in bthost 2014-01-16 12:23:15 +02:00
Marcin Kraglak
662c19903f emulator/bthost: Service msc frames 2014-01-16 12:23:15 +02:00
Marcin Kraglak
f167df0e3a emulator/bthost: Add recv_pn implementation 2014-01-16 12:23:15 +02:00
Marcin Kraglak
cbc1720d4f emulator/bthost: Add rfcomm_mcc_recv stub
It will handle mcc frames in bthost.
2014-01-16 12:23:15 +02:00
Marcin Kraglak
983ecc30e4 emulator/bthost: Add recv_sabm imnplementation
This will handle sabm frames and send ua or dm frame.
2014-01-16 12:23:15 +02:00
Marcin Kraglak
75c7ab2d99 emulator/bthost: Add method to create rfcomm server
It allows user to create rfcomm server on bthost.
2014-01-16 12:23:15 +02:00
Marcin Kraglak
0c27ca7f45 emulator/bthost: Add initial rfcomm handling
This is initial rfcomm handling in bthost.
2014-01-16 12:23:15 +02:00
Johan Hedberg
3c08f44715 emulator/bthost: Fix requesting encryption if authentication failed 2014-01-15 14:38:04 +02:00
Johan Hedberg
f072c7573b emulator/bthost: Add API to request authentication 2014-01-15 14:34:01 +02:00
Johan Hedberg
7dfc7e9614 emulator/bthost: Add basic support for link key requests 2014-01-15 14:33:38 +02:00
Johan Hedberg
e52dfcadf5 emulator: Fix SSP IO capability request handling 2014-01-13 16:56:49 +02:00
Johan Hedberg
c85d3d5747 emulator: Add reminding comment to fix link key type 2014-01-13 16:32:41 +02:00
Johan Hedberg
92d3e1b6f2 emulator: Fix emitting bogus encrypt change if we're not connected 2014-01-13 16:32:40 +02:00
Johan Hedberg
579876ea9e emulator: Fix returning correct remote host features 2014-01-13 16:32:40 +02:00
Johan Hedberg
a26be8f057 emulator: Fix completion of SSP user confirm commands 2014-01-13 16:32:40 +02:00
Johan Hedberg
162882534b emulator: Fix SSP rejection status propagation 2014-01-13 14:29:36 +02:00
Johan Hedberg
27d79b3a73 emulator/bthost: Add API to reject SSP User Confirmation 2014-01-13 14:29:06 +02:00
Johan Hedberg
0903fa12a5 emulator/bthost: Add support for specifying custom IO capability 2014-01-13 13:23:45 +02:00
Marcin Kraglak
62041e0a4d emulator/bthost: Fix sending L2CAP config req
Send L2CAP config request with correct dcid field. It worked
well only if scid and dcid of L2CAP connection were the same.
2014-01-13 13:05:44 +02:00
Johan Hedberg
f881e165ec emulator/bthost: Request encryption when authentication completes 2014-01-13 12:58:16 +02:00
Johan Hedberg
4ea78ff34b emulator: Add Set Connection Encryption command support 2014-01-13 12:58:15 +02:00
Johan Hedberg
f89e2eb7fb emulator: Encryption should be enabled only when explicitly requested 2014-01-13 12:58:15 +02:00
Johan Hedberg
78d239fd40 emulator: Add missing Transparent SCO feature bit 2014-01-12 09:19:25 +02:00
Marcel Holtmann
e90a074333 emulator: Make use of generic endian conversion macros 2014-01-10 13:05:23 -08:00
Johan Hedberg
8a5967251a emulator: Add basic support for SSP completion 2014-01-10 16:05:08 +02:00
Johan Hedberg
cee10685ae emulator/bthost: Add basic handling of user confirm request and SSP complete events 2014-01-10 16:05:08 +02:00
Johan Hedberg
0143a51c32 emulator: Add dummy cmd complete handler for IO Capability Request Reply 2014-01-10 16:05:07 +02:00
Johan Hedberg
9980744cd4 emulator/bthost: Add basic IO Capability Request & Response handling 2014-01-10 16:05:07 +02:00
Johan Hedberg
2781eb13f5 emulator: Add basic HCI_IO_Capability_Request_Reply handling 2014-01-10 16:05:07 +02:00
Johan Hedberg
bc3b7427cf tools/bthost: Add dummy handler for HCI_Write_SSP_Mode completion 2014-01-10 16:05:06 +02:00
Johan Hedberg
262ee6bd02 emulator/bthost: Track remote address in btconn 2014-01-10 16:05:06 +02:00
Johan Hedberg
524808ae75 emulator: Add initial IO Capability Request sending when SSP is enabled 2014-01-10 16:05:05 +02:00
Johan Hedberg
12d51b2ed1 emulator/bthost: Add support for enabling SSP mode 2014-01-10 16:05:05 +02:00
Johan Hedberg
0f6fb5c0de emulator: Add basic security mode 3 support 2014-01-09 14:51:51 +02:00
Johan Hedberg
1c3b4eabd0 emulator: Add missing PIN Code Request Reply bit to supported commands 2014-01-08 17:47:08 +02:00
Johan Hedberg
f9b9a06c93 emulator: Fix emitting incorrect auth complete on acceptor side 2014-01-08 16:37:35 +02:00
Johan Hedberg
4cd914bd4f emulator/bthost: Add dummy handler for Authentication Complete HCI event 2014-01-08 16:37:34 +02:00
Johan Hedberg
6f054b115f emulator/bthost: Add dummy handler for Link Key Notification HCI event 2014-01-08 16:37:34 +02:00
Johan Hedberg
f8052a6616 emulator: Add initial support for Link Key Notify event 2014-01-08 16:37:34 +02:00
Johan Hedberg
1ba4a4fff3 emulator/bthost: Add basic PIN Code Request handling 2014-01-08 16:37:34 +02:00
Johan Hedberg
1dd5b101c5 emulator: Add basic support for PIN Code Request Reply command 2014-01-08 16:37:34 +02:00
Johan Hedberg
4f53c2c3cc emulator: Add basic support for Link Key Request Reply command 2014-01-08 16:37:33 +02:00
Johan Hedberg
ed2254b20c emulator: Add initial support for PIN Code Request Negative Reply 2014-01-08 16:37:33 +02:00
Johan Hedberg
52682e25b7 emulator: Add initial handling for link key req neg reply 2014-01-08 16:37:32 +02:00
Johan Hedberg
e6a16562a4 emulator: Add basic auth request completion support 2014-01-08 16:37:32 +02:00
Andrei Emeltchenko
1ae9c6a645 btdev: Return Command Status for Authentication Requested
Add support for "Authentication Requested" command
2014-01-08 16:37:32 +02:00
Johan Hedberg
678b6733ef emulator/bthost: Add support for encryption change HCI event 2014-01-02 12:32:16 +02:00
Marcel Holtmann
7f92310ccc emulator: Add simple standalone single mode LE device 2013-12-28 21:49:49 -08:00
Marcel Holtmann
0007671cf8 emulator: Add support for secure connections host support commands 2013-12-28 19:13:55 -08:00
Marcin Kraglak
e3d07f58d1 emulator/bthost: Remove not used bthost_set_server_psm
This function is not needed and has been replaced with bthost_add_l2cap_server.
2013-12-20 13:02:34 +02:00
Johan Hedberg
9f22db6df8 emulator/bthost: Remove double lookup with bthost_find_l2cap_cb_by_psm 2013-12-20 09:37:00 +02:00
Johan Hedberg
2fe0179189 emulator/bthost: Make bthost_add_l2cap_conn return the added struct for convenience 2013-12-20 09:35:33 +02:00
Marcin Kraglak
75c50937fe emulator: Add new method for adding l2cap server
This method allow user to add l2cap server and register
connect callback. If no callback is specified, it will behave
like bthost_set_server_psm() method.
2013-12-20 09:32:16 +02:00
Marcin Kraglak
303acb8364 emulator: Add L2CAP PSM handling to bthost
Store the PSM of L2CAP connections. We retrieve the PSM from the
connection request frame.
2013-12-19 13:58:09 +02:00
Szymon Janc
1f9177812c emulator/bthost: Fix use after free in bthost_destroy
cmd was dereferenced after free. Use temp pointer for freeing.
2013-12-16 10:06:34 +02:00
Johan Hedberg
37585d8ce1 emulator/bthost: Add LE L2CAP Connect support 2013-12-01 19:01:59 +02:00
Johan Hedberg
e197563f7c emulator/bthost: Add Disconnect request support for LE 2013-12-01 19:01:59 +02:00
Johan Hedberg
a2685ac211 emulator/btdev: Add initial support for HCI_LE_Long_Term_Key_Request_Reply 2013-11-29 14:41:14 +02:00
Johan Hedberg
f61edaad86 emulator/bthost: Add API for requesting LE encryption 2013-11-29 14:11:07 +02:00
Johan Hedberg
c56b263fbf emulator/btdev: Add basic support for HCI_LE_Start_Encryption 2013-11-29 14:11:06 +02:00
Johan Hedberg
c8217dc462 emulator/btdev: Fix existing connection check in disconnection logic 2013-11-29 11:17:39 +02:00
Johan Hedberg
3204c443ad emulator/btdev: Simplify connection request logic
We should return page timeout both when the remote exists but just
doesn't have page scan enabled as well as when the remote doesn't exist.
2013-11-29 11:13:09 +02:00
Johan Hedberg
d5306edce0 emulator/bthost: Add support for CID hooks
This patch adds support for registering CID based hooks to a bthost.
These are intended for test tools to override the default data handling
for specific CIDs.
2013-11-05 11:38:12 +02:00
Marcel Holtmann
bdaa349ba5 emulator: Add support for reading IAC information 2013-10-14 14:43:58 -07:00
Szymon Janc
0b24507b8a emulator: Fix AMP emulation build error
This fix build with GCC 4.6.3.

  CC     emulator/amp.o
emulator/amp.c: In function ‘send_packet’:
emulator/amp.c:172:7: error: ignoring return value of ‘write’,
    declared with attribute warn_unused_result [-Werror=unused-result]
cc1: all warnings being treated as errors
make[1]: *** [emulator/amp.o] Error
2013-10-11 14:59:32 +02:00
Marcel Holtmann
e6e6e84340 emulator: Add support for AMP controller emulation 2013-10-09 11:03:42 -07:00
Marcel Holtmann
f8b11ca9d9 monitor: Fix broken assoc_fragment structure value 2013-10-07 12:47:07 -07:00
Marcel Holtmann
065783d0a2 emulator: Add support for read local amp assoc command 2013-10-05 10:31:14 -07:00
Marcel Holtmann
d46acd58a4 emulator: Add some extra long option strings 2013-10-05 09:52:10 -07:00
Marcel Holtmann
773361ac7c emulator: Make unix server sockets optional 2013-10-05 08:27:50 -07:00
Marcel Holtmann
d38e0b4514 emulator: Exit with failure when Virtual HCI setup fails 2013-10-05 08:19:58 -07:00
Marcel Holtmann
3af320e60d emulator: Add command line option for AMP controllers 2013-10-05 08:19:04 -07:00
Marcel Holtmann
57a43ed48e emulator: Add special Virtual HCI setup command 2013-10-05 08:15:41 -07:00
Johan Hedberg
5d8b3ba494 emulator/bthost: Add support for creating LE connections 2013-09-25 13:51:11 +03:00
Johan Hedberg
a41a27b10a emulator/bthost: Fix using correct address type for LE connections 2013-09-20 17:39:03 +03:00
Johan Hedberg
9da7996910 emulator/bthost: Fix ACL handle packing 2013-09-20 06:19:22 +03:00
Johan Hedberg
064803eb9b emulator/bthost: Track address type for connections 2013-09-20 06:19:22 +03:00
Johan Hedberg
2ebd446197 emulator/bthost: Use right CID for LE signaling 2013-09-20 06:19:22 +03:00
Johan Hedberg
9844a8c3c7 emulator/bthost: Pass full ACL connection context around 2013-09-20 06:19:22 +03:00
Johan Hedberg
07306b872e emulator: Add initial LE L2CAP signaling support to bthost 2013-09-20 00:20:19 +03:00
Johan Hedberg
670d0ed2fd emulator: Add LE Connection Complete handling to bthost 2013-09-19 21:42:36 +03:00
Johan Hedberg
9e065d9354 emulator: Refactor bthost ACL connection tracking 2013-09-19 21:42:36 +03:00
Johan Hedberg
c2f09ece20 emulator: Add skeleton for LE meta event handler in bthost 2013-09-19 21:39:10 +03:00
Johan Hedberg
274df58a0d emulator: Add basic advertise enable support for bthost 2013-09-19 20:41:50 +03:00
Johan Hedberg
724a904228 emulator: Add basic support for LE connections 2013-09-19 20:39:02 +03:00
Johan Hedberg
26218dbf24 emulator: Remove redundant empty line 2013-09-19 10:06:57 -05:00
Johan Hedberg
84a0738622 emulator: Add missing HCI commands to the supported commands response 2013-09-11 10:54:41 +03:00
Johan Hedberg
d87776a264 emulator: Disallow SCO HCI commands on LE-only controllers 2013-09-11 10:54:22 +03:00
Johan Hedberg
4b95a69b61 emulator: Disallow HCI_Write_Current_IAP_LAP for LE-only controllers 2013-09-11 10:53:56 +03:00
Marcel Holtmann
aa6c727822 emulator: Add support for reading local out-of-band data 2013-09-11 00:04:35 -07:00
Marcel Holtmann
9a9680909d emulator: Add options to usage description 2013-09-10 21:12:05 -07:00
Marcel Holtmann
44f2f61e9f emulator: Add support for LE test commands 2013-09-07 21:36:38 -07:00
Marcel Holtmann
840fbec181 emulator: Add emulation a few more HCI commands 2013-09-07 21:28:34 -07:00
Marcel Holtmann
d68010fb9d emulator: Add support for host buffer size and LE rand commands 2013-09-07 16:35:22 -07:00
Marcel Holtmann
43c1b24f46 emulator: Filter for valid packet types from /dev/vhci 2013-09-02 10:31:22 -07:00
Marcel Holtmann
da05e084ae emulator: Fix up AFH channel assessment structures 2013-08-27 19:21:28 -07:00
Frédéric Dalleau
7d0783b711 emulator: Add btdev_get_features API (needed for SCO tests) 2013-08-01 12:54:32 +03:00
Frédéric Dalleau
287304526a emulator: Add SCO connection creation support 2013-08-01 12:54:32 +03:00
Bruna Moreira
c582e850a8 emulator: Add new function for running all hooks
It was defined four hook types and they are run before/after the first
part of default command processing and send event. Note that hook return
will define if the emulator will process/send next events (calling the
default_cmd_completion() function or not).
2013-07-24 09:05:56 -07:00
Eder Ruiz Maria
0714d4ee67 emulator: cmd_status() using send_packet() for run hooks easily
Now like cmd_command(), cmd_status() directly uses send_packet() instead
of send_event(), consequently cmd_status() must build the hci packet
without help of send_event(). With this change the events sent by
default_cmd() no more use send_event(), who is a good place to run hooks
for BTDEV_HOOK_POST_EVT. And the functions cmd_command() and
cmd_status() can run hooks for BTDEV_HOOK_POST_CMD.
2013-07-24 09:05:45 -07:00
Eder Ruiz Maria
6eef674964 emulator: Split default_cmd() for better command and event handler
Now except for command complete event and command status event, all
other are handled by default_cmd_completion(). With this we can easily
add hooks in some points.
2013-07-24 09:04:03 -07:00
Eder Ruiz Maria
653a17cc3b emulator: Add support for delete a hook 2013-07-24 09:03:49 -07:00
Eder Ruiz Maria
7fcddf9989 emulator: Add hook only if there aren't other with same type and opcode 2013-07-24 09:03:02 -07:00
Eder Ruiz Maria
37199df506 emulator: Add support for pre/post command/event hooks
Now who use emulator can add hooks to manipulate hci packets before
and after process commands and send events.
2013-07-24 09:02:52 -07:00
Jefferson Delfes
328231416b emulator: Implement LE advertising report
When a virtual device starts a LE advertising, emulator searches for
other virtual devices that are in scan mode, in order to send adv data
to these devices.
Inverse goes when LE scan is enabled. Emulator searches virtual devices
that are in advertising mode and copy adv data to them.
2013-07-05 11:56:48 +03:00
Jefferson Delfes
2aab109f42 emulator: Dummy LE set advertising parameters
Implement basic LE set adv parameters command.
2013-07-05 11:56:25 +03:00
Jefferson Delfes
8d3386453a emulator: Disallow LE set scan params command when scan is enabled
When LE scan is enabled, the command LE set scan parameters should
return a command disallowed in status of command complete event.
2013-07-05 11:56:13 +03:00
Jefferson Delfes
5616bb9686 emulator: Store LE scan state of virtual controller
The LE command set scan enable can change the scan state of virtual
controller.
2013-07-05 11:55:57 +03:00
Jefferson Delfes
ba6460907a emulator: Implement basic LE set adv enable command
Store advertising state of virtual controller in btdev struct.
2013-07-05 11:55:33 +03:00
Jefferson Delfes
f1877f83b2 emulator: Store LE advertising data length in btdev
LE advertising data length will be used for emulating reports in other
virtual devices.
2013-07-05 11:55:09 +03:00
Anderson Lizardo
14b00ae8d2 emulator: Fix Remote Name Request Cancel command complete
The Command Complete event for this HCI command contains two parameters,
status and bd_addr.
2013-06-17 13:49:19 +03:00
Anderson Lizardo
fc2911aae7 emulator: Fix uninitialised memory usage on inquiry
This happens when using "btvirt -l2" and running "discoverable on" on
hci1 and "scan on" on hci0 using bluetoothctl:

==1870== Syscall param write(buf) points to uninitialised byte(s)
==1870==    at 0x4114443: __write_nocancel (syscall-template.S:82)
==1870==    by 0x804B503: send_packet (btdev.c:478)
==1870==    by 0x804B599: send_event (btdev.c:503)
==1870==    by 0x804B8C0: inquiry_complete (btdev.c:589)
==1870==    by 0x804C538: default_cmd (btdev.c:881)
==1870==    by 0x804E5DE: process_cmd (btdev.c:1559)
==1870==    by 0x804E646: btdev_receive_h4 (btdev.c:1577)
==1870==    by 0x804A487: vhci_read_callback (vhci.c:82)
==1870==    by 0x804923E: mainloop_run (mainloop.c:142)
==1870==    by 0x8048FD4: main (main.c:145)
==1870==  Address 0x41e4d0f is 15 bytes inside a block of size 258
alloc'd
==1870==    at 0x402B56C: malloc (vg_replace_malloc.c:270)
==1870==    by 0x804B531: send_event (btdev.c:490)
==1870==    by 0x804B8C0: inquiry_complete (btdev.c:589)
==1870==    by 0x804C538: default_cmd (btdev.c:881)
==1870==    by 0x804E5DE: process_cmd (btdev.c:1559)
==1870==    by 0x804E646: btdev_receive_h4 (btdev.c:1577)
==1870==    by 0x804A487: vhci_read_callback (vhci.c:82)
==1870==    by 0x804923E: mainloop_run (mainloop.c:142)
==1870==    by 0x8048FD4: main (main.c:145)
==1870==
2013-06-17 13:49:17 +03:00
Johan Hedberg
dcd5640ece emulator: Fix typo in supported command comment 2013-06-13 12:19:00 +03:00
Johan Hedberg
a70bd17bc9 emulator: Add handler for L2CAP command reject PDU 2013-05-29 12:13:20 +03:00
Johan Hedberg
1cb6d14459 emulator: Add callback mechanism for L2CAP requests 2013-05-29 12:10:37 +03:00
Johan Hedberg
391dbdefa0 emulator: Make bthost L2CAP sender strictly only for requests 2013-05-29 11:05:32 +03:00
Johan Hedberg
97d492f239 emulator: Return used L2CAP ident value from bthost_l2cap_cmd() 2013-05-29 10:56:41 +03:00
Johan Hedberg
55bca22b24 emulator: Add L2CAP connection tracking to bthost 2013-05-28 11:14:16 +03:00
Johan Hedberg
ec2b477c3e emulator: Add ACL connection tracking to bthost 2013-05-28 11:14:16 +03:00
Johan Hedberg
4f5290a2a3 emulator: Fix L2CAP Config req/rsp handling in bthost 2013-05-28 11:14:16 +03:00
Johan Hedberg
c27f48e426 emulator: Fix btdev connectability test (0x02 is page scan) 2013-05-28 11:14:16 +03:00
Johan Hedberg
948dc088ad emulator: Add API to initiate ACL connections 2013-05-28 11:14:16 +03:00
Johan Hedberg
1373116239 emulator: Make bthost L2CAP command function public 2013-05-28 11:14:15 +03:00
Johan Hedberg
d54f3c6f51 emulator: Add ACL connection callback to bthost 2013-05-28 11:14:15 +03:00
Johan Hedberg
ef276c5478 monitor: L2CAP Conf Response CID is a Source CID 2013-05-28 11:14:15 +03:00
Johan Hedberg
dfca2fff13 emulator: Add L2CAP Disconnect Request handler to bthost 2013-05-27 15:27:12 +03:00
Johan Hedberg
58ca55c669 emulator: Simpify bthost L2CAP signaling channel code 2013-05-27 12:27:20 +03:00
Johan Hedberg
86beb4d9f0 emulator: Add basic L2CAP Config Response handling to bthost 2013-05-27 11:48:22 +03:00
Johan Hedberg
d705186967 emulator: Add basic L2CAP Config Request handling to bthost 2013-05-27 11:48:22 +03:00
Johan Hedberg
c27e468d1e emulator: Add basic server PSM support to bthost 2013-05-27 11:37:04 +03:00
Johan Hedberg
a0e270818d emulator: Add stub for L2CAP connect requests to bthost 2013-05-27 08:16:11 +03:00
Johan Hedberg
5a09d9303c emulator: Log unsupported L2CAP packet types 2013-05-27 07:19:03 +03:00
Johan Hedberg
f7bd0a702e emulator: Add stub for completed packets event to bthost 2013-05-27 07:19:03 +03:00
Johan Hedberg
c0f2462620 emulator: Add basic L2CAP signaling handling to bthost 2013-05-27 07:19:03 +03:00
Johan Hedberg
d60ebb078b emulator: Add stub for connect complete handling to bthost 2013-05-26 04:35:23 +01:00
Johan Hedberg
9906998168 emulator: Add stub for ACL data handling to bthost 2013-05-26 04:32:10 +01:00
Johan Hedberg
d4a0ce5186 emulator: Add connect request handling to bthost 2013-05-26 04:24:30 +01:00
Johan Hedberg
8d7c9ffe50 emulator: Add scan_enable cmd_complete handler for bthost 2013-05-25 18:21:52 -07:00
Johan Hedberg
af2c5941cc emulator: implement write_scan_enable support 2013-05-24 14:30:38 -07:00
Johan Hedberg
b76f55ce12 emulator: Add bdaddr reading support to bthost 2013-05-24 14:30:38 -07:00
Johan Hedberg
5e7eea6767 emulator: Add HCI command queuing support 2013-05-24 14:30:37 -07:00
Johan Hedberg
1fdd76c7cb emulator: Add basic cmd_complete/status handling for bthost 2013-05-24 14:30:37 -07:00
Johan Hedberg
890fac2917 emulator: Remove unneeded btdev_set_bdaddr function 2013-04-30 13:21:23 +03:00
Jefferson Delfes
b895b60dcf emulator: Add getter function for device address in btdev
This helper function returns bdaddr field from btdev.
2013-04-30 13:01:58 +03:00
Johan Hedberg
1e0aa26199 emulator: Remove extended features from LE-only controllers 2013-04-19 16:51:07 +03:00
Johan Hedberg
d311de1295 emulator: Move Event Mask Page 2 from BR/EDR to BR/EDR/LE 2013-04-19 16:50:21 +03:00
Johan Hedberg
449ab3a1ad emulator: Add proper supported commands response values 2013-04-19 16:13:48 +03:00
Johan Hedberg
d4405c37b5 emulator: Add missing command support checks 2013-04-19 16:02:55 +03:00
Johan Hedberg
711b7e3008 emulator: Add basic HCI_Set_Event_Mask_Page_2 support 2013-04-19 15:55:20 +03:00
Johan Hedberg
4c4726d1d5 emulator: Add sync train parameter reading support 2013-04-18 17:57:38 +03:00
Johan Hedberg
611d1d2ca6 emulator: Fix extended features invalid params response 2013-04-18 17:57:38 +03:00
Johan Hedberg
ddb4dbd0ea emulator: Add support for local features page 2 2013-04-17 14:56:35 +03:00
Johan Hedberg
bcb96cdde5 emulator: Allow multiple vhci adapter creation with btvirt 2013-03-07 19:01:30 +02:00
Johan Hedberg
90cb7c5884 emulator: Fix unique bdaddr creation for multiple vhci_open() calls 2013-03-07 18:32:59 +02:00
Johan Hedberg
9353c8ca44 emulator: Fix missing break statement for LE Read White List Size 2013-03-04 15:34:42 +02:00
Johan Hedberg
338656c527 emulator: Add Page Scan Type HCI command support 2013-03-04 15:27:52 +02:00
Johan Hedberg
373abffd14 emulator: Add Page Scan Activity HCI command support 2013-03-04 15:19:25 +02:00
Johan Hedberg
11b9adb69a emulator: Fix BR/EDR-only and LE-only supported command checks 2013-01-31 21:47:22 -06:00
Johan Hedberg
dbab424350 emulator: Add command line options for selecting controller type to btvirt 2013-01-31 21:32:31 -06:00
Johan Hedberg
24c2977006 emulator: Use BR/EDR/LE vhci type as default for btvirt 2013-01-31 21:22:21 -06:00
Johan Hedberg
6b0eaec9bd emulator: Fix controller version for BR/EDR type 2013-01-31 14:52:11 -06:00
Johan Hedberg
946e51cdc3 emulator: Create separate BR/EDR, BR/EDR/LE and LE vhci types 2013-01-31 14:26:40 -06:00
Johan Hedberg
1ffa263826 emulator: Create separate server BR/EDR/LE and BR/EDR types 2013-01-31 14:26:40 -06:00