summaryrefslogtreecommitdiff
path: root/mesh/mesh.c
Commit message (Collapse)AuthorAgeFilesLines
* mesh: Add new kernel MGMT based IO transportBrian Gix2022-09-261-1/+5
| | | | | | | | | | | 1. Re-structures MGMT handling such that it is used to detect kernel support of the mesh MGMT opcodes and events before selecting between using MGMT or the legacy raw HCI socket method. 2. Re-structures main() to allow command line to prefer MGMT over HCI or visa versa, plus optionally pass an explicte controller. 3. Adds mesh-io-mgmt as a transport.
* mesh: Add validation of Device UUID valueInga Stotland2021-02-161-9/+9
| | | | | Validate that the value of Device UUID supplied in CreateNetwork/Join/Import methods is compliant with RFC 4122.
* mesh: Add SPDX License IdentifierTedd Ho-Jeong An2020-09-211-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* mesh: Add deferral of Attach() and Leave() if busyBrian Gix2020-06-181-2/+52
| | | | | | | | | | | We require the successful return of JoinComplete() method before handling subsequent Attach() or Leave() method calls. To simplify the construction of Applications, we will accept one of these calls up to 1 second prior to receiving the final return status of JoinComplete, which tells us that the Application is ready to use the node. If the node is still not ready after the deferral, Attach and/or Leave will fail.
* mesh: Rename IVUpdate import flag to IvUpdateMichał Lowas-Rzechonek2020-06-161-1/+1
| | | | Name change for consistency with "IvIndex" property.
* mesh: Add "node is busy" check for Leave() & Attach()Inga Stotland2020-06-101-1/+9
| | | | | | | | | | | | | | | This introduces the following behavior change for those methods on Network interface that specify node token as an input parameter Leave() method: If Leave method is called for a node that is being processed as a result of a Create, Import, Join or Attach method calls in progress, node removal is not allowed and org.bluez.mesh.Error.Busy error is returned. Attach() method: If Attach method is called for a node that is being processed as a result of a Create, Import or Join method calls in progress, node attachment is not allowed and org.bluez.mesh.Error.Busy error is returned.
* mesh: Add destroy callback to dbus_send_with_timeout()Inga Stotland2020-06-101-6/+6
| | | | | | This adds a destroy callback as a function parameter to dbus_send_with_timeout() to allow automatic release of user data on either reply or timeout.
* mesh: Clean up Join() methodInga Stotland2020-05-221-27/+22
| | | | | | This consolidates various places where a pending response to Join() is created and makes sure that l_dus_message_unref() is called correctly.
* mesh: Fix memory leak in Create, Import & Attach methodsInga Stotland2020-05-221-0/+4
| | | | | | This ensures that every time l_dbus_message_ref() is used to preserve a message for a pending method reply, there is a matching call to l_dbus_message_unref().
* mesh: Clean up Attach() method callInga Stotland2020-05-221-21/+8
| | | | | This consolidates error return form one place: off a callback with unsuccessful status.
* mesh: Clean up Import() method callInga Stotland2020-05-221-26/+7
| | | | | This removes unnecessary failing conditions in Import() call and simplifies iterations through "flags" dictionary.
* mesh: Create a queue of pending requests in mesh_init()Inga Stotland2020-05-221-10/+4
| | | | | This removes unnnecessary checking for queue existence every time either Attach(), Create() or Import() methods are called.
* mesh: Add finalization of a newly created nodeInga Stotland2020-05-221-2/+2
| | | | | | | | | | | | When a new node is created as a result of successful completion of either Join() or Create() or Import() methods and has been confirmed via successful token delivery to the application, clean up node's D-Bus resources (application path, element paths, etc) that have been gathered during the initial GetMAnagedObjects() call. Also, remove the agent instance associaed with the new node. These resources will be re-populated after the Attach() call verifies the node's integrity.
* mesh: Remove unused structure memberInga Stotland2020-05-221-3/+0
| | | | This removes unused "agent" member from join_data structure.
* mesh: Fix segfault caused by re-enabling of HCI controllerInga Stotland2020-05-171-1/+8
| | | | | | | | | | | | | This fixes the crash that occurs when a controller used by bluetooth-meshd is removed and then added back again. Also, correctly restart scanning when the controller is re-enabled. Backtrace: 0x00005618e754d040 in ?? () 0x00005618e6e12d9a in io_ready_callback () at mesh/mesh.c:174 0x00005618e6e3d2c8 in l_queue_foreach () at ell/queue.c:441 0x00005618e6e37927 in request_complete () at src/shared/mgmt.c:261
* mesh: Fix valgrind memory leak warningsBrian Gix2020-05-151-0/+4
| | | | | These warnings are caused by not completely freeing memory allocations at shutdown, and are not serious, but they make valgrind output cleaner.
* mesh: Fix valgrind memory leaksBrian Gix2020-05-151-1/+4
| | | | | These memory leaks are ones that will compound over time with node creation and deletion.
* mesh: Add Time-outs to critical dbus send-with-repliesBrian Gix2020-04-141-5/+5
| | | | | | | JoinComplete() dbus method calls are the only time that node tokens are delivered to client Applications, so if the call fails for any reason (including time-outs) the daemon has a way to clean-up the stale unused node data.
* mesh: Change API to deliver tokens via JoinCompletePrzemysław Fierek2020-04-141-15/+53
| | | | | | | | This patch changes Import and CreateNetwork API to deliver tokens via the JoinComplete method call. When application doesn't raise any error during handling JoinComplete then it is assumed that the token has been saved, otherwise when application replies with an error message then the node is removed.
* mesh: Fix invalid app_path on 'Join'Przemysław Fierek2020-04-101-3/+1
| | | | | | This patch fixes invalid app_path on 'Join' method call - the daemon tried to use the value of app_root API argument, while it should use path discovered by scanning result of GetManagedObjects() call.
* mesh: rework incoming advertisement filteringBrian Gix2020-02-261-3/+7
| | | | | | | Future versions of Mesh will introduce new advertising packets, which do not fit in the limited and rigid filtering currently used. This minor rewrite allows registering and receiving of *any* AD types, including the filtering on multiple octets of the incoming AD parts.
* mesh: Add mesh-main.conf file with general mesh configurationInga Stotland2019-12-161-5/+97
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* mesh: Fix memory leak in Join() API callBrian Gix2019-12-041-2/+5
|
* mesh: Fix io inititalization sequenceInga Stotland2019-11-151-5/+28
| | | | | | | | | | | 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.
* mesh: Fix segmentation fault on Join() callInga Stotland2019-10-051-2/+5
| | | | | | | | | | | | | | | | | | | | 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.
* mesh: Implement Import() D-Bus API of org.bluez.mesh.Network1 interfaceMichał Lowas-Rzechonek2019-08-011-2/+113
| | | | | | | | | This method allows local nodes to be imported from an external provisioning database, enabling applications to create mesh nodes without using provisioning procedure. The procedure is similar to provisioning procedure, but all data exchange happens over D-Bus.
* mesh: Manage node config directory in mesh-configInga Stotland2019-07-151-5/+10
| | | | | | | | | | | | | | | | | | | 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)
* mesh: Convert provisioning pkts to packed structsBrian Gix2019-07-141-1/+1
| | | | | | 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.
* mesh: Expose mapping function for D-Bus errorsBrian Gix2019-07-141-4/+4
|
* mesh: Move HCI handling to mesh-io-genericMichał Lowas-Rzechonek2019-06-241-177/+12
| | | | | | | | | | | 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.
* mesh: Remove unnecessary includes from .c filesInga Stotland2019-05-171-2/+1
|
* mesh: Update copyright datesInga Stotland2019-05-171-1/+1
|
* mesh: Add CreateNetwork method() implementationInga Stotland2019-05-101-2/+68
| | | | | | | | | | | 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.
* mesh: Use node uuids as storage directory namesMichał Lowas-Rzechonek2019-05-081-0/+7
| | | | | | | | | | | 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
* mesh: Clean up processing of Attach() methodInga Stotland2019-05-021-43/+26
| | | | | | 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.
* mesh: Create and store random token per nodeBrian Gix2019-04-091-3/+3
| | | | | Fix issue with device key being used as a token. Token now seperate, and with a portable representation in the node database.
* mesh: Fix array processing in Send, Publish, JoinInga Stotland2019-03-071-7/+4
| | | | | | Use correct parameters when calling l_dbus_message_iter_get_fixed_array(). Also, check the return value and the length of the processed array and return an error if the checks fail.
* mesh: Implement Leave() method on Network interfaceInga Stotland2019-02-281-1/+18
| | | | | | This implements D-Bus Leave() method that results in complete removal of node information from the system, including configuration files from storage directory.
* mesh: Re-arrange node cleanup functionsInga Stotland2019-02-281-8/+6
| | | | | Rename node_free() to node_remove() and consolidate clean up operations. Change declarations for internally used functions to static.
* mesh: Remove unnecessary variable initializationInga Stotland2019-02-041-1/+1
|
* mesh: Add MGMT bypass when specifying controllerBrian Gix2019-02-041-7/+13
| | | | | | If Daemon is started with an explicit controller specified, the MGMT search for an unused shared controller is bypassed, and the controller is opened directly.
* mesh: Fix logic when cleaning up incomplete provisioningInga Stotland2019-01-221-5/+7
| | | | | | Do not call acceptor_cancel() if the provisioning has been completed, either fail or success. Acceptor automatically takes care of cleanup on completion, either successful or not.
* mesh: Clean up when finishing the Join callInga Stotland2019-01-141-34/+25
| | | | | | | | Consolidate multiple instances where the pending Join data is freed into calling one function free_pending_join_call(). Also, add checks for NULL data in cleanup functions for storage, agent and provisioning acceptor.
* mesh: Fix reading device UUID from Join() callInga Stotland2019-01-141-1/+4
| | | | | Supply correct parameters to l_dbus_message_iter_get_fixed_array to get the location from where to read UUID value.
* mesh: Implement org.bluez.mesh.Network APIInga Stotland2019-01-081-141/+485
| | | | | | | | | This implements the following methods of org.bluez.mesh.Network interface: Join(), Attach(), Cancel(). The methods are described in doc/mesh-api.txt document. Also, add changes to reflect that the single daemon now handles multiple local mesh nodes.
* build: Move declaration of _GNU_SOURCE back into individual source filesMarcel Holtmann2018-12-061-0/+1
|
* mesh: Add start up management command chainInga Stotland2018-09-061-23/+230
| | | | | | This allows co-existense of meshd and bluetoothd. meshd will automatically take control of the first available LE-capable controller that is powered down.
* mesh: Source files for mesh access layer and utilitiesInga Stotland2018-08-201-0/+184
This adds initial implementation of BT Mesh access layer functionality plus utilities.