platform/upstream/bluez.git
3 years agoavdtp: Enable MTU auto tunning
Luiz Augusto von Dentz [Wed, 19 Feb 2020 00:32:22 +0000 (16:32 -0800)]
avdtp: Enable MTU auto tunning

This uses BT_PHY to check if kernel is able to do MTU auto tunning
which is enabled by forcing the input MTU to 0.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agol2test: Add support to BT_PHY
Luiz Augusto von Dentz [Tue, 18 Feb 2020 21:35:57 +0000 (13:35 -0800)]
l2test: Add support to BT_PHY

This makes l2test attempt to read BT_PHY socket option and print out
the supported packet types/PHY:

l2test[7282]: Connected to XX:XX:XX:XX:XX:XX (bredr, psm 4113, dcid 64)
l2test[7282]: Local device XX:XX:XX:XX:XX:XX (bredr, psm 4113, scid 64)
l2test[7282]: Options [imtu 672, omtu 672, flush_to 65535, mode 0, handle 256, class 0x000000, priority 0, rcvbuf 212992]
l2test[7282]: Supported PHY: 0x000001ff
          BR1M1SLOT
          BR1M3SLOT
          BR1M5SLOT
          EDR2M1SLOT
          EDR2M3SLOT
          EDR2M5SLOT
          EDR3M1SLOT
          EDR3M3SLOT
          EDR3M5SLOT

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agobtio: Add BT_IO_PHY option
Luiz Augusto von Dentz [Tue, 18 Feb 2020 19:41:29 +0000 (11:41 -0800)]
btio: Add BT_IO_PHY option

This adds BT_IO_PHY option which can be used to read the underline
packet types/PHY in use by the link layer.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Add definition to BT_PHY
Luiz Augusto von Dentz [Tue, 18 Feb 2020 19:39:15 +0000 (11:39 -0800)]
lib: Add definition to BT_PHY

This adds the definition to BT_PHY socket options along with the
possible bitfields for the return value.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agocore: Add new policy for Just-Works repairing
howardchung@google.com [Sat, 15 Feb 2020 03:44:33 +0000 (11:44 +0800)]
core: Add new policy for Just-Works repairing

When kernel find out that the incoming Just-Works pairing is
initiated by a paired device, it is user space's responsibility to
decide the next action.

This patch includes the following:
- add JustWorksRepairing policy as an option in main.conf
- handle the confirmation request from kernel

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoRelease 5.53
Marcel Holtmann [Sat, 15 Feb 2020 18:31:37 +0000 (19:31 +0100)]
Release 5.53

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agobuild: Update library version
Marcel Holtmann [Fri, 14 Feb 2020 22:27:03 +0000 (23:27 +0100)]
build: Update library version

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agobuild: Require at least version 0.28 when building with external ELL
Marcel Holtmann [Fri, 14 Feb 2020 22:24:03 +0000 (23:24 +0100)]
build: Require at least version 0.28 when building with external ELL

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoobex: report notification status on incoming message
Matt Ranostay [Fri, 7 Feb 2020 05:08:56 +0000 (21:08 -0800)]
obex: report notification status on incoming message

To match doc/obex.txt on incoming message notification the respective
Status field should be set.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Add company id for The Linux Foundation
Marcel Holtmann [Tue, 11 Feb 2020 02:27:34 +0000 (03:27 +0100)]
lib: Add company id for The Linux Foundation

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agotools/btproxy: Add support for ISO packets
Luiz Augusto von Dentz [Wed, 9 Oct 2019 10:29:07 +0000 (13:29 +0300)]
tools/btproxy: Add support for ISO packets

This enables proxing ISO packets.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoemulator: Add initial support for BT 5.2
Luiz Augusto von Dentz [Wed, 25 Sep 2019 09:56:00 +0000 (12:56 +0300)]
emulator: Add initial support for BT 5.2

This adds the initial command/event decoding for 5.2.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Add decoding for L2CAP Enhanced Credit Based PDUs
Luiz Augusto von Dentz [Wed, 31 Jul 2019 11:47:40 +0000 (14:47 +0300)]
monitor: Add decoding for L2CAP Enhanced Credit Based PDUs

Enhanced Credit Based Flow Control Mode is used for L2CAP
connection-oriented channels on LE and BR/EDR with flow control using
a credit-based scheme for L2CAP data.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Add support for ISO packets
Luiz Augusto von Dentz [Thu, 3 Oct 2019 13:36:22 +0000 (16:36 +0300)]
monitor: Add support for ISO packets

This enables decoding of ISO packets.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Add decoding of ISO related Link Layer PDUs
Luiz Augusto von Dentz [Fri, 12 Apr 2019 07:23:25 +0000 (10:23 +0300)]
monitor: Add decoding of ISO related Link Layer PDUs

This adds the decoding of ISO related Link Layer PDUs

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Add support for decoding ISO related commands
Luiz Augusto von Dentz [Fri, 12 Apr 2019 07:20:14 +0000 (10:20 +0300)]
monitor: Add support for decoding ISO related commands

This adds parsing of ISO related commands.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Add missing HCI command error code decoding
Szymon Janc [Tue, 28 Jan 2020 11:07:40 +0000 (12:07 +0100)]
monitor: Add missing HCI command error code decoding

Packet Too Long (0x45 ) status code was missing.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared: shell: Only omit consecutive duplicate history lines.
Marijn Suijten [Sat, 18 Jan 2020 20:44:23 +0000 (21:44 +0100)]
shared: shell: Only omit consecutive duplicate history lines.

Change rl_handler to append duplicate history, as long as it isn't
identical to the last line. It prevents consecutive duplicates while
still having an accurate overview of the most recent commands used,
mimicking most modern shells.

This addresses my only major gripe with bluetoothctl: pressing UP does
not retrieve the last typed command when it is a duplicate of something
else written (much) earlier in the history. It is especially noticeable
when needing the same command repeatedly.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Adding missing op_code string conversion
Alain Michaud [Fri, 17 Jan 2020 04:24:21 +0000 (04:24 +0000)]
lib: Adding missing op_code string conversion

