|
Z-Wave Protocol Controller Reference
|
#include "zwave_s0_internal.h"#include "zwave_s0_transport.h"#include "zwave_s0_network.h"#include "zwave_s0_sm.h"#include <stdint.h>#include <string.h>#include <ctimer.h>#include <assert.h>#include "zwave_command_class_indices.h"#include "ZW_classcmd.h"#include "zwave_helper_macros.h"#include "zwave_controller_internal.h"#include "zwave_controller_transport_internal.h"#include "zwave_controller_storage.h"#include "zwave_controller_transport.h"#include "zwave_tx.h"#include "S2.h"#include "zwave_s2_keystore.h"#include "s2_keystore.h"#include "aes.h"#include "sl_log.h"Classes | |
| struct | sec_tx_session |
| struct | _authdata_ |
| struct | nonce_block_t |
| struct | nonce |
| struct | rx_session_t |
Macros | |
| #define | LOG_TAG "zwave_s0_transport" |
| #define | NONCE_TABLE_SIZE 5 * 3 |
| #define | NUM_TX_SESSIONS 2 |
| #define | MAX_ENCRYPTED_MSG_SIZE 128 |
| #define | MAX_NONCES 10 |
| #define | MAX_RXSESSIONS 2 |
| #define | NONCE_TIMEOUT 10 |
| #define | NONCE_REQUEST_TIMER 10000 |
| #define | NONCE_REPORT_DISCARD_TIMEOUT 20000 |
| #define | NONCE_BLOCK_LIST_SIZE 10 |
| #define | RECEIVERS_NONCE_SIZE 8 |
| #define | S0_IV_SIZE 8 |
| #define | RECEIVER_NONCE_IDENTIFIER_OFFSET_FROM_END 9 |
| #define | S0_MAC_SIZE 8 |
| #define | S0_ENCAP_HEADER_LEN 20 |
| #define | UNUSED(x) x = x; |
Typedefs | |
| typedef struct sec_tx_session | sec_tx_session_t |
| typedef struct _authdata_ | auth_data_t |
| typedef struct nonce | nonce_t |
Enumerations | |
| enum | tx_state_t { NONCE_GET , NONCE_GET_SENT , ENC_MSG , ENC_MSG_SENT , ENC_MSG2 , ENC_MSG2_SENT , TX_DONE } |
| enum | rx_session_state_t { RX_INIT , RX_ENC1 , RX_ENC2 , RX_SESSION_DONE } |
Functions | |
| static void | restart_s0_timer (void) |
| const char * | s0_cmd_name (uint8_t cmd) |
| const char * | s0_state_name (tx_state_t state) |
| static void | aes_encrypt (uint8_t *in, uint8_t *out) |
| static void | aes_set_key_tpt (const uint8_t *key, const uint8_t *iv) |
| static void | aes_ofb (uint8_t *data, uint8_t len) |
| static void | aes_cbc_mac (const uint8_t *data, uint8_t len, uint8_t *mac) |
| static unsigned int | s0_is_nonce_blocked (const uint8_t src, const uint8_t dst, const uint8_t *nonce) |
| static void | s0_block_nonce (const uint8_t src, const uint8_t dst, const uint8_t *nonce) |
| static u8_t | register_nonce (u8_t src, u8_t dst, u8_t reply_nonce, const u8_t nonce[8]) |
| static u8_t | get_s0_nonce (u8_t src, u8_t dst, u8_t ri, u8_t nonce[RECEIVERS_NONCE_SIZE], u8_t any_nonce) |
| static void | nonce_clear (u8_t src, u8_t dst) |
| static void | nonce_timer_timeout (void *data) |
| static void | tx_session_state_set (sec_tx_session_t *s, tx_state_t state) |
| Move a S0 Tx Session state to a new state. More... | |
| void | s0_set_key (const uint8_t *network_key) |
| Set the S0 network key. More... | |
| static void | s0_timeout (void *user) |
| static sec_tx_session_t * | get_tx_session_by_node (uint8_t snode, uint8_t dnode) |
| static uint8_t | get_node_max_frame_size (zwave_node_id_t node_id) |
| static uint8_t | s0_encrypt_message (sec_tx_session_t *s, uint8_t pass2) |
| static void | reset_tx_session_data (sec_tx_session_t *s) |
| Resets the data from the previous S0 Tx Session. More... | |
| static void | callback (uint8_t status, const zwapi_tx_report_t *tx_info, void *user) |
| Z-Wave Tx Send data callback function. More... | |
| static uint8_t | get_seq () |
| sl_status_t | zwave_s0_send_data (const zwave_controller_connection_info_t *conn_info, uint16_t data_length_2_byte, 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 S0 encapsulated frame. More... | |
| static void | s0_register_nonce (uint8_t src, uint8_t dst, const uint8_t *nonce) |
| uint8_t | is_free (const rx_session_t *e) |
| rx_session_t * | new_rx_session (uint8_t snode, uint8_t dnode) |
| static void | free_rx_session (rx_session_t *s) |
| void | s0_abort_all_tx_sessions () |
| Abort all S0 network TX sessions. More... | |
| void | free_all_rx_session () |
| Free all S0 RX sessions. More... | |
| rx_session_t * | get_rx_session_by_nodes (uint8_t snode, uint8_t dnode) |
| static void | s0_send_nonce (const zwave_controller_connection_info_t *conn_info) |
| static uint8_t | s0_decrypt_message (const zwave_controller_connection_info_t *connection_info, const zwave_rx_receive_options_t *rx_options, const uint8_t *encrypted_frame, uint16_t encrypted_frame_len, uint8_t *decrypted_frame, uint16_t decrypted_frame_len) |
| sl_status_t | s0_application_command_handler (const zwave_controller_connection_info_t *c, const zwave_rx_receive_options_t *rx_options, const uint8_t *frame_data, uint16_t frame_length) |
| sl_status_t | zwave_s0_on_frame_received (const zwave_controller_connection_info_t *c, const zwave_rx_receive_options_t *rx_options, const uint8_t *encrypted_frame, uint16_t encrypted_frame_len) |
| Entry point of S0 frames received from the PHY/radio stack. More... | |
| void | free_all_tx_sessions () |
| Free all S0 Tx sessions. More... | |
| void | free_nonce_block_list () |
| Free S0 nonce block list. More... | |
| void | reset_block_next_elem () |
| Reset (block_next_elem)s0 block next elem variable. More... | |
| void | reset_s0_timers () |
| Reset nonce timer. More... | |
| sl_status_t | zwave_s0_on_abort_send_data (zwave_tx_session_id_t session_id) |
| Z-Wave controller transport callback function which will be triggered when S0 frame tranmission is aborted. More... | |
| static void | s0_on_new_network (zwave_home_id_t home_id, zwave_node_id_t node_id, zwave_keyset_t granted_keys, zwave_kex_fail_type_t kex_fail_type) |
| sl_status_t | zwave_s0_transport_init () |
| Initialize the S0 Transport Also calls zwave_s0_network_init() which aborts all tx sessions and frees them and also frees rx sessions and reads S0 key from keystore and initializes the S0 key. More... | |
Variables | |
| static sec_tx_session_t | tx_sessions [NUM_TX_SESSIONS] |
| nonce_block_t | nonce_block [NONCE_BLOCK_LIST_SIZE] |
| static unsigned int | block_next_elem |
| static uint8_t | aes_key [16] |
| static uint8_t | aes_iv [16] |
| static nonce_t | nonce_table [NONCE_TABLE_SIZE] |
| struct ctimer | nonce_timer |
| static uint8_t | enckey [16] |
| static uint8_t | authkey [16] |
| static uint8_t | enckeyz [16] |
| static uint8_t | authkeyz [16] |
| rx_session_t | rxsessions [MAX_RXSESSIONS] |
| static const zwave_controller_callbacks_t | s0_callbacks = {.on_new_network_entered = &s0_on_new_network} |
| #define LOG_TAG "zwave_s0_transport" |
| #define MAX_ENCRYPTED_MSG_SIZE 128 |
| #define MAX_NONCES 10 |
| #define MAX_RXSESSIONS 2 |
| #define NONCE_BLOCK_LIST_SIZE 10 |
| #define NONCE_REPORT_DISCARD_TIMEOUT 20000 |
| #define NONCE_REQUEST_TIMER 10000 |
| #define NONCE_TABLE_SIZE 5 * 3 |
| #define NONCE_TIMEOUT 10 |
| #define NUM_TX_SESSIONS 2 |
| #define RECEIVER_NONCE_IDENTIFIER_OFFSET_FROM_END 9 |
| #define RECEIVERS_NONCE_SIZE 8 |
| #define S0_ENCAP_HEADER_LEN 20 |
| #define S0_IV_SIZE 8 |
| #define S0_MAC_SIZE 8 |
| #define UNUSED | ( | x | ) | x = x; |
| typedef struct _authdata_ auth_data_t |
| typedef struct sec_tx_session sec_tx_session_t |
| enum rx_session_state_t |
| enum tx_state_t |
|
static |
|
static |
|
static |
|
static |
|
static |
Z-Wave Tx Send data callback function.
This function is invoked when a frame queue by the S0 transport has been transmitted.
| status | Tx Status for the transmision |
| tx_info | Z-Wave Tx Report for our frame |
| user | User pointer. |
|
static |
|
static |
Get the maximum frame size supported by a node.
| rx_session_t * get_rx_session_by_nodes | ( | uint8_t | snode, |
| uint8_t | dnode | ||
| ) |
Get a specific nonce from the nonce table. The session must not be expired
|
static |
Receive nonce sent from src to dst, if th ri. If a nonce is found, then remove all entries from that src->dst combination from the table.
If any_nonce is set then ri is ignored
|
static |
Get the next sequence number no node may receive the same sequence number in two concurrent transmissions
|
static |
Lookup a tx session by nodeid
| uint8_t is_free | ( | const rx_session_t * | e | ) |
| rx_session_t * new_rx_session | ( | uint8_t | snode, |
| uint8_t | dnode | ||
| ) |
Get a new free RX session.
|
static |
Remove all nonces from nonce table sent from src to dst
| src | |
| dst |
|
static |
|
static |
Register a new nonce from sent from src to dst
|
static |
Resets the data from the previous S0 Tx Session.
| s | Pointer to the S0 Tx Session |
|
static |
| sl_status_t s0_application_command_handler | ( | const zwave_controller_connection_info_t * | c, |
| const zwave_rx_receive_options_t * | rx_options, | ||
| const uint8_t * | frame_data, | ||
| uint16_t | frame_length | ||
| ) |
|
static |
We block the last NONCE_BLOCK_LIST_SIZE external nonces we have used. This function adds nonce to the block.
| const char * s0_cmd_name | ( | uint8_t | cmd | ) |
|
static |
|
static |
Encrypt a message and write the encrypted data into s->crypted_msg
|
static |
Test if an S0 nonce with particular source and destination is blocked.
|
static |
|
static |
Register a nonce by source and destination
|
static |
Send a nonce from given source to given destination. The nonce is registered internally
| const char * s0_state_name | ( | tx_state_t | state | ) |
|
static |
|
static |
Move a S0 Tx Session state to a new state.
| s | Pointer to the S0 Tx Session |
| state | New state for the session. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| nonce_block_t nonce_block[NONCE_BLOCK_LIST_SIZE] |
|
static |
| struct ctimer nonce_timer |
| rx_session_t rxsessions[MAX_RXSESSIONS] |
|
static |
|
static |