platform/upstream/bluez.git
4 years agotools/mesh: Fix check condition for model ID 28/222928/1
Inga Stotland [Thu, 9 Jan 2020 17:44:09 +0000 (09:44 -0800)]
tools/mesh: Fix check condition for model ID

Use the value of VENDOR_ID_MASK to set/check vendor model
and SIG model IDs

Change-Id: I15a39ea0795fda273b5040db5e3dcc2fcdf5bdea
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotools/mesh: add commands for AppKey Get and NetKey Get 27/222927/1
Inga Stotland [Fri, 10 Jan 2020 03:04:40 +0000 (19:04 -0800)]
tools/mesh: add commands for AppKey Get and NetKey Get

This implements commands to send AppKey Get and NetKey Get messages and
to process AppKey List and NetKey List reponses

Change-Id: If35f360fec2af10a972088a5aaf5aed720fbedae
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix exiting IV_UPD_STATE when receiving first SNB 26/222926/1
Michał Lowas-Rzechonek [Thu, 9 Jan 2020 12:58:59 +0000 (13:58 +0100)]
mesh: Fix exiting IV_UPD_STATE when receiving first SNB

First valid SNB received from the network should cause the node to
switch into IV_UPD_NORMAL state.

Otherwise, it will never try to enter IV Update procedure when sequence
number approaches the IV_UPDATE_SEQ_TRIGGER, because that's only allowed
in IV_UPD_NORMAL.

Change-Id: I532f8b2c7bb2e2dddb7585979f1b77caf4572b49
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Allow apps to receive DevKey messages from external nodes 25/222925/1
Michał Lowas-Rzechonek [Thu, 9 Jan 2020 10:32:22 +0000 (11:32 +0100)]
mesh: Allow apps to receive DevKey messages from external nodes

After introducing "remote" flag for DevKeyMessageReceived in
c8cd5b04ccd865deeb90b70ea649c0b6cc0385e6, we can now allow applications
to received DevKey messages from external addresses as well as from
local ones.

This enables applications to properly implement models using DevKey
security, by accepting only requests with "remote" flag set to false.

Change-Id: I433dd34bc92f79949c5d29322ca9c146027ef48b
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix wholesale deletion of appkeys bound to a netkey 24/222924/1
Inga Stotland [Fri, 10 Jan 2020 01:41:45 +0000 (17:41 -0800)]
mesh: Fix wholesale deletion of appkeys bound to a netkey

When a netkey is deleted all the appkeys bound to this key has
to be deleted as well. This fixes app_key queue manipulation to
avoid issues caused by modifying the queue while iterating over it:
instead of iteration over all the entries, find a first bound key,
delete it, find next... and so on, until there are no bound keys
left in the app_keys queue.

Change-Id: I152cbb3959401e1c333ee3afc5103672d06d8979
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix logic in AppKey deletion 23/222923/1
Inga Stotland [Fri, 10 Jan 2020 01:41:44 +0000 (17:41 -0800)]
mesh: Fix logic in AppKey deletion

When deleting an AppKey from a node, call mesh_config_app_key_del()
only from appkey level (i.e., keep it contained in appkey.c and
remove the duplicate call in node.c)

Also, simplify the node_app_key_delete() argument list.

Change-Id: I9f04abdaeeae2e791b02afafec565d1fcbbb6931
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Implement provisioning loop-back 22/222922/1
Brian Gix [Sun, 12 Jan 2020 16:16:08 +0000 (08:16 -0800)]
mesh: Implement provisioning loop-back

This allows one App using the mesh daemon to provision another.

Change-Id: Ie19181f80648fd76d8690fd79ea1f206d437bd8b
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix BeaconFlags property type 21/222921/1
Michał Lowas-Rzechonek [Wed, 8 Jan 2020 21:51:14 +0000 (22:51 +0100)]
mesh: Fix BeaconFlags property type

This property is an uint8, not a boolean.

Change-Id: I54a558c624ff6c95275fca50afe101f97718549b
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Remove local_iv_index and local_ivu aliases 20/222920/1
Rafał Gajda [Wed, 8 Jan 2020 21:01:03 +0000 (22:01 +0100)]
mesh: Remove local_iv_index and local_ivu aliases

Change-Id: I060b1fff8bdf5fb5cd8175ff6669885b64dc568a
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix IV recovery 19/222919/1
Rafał Gajda [Wed, 8 Jan 2020 21:01:02 +0000 (22:01 +0100)]
mesh: Fix IV recovery

This patch fixes saving IV received in SNB to storage.

Previously after creating new node with IV 0 (or loading node with
IV > 0 but after long inactivity) first received SNB should update IV
(and reset sequence number to 0 if necessary).

The bug would prevent new IV being saved in storage which resulted in
sequence number being set to 0 on first SNB received after every daemon
reset but IV never being updated.

Change-Id: I3767a14a408a33633c374fcdcc08cb6ab68bd9a7
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Remove misleading DEFAULT_CRPL from node.c 18/222918/1
Michał Lowas-Rzechonek [Wed, 8 Jan 2020 15:19:41 +0000 (16:19 +0100)]
mesh: Remove misleading DEFAULT_CRPL from node.c

Change-Id: I9a53d0714ed496d43b61a82d9225c96054d598ef
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix node reset 17/222917/1
Michał Lowas-Rzechonek [Tue, 7 Jan 2020 23:05:05 +0000 (00:05 +0100)]
mesh: Fix node reset

Instead of stopping the daemon, just remove the node.

Change-Id: Ica7a36a698190a0b92f6ce688ef37d52db37c0f1
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Style fix 16/222916/1
Inga Stotland [Mon, 6 Jan 2020 05:50:49 +0000 (21:50 -0800)]
mesh: Style fix

This fixes style issues: spaces -> tabs, alignment.