Adding the missing string conversion for MGMG_OP_SET_BLOCKED_KEYS.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Load keys that should be blocked by the kernel
Alain Michaud [Tue, 7 Jan 2020 01:28:22 +0000 (01:28 +0000)]
adapter: Load keys that should be blocked by the kernel

This change accomplishes 2 things:
 1. Drop device security data from previously paired devices
 using blocked keys.
 2. Send the list of known bad keys that should be blocked to the kernel
 if supported.

In particular keys from the Google Titan Security key are being
blocked.

For additional background information, please see
https://security.googleblog.com/2019/05/titan-keys-update.html

Change-Id: Ib854cbae108058f2ecb9822d46d621434a980f19
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/util: Adding a shared ARRAY_SIZE macro
Alain Michaud [Tue, 7 Jan 2020 01:28:20 +0000 (01:28 +0000)]
shared/util: Adding a shared ARRAY_SIZE macro

This will allow other implementations within src/ to use a single
definition of the ARRAY_SIZE macro.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: MGMT_OP_SET_BLOCKED_KEYS Api definitions
Alain Michaud [Tue, 7 Jan 2020 01:28:18 +0000 (01:28 +0000)]
lib: MGMT_OP_SET_BLOCKED_KEYS Api definitions

Adding the required definitions for the MGMT_OP_SET_BLOCKED_KEYS Api.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoavctp: Fix EINVAL on uinput creation
Haochen Tong [Sun, 12 Jan 2020 00:42:26 +0000 (01:42 +0100)]
avctp: Fix EINVAL on uinput creation

The struct uinput_dev variable is on stack, so clear its content to
avoid accidentally writing garbage values to kernel. This fixes "Can't
create uinput device: Invalid argument (22)" in some cases.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoaudio/a2dp - fix crash during recovering process
howardchung [Fri, 10 Jan 2020 07:57:28 +0000 (15:57 +0800)]
audio/a2dp - fix crash during recovering process

The crash with stack trace:

(libc-2.27.so -raise.c:51 )       raise
(libc-2.27.so -abort.c:79 )       abort
(libc-2.27.so -libc_fatal.c:181 )         __libc_message
(libc-2.27.so -malloc.c:5350 )    malloc_printerr
(libc-2.27.so -malloc.c:4157 )    _int_free
(libglib-2.0.so.0.5200.3 -gslist.c:878 )        g_slist_free_full
(bluetoothd -a2dp.c:165 )        setup_unref
(bluetoothd -a2dp.c:2184 )       a2dp_cancel
(bluetoothd -sink.c:317 )        sink_unregister
(bluetoothd -service.c:176 )     service_remove
(bluetoothd -device.c:4678 )     device_remove
(bluetoothd -adapter.c:6573 )    adapter_remove
(bluetoothd -adapter.c:8832 )    index_removed
(bluetoothd -queue.c:220 )       queue_foreach
(bluetoothd -mgmt.c:304 )        can_read_data
(bluetoothd -io-glib.c:170 )     watch_callback
(libglib-2.0.so.0.5200.3 -gmain.c:3234 )        g_main_context_dispatch
(libglib-2.0.so.0.5200.3 -gmain.c:3972 )        g_main_context_iterate
(libglib-2.0.so.0.5200.3 -gmain.c:4168 )        g_main_loop_run
(bluetoothd -main.c:798 )        main
(libc-2.27.so -libc-start.c:308 )         __libc_start_main
(bluetoothd + 0x0000b089 )       _start
(bluetoothd + 0x0000b05f )       _init

triggered when 'usb disconnect' happened during AVDTP_SET_CONFIGURATION
request is sent but haven't received the response.
In this situation, the recovering process goes into sink.c:sink_free and
then a2dp.c:a2dp_cancel, avdtp.c:cancel_request, avdtp.c:connection_lost,
avdtp.c:release_stream.

During recovering, the reference count of setup and avdtp decrease more
than it increase, which ends up causing the crash.

The reference count of setup decreases one more time since
a2dp.c:setconf_cfm(called by cfm->set_configuration in
avdtp.c:cancel_request) was called in the 'error mode', which didn't
reference the setup, but in a2dp.c:abort_cfm(called by cfm->abort in
avdtp.c:release_stream), the reference count decreased by 1.

In this case, abort_cfm shouldn't be called as we already know
setconf_cfm didn't send any request. Setting avdtp_sep_state to
AVDTP_STATE_ABORTING should avoid this issue.

The reference count of avdtp decrease one more time since
both sink.c:sink_free and sink.c:sink_set_state(called from
avdtp.c:connection_lost -> avdtp.c:avdtp_set_state) unreference avdtp
for the session. The changes in sink.c should avoid the issue.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoAUTHORS: mention Szymon's contributions
Szymon Janc [Thu, 9 Jan 2020 10:37:28 +0000 (11:37 +0100)]
AUTHORS: mention Szymon's contributions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Decode LE CTE Request Failed event
Szymon Czapracki [Wed, 8 Jan 2020 11:47:52 +0000 (12:47 +0100)]
monitor: Decode LE CTE Request Failed event

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Decode LE Set Default Periodic Adv Sync Transfer Params. command
Szymon Czapracki [Wed, 8 Jan 2020 11:47:51 +0000 (12:47 +0100)]
monitor: Decode LE Set Default Periodic Adv Sync Transfer Params. command

< HCI Command: LE Set Default Periodic Advertisng Sync Transfer Parameters (0x08|0x005d) plen 6
        Mode: Enabled with report events disabled (0x01)
        Skip: 0x00
        Sync timeout: 0 msec (0x0000)
        Sync CTE type: 0x0000
> HCI Event: Command Status (0x0f) plen 4
      LE Set Default Periodic Advertisng Sync Transfer Parameters (0x08|0x005d) ncmd 1
        Status: Unknown HCI Command (0x01)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Decode LE Set Periodic Adv Sync Transfer Parameterers command
