platform/upstream/bluez.git
4 years agomesh: Extract read_* functions in mesh-config-json
Jakub Witowski [Wed, 31 Jul 2019 07:16:45 +0000 (09:16 +0200)]
mesh: Extract read_* functions in mesh-config-json

This is a small improvement of read_node function readability.

Change-Id: I9c9194b66c95462f776724fe47fcccbfa3d673c6
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Check that config server is present in primary element
Michał Lowas-Rzechonek [Fri, 26 Jul 2019 06:36:06 +0000 (08:36 +0200)]
mesh: Check that config server is present in primary element

This verifies that Config Server model is supported by element #0, and
is not supported by any other element.

Change-Id: I797fa781a64c7f99754e8c609aee5ccb5a20f9a9
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Check that element indexes are consecutive
Michał Lowas-Rzechonek [Fri, 26 Jul 2019 06:36:05 +0000 (08:36 +0200)]
mesh: Check that element indexes are consecutive

Change-Id: I57cbf929ce5e2af1a1ba15ce1a78b668d30382fb
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Keep element and model lists sorted and unique
Michał Lowas-Rzechonek [Fri, 26 Jul 2019 06:36:04 +0000 (08:36 +0200)]
mesh: Keep element and model lists sorted and unique

This keeps composition data unchanged even if elements or models are
registered in a different order.

Change-Id: Ic918001bc152e92ba6f08274159d81b9a65b20b1
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Validate application by comparing composition data
Michał Lowas-Rzechonek [Fri, 26 Jul 2019 06:36:03 +0000 (08:36 +0200)]
mesh: Validate application by comparing composition data

Instead of validating application by enumerating D-Bus objects, create a
temporary node instance and check if composition data generated for the
temporary matches the node loaded from storage.

This allows node validation logic (primary element, mandatory models etc)
to be confined in node_generate_comp() function.

This also streamlines code implementing Attach(), Join() and
CreateNetwork() calls.

Change-Id: I82c634a32a89c446937a7d58ff4f9a73da339aa3
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Convert void pointers to anonymous unions in managed_obj_request
Michał Lowas-Rzechonek [Fri, 26 Jul 2019 06:36:02 +0000 (08:36 +0200)]
mesh: Convert void pointers to anonymous unions in managed_obj_request

Change-Id: I245a62465bac7f093524bb041a2e034d9bdfad0a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotest/test-mesh: Initialize required properties
Inga Stotland [Thu, 25 Jul 2019 18:31:45 +0000 (11:31 -0700)]
test/test-mesh: Initialize required properties

This initialized required "Models" and "VendorModels" properties
wheher the actual models exist or not, according to the mesh-api.txt.
In case when an element does not contain either SIG defined models or
vendor defineed models, the corresponding properties should contain
empty arrays.

Change-Id: Ica2e4bab99f6da827997832a29afe4f2079c0561
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix storage init of Friend and LPN features
Inga Stotland [Thu, 25 Jul 2019 18:26:12 +0000 (11:26 -0700)]
mesh: Fix storage init of Friend and LPN features

This fixes a typo in mesh-config-json.c when Friend feature
was initialized twice and LPN was not initialized at all.

Change-Id: I69b79713e31667210a515821635c2acfef003739
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agodoc/mesh-api: Restore properties in mesh node hierarchy
Inga Stotland [Fri, 26 Jul 2019 02:03:10 +0000 (19:03 -0700)]
doc/mesh-api: Restore properties in mesh node hierarchy

This restores Features, Beacon, BeaconFlags, IvIndex and
SecondsSinceLAst heard properties under the
org.bluez.mesh.Node1 interface.

Change-Id: I27dd9dd8544c973825848ac089c38663585e94b1
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Check address range passed to ImportRemoteNode
Michał Lowas-Rzechonek [Fri, 19 Jul 2019 12:15:59 +0000 (14:15 +0200)]
mesh: Check address range passed to ImportRemoteNode

+changed "not authorized" error to "invalid args" when managing device
key for local address range

Change-Id: I17f83a7b0eed3321d67cb4394204d2978e4b05d8
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Propagate Net Index up Rx message chain
Brian Gix [Tue, 16 Jul 2019 22:56:44 +0000 (15:56 -0700)]
mesh: Propagate Net Index up Rx message chain

When a model receives a message, it is required by the spec
to respond using the same credentials. When an App Key is used,
this is trivial because App keys are bound to Net keys, so only
the App Index is required.  Messages received on a Device key
however, need the Net Index preserved from original message for
re-use during the response.

Change-Id: Ib8497b393f38e761253652364661db626801ea79
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Normalize Access Key AID naming convention
Brian Gix [Tue, 16 Jul 2019 22:56:43 +0000 (15:56 -0700)]
mesh: Normalize Access Key AID naming convention

Change-Id: I9e72835c2aac5864f7d35781d97790796c1e751d
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add bound Net Index lookup for App Keys
Brian Gix [Tue, 16 Jul 2019 22:56:42 +0000 (15:56 -0700)]
mesh: Add bound Net Index lookup for App Keys

This patch also normalizes the naming convention in favor of key_aid
when referring to the calculated AID of the used Access Layer key.

Change-Id: I49f973d9f2bcdd03b8558da2fa7e30b4510c2dc1
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Allow sending on org.bluez.mesh.Provisioner1
Inga Stotland [Thu, 18 Jul 2019 03:54:18 +0000 (20:54 -0700)]
mesh: Allow sending on org.bluez.mesh.Provisioner1

