Commit Graph

384 Commits

Author SHA1 Message Date
Michał Lowas-Rzechonek
c957b8ea6f mesh: Fix D-Bus node path
According to doc/mesh-api.txt, node object should be located at
/org/bluez/mesh/node.
2019-07-01 09:17:43 -07:00
Michał Lowas-Rzechonek
3c143c7158 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.
2019-06-27 10:13:35 -07:00
Inga Stotland
a0ced2910a 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.
2019-06-26 10:42:01 -07:00
Rafał Gajda
e0b1d64e39 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.
2019-06-26 10:24:54 -07:00
Michał Lowas-Rzechonek
12b984d1d4 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.
2019-06-24 09:04:44 -07:00
Inga Stotland
510224f47c 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.
2019-06-12 14:36:38 -07:00
Jakub Witowski
231c50a1ff 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
2019-06-11 15:26:39 -07:00
Inga Stotland
9c64e35282 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.
2019-06-06 12:12:56 -07:00
Inga Stotland
0f5cf35948 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.
2019-06-06 12:12:56 -07:00
Inga Stotland
0f8cf75f62 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.
2019-06-06 11:58:31 -07:00
Inga Stotland
5bcce2ce59 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.
2019-06-06 11:58:22 -07:00
Brian Gix
632e67f8d6 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.
2019-05-31 16:46:34 -07:00
Brian Gix
dfed483946 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.
2019-05-31 16:46:34 -07:00
Jakub Witowski
75cd5b382e 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.
2019-05-24 07:52:58 -07:00
Brian Gix
2565283cbb 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.
2019-05-24 07:52:58 -07:00
Brian Gix
4d95426caa 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.
2019-05-24 07:52:58 -07:00
Brian Gix
77950fd427 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.
2019-05-24 07:52:58 -07:00
Brian Gix
84610cd7cb 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.
2019-05-24 07:52:58 -07:00
Brian Gix
638622af5f mesh: Centralize definition of PRIMARY_NET_IDX 2019-05-24 07:52:58 -07:00
Inga Stotland
6df5c5e379 mesh: Remove unnecessary includes from .c files 2019-05-17 13:14:40 -07:00
Inga Stotland
af3f7f1b09 mesh: Update copyright dates 2019-05-17 13:14:40 -07:00
Brian Gix
3242dd3db9 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.
2019-05-15 09:36:42 -07:00
Brian Gix
8b179cbd1d mesh: Fix file open error checking and permissions 2019-05-15 09:36:42 -07:00
Inga Stotland
f66e29d566 mesh: Add skeleton for org.bluez.mesh.Management1 interface
This adds bare-bones imlementation of methods on org.bluez.mesh.Management1
interface.
2019-05-15 09:12:38 -07:00
Inga Stotland
0af87c6c6c 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.
2019-05-15 09:12:38 -07:00
Brian Gix
3545edb6a4 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.
2019-05-13 12:12:20 -07:00
Brian Gix
ce3031a6b2 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.
2019-05-13 12:12:20 -07:00
Inga Stotland
97b8bbc47e 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.
2019-05-10 07:39:57 -07:00
Michał Lowas-Rzechonek
64670a4a31 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
2019-05-08 11:31:18 -07:00
Inga Stotland
d6dce2bd37 mesh: Unify processing of GetManagedObjects result
This combines processing of results obtained from GetManagedObjects
request for both Attach() and Join() methods
2019-05-02 08:47:39 -07:00
Inga Stotland
0639e17741 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.
2019-05-02 08:47:39 -07:00
Inga Stotland
65844fe23f 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.
2019-05-02 08:47:39 -07:00
Inga Stotland
d76a4cd489 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.
2019-05-02 08:47:39 -07:00
Inga Stotland
4dbe6f78c6 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.
2019-04-22 16:44:04 -07:00
Inga Stotland
1e5e98c3b3 mesh: Fix structure memeber initialization
This fixes incorrectly reversed assignment of "friend" value in
convert_node_to_storage()
2019-04-22 16:44:04 -07:00
Inga Stotland
ecf001daa1 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
2019-04-22 16:44:04 -07:00
Inga Stotland
0cf59dd120 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()
2019-04-19 08:33:27 -07:00
Brian Gix
4d3c4fd64d 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.
2019-04-16 10:00:35 -07:00
Brian Gix
c051df3cf9 mesh: Create and store random token per node
Fix issue with device key being used as a token. Token now seperate, and
with a portable representation in the node database.
2019-04-09 09:58:22 -07:00
Brian Gix
3ad9090181 mesh: Store node state variables prior to response
Remotely set node state variables need to be saved to the file system
or other NVM prior to returning success status.
2019-03-26 08:59:30 -07:00
Brian Gix
b1adefb032 mesh: Fix json-c calling conventions
Fix issue assuming that failed calls to json_object_object_get_ex() will
always NULL the out parameter. Re-coded to always check the returned
boolean for success or failure.
2019-03-26 08:59:30 -07:00
Inga Stotland
b9b070ff30 mesh: Fix adding model app key binding
This fixes the situation when a new app key binding is being
added to a model and the list of bindings does not exist yet.
If the list does not exist, it is created and the binding is
added to it.