Change-Id: I5bf6f0fe51f500e740910d43140f0c8cb964d121
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomeshctl: Fix meshctl crash 15/222915/1
Anurag Biradar [Fri, 6 Dec 2019 04:13:36 +0000 (09:43 +0530)]
meshctl: Fix meshctl crash

list entry was not updated properly during flushing of packets

<call stack>
flush_pkt_list (list=0x638b40 <net+64>) at tools/mesh-gatt/net.c:1199
net_session_close (data_in=<optimized out>) at tools/mesh-gatt/net.c:1979
disconnect_device (cb=cb@entry=0x0, user_data=user_data@entry=0x0)
  at tools/meshctl.c:791
cmd_start_prov (argc=<optimized out>, argv=0x6a9fb0)
  at tools/meshctl.c:1789

Change-Id: I5e7827fe7faf8e3611789123373fd5074aabc46b
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomeshctl: Fix infinite sock read 14/222914/1
Anurag Biradar [Fri, 6 Dec 2019 04:13:04 +0000 (09:43 +0530)]
meshctl: Fix infinite sock read

When a stream socket peer has performed an orderly shutdown,
then return value will be 0.

Change-Id: Ie94d8b8ade7b7eb94294ca5051537ce79e6a488f
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agoFix adapter_le_enable_privacy for disable functionality 13/222413/3
himanshu [Tue, 14 Jan 2020 13:09:31 +0000 (18:39 +0530)]
Fix adapter_le_enable_privacy for disable functionality

Change-Id: Icc451a464a585d0692f49fd89f8903e4f966a140
Signed-off-by: himanshu <h.himanshu@samsung.com>
4 years agoFix: Connectable device removed after scan stopped 44/222044/1
injun.yang [Thu, 9 Jan 2020 00:38:09 +0000 (09:38 +0900)]
Fix: Connectable device removed after scan stopped

Check the adv type instead of adv flag

Change-Id: Ie579c9629503163c00e03664c1cb6028c7cfd181

4 years agomesh: Add interface for dbus in bluetooth-mesh.conf 24/221724/1
Abhay Agarwal [Mon, 6 Jan 2020 11:17:51 +0000 (16:47 +0530)]
mesh: Add interface for dbus in bluetooth-mesh.conf

Dbus interface="org.freedesktop.DBus.ObjectManager" is being used
while getting managed objects.

Change-Id: I3a528e8ce8bd45cd9f0d7c1968eeb9da0cc51ab5
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Base config json code on newer version of json-c 15/221715/1
Inga Stotland [Fri, 20 Dec 2019 19:13:29 +0000 (11:13 -0800)]
mesh: Base config json code on newer version of json-c

This removes a roundabout logic that was required to delete
a json entry from a json array using libjsonc utilities.
A new API function, json_object_array_del_idx(), implemented in
json-c version 0.13 simplifies array entry removal to one call.

Also, add requirement to configure.ac for json-c version >= 0.13

Change-Id: I4c1e90d7dedd64404ad2404070d51a6a224677cb
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Start link establishment timer of 60 sec 14/221714/1
Prathyusha N [Fri, 6 Dec 2019 04:08:39 +0000 (09:38 +0530)]
mesh: Start link establishment timer of 60 sec

5.3.2 of Mesh Profile Bluetooth specification:
To open a link, the provisioner shall start the link establishment
timer, set to 60 seconds, and then shall start sending Link Open
messages.

On timeout, close indication will be sent. Provisioner cancels the
Link Establishment timer, when the link is open i.e. in pb_adv_tx().

Change-Id: I7e39904ef6eb85e18f6675a3de8d02a818d16146
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Recognize SNBs in SecondsSinceLastHeard 13/221713/1
Brian Gix [Fri, 20 Dec 2019 20:13:40 +0000 (12:13 -0800)]
mesh: Recognize SNBs in SecondsSinceLastHeard

Timestamp is taken on each OTA beacon reception, and considered in the
SecondsSinceLastHeard property.

Change-Id: I292b1cadad150e1bf10ce40bd413af5e46be17d8
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Deliver newly composed SNBs to local nodes 12/221712/1
Brian Gix [Fri, 20 Dec 2019 20:13:39 +0000 (12:13 -0800)]
mesh: Deliver newly composed SNBs to local nodes

Change-Id: I65b649ac0cf8495ab44aa32602b4ba42e815554a
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agoTODO: Update mesh section 11/221711/1
Inga Stotland [Fri, 20 Dec 2019 06:18:29 +0000 (22:18 -0800)]
TODO: Update mesh section

Change-Id: I545d67f78a1ecccde50733c347ea5208dcac0f9c
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix getting managed objects from ObjectManager 10/221710/1
Michał Lowas-Rzechonek [Tue, 17 Dec 2019 14:54:42 +0000 (15:54 +0100)]
mesh: Fix getting managed objects from ObjectManager

D-Bus spec mandates that GetManagedObjects method of
org.freedesktop.DBus.ObjectManager interface returns *children* only:

https://dbus.freedesktop.org/doc/dbus-specification.html
> All returned object paths are children of the object path implementing
> this interface, i.e. their object paths start with the ObjectManager's
> object path plus '/'

Both test scripts and ELL abuse this by returning application interfaces
via ObjectManager attached to the same path, but other D-Bus
implementations do not, making Attach() fail because mandatory
interfaces cannot be found.

This patch fixes the issue by scanning hierarchy returned by
GetManagedObjects for object implementing org.bluez.mesh.Application1
interface and keeping that as node's app_path.

Change-Id: Ia05f5b2a8da2ac4f77340a46e6eb948f85cd97a2
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotools/mesh-cfgclient: Fix agent method signatures 09/221709/1
Inga Stotland [Fri, 22 Nov 2019 16:23:31 +0000 (08:23 -0800)]
tools/mesh-cfgclient: Fix agent method signatures

This adds return parameter name to PromptNumeric and PromptStatic
method signatures. Also, style fixes.