Szymon Czapracki [Wed, 8 Jan 2020 11:47:50 +0000 (12:47 +0100)]
monitor: Decode LE Set Periodic Adv Sync Transfer Parameterers command

< HCI Command: LE Periodic Advertising Sync Transfer Parameters (0x08|0x005c) plen 8
        Connection handle: 1
        Mode: Disabled (0x00)
        Skip: 0x00
        Sync timeout: 0 msec (0x0000)
        Sync CTE type: 0x0000
> HCI Event: Command Status (0x0f) plen 4
      LE Periodic Advertising Sync Transfer Parameters (0x08|0x005c) ncmd 1
        Status: Unknown HCI Command (0x01)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Decode LE Periodic Advertising Set Info Transfer command
Szymon Czapracki [Wed, 8 Jan 2020 11:47:49 +0000 (12:47 +0100)]
monitor: Decode LE Periodic Advertising Set Info Transfer command

< HCI Command: LE Periodic Advertising Set Info Transfer (0x08|0x005b) plen 5
       Connection handle: 1
       Service data: 0x0000
       Advertising handle: 0
> HCI Event: Command Status (0x0f) plen 4
     LE Periodic Advertising Set Info Transfer (0x08|0x005b) ncmd 1
       Status: Unknown HCI Command (0x01)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Decode LE Periodic Advertising Sync Transfer command
Szymon Czapracki [Wed, 8 Jan 2020 11:47:48 +0000 (12:47 +0100)]
monitor: Decode LE Periodic Advertising Sync Transfer command

< HCI Command: LE Periodic Advertising Sync Transfer (0x08|0x005a) plen 6
        Connection handle: 1
        Service data: 0x0001
        Sync handle: 1
> HCI Event: Command Status (0x0f) plen 4
      LE Periodic Advertising Sync Transfer (0x08|0x005a) ncmd 1
        Status: Unknown HCI Command (0x01)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Decode LE Set Periodic Advertising Receive Enable command
Szymon Czapracki [Wed, 8 Jan 2020 11:47:47 +0000 (12:47 +0100)]
monitor: Decode LE Set Periodic Advertising Receive Enable command

< HCI Command: LE Periodic Advertising Receive Enable (0x08|0x0059) plen 3
        Sync handle: 0
        Reporting: Enabled (0x01)
> HCI Event: Command Status (0x0f) plen 4
      LE Periodic Advertising Receive Enable (0x08|0x0059) ncmd 1
        Status: Unknown HCI Command (0x01)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Decode LE Periodic Advertising Sync Transfer Received Event
Szymon Czapracki [Wed, 8 Jan 2020 11:47:46 +0000 (12:47 +0100)]
monitor: Decode LE Periodic Advertising Sync Transfer Received Event

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Update periodic sync commands.
Szymon Czapracki [Wed, 8 Jan 2020 11:47:45 +0000 (12:47 +0100)]
monitor: Update periodic sync commands.

Change fields in periodic_adv_(create/term)_sync_cmd, according to their
description with 5.1 specification.

< HCI Command: LE Periodic Advertising Create Sync (0x08|0x0044) plen 14
        Options: 0x0001
        Use Periodic Advertiser List
        Reporting initially enabled
        SID: 0x00
        Adv address type: Public (0x00)
        Adv address: 00:00:00:00:00:00 (OUI 00-00-00)
        Skip: 0x0000
        Sync timeout: 0 msec (0x0000)
        Sync CTE type: 0x0000
> HCI Event: Command Status (0x0f) plen 4
      LE Periodic Advertising Create Sync (0x08|0x0044) ncmd 1
        Status: Unknown HCI Command (0x01)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoagent: Detect when ongoing request is already in progress
Luiz Augusto von Dentz [Fri, 27 Dec 2019 18:19:15 +0000 (10:19 -0800)]
agent: Detect when ongoing request is already in progress

This detects when a agent request is already pending for the same device
which could happen when there are 2 or more adapters in the system and
they are trying to pair with each other.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/mainloop: Use connect() instead of bind() for sd_notify
Guillem Jover [Sat, 14 Dec 2019 09:40:52 +0000 (10:40 +0100)]
shared/mainloop: Use connect() instead of bind() for sd_notify

We are the client, so we should be using connect(2) instead of bind(2),
otherwise when using non-abstract Unix sockets we will get an error that
the address is already in use.

This breaks the notify support in dpkg's start-stop-daemon.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoclient: Fix memory leak
Syam Sidhardhan [Tue, 3 Dec 2019 09:48:42 +0000 (15:18 +0530)]
client: Fix memory leak

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoRevert "input: Set uniq attribute"
Luiz Augusto von Dentz [Wed, 4 Dec 2019 11:59:21 +0000 (13:59 +0200)]
Revert "input: Set uniq attribute"

UNIQ is changes to the kernel has not been accepted yet.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput: Set uniq attribute
Abhishek Pandit-Subedi [Tue, 3 Dec 2019 01:04:00 +0000 (17:04 -0800)]
input: Set uniq attribute

Set the uniq attribute of /dev/uinput with the peer device address.

The resulting uinput device will look like this:

$ udevadm info -a -p /sys/devices/virtual/input/input17
...
  looking at device '/devices/virtual/input/input17':
    KERNEL=="input17"
    SUBSYSTEM=="input"
    DRIVER==""
    ATTR{inhibited}=="0"
    ATTR{name}=="BeatsStudio Wireless (AVRCP)"
    ATTR{phys}=="00:00:00:6e:d0:74"
    ATTR{properties}=="0"
    ATTR{uniq}=="00:00:00:1a:33:21"

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput: Change uinput name and add AVRCP suffix
Abhishek Pandit-Subedi [Tue, 3 Dec 2019 01:03:59 +0000 (17:03 -0800)]
input: Change uinput name and add AVRCP suffix