This adds a new interface permission to bluetooth-mesh.conf:
<allow send_interface="org.bluez.mesh.Provisioner1"/>

Change-Id: I9285c0ba2580510bdfd6914e85d9dea0d7990460
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Init keyring storage directory on node Attach()
Inga Stotland [Thu, 18 Jul 2019 04:01:26 +0000 (21:01 -0700)]
mesh: Init keyring storage directory on node Attach()

This adds initialization of keyring storage directory when
a mesh node is attached successfully.

Change-Id: I50889c558595bbda544971ffb7973732905bab97
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Rename mesh_config_srv_init() to cfgmod_server_init()
Inga Stotland [Sun, 14 Jul 2019 23:23:20 +0000 (16:23 -0700)]
mesh: Rename mesh_config_srv_init() to cfgmod_server_init()

This renames mesh_config_srv_init() to cfgmod_server_init() to avoid
confusion with mesh_config_..> API and to reflect that the call pertains
to configuration server model.

Change-Id: I6b63f3dd4eac6091b020f828bbe18f659351933f
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Create or re-use a node storage directory for keyring
Inga Stotland [Sun, 14 Jul 2019 23:23:19 +0000 (16:23 -0700)]
mesh: Create or re-use a node storage directory for keyring

This adds APIs to set a directory for storing node's key ring info.
The directory is named MESH_STORAGE_DIR/<node uuid>. This directory
may contain additional node info plus node configuration, if node
configuration storage follows the same layout (as it does when
JSON based config file format is used).

Change-Id: I7e85b5742dd44e33e7c64e87468ec78b8a7ffd00
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Manage node config directory in mesh-config
Inga Stotland [Sun, 14 Jul 2019 23:23:18 +0000 (16:23 -0700)]
mesh: Manage node config directory in mesh-config

This completely removes storage.c file. Instead, the handling
of mesh node configuration storage is done completely in
mesh-config layer by calling the following API functions:
bool mesh_config_load_nodes(const char *cfg_dir,
                            mesh_config_node_func_t cb,
                            void *user_data)

void mesh_config_release(struct mesh_config *cfg)
void mesh_config_destroy(struct mesh_config *cfg)

bool mesh_config_save(struct mesh_config *cfg, bool no_wait,
                      mesh_config_status_func_t cb, void *user_data)

struct mesh_config *mesh_config_create(const char *cfg_path,
                                       const uint8_t uuid[16],
                                       struct mesh_config_node *node)

Change-Id: I72124397b14d3a1fa4e8bedd9a23733ce8fd1249
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Use mesh_config APIs to store node configuration
Inga Stotland [Sun, 14 Jul 2019 23:23:17 +0000 (16:23 -0700)]
mesh: Use mesh_config APIs to store node configuration

This eliminates storage_set...() routines as an intermediate
layer between mesh_config layer and the rest of the daemon when
storing updated node configuration values.
For the JSON based implementation, each call to mesh_config_write...()
routines results in writing to the node configuration file.

Change-Id: Ia42ed3d2f5a49efa2665fea15384ea06389dc49d
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Replace storage_save_config with mesh_config_save_config
Inga Stotland [Sun, 14 Jul 2019 23:23:16 +0000 (16:23 -0700)]
mesh: Replace storage_save_config with mesh_config_save_config

This moves writing out of node configuration from storage.c down to
mesh-config-<format-specific>.c to allow for more generic storage layout.

New generalized API in mesh-config.h:
mesh_config_save_config(struct mesh_config *cfg, bool no_wait,
mesh_config_status_func_t cb, void *user_data)

replaces the old one in storage.h:
storage_save_config(struct mesh_node *node, bool no_wait,
mesh_status_func_t cb, void *user_data)

Currently, only JSON format is supported for storing node configuration:
mesh_config_save_config is implemented in mesh-config-json.c

Change-Id: I6ecb77332911bdb6a6ae18feedb8cae40b2832ff
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Confine dependency on json-c to mesh-config-json.c
Inga Stotland [Sun, 14 Jul 2019 23:23:15 +0000 (16:23 -0700)]
mesh: Confine dependency on json-c to mesh-config-json.c

This removes dependency on json-s/json.h header from everywhere
in the code except for mesh-config-json.c. The details about
node configuration storage format are obfuscated: a pointer
to an opaque mesh_config structure is stored with mesh_node and is
passed around to mae all the storage related operations.

Change-Id: I9acad57fdaad8844c48e629e6de80ed0595404b3
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Move load from storage functionality into node.c
Inga Stotland [Sun, 14 Jul 2019 23:23:14 +0000 (16:23 -0700)]
mesh: Move load from storage functionality into node.c

This moves the initialization of a mesh node from stored
configuration from storage.c to node.c

Change-Id: Id2af576c57b75c4d91fc34a1fa78169d421d10ad
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Change mesh_db prefix to mesh_config
Inga Stotland [Sun, 14 Jul 2019 23:23:13 +0000 (16:23 -0700)]
mesh: Change mesh_db prefix to mesh_config

This changes the naming the API declarations in mesh-config.h:
mesh_db_... ->mesh_config_...

Change-Id: I397ca6192d596de66c8de2cfe469758aaa4ffb4f
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Rename mesh-db.c to mesh-config-json.c
Inga Stotland [Sun, 14 Jul 2019 23:23:12 +0000 (16:23 -0700)]
mesh: Rename mesh-db.c to mesh-config-json.c