Change-Id: I4516f93cd571bcdb8fff82dcc6b33b427b19563b
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotools/mesh-cfgclient: Add full support inOOB and outOOB 08/221708/1
Inga Stotland [Sat, 9 Nov 2019 01:33:53 +0000 (17:33 -0800)]
tools/mesh-cfgclient: Add full support inOOB and outOOB

Add support for all the forms of inOOB and outOOB prompt and display
requests from the Provisioner for a remote device:
"push", "twist", "blink", "beep", "vibrate", "in-numeric",
"out-numeric", "in-alpha", and "out-alpha"

Change-Id: Iad1d272da74bec80e1088ec1aea32ee9966fdd4c
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Inform application about model subscriptions 07/221707/1
Michał Lowas-Rzechonek [Tue, 26 Nov 2019 14:54:01 +0000 (15:54 +0100)]
mesh: Inform application about model subscriptions

Change-Id: I1df8fa811482a2aab8f9d2be6c26957e86168711
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Provide destination address in MessageReceived API 06/221706/1
Michał Lowas-Rzechonek [Tue, 26 Nov 2019 14:54:00 +0000 (15:54 +0100)]
mesh: Provide destination address in MessageReceived API

Change-Id: I90cd462038491612e12a4684871cc305683834f6
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix test-join to include mandatory VendorModels property 05/221705/1
Michał Lowas-Rzechonek [Tue, 26 Nov 2019 14:53:59 +0000 (15:53 +0100)]
mesh: Fix test-join to include mandatory VendorModels property

Change-Id: I61cb48d751a7049ca17c0b85a74a8dd693f8ab5f
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Ignore Composition features during attach 04/221704/1
Brian Gix [Mon, 25 Nov 2019 18:58:42 +0000 (10:58 -0800)]
mesh: Ignore Composition features during attach

Node Features are currently all under the control of the mesh daemon,
and should be ignored when attaching.  Eventually all Composition
feature bits will be controlled by a master mesh.conf file, overriding
any local node specific settings.

Change-Id: I6aec29942e0ad3416d6fd1e64a87604012acd13c
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix dbus management interface input params 03/221703/1
Rafał Gajda [Wed, 20 Nov 2019 09:09:29 +0000 (10:09 +0100)]
mesh: Fix dbus management interface input params

Previously input parameters in "org.bluez.mesh.Management1"
would not register properly, being shifted by one:
     <method name="ImportRemoteNode">
 <arg name="" type="q" direction="in"/>
 <arg name="primary" type="y" direction="in"/>
 <arg name="count" type="ay" direction="in"/>
 </method>

 This fixes this issue:
 <method name="ImportRemoteNode">
 <arg name="primary" type="q" direction="in"/>
 <arg name="count" type="y" direction="in"/>
 <arg name="dev_key" type="ay" direction="in"/>
 </method>

Change-Id: I89bc4b8210fdeaf5494da5e0637e1ba95f1a3aa7
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix inOOB and outOOB agent handling on prov initiate 02/221702/1
Brian Gix [Fri, 15 Nov 2019 22:52:09 +0000 (14:52 -0800)]
mesh: Fix inOOB and outOOB agent handling on prov initiate

This code fixes the Provisioner Initiator role so that the following
Out-of-Band agent calls are made correctly, and their results handled
properly:

"push", "twist", "blink", "beep", "vibrate", "in-numeric",
"out-numeric", "in-alpha", "out-alpha"

Change-Id: Ice602368641d25ddd0cb8c1e6591401d6c627efe
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix crash after deleting all subscriptions 01/221701/1
Rafał Gajda [Mon, 18 Nov 2019 10:51:18 +0000 (11:51 +0100)]
mesh: Fix crash after deleting all subscriptions

Change-Id: I5c05a9c804d6772fff5a76d366fb1fba844c5710
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Correct typo in cfg_cmd table 00/221700/1
Steve Brown [Mon, 18 Nov 2019 00:09:51 +0000 (19:09 -0500)]
mesh: Correct typo in cfg_cmd table

Change-Id: I1d57551387ea2a595e1f02660260cec102fa0b99
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Cancel unprovisioned scan on exit or app disconnect 99/221699/1
Inga Stotland [Tue, 12 Nov 2019 06:22:05 +0000 (22:22 -0800)]
mesh: Cancel unprovisioned scan on exit or app disconnect

If a provisioner app quits or the daemon is stopped while there's
an active scan for unprovisioned devices in progress, the scan needs
to be explicitly canceled.

Change-Id: I811ef47457d178cea1c135a1070d17479ca95339
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Add missing property interface to node objects 98/221698/1
Michał Lowas-Rzechonek [Tue, 12 Nov 2019 10:43:27 +0000 (11:43 +0100)]
mesh: Add missing property interface to node objects

Change-Id: I4e57e4e0def574511f3e72a048f56f52b1764da7
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix io inititalization sequence 55/221455/1
Inga Stotland [Thu, 14 Nov 2019 23:52:10 +0000 (15:52 -0800)]
mesh: Fix io inititalization sequence

This introduces a chain of callbacks to indicate whether mesh io
is initialized and mesh network is ready to use.

This fixes the reported situation when the receive callbacks
were setup before the HCI was fully initialized. In other words,
BT_HCI_CMD_LE_SET_SCAN_PARAMETERS was called before BT_HCI_CMD_RESET
and, as the result, the callback issueing BT_HCI_CMD_LE_SET_SCAN_ENABLE
command was not called.

Change-Id: Ib9f8b3e2d4e3882586244c4cae2885cb34b52907
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agoRemove redundant debug message 43/221243/1
injun.yang [Mon, 30 Dec 2019 08:46:21 +0000 (17:46 +0900)]
Remove redundant debug message

Change-Id: I7c40721f4b30aaa45d80abb517b26aed4bf72cd9