When creating the uinput device, change the name to the peer device
name and add a "(AVRCP)" suffix.

The resulting uinput device will look like this:

$ udevadm info -a -p /sys/devices/virtual/input/input17
...
  looking at device '/devices/virtual/input/input17':
    KERNEL=="input17"
    SUBSYSTEM=="input"
    DRIVER==""
    ATTR{inhibited}=="0"
    ATTR{name}=="BeatsStudio Wireless (AVRCP)"
    ATTR{phys}=="00:00:00:6e:d0:74"
    ATTR{properties}=="0"
    ATTR{uniq}==""

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput: Update virtual input devices with correct info
Abhishek Pandit-Subedi [Tue, 3 Dec 2019 01:03:58 +0000 (17:03 -0800)]
input: Update virtual input devices with correct info

Update uhid and uinput devices with lowercase addresses (to match how
kernel prints it via %pMR). Also update uinput to include the phys
attribute and correctly set the vendor/product/version during init.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Add ba2strlc to match kernel printk format
Abhishek Pandit-Subedi [Tue, 3 Dec 2019 01:03:57 +0000 (17:03 -0800)]
lib: Add ba2strlc to match kernel printk format

When the kernel prints the bluetooth address (via %pMR), it prints the
address in lower case. ba2strlc should be used in cases where we should
match the kernel casing (i.e. addresses assigned to /dev/uhid and
/dev/uinput)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoAUTHORS: Mention Silvair's contributions
Michał Lowas-Rzechonek [Wed, 27 Nov 2019 09:42:54 +0000 (10:42 +0100)]
AUTHORS: Mention Silvair's contributions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoAUTHORS: Fix typo in Inga's surname
Michał Lowas-Rzechonek [Wed, 27 Nov 2019 09:42:53 +0000 (10:42 +0100)]
AUTHORS: Fix typo in Inga's surname

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoAUTHORS: Mention Alain's contributions
Marcel Holtmann [Wed, 27 Nov 2019 05:56:24 +0000 (06:56 +0100)]
AUTHORS: Mention Alain's contributions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Add definition for Load Blocked Keys command
Alain Michaud [Tue, 26 Nov 2019 19:14:52 +0000 (19:14 +0000)]
doc: Add definition for Load Blocked Keys command

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc: Fix wrongly documented mgmt command opcodes
Alain Michaud [Tue, 26 Nov 2019 19:09:41 +0000 (19:09 +0000)]
doc: Fix wrongly documented mgmt command opcodes

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoREADME: Adding information for dependency get command for Debian
Alain Michaud [Tue, 26 Nov 2019 19:08:42 +0000 (19:08 +0000)]
README: Adding information for dependency get command for Debian

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agocore/advertising: Fix crash when client is added after unregistration
Simon Mikuda [Tue, 12 Nov 2019 13:56:35 +0000 (14:56 +0100)]
core/advertising: Fix crash when client is added after unregistration

After "register_advertisement()" callback "client_proxy_added()" was yet
called but it was actually called after: "unregister_advertisement()" which
caused segmentation fault because client was removed twice.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agocore/advertising: Fix crash when unregistering advertisement too fast
Simon Mikuda [Tue, 12 Nov 2019 13:56:34 +0000 (14:56 +0100)]
core/advertising: Fix crash when unregistering advertisement too fast

When advertisement is unregistered during MGMT_OP_ADD_ADVERTISING it will
crash in add_adv_callback because struct btd_adv_client no longer exist.

This is seen also in debug log from bluetoothd:
bluetoothd[29698]: src/advertising.c:register_advertisement() RegisterAdvertisement
bluetoothd[29698]: src/advertising.c:client_create() Adding proxy for /org/bluez/example/advertisement0
bluetoothd[29698]: src/advertising.c:register_advertisement() Registered advertisement at path /org/bluez/example/advertisement0
bluetoothd[29698]: src/advertising.c:parse_service_uuids() Adding ServiceUUID: 180D
bluetoothd[29698]: src/advertising.c:parse_service_uuids() Adding ServiceUUID: 180F
bluetoothd[29698]: src/advertising.c:parse_manufacturer_data() Adding ManufacturerData for ffff
bluetoothd[29698]: src/advertising.c:parse_service_data() Adding ServiceData for 9999
bluetoothd[29698]: src/advertising.c:parse_data() Adding Data for type 0x26 len 3
bluetoothd[29698]: src/advertising.c:refresh_adv() Refreshing advertisement: /org/bluez/example/advertisement0
bluetoothd[29698]: src/advertising.c:unregister_advertisement() UnregisterAdvertisement
bluetoothd[29698]: src/advertising.c:add_adv_callback() Advertisement registered: �
Segmentation fault (core dumped)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoGATT: Initialise service discovery handle range to support GATT-caching 50/253450/1 accepted/tizen/unified/20210218.042152 submit/tizen/20210216.223518
Ayush Garg [Wed, 10 Feb 2021 06:40:38 +0000 (12:10 +0530)]
GATT: Initialise service discovery handle range to support GATT-caching

This change will initialise handle range based on
whether GATT database is empty or not.
This is done to properly handle GATT-Cached data and
prevent resetting it in case when same database-hash
is received from GATT-Server during service discovery.

Change-Id: Ic2a8dc4ff9a5ccf563615156b7b5e97d1e2b3bca
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoModify service file name to bluez-start.service 36/252936/1 accepted/tizen/unified/20210204.134648 submit/tizen/20210203.002701
Wootak Jung [Wed, 3 Feb 2021 07:17:34 +0000 (16:17 +0900)]
Modify service file name to bluez-start.service

Change-Id: Id027c0fa8f8655f9b9d5518bce7b5a50060c18d5
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
3 years agoMerge "Fix the crash when stopping LE discovery" into tizen
Pyun DoHyun [Wed, 3 Feb 2021 00:09:20 +0000 (00:09 +0000)]
Merge "Fix the crash when stopping LE discovery" into tizen

