summaryrefslogtreecommitdiff
path: root/mesh/model.c
Commit message (Collapse)AuthorAgeFilesLines
* mesh: Add internal Mesh Private Beacon modelBrian Gix2023-01-301-1/+9
| | | | | Adds recgnition that the Mesh Private Beacon model is internal and foundational, without bindings.
* mesh: Add Remote ProvisioningBrian Gix2023-01-301-5/+22
| | | | | | | | Add Remote Provisioning Server Add Remote Provisioning Client Remove local scanning/provisioning Add delete-all dev key function Add NPPI procedures
* mesh: Do not accept publication for unbound appkeyIsak Westin2022-09-221-1/+2
| | | | | If a user tries to configure publication of a model with an appkey that is not bound to that model, an error should be returned.
* mesh: Fix memory leak and NULL pointer dereferenceInga Stotland2020-11-101-3/+5
| | | | | | | This fixes a potential NULL pointer dereferencing in mesh_model_pub_set() when virtual address publication cannot be successfully stored. Also, fix a minor memory leak that may occur on unsuccessful model initialization from storage.
* 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: Remove unused timing variable tx_startInga Stotland2020-09-031-6/+0
| | | | | In model.c, tx_Start is a static variable, dynamically set, but never used. Is removed now.
* mesh: Move RPL check from model to net layerInga Stotland2020-08-281-14/+4
| | | | | | | | | Check whether an incoming message has an RPL entry prior to handing it over to model layer for processing. If present in RPL or the RPL queue is full, ignore the incoming message. If the incoming message is processed successfully, add the message as a new RPL entry.
* mesh: Handle "options" dictionary in Send/Publish methodsInga Stotland2020-08-261-3/+3
| | | | | | | | | | | | | | | | | | | This adds processing of "options" dictionary argument in Send, DevKeySend & Publish methods on mesh.Node interface. This new argument is a dictionary that currently has only one new key word defined for Send() and DevKeySend(): "ForceSegmented" - to force small payloads to be sent as one-segment messages In case of Publish(), and additional keyword is defined "Vendor" - 16-bit Company ID as defined by the Bluetooth SIG Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification. Also, the addition of "options" dictionary to Publish allows to eliminate VendorPublish() method (taken care by "Vendor" keyword).
* mesh: Use valid net key index when handling Send callInga Stotland2020-08-221-2/+0
| | | | | | | Retrieve value of bound Net Key index based on the value of passed AppKey index. Check if the key is present and fail early in case of error. Also, pass the correct NetKey index to model layer in mesh_model_send(), instead of hard coded 0.
* mesh: Use correct retransmit parameters for publicationsInga Stotland2020-08-221-26/+33
| | | | | | This adds previously missing retransmit count and interval values specific to model publications. The values are configured by Config CLient and may be different to each model.
* mesh: Send correct NetKey index in DevKeyMessageReceivedInga Stotland2020-08-201-1/+2
| | | | | | The value of net_index in DevKeyMessageReceived() method must be set to the value of a subnet index on which a device key encoded message has been received. Was hard coded to 0. Fixed.
* mesh: Check for enabled modes when dst is fixed addressInga Stotland2020-08-201-21/+0
| | | | | | This moves the check for incoming messages addressed to fixed addresses, e.g. RELAY, PROXY, FRIEND. If the corresponding feature is not enabled, the message is not processed.
* mesh: Make mesh config model binding API consistentInga Stotland2020-08-131-2/+2
| | | | | | This changes the order of function arguments in mesh_config_model_binding_add() and mesh_config_model_binding_del() to make them consistent with the rest of mesh_config_model... APIs
* mesh: Fix model ID prior to calling mesh config functionsInga Stotland2020-08-131-4/+8
| | | | | | | | Model IDs for SIG defined models need to be stripped off SIG_VENDOR value used for internal housekeeping prior to calling functions that save new model state in node configuration. Also, remove duplicate statements for model lookup in node config.
* mesh: Fix element index look up for config model subsInga Stotland2020-08-111-7/+8
| | | | | Use element address for looking up element index (subscription address was erroneously used to perform the lookup).
* mesh: Fix application key binding lookupMichał Lowas-Rzechonek2020-08-111-1/+7
| | | | | | | | Because l_queue_find can't distinguish between entry->data equal to zero and missing entry, has_binding() fails when we bind app key with index 0, via L_UINT_TO_PTR. Bug has been introduced in commit 1a2a6debd
* mesh: Clean up handling of config publication messagesInga Stotland2020-08-101-2/+5
| | | | | | | | This modification allows using a single point for sending out the composed status messages by the Config Server. Also, return Feature Not Supported errror code when credential flag is set, but the node does not support LPN feature
* mesh: Clean up handling of config model binding messagesInga Stotland2020-08-101-14/+6
| | | | | | | This modification allows using a single point for sending out the composed status messages by the Config Server. Also, remove unused definitions for binding functions in node.h
* mesh: Clean up handling of config subscription messagesInga Stotland2020-08-101-88/+123
| | | | | | | | This provides better functional grouping based on whether a group or a virtual label is used for the subscription address. Also, use a single point for sending out the composed Config Server status messages.
* mesh: Use correct TTL value to send model publicationInga Stotland2020-08-071-2/+2
| | | | | | When sending model publishing data, use TTL value configured for that publication instead of the default TTL value used for regular messages.
* mesh: Fix calculation of model publication periodInga Stotland2020-07-291-7/+8
| | | | | | | | This fixes the extraction of bit fields from model publication period octet received as part of Congif Publication Set message. The step resolution field is extracted as upper 2 bits (shift by 6) and the number of steps field is extracted by masking lower 6 bits.
* mesh: Move model functionality out of node.c to model.cInga Stotland2020-07-251-170/+374
| | | | | | | | | This moves the model related code out of node.c to model.c providing for better functional separation of modules. Also, use the value of 0xFFFF for internal representation of vendor ID for BT SIG defined models. This allows to maintain a single internal vendor ID / model ID space.
* mesh: Check app model settings of pub/sub supportInga Stotland2020-07-011-14/+84
| | | | | | | | | | | | | | | | | | | | This adds handling of new options dictionary included with "Models" and "VendorModels" properties on org.bluez.mesh.Element1 interface. Supported (optional) dictionary entries: "Publish" - indicates whether the model supports publication mechanism. If not present, publication is enabled. "Subscribe" - indicates whether the model supports subscription mechanism. If not present, subscriptions are enabled. If a config message related to subscription state is received for a model that does not support subscription mechanism, an error code 0x08, ("Not A Subscribe Model") is sent in response. If a config message related to publication state is received for a model that does not support publication mechanism, an error code 0x07 ("Invalid Publish Parameters") is sent in response.
* mesh: Fix clean-up introduced bugBrian Gix2020-06-081-1/+1
| | | | | | | | | Before the clean-up we were making a useless check of an otherwise unused boolean (net->provisioner) to determine if we should decode with device keys (which was incorrect). This was replaced by a check the node type (node->provisioner). However, the check was incorrect in the first place, and prevents provisioner nodes from decrypting non device key messages.
* mesh: Remove unused/redundant functionsInga Stotland2020-06-081-1/+1
| | | | | This removes mesh_net_provisioner_mode_set (unused) and mesh_net_provisioner_mode_get (duplicates node_is_provisioner)
* mesh: Remove debug-only related callback for packet sendInga Stotland2020-06-011-25/+2
| | | | | | This removes callback for sending every single access layer packet since the callback does nothing but print debug satement. This functionality is mature enough not to require such heavy debugging.
* mesh: Debug output clean upInga Stotland2020-06-011-22/+5
| | | | | This changes l_info() to l_debug() for recurring cases and removes some excessive debug output.
* mesh: Allow short messages to be segmentedBrian Gix2020-03-201-6/+6
| | | | | | | | | | | For added reliability, it is legal to send short messages as "single segment" segmented messages, which require transport layer acknowledgement. This feature is intended for heavy usage in the future so I am adding it now. Further, to support this functionality, an additional queue has been added to allow multiple SAR messages to the same DST to be queued and sent serially.
* mesh: Remove unused parameters from internal rx functionsInga Stotland2020-03-051-10/+7
| | | | | | | | | This removes unused ttl parameter from mesh_model_rx(). The TTL value is not processed at the access layer, so there is no need to pass it to a model. Also, remove "uint32_t dst" parameter from the typedef of mesh_model_recv_cb: providing a just destination address is sufficient for internally implemented models (currently, it's only Config Server)
* mesh: Simplify model virtual pub/sub logicInga Stotland2020-02-261-158/+113
| | | | | This reorganizes the part of the code that handles model publishing and subscribitng to virtual labels.
* mesh: Fix app payload decryption for virtual labelsInga Stotland2020-02-181-4/+4
| | | | | | | This fixes a bug when a virtual label and its size hasn't been passed to a decryption function: instead of always using NULL pointer for label and 0 for lable size, use actual virtual label info if decrypting a payload addressed to a virtual destination.
* mesh: Re-arrange replay protection check and addBrian Gix2020-01-311-13/+10
| | | | | | | Re-arranged for efficiency. Replay Protection was set up as an atomic check-and-add operation. Now we check the message early so we can discard it without taking further action, and only add it to the RPL once fully verified that it was authorized and addressed to us.
* mesh: Apply Replay Protection to all incoming packetsBrian Gix2020-01-301-9/+7
| | | | | | Replay Protection was only being applied against Application Keys, but messages with Device Keys are just as vulnerable, and need to be checked as well.
* mesh: Move Replay Protection to mesh/net.cBrian Gix2020-01-301-1/+1
| | | | | | | The specification calls for a flatter Replay Protection List that applies to all processed messages, regardless of which credentials were used to secure them. So storage and checking is now centralized in mesh/net.c
* mesh: Allow apps to receive DevKey messages from external nodesMichał Lowas-Rzechonek2020-01-141-2/+1
| | | | | | | | | | 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.
* mesh: Clean up node.cInga Stotland2019-12-101-15/+2
| | | | | | 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.
* mesh: fix (re)transmit count & interval stepsAurelien Jarno2019-12-021-2/+2
| | | | | | | | | | | | | | 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.
* mesh: Inform application about model subscriptionsMichał Lowas-Rzechonek2019-11-261-2/+91
|
* mesh: Provide destination address in MessageReceived APIMichał Lowas-Rzechonek2019-11-261-4/+16
|
* mesh: Fix crash after deleting all subscriptionsRafał Gajda2019-11-191-3/+2
|
* mesh: Align appkey_packet_decrypt with dev and virt variants.Michał Lowas-Rzechonek2019-10-031-9/+64
| | | | | | | | | 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.
* mesh: Normalize Access Key AID and Index naming in modelsMichał Lowas-Rzechonek2019-10-031-7/+8
| | | | | | After 8f0839a1c46300ceb1b129d17a3bff446ff79d08, mesh/crypto uses _aid suffix for keys' AID property, so let's change the wording in mesh/model as well.
* mesh: Explicit Remote/Local Device key usageBrian Gix2019-10-011-4/+7
| | | | | | | | | When sending or receiving Device Key (privileged) mesh messages, the remote vs local device key must be specified. This allows Apps to specify Key Ring stored device keys, and sanity checks that the correct key exists before allowing the transmission. Loopback messages to local servers *must* use keys from the Key Ring to indicate privilege has been granted.
* mesh: Make mesh-config API more consistentInga Stotland2019-10-011-5/+2
| | | | | | | This changes the prototypes for mesh_config_model_binding_add() and mesh_config_model_binding_del() to take the element's address as input parameter instead of the element's index. The change aligns the API with other functions that handle storage of model states.
* mesh: Handle messages sent to a fixed group addressInga Stotland2019-09-081-1/+31
| | | | | | | | This handles the case when an inbound message is addressed to a fixed group, i.e., all-proxies, all-friends, all-relays and all-nodes. The message is delivered to a primary element only, and, with the exception of all-nodes case, if the corresponding feature is enabled on the node.
* mesh: Check address range passed to ImportRemoteNodeMichał Lowas-Rzechonek2019-07-191-1/+1
| | | | | +changed "not authorized" error to "invalid args" when managing device key for local address range
* mesh: Propagate Net Index up Rx message chainBrian Gix2019-07-181-66/+63
| | | | | | | | | 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.
* mesh: Manage node config directory in mesh-configInga Stotland2019-07-151-1/+0
| | | | | | | | | | | | | | | | | | | 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: Use mesh_config APIs to store node configurationInga Stotland2019-07-151-5/+10
| | | | | | | | 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.
* mesh: Confine dependency on json-c to mesh-config-json.cInga Stotland2019-07-151-1/+0
| | | | | | | | 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.