Z-Wave Protocol Controller Reference
zwave_s2_transport.c File Reference
#include "zwave_s2_transport.h"
#include "zwave_s2_keystore.h"
#include "zwave_s2_process.h"
#include "zwave_s2_internal.h"
#include "S2.h"
#include "s2_inclusion.h"
#include "s2_keystore.h"
#include "s2_protocol.h"
#include "s2_classcmd.h"
#include <stdio.h>
#include <string.h>
#include "zwave_controller_connection_info.h"
#include "zwave_command_class_indices.h"
#include "zwave_controller_internal.h"
#include "zwave_controller_storage.h"
#include "zwave_network_management.h"
#include "zwave_rx.h"
#include "zwave_tx.h"
#include "zwave_tx_groups.h"
#include "zwave_utils.h"
#include "sys/clock.h"
#include "sl_log.h"
Include dependency graph for zwave_s2_transport.c:

Classes

struct  s2_transport_session_state
 
struct  s2_node_nls_context
 

Macros

#define LOG_TAG   "zwave_s2_transport"
 
#define END_NODE_VERIFY_DELIVERY_TIMEOUT   500
 
#define NONCE_REP_TIME   250
 
#define SECURITY_2_NONCE_GET   0x01
 
#define SECURITY_2_COMMANDS_SUPPORTED_REPORT   0x0E
 
#define INVALID_KEY_ID   0xFF
 
#define S2_NONCE_REPORT_MOS_SOS_INDEX   3
 
#define S2_NONCE_REPORT_MOS_SOS_MASK   0x3
 
#define NLS_ENABLED_NODES_PER_BYTE   8
 
#define UNAUTHENTICATED_KEY_SLOT   0
 
#define AUTHENTICATED_KEY_SLOT   1
 
#define ACCESS_KEY_SLOT   2
 
#define LR_AUTHENTICATED_KEY_SLOT   3
 
#define LR_ACCESS_KEY_SLOT   4
 

Typedefs

typedef struct s2_transport_session_state s2_transport_session_state_t
 
typedef struct s2_node_nls_context s2_node_nls_context_t
 

Enumerations

enum  zwave_s2_current_transmission_type_t { SINGLECAST , MULTICAST }
 

Functions

static uint8_t encapsulation_to_class (zwave_controller_encapsulation_scheme_t encap)
 
static zwave_controller_encapsulation_scheme_t class_to_encapsulation (uint8_t key_class)
 
static zwave_s2_keyset_t get_s2_keyset_from_node (zwave_node_id_t node_id)
 Finds out which keyset to use for S2 transmissions to a NodeID. More...
 
static zwave_s2_keyset_t get_s2_keyset_from_group (zwave_multicast_group_id_t group_id)
 Finds out which keyset to use for S2 transmissions to a Group ID. More...
 
static void send_frame_callback (uint8_t status, const zwapi_tx_report_t *tx_info, void *user)
 
void S2_get_hw_random (uint8_t *buf, uint8_t len)
 
static uint8_t convert_lr_to_zwave_class_id (uint8_t class_id)
 
void S2_get_commands_supported (node_t lnode, uint8_t class_id, const uint8_t **cmdClasses, uint8_t *length)
 
void S2_send_done_event (struct S2 *ctxt, s2_tx_status_t status)
 
void S2_msg_received_event (struct S2 *ctxt, s2_connection_t *src, uint8_t *buf, uint16_t len)
 
uint8_t S2_send_frame (struct S2 *ctxt, const s2_connection_t *conn, uint8_t *buf, uint16_t len)
 
uint8_t S2_send_frame_no_cb (struct S2 *ctxt, const s2_connection_t *conn, uint8_t *buf, uint16_t len)
 
uint8_t S2_send_frame_multi (struct S2 *ctxt, s2_connection_t *conn, uint8_t *buf, uint16_t len)
 
void S2_notify_nls_state_report (node_t srcNode, uint8_t class_id, bool nls_capability, bool nls_state)
 
void S2_save_nls_state (void)
 
sl_status_t compute_next_nls_enabled_node (void)
 
static uint16_t compute_nls_enabled_node_cnt (void)
 