4 years agoAdjust the position of GCC build option 85/221185/1 accepted/tizen/unified/20200101.120636 submit/tizen/20191230.003618
DoHyun Pyun [Mon, 30 Dec 2019 04:21:38 +0000 (13:21 +0900)]
Adjust the position of GCC build option

Change-Id: Ifb5ab3083ade1638b80a25167314d5ffb118a7f2
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
4 years agoAdd the build exception for GCC9 60/221160/1
DoHyun Pyun [Mon, 30 Dec 2019 00:29:47 +0000 (09:29 +0900)]
Add the build exception for GCC9

Change-Id: Iec7c24e4db833b7c49ff24a6feaea206910d624e
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
4 years agoFix build issue for strncpy 40/221140/1
Amit Purwar [Fri, 27 Dec 2019 10:49:45 +0000 (16:19 +0530)]
Fix build issue for strncpy

Change-Id: Ife86ad79f4a271179a184faf47e489fa88c2f0fa
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
4 years agoMerge "Support the keyboard plugin" into tizen
Pyun DoHyun [Tue, 24 Dec 2019 03:25:57 +0000 (03:25 +0000)]
Merge "Support the keyboard plugin" into tizen

4 years agoSupport the keyboard plugin 35/220835/1
DoHyun Pyun [Mon, 23 Dec 2019 23:42:10 +0000 (08:42 +0900)]
Support the keyboard plugin

Change-Id: Ia5a640caf07cba2a355af94998aa9000500bb82a
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
4 years agoshared/mainloop: Add ell-based mainloop implementation 43/220743/1
Inga Stotland [Sun, 11 Aug 2019 07:00:45 +0000 (00:00 -0700)]
shared/mainloop: Add ell-based mainloop implementation

This adds implementation of wrapper mainloop functions to interact with
ell main APIs, enabling support for the applications that link with ell
library and use mainloop functionality.

Change-Id: I9a52c5589097d0acb7a488af88600e9a99d38070
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agoMerge branch 'meshd_integrate' into tizen 09/220609/1 accepted/tizen/unified/20191220.123149 submit/tizen/20191220.041051
DoHyun Pyun [Fri, 20 Dec 2019 03:53:56 +0000 (12:53 +0900)]
Merge branch 'meshd_integrate' into tizen

Change-Id: I1d361e7c478b6a61680f96e6e9724ad96f82bc27

4 years agobuild: Include dependencies for ell/settings.[ch]
Brian Gix [Wed, 4 Dec 2019 19:15:16 +0000 (11:15 -0800)]
build: Include dependencies for ell/settings.[ch]

Including settings.[ch] in a build requires the following chained
dependencies:
PEM
CERT
KEY
PKSC5
BASE64

Change-Id: I29e6478c9c445cbf30b3681a5248185fdf1c19eb
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add mesh-main.conf file with general mesh configuration
Inga Stotland [Wed, 11 Dec 2019 00:56:16 +0000 (16:56 -0800)]
mesh: Add mesh-main.conf file with general mesh configuration

This adds key file with default settings for the mesh daemon.
The following settings are included:

    Beacon:          Default setting for to indicate whether
                     secure network beaconing is enabled for a
                     node whose Beacon state hasn't been configured
                     by a configuration client, i.e., this setting
                     apllies to a newly provisioned, created or
                     imported node.

    Relay:           Default setting for supporting relay

    Friendship:      Default setting for supporting Friendship

    CRPL:            Default depth of replay protection list.

    FriendQueueSize: Default size of friend queue: the number
                     of messages that each Friend node can store
                     for the Low Power node.

    ProvTimeout:     Provisioning timeout in seconds.

Change-Id: Ia5f40ef9d5d866e8d94a2ff5cac7cf6339015eca
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh-cfgclient: add friend get/set commands
Aurelien Jarno [Tue, 10 Dec 2019 22:22:50 +0000 (23:22 +0100)]
tools/mesh-cfgclient: add friend get/set commands

Add friend-get and friend-set commands as per Mesh Profile 4.3.2.55,
4.3.2.56 and 4.3.2.57.

Change-Id: I4375267c2b4a18a68ebafc6610bf22e067ecd663
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh-cfgclient: add network transmit get/set commands
Aurelien Jarno [Mon, 11 Nov 2019 19:55:30 +0000 (20:55 +0100)]
tools/mesh-cfgclient: add network transmit get/set commands

Add network-transmit-get and network-transmit-set commands as per
Mesh Profile 4.3.2.69, 4.3.2.70 and 4.3.2.71.

Change-Id: I622480b77bd07d474d4ae8259e0edc1eda552471
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Cleanup unused LPN code
Brian Gix [Fri, 13 Dec 2019 20:25:02 +0000 (12:25 -0800)]
mesh: Cleanup unused LPN code

The daemon does not support the LPN role, and this is unreferenced code.

Change-Id: I8e201453bec2800c27e57d856b1258c127a67388
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Refactor Secure Network Beaconing
Brian Gix [Fri, 13 Dec 2019 20:15:05 +0000 (12:15 -0800)]
mesh: Refactor Secure Network Beaconing

The daemon handles multiple nodes, that may or may not be on the same
mesh network.  While each node my be seperately configured to beacon or
not beacon, there is nothing gained (except redundent traffic) for each
node to beacon seperately.  Beaconing is therefore centralized with the
Network Key the SNB represents, with each *received* beacon delivered
to each node. But for SNBs generated, we keep a count of how many nodes
want beacons sent for a specific key. If 1 or more, we beacon, if 0
nodes want the beacon sent, then we do not beacon.

Change-Id: Id186b6e93d70b09553d585ee9cc4d1b8c7e8b268
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add more checks for element properties
Inga Stotland [Wed, 11 Dec 2019 23:28:47 +0000 (15:28 -0800)]
mesh: Add more checks for element properties

This adds consistency checks for mandatory properties on
org.bluez.mesh.Element1 interface:
    - disallow duplicate models on the same element
    - disallow elements with duplicate indices
    - disallow configuration server model on any element but primary

