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).
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.
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.
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.
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==
This reverts commit 8a03376544.
The patch needs to be split up and the gdbus/ changes were bogus
compared to the original commit message.
Conflicts:
Makefile.am
Makefile.obexd
profiles/cyclingspeed/cyclingspeed.c
profiles/heartrate/heartrate.c
src/error.c
Instead of trying to include config.h in each file over the tree and
possibly forgetting to include it, give a "-include config.h" argument
to the compiler so it's guaranteed that a) it will be included for all
source files and b) it will be the first header included.
gdbus/ directory is left out, since it would break other projects using
it.