int8_t S2_get_nls_node_list (node_t srcNode, bool request, bool *is_last_node, uint16_t *node_id, uint8_t *granted_keys, bool *nls_state)
 
int8_t S2_notify_nls_node_list_report (node_t srcNode, uint16_t id_of_node, uint8_t keys_node_bitmask, bool nls_state)
 
sl_status_t zwave_s2_send_data (const zwave_controller_connection_info_t *connection, uint16_t data_length, const uint8_t *cmd_data, const zwave_tx_options_t *tx_options, const on_zwave_tx_send_data_complete_t on_send_complete, void *user, zwave_tx_session_id_t parent_session_id)
 Sending an S2 encapsulated frame. More...
 
sl_status_t zwave_s2_on_frame_received (const zwave_controller_connection_info_t *connection_info, const zwave_rx_receive_options_t *rx_options, const uint8_t *frame_data, uint16_t frame_length)
 Entry point of S2 frames received from the PHY/radio stack. More...
 
sl_status_t zwave_s2_set_secure_nif (const uint8_t *nif, uint8_t nif_length)
 Set the secure NIF. More...
 
void zwave_s2_transport_init ()
 Initializes the Z-Wave S2 Transport. More...
 
void S2_resynchronization_event (node_t remote_node, sos_event_reason_t reason, uint8_t seqno, node_t local_node)
 
void zwave_s2_on_on_multicast_group_deleted (zwave_multicast_group_id_t group_id)
 Asks LibS2 to erase an MPAN entry. More...
 
sl_status_t zwave_s2_abort_send_data (zwave_tx_session_id_t session_id)
 Z-Wave controller transport callback function which will be triggered when S2 frame tranmission is aborted. More...
 

Variables

struct S2 * s2_ctx
 
static s2_transport_session_state_t state = {}
 
static uint8_t secure_nif [ZWAVE_MAX_FRAME_SIZE]
 
static uint8_t secure_nif_length
 
static s2_node_nls_context_t node_nls_context = {0}
 

Macro Definition Documentation

◆ ACCESS_KEY_SLOT

#define ACCESS_KEY_SLOT   2

◆ AUTHENTICATED_KEY_SLOT

#define AUTHENTICATED_KEY_SLOT   1

◆ END_NODE_VERIFY_DELIVERY_TIMEOUT

#define END_NODE_VERIFY_DELIVERY_TIMEOUT   500

◆ INVALID_KEY_ID

#define INVALID_KEY_ID   0xFF

◆ LOG_TAG

#define LOG_TAG   "zwave_s2_transport"

◆ LR_ACCESS_KEY_SLOT

#define LR_ACCESS_KEY_SLOT   4

◆ LR_AUTHENTICATED_KEY_SLOT

#define LR_AUTHENTICATED_KEY_SLOT   3

◆ NLS_ENABLED_NODES_PER_BYTE

#define NLS_ENABLED_NODES_PER_BYTE   8

◆ NONCE_REP_TIME

#define NONCE_REP_TIME   250

◆ S2_NONCE_REPORT_MOS_SOS_INDEX

#define S2_NONCE_REPORT_MOS_SOS_INDEX   3

◆ S2_NONCE_REPORT_MOS_SOS_MASK

#define S2_NONCE_REPORT_MOS_SOS_MASK   0x3

◆ SECURITY_2_COMMANDS_SUPPORTED_REPORT

#define SECURITY_2_COMMANDS_SUPPORTED_REPORT   0x0E

◆ SECURITY_2_NONCE_GET

#define SECURITY_2_NONCE_GET   0x01

◆ UNAUTHENTICATED_KEY_SLOT

#define UNAUTHENTICATED_KEY_SLOT   0

Typedef Documentation

◆ s2_node_nls_context_t

◆ s2_transport_session_state_t

Enumeration Type Documentation

◆ zwave_s2_current_transmission_type_t

Enumerator
SINGLECAST 
MULTICAST 

Function Documentation

◆ class_to_encapsulation()

static zwave_controller_encapsulation_scheme_t class_to_encapsulation ( uint8_t  key_class)
static
Here is the caller graph for this function:

◆ compute_next_nls_enabled_node()

sl_status_t compute_next_nls_enabled_node ( void  )
Here is the caller graph for this function:

◆ compute_nls_enabled_node_cnt()

static uint16_t compute_nls_enabled_node_cnt ( void  )
static
Here is the caller graph for this function:

◆ convert_lr_to_zwave_class_id()

static uint8_t convert_lr_to_zwave_class_id ( uint8_t  class_id)
static
Here is the caller graph for this function:

◆ encapsulation_to_class()

static uint8_t encapsulation_to_class ( zwave_controller_encapsulation_scheme_t  encap)
static
Here is the caller graph for this function:

◆ get_s2_keyset_from_group()

static zwave_s2_keyset_t get_s2_keyset_from_group ( zwave_multicast_group_id_t  group_id)
static

Finds out which keyset to use for S2 transmissions to a Group ID.

Parameters
group_idThe GroupID to transmit to
Returns
zwave_s2_keyset_t to use with S2_send_data functions.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_s2_keyset_from_node()

static zwave_s2_keyset_t get_s2_keyset_from_node ( zwave_node_id_t  node_id)
static

Finds out which keyset to use for S2 transmissions to a NodeID.

Parameters
node_idThe NodeID to transmit to
Returns
zwave_s2_keyset_t to use with S2_send_data functions.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ S2_get_commands_supported()

void S2_get_commands_supported ( node_t  lnode,
uint8_t  class_id,
const uint8_t **  cmdClasses,
uint8_t *  length 
)
Here is the call graph for this function:

◆ S2_get_hw_random()

void S2_get_hw_random ( uint8_t *  buf,
uint8_t  len 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ S2_get_nls_node_list()

int8_t S2_get_nls_node_list ( node_t  srcNode,
bool  request,
bool *  is_last_node,
uint16_t *  node_id,
uint8_t *  granted_keys,
bool *  nls_state 
)
Here is the call graph for this function:

◆ S2_msg_received_event()

void S2_msg_received_event ( struct S2 *  ctxt,
s2_connection_t *  src,
uint8_t *  buf,
uint16_t  len 
)
Here is the call graph for this function:

◆ S2_notify_nls_node_list_report()

int8_t S2_notify_nls_node_list_report ( node_t  srcNode,
uint16_t  id_of_node,
uint8_t  keys_node_bitmask,
bool  nls_state 
)
Here is the call graph for this function:

◆ S2_notify_nls_state_report()

void S2_notify_nls_state_report ( node_t  srcNode,
uint8_t  class_id,
bool  nls_capability,
bool  nls_state 
)
Here is the call graph for this function:

◆ S2_resynchronization_event()

void S2_resynchronization_event ( node_t  remote_node,
sos_event_reason_t  reason,
uint8_t  seqno,
node_t  local_node 
)

◆ S2_save_nls_state()

void S2_save_nls_state ( void  )
Here is the call graph for this function:

◆ S2_send_done_event()

void S2_send_done_event ( struct S2 *  ctxt,
s2_tx_status_t  status 
)
Here is the call graph for this function:

◆ S2_send_frame()

uint8_t S2_send_frame ( struct S2 *  ctxt,
const s2_connection_t *  conn,
uint8_t *  buf,
uint16_t  len 
)
Here is the call graph for this function:

◆ S2_send_frame_multi()

uint8_t S2_send_frame_multi ( struct S2 *  ctxt,
s2_connection_t *  conn,
uint8_t *  buf,
uint16_t  len 
)
Here is the call graph for this function:

◆ S2_send_frame_no_cb()

uint8_t S2_send_frame_no_cb ( struct S2 *  ctxt,
const s2_connection_t *  conn,
uint8_t *  buf,
uint16_t  len 
)
Here is the call graph for this function:

◆ send_frame_callback()

static void send_frame_callback ( uint8_t  status,
const zwapi_tx_report_t tx_info,
void *  user 
)
static
Here is the caller graph for this function:

Variable Documentation

◆ node_nls_context

s2_node_nls_context_t node_nls_context = {0}
static

◆ secure_nif

uint8_t secure_nif[ZWAVE_MAX_FRAME_SIZE]
static

◆ secure_nif_length

uint8_t secure_nif_length
static

◆ state

s2_transport_session_state_t state = {}
static