3 years agoFix the crash when stopping LE discovery 43/252743/1
DoHyun Pyun [Tue, 2 Feb 2021 06:02:02 +0000 (15:02 +0900)]
Fix the crash when stopping LE discovery

This patchset combines two upstream commits.
If we upgrade bluez version, this issue will be resolved.
But for the product issue, we make the hotfix patchset.

------------------------------------------------
commit b94e7fc4e267edbae5359a3efb69b14575c6ca3b
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Thu Jun 11 10:26:57 2020 -0700

    adapter: Fix passing wrong pointer to stop discovery
------------------------------------------------
commit 9dd6df753a0a7e09e09cea0fdc0bc056389624d4
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Mon Jun 8 14:55:57 2020 -0700

    adapter: Fix possible crash when stopping discovery
-----------------------------------------------

Change-Id: I5c9d5fa98e9a1201e2547fd674da851a4e82edab
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
3 years agoMigrate bluez-start.service from tools 09/252709/1
Wootak Jung [Mon, 1 Feb 2021 23:29:51 +0000 (08:29 +0900)]
Migrate bluez-start.service from tools

Change-Id: Ib0ddea5514ebbd7c6853d6eec81810f04c37d800
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
3 years ago[GATT] Send prepare_authorize parameter to HAL layer. 50/251750/3 accepted/tizen/unified/20210128.132355 submit/tizen/20210127.232224
Ayush Garg [Tue, 19 Jan 2021 04:57:26 +0000 (10:27 +0530)]
[GATT] Send prepare_authorize parameter to HAL layer.

In GATT Server role, prepare_authorize parameter will be used
to ask authorization permission from the application when
ATT_PREPARE_WRITE_REQUEST PDU receive for the first time in case
of long write.

This patchset should be merged with the following bluetooth-frwk's
patchset in order to match API and avoid crash:
bluetooth-frwk Change-Id: Ic4397ae86760177e08ccd283e80d4526bd32e0c4

Change-Id: I93bc46151ebbe695c74b224c3a3579c6e5d0de14
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoRemove unused devel package: libusb-devel 69/251169/1
INSUN PYO [Mon, 11 Jan 2021 01:39:39 +0000 (10:39 +0900)]
Remove unused devel package: libusb-devel

Change-Id: Ie74266b75b1f8a850a1989805f56985930313baa

3 years agoMerge branch 'meshd_integrate' into tizen bluez_upgrade_5.52
Anupam Roy [Mon, 4 Jan 2021 06:01:19 +0000 (11:31 +0530)]
Merge branch 'meshd_integrate' into tizen

3 years agoModify the capability option for systemd meshd_integrate
DoHyun Pyun [Thu, 24 Dec 2020 01:51:07 +0000 (10:51 +0900)]
Modify the capability option for systemd

Change-Id: I401965ca58820038f23c1caac0bd5bc2b114a233
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
3 years agomesh: Fix check for mkdir return value in keyring.c
Inga Stotland [Tue, 22 Dec 2020 06:04:08 +0000 (11:34 +0530)]
mesh: Fix check for mkdir return value in keyring.c

Remove check for mkdir() return value, since checking for zero does not
cover "already exists" condition and adding extra check for errno value
unnecessarily complicates the code. If mkdir() fails due to any reason
than "already exists", the subsequent call to open() fails and the
error is detected and corectly processed by the code.

Change-Id: I72db1d9553ba9a8269d391f938fbb26abc5cdf50
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
3 years agomesh: fix node default TTL
Aurelien Jarno [Fri, 18 Dec 2020 06:30:30 +0000 (12:00 +0530)]
mesh: fix node default TTL

There is a confusion between the node default TTL (section 4.2.7) and
the publish TTL (section 4.2.2.5):

- The node default TTL can only take values 0x00, and 0x02 to 0x7f. The
  value 0xff is not prohibited.
- The publish TTL can take values 0x00 to 0x7f, as well as 0xff which
  means use the node default TTL.

Currently the default node TTL is set to 0xff (DEFAULT_TTL), and
read_default_ttl() also allows such a value. This patch fixes that to
use 0x7f (TTL_MASK) as the default value instead.

Note that the code handling OP_CONFIG_DEFAULT_TTL_SET correctly use 0x7f
(TTL_MASK) for the upper allowed limit.

Change-Id: If894a9eb88bd129293845c068e0b6f3685495a4c
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
3 years agomesh: Zero out config node struct before initializing
Inga Stotland [Wed, 2 Dec 2020 21:11:51 +0000 (13:11 -0800)]
mesh: Zero out config node struct before initializing

This memsets all the fields of mesh_db_node to zero prior to intializing
some fields in mesh_config_node struct and creating a brand new node
configuration. Just a precaution against having uninitialized items.

Change-Id: I92528e58d399db611e84fdacf6399281e4ffc54d
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
3 years agomesh: Fix regression error in HB subscription set
Inga Stotland [Wed, 18 Nov 2020 19:56:00 +0000 (11:56 -0800)]
mesh: Fix regression error in HB subscription set

This fixes a regression introduced in commit c77bb848a9fb
("mesh: Refactor heartbeat pub/sub"):
Heartbeat subscription should be enabled unless either source or
destination are unassigned addresses or period log is zero.

Also, decrement ref count on group destination address if period log
is zero since the subscription is not supposed to be processed.

Change-Id: I981784d5e260e90dce022ee8785d3d1b47348e57
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Only deregister io for the last network detached
Michael N. Moran [Fri, 6 Nov 2020 22:48:11 +0000 (17:48 -0500)]
mesh: Only deregister io for the last network detached

When multiple mesh networks are active and one is detached
using Leave(), the I/O to all networks is halted.

This patch prevents that by only deregistering the I/O
if all networks have been detached.

Change-Id: Iae00af608959dda15440801f2141602e1844e4aa
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh/mesh-config-json: Fix errors found by static analysis
Inga Stotland [Fri, 6 Nov 2020 22:22:45 +0000 (14:22 -0800)]
mesh/mesh-config-json: Fix errors found by static analysis