Change-Id: If4174021b50a0f05c7c25911054cfb98042a06c8
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Remove redundant code in mesh IO mgmt
Inga Stotland [Tue, 10 Dec 2019 23:06:00 +0000 (15:06 -0800)]
mesh: Remove redundant code in mesh IO mgmt

This removes unnecessary housekeeping for hci controllers

Change-Id: I38cf74c18d447d5df6ad340e8cbe0e8f40640122
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Initialize net modes based on node configuration
Inga Stotland [Fri, 6 Dec 2019 20:57:49 +0000 (12:57 -0800)]
mesh: Initialize net modes based on node configuration

This correctly initializes net settings related to node features
based on node configuration: either defaults in the case of
a newly node created/provisioned/imported node or the configured
values read from stored existing node.

Change-Id: Id0d7a7e2ba2ea7e4dc3cdc17b241250581a14af1
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Clean up node.c
Inga Stotland [Fri, 6 Dec 2019 20:57:48 +0000 (12:57 -0800)]
mesh: Clean up node.c

This change makes the node initialization a bit easier to follow.
Replace if-else with switch when processing request type, descriptive
function names, more predictable code flow.

Change-Id: Id81f673224878a64d3ff341c7eb574a78bd8be0b
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agoAdd custom uuid support to trusted profile
Biman Paul [Tue, 17 Dec 2019 08:18:57 +0000 (17:18 +0900)]
Add custom uuid support to trusted profile

[Model] Z400F
[BinType] AP
[Customer] OPEN