This moves mesh-db.h to mesh-config.h and mesh-db.c to mesh-config-json.c.
mesh-config.h declares common APIs for storing mesh node configuration.
mesh-config-json.c defines the APIs for JSOn specific storage.
This allows for future parallel implementation a different (not JSON-based)
mechanism of storing node configuration.

Change-Id: Iffde923efc7597cdb34a86e322b9baa901a6ee02
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Move network config setup from storage.c to node.c
Inga Stotland [Sun, 14 Jul 2019 23:23:11 +0000 (16:23 -0700)]
mesh: Move network config setup from storage.c to node.c

This commit moves initialization of configuration parameters
for node->net when the local node state is restored from stored
configuration. Old location: storage.c, new locaiton node.c.

Change-Id: I7e9577f6da3e6418eacdf2e97a95250ee1cb4357
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotest: This extends the mesh tool to exercise Provisioning methods
Brian Gix [Thu, 11 Jul 2019 22:59:52 +0000 (15:59 -0700)]
test: This extends the mesh tool to exercise Provisioning methods

Note:  This script is *not* a suitable tool for expanding into
a Mesh Provisioner. It is only intended to demonstrate the arguments
and methods required.

Change-Id: Ifacbf894c5e50621e5d35958a97efc7f487777ab
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Convert provisioning pkts to packed structs
Brian Gix [Thu, 11 Jul 2019 22:59:51 +0000 (15:59 -0700)]
mesh: Convert provisioning pkts to packed structs

Provisioning packets are defined in the specification
as packed big endian structures. Instead of specifying
an octet array, we now use struct matching the spec.

Change-Id: Ib7e0457a2d39f6c0a09b66208c98e1ecf2b7bbde
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Implement DBus Provisioning methods
Brian Gix [Thu, 11 Jul 2019 22:59:50 +0000 (15:59 -0700)]
mesh: Implement DBus Provisioning methods

This implements the Interface and Methods for:
UnprovisionedScan()
UnprovisionedScanCancel()
AddNode()

Change-Id: Id9b08cecbd7bcc27fe077271719d494a4d6765b4
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix implementation of Provisioner Initiator
Brian Gix [Thu, 11 Jul 2019 22:59:49 +0000 (15:59 -0700)]
mesh: Fix implementation of Provisioner Initiator

This has had testing of baseline functionality that includes
OOB authentication type "3c" from BT Mesh v1.0 specification

Change-Id: Ia5c6b90a28d39871cedbf652c9533f761670c892
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Expose resources needed by Management1 interface
Brian Gix [Thu, 11 Jul 2019 22:59:48 +0000 (15:59 -0700)]
mesh: Expose resources needed by Management1 interface

Change-Id: I34c48666cad7fd717536582bedd44503a9b738e6
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Expose mapping function for D-Bus errors
Brian Gix [Thu, 11 Jul 2019 22:59:47 +0000 (15:59 -0700)]
mesh: Expose mapping function for D-Bus errors

Change-Id: Ifd701c0fb651108cc3d7185271f0415e38dcd10c
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add special Beacon handler for Provisioning
Brian Gix [Thu, 11 Jul 2019 22:59:46 +0000 (15:59 -0700)]
mesh: Add special Beacon handler for Provisioning

Provisioning uses the same AD type for Provisioning that
is also used by the Secure Network Beacon, but their
usage is distinct from each other.  This change allows
us to enable/disable Unprovisioned Device Beacon capture
without disrupting SNB handling.

Change-Id: I008db68f0e371ca6c843a3dd27357318973ccb8e
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix support for Provisioner Initiator
Brian Gix [Thu, 11 Jul 2019 22:59:45 +0000 (15:59 -0700)]
mesh: Fix support for Provisioner Initiator

Change-Id: Ibc02f8edb7ec8da10de89b7f0b0c2e0063dee5f4
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix segmentation fault when removing a node
Inga Stotland [Thu, 4 Jul 2019 17:36:06 +0000 (10:36 -0700)]
mesh: Fix segmentation fault when removing a node

This fixes a segmentation fault introduced by earlier changes.
Segmentation fault was used by accessing a queu that has been
destroyed, but the corresponding pointer hasn't been set to NULL.

Change-Id: I97d395e354ed8b21b9ec55d2eea924d7b1db9175
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Handle messages encrypted with a remote device key
Michał Lowas-Rzechonek [Thu, 4 Jul 2019 12:33:38 +0000 (14:33 +0200)]
mesh: Handle messages encrypted with a remote device key

This adds ability to receive messages encrypted using known remote
device key. Such a key must be added to the node's keyring using
ImportRemoteNode() method of org.bluez.mesh.Management1 interface.

Decrypted messages are then forwarded to the application using
DevKeyMessageReceived() D-Bus API.

Also, messages originating from a local node and encrypted using local
device key are forwarde to the application as well, if they weren't
handled by internal model. This allows e.g. receiving status messages
from a local Config Server in the application.

Change-Id: I2fcf957dcf652d5c5cd5ae799344692a4f9c69cf
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Implement DevKeySend() method on Node interface
Michał Lowas-Rzechonek [Thu, 4 Jul 2019 12:33:37 +0000 (14:33 +0200)]
mesh: Implement DevKeySend() method on Node interface