This fixes miscellaneous issues related to unchecked return status
and (temporary) allocated memory leaks due to daemon's exit on startup
failure.

Change-Id: Icf621e459ed4f045a740a78f3252dcdde8621350
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix memory leak when failing to load a node
Inga Stotland [Tue, 10 Nov 2020 04:24:51 +0000 (20:24 -0800)]
mesh: Fix memory leak when failing to load a node

This fixes a memory leak that may occur on unsuccessful element
initialization from storage.

Change-Id: I2a1b928280d58a3077f9ba1c30682a0041bfb9ab
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix memory leak and NULL pointer dereference
Inga Stotland [Tue, 10 Nov 2020 04:21:27 +0000 (20:21 -0800)]
mesh: Fix memory leak and NULL pointer dereference

This fixes a potential NULL pointer dereferencing in mesh_model_pub_set()
when virtual address publication cannot be successfully stored.
Also, fix a minor memory leak that may occur on unsuccessful model
initialization from storage.

Change-Id: Ic5de82e7109237c7aa411e27c544b5fe2164a3d4
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix errors found by static analysis
Inga Stotland [Fri, 6 Nov 2020 07:10:53 +0000 (23:10 -0800)]
mesh: Fix errors found by static analysis

This fixes a NULL pointer dereference error (cfgmod-server.c)
and miscellaneous issues related to unchecked return status.

Change-Id: Ic0951ce49c17fe1e97065da5f50589563290afdb
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agotools/mesh-cfgclient: Fix errors found by static analysis
Inga Stotland [Mon, 26 Oct 2020 21:08:17 +0000 (14:08 -0700)]
tools/mesh-cfgclient: Fix errors found by static analysis

This fixes a NULL pointer dereference error in subscription_cmd().

Also re-order calling sequence for l_free() & l_queue_remove()
in msg_recvd(): even though technically it is not a bug to pass
a value of a freed pointer to l_queue_remove(), it's a poor form
and confuses the analyzer.

Change-Id: I6863f60c23dbda3e2030bee7d8d7c8fe666887de
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Re-arrange Join/Create/Import/Attach page saving
Brian Gix [Wed, 7 Oct 2020 21:09:59 +0000 (14:09 -0700)]
mesh: Re-arrange Join/Create/Import/Attach page saving

When an App is creating or attaching to a node, it first evaluates the
validity of the Apps composition. Invalid compositions are not allowed
to continue.  Valid compositions need to be saved, which means that
create_node_config() must be called as part of Composition validation.

Change-Id: I485904ef8165ea7315221d899147a5eee476f1cf
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:35:33 +0000 (12:35 -0700)]
mesh: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 LGPL-2.1-or-later    :     48

License: LGPL-2.1-or-later
   mesh/mesh-mgmt.h
   mesh/mesh-mgmt.c
   mesh/net-keys.c
   mesh/mesh-io-api.h
   mesh/mesh.h
   mesh/net-keys.h
   mesh/model.h
   mesh/util.h
   mesh/appkey.c
   mesh/cfgmod.h
   mesh/appkey.h
   mesh/prov.h
   mesh/prov-acceptor.c
   mesh/net.c
   mesh/dbus.h
   mesh/friend.h
   mesh/mesh-io-generic.c
   mesh/main.c
   mesh/util.c
   mesh/dbus.c
   mesh/error.h
   mesh/mesh-config-json.c
   mesh/agent.h
   mesh/pb-adv.c
   mesh/crypto.c
   mesh/crypto.h
   mesh/friend.c
   mesh/pb-adv.h
   mesh/provision.h
   mesh/mesh-config.h
   mesh/mesh-io-generic.h
   mesh/agent.c
   mesh/cfgmod-server.c
   mesh/mesh-io.h
   mesh/keyring.h
   mesh/net.h
   mesh/keyring.c
   mesh/mesh-defs.h
   mesh/mesh.c
   mesh/rpl.c
   mesh/manager.c
   mesh/model.c
   mesh/mesh-io.c
   mesh/node.c
   mesh/prov-initiator.c
   mesh/rpl.h
   mesh/node.h
   mesh/manager.h

Change-Id: I5f80a399c16872afdbfff9143e77fabbbc703b9f
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Align option names with functionality
Inga Stotland [Thu, 3 Sep 2020 20:00:52 +0000 (13:00 -0700)]
mesh: Align option names with functionality