Also, remove unnecessary memory alloc check when model subscriptions
are added.
2019-03-22 09:34:53 -07:00
Inga Stotland
b57dd2de74 mesh: Correctly initialize node's vendor models
This fixes vendor model initialization based on node properties
collected during Join() method call.
2019-03-21 14:04:42 -07:00
Stotland, Inga
70fab12bf2 mesh: Fix bug with adding more than one app key
Fixed problem where if the appKeys array already exists, that
new add key requests were rejected.
2019-03-11 14:57:39 -07:00
Inga Stotland
076f20fe34 mesh: Store model publication settings in config file
This adds functionality to enable storing model publication
parameters in node configuration file.

Also, fix calculations of model publication period.
2019-03-11 14:50:03 -07:00
Inga Stotland
fd77b3199a mesh: Save model subscription updates to config file
This adds functionality in Config Server model to save changes in
node configuration file when model subscriptions are added, deleted or
overwritten.
2019-03-11 14:50:03 -07:00
Inga Stotland
2da78fd479 mesh: Add json config functions to save pub/sub updates
This adds functions to save updates to model subscriptions and
publication in JSON format.
2019-03-11 14:50:03 -07:00
Inga Stotland
a00dd4ea79 mesh: Set node ID for a newly provisioned node
When a new node is created after successful provisioning, a 4-digit
hex node id needs to be generated and preserved.
2019-03-11 14:50:03 -07:00
Brian Gix
f5f4267027 mesh: Enable local loopback
Implements mechanism to allow direct messaging between local
nodes without requiring an external relay node.
2019-03-11 14:50:03 -07:00
Inga Stotland
2ada1c13f6 mesh: Fix array processing in Send, Publish, Join
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.
2019-03-07 12:58:09 -08:00
Inga Stotland
8e0cbe9d5e mesh: Implement Leave() method on Network interface
This implements D-Bus Leave() method that results in complete removal
of node information from the system, including configuration files
from storage directory.
2019-02-28 08:54:47 -08:00
Inga Stotland
e5ab6013e6 mesh: Cleanup storage save and remove procedures
To remove a node config directory completely, the directory
needs to be empty. Both node.json and node,json.bak files must
are deleted.

Also, change storage_save_config() type to void to eliminate
meaningless checks.
2019-02-28 08:54:47 -08:00
Inga Stotland
ddb5ed7918 mesh: Re-arrange node cleanup functions
Rename node_free() to node_remove() and consolidate clean up operations.
Change declarations for internally used functions to static.
2019-02-28 08:54:47 -08:00
Brian Gix
ae44c8f7c2 mesh: Fix type checking for 32 vs 64 bit systems 2019-02-28 08:54:12 -08:00
Brian Gix
9e6da22ed8 mesh: Fix for file naming convention 2019-02-21 16:21:30 -08:00
Inga Stotland
4a21925543 mesh: Return correct error code for AppKey List command
If AppKey List command is called with a network key index that
is not valid for the node, return Invalid NetKey Index error code
2019-02-19 08:54:07 -08:00
Inga Stotland
126f01f83a mesh: Save newly added or updated app key to config file
This separates mesh_db_app_key_add() into distinct functions:
mesh_db_app_key_add() and mesh_db_app_key_update() which will be called
based on whether an application key is newly added or updated.
2019-02-19 08:54:07 -08:00
Inga Stotland
52b840d0a5 mesh: Separate functions for app key add and update
This splits appkey_key_add() into two separate functions:
app_key_add() and app_key_update().
Fix checks for miscellaneous invalid conditions and return
appropriate error status.
2019-02-19 08:54:07 -08:00
Marcel Holtmann
a0fc007256 mesh: Use l_malloc instead of l_new with a cast 2019-02-16 08:23:43 +01:00
Marcel Holtmann
425ca24613 mesh: Use PRIx64 instead of %16.16lx 2019-02-16 08:00:08 +01:00
Inga Stotland
8d8066d88a mesh: Save newly added or updated net key to config file
This separates mesh_db_net_key_add() into distinct functions:
mesh_db_net_key_add() and mesh_db_net_key_update() which will be called
based on whether a network key was newly added or updated.
2019-02-12 15:30:53 -08:00
Inga Stotland
9fe6a99f08 mesh: Save key refresh phase state to node config file
This adds implementation for saving the key refresh phase to
a node configuration file in JSON format. When the key refresh
procedure is finished, the old network keys are remove from the
configuration file.
2019-02-12 15:30:53 -08:00
Inga Stotland
8c4c46e57d mesh: Declare internal functions as static
This renames mesh_net_key_refresh_finish() to key_refresh_finish() and
mesh_net_key_phase_two() to key_refresh_phase_wo() and changes the
function declaration to static since they are called only within net.c
2019-02-12 15:30:53 -08:00
Inga Stotland
d69e29af66 mesh: Add function to restore net key state from storage
This creates subnet state based on saved network key state:
current keys and, if present, updated keys.
Secure network beacon is generated according to key refresh phase.
2019-02-12 15:30:53 -08:00
Inga Stotland
c1551f2027 mesh: Separate functions for net key add and update
This splits mesh_net_key_add() into two separate functions:
mesh_net_key_add() and mesh_net_key_update().
mesh_net_key_update() essentially replaces mesh_net_kr_phase_one()
since switching to Key Refresh phase one can only be triggered
by successful network key update.
2019-02-12 15:30:53 -08:00
Inga Stotland
64441a327a mesh: Add D-Bus policy for Bluetooth mesh daemon
This adds new D-Bus policy file bluetooth-mesh.conf
2019-02-04 12:04:42 -08:00
Inga Stotland
d8e2e394f9 mesh: Remove unnecessary variable initialization 2019-02-04 12:04:42 -08:00
Inga Stotland
c953e1c7f3 mesh: Add README file
This file contains instructions for Bluetooth mesh daemon
    configuration and description of the persistent storage.