This patch implements D-Bus DevKeySend() method of org.bluez.mesh.Node1
interface, allowing the application to send messages encrypted using
a known remote device key.

At the moment the call ignores net_index argument and sends messages
using the primary subnet.

Also, it's no longer possible to use 'magic' key_index value 0x7fff
(denoting local device key) when calling regular Send(). Applications
should use DevKeySend() instead.

Change-Id: I37c13c2c050b03880f23d6b8d149e998a7cff1f3
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Split APP_IDX_DEV into APP_IDX_DEV_LOCAL and APP_IDX_DEV_REMOTE
Michał Lowas-Rzechonek [Thu, 4 Jul 2019 12:33:36 +0000 (14:33 +0200)]
mesh: Split APP_IDX_DEV into APP_IDX_DEV_LOCAL and APP_IDX_DEV_REMOTE

This is needed to distinguish incoming messages encrypted using a device
key: if the key is local, the message can be forwarded to internal
models. If the key is a known remote one, it will be forwarded to the
application via DevKeyMessageReceived() API.

Change-Id: I4cd92b881b29e24d3579e6db22f866cb0b3a2fa9
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Cleanup D-Bus method returns with empty result
Michał Lowas-Rzechonek [Thu, 4 Jul 2019 12:33:35 +0000 (14:33 +0200)]
mesh: Cleanup D-Bus method returns with empty result

Change-Id: I891ea4f6d3587383152b5a29d63db098b9c024dc
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Use l_dbus_message...() APIs in more consistent fashion
Inga Stotland [Thu, 4 Jul 2019 07:40:40 +0000 (00:40 -0700)]
mesh: Use l_dbus_message...() APIs in more consistent fashion

This removes checks for the return values of l_dbus_message...()
calls in the few places where we can rely on ell to handle error
cases gracefully.

Change-Id: Ib34c50366b0a93456bb4f891cc750777089e4147
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Remove redundant initialization
Inga Stotland [Thu, 4 Jul 2019 07:15:16 +0000 (00:15 -0700)]
mesh: Remove redundant initialization

This fixes a case where a variable was initialized twice.

Change-Id: I14b10105095304d93c25d067ad435fceed79835f
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix stack overflow in get_element_properties
Michał 'Khorne' Lowas-Rzechonek [Wed, 3 Jul 2019 19:08:33 +0000 (21:08 +0200)]
mesh: Fix stack overflow in get_element_properties

D-Bus type 'q' denotes uint16, not uint8.

Change-Id: Ia9c8f9bb2d6f60f46d180ae583771685593be7f5
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix clean up of node's DBUS assosiated resources
Inga Stotland [Wed, 3 Jul 2019 23:02:44 +0000 (16:02 -0700)]
mesh: Fix clean up of node's DBUS assosiated resources

This consolidates multiple places where node's object paths,
interfaces, etc. are de-allocated, into one routine:
free_node_dbus_resources().
This also addresses memory leaks assosiated with inconsistent freeing
of object path strings.

Change-Id: If11ec87748384b43dd7f6b7ef06d88439cf0323c
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix checks when restoring internal model state
Inga Stotland [Wed, 3 Jul 2019 20:53:41 +0000 (13:53 -0700)]
mesh: Fix checks when restoring internal model state

This fixes incorrect conditional checks in restore_model_state()
which could lead to dereferencing a NULL pointer.

Change-Id: I65631b3cd22c9e5f5e43aa62e093c227182749b8
Wrong: if (l_queue_isempty(mod->bindings) || !mod->cbs->bind) ...
Fixed: if (!l_queue_isempty(mod->bindings) && cbs->bind) ...
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix memory leak on dbus message creation
Brian Gix [Wed, 3 Jul 2019 16:34:03 +0000 (09:34 -0700)]
mesh: Fix memory leak on dbus message creation

Change-Id: I82a29b20859c1310ff17acf8e181de822b9a4952
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Allow to set-up the CRPL with application
Jakub Witowski [Tue, 2 Jul 2019 12:31:41 +0000 (14:31 +0200)]
mesh: Allow to set-up the CRPL with application

This adds an optional CRPL property to org.bluez.mesh.Application1
interface, allowing to indicate the depth of reply protection list.

Change-Id: I838ecb7f4f5396d46a67fe20ca87c8944331eb82
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Register D-Bus management interface
Michał Lowas-Rzechonek [Fri, 28 Jun 2019 08:27:34 +0000 (10:27 +0200)]
mesh: Register D-Bus management interface

When application Attach()es itself, start exposing both Node1 and
Management1 D-Bus interfaces.

Change-Id: I2a94441cce59cee62e219ee40b07d6f3124290df
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Clear nodes queue on get_managed_objects_cb() fails
Jakub Witowski [Fri, 28 Jun 2019 09:50:49 +0000 (11:50 +0200)]
mesh: Clear nodes queue on get_managed_objects_cb() fails

Currently when the get_managed_objects_cb() fails it frees
the node resources but the node still remains on the "nodes" queue.

This implementation calls node_remove() instead of
free_node_resources()."

Change-Id: I2a2e03c671d85e9ee318fb8ae30b7d67e4855ffc
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotest: test-mesh - Correctly stop periodic publication
Inga Stotland [Sun, 30 Jun 2019 06:43:56 +0000 (23:43 -0700)]
test: test-mesh - Correctly stop periodic publication