Change option "config" ('c') to "storage" ('s) to specify
a custom storage directory for node configuration.

Change option 'f' (long name was missing) to "config" ('c')
to specify a custom mesh configuration file to override the
default mesh-main.conf

Change-Id: Idcf869faed62bdf401c9994754589698eeade2a6
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Remove unused timing variable tx_start
Inga Stotland [Thu, 3 Sep 2020 19:02:05 +0000 (12:02 -0700)]
mesh: Remove unused timing variable tx_start

In model.c, tx_Start is a static variable, dynamically set, but
never used. Is removed now.

Change-Id: I668c9c9c941ccc6c37a6f26c3e7994eb5765bf44
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Move RPL check from model to net layer
Inga Stotland [Fri, 28 Aug 2020 20:04:27 +0000 (13:04 -0700)]
mesh: Move RPL check from model to net layer

Check whether an incoming message has an RPL entry prior to
handing it over to model layer for processing. If present in RPL
or the RPL queue is full, ignore the incoming message.

If the incoming message is processed successfully, add the message
as a new RPL entry.

Change-Id: Ie7195212a78b7d503c015b3d1fef2300fc213ddd
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Initialize RPL when creating or loading a node
Inga Stotland [Fri, 28 Aug 2020 20:04:26 +0000 (13:04 -0700)]
mesh: Initialize RPL when creating or loading a node

When either a new node is created or an existing node is loaded from
storage, initialize RPL storage directory.

Additionally, when an existing node configguration is read from storage,
load saved RPL entries into the corresponding RPL lists.

Change-Id: Ia9b2cb55e1170dcb149df59fccb93b917d3e060b
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Store key indices as integers in node config
Inga Stotland [Fri, 28 Aug 2020 16:51:12 +0000 (09:51 -0700)]
mesh: Store key indices as integers in node config

Store NetKey and AppKey indices as integers instead of hex strings.
This removes unnecessary string manipulations while not affecting
the configuration file readability.

Change-Id: Ic2cf06f4a3ec8cf9fd429caa863f0893ab5afc9f
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agotest/test-mesh: Add "options" to Send/Publish
Inga Stotland [Tue, 25 Aug 2020 00:54:35 +0000 (17:54 -0700)]
test/test-mesh: Add "options" to Send/Publish

This adds a new dictionary paramenter (empty by default) when
invoking Send() or Publish() methods.

Change-Id: I1b129cb00947159e667333a0437b7563d054a11b
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agotools/mesh-cfglient: Add "options" to Send/DevKeySend
Inga Stotland [Tue, 25 Aug 2020 00:54:34 +0000 (17:54 -0700)]
tools/mesh-cfglient: Add "options" to Send/DevKeySend

This adds a new dictionary paramenter (empty by default) when
invoking Send() and DevKeySend() methods.

Change-Id: I3a557f7a6a006a8b90f175f8d7d2d439b95e4f10
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Handle "options" dictionary in Send/Publish methods
Inga Stotland [Tue, 25 Aug 2020 00:54:33 +0000 (17:54 -0700)]
mesh: Handle "options" dictionary in Send/Publish methods

This adds processing of "options" dictionary argument in Send,
DevKeySend & Publish methods on mesh.Node interface.

This new argument is a dictionary that currently has only one
new key word defined for Send() and DevKeySend():
    "ForceSegmented" - to force small payloads to be sent as
                       one-segment messages

In case of Publish(), and additional keyword is defined
     "Vendor" -  16-bit Company ID as defined by the Bluetooth SIG

Other key words may be defined in future to accommodate evolving
requirements of Mesh Profile specification.

Also, the addition of "options" dictionary to Publish allows to
eliminate VendorPublish() method (taken care by "Vendor" keyword).

Change-Id: I651165b5844fa2f709bcf563d17a07c8bbb0f324
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agodoc/mesh-api: Add "options" dictionary to Send/Publish
Inga Stotland [Tue, 25 Aug 2020 00:54:32 +0000 (17:54 -0700)]
doc/mesh-api: Add "options" dictionary to Send/Publish

This modifies Send, DevKeySend and Publish methods
on mesh.Node interface to include additional argument "options".
This new argument is a dictionary that currently has only one
new key word defined for Send() and DevKeySend():
    "ForceSegmented" - to force small payloads to be sent as
           one-segment messages

In case of Publish(), and additional keyword is defined
     "Vendor" -  16-bit Company ID as defined by the Bluetooth SIG

Other key words may be defined in future to accommodate evolving
requirements of Mesh Profile specification.

Also, the addition of "options" dictionary to Publish allows to
eliminate VendorPublish() method (taken care by "Vendor" keyword).

Change-Id: I5fa1ed0e03875cc4c16723aa6005b38fcf031255
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Add random address to mesh HCI init
Daan Pape [Wed, 19 Aug 2020 08:28:22 +0000 (10:28 +0200)]
mesh: Add random address to mesh HCI init

This prevents error 0x12 when enabling/disabling LE scans

Change-Id: I1e299724c2a6b7229005762b3e04b3267aaaeca5
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Use valid net key index when handling Send call
Inga Stotland [Fri, 21 Aug 2020 05:48:56 +0000 (22:48 -0700)]
mesh: Use valid net key index when handling Send call

Retrieve value of bound Net Key index based on the value of
passed AppKey index. Check if the key is present and fail early
in case of error. Also, pass the correct NetKey index to model
layer in mesh_model_send(), instead of hard coded 0.

Change-Id: Ia876bb512cc877a3634ef3aa1f20b8fd4ddedb15
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Use correct retransmit parameters for publications
Inga Stotland [Thu, 20 Aug 2020 05:41:32 +0000 (22:41 -0700)]
mesh: Use correct retransmit parameters for publications

This adds previously missing retransmit count and interval values
specific to model publications. The values are configured by Config CLient
and may be different to each model.

Change-Id: I5ee9af88e7ed11f4fc43a18bcf78d97ba7992f39
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Send correct NetKey index in DevKeyMessageReceived
Inga Stotland [Wed, 19 Aug 2020 21:48:02 +0000 (14:48 -0700)]
mesh: Send correct NetKey index in DevKeyMessageReceived

The value of net_index in DevKeyMessageReceived() method must be set
to the value of a subnet index on which a device key encoded message
has been received. Was hard coded to 0. Fixed.

Change-Id: I398c669253d92f24f16b49a0ec892cc031380212
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Check for enabled modes when dst is fixed address
Inga Stotland [Tue, 18 Aug 2020 22:22:08 +0000 (15:22 -0700)]
mesh: Check for enabled modes when dst is fixed address

This moves the check for incoming messages addressed to fixed addresses,
e.g. RELAY, PROXY, FRIEND. If the corresponding feature is not enabled,
the message is not processed.

Change-Id: I0d7ccefa3e905cf5c7c9a35b12ef0bbbcf74a9e5
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Always set net modes based on node feature settings
Inga Stotland [Tue, 18 Aug 2020 22:22:07 +0000 (15:22 -0700)]
mesh: Always set net modes based on node feature settings

The network settings such as relay, beacon, proxy and friend are
always set based on local node feature settings. This change makes
the net modes initialization unconditional, to include the "No Support"
setting on node level which should result in the disabled mode in net.c

Change-Id: Ie3d31cb8a4af91ee712c6f6fe49da854ba0c0345
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: fix double-free of outbound tx data
Brian Gix [Thu, 13 Aug 2020 17:43:14 +0000 (10:43 -0700)]
mesh: fix double-free of outbound tx data

Due to the asyncronous multi-step process to send a packet on an HCI
socket, an outbound packet could be superseded before send procedure
is completed. This change ensures that at any stage in the process,
that the pointer to the packet has been fully disposed.

Change-Id: I32121f72abe6abe5f54607e41381397272059bcf
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Don't add config server when loading from storage
Inga Stotland [Thu, 13 Aug 2020 05:01:50 +0000 (22:01 -0700)]
mesh: Don't add config server when loading from storage

Adding a sonfig server model when loading from storage is unnecessary,
since the daemon-generated stored configuration always contains
config server model.
This also fixes a memory leak caused by bad parameters passed to
mesh_model_add()

Change-Id: I2568e8a2c910e40fec6c910d65f5f7d432726c4a
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Make mesh config model binding API consistent
Inga Stotland [Wed, 12 Aug 2020 19:03:17 +0000 (12:03 -0700)]
mesh: Make mesh config model binding API consistent

This changes the order of function arguments in
mesh_config_model_binding_add() and mesh_config_model_binding_del()
to make them consistent with the rest of mesh_config_model... APIs

Change-Id: I5fcb97c5288d277b28c9ee7da807080f16d50ba9
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix model ID prior to calling mesh config functions
Inga Stotland [Wed, 12 Aug 2020 19:03:16 +0000 (12:03 -0700)]
mesh: Fix model ID prior to calling mesh config functions

Model IDs for SIG defined models need to be stripped off SIG_VENDOR
value used for internal housekeeping prior to calling functions
that save new model state in node configuration.

Also, remove duplicate statements for model lookup in node config.

Change-Id: I0a45e64e9b1666e531134a192b129777a63ba1f1
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix encoding of Config Key Refresh Phase Status
Michał Lowas-Rzechonek [Tue, 11 Aug 2020 19:37:09 +0000 (21:37 +0200)]
mesh: Fix encoding of Config Key Refresh Phase Status

Config Key Refresh Phase Status is 4 octets long (see Mesh Profile
v1.0.1, section 4.3.2.60): 1 octet for status, 2 octets for net key
index, 1 octet for the phase.

Change-Id: I7c9ab88fc8ea469ed4b354b3e746cdf9c1f000c3
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix logic error when saving model subscriptions
Inga Stotland [Tue, 11 Aug 2020 17:18:55 +0000 (10:18 -0700)]
mesh: Fix logic error when saving model subscriptions

This fixes opcode check condition when saving configuration for model
subscriptions: use || instead of && for opcode checking

Change-Id: I5d80c0dad98458ceca565b40c824081e6916f02f
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix element index look up for config model subs
Inga Stotland [Tue, 11 Aug 2020 16:31:34 +0000 (09:31 -0700)]
mesh: Fix element index look up for config model subs

Use element address for looking up element index (subscription
address was erroneously used to perform the lookup).

Change-Id: Ife79cb0bbe7e5495ab55416c968fc97e24302f5e
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix application key binding lookup
Michał Lowas-Rzechonek [Tue, 11 Aug 2020 13:39:07 +0000 (15:39 +0200)]
mesh: Fix application key binding lookup

Because l_queue_find can't distinguish between entry->data equal to zero
and missing entry, has_binding() fails when we bind app key with index
0, via L_UINT_TO_PTR.

Bug has been introduced in commit 1a2a6debd

Change-Id: Ib9b7801c85a95875d9a3d1645f8fe1a35dbd4948
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Refactor heartbeat pub/sub
Inga Stotland [Fri, 7 Aug 2020 01:38:34 +0000 (18:38 -0700)]
mesh: Refactor heartbeat pub/sub

Move heartbeat publication/subscription timers and housekeeping
to net.c since this is where the trigger events and control messages
are handled. Configuration server (cfgmod-server.c) stays
responsible for parsing the set pub/sub message parameters and
assemblying the pub/sub status messages.

Also, make sure that the correct message status is reported.

Change-Id: I3243b98a1f970717b7c48d6a3bbe0344e24fb1ac
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config KR phase messages
Inga Stotland [Fri, 7 Aug 2020 01:38:33 +0000 (18:38 -0700)]
mesh: Clean up handling of config KR phase messages

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Also, this checks for the correct relationship between KR transition
and KR phase values. Correct error codes are sent on unsuccessful
requests and malformed requests are ignored.

Change-Id: I5fa1f9e4d33c99cf5a5788d924951dcf2d1241c2
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config net transmit messages
Inga Stotland [Fri, 7 Aug 2020 01:38:32 +0000 (18:38 -0700)]
mesh: Clean up handling of config net transmit messages

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Change-Id: Idb6fded370e1145fbcc304dba05cfeb324aa813a
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config poll timeout message
Inga Stotland [Fri, 7 Aug 2020 01:38:31 +0000 (18:38 -0700)]
mesh: Clean up handling of config poll timeout message

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Change-Id: I0d04b74c9619e53319f1443a4c331ec33d40ef18
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config relay messages
Inga Stotland [Fri, 7 Aug 2020 01:38:30 +0000 (18:38 -0700)]
mesh: Clean up handling of config relay messages

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Change-Id: I41fca45bc147f8483c9cb0be17976bed5b5eebf1
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config net and app key messages
Inga Stotland [Fri, 7 Aug 2020 01:38:29 +0000 (18:38 -0700)]
mesh: Clean up handling of config net and app key messages

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Change-Id: If73686f788afbcbc0988faaa8631469474280c94
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config publication messages
Inga Stotland [Fri, 7 Aug 2020 01:38:28 +0000 (18:38 -0700)]
mesh: Clean up handling of config publication messages

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Also, return Feature Not Supported errror code when credential
flag is set, but the node does not support LPN feature

Change-Id: I5f18606fa1bcb959fbb62247834a53bb9e193d05
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>