2019-02-04 12:04:42 -08:00
Brian Gix
6f0b95a2a4 mesh: Add MGMT bypass when specifying controller
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.
2019-02-04 12:04:42 -08:00
Inga Stotland
bb61884de5 mesh: Fix logic when cleaning up incomplete provisioning
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.
2019-01-22 12:41:08 -08:00
Brian Gix
cca48f305b mesh: Fix Relaying for multiple nodes
Relay is now a cooperation between all the nodes on the daemon.
If any one or more nodes have relay enabled and a received packet
is addressed to a Group, or a non-present Unicast address, then the
packet's TTL is decremented and it is resent.
2019-01-22 12:39:51 -08:00
Brian Gix
452b7d7e87 mesh: Cleanup PB-ADV transport on Prov Close
PB-ADV always used for provisioning, so must always  be cleaned up.
2019-01-14 15:00:25 -08:00
Inga Stotland
9ce5a51872 mesh: Clean up when finishing the Join call
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.
2019-01-14 14:02:09 -08:00
Inga Stotland
1ec2082582 mesh: Fix reading device UUID from Join() call
Supply correct parameters to l_dbus_message_iter_get_fixed_array
to get the location from where to read UUID value.
2019-01-14 14:02:09 -08:00
Brian Gix
39c2e03f1b mesh: remove uneeded BDADDR type check
BT_HCI_EVT_LE_ADV_REPORT only comes from legal LE events
2019-01-14 14:01:37 -08:00
Inga Stotland
00d7b3cbe5 mesh: Update init for D-Bus and multi-node support
This adds D-Bus initialization, modifications for mulitple nodes and
optional control of storage directory location.
2019-01-08 08:26:22 -08:00
Brian Gix
f4cf2c2312 mesh: Clean up debug logging and comment style 2019-01-08 08:26:22 -08:00
Inga Stotland
e25f480527 mesh: Clean up App Key configuration and storage
Fix miscellaneous issues: use l_debug instead of l_info for debug logs;
remove "local" from functions names (this handles only local app keys);
add missing App Key index initialization.
2019-01-08 08:26:22 -08:00
Inga Stotland
a7a5cca049 mesh: Implement Provisioning Agent D-Bus interface
This implements the time limited and user interaction D-Bus API as
required for Out-Of-Band authentication during provisioning, and as
described in doc/mesh-api.txt.
2019-01-08 08:26:22 -08:00
Inga Stotland
fb65010cb8 mesh: Restructure model services for multiple nodes
This handles checking that incoming Mesh messages obey all
authentication rules regarding subscriptions and encryption
key bindings on a per node basis, before forwarding via D-Bus
to external applications that are authorized to handle them.
2019-01-08 08:26:22 -08:00
Inga Stotland
23cd727b62 mesh: Add support for storage of multiple nodes
Add functionality to support storage of multiple subnets, model
subscriptions and publications per mesh node.
2019-01-08 08:26:22 -08:00
Brian Gix
535e83b73d mesh: Restructure I/O for multiple controllers
Restructured access to Bluetooth Controllers to allow the usage of
multiple controllers, and potentially functionality tailored to Mesh
specific features.
2019-01-08 08:26:22 -08:00
Inga Stotland
c1f5df90bc mesh: Add multi-node support to Config Server model
The Config Server model is rewritten to allow control of mutiple nodes
on the local device. The updates to a node configuration (e.g., keys,
model subscriptions/publications, etc.) as set by a remote Config Client
are routed to a properly addressed node and stored in a protected
configuration file corresponding to that node.
2019-01-08 08:26:22 -08:00
Inga Stotland
7c11237d9f mesh: Implement org.bluez.mesh.Network API
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.
2019-01-08 08:26:22 -08:00
Brian Gix
7005bb77bf mesh: Re-arrange provisioning for DBus API
This restructures provisioning so that it is a service of high level
d-Bus based API and may be potentially used on mulitple provisioning
transports.
2019-01-08 08:26:22 -08:00
Inga Stotland
72486a7896 mesh: Add hex string and debug logging utilities
This adds frequently used functionaility for logging and
saving/retrieval of long (128+ bit) hexidecimal data.
2019-01-08 08:26:22 -08:00
Brian Gix
3f10f9d3da mesh: Set unchanging variables to const 2019-01-08 08:26:22 -08:00
Brian Gix
c42fd5bd6b mesh: Rewrite Controler interface for full init
Functionaility has been added to allow a BT 4.0 or later controller
to be used for Advertising based Mesh usage, regardless of how it
was previously initialized.
2019-01-08 08:26:22 -08:00
Brian Gix
37c0607909 mesh: Implement provisioning initiator side
This functionaility (originally found in provision.c) was rewritten
as the Initiator side only of the provisioning procedure.  If the
local device owns and controls access to a mesh network, this is the
side of the provisioning procedure that it must use to bring new
unprovisioned devices into the network as Nodes.
2019-01-08 08:26:22 -08:00
Brian Gix
5f871831a7 mesh: Implement provisioning acceptor
This implements acceptor side of the provisioning procedure when an
unprovisioned device is brought into an existing mesh network by a
remote Provisioner. Upon the successful completion of the procedure
the device becomes a participating mesh node in thie network.
2019-01-08 08:26:22 -08:00
Brian Gix
98ef51901d mesh: Add direction agnostic PB-ADV implementation
Originally found in prov.c, this file implements the PB-ADV
provisioning transport.  It may be used by either the
Acceptor or the Initiator side of the Provisioning procedure,
but only one session may be active at a time.
2019-01-08 08:26:22 -08:00
Brian Gix
628ab54fef mesh: Rewrite Network layer for multiple nodes
The Network layer of the Mesh Daemon has access to all
network keys that have been entrusted to Nodes on the local
device, and acts as a MUX by forwarding incoming messages
to some, all or none of the local Nodes, based on addressing
and keys.

It also is reponsible for for applying Network layer encryption
to outgoing messages, and for relaying messages based on TTL.
2019-01-08 08:26:22 -08:00
Inga Stotland
39db4f7d29 mesh: Add org.bluez.mesh.Node D-Bus API support
Add support for maintaining multiple local nodes within a single daemon.
A mesh node is an adressable entity in Bluetooth mesh. A local mesh
capable device may have multiple distinct representations as a mesh
node on different mesh networks. Each such representation (aka "node
configuration") maintains runtime storage of encryption/decryption
keys, model subscriptions and publications, etc.

Also, implement D-Bus methods for org.bluez.mesh.Node interaface:
Send(), Publish(), VendorPublish()

Also, add support for generating temporary mesh node entity for Join()
method and verification of credentials for Attach() method
2019-01-08 08:26:22 -08:00
Inga Stotland
20146a4f2f mesh: Rewrite storage for multiple nodes
Multiple node configurations are now stored in priviledged location
to prevent unauthorized access to the security material entrusted to
each node.
Default storage location is /var/lib/bluetooth/mesh.
2019-01-08 08:26:22 -08:00
Inga Stotland
dc21082bd9 mesh: Internal errors
Add error codes that map to specific faults that may occur while
using the mesh D-Bus API.
2019-01-08 08:26:22 -08:00
Inga Stotland
82e5d87fac mesh: Add utilities for DBus support
These files implement helper routines for common D-Bus functionality.
2019-01-08 08:26:04 -08:00
Brian Gix
e3512c7401 mesh: Structural changes for mesh
Delete composition.json since it not used for initialization anymore.
Delete btmesh.c as it is not used anymore.
Delete display.c and display.h, move retained functionality to util.c
Delete prov.c, move retained PB-ADV functionality to pb-adv.c
Delete provision.c, split retained functionality between
prov-acceptor.c and prov-initiator.c
2019-01-08 07:50:35 -08:00
Marcel Holtmann
261948090e build: Move declaration of _GNU_SOURCE back into individual source files 2018-12-06 21:28:18 +01:00
Marcel Holtmann
a18ad9bb9e mesh: Avoid loop variable initial declarations 2018-12-04 17:30:42 +01:00
Marcel Holtmann
f0619047c2 mesh: Fix various compiler warnings 2018-12-03 19:54:33 +01:00
Brian Gix
d800a11512 mesh: Up-rev ELL dependancies to >= 0.14 2018-11-28 08:41:21 -08:00
Brian Gix
994932b740 mesh: Refactor friend.c and net.c for central key DB
To enable multiple local nodes and friendships to
coexist, and minimize redundant encryption processing
2018-10-03 13:42:52 -07:00
Brian Gix
df337d8d50 mesh: Add centralized caching Net Key management 2018-10-03 13:42:52 -07:00
Inga Stotland
e4cf43fc62 mesh: Add clean up on start up failure
Call bt_shell_clanup if failed to start the tool.
2018-09-11 11:36:08 +03:00
Inga Stotland
a38796b18d mesh: Add start up management command chain
This allows co-existense of meshd and bluetoothd. meshd will
automatically take control of the first available LE-capable
controller that is powered down.
2018-09-06 12:38:17 -07:00
Luiz Augusto von Dentz
6d2ecb1b54 mesh: Fix uninitilized error
This fixes the following error:

mesh/cfgmod-server.c: In function ‘cfg_srv_pkt’:
mesh/cfgmod-server.c:103:5: error: ‘pub’ may be used uninitialized in
this function [-Werror=maybe-uninitialized]
2018-08-24 17:52:17 +03:00
Brian Gix
a4f6905ea9 mesh: Fixed warning-to-error from GCC 8.1.1
Fixed compiler flagged unsafe usage of strncpy
2018-08-24 17:52:16 +03:00
Inga Stotland
d38013e7df mesh: Sample device composition in JSON format
This is a sample unprovisioned device composition described
in JSON format.
2018-08-20 12:48:27 -07:00
Inga Stotland
e594ed81be mesh: Read and write mesh configuration in JSON format
This adds implementation for parsing and writing Mesh configuration
into JSON format. Also, parse stored unprovisioned device composiotion.
2018-08-20 12:48:26 -07:00
Inga Stotland
6a0904314d mesh: Mesh config server model 2018-08-20 12:48:25 -07:00
Inga Stotland
7c47188f73 mesh: Source code for handling access layer mux/demux 2018-08-20 12:48:24 -07:00
Inga Stotland
e594aefd3a mesh: Source files for mesh access layer and utilities
This adds initial implementation of BT Mesh access layer
functionality plus utilities.
2018-08-20 12:48:23 -07:00
Inga Stotland
6fbc4c83e1 mesh: Header files for mesh access layer and utilities
This adds initial implementation of Mesh access layer functionality
2018-08-20 12:48:21 -07:00
Brian Gix
ef60219269 mesh: Add Accessors to Transport layer data 2018-08-20 12:48:21 -07:00
Brian Gix
37ebf9eb0b mesh: Upper and Lower mesh transport 2018-08-20 12:48:20 -07:00
Brian Gix
16af0cf95b mesh: Provisioning logic for mesh 2018-08-20 12:48:18 -07:00
Brian Gix
22d6107689 mesh: Initial Mesh Friendship support 2018-08-20 12:48:16 -07:00
Brian Gix
4120a514e9 mesh: Infrastructure for Mesh daemon 2018-08-20 12:48:16 -07:00
Brian Gix
7c9a8c7176 mesh: Mesh crypto support 2018-08-20 12:48:15 -07:00
Brian Gix
603743a6ef mesh: Shared private meshd interfaces 2018-08-20 12:48:14 -07:00
Inga Stotland
ef05f4957d tools: Move meshctl sources under tools/mesh directory
This is a temporary location until the unified mesh solution is provided
2018-07-06 13:03:33 +02:00
Inga Stotland
f0d0c48e82 tools: Move meshctl tool under tools directory 2018-07-06 13:03:33 +02:00
Robert Lubaś
1b18e128f3 Mesh: Add Config Beacon to Configuration Model
This patch adds two commands (set and get) to menu config and handles the
incomming status message.
2018-04-05 19:20:29 +03:00
Robert Lubaś
c52903c4fc Mesh: Fix in Config GATT Proxy Set
According to the 4.3.2.10 Config GATT Proxy Set, message should have only 1
byte.
2018-04-05 19:20:29 +03:00
ERAMOTO Masaya
fde2b0580e mesh: Return exit status for non-interactive 2018-03-29 15:42:24 +03:00
Robert Lubaś
4dc3fd37f7 Mesh: Fix TTL in Config Heartbeat Publication Set
In Mesh Profile spec 4.2.17.4 Heartbeat Publication TTL value range is
0x00-0x7F. In cmd_hb_pub_set heartbeat ttl was set to DEFAULT_TTL 0xFF, this
patch fix this by adding ttl param to hb-pub-set.
2018-03-28 15:38:58 +03:00
Atul Rai
382ad0905d Mesh: add 'node-reset' command
This patch adds 'node-reset' command which can be used to reset a
node (other than a Provisioner) and remove it from the network.
2018-03-27 17:04:57 +03:00
Inga Stotland
0a2a2b0c7f mesh/meshctl: Exit cleanly if start up fails
This addresses the following issue: if the program exits
after bt_shell_init() has been called, but prior to calling
bt_shell_run() (e.g., failing to start meshctl due to invalid
input configuration), the original shell is messed up after that.
Calling bt_shell_cleanup() on faiure fixes this.
2018-03-27 13:59:16 +03:00
Robert Lubaś
99209ba5e0 Mesh: Fix proxy PDU SAR msg length
In read_pipe function there was a mishandled case when the msg has
more than one segment. As a result e.g. after provisioning the
capabilities discovery was incorrect parsed.
2018-03-19 17:02:50 +02:00
Atul Rai
1c1f807c30 Mesh: Close net session on device disconnection
On device disconnection, net session is not closed. On next
attempt to provision/connect a device, net session proxy is
not updated by net_session_open() as proxy_in is not NULL.
This causes meshctl to use invalid proxy resulting in below
crash.

0  strlen () at ../sysdeps/x86_64/strlen.S:106
1  0x00007f3a3c8b1ac4 in _dbus_string_init_const () from libdbus-1.so.3
2  0x00007f3a3c89ed15 in ?? () from libdbus-1.so.3
3  0x00007f3a3c89fba0 in dbus_message_new_method_call () from libdbus-1.so.3
4  0x0000000000419880 in g_dbus_proxy_method_call at gdbus/client.c:997
5  0x000000000040ab9d in mesh_gatt_write at mesh/gatt.c:347
6  0x000000000040d761 in send_mesh_pkt at mesh/net.c:1227
7  send_seg at mesh/net.c:1325
8  0x000000000040fa60 in net_access_layer_send at mesh/net.c:2163
9  0x0000000000413c74 in config_send at mesh/config-client.c:418
10 0x0000000000414886 in cmd_composition_get at mesh/config-client.c:470
11 0x000000000041ffd9 in cmd_exec at src/shared/shell.c:356
12 menu_exec at src/shared/shell.c:383
13 0x00000000004203a5 in shell_exec at src/shared/shell.c:426
14 0x0000000000420d24 in rl_handler (input=0x2259aa0 "composition-get ")
at src/shared/shell.c:571
15 0x00007f3a3c45d6f5 in rl_callback_read_char () from libreadline.so.6
16 0x0000000000420229 in input_read at src/shared/shell.c:1034
17 0x0000000000421655 in watch_callback at src/shared/io-glib.c:170
18 0x00007f3a3cb1a04a in g_main_context_dispatch () from libglib-2.0.so.0
19 0x00007f3a3cb1a3f0 in ?? () from libglib-2.0.so.0
20 0x00007f3a3cb1a712 in g_main_loop_run () from libglib-2.0.so.0
21 0x0000000000421bf5 in mainloop_run () at src/shared/mainloop-glib.c:73
22 0x000000000042115a in bt_shell_run () at src/shared/shell.c:962
23 0x0000000000405c5d in main at mesh/main.c:1992
2018-03-18 10:43:12 +02:00
Luiz Augusto von Dentz
480ff6961d mesh: Fix lines going beyond 80 columns 2018-03-01 12:21:04 +02:00
ERAMOTO Masaya
3b4008d00c mesh: Use g_dbus_dict_append_{entry,array}() 2018-03-01 10:49:05 +02:00
Luiz Augusto von Dentz
5d24fe74da mesh/meshctl: Quit when done with command
This ensures that the commands don't stay hanging since bt_shell no
longer quits immediatelly after executing a command.
2018-02-28 16:17:13 +02:00
Steve Brown
48a2c3db1c mesh: node: Correct minor errors
Correct length computation in node_parse_composition()
Correct return value in node_set_model()
  An existing node is not an error
2018-02-25 20:32:14 +02:00
Steve Brown
444af714a2 mesh: prov-db: Correct json database parsing
"composition": {
        "cid": "0002",
        "pid": "0010",
        "vid": "0001",
        "crpl": "000a",
        "features": {
            "relay": false,
            "proxy": true,
            "friend": false,
            "lowPower": false
        },
        "elements": [
            {
                "elementIndex": 0,
                "location": "0001",
                "models": ["0000", "0001", "1001"]
            }
        ]
    },
2018-02-25 20:32:12 +02:00
Steve Brown
287cd9b515 mesh: meshctl: Add subscriptions to node structure and json database
sub-add 0101 c000 1000

              {
                "modelId":"1000",
                "bind":[
                  1
                ],
                "subscribe":[
                  "c000"
                ]
              },
2018-02-16 12:38:20 +02:00
Steve Brown
0412f3843b mesh: meshctl: Conform command and function names
Also improve readability of commands descriptions
2018-02-13 14:05:50 +02:00
Steve Brown
7f33e5cc09 mesh: meshctl: Cleanup status messaging
Remove redundant status tests
  mesh_status_str() also decodes MESH_STATUS_SUCCESS
Regularize text in status messages
Add helper function to print model id
2018-02-13 14:05:48 +02:00
Steve Brown
3cb9770549 mesh: meshctl: Add heartbeat get subscribe and publish
[config: Target = 0100]# hb-pub-get

Set heartbeat for node 0100 status: Success
Destination:	c000
Count:		00
Period:		00
TTL:		ff
Features:	0000
Net_Idx:	0000

[config: Target = 0100]# hb-sub-get

Heartbeat subscription status for node 0100 status: Success
Source:		0100
Destination:	0100
Period:		00
Count:		00
Min Hops:	7f
Max Hops:	00
2018-02-13 14:05:43 +02:00
Steve Brown
30d4b43590 mesh: meshctl: Add set heartbeat subscription command
[config: Target = 0100]# hb-sub-set 0077 0100 2

Heartbeat subscription status for node 0100 status: Success
Source:		0077
Destination:	0100
Period:		01
Count:		00
Min Hops:	7f
Max Hops:	00
2018-01-27 11:12:11 -08:00
Steve Brown
b80e4f58f6 mesh: meshctl: Correct display security
The case of a security command without an argument is not handled
and throws a segv.
2017-12-25 21:05:35 +02:00
Luiz Augusto von Dentz
7a03b61ee8 tools: Remove monitor/uuid.{c,h}
Use the shared/util.h helpers instead.
2017-12-21 10:08:22 -02:00
Steve Brown
0c6ec93755 mesh: meshctl: Make composition-get argument optional
It can't be both optional and required.

[config: Target = 0100]# composition-get 0
Unable to parse optional command arguments
2017-12-20 09:53:04 +01:00
Inga Stotland
c07b067ff1 mesh: meshctl: make model parsing more manageable
Extract functionality for finding an existing model from
parse_configuration_models() into new function find_configured_model().
This removes confusing logic from overloaded implementation of
parse_configuration_models().
2017-12-19 17:51:40 +01:00
Steve Brown
557d6368f9 mesh: meshctl: Add Company ID parameter to pub-set and pub-get
Add a CID parameter to both commands similar to bind.
Correct the prior assumption that a model id > 0xffff
was a vendor model.

pub-set 0100 c000 1 0 0 1000
03 0001 00c0 01 00 ff 00 00 0010

pub-set 0100 c000 1 0 0 1000 1
03 0001 00c0 01 00 ff 00 00 0100 0010
2017-12-18 13:15:15 +01:00
Steve Brown
fa5084a183 mesh: meshctl: Add get/set relay
Sets the relay state in node 0100 to 1

[config: Target = 0100]# relay-set 1 0 0

Node 0100 Relay state: 0x01 count: 0 steps: 0

Fetches the relay state of node 0100

[config: Target = 0100]# relay-get

Node 0100 Relay state: 0x01 count: 0 steps: 0
2017-12-18 13:15:11 +01:00
Steve Brown
0a8d9c69ab mesh: meshctl: Add get/set identity
Setting identity will cause connectable identity
beacons to be transmitted. The connect command
has an option to connect in this mode.

Sets the identity state to 1 in node 0100 on network
0000.

[config: Target = 0100]# ident-set 0 1
Network index 0x0000 has Node Identity state 0x01 Success

Fetched the identity state from node 0100

[config: Target = 0100]# ident-get 0
Network index 0x0000 has Node Identity state 0x01 Success
2017-12-18 13:15:07 +01:00
Steve Brown
f832f66f77 mesh: meshctl: Add set/get proxy
Set the current proxy state of node 0100
Setting the proxy state to 0 will disconnect
the GATT proxy connection.

[config: Target = 0100]# proxy-set 1

Node 0100 Proxy state: 0x01

Get the current proxy state of element 0100

[config: Target = 0100]# proxy-get

Node 0100 Proxy state: 0x01
2017-12-18 13:15:03 +01:00
Steve Brown
1a53ed0ca4 mesh: meshctl: Add get publish
Get the publish address for model 1001 in element 0100

[config: Target = 0100]# pub-get 0100 1001

Set publication for node 0100 status: Success
Publication address: 0xc000
Period: 0 ms
Retransmit count: 0
Retransmit Interval Steps: 0
2017-12-18 13:14:59 +01:00
Steve Brown
8087cd3db6 mesh: meshctl: Add get app keys
List application keys of model 1000 in element 0100.

[config: Target = 0100]# app-get 0100 1000

Model App Key list for node 0100 length: 7 status: Success
Element Addr:   0100
Model ID:       1000
Model App Key:  0001
2017-12-18 13:14:53 +01:00
Steve Brown
d6f74e4a06 mesh: meshctl: Add set heartbeat publish
Sets heartbeat for node 0100

[config: Target = 0100]# hb-set 0100 0 0 0 0

Set heartbeat for node 0100 status: Success
Destination:    0100
Count:          00
Period:         00
TTL:            ff
Features:       0000
Net_Idx:        0000
2017-12-18 13:14:49 +01:00
Steve Brown
61ca29dff5 mesh: meshctl: Add add/get subscribe
Adds a subscription for group address c000 to
model 1000 in element 0100.

[config: Target = 0100]# sub-add 0100 c000 1000

Subscription changed for node 0100 status: Success
ModelId 1000
Element Addr:   0100
Subscr Addr:    c000

Gets the current subscription list for model 1000
on element 0100.

[config: Target = 0100]# sub-get 0100 1000

Subscription list for node 0100 length: 7 status: Success
Element Addr:   0100
Model ID:       1000
Subscr Addr:    c000
2017-12-18 13:14:42 +01:00
Steve Brown
37aafbbf0e mesh: meshctl: Change command names to <cmd>-<get/set>
Fix lines over 80 chars
Move cmd_default()
Add parameter to pub-set to control retransmit count
2017-12-18 13:14:23 +01:00
Luiz Augusto von Dentz
9d7d70ee98 mesh: Add description for submenus
This adds proper descriptions for each submenu.
2017-12-13 10:08:55 -02:00
Steve Brown
813b8e6737 mesh: Segmentation fails in gatt.c:pipe_write()
If the first command output in a new connection exceeds 20 bytes,
mesh_gatt_write sets the SAR to FIRST as the write_mtu is initially 0
and the default is GATT_MTU-3 (20).

When pipe_write gets called, a new larger write_mtu has been set, but
the SAR is still set to FIRST. It's assumed that data->gatt_len >
max_len. However, it's not which causes lots of bogus output.
2017-12-12 09:50:46 -02:00
Luiz Augusto von Dentz
e199cd9bca mesh: Fix crash while reading input parameters
read_input_parameters skips the command argument thus arg[0] shall be
considerer the fist argument.
2017-12-11 11:19:16 +02:00
Luiz Augusto von Dentz
d1f9544681 mesh: Remove cmd_scan
cmd_scan is only used internally by discover-unprovisioned.
2017-12-08 13:06:21 +02:00
Luiz Augusto von Dentz
f11a25d42d mesh: Rework set_scan_filter_uuids parameters
set_scan_filter_uuids is not a command handler which means it doesn't
need to take argc and argv instead just pass the filter array.
2017-12-08 13:06:20 +02:00
Luiz Augusto von Dentz
7c16c4044d shell: Add bt_shell_opt
Make use of struct option and getopt_long to parse the options given.
2017-12-08 13:06:19 +02:00
Luiz Augusto von Dentz
fc53175b8a mesh: Make meshctl use bt_shell helpers
This makes meshctl use bt_shell to manage the menus and command
handling.
2017-12-08 13:06:12 +02:00
Steve Brown
cb1c2622fa mesh: meshctl add Node Identity option to connect command
This adds the option to connect via either Node Identity or Network ID
advertisements. Adding the node unicast address selects Node Identity.

See Mesh Profile Specification 7.2.2.2 for further details.
2017-12-04 19:51:26 +02:00
Michal Hobot
5b4be5a091 mesh: Fix parsing composition data for custom models
Custom model ids consist of model id and vendor id. Instead, vendor id
was used twice to build model id.
2017-11-30 23:18:29 +02:00
Steve Brown
1f17efbac0 mesh: Correct typo in config op defines 2017-11-29 09:34:21 +02:00
Michal Hobot
7be84fe316 mesh: onoff-model: Fix msec to sec conversion
There is an error in meshctl while displaying transition time. 1000 ms
is being presented as 16 sec, 40 ms. The reason is incorrect
conversion of milliseconds to seconds.  The fix is pretty trivial.
2017-11-27 10:50:40 +02:00
Inga Stotland
4d58eb52bc mesh: validate configuration target
Require obtaining node composition prior to sending configuration
commands that assume knowledge about the node's element/model layout.
2017-11-23 12:16:13 +02:00
Steve Brown
65aaf36f2a mesh: Correct length test in agent.c:request_ascii 2017-11-19 10:16:33 +02:00
Inga Stotland
d9a074b6b1 mesh: Add config server response for loopback 2017-11-01 15:02:29 +02:00
Steve Brown
2223d9f22d mesh: Correct segmentation logic
The decision whether to segment or not didn't consider the size of the MIC
2017-10-11 22:20:24 +03:00
Luiz Augusto von Dentz
8090f7a6c8 gatt: Update signature of AcquireWrite and AcquireNotify
It should now contain an argument for the options even though there
are not options defined for clients.
2017-09-22 13:50:17 +03:00
Marcel Holtmann
8168ab64d5 mesh: Use PRIx64 for printing uint64_t variables 2017-09-18 01:32:17 -07:00
Brian Gix
2b3be1c2e7 Rename sample JSON Databases 2017-09-14 11:22:27 +03:00
Luiz Augusto von Dentz
a446569b86 mesh: Add 'security' command
This adds 'security' command which can be used to display and change
the provision security level:

[meshctl]# security
Provision Security Level set to 1 (medium)
[meshctl]# security 2
Provision Security Level set to 2 (high)

Note: This doesn't change the default which is still medium.
2017-09-14 11:22:24 +03:00
Inga Stotland
660081ce5a mesh: Use correct length for config server response
Also check if the length is nonzero before sending response
2017-09-11 16:02:12 +03:00
Inga Stotland
9c2c9d3c71 mesh: Add characteristic property name check
If PropertyChanged signal is not emitted due to a change in
characteristic's "Value" property, the characteristic does
not need to be processed.
2017-09-11 16:02:12 +03:00
Łukasz Rymanowski
a75b37a476 mesh: Typo fix 2017-09-04 14:57:36 +03:00
Łukasz Rymanowski
22d943a798 mesh: Fix for handling unprovisioned device
If there is no ServiceData there is no valid provisioning data for
PB-GATT
2017-09-04 14:57:32 +03:00
Luiz Augusto von Dentz
a5b844cb8f mesh: Use DuplicateData filter
Also use the term duplicate instead of reset to make it more clear
the intent of the filter.
2017-08-30 14:59:55 +03:00
Inga Stotland
cce5161556 mesh: move GATT defines to the appropriate header file
Group mesh GATT definitions in mesh/gatt.h file.
Also remove unused members in mesh_node structure.
2017-08-28 13:56:55 +03:00
Luiz Augusto von Dentz
e5562190af mesh: Make use of rl_prompt_input
This removes unnecessary code to ask user input which is already
supported by rl_prompt_input.
2017-08-28 13:54:24 +03:00
Marcel Holtmann
de6c9e2cf0 mesh: Remove circular include protection guards 2017-08-21 18:43:31 +02:00
Marcel Holtmann
8e96790482 mesh: Fix includes to use root relative path names 2017-08-21 13:40:03 +02:00
Brian Gix
9b92507843 mesh: Baseline Mesh implementation 2017-08-21 12:40:35 +02:00
Brian Gix
112ebe6e71 mesh: Baseline Mesh runtime configuration files 2017-08-21 12:40:35 +02:00
Brian Gix
846af2a229 mesh: define APIs for Bluetooth Mesh 2017-08-21 12:40:35 +02:00