This changes the order of checks for an updated publication period:
check for zero period first, and if this is the case, stop sending
the periodic model publications.

Change-Id: I2693c5a593fa23e59dd2e015348f1fd96a30c88f
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix and clean up model publication code
Inga Stotland [Sun, 30 Jun 2019 06:43:55 +0000 (23:43 -0700)]
mesh: Fix and clean up model publication code

This adds proper checks for model publication removal:
the publication is not virtual and the publication address is set to zero,
i.e., UNASSIGNED_ADDRESS.
Also removes double memory allocation for model publication and
miscellaneous redundancies.

Change-Id: Ib41b16a583de598c38ffd176bca5812f1bf96375
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix virtual address processing
Inga Stotland [Sun, 30 Jun 2019 06:43:54 +0000 (23:43 -0700)]
mesh: Fix virtual address processing

This tightens up the accounting for locally stored virtual addresses.
Alos, use meaningful variable names to identify components of a
mesh virtual address.

Change-Id: Iea7ed8035bacd8ea41deda7738ace39b57a8eb2e
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Clean up model.c and cfg-server.c
Inga Stotland [Sun, 30 Jun 2019 06:43:53 +0000 (23:43 -0700)]
mesh: Clean up model.c and cfg-server.c

This removes a number of redundancies, fixes naming conventions and
style.

Change-Id: I6b7d7027451ee043f89e5afe17ec9a0eebb0ef5b
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix D-Bus node path
Michał Lowas-Rzechonek [Fri, 28 Jun 2019 08:27:33 +0000 (10:27 +0200)]
mesh: Fix D-Bus node path

According to doc/mesh-api.txt, node object should be located at
/org/bluez/mesh/node.

Change-Id: I94a39b7b092e14b7a082fd7dfd17e11c1960b568
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fixed handling of IVI flag in app layer
Michał Lowas-Rzechonek [Thu, 27 Jun 2019 07:40:42 +0000 (09:40 +0200)]
mesh: Fixed handling of IVI flag in app layer

Since IV Index is used in application nonces, we need to honor IVI flag
not only in network layer crypto, but also in application layer.

This means that if IVI field of incoming packet is different than in
current IV Index, try to decode *both* net and app layers using IV Index
decreased by one.

Change-Id: Ieaacc703dac4aa8b9a58ea6bf01a92b1893e9b7b
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Modify check of the node directory name upon removal
Inga Stotland [Mon, 24 Jun 2019 17:41:42 +0000 (10:41 -0700)]
mesh: Modify check of the node directory name upon removal

This removes check for "mesh" as the parent directory name and, instead,
verifies that the node configuration directory name is the hexadecimal
string representating the node's UUID.

Change-Id: Id7ec5d7cb4c609fea7ea79232da8c78cc18f09af
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix to duplicated model Ids saved to storage
Rafał Gajda [Wed, 26 Jun 2019 15:49:02 +0000 (17:49 +0200)]
mesh: Fix to duplicated model Ids saved to storage

Mesh daemon internally implements the Config Server SIG model.

When generating node, if the Mesh Element in mesh application
returns modelId 0 among its supported models, it should be skipped,
otherwise it will be duplicated and saved in the storage file.

This patch fixes correctly skipping Config Server model during node
creation.

Change-Id: Ic2bc3df4e21ec5b2e4f5678a70443fa458f69aa4
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Remove unused error code from Leave()
Jakub Witowski [Wed, 19 Jun 2019 09:18:56 +0000 (11:18 +0200)]
mesh: Remove unused error code from Leave()

This removes NotFound error from mesh-api.txt from Leave() function.

Change-Id: I00efdb4781f24f6866208bf7a76075b78813a325
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Move HCI handling to mesh-io-generic
Michał Lowas-Rzechonek [Mon, 24 Jun 2019 07:32:28 +0000 (09:32 +0200)]
mesh: Move HCI handling to mesh-io-generic

This patch separates 'mesh' module from 'mesh_io', particularly
regarding configuration and initialization.

Main code is no longer aware of MGMT and HCI usage - querying available
HCI interfaces now happens in mesh-io-generic.

MGMT code is now extracted into mesh-mgmt module, which mesh-io-generic
uses to query interfaces.

Change-Id: I698752859bc7c1218410e83fc1a04a381539984b
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Remove redundant checks when adding a net key
Inga Stotland [Wed, 12 Jun 2019 15:04:37 +0000 (08:04 -0700)]
mesh: Remove redundant checks when adding a net key

This patch cleans up redundant checks in add_key() and mesh_net_set_key():
no need to check the result of l_queue_push_tail() and no need to check
if subnet is valid after it was successfully created.

Change-Id: I5c9b0a7483d70db955b57d9c2d4587b5996934fe
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agobuild: Add missing mesh & btpclient dependencies
Brian Gix [Wed, 12 Jun 2019 15:09:50 +0000 (08:09 -0700)]
build: Add missing mesh & btpclient dependencies

btpclient and bluetooth mesh fail to build on their own until
certain ELL and generated header files have been built, which
can cause a build to fail if derived objects are generated in
wrong order.

Change-Id: I4e50d13e8fbd2718cc6a1fc3ee6bef5db0d46e94
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix segmentation fault after adding second netkey via NET_KEY_ADD opcode
Jakub Witowski [Mon, 10 Jun 2019 08:46:05 +0000 (10:46 +0200)]
mesh: Fix segmentation fault after adding second netkey via NET_KEY_ADD opcode