[Issue#] NA
[Request] Monitoring Test
[Occurrence Version] Z4 Daily

[Problem] SPP authorization request is always shown
even if we select "do not show again".
[Cause & Measure] We are not marking SPP uuid as trusted
Measure: Add custom uuid support to trusted profile
[Checking Method] Request SPP connect from remote device

[Team] Basic Connection
[Developer] Biman Paul <biman.paul@samsung.com>
[Solution company] Samsung
[Change Type] N/A

Change-Id: I9bb537cd0da01b1f86a99f7b4f1c8765c409ce6f
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
4 years agomesh: Delete unused function
Inga Stotland [Fri, 6 Dec 2019 20:57:47 +0000 (12:57 -0800)]
mesh: Delete unused function

This removes node_parse_composition() implementation as it is not used
anywhere in the rest of the code base.

Change-Id: Ifb628a4c8cd447f327cfd560b631b04f435837c6
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh-cfgclient: Fix appkey/netkey commands
Inga Stotland [Tue, 10 Dec 2019 17:45:22 +0000 (09:45 -0800)]
tools/mesh-cfgclient: Fix appkey/netkey commands

This fixes the checks for the presence of AppKeys and Netkeys.

Change-Id: I095c36f5be5846b789c56673fed8deb4d882cf7e
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh-cfgclient: Disallow sending a non-existing key
Inga Stotland [Sat, 7 Dec 2019 06:12:45 +0000 (22:12 -0800)]
tools/mesh-cfgclient: Disallow sending a non-existing key

Prior to sending either NetKeyAdd or AppKeyAdd message to a
remote node, check if the key exists locally.

Change-Id: I7ba29c91b15ccbffbdffa0ef206e659843f955ea
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix memory leak in Join() API call
Brian Gix [Tue, 3 Dec 2019 21:04:10 +0000 (13:04 -0800)]
mesh: Fix memory leak in Join() API call

Change-Id: I69da675134c83fea589056e52882df5339ec9092
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Rearrange PB-ACK for possible session close
Brian Gix [Tue, 3 Dec 2019 21:04:09 +0000 (13:04 -0800)]
mesh: Rearrange PB-ACK for possible session close

In certain circumstances, reception of PB-ADV messages may trigger
session close. This rearrange ACKs new verified messages before
performing call-back to avoid situations where the session no longer
exists after the message has been handled.

This caused static analysis errors during provisioning, which are now
addressed.

Change-Id: I272e8066f307374c848cb78326259b49acaf4e20
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix to send close indication on timeout
Prathyusha N [Tue, 3 Dec 2019 10:01:25 +0000 (15:31 +0530)]
mesh: Fix to send close indication on timeout

If pb_session is freed in timeout, close indication will not be sent.
pb_session is freed in pb_adv_unreg() and hence removed from tx_timeout.
Added acceptor_free() in acp_prov_close() to ensure pb_session is freed.

Change-Id: I4649bfa038cf14fb613f13c6b910314f7f710403
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix string of public-oob and static-oob
Prathyusha N [Tue, 3 Dec 2019 10:01:23 +0000 (15:31 +0530)]
mesh: Fix string of public-oob and static-oob

Fix string typo as per mesh-api.txt

Change-Id: I58742118a47a0b304468bcf6245c4871f692b75b
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix invalid transaction number in PROV_INVITE
Prathyusha N [Tue, 3 Dec 2019 10:01:24 +0000 (15:31 +0530)]
mesh: Fix invalid transaction number in PROV_INVITE

For initiator, transaction number starts from 0x00 where as for acceptor
transaction number starts from 0x80. Since transaction number is
pre-incremented and sent in every packet, initialize it with 0xFF for
initiator and 0x7F for acceptor.

Change-Id: I833335c962f06b6a58ff70d63c603938d335005c
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix invalid netkey index in appkey add/delete
Nagaraj D R [Tue, 3 Dec 2019 09:53:27 +0000 (15:23 +0530)]
mesh: Fix invalid netkey index in appkey add/delete

8 LSbs of netkey index should be packed into the first octet

Change-Id: Ia2226334e4ef9702e44a9fa96a28e8273780ac04
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: fix (re)transmit count & interval steps
Aurelien Jarno [Mon, 11 Nov 2019 19:54:06 +0000 (20:54 +0100)]
mesh: fix (re)transmit count & interval steps

The Foundation Model Layer uses little endian ordering. As a
consequence the (re)transmit count and interval steps in the Config
Relay, Config Model Publication and Config Network Transmit messages
use the lower 3 bits for the (re)transmission count and the higher 5
bits for the interval steps.

The figure 4.5 in section 4.3.2.16 of the Mesh Profile Bluetooth
Specification provides a good clarification.

This patch therefore fixes those messages for both the daemon and
configuration client parts.

Change-Id: I3473d43c2ca9a7de79faa93c6d0c6953377d0f31
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Friendship clean-up and rewrite
Brian Gix [Wed, 27 Nov 2019 21:39:39 +0000 (13:39 -0800)]
mesh: Friendship clean-up and rewrite

Friendship support re-written such that it can now support multiple
nodes (on multiple mesh networks) as friends to remote Low Power Nodes
(LPNs).  Validated to properly respond to Friend Requests when enabled,
and a hard coded Friend Queue size of 32 (FRND_CACHE_MAX).

Change-Id: Ia50bba5f000eb9bd30e5a7d54045a22d2978428a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: clean-up Recieved Message debug output
Brian Gix [Wed, 27 Nov 2019 21:39:38 +0000 (13:39 -0800)]
mesh: clean-up Recieved Message debug output

For each received packet, this change limits outputing the encrypted
version once, and the decrypted version once per applicable local node.

Change-Id: Ib1d237e5aeef927a20343be2877a98bd3a36ed14
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh-cfgclient: add unbind command
Aurelien Jarno [Mon, 11 Nov 2019 20:20:09 +0000 (21:20 +0100)]
tools/mesh-cfgclient: add unbind command

This reuses the existing cmd_bind for both opcodes. cmds[] already has
code to handle it.

Change-Id: I7152d6170b73c6438caf72692564c87c08e8bcfe
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: fix sending messages to group addresses
Aurelien Jarno [Mon, 11 Nov 2019 14:10:46 +0000 (15:10 +0100)]
mesh: fix sending messages to group addresses

When sending a message to a group address (either virtual or fixed), it
has to be sent OTA even if successfully enqueued to an internal model.

Change-Id: I29a5d4a6a8aee3c906c0f544c8b30f8a3c8e1f29
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix clean up after AddNode method
Inga Stotland [Sat, 9 Nov 2019 00:07:00 +0000 (16:07 -0800)]
mesh: Fix clean up after AddNode method

This fixes the cleanup routine that is called after AddNode method
on org.bluez.mesh.Manager1 interface is complete: do not remove
the agent associated with the Provisioner (owner of Manager interface).

Change-Id: I8048b820a8e7f29e5e3d9c3001e6d19111af7733
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh-cfgclient: fix binaries and config name in README
Aurelien Jarno [Thu, 7 Nov 2019 12:16:40 +0000 (13:16 +0100)]
tools/mesh-cfgclient: fix binaries and config name in README

This patch fixes the mesh-cfgclient README file:
- The configuration directory is meshcfg not mesh-cfgcli
- The home directory is looked up using $HOME not using /home/$USER
- The binary is called mesh-cfgclient, not mesh-config
- The -c option takes a config file path, not the directory where the
  config file is stored.

Change-Id: I44b259458876d4d954346b57d43e5f77af3af018
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh-cfgclient: Add README file
Inga Stotland [Fri, 1 Nov 2019 18:57:29 +0000 (11:57 -0700)]
tools/mesh-cfgclient: Add README file

Change-Id: Ie3f292a17cbf2af897b079a8b08abd474ae16cab
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh: add initial support for config storage
Inga Stotland [Fri, 1 Nov 2019 18:57:28 +0000 (11:57 -0700)]
tools/mesh: add initial support for config storage

This adds support for storing the state of a mesh network.
The configuration is written out in JSON format. The initial
configuration file is generated automatically upon the
successful completion of "create" command form the main menu.

Change-Id: I2a8731d44110a83d6a620c6c6b28930fad599f38
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh-cfgclient: Command line option for config
Inga Stotland [Fri, 1 Nov 2019 18:57:27 +0000 (11:57 -0700)]
tools/mesh-cfgclient: Command line option for config

This adds "-c" option to specify full path to configuration file.
If the path is not provided, the application will attempt to open
in the following order:
1) $XDG_CONFIG_HOME/meshcfg/config_db.json
2) $HOME/meshcfg/config_db.json

if the file does not exist, it will be generated for a newly created
network, i.e., upon successful completion of "create" command.

Change-Id: Ica273fe3803a09ab8d54434dbbcb586c0620f16a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh-cfgclient: Add timeout for expected response
Inga Stotland [Fri, 1 Nov 2019 18:57:26 +0000 (11:57 -0700)]
tools/mesh-cfgclient: Add timeout for expected response

This adds a pending request queue for the issued commands awaiting
response from a remote config server. The tool forces "single-issue"
of a config command, i.e. only one command that has a specified return
type is allowed to be outstanding per a remote node address.
That is, if AppKeyAdd command to a node is pending response, the tool
disallows sending another AppKeyAdd, AppKeyUpdate or AppKeyDelete to
the same address until response timeout expires (notification will
be displayed).
The default response timeout is set to 2 seconds and is configurable
by "timeout" command.

Change-Id: I4611df3e02faf1a5310faec16cd714f7cde5d013
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh-cfgclient: Add config menu key commands
Inga Stotland [Fri, 1 Nov 2019 18:57:25 +0000 (11:57 -0700)]
tools/mesh-cfgclient: Add config menu key commands

This adds implementation for config client commands to add/update
NetKeys and AppKeys on a remote node.

Change-Id: I22eec3e0bcce0e6f1a2ccc4cd32970049279b8fa
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh-cfgclient: Commands for Management iface methods
Inga Stotland [Fri, 1 Nov 2019 18:57:24 +0000 (11:57 -0700)]
tools/mesh-cfgclient: Commands for Management iface methods

This adds complete list of commenads that excercise calls to
org.bluez.mesh.Manager1 methods:
"appkey-create": CreateAppKey()
"appkey-import": ImportAppKey()
"appkey-update": UpdateAppKey()
"appkey-delete": DeleteAppKey()
"subnet-create": CreateSubnet()
"subnet-import": SubnetImport()
"subnet-update": SubnetUpdate()
"subnet-delete": SubnetDelete()
"subnet-set-phase": SetKeyPhase()
"node-import": ImportRemoteNode()
"node-delete": DeleteRemoteNode()

Change-Id: I814e21afb5e4362b5512bbb865e0c7c1181d2802
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh: move remote node processing to a separate file
Inga Stotland [Fri, 1 Nov 2019 18:57:23 +0000 (11:57 -0700)]
tools/mesh: move remote node processing to a separate file

This confines the functionality related to remote node
housekeeping into a separate file remote.c

Change-Id: I45230ddfff9b63c4c48a622559b039df11282f2a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Enable mesh-cfgclient build
Anupam Roy [Tue, 17 Dec 2019 20:17:37 +0000 (01:47 +0530)]
mesh: Enable mesh-cfgclient build

Change-Id: Ie826322bfdac767c6ac4bb81a21ce71024ea1424
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools: Add mesh-cfgclient tool
Inga Stotland [Fri, 1 Nov 2019 18:57:22 +0000 (11:57 -0700)]
tools: Add mesh-cfgclient tool

This adds a tool that allows to create  mesh networks
opreating over advertising (PB-ADV) provisioning bearer.
The main commands are:
create - Create new mesh network with one initial node
discover-unprovisioned - Look for devices to provision
list-unprovisioned - List unprovisioned devices
provision - Initiate provisioning
list-nodes - List remote mesh nodes

Change-Id: I04a3b16038933e374e6447818952e9d7f55e7475
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh: Move meshctl specific files to mesh-gatt
Inga Stotland [Fri, 1 Nov 2019 18:57:21 +0000 (11:57 -0700)]
tools/mesh: Move meshctl specific files to mesh-gatt

Change-Id: I856ab403aefe0058dc5543d8812fd37751a57e75
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotools/mesh: Remove extra dependencies from agent.c
Inga Stotland [Fri, 1 Nov 2019 18:57:20 +0000 (11:57 -0700)]
tools/mesh: Remove extra dependencies from agent.c

This removes dependency on glib and mesh/util.c.
Also, fixes few style glitches.

Change-Id: I74b63e7b293a34ed35e210cbc0e5dd2170b138a7
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add authorization checks for Manager iface methods
Inga Stotland [Wed, 30 Oct 2019 06:27:49 +0000 (23:27 -0700)]
mesh: Add authorization checks for Manager iface methods

This adds a check for org.bluez.mesh.Manager1 interface calls to
validate that a message sender, i.e. thatt the sender is the original
owner of the node object generated on Attach() method call.
If the check fails, org.bluez.mesh.Error.NotAuthorized is returned.

Change-Id: Ibf46b6e27df02ce2a62a84f2f68c4e7639a0889f
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add ELL source and headers
Anupam Roy [Tue, 17 Dec 2019 19:05:15 +0000 (00:35 +0530)]
mesh: Add ELL source and headers

Change-Id: I6600cf2244463c1e8371574ddeabaccb8bb9b3ef
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Adjust for changed l_dbus_object_manager_enable parameters
Marcel Holtmann [Thu, 31 Oct 2019 06:33:48 +0000 (07:33 +0100)]
mesh: Adjust for changed l_dbus_object_manager_enable parameters

Change-Id: I4921c56e642c16e2c1ef3f6a60ab8238e262419a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add ELL changes
Anupam Roy [Tue, 17 Dec 2019 18:05:20 +0000 (23:35 +0530)]
mesh: Add ELL changes

This patch refers following upstream patch from
ELL project.

=======================================================
commit 2088ddd7437f4ae544917f7634967746b36c3c5d
Author: Denis Kenzior <denkenz@gmail.com>
Date:   Mon Oct 28 13:25:05 2019 -0500

    dbus: Add ability to put ObjectManager on any path
========================================================

Change-Id: Ieacea5c8e1f898d9bc123c582feb9f09f9b36bf6
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix reading/writing key indices
Inga Stotland [Sun, 20 Oct 2019 21:29:49 +0000 (14:29 -0700)]
mesh: Fix reading/writing key indices

This fixes inconsistency when reading/writing NetKey and AppKey
indices to/from JSON config storage:
- when writing, convert an integer to hex string
- when reading, convert hex string to uint16 integer

Change-Id: Iaefe05c061f6c62d9fdc9835457e3ff75d84de1a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Implement AddAppKey and AddNetKey methods
Inga Stotland [Thu, 17 Oct 2019 21:55:00 +0000 (14:55 -0700)]
mesh: Implement AddAppKey and AddNetKey methods

This adds implementation for the following methods on
org.bluez.mesh.Node1 interface:
void AddNetKey(object element_path, uint16 destination,
uint16 subnet_index, uint16 net_index, boolean update)
void AddAppKey(object element_path, uint16 destination,
uint16 app_index, uint16 net_index, boolean update)

Change-Id: I31ebf4f126f02f7b16e10c718214e21abd9523af
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add provisioner confirmation
Inga Stotland [Mon, 14 Oct 2019 21:47:58 +0000 (14:47 -0700)]
mesh: Add provisioner confirmation

This adds codes to send a confirmationfrom provisioner's side
after receiving a callback from a provisioning agent.

Change-Id: Ibb0293d9736e8cb2b735cacce89d389831415bbd
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agounit: Make mesh tests conditional
Luiz Augusto von Dentz [Wed, 16 Oct 2019 08:57:23 +0000 (11:57 +0300)]
unit: Make mesh tests conditional

Mesh code can be disabled with use of --disable-mesh.

Change-Id: Ie268fab60a5199d730561c95ba9fd9e2d87280b3
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Secure Beacon - IV_Index/Key Refresh re-write
Brian Gix [Thu, 10 Oct 2019 22:58:52 +0000 (15:58 -0700)]
mesh: Secure Beacon - IV_Index/Key Refresh re-write

This is a major rewrite of Secure Network Beacon (SNB) handling
that includes:

* Seperating Key Refresh from IV_Index handling

  This is a clearer handling of the two features. Although both features
  are represented in SNB's, they run independantly.

* Creating a Seperate IV_Index initialization and updating state
  distinct from the current values sent and received in SNBs.

  If a restart occured during an IV Update procedure (96 hours long)
  the IVU bit got lost, and Sequence number resetting was not done
  correctly.

* Assuring that all Nodes handled by daemon receive each incoming
  beacon. SNB handling previously stopped after the first node
  successfuly handled it, although the SNB may be valid for many local
  nodes.

Change-Id: Ia447518da6800f42b2c316406a4d48879a05a4de
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agounit: Fix valgrind errors in test-mesh-crypto
Brian Gix [Fri, 11 Oct 2019 17:31:29 +0000 (10:31 -0700)]
unit: Fix valgrind errors in test-mesh-crypto

Two HEAP errors, and one error caused by missing checksum data.

Change-Id: I383a43b5f7669b8e7efb3dd0c7bd1142f916c46a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix ignored return value
Michał Lowas-Rzechonek [Tue, 12 Nov 2019 14:54:25 +0000 (15:54 +0100)]
mesh: Fix ignored return value

This fixes the following build error when compiling in maintainer mode:

mesh/keyring.c: In function ‘finalize’:
mesh/keyring.c:142:8: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
  (void)write(fd, &key, sizeof(key));
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: I0fb908ee59ae2db2dcd682c342dd94107419ab89
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agounit: Add Mesh Crypto tests from Mesh Profile Spec
Brian Gix [Thu, 3 Oct 2019 20:44:05 +0000 (13:44 -0700)]
unit: Add Mesh Crypto tests from Mesh Profile Spec

This unit test will be grown over time to include tests formed from the
sample data in the Bluetooth Mesh Profile specification (Currently at
version v1.0.1).

Currently it includes test cases for the following sets of sample data:
Sections 8.1.1-6
Sections 8.2.1-6
Sections 8.3.1-11
Section 8.4.3
Section 8.6.2

Change-Id: I70b90d83e997b2c711433a2a131a4cc6ef3bca3f
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix segmentation fault on Join() call
Inga Stotland [Tue, 1 Oct 2019 18:51:08 +0000 (11:51 -0700)]
mesh: Fix segmentation fault on Join() call

This fixes the following segfault:

node_init_cb (node=0x0, agent=0x0) at mesh/mesh.c:359
        reply = dbus_error(join_pending->msg, MESH_ERROR_FAILED,

        user_data=0x5555555be170) at mesh/node.c:1760
        dbus=<optimized out>) at ell/dbus.c:216
        user_data=0x5555555a6e00) at ell/dbus.c:279
        user_data=0x5555555a7ef0) at ell/io.c:126
        at ell/main.c:642
        at mesh/main.c:205

The fault was caused by the premature deletion of preserved state.

This moves setup of disconnect watch for the application calling the Join()
method into the node_init_cb(), after a temporary node has been
successfully created.

Change-Id: Ib564cf87d4f09f0713b40a37bf91bff2219a30d1
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Align appkey_packet_decrypt with dev and virt variants.
Michał Lowas-Rzechonek [Thu, 3 Oct 2019 20:07:47 +0000 (13:07 -0700)]
mesh: Align appkey_packet_decrypt with dev and virt variants.

Move appkey_packet_decrypt to mesh/model, rename it to
app_packet_decrypt, make it private and change arguments to be aligned
with other decryption functions.

Also, simplify the implementation using an inline loop, removing the
need of mod_decrypt struct.

Change-Id: I0eb810553d8947a9cbeaf4469104ba69f31579e8
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Normalize Access Key AID and Index naming in models
Michał Lowas-Rzechonek [Thu, 3 Oct 2019 20:07:46 +0000 (13:07 -0700)]
mesh: Normalize Access Key AID and Index naming in models

After 8f0839a1c46300ceb1b129d17a3bff446ff79d08, mesh/crypto uses _aid
suffix for keys' AID property, so let's change the wording in mesh/model
as well.

Change-Id: Ia4cb39f7b0b4cabb62ef097288ef7d6734476c8b
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Remove unused defines
Michał Lowas-Rzechonek [Thu, 3 Oct 2019 20:07:45 +0000 (13:07 -0700)]
mesh: Remove unused defines

Change-Id: Ide8c43fde71bd649a8624b2139860e98bc26d91f
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix Key Ring permissions for local nodes
Brian Gix [Thu, 26 Sep 2019 18:14:44 +0000 (11:14 -0700)]
mesh: Fix Key Ring permissions for local nodes

We do *not* automatically create populated key rings for imported or
joined nodes, but we also do not *forbid* any node from adding a key
in it's possesion to the local key ring.

There are two (known) use cases for Import()

1. Node previously existed on a different physical piece of hardware,
and is being migrated to this daemon.

2. Node was newly provisioned Out-Of-Band, and this is the net result
of the provisioning.

In *neither* case is it a given that the Node should be able to
provision another node (the effect of adding the Net Key to the key
ring). In neither case is it a given that the Node should be able to
modify it's own Config Server states (the effect of adding it's
Device Key to the key ring).

Change-Id: Ida5adbedbb6757a36a7f0b8c803fe66e4c7d4cf0
Signed-off-by: Anupam Roy <anupam.r@samsung.com>