Segmentation fault was caused by passing subnet pointer to the
start_network_beacon() which was NULL

Change-Id: Ic09f390fe7c056028acc948f5feb3f34a0e50b4f
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Clean up style
Inga Stotland [Thu, 6 Jun 2019 01:18:32 +0000 (18:18 -0700)]
mesh: Clean up style

This cleans up some stylistic issues. Plus, don't check the return
value of l_new(): if memory allocation fails, the execution stops.

Change-Id: I86e7980ab218fab1d761ce52c41fd936b00e155e
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Make "elements" mandatory in node configuration
Inga Stotland [Thu, 6 Jun 2019 01:18:31 +0000 (18:18 -0700)]
mesh: Make "elements" mandatory in node configuration

This patch modifies the behavior of node configuration parsing:
if "elements" property is not present, th configuration file
for this node is regarded as malformed.

Also, clean up style.

Change-Id: I3a869f74cf103f04fdb99f991c0156932372354e
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Do not daemonize, run in foreground or as service
Inga Stotland [Tue, 4 Jun 2019 06:07:48 +0000 (23:07 -0700)]
mesh: Do not daemonize, run in foreground or as service

This removes call to daemon(). "--nodetach" option is retained
to set umask().

Also, adds description for dbus-debug option.

Change-Id: I534dfb17161e2866a1b87c78d6d72b492c20c768
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Enable mesh package build in Tizen
Anupam Roy [Tue, 17 Dec 2019 15:10:01 +0000 (20:40 +0530)]
mesh: Enable mesh package build in Tizen

Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add bluetooth mesh package in Tizen
Anupam Roy [Fri, 13 Dec 2019 09:18:34 +0000 (14:48 +0530)]
mesh: Add bluetooth mesh package in Tizen

bluetooth mesh support is presently by-default enabled
in buid spec file.

Change-Id: Ice98f3a8dad6a4d3a6f999bfae0ed9c674e83b19
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix compilation issues
Anupam Roy [Tue, 17 Dec 2019 14:48:11 +0000 (20:18 +0530)]
mesh: Fix compilation issues

Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agobuild: Add support for systemd bluetooth-mesh service
Inga Stotland [Tue, 4 Jun 2019 06:07:47 +0000 (23:07 -0700)]
build: Add support for systemd bluetooth-mesh service

This adds support for installing systemd bluetooth-mesh service unit
and D-Bus service file that references this systemd unit.

Change-Id: I8306de2261244ead765bdae9b6b7bed00f069a61
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: ELL encrypt dependancy README section added
Brian Gix [Fri, 31 May 2019 15:56:43 +0000 (08:56 -0700)]
mesh: ELL encrypt dependancy README section added

Due to known AEAD encryption deficiencies in old versions of the
kernel, we have added a section on identifying and back-porting
mesh to otherwise non-supporting platforms.

Change-Id: I71ecc5164dbd29cc7fd33278712ab746c961fa82
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Convert crypto to use ELL wrappers
Brian Gix [Wed, 29 May 2019 17:28:18 +0000 (10:28 -0700)]
mesh: Convert crypto to use ELL wrappers

Use ELL implementations of aead-ccm(aes), ecb(aes) and cmac(aes). These
standard encryption and hashing routines are provided by ELL.

Change-Id: I4c82199cf8a58c6a09de8a8afcc74bb3cf584376
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix long MIC usage in segmented messages
Jakub Witowski [Fri, 24 May 2019 14:48:10 +0000 (07:48 -0700)]
mesh: Fix long MIC usage in segmented messages

Contrary to the comment, implementation used a 8-byte MIC even if this
generated an additional segment.

Change-Id: I7e718efbe401a3312871f2a4567050dc1805a508
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Implement remote dev key methods for keyring
Brian Gix [Fri, 24 May 2019 14:48:09 +0000 (07:48 -0700)]
mesh: Implement remote dev key methods for keyring

Implements following org.bluez.mesh.Management1 methods:
ImportRemoteNode()
DeleteRemoteNode()

These methods are used to maintain Device Key keyring storage.

Change-Id: I8ea4508ca9e2717e0f2779ebff88ce0b2fa9c0a8
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Implement Key Refresh Phasing in keyring
Brian Gix [Fri, 24 May 2019 14:48:08 +0000 (07:48 -0700)]
mesh: Implement Key Refresh Phasing in keyring

Implements following org.bluez.mesh.Management1 methods:
CompleteAppKeyUpdate()
SetKeyPhase()

These methods are used to maintain Key Refresh settings
in the keyring storage.

Change-Id: Ic987cbb477710b35af4c40b5de60466a8ff2cdd8
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Implement App Key keyring storage handling
Brian Gix [Fri, 24 May 2019 14:48:07 +0000 (07:48 -0700)]
mesh: Implement App Key keyring storage handling

Implements following org.bluez.mesh.Management1 methods:
CreateAppKey()
ImportAppKey()
UpdateAppKey()
DeleteAppKey()

These methods are used to maintain App Key keyring storage.

Change-Id: I16cf6fb5e503e8474f35f383e8a7129cf4aae335
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Implement Net Key keyring storage handling
Brian Gix [Fri, 24 May 2019 14:48:06 +0000 (07:48 -0700)]
mesh: Implement Net Key keyring storage handling

Implements following org.bluez.mesh.Management1 methods:
CreateSubnet()
ImportSubnet()
UpdateSubnet()
DeleteSubnet()

These methods are used to maintain Net Key keyring storage.

Change-Id: Iff079138608495589063efb57571118975bbe281
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Centralize definition of PRIMARY_NET_IDX
Brian Gix [Fri, 24 May 2019 14:48:05 +0000 (07:48 -0700)]
mesh: Centralize definition of PRIMARY_NET_IDX

Change-Id: I8982c1b778f4990d425e3eed9160fbcaeca5dc85
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add new method for Key Refresh procedure
Brian Gix [Fri, 24 May 2019 14:48:04 +0000 (07:48 -0700)]
mesh: Add new method for Key Refresh procedure

This adds a new method CompleteAppKeyUpdate() on
org.bluez.mesh.Management1 interface to be used by the application
at the completion of a Key Refresh procedure. This method should
be called for each app key that is being updated during the
procedure, and must be performed prior to changing the phase of
the bound net key to phase 3.

Change-Id: I7bb869c9af78c58df0d567c745026b59fef97ce8
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomeshctl: Retry recvmsg if data is not ready
Steve Brown [Tue, 21 May 2019 20:03:13 +0000 (16:03 -0400)]
meshctl: Retry recvmsg if data is not ready

Commit d6eec1b67d6d ("meshctl: Switch from write to sendmsg for Acquire*")
causes a regression by returning an error if recvmsg has no data available.
Fix it by retrying until data is received.

Change-Id: I9f950f4ac7688dc3b89ccdc940f3ba60bc781737
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Remove unnecessary includes from .c files
Inga Stotland [Wed, 15 May 2019 19:00:19 +0000 (12:00 -0700)]
mesh: Remove unnecessary includes from .c files

Change-Id: Ifb8be3d309ad1a99b9397f608d9fe1023d6480d8
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Update copyright dates
Inga Stotland [Wed, 15 May 2019 19:00:18 +0000 (12:00 -0700)]
mesh: Update copyright dates

Change-Id: I66dc7b41b7b09e22b57624493647fe286101e984
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Save generated Net and Dev keys in KeyRing
Brian Gix [Wed, 15 May 2019 16:34:17 +0000 (09:34 -0700)]
mesh: Save generated Net and Dev keys in KeyRing

When creating a network from scratch, we need to save all
keys that are created into the KeyRing for use by Config
Client application.

Change-Id: I477c99dbab5973c34059bb63a5b0576034b8b3b4
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix file open error checking and permissions
Brian Gix [Wed, 15 May 2019 16:34:16 +0000 (09:34 -0700)]
mesh: Fix file open error checking and permissions

Change-Id: Ie3836862c91e779fc208b920071aa970d9681bc3
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add "create" command to test app
Brian Gix [Wed, 15 May 2019 16:34:15 +0000 (09:34 -0700)]
mesh: Add "create" command to test app

Like "join" this command generates a UUID and calls CreateNetwork()
and displays the UUID and token.

Change-Id: I5e28c5ae4acd85fa1547c7f21933bd851f765424
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add skeleton for org.bluez.mesh.Management1 interface
Inga Stotland [Tue, 14 May 2019 22:54:07 +0000 (15:54 -0700)]
mesh: Add skeleton for org.bluez.mesh.Management1 interface

This adds bare-bones imlementation of methods on org.bluez.mesh.Management1
interface.

Change-Id: If6a00b26a5f5732e005f3ba2ca6f1fb2015dee10
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add check for org.bluez.mesh.Provisioner1 interface
Inga Stotland [Tue, 14 May 2019 22:54:06 +0000 (15:54 -0700)]
mesh: Add check for org.bluez.mesh.Provisioner1 interface

This adds check for the presence of org.bluez.mesh.Provisioner1
interface when collecting information about mesh application
that is received in callback of GetManagedObjects() method.
Set "provisioner" flag in the node structure to trueto indicate
that the node may act aa a provisioner.

Change-Id: I599740694dde48955e2492acf13d3812d5938828
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add key storage
Brian Gix [Thu, 9 May 2019 21:33:21 +0000 (14:33 -0700)]
mesh: Add key storage

This implements internal key storage add/delete/fetch for the three
basic key types managed in Mesh: Network, Application and Device.

This key storage is separate from keys assigned to nodes within the
mesh, and are used to support Configuration Client functionality.

Change-Id: Ie582b6c0de2ed81c3b9e35cd5f1fc63674be2334
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Reconfigure node storage tree
Brian Gix [Thu, 9 May 2019 21:33:20 +0000 (14:33 -0700)]
mesh: Reconfigure node storage tree

Add a tree structure to a nodes data storage, in order to safely handle
Replay Protection list, Refactor local Sequence Numbers, and add Key
storage for Config Client nodes.

Change-Id: Ib66ad23430b8fc6c4864f83a69c3afb6ed10b9bf
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add CreateNetwork method() implementation
Inga Stotland [Wed, 8 May 2019 21:50:08 +0000 (14:50 -0700)]
mesh: Add CreateNetwork method() implementation

This implements CreateNetwork() method on org.bluez.mesh.Network1
interface. Invoking this method generates a self-provisioned
local node associated with a brand new mesh network. This new
network is bare bones: only one network key is defined. The new node
assumes the role of mesh network manager and will be able to use
soon to be implemented methods of org.bluez.mesh.Management1 interface
to provision remote nodes into its network and to add/update/remove
network and application keys.

Change-Id: I2b4e37e98582a272fba9c421c010691a1e921db3
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Use node uuids as storage directory names
Michał Lowas-Rzechonek [Wed, 8 May 2019 14:24:45 +0000 (16:24 +0200)]
mesh: Use node uuids as storage directory names

Instead of keeping track of unique 16bit node identifiers, reuse their
UUIDs to create both storage directories and dbus objects.

Because of that:
 - UUID is no longer stored in the JSON file, it's inferred from the
   directory name instead
 - Join(), CreateNetwork() and ImportLocalNode() APIs return an error if
   given UUID already registered within the daemon

Change-Id: I86032691fa81003c5503880c4bbf9a76aa7bd26e
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Unify processing of GetManagedObjects result
Inga Stotland [Mon, 29 Apr 2019 19:45:09 +0000 (12:45 -0700)]
mesh: Unify processing of GetManagedObjects result

This combines processing of results obtained from GetManagedObjects
request for both Attach() and Join() methods

Change-Id: I4cfc035f5433c4946d9e7eeaf0fdc5298b4b33ed
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Consolidate processing of mesh element properties
Inga Stotland [Mon, 29 Apr 2019 19:45:08 +0000 (12:45 -0700)]
mesh: Consolidate processing of mesh element properties

Consolidate functions to parse and process properties of mesh
element objects. Also, add validation of element composition
when processing Attach() method.

Change-Id: I34fd3db467c75fe80e61e79801e096eeb233136b
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Clean up processing of Attach() method
Inga Stotland [Mon, 29 Apr 2019 19:45:07 +0000 (12:45 -0700)]
mesh: Clean up processing of Attach() method

This changes the prototype for the callback function of
Attach() method call: remove unused node_path argument and make the
callback more generalized and re-usable for other method calls.

Change-Id: I6aab7fb6a8afdd32e14f785cb09f15dfbf021816
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Remove Node interface if node owner disconnects
Inga Stotland [Mon, 29 Apr 2019 19:45:06 +0000 (12:45 -0700)]
mesh: Remove Node interface if node owner disconnects

This unregisters Node interface associated with a specific node
application when this application disconnects from D-Bus.

Change-Id: Ia01f2b898e2a79c54433fcf6ed46467166aff815
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Add APIs for Provisioner and Config Client
Brian Gix [Thu, 18 Apr 2019 22:15:18 +0000 (15:15 -0700)]
mesh: Add APIs for Provisioner and Config Client

The added D-Bus APIs enable Applications to function in a Provisioner
Initiator role, and as a Configuration Client.

Change-Id: I9d038b7fded415a3a43e5d41f5c94218fce96e9a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix the cleanup of failed Join call
Inga Stotland [Thu, 18 Apr 2019 04:33:32 +0000 (21:33 -0700)]
mesh: Fix the cleanup of failed Join call

This fixes the accidental swap of conditional checks: on failure,
remove agent info if agent is registered and remove temporary node,
if one has been created.

Change-Id: Ied17e66039641c6133ee3f83e687e9adcff6b22a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix structure memeber initialization
Inga Stotland [Mon, 22 Apr 2019 15:25:55 +0000 (08:25 -0700)]
mesh: Fix structure memeber initialization

This fixes incorrectly reversed assignment of "friend" value in
convert_node_to_storage()

Change-Id: Ief74507a1aa41b3376f42d8ee1d3beccf85fa218
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Allow only one app attachment per node
Inga Stotland [Mon, 22 Apr 2019 04:51:11 +0000 (21:51 -0700)]
mesh: Allow only one app attachment per node

If a node is already attached to an application process,
disallow another appication to attach to the same node.
This means that an Attach() method called with the token
identifying a node that is already in use, returns an error
org.bluez.mesh.Error.AlreadyExists

Change-Id: Ifde6a2c13ed5d0c044086c58bbb5013fe9f8eb59
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotest: Enable test-mesh to send raw vendor commands
Inga Stotland [Thu, 18 Apr 2019 06:31:10 +0000 (23:31 -0700)]
test: Enable test-mesh to send raw vendor commands

This adds a sample vendor model to the first element of the
mesh node. A new menu entry allows to generate and send a raw
vendor command.

Change-Id: Ic620c0f39e44a414b4ef89938026582f2305c2bd
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agotest: Drive test-mesh with a string-based menu
Inga Stotland [Thu, 18 Apr 2019 06:31:09 +0000 (23:31 -0700)]
test: Drive test-mesh with a string-based menu

Switch to  string interactive commands to drive testing
of bluetooth-meshd. Re-work the menu to allow global setting of
destination address and AppKey index for outbound mesh messages.

Change-Id: Id9d8eb5b8b8d8b439ff6f00c6db583f7638af616
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix network information cleanup
Inga Stotland [Thu, 18 Apr 2019 04:13:06 +0000 (21:13 -0700)]
mesh: Fix network information cleanup

This fixes issues caused by accessing invalidated entries of nets
queue that were left around when removing network info in
mesh_net_detach()

Change-Id: Ic19c0232cbb095a658b8be56ea06f989d07dabfb
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
4 years agomesh: Fix decryption when on more than one Network
Brian Gix [Mon, 15 Apr 2019 21:16:44 +0000 (14:16 -0700)]
mesh: Fix decryption when on more than one Network

Multiple networks use different IV Index's, so we should only use
decryption cache after successful decoding.

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