Squashed 'features/nanostack/sal-stack-nanostack/' changes from ccd30a3..513a38e

513a38e Merge branch 'release_internal' into release_external
3d2f391 Use Mbed OS coding style (#1900)
e07cfb4 re-factored thread_mcast_should_register_address. (#1887)
426acd1 Fixed filter to not drop packets when no modification

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 513a38ee18ab64c065531b7503ead726bf3b5858
pull/8647/head^2
Arto Kinnunen 2018-11-10 20:16:03 +02:00
parent 6dd01c679d
commit 77818568c6
211 changed files with 4883 additions and 4791 deletions

View File

@ -70,9 +70,9 @@ typedef struct {
uint16_t data_len; /**< Length of data IN. */
const uint8_t *adata_ptr; /**< Pointer to authentication data. */
uint16_t adata_len; /**< Length of authentication data. */
unsigned ccm_encode_mode:1; /**< Encryption modeAES_CCM_ENCRYPT or AES_CCM_DECRYPT. */
unsigned ccm_sec_level:3; /**< Encryption operation security level 0-7. */
unsigned ccm_l_param:4; /**< Can be 2 or 3. 2 when NONCE length is 13 and 3 when 12*/
unsigned ccm_encode_mode: 1; /**< Encryption modeAES_CCM_ENCRYPT or AES_CCM_DECRYPT. */
unsigned ccm_sec_level: 3; /**< Encryption operation security level 0-7. */
unsigned ccm_l_param: 4; /**< Can be 2 or 3. 2 when NONCE length is 13 and 3 when 12*/
uint8_t mic_len; /**< ccm_sec_init() sets here the length of MIC. */
uint8_t *mic; /**< Encrypt process writes MIC. Decrypt reads it and compares it with the MIC obtained from data. */
const uint8_t *key_ptr; /**< Encyption key pointer to 128-bit key. */

View File

@ -66,8 +66,7 @@
* /enum dhcp_instance_type
* /brief DHCP instance types.
*/
typedef enum dhcp_instance_type
{
typedef enum dhcp_instance_type {
DHCP_INSTANCE_CLIENT,
DHCP_INSTANCE_SERVER,
DHCP_INTANCE_RELAY_AGENT

View File

@ -42,7 +42,7 @@ typedef struct eth_mac_api_s eth_mac_api_t;
typedef struct eth_data_conf_s {
uint8_t msduHandle; /**< Handle associated with MSDU */
uint8_t status; /**< Status of the last transaction */
}eth_data_conf_t;
} eth_data_conf_t;
/**
* \brief Struct eth_data_req_s defines arguments for data request message
@ -67,7 +67,7 @@ typedef struct eth_data_ind_s {
uint16_t etehernet_type; /**< Ethernet type */
uint8_t link_quality; /**< Link quality */
int8_t dbm; /**< measured dBm */
}eth_data_ind_t;
} eth_data_ind_t;
/**
* @brief Creates ethernet MAC API instance which will use driver given
@ -91,21 +91,21 @@ extern int8_t ethernet_mac_destroy(eth_mac_api_t *mac_api);
* @param api API to handle the request
* @param data Data containing request parameters
*/
typedef void eth_mac_data_request(const eth_mac_api_t* api, const eth_data_req_t *data);
typedef void eth_mac_data_request(const eth_mac_api_t *api, const eth_data_req_t *data);
/**
* @brief data_confirm confirm is called as a response to data_request
* @param api The API which handled the request
* @param data Data containing confirm parameters
*/
typedef void eth_mac_data_confirm(const eth_mac_api_t* api, const eth_data_conf_t *data );
typedef void eth_mac_data_confirm(const eth_mac_api_t *api, const eth_data_conf_t *data);
/**
* @brief data_indication Data indication is called when MAC layer has received data
* @param api The API which handled the response
* @param data Data containing indication parameters
*/
typedef void eth_mac_data_indication(const eth_mac_api_t* api, const eth_data_ind_t *data );
typedef void eth_mac_data_indication(const eth_mac_api_t *api, const eth_data_ind_t *data);
/**
* @brief Set 48 bit address from MAC
@ -113,7 +113,7 @@ typedef void eth_mac_data_indication(const eth_mac_api_t* api, const eth_data_in
* @param mac48 Pointer having mac address to be set
* @return 0 if successful, -1 otherwise
*/
typedef int8_t eth_mac_mac48_address_set(const eth_mac_api_t* api, const uint8_t *mac48);
typedef int8_t eth_mac_mac48_address_set(const eth_mac_api_t *api, const uint8_t *mac48);
/**
* @brief Read 48 bit address from MAC
@ -121,7 +121,7 @@ typedef int8_t eth_mac_mac48_address_set(const eth_mac_api_t* api, const uint8_t
* @param mac48_buf Pointer where mac address can be written
* @return 0 if successful, -1 otherwise
*/
typedef int8_t eth_mac_mac48_address_get(const eth_mac_api_t* api, uint8_t *mac48_buf);
typedef int8_t eth_mac_mac48_address_get(const eth_mac_api_t *api, uint8_t *mac48_buf);
/**
* @brief Upper layer will call this function, when MAC is taken into use
@ -132,7 +132,7 @@ typedef int8_t eth_mac_mac48_address_get(const eth_mac_api_t* api, uint8_t *mac4
* @return 0 if success; -1 if api is NULL or not found
*/
typedef int8_t eth_mac_api_initialize(eth_mac_api_t *api, eth_mac_data_confirm *conf_cb,
eth_mac_data_indication *ind_cb, uint8_t parent_id);
eth_mac_data_indication *ind_cb, uint8_t parent_id);
/**
* \brief Struct eth_mac_api_s defines functions for two-way communications between ethernet MAC and Upper layer.

View File

@ -46,8 +46,7 @@ typedef struct fhss_callback fhss_callback_t;
/**
* @brief FHSS states.
*/
typedef enum
{
typedef enum {
FHSS_UNSYNCHRONIZED,
FHSS_SYNCHRONIZED,
} fhss_states;

View File

@ -33,8 +33,7 @@ extern "C" {
/**
* @brief WS channel functions.
*/
typedef enum
{
typedef enum {
/** Fixed channel. */
WS_FIXED_CHANNEL,
/** TR51 channel function. */
@ -49,8 +48,7 @@ typedef enum
* \brief Struct fhss_tuning_parameter defines FHSS tuning parameters.
* All delays are given in microseconds.
*/
typedef struct fhss_tuning_parameter
{
typedef struct fhss_tuning_parameter {
/** Delay between data pushed to PHY TX function and TX started (Contains CSMA-CA maximum random period). */
uint32_t tx_processing_delay;
@ -64,8 +62,7 @@ typedef struct fhss_tuning_parameter
/**
* \brief Struct fhss_configuration defines basic configuration of FHSS.
*/
typedef struct fhss_configuration
{
typedef struct fhss_configuration {
/** Tuning parameters can be used to enhance synchronization accuracy*/
fhss_tuning_parameter_t fhss_tuning_parameters;
@ -94,8 +91,7 @@ typedef int32_t fhss_vendor_defined_cf(const fhss_api_t *api, uint16_t slot, uin
/**
* \brief Struct fhss_ws_configuration defines configuration of WS FHSS.
*/
typedef struct fhss_ws_configuration
{
typedef struct fhss_ws_configuration {
/** WS unicast channel function. */
fhss_ws_channel_functions ws_uc_channel_function;
@ -132,8 +128,7 @@ typedef struct fhss_ws_configuration
* \brief Struct fhss_timer defines interface between FHSS and FHSS platform timer.
* Application must implement FHSS timer driver which is then used by FHSS with this interface.
*/
typedef struct fhss_timer
{
typedef struct fhss_timer {
/** Start timeout (1us). Timer must support multiple simultaneous timeouts */
int (*fhss_timer_start)(uint32_t, void (*fhss_timer_callback)(const fhss_api_t *fhss_api, uint16_t), const fhss_api_t *fhss_api);
@ -154,8 +149,7 @@ typedef struct fhss_timer
* \brief Struct fhss_synch_configuration defines the synchronization time configurations.
* Border router application must define and set these configuration for FHSS network.
*/
typedef struct fhss_synch_configuration
{
typedef struct fhss_synch_configuration {
/** Number of broadcast channels. */
uint8_t fhss_number_of_bc_channels;
@ -174,8 +168,7 @@ typedef struct fhss_synch_configuration
/**
* \brief Struct fhss_statistics defines the available FHSS statistics.
*/
typedef struct fhss_statistics
{
typedef struct fhss_statistics {
/** FHSS synchronization drift compensation (us/channel). */
int16_t fhss_drift_compensation;

View File

@ -34,7 +34,7 @@ extern "C" {
* @brief unicast_timing_info Unicast timing/hopping schedule information structure.
*/
typedef struct unicast_timing_info {
unsigned unicast_channel_function:3; /**< Unicast schedule channel function */
unsigned unicast_channel_function: 3; /**< Unicast schedule channel function */
uint8_t unicast_dwell_interval; /**< Unicast dwell interval */
uint16_t unicast_number_of_channels; /**< Unicast number of channels */
uint16_t fixed_channel; /**< Unicast fixed channel*/
@ -46,7 +46,7 @@ typedef struct unicast_timing_info {
* @brief broadcast_timing_info Broadcast timing/hopping schedule information structure.
*/
typedef struct broadcast_timing_info {
unsigned broadcast_channel_function:3; /**< Broadcast schedule channel function */
unsigned broadcast_channel_function: 3; /**< Broadcast schedule channel function */
uint8_t broadcast_dwell_interval; /**< Broadcast dwell interval */
uint16_t fixed_channel; /**< Broadcast fixed channel*/
uint16_t broadcast_slot; /**< Broadcast slot number */

View File

@ -95,7 +95,7 @@ typedef struct mac_description_storage_size_s {
typedef enum mac_extended_address_type {
MAC_EXTENDED_READ_ONLY, /** EUID64 which is unique */
MAC_EXTENDED_DYNAMIC /** Configured MAC 64-bit address to RAM and Radio */
}mac_extended_address_type;
} mac_extended_address_type;
//External MAC functions
/**
@ -113,14 +113,14 @@ typedef enum mac_extended_address_type {
* @param id The identifier of the MLME primitive
* @param data Primitive specific data (\see mlme.h)
*/
typedef void mlme_request(const mac_api_t* api, mlme_primitive id, const void *data);
typedef void mlme_request(const mac_api_t *api, mlme_primitive id, const void *data);
/**
* @brief mcps_request MCPS_DATA request call
* @param api API to handle the request
* @param data MCPS-DATA.request specific values
*/
typedef void mcps_data_request(const mac_api_t* api, const mcps_data_req_t *data);
typedef void mcps_data_request(const mac_api_t *api, const mcps_data_req_t *data);
/**
* @brief mcps_request MCPS_DATA with IE extions request call
@ -131,7 +131,7 @@ typedef void mcps_data_request(const mac_api_t* api, const mcps_data_req_t *data
*
* Asynch data request is mac standard extension. asynch_channel_list include channel mask which channel message is requested to send.
*/
typedef void mcps_data_request_ext(const mac_api_t* api, const mcps_data_req_t *data, const mcps_data_req_ie_list_t *ie_ext, const struct channel_list_s *asynch_channel_list);
typedef void mcps_data_request_ext(const mac_api_t *api, const mcps_data_req_t *data, const mcps_data_req_ie_list_t *ie_ext, const struct channel_list_s *asynch_channel_list);
/**
* @brief mcps_purge_request MCPS_PURGE request call
@ -139,7 +139,7 @@ typedef void mcps_data_request_ext(const mac_api_t* api, const mcps_data_req_t *
* @param data MCPS-PURGE.request specific values
* @return 0 in case of success, non-zero otherwise
*/
typedef uint8_t mcps_purge_request(const mac_api_t* api, const mcps_purge_t *data);
typedef uint8_t mcps_purge_request(const mac_api_t *api, const mcps_purge_t *data);
//Upper layer specific callback functions (will also be set by Upper layer after mac_api_t has been created and given to it)
@ -148,7 +148,7 @@ typedef uint8_t mcps_purge_request(const mac_api_t* api, const mcps_purge_t *dat
* @param api The API which handled the response
* @param data MCPS-DATA.confirm specific values
*/
typedef void mcps_data_confirm(const mac_api_t* api, const mcps_data_conf_t *data);
typedef void mcps_data_confirm(const mac_api_t *api, const mcps_data_conf_t *data);
/**
* @brief mcps_data_confirm_ext MCPS-DATA confirm with Enhanced ACK payload is called as a response to MCPS-DATA request
@ -156,14 +156,14 @@ typedef void mcps_data_confirm(const mac_api_t* api, const mcps_data_conf_t *dat
* @param data MCPS-DATA.confirm specific values
* @param conf_data Possible Confirmation Data
*/
typedef void mcps_data_confirm_ext(const mac_api_t* api, const mcps_data_conf_t *data, const mcps_data_conf_payload_t *conf_data);
typedef void mcps_data_confirm_ext(const mac_api_t *api, const mcps_data_conf_t *data, const mcps_data_conf_payload_t *conf_data);
/**
* @brief mcps_data_indication MCPS-DATA indication is called when MAC layer has received data
* @param api The API which handled the response
* @param data MCPS-DATA.indication specific values
*/
typedef void mcps_data_indication(const mac_api_t* api, const mcps_data_ind_t *data);
typedef void mcps_data_indication(const mac_api_t *api, const mcps_data_ind_t *data);
/**
* @brief mcps_data_indication MCPS-DATA indication is called when MAC layer has received data
@ -171,7 +171,7 @@ typedef void mcps_data_indication(const mac_api_t* api, const mcps_data_ind_t *d
* @param data MCPS-DATA.indication specific values
* @param ie_ext Information element list
*/
typedef void mcps_data_indication_ext(const mac_api_t* api, const mcps_data_ind_t *data, const mcps_data_ie_list_t *ie_ext);
typedef void mcps_data_indication_ext(const mac_api_t *api, const mcps_data_ind_t *data, const mcps_data_ie_list_t *ie_ext);
/**
* @brief mcps_ack_data_req_ext Callback for request IE elements and payload to enhanced ACK
@ -180,7 +180,7 @@ typedef void mcps_data_indication_ext(const mac_api_t* api, const mcps_data_ind_
* @param rssi Signal strength for received packet
* @param lqi Link quality to neighbor
*/
typedef void mcps_ack_data_req_ext(const mac_api_t* api, mcps_ack_data_payload_t *data, int8_t rssi, uint8_t lqi);
typedef void mcps_ack_data_req_ext(const mac_api_t *api, mcps_ack_data_payload_t *data, int8_t rssi, uint8_t lqi);
/**
@ -188,7 +188,7 @@ typedef void mcps_ack_data_req_ext(const mac_api_t* api, mcps_ack_data_payload_t
* @param api The API which handled the request
* @param data MCPS-PURGE.confirm specific values
*/
typedef void mcps_purge_confirm( const mac_api_t* api, mcps_purge_conf_t *data );
typedef void mcps_purge_confirm(const mac_api_t *api, mcps_purge_conf_t *data);
/**
* @brief mlme_confirm One of the MLME primitive confirm callbacks
@ -196,7 +196,7 @@ typedef void mcps_purge_confirm( const mac_api_t* api, mcps_purge_conf_t *data )
* @param id The identifier of the MLME primitive
* @param data Primitive specific data (\see mlme.h)
*/
typedef void mlme_confirm(const mac_api_t* api, mlme_primitive id, const void *data);
typedef void mlme_confirm(const mac_api_t *api, mlme_primitive id, const void *data);
/**
* @brief mlme_indication One of the
@ -204,28 +204,28 @@ typedef void mlme_confirm(const mac_api_t* api, mlme_primitive id, const void *d
* @param id The identifier of the MLME primitive
* @param data Primitive specific data (\see mlme.h)
*/
typedef void mlme_indication(const mac_api_t* api, mlme_primitive id, const void *data);
typedef void mlme_indication(const mac_api_t *api, mlme_primitive id, const void *data);
/**
* @brief Set extended address from MAC
* @param api API to handle the request
* @param mac64 pointer
*/
typedef int8_t mac_ext_mac64_address_set(const mac_api_t* api, const uint8_t *mac64);
typedef int8_t mac_ext_mac64_address_set(const mac_api_t *api, const uint8_t *mac64);
/**
* @brief Read extended address from MAC
* @param api API to handle the request
* @param mac64_buf Pointer where mac extended address can be written
*/
typedef int8_t mac_ext_mac64_address_get(const mac_api_t* api, mac_extended_address_type type, uint8_t *mac64_buf);
typedef int8_t mac_ext_mac64_address_get(const mac_api_t *api, mac_extended_address_type type, uint8_t *mac64_buf);
/**
* @brief Read MAC security description storage sizes from MAC
* @param api API to handle the request
* @param buffer Pointer where supported sizes can be written
*/
typedef int8_t mac_storage_decription_sizes_get(const mac_api_t* api, mac_description_storage_size_t *buffer);
typedef int8_t mac_storage_decription_sizes_get(const mac_api_t *api, mac_description_storage_size_t *buffer);
/**
* @brief mac_api_initialize Initialises MAC layer into use, callbacks must be non-NULL.

View File

@ -61,8 +61,8 @@
* See IEEE standard 802.15.4-2006 (e.g end of table 41) for more details
*/
typedef struct mlme_security_s {
unsigned SecurityLevel:3; /**< Security level */
unsigned KeyIdMode:2; /**< 2-bit value which define key source and ID use case */
unsigned SecurityLevel: 3; /**< Security level */
unsigned KeyIdMode: 2; /**< 2-bit value which define key source and ID use case */
uint8_t KeyIndex; /**< Key index */
uint8_t Keysource[8]; /**< Key source */
} mlme_security_t;
@ -79,7 +79,7 @@ typedef struct mlme_security_s {
*/
typedef struct mac_header_IE_s {
uint8_t *content_ptr; /**< Content data */
unsigned length:7; /**< Element length 0- 127 */
unsigned length: 7; /**< Element length 0- 127 */
uint8_t id; /**< Element ID */
} mac_header_IE_t;
@ -95,8 +95,8 @@ typedef struct mac_header_IE_s {
*/
typedef struct mac_payload_IE_s {
uint8_t *content_ptr; /**< Content data */
unsigned length:11; /**< Element length 0- 2047 */
unsigned id:4; /**< Group ID */
unsigned length: 11; /**< Element length 0- 2047 */
unsigned id: 4; /**< Group ID */
} mac_payload_IE_t;
#endif /* MAC_COMMON_DEFINES_H_ */

View File

@ -32,18 +32,18 @@
* See IEEE standard 802.15.4-2006 (table 41) for more details
*/
typedef struct mcps_data_req_s {
unsigned SrcAddrMode:2; /**< Source address mode */
unsigned DstAddrMode:2; /**< Destination address mode */
unsigned SrcAddrMode: 2; /**< Source address mode */
unsigned DstAddrMode: 2; /**< Destination address mode */
uint16_t DstPANId; /**< Destination PAN ID */
uint8_t DstAddr[8]; /**< Destination address */
uint16_t msduLength; /**< Service data unit length */
uint8_t *msdu; /**< Service data unit */
uint8_t msduHandle; /**< Handle associated with MSDU */
bool TxAckReq: 1; /**< Specifies whether ACK is needed or not */
bool InDirectTx:1; /**< Specifies whether indirect or direct transmission is used */
bool InDirectTx: 1; /**< Specifies whether indirect or direct transmission is used */
bool PendingBit: 1; /**< Specifies whether more fragments are to be sent or not */
bool SeqNumSuppressed:1; /**< True suppress sequence number from frame. This will be only checked when 2015 extension is enabled */
bool PanIdSuppressed:1; /**< True suppress PAN-id is done when possible from frame. This will be only checked when 2015 extension is enabled */
bool SeqNumSuppressed: 1; /**< True suppress sequence number from frame. This will be only checked when 2015 extension is enabled */
bool PanIdSuppressed: 1; /**< True suppress PAN-id is done when possible from frame. This will be only checked when 2015 extension is enabled */
mlme_security_t Key; /**< Security key */
} mcps_data_req_t;
@ -82,10 +82,10 @@ typedef struct mcps_data_conf_payload_s {
* See IEEE standard 802.15.4-2006 (table 43) for more details
*/
typedef struct mcps_data_ind_s {
unsigned SrcAddrMode:2; /**< 0x00 = no address 0x01 = reserved 0x02 = 16-bit short address 0x03 = 64-bit extended address */
unsigned SrcAddrMode: 2; /**< 0x00 = no address 0x01 = reserved 0x02 = 16-bit short address 0x03 = 64-bit extended address */
uint16_t SrcPANId; /**< Source PAN ID */
uint8_t SrcAddr[8]; /**< Source address */
unsigned DstAddrMode:2; /**< Destination address mode */
unsigned DstAddrMode: 2; /**< Destination address mode */
uint16_t DstPANId; /**< Destination PAN ID */
uint8_t DstAddr[8]; /**< Destination address */
uint8_t mpduLinkQuality; /**< LQI value measured during reception of the MPDU */

View File

@ -32,13 +32,13 @@
* See IEEE standard 802.15.4-2006 (table 55) for more details
*/
typedef struct mlme_pan_descriptor_s {
unsigned CoordAddrMode:2; /**<Coordinator address mode MAC_ADDR_MODE_16_BIT or MAC_ADDR_MODE_64_BIT */
unsigned CoordAddrMode: 2; /**<Coordinator address mode MAC_ADDR_MODE_16_BIT or MAC_ADDR_MODE_64_BIT */
uint16_t CoordPANId; /**<PAN-id */
uint8_t CoordAddress[8]; /**< Coordinator based CoordAddrMode */
uint8_t LogicalChannel; /**< Pan's Logical channel */
uint8_t ChannelPage; /**< Channel Page*/
uint8_t SuperframeSpec[2]; /**< Superframe specification */
bool GTSPermit:1; /**< true = GTS enabled false = disabled */
bool GTSPermit: 1; /**< true = GTS enabled false = disabled */
uint8_t LinkQuality; /**< Link quality based on received packet to Coordinator 0-0xff */
uint32_t Timestamp; /**< Time stamp for received packet */
uint8_t SecurityFailure; /**< Indicates payload security failure */
@ -60,7 +60,7 @@ typedef enum {
BEACON_REQUEST = 7, /**<Beacon request */
COORDINATOR_REALIGNMENT = 8, /**<Coordinator Realignment (Not supported)*/
GTS_REQUEST = 9 /**<GTS request (Not supported)*/
//Reserved
//Reserved
} mlme_command_type_t;
/**
@ -80,8 +80,8 @@ typedef enum {
* See IEEE standard 802.15.4-2006 (table 90) for more details
*/
typedef struct mlme_key_usage_descriptor_s {
unsigned FrameType:3; /**<0 = Beacon Frame, 1 = Data Frame or 3 Command Frame */
unsigned CommandFrameIdentifier:4; /**< Set this part only when FrameType is 3 */
unsigned FrameType: 3; /**<0 = Beacon Frame, 1 = Data Frame or 3 Command Frame */
unsigned CommandFrameIdentifier: 4; /**< Set this part only when FrameType is 3 */
} mlme_key_usage_descriptor_t;
/**
@ -91,8 +91,8 @@ typedef struct mlme_key_usage_descriptor_s {
*/
typedef struct mlme_key_device_descriptor_s {
uint8_t DeviceDescriptorHandle; /**< User defined unique ID to key User */
bool UniqueDevice:1; /**< true = Key description is for Key Pair Key usage only, False = group key */
bool Blacklisted:1; /**< true = Description is black listed, False = valid to use */
bool UniqueDevice: 1; /**< true = Key description is for Key Pair Key usage only, False = group key */
bool Blacklisted: 1; /**< true = Description is black listed, False = valid to use */
} mlme_key_device_descriptor_t;
/**
@ -117,10 +117,10 @@ typedef enum {
* See IEEE standard 802.15.4-2006 (table 92) for more details
*/
typedef struct mlme_security_level_descriptor_s {
unsigned FrameType:3; /**<0 = Beacon Frame, 1 = Data Frame or 3 Command Frame */
unsigned CommandFrameIdentifier:4; /**< Set this part only when FrameType is 3 */
unsigned SecurityMinimum:3; /**< Define Minimum acceptable security level for RX */
bool DeviceOverrideSecurityMinimum:1; /**< Set false */
unsigned FrameType: 3; /**<0 = Beacon Frame, 1 = Data Frame or 3 Command Frame */
unsigned CommandFrameIdentifier: 4; /**< Set this part only when FrameType is 3 */
unsigned SecurityMinimum: 3; /**< Define Minimum acceptable security level for RX */
bool DeviceOverrideSecurityMinimum: 1; /**< Set false */
} mlme_security_level_descriptor_t;
/**
@ -133,7 +133,7 @@ typedef struct mlme_device_descriptor_s {
uint16_t ShortAddress; /**< Device 16-bit short address 0xffff means not defined */
uint8_t ExtAddress[8]; /**< Device Extended 64-bit address */
uint32_t FrameCounter; /**< Security Frame counter */
bool Exempt:1; /**< Set false */
bool Exempt: 1; /**< Set false */
} mlme_device_descriptor_t;
/**
@ -143,7 +143,7 @@ typedef struct mlme_device_descriptor_s {
*/
typedef struct mlme_key_id_lookup_descriptor_s {
uint8_t LookupData[9]; /**< Key Lookup data */
unsigned LookupDataSize:1; /**< Key Lookup data size 0= 5 1 is 9 bytes */
unsigned LookupDataSize: 1; /**< Key Lookup data size 0= 5 1 is 9 bytes */
} mlme_key_id_lookup_descriptor_t;
@ -160,7 +160,7 @@ typedef struct mlme_key_descriptor_entry_s {
mlme_key_usage_descriptor_t *KeyUsageList; /**< List of descriptor entries indicating which frame types this key may be used with*/
uint8_t KeyUsageListEntries; /**< Number of entries in KeyUsageList*/
uint8_t Key[16]; /**< Actual value of Security key*/
}mlme_key_descriptor_entry_t;
} mlme_key_descriptor_entry_t;
/**
* @brief MLME primitive error statuses
@ -275,20 +275,20 @@ typedef enum {
*
* See IEEE standard 802.15.4-2006 (figure 51) for more details
*/
typedef struct mlme_beacon_pending_address_spec_s{
unsigned short_address_count:3; /**< Number of short address count */
unsigned extended_address_count:3; /**< Number of extended address count */
}mlme_beacon_pending_address_spec_t;
typedef struct mlme_beacon_pending_address_spec_s {
unsigned short_address_count: 3; /**< Number of short address count */
unsigned extended_address_count: 3; /**< Number of extended address count */
} mlme_beacon_pending_address_spec_t;
/**
* @brief struct mlme_beacon_gts_spec_t Format of GTS specification field
*
* See IEEE standard 802.15.4-2006 (figure 48) for more details
*/
typedef struct mlme_beacon_gts_spec_s{
unsigned description_count:3; /**< Number of GTS description count */
unsigned gts_permit:1; /**< 1= GTS request accepted 0= not accepted */
}mlme_beacon_gts_spec_t;
typedef struct mlme_beacon_gts_spec_s {
unsigned description_count: 3; /**< Number of GTS description count */
unsigned gts_permit: 1; /**< 1= GTS request accepted 0= not accepted */
} mlme_beacon_gts_spec_t;
/**
* @brief struct mlme_beacon_ind_t Beacon notify structure
@ -311,7 +311,7 @@ typedef struct mlme_beacon_ind_s {
*/
typedef struct mlme_scan_s {
mac_scan_type_t ScanType; /**< ED=0, active=1, passive=2, orphan=3*/
channel_list_s ScanChannels; /**<bit field, low 27 bits used*/
channel_list_s ScanChannels; /**<bit field, low 27 bits used*/
uint8_t ScanDuration; /**<0-14, scan duration/channel*/
uint8_t ChannelPage; /**<0-31*/
mlme_security_t Key; /**< Security parameters for active scan process */
@ -373,7 +373,7 @@ typedef struct mlme_set_conf_s {
*/
typedef struct mlme_scan_conf_s {
uint8_t status; /**< status of operation*/
unsigned ScanType:2; /**< Finished Scan type*/
unsigned ScanType: 2; /**< Finished Scan type*/
uint8_t ChannelPage; /**< Operated Channel Page*/
channel_list_s UnscannedChannels; /**< Channel mask for unscanned channels*/
uint8_t ResultListSize; /**< Result list size*/
@ -426,9 +426,9 @@ typedef struct mlme_rx_enable_conf_s {
*/
typedef struct mlme_comm_status_s {
uint16_t PANId; /**< Messages Pan-id */
unsigned SrcAddrMode:2; /**< source address mode: MAC_ADDR_MODE_NONE,MAC_ADDR_MODE_16_BIT or MAC_ADDR_MODE_64_BIT */
unsigned SrcAddrMode: 2; /**< source address mode: MAC_ADDR_MODE_NONE,MAC_ADDR_MODE_16_BIT or MAC_ADDR_MODE_64_BIT */
uint8_t SrcAddr[8]; /**< source address when mode is: MAC_ADDR_MODE_16_BIT or MAC_ADDR_MODE_64_BIT */
unsigned DstAddrMode:2; /**< destination address mode: MAC_ADDR_MODE_NONE,MAC_ADDR_MODE_16_BIT or MAC_ADDR_MODE_64_BIT */
unsigned DstAddrMode: 2; /**< destination address mode: MAC_ADDR_MODE_NONE,MAC_ADDR_MODE_16_BIT or MAC_ADDR_MODE_64_BIT */
uint8_t DstAddr[8]; /**< Destination address when mode is: MAC_ADDR_MODE_16_BIT or MAC_ADDR_MODE_64_BIT */
uint8_t status; /**< Communication status */
mlme_security_t Key; /**< Messages Security parameters */
@ -444,11 +444,11 @@ typedef struct mlme_start_s {
uint8_t LogicalChannel; /**< Operated Logical channel */
uint8_t ChannelPage; /**< Operated Logical channel page */
uint32_t StartTime; /**< Start time, set 0 */
unsigned BeaconOrder:4; /**< Beacon order, set 15 */
unsigned SuperframeOrder:4; /**< Super frame order, set 15 */
bool PANCoordinator:1; /**< true= Enable beacon response for beacon request, false = disable beacon request responses */
bool BatteryLifeExtension:1; /**< Set false */
bool CoordRealignment:1; /**< Set false */
unsigned BeaconOrder: 4; /**< Beacon order, set 15 */
unsigned SuperframeOrder: 4; /**< Super frame order, set 15 */
bool PANCoordinator: 1; /**< true= Enable beacon response for beacon request, false = disable beacon request responses */
bool BatteryLifeExtension: 1; /**< Set false */
bool CoordRealignment: 1; /**< Set false */
mlme_security_t CoordRealignKey; /**< Coordinator Realignment security parameter's (Valid only CoordRealignment = true)*/
mlme_security_t BeaconRealignKey; /**< Beacon realign security parameter's (Valid only CoordRealignment = true)*/
} mlme_start_t;
@ -483,7 +483,7 @@ typedef struct mlme_sync_loss_s {
* See IEEE standard 802.15.4-2006 (table 76) for more details
*/
typedef struct mlme_poll_s {
unsigned CoordAddrMode:2; /**< coordinator address mode:MAC_ADDR_MODE_16_BIT or MAC_ADDR_MODE_64_BIT */
unsigned CoordAddrMode: 2; /**< coordinator address mode:MAC_ADDR_MODE_16_BIT or MAC_ADDR_MODE_64_BIT */
uint16_t CoordPANId; /**< coordinator Pan-id to coordinator*/
uint8_t CoordAddress[8]; /**< coordinator address */
mlme_security_t Key; /**< Security parameters for Poll request */

View File

@ -225,20 +225,20 @@ int8_t multicast_mpl_domain_subscribe(int8_t interface_id,
* for more information on parameters.
*/
int8_t multicast_mpl_domain_subscribe_with_parameters
(int8_t interface_id,
const uint8_t address[16],
multicast_mpl_seed_id_mode_e seed_id_mode,
const void *seed_id,
bool proactive_forwarding,
uint16_t seed_set_entry_lifetime,
uint32_t data_message_imin,
uint32_t data_message_imax,
uint8_t data_message_k,
uint8_t data_message_timer_expirations,
uint32_t control_message_imin,
uint32_t control_message_imax,
uint8_t control_message_k,
uint8_t control_message_timer_expirations);
(int8_t interface_id,
const uint8_t address[16],
multicast_mpl_seed_id_mode_e seed_id_mode,
const void *seed_id,
bool proactive_forwarding,
uint16_t seed_set_entry_lifetime,
uint32_t data_message_imin,
uint32_t data_message_imax,
uint8_t data_message_k,
uint8_t data_message_timer_expirations,
uint32_t control_message_imin,
uint32_t control_message_imax,
uint8_t control_message_k,
uint8_t control_message_timer_expirations);
/**
* \brief Unsubscribe from an MPL Domain

View File

@ -30,7 +30,7 @@ extern "C" {
* \section set-addr Setting short address
* - net_ext_set_short_address_from_app(), Sets up a user-specified short address and enables or disables DAD.
*
* NOTE: In case of duplication of address and DAD (duplicate address detection) enabled, i.e., DAD=1, the stack
* NOTE: In case of duplication of address and DAD (duplicate address detection) enabled, i.e., DAD=1, the stack
* generates a short address dynamically.
*
* - \section reset-addr Resetting short address.

View File

@ -166,7 +166,7 @@ typedef enum {
NET_6LOWPAN_ND_WITHOUT_MLE, /**< **UNSUPPORTED** */
NET_6LOWPAN_ND_WITH_MLE, /**< 6LoWPAN ND with MLE. */
NET_6LOWPAN_THREAD, /**< 6LoWPAN Thread with MLE attached. */
NET_6LOWPAN_WS , /**< WS. */
NET_6LOWPAN_WS, /**< WS. */
NET_6LOWPAN_ZIGBEE_IP /**< **UNSUPPORTED** */
} net_6lowpan_mode_extension_e;
@ -257,8 +257,7 @@ typedef struct {
} border_router_setup_s;
/** Channel list */
typedef struct channel_list_s
{
typedef struct channel_list_s {
channel_page_e channel_page; /**< Channel page */
uint32_t channel_mask[8]; /**< Channel mask. Each bit defining one channel */
} channel_list_s;

View File

@ -18,7 +18,7 @@
/**
* \file net_load_balance_api.h
* \brief 6LoWPAN network load balance control API.
*/
*/
#ifndef NET_LOAD_BALANCE_API_H_
#define NET_LOAD_BALANCE_API_H_
@ -87,7 +87,7 @@ int8_t net_load_balance_threshold_set(int8_t interface_id, uint8_t threshold_min
*
* \return 0 Process OK, -1 Unknown interface ID or parameter fail.
*/
int8_t net_load_balance_set_max_probability(int8_t interface_id , uint8_t max_p);
int8_t net_load_balance_set_max_probability(int8_t interface_id, uint8_t max_p);
/**
* \brief Set load balance expected device count and enable automatic network load level update.

View File

@ -211,7 +211,7 @@ extern int8_t pana_server_nvm_client_session_load(uint8_t *nvm_pointer);
* \return -1, Null parameter detect.
*
*/
extern int8_t pana_client_nvm_callback_set(pana_client_session_update_cb *nvm_update, pana_client_session_get_cb *nvm_get,uint8_t *nvm_static_buffer);
extern int8_t pana_client_nvm_callback_set(pana_client_session_update_cb *nvm_update, pana_client_session_get_cb *nvm_get, uint8_t *nvm_static_buffer);
/**
* \brief Clean node persistent data and all PANA client sessions from the stack.

View File

@ -438,7 +438,7 @@ typedef int (response_cb)(int8_t interface_id, uint8_t *response_ptr, uint16_t r
* \return 0, Command send OK
* \return <0 Command send Fail
*/
int thread_test_diagnostic_command_send(int8_t interface_id, uint8_t *address_ptr,const char *uri_ptr, uint8_t request_length, uint8_t *request_ptr, response_cb *resp_cb);
int thread_test_diagnostic_command_send(int8_t interface_id, uint8_t *address_ptr, const char *uri_ptr, uint8_t request_length, uint8_t *request_ptr, response_cb *resp_cb);
typedef int (coap_response_cb)(int8_t interface_id, uint8_t message_code, uint8_t message_type, uint8_t *response_ptr, uint16_t response_len);

View File

@ -39,8 +39,7 @@ typedef struct ns_mdns_service *ns_mdns_service_t; /**< Service instance */
* \struct ns_mdns_service_param_t
* \brief Structure for mDNS service parameters
*/
typedef struct ns_mdns_service_param
{
typedef struct ns_mdns_service_param {
const char *service_type; /**< Null-terminated string owned by the caller */
uint16_t service_port; /**< Service Port number */
const uint8_t *(*service_get_txt)(void); /**< Call-back function, which returns a pointer to the service TXT record (null-terminated).

View File

@ -112,8 +112,7 @@ static inline void ns_sha256_nbits(const void *input, size_t ilen, void *output,
/**
* \brief SHA-256 context structure
*/
typedef struct
{
typedef struct {
uint32_t total[2]; /*!< number of bytes processed */
uint32_t state[8]; /*!< intermediate digest state */
unsigned char buffer[64]; /*!< data block being processed */
@ -125,14 +124,14 @@ ns_sha256_context;
*
* \param ctx SHA-256 context to be initialized
*/
void ns_sha256_init( ns_sha256_context *ctx );
void ns_sha256_init(ns_sha256_context *ctx);
/**
* \brief Clear SHA-256 context
*
* \param ctx SHA-256 context to be cleared
*/
void ns_sha256_free( ns_sha256_context *ctx );
void ns_sha256_free(ns_sha256_context *ctx);
/**
* \brief Clone (the state of) a SHA-256 context
@ -140,15 +139,15 @@ void ns_sha256_free( ns_sha256_context *ctx );
* \param dst The destination context
* \param src The context to be cloned
*/
void ns_sha256_clone( ns_sha256_context *dst,
const ns_sha256_context *src );
void ns_sha256_clone(ns_sha256_context *dst,
const ns_sha256_context *src);
/**
* \brief SHA-256 context setup
*
* \param ctx context to be initialized
*/
void ns_sha256_starts( ns_sha256_context *ctx );
void ns_sha256_starts(ns_sha256_context *ctx);
/**
* \brief SHA-256 process buffer
@ -157,8 +156,8 @@ void ns_sha256_starts( ns_sha256_context *ctx );
* \param input buffer holding the data
* \param ilen length of the input data
*/
void ns_sha256_update( ns_sha256_context *ctx, const void *input,
size_t ilen );
void ns_sha256_update(ns_sha256_context *ctx, const void *input,
size_t ilen);
/**
* \brief SHA-256 final digest
@ -166,7 +165,7 @@ void ns_sha256_update( ns_sha256_context *ctx, const void *input,
* \param ctx SHA-256 context
* \param output SHA-256 checksum result
*/
void ns_sha256_finish( ns_sha256_context *ctx, void *output );
void ns_sha256_finish(ns_sha256_context *ctx, void *output);
/**
* \brief SHA-256 final digest
@ -175,8 +174,8 @@ void ns_sha256_finish( ns_sha256_context *ctx, void *output );
* \param output SHA-256 checksum result
* \param obits Number of bits of to output - must be multiple of 32
*/
void ns_sha256_finish_nbits( ns_sha256_context *ctx,
void *output, unsigned obits );
void ns_sha256_finish_nbits(ns_sha256_context *ctx,
void *output, unsigned obits);
/**
* \brief Output = SHA-256( input buffer )
@ -185,8 +184,8 @@ void ns_sha256_finish_nbits( ns_sha256_context *ctx,
* \param ilen length of the input data
* \param output SHA-256 checksum result
*/
void ns_sha256( const void *input, size_t ilen,
void *output );
void ns_sha256(const void *input, size_t ilen,
void *output);
/**
* \brief Output = SHA-256( input buffer )
@ -196,8 +195,8 @@ void ns_sha256( const void *input, size_t ilen,
* \param output SHA-256 checksum result
* \param obits Number of bits of to output - must be multiple of 32
*/
void ns_sha256_nbits( const void *input, size_t ilen,
void *output, unsigned obits );
void ns_sha256_nbits(const void *input, size_t ilen,
void *output, unsigned obits);
#endif /* NS_USE_EXTERNAL_MBED_TLS */

View File

@ -125,8 +125,7 @@ typedef struct phy_csma_params {
} phy_csma_params_t;
/** PHY modulation scheme */
typedef enum phy_modulation_e
{
typedef enum phy_modulation_e {
M_OFDM, ///< QFDM
M_OQPSK, ///< OQPSK
M_BPSK, ///< BPSK
@ -135,8 +134,7 @@ typedef enum phy_modulation_e
} phy_modulation_e;
/** Channel page numbers */
typedef enum
{
typedef enum {
CHANNEL_PAGE_0 = 0, ///< Page 0
CHANNEL_PAGE_1 = 1, ///< Page 1
CHANNEL_PAGE_2 = 2, ///< Page 2
@ -149,8 +147,7 @@ typedef enum
} channel_page_e;
/** Channel configuration */
typedef struct phy_rf_channel_configuration_s
{
typedef struct phy_rf_channel_configuration_s {
uint32_t channel_0_center_frequency; ///< Center frequency
uint32_t channel_spacing; ///< Channel spacing
uint32_t datarate; ///< Data rate
@ -159,8 +156,7 @@ typedef struct phy_rf_channel_configuration_s
} phy_rf_channel_configuration_s;
/** Channel page configuration */
typedef struct phy_device_channel_page_s
{
typedef struct phy_device_channel_page_s {
channel_page_e channel_page; ///< Channel page
const phy_rf_channel_configuration_s *rf_channel_configuration; ///< Pointer to channel configuration
} phy_device_channel_page_s;
@ -202,7 +198,7 @@ typedef int8_t arm_net_phy_tx_done_fn(int8_t driver_id, uint8_t tx_handle, phy_l
* @param driver_id ID of driver which received data
* @return 0 if success, error otherwise
*/
typedef int8_t arm_net_virtual_rx_fn(const uint8_t *data_ptr, uint16_t data_len,int8_t driver_id);
typedef int8_t arm_net_virtual_rx_fn(const uint8_t *data_ptr, uint16_t data_len, int8_t driver_id);
/**
* @brief arm_net_virtual_tx TX callback set by serial MAC. Used to send data.
@ -210,7 +206,7 @@ typedef int8_t arm_net_virtual_rx_fn(const uint8_t *data_ptr, uint16_t data_len,
* @param driver_id Id of the driver to be used.
* @return 0 if success, error otherwise
*/
typedef int8_t arm_net_virtual_tx_fn(const virtual_data_req_t *data_req,int8_t driver_id);
typedef int8_t arm_net_virtual_tx_fn(const virtual_data_req_t *data_req, int8_t driver_id);
/**
* @brief arm_net_virtual_config Configuration receive callback set by upper layer. Used to receive internal configuration parameters.
@ -240,8 +236,7 @@ typedef int8_t arm_net_virtual_config_tx_fn(int8_t driver_id, const uint8_t *dat
typedef int8_t arm_net_virtual_confirmation_rx_fn(int8_t driver_id, const uint8_t *data, uint16_t length);
/** Device driver structure */
typedef struct phy_device_driver_s
{
typedef struct phy_device_driver_s {
phy_link_type_e link_type; /**< Define driver types. */
driver_data_request_e data_request_layer; /**< Define interface data OUT protocol. */
uint8_t *PHY_MAC; /**< Pointer to 64-bit or 48-bit MAC address. */
@ -251,7 +246,7 @@ typedef struct phy_device_driver_s
uint8_t phy_header_length; /**< Define PHY driver needed header length before PDU. */
int8_t (*state_control)(phy_interface_state_e, uint8_t); /**< Function pointer for control PHY driver state. */
int8_t (*tx)(uint8_t *, uint16_t, uint8_t, data_protocol_e); /**< Function pointer for PHY driver write operation. */
int8_t (*address_write)(phy_address_type_e , uint8_t *); /**< Function pointer for PHY driver address write. */
int8_t (*address_write)(phy_address_type_e, uint8_t *); /**< Function pointer for PHY driver address write. */
int8_t (*extension)(phy_extension_type_e, uint8_t *); /**< Function pointer for PHY driver extension control. */
const phy_device_channel_page_s *phy_channel_pages; /**< Pointer to channel page list */

View File

@ -46,7 +46,7 @@ extern serial_mac_api_t *serial_mac_create(int8_t serial_driver_id);
* @param data Data to be sent
* @param data_length Length of the data
*/
typedef int8_t data_request(const serial_mac_api_t* api, const uint8_t *data_ptr, uint16_t data_length);
typedef int8_t data_request(const serial_mac_api_t *api, const uint8_t *data_ptr, uint16_t data_length);
/**
@ -78,7 +78,7 @@ typedef int8_t serial_mac_virtual_initialize(const serial_mac_api_t *api, int8_t
*/
struct serial_mac_api_s {
serial_mac_api_initialize *mac_initialize; /**< Inititilize data callback */
serial_mac_virtual_initialize * virtual_initilize; /**< Enable bridge to virtual driver */
serial_mac_virtual_initialize *virtual_initilize; /**< Enable bridge to virtual driver */
data_request *data_request_cb; /**< Data request callback */
data_indication *data_ind_cb; /**< Data indication callback */
};

View File

@ -672,7 +672,7 @@ static inline int8_t socket_read_session_address(int8_t socket, ns_address_t *ad
/** \name Protocol levels used for socket_setsockopt. */
///@{
#define SOCKET_SOL_SOCKET 0 /**< Socket level */
#define SOCKET_IPPROTO_IPV6 41 /**< IPv6. */
#define SOCKET_IPPROTO_IPV6 41 /**< IPv6. */
///@}
/** \name Option names for protocol level SOCKET_SOL_SOCKET.

View File

@ -221,7 +221,7 @@ typedef void (thread_network_data_tlv_cb)(int8_t interface_id, uint8_t *network_
* \return 0, Callback function registered successfully.
* \return <0 when error occurs during registering the callback function.
*/
int thread_border_router_network_data_callback_register(int8_t interface_id, thread_network_data_tlv_cb* nwk_data_cb);
int thread_border_router_network_data_callback_register(int8_t interface_id, thread_network_data_tlv_cb *nwk_data_cb);
/**
* Find Prefix TLV from the Network Data TLV byte array.
@ -236,7 +236,7 @@ int thread_border_router_network_data_callback_register(int8_t interface_id, thr
* \return 0 if TLV is empty or no Prefix TLV found.
* \return negative value indicates error in input parameters.
*/
int thread_border_router_prefix_tlv_find(uint8_t* network_data_tlv, uint16_t network_data_tlv_length, uint8_t** prefix_tlv, bool* stable);
int thread_border_router_prefix_tlv_find(uint8_t *network_data_tlv, uint16_t network_data_tlv_length, uint8_t **prefix_tlv, bool *stable);
/**
* Find Border router TLV from the Network Data TLV (under Prefix TLV) byte array.
@ -251,7 +251,7 @@ int thread_border_router_prefix_tlv_find(uint8_t* network_data_tlv, uint16_t net
* \return 0 if TLV is empty or no TLV found.
* \return negative value indicates error in input parameters.
*/
int thread_border_router_tlv_find(uint8_t* prefix_tlv, uint16_t prefix_tlv_length, uint8_t** border_router_tlv, bool* stable);
int thread_border_router_tlv_find(uint8_t *prefix_tlv, uint16_t prefix_tlv_length, uint8_t **border_router_tlv, bool *stable);
/**
* Find Service TLV from the Network Data TLV byte array.
@ -266,7 +266,7 @@ int thread_border_router_tlv_find(uint8_t* prefix_tlv, uint16_t prefix_tlv_lengt
* \return 0 if TLV is empty or no Service TLV found.
* \return negative value indicates error in input parameters.
*/
int thread_border_router_service_tlv_find(uint8_t* network_data_tlv, uint16_t network_data_tlv_length, uint8_t** service_tlv, bool* stable);
int thread_border_router_service_tlv_find(uint8_t *network_data_tlv, uint16_t network_data_tlv_length, uint8_t **service_tlv, bool *stable);
/**
* Find Server TLV from the Network Data TLV (under Service TLV) byte array.
@ -281,7 +281,7 @@ int thread_border_router_service_tlv_find(uint8_t* network_data_tlv, uint16_t ne
* \return 0 if TLV is empty or no TLV found.
* \return negative value indicates error in input parameters.
*/
int thread_border_router_server_tlv_find(uint8_t* service_tlv, uint16_t service_tlv_length, uint8_t** server_tlv, bool* stable);
int thread_border_router_server_tlv_find(uint8_t *service_tlv, uint16_t service_tlv_length, uint8_t **server_tlv, bool *stable);
/**
* Determine context ID from the Network Data TLV (under Prefix TLV) byte array.

View File

@ -208,7 +208,7 @@ typedef struct thread_commissioning_link_configuration {
* \param link_ptr Poiner to Commissioning link configuration
*
*/
typedef void thread_commissioning_native_select_cb(int8_t interface_id, uint8_t count, thread_commissioning_link_configuration_s *link_ptr );
typedef void thread_commissioning_native_select_cb(int8_t interface_id, uint8_t count, thread_commissioning_link_configuration_s *link_ptr);
/** \brief Native commissioner network scan start.
*

View File

@ -95,18 +95,18 @@ int thread_management_unregister(int8_t instance_id);
*/
typedef int (management_set_response_cb)(int8_t interface_id, management_state_e status);
/** \brief Set the Thread security policy
*
* \param instance_id The ID of the management session.
* \param options Security policy options:
* bit 8 Out-of-band commissioning restricted.
* bit 7 Native commissioner restricted.
* \param rotation_time Thread key rotation time in hours.
* \param cb_ptr A callback function indicating the result of the operation. Can be NULL if no result code needed.
*
* \return 0 Success.
* \return <0 Fail.
*/
/** \brief Set the Thread security policy
*
* \param instance_id The ID of the management session.
* \param options Security policy options:
* bit 8 Out-of-band commissioning restricted.
* bit 7 Native commissioner restricted.
* \param rotation_time Thread key rotation time in hours.
* \param cb_ptr A callback function indicating the result of the operation. Can be NULL if no result code needed.
*
* \return 0 Success.
* \return <0 Fail.
*/
int thread_management_set_security_policy(int8_t instance_id, uint8_t options, uint16_t rotation_time, management_set_response_cb *cb_ptr);
/** \brief Set the steering data
@ -179,7 +179,7 @@ int thread_management_get(int8_t instance_id, uint8_t dst_addr[static 16], char
* \param instance_id Instance ID of the management session.
* \param dst_addr Destination address, the address of a remote device where it is desired to setup management information. If however, the address is not provided, a request is sent to leader of the network for this purpose. If a native commissioner is being used, the rquest for setting up management information is sent to the Border router.
* \param uri_ptr The ASCII string for the URI. This string identifies the CoAP URI for the desired resource, for example, /c/ms identifies the the management set information resource.
* \param data_ptr A pointer to the desired set of TLVs.
* \param data_ptr A pointer to the desired set of TLVs.
* \param data_len count of the members (no. of TLVs) in the TLV set.
* \param cb_ptr A callback function carrying the result of the operation.
*

View File

@ -303,7 +303,7 @@ bool thread_meshcop_tlv_list_present(const uint8_t *ptr, uint16_t length, const
*
* \return amount of TLVs present in the buffer.
*/
uint16_t thread_meshcop_tlv_list_generate(const uint8_t *ptr, uint16_t length,uint8_t *result_ptr, uint16_t *result_len);
uint16_t thread_meshcop_tlv_list_generate(const uint8_t *ptr, uint16_t length, uint8_t *result_ptr, uint16_t *result_len);
/**
* Remove TLV from list of TLVs.
@ -338,7 +338,7 @@ bool thread_meshcop_tlv_list_type_available(const uint8_t *list_ptr, uint16_t li
*
* \return The length of the TLV data found and found_tlv updated to point beginning of value field. 0 if TLV is not found.
*/
uint16_t thread_meshcop_tlv_find_next(uint8_t* tlv_ba, uint16_t tlv_ba_length, uint8_t tlv_id, uint8_t** found_tlv);
uint16_t thread_meshcop_tlv_find_next(uint8_t *tlv_ba, uint16_t tlv_ba_length, uint8_t tlv_id, uint8_t **found_tlv);
/**
* Read 1 byte length TLV.

View File

@ -131,8 +131,7 @@ buffer_t *nwk_udp_rx_security_check(buffer_t *buf)
}
if (buf->socket && buf->socket->inet_pcb->link_layer_security == 0) {
// non-secure okay if it's for a socket whose security flag is clear.
}
else {
} else {
drop_unsecured = 1;
}
}

View File

@ -366,7 +366,8 @@ void protocol_6lowpan_router_init(protocol_interface_info_entry_t *cur)
}
void protocol_6lowpan_configure_core(protocol_interface_info_entry_t *cur) {
void protocol_6lowpan_configure_core(protocol_interface_info_entry_t *cur)
{
cur->dup_addr_detect_transmits = 0;
cur->ipv6_neighbour_cache.max_ll_len = 2 + 8;
cur->ipv6_neighbour_cache.link_mtu = LOWPAN_MTU;
@ -463,7 +464,7 @@ void protocol_6lowpan_neighbor_priority_update(protocol_interface_info_entry_t *
if (cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_MLE) {
#ifndef NO_MLE
if (removed_priority) {
mle_set_link_priority(cur,removed_priority, false);
mle_set_link_priority(cur, removed_priority, false);
}
if (updated_priority) {
@ -483,7 +484,7 @@ uint16_t protocol_6lowpan_neighbor_priority_set(int8_t interface_id, addrtype_t
return 0;
}
mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type);
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type);
if (entry) {
@ -523,7 +524,7 @@ uint16_t protocol_6lowpan_neighbor_second_priority_set(int8_t interface_id, addr
return 0;
}
mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type);
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type);
if (entry) {
bool new_secondary = false;
@ -577,7 +578,7 @@ int8_t protocol_6lowpan_neighbor_address_state_synch(protocol_interface_info_ent
{
int8_t ret_val = -1;
mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), eui64, ADDR_802_15_4_LONG);
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), eui64, ADDR_802_15_4_LONG);
if (entry) {
if (memcmp(iid, ADDR_SHORT_ADR_SUFFIC, 6) == 0) {
iid += 6;
@ -598,7 +599,7 @@ int8_t protocol_6lowpan_neighbor_address_state_synch(protocol_interface_info_ent
int8_t protocol_6lowpan_neighbor_remove(protocol_interface_info_entry_t *cur, uint8_t *address_ptr, addrtype_t type)
{
mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), address_ptr, type);
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), address_ptr, type);
if (entry) {
mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), entry);
}
@ -739,7 +740,7 @@ uint8_t protocol_6lowpan_beacon_join_priority_tx(int8_t interface_id)
int16_t priority = 0;
#ifdef HAVE_RPL
if (cur->rpl_domain) {
priority = protocol_6lowpan_rpl_global_priority_get();
priority = protocol_6lowpan_rpl_global_priority_get();
}
#endif

View File

@ -92,10 +92,10 @@ static void protocol_6lowpan_bootstrap_rpl_callback(rpl_event_t event, void *han
#endif
static void protocol_6lowpan_mle_purge_neighbors(struct protocol_interface_info_entry *cur_interface, uint8_t entry_count, uint8_t force_priority);
static uint8_t protocol_6lowpan_mle_order_last_entries(int8_t interface_id,mac_neighbor_table_list_t *mac_neigh_table, uint8_t entry_count);
static uint8_t protocol_6lowpan_mle_order_last_entries(int8_t interface_id, mac_neighbor_table_list_t *mac_neigh_table, uint8_t entry_count);
static uint8_t protocol_6lowpan_mle_data_allocate(void);
static bool mle_accept_request_cb(int8_t interface_id, uint16_t msgId, bool usedAllRetries);
static void lowpan_comm_status_indication_cb(int8_t if_id, const mlme_comm_status_t* status);
static void lowpan_comm_status_indication_cb(int8_t if_id, const mlme_comm_status_t *status);
static void protocol_6lowpan_priority_neighbor_remove(protocol_interface_info_entry_t *cur_interface, mac_neighbor_table_entry_t *cur);
static void lowpan_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_ptr, void *user_data);
@ -119,7 +119,7 @@ static void lowpan_bootstrap_pan_control(protocol_interface_info_entry_t *cur, b
start_req.PANCoordinator = bootstrap_ready;
start_req.LogicalChannel = cur->mac_parameters->mac_channel;
start_req.PANId = cur->mac_parameters->pan_id;
cur->mac_api->mlme_req(cur->mac_api, MLME_START , &start_req);
cur->mac_api->mlme_req(cur->mac_api, MLME_START, &start_req);
net_load_balance_internal_state_activate(cur, bootstrap_ready);
}
}
@ -164,8 +164,8 @@ uint8_t *mle_general_write_timeout(uint8_t *ptr, protocol_interface_info_entry_t
static void protocol_6lowpan_priority_neighbor_remove(protocol_interface_info_entry_t *cur_interface, mac_neighbor_table_entry_t *cur)
{
if (cur->link_role != PRIORITY_PARENT_NEIGHBOUR ||
!(cur_interface->lowpan_info & INTERFACE_NWK_ACTIVE) ||
cur_interface->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
!(cur_interface->lowpan_info & INTERFACE_NWK_ACTIVE) ||
cur_interface->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
return;
}
@ -183,7 +183,7 @@ static void protocol_6lowpan_priority_neighbor_remove(protocol_interface_info_en
memcpy(mac64, ADDR_SHORT_ADR_SUFFIC, 6);
common_write_16_bit(cur->mac16, &mac64[6]);
} else {
memcpy(mac64,cur->mac64 , 8);
memcpy(mac64, cur->mac64, 8);
mac64[0] ^= 2;
}
@ -208,7 +208,7 @@ static bool protocol_6lowpan_challenge_callback(int8_t interface_id, uint16_t ms
memcpy(mac64, ll64_ptr + 8, 8);
mac64[0] ^= 2;
mac_neighbor_table_entry_t * neig_info = mac_neighbor_table_address_discover(mac_neighbor_info(cur_interface), mac64, ADDR_802_15_4_LONG);
mac_neighbor_table_entry_t *neig_info = mac_neighbor_table_address_discover(mac_neighbor_info(cur_interface), mac64, ADDR_802_15_4_LONG);
if (!neig_info) {
return false;//Why entry is removed before timeout??
@ -240,7 +240,7 @@ static bool protocol_6lowpan_host_challenge(protocol_interface_info_entry_t *cur
uint8_t security_level = mle_service_security_level_get(cur->id);
tr_debug("Link REQUEST");
bufId = mle_service_msg_allocate(cur->id, 32, true,MLE_COMMAND_REQUEST);
bufId = mle_service_msg_allocate(cur->id, 32, true, MLE_COMMAND_REQUEST);
if (bufId == 0) {
return false;
}
@ -259,7 +259,7 @@ static bool protocol_6lowpan_host_challenge(protocol_interface_info_entry_t *cur
memcpy(ll64, ADDR_LINK_LOCAL_PREFIX, 8);
memcpy(&ll64[8], mac64, 8);
ll64[8] ^= 2;
if (mle_service_update_length_by_ptr(bufId,ptr)!= 0) {
if (mle_service_update_length_by_ptr(bufId, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
timeout.retrans_max = 3;
@ -289,7 +289,7 @@ static bool protocol_6lowpan_router_challenge(protocol_interface_info_entry_t *c
uint8_t security_level = mle_service_security_level_get(cur->id);
tr_debug("Link REQUEST");
bufId = mle_service_msg_allocate(cur->id, 32, true,MLE_COMMAND_REQUEST);
bufId = mle_service_msg_allocate(cur->id, 32, true, MLE_COMMAND_REQUEST);
if (bufId == 0) {
return false;
}
@ -305,7 +305,7 @@ static bool protocol_6lowpan_router_challenge(protocol_interface_info_entry_t *c
memcpy(ll64, ADDR_LINK_LOCAL_PREFIX, 8);
memcpy(&ll64[8], mac64, 8);
ll64[8] ^= 2;
if (mle_service_update_length_by_ptr(bufId,ptr)!= 0) {
if (mle_service_update_length_by_ptr(bufId, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
timeout.retrans_max = 2;
@ -322,7 +322,8 @@ static bool protocol_6lowpan_router_challenge(protocol_interface_info_entry_t *c
}
static uint8_t mle_advert_neigh_cnt(protocol_interface_info_entry_t *cur_interface, bool short_adr) {
static uint8_t mle_advert_neigh_cnt(protocol_interface_info_entry_t *cur_interface, bool short_adr)
{
uint8_t advert_neigh_cnt;
uint8_t neighb_max;
@ -358,9 +359,9 @@ static uint8_t mle_link_quality_tlv_parse(uint8_t *mac64, uint16_t short_address
uint8_t own_addr_match = false;
// Searches own address from link quality TLV
while (data_length >= entry_size ) {
while (data_length >= entry_size) {
if (entry_size == 4){
if (entry_size == 4) {
if (common_read_16_bit(ptr + 2) == short_address) {
own_addr_match = true;
}
@ -408,7 +409,7 @@ static uint8_t *mle_table_set_neighbours(protocol_interface_info_entry_t *cur, u
uint8_t *link_flags_ptr;
mac_neighbor_table_entry_t *first_entry_ptr = NULL;
mac_neighbor_table_list_t * neigh_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list;
mac_neighbor_table_list_t *neigh_list = &cur->mac_parameters->mac_neighbor_table->neighbour_list;
*ptr++ = MLE_TYPE_LINK_QUALITY;
len_ptr = ptr++;
@ -428,8 +429,7 @@ static uint8_t *mle_table_set_neighbours(protocol_interface_info_entry_t *cur, u
neigh_count_max = mle_advert_neigh_cnt(cur, use_short_address_compression);
bool clean_entries = false;
ns_list_foreach(mac_neighbor_table_entry_t, cur_entry, neigh_list)
{
ns_list_foreach(mac_neighbor_table_entry_t, cur_entry, neigh_list) {
if ((cur_entry->connected_device) && (cur_entry->advertisment == false)) {
@ -489,7 +489,7 @@ static int protocol_6lowpan_mle_neigh_advertise(protocol_interface_info_entry_t
* Total = 10 + neighbours * 4
*/
uint16_t neig_cache_size = 40 + 7;
uint8_t short_temp[2] = {0xff,0xff};
uint8_t short_temp[2] = {0xff, 0xff};
uint8_t *ptr;
mle_message_timeout_params_t timeout;
@ -497,7 +497,7 @@ static int protocol_6lowpan_mle_neigh_advertise(protocol_interface_info_entry_t
return 0;
}
if (mac_neighbor_table_address_discover(mac_neighbor_info(cur), short_temp,ADDR_802_15_4_SHORT)) {
if (mac_neighbor_table_address_discover(mac_neighbor_info(cur), short_temp, ADDR_802_15_4_SHORT)) {
neig_cache_size += mle_advert_neigh_cnt(cur, false) * 10;
} else {
neig_cache_size += mle_advert_neigh_cnt(cur, true) << 2;
@ -515,7 +515,7 @@ static int protocol_6lowpan_mle_neigh_advertise(protocol_interface_info_entry_t
timeout.delay = MLE_NO_DELAY;
tr_debug("Send MLE Advertisement");
mle_service_set_msg_destination_address(bufId,ADDR_LINK_LOCAL_ALL_ROUTERS);
mle_service_set_msg_destination_address(bufId, ADDR_LINK_LOCAL_ALL_ROUTERS);
mle_service_set_msg_timeout_parameters(bufId, &timeout);
ptr = mle_service_get_data_pointer(bufId);
@ -523,7 +523,7 @@ static int protocol_6lowpan_mle_neigh_advertise(protocol_interface_info_entry_t
ptr = mle_tlv_write_mode(ptr, lowpan_mode_get_by_interface_ptr(cur));
ptr = mle_table_set_neighbours(cur, ptr);
if (mle_service_update_length_by_ptr(bufId,ptr)!= 0) {
if (mle_service_update_length_by_ptr(bufId, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
@ -626,7 +626,7 @@ static uint16_t mle_router_synch(protocol_interface_info_entry_t *cur, const uin
ptr = mle_general_write_timeout(ptr, cur);
}
if (destAddress && incoming_idr != 0){
if (destAddress && incoming_idr != 0) {
uint8_t mac64[8];
memcpy(mac64, &destAddress[8], 8);
mac64[0] ^= 2;
@ -634,9 +634,9 @@ static uint16_t mle_router_synch(protocol_interface_info_entry_t *cur, const uin
}
if (destAddress) {
mle_service_set_msg_destination_address(bufId,destAddress);
mle_service_set_msg_destination_address(bufId, destAddress);
} else {
mle_service_set_msg_destination_address(bufId,ADDR_LINK_LOCAL_ALL_ROUTERS);
mle_service_set_msg_destination_address(bufId, ADDR_LINK_LOCAL_ALL_ROUTERS);
}
if (retrans) {
@ -657,9 +657,9 @@ static uint16_t mle_router_synch(protocol_interface_info_entry_t *cur, const uin
timeout.delay = delay;
if (mle_service_update_length_by_ptr(bufId,ptr)!= 0) {
tr_debug("Buffer overflow at message write");
}
if (mle_service_update_length_by_ptr(bufId, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
mle_service_set_msg_timeout_parameters(bufId, &timeout);
mle_service_send_message(bufId);
@ -677,12 +677,12 @@ static int mle_router_accept_request_build(protocol_interface_info_entry_t *cur,
if (type == MLE_COMMAND_ACCEPT) {
bufId = mle_service_msg_allocate(cur->id, 64, false,type);
bufId = mle_service_msg_allocate(cur->id, 64, false, type);
timeout.retrans_max = 0;
timeout.timeout_init = 0;
timeout.timeout_max = 0;
} else {
bufId = mle_service_msg_allocate(cur->id, 64, true,type);
bufId = mle_service_msg_allocate(cur->id, 64, true, type);
timeout.retrans_max = 2;
timeout.timeout_init = 2;
timeout.timeout_max = 4;
@ -700,7 +700,7 @@ static int mle_router_accept_request_build(protocol_interface_info_entry_t *cur,
tr_debug("MLE Router Link Request response");
mle_service_set_msg_destination_address(bufId,mle_msg->packet_src_address);
mle_service_set_msg_destination_address(bufId, mle_msg->packet_src_address);
uint8_t *ptr = mle_service_get_data_pointer(bufId);
ptr = mle_tlv_write_mode(ptr, lowpan_mode_get_by_interface_ptr(cur));
@ -719,9 +719,9 @@ static int mle_router_accept_request_build(protocol_interface_info_entry_t *cur,
ptr = mle_tlv_write_link_quality(ptr, incoming_idr, mac64, 0, priority_flag);
ptr = mle_general_write_source_address(ptr, cur);
if (mle_service_update_length_by_ptr(bufId,ptr)!= 0) {
tr_debug("Buffer overflow at message write");
}
if (mle_service_update_length_by_ptr(bufId, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
mle_service_set_msg_timeout_parameters(bufId, &timeout);
if (type == MLE_COMMAND_ACCEPT) {
@ -995,7 +995,7 @@ static bool mle_6lowpan_neighbor_limit_check(mle_message_t *mle_msg, uint8_t onl
if (mle_msg->message_type == MLE_COMMAND_REQUEST) {
mle_tlv_info_t mle_tlv_info;
if (mle_tlv_option_discover(mle_msg->data_ptr, mle_msg->data_length, MLE_TYPE_LINK_QUALITY, &mle_tlv_info) > 0) {
link_quality = true;
link_quality = true;
}
}
@ -1010,7 +1010,7 @@ static bool mle_6lowpan_neighbor_limit_check(mle_message_t *mle_msg, uint8_t onl
}
uint16_t ignore_prob = randLIB_get_random_in_range(1,
mle_6lowpan_data->nbr_of_neigh_upper_threshold - mle_6lowpan_data->nbr_of_neigh_lower_threshold);
mle_6lowpan_data->nbr_of_neigh_upper_threshold - mle_6lowpan_data->nbr_of_neigh_lower_threshold);
if (ignore_prob < (mle_neigh_cnt - mle_6lowpan_data->nbr_of_neigh_lower_threshold)) {
return false;
@ -1041,7 +1041,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml
tr_debug("Link REQ");
if (!cur->global_address_available) {
return;
} else if (mle_validate_6lowpan_link_request_message(mle_msg->data_ptr, mle_msg->data_length,&mle_challenge) !=0 ) {
} else if (mle_validate_6lowpan_link_request_message(mle_msg->data_ptr, mle_msg->data_length, &mle_challenge) != 0) {
return;
}
@ -1057,7 +1057,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml
//Update only old information based on link request
entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL);
if (entry_temp) {
mle_neigh_time_and_mode_update(entry_temp,mle_msg);
mle_neigh_time_and_mode_update(entry_temp, mle_msg);
mle_neigh_entry_update_by_mle_tlv_list(interface_id, entry_temp, mle_msg->data_ptr, mle_msg->data_length, cur->mac, own_mac16);
mle_neigh_entry_frame_counter_update(entry_temp, mle_msg->data_ptr, mle_msg->data_length, cur, security_headers->KeyIndex);
} else {
@ -1114,7 +1114,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml
mac_data_poll_protocol_poll_mode_decrement(cur);
//Read Source address and Challenge
mle_neigh_time_and_mode_update(entry_temp,mle_msg);
mle_neigh_time_and_mode_update(entry_temp, mle_msg);
if (mle_msg->message_type == MLE_COMMAND_ACCEPT_AND_REQUEST) {
// If no global address set priority (bootstrap ongoing)
if (!cur->global_address_available) {
@ -1179,8 +1179,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml
uint8_t link_flags;
if (mle_tlv_info.tlvLen > 0) {
link_flags = *(mle_tlv_info.dataPtr);
if (mle_link_quality_tlv_parse(cur->mac,mac_helper_mac16_address_get(cur) , mle_tlv_info.dataPtr, mle_tlv_info.tlvLen, NULL, NULL))
{
if (mle_link_quality_tlv_parse(cur->mac, mac_helper_mac16_address_get(cur), mle_tlv_info.dataPtr, mle_tlv_info.tlvLen, NULL, NULL)) {
drop_advertisment = 0;
}
@ -1200,7 +1199,7 @@ void mle_6lowpan_message_handler(int8_t interface_id, mle_message_t *mle_msg, ml
}
//UPDATE
mle_neigh_entry_update_by_mle_tlv_list(cur->id,entry_temp, mle_msg->data_ptr, mle_msg->data_length, cur->mac, own_mac16);
mle_neigh_entry_update_by_mle_tlv_list(cur->id, entry_temp, mle_msg->data_ptr, mle_msg->data_length, cur->mac, own_mac16);
mle_neigh_entry_frame_counter_update(entry_temp, mle_msg->data_ptr, mle_msg->data_length, cur, security_headers->KeyIndex);
if (entry_temp->connected_device) {
mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, entry_temp->link_lifetime);
@ -1220,13 +1219,13 @@ int8_t arm_6lowpan_mle_service_ready_for_security_init(protocol_interface_info_e
//validate MLE service
if (!mle_service_interface_registeration_validate(cur->id)) {
//Register
if (mle_service_interface_register(cur->id,cur, mle_6lowpan_message_handler, cur->mac,8) != 0) {
if (mle_service_interface_register(cur->id, cur, mle_6lowpan_message_handler, cur->mac, 8) != 0) {
tr_error("Mle Service init Fail");
return -1;
}
if (mle_6lowpan_data) {
if (mle_service_interface_token_bucket_settings_set(cur->id, mle_6lowpan_data->token_bucket_size,
mle_6lowpan_data->token_bucket_rate, mle_6lowpan_data->token_bucket_count) < 0) {
mle_6lowpan_data->token_bucket_rate, mle_6lowpan_data->token_bucket_count) < 0) {
return -1;
}
mle_service_set_frame_counter_check(true);
@ -1312,7 +1311,7 @@ static uint8_t protocol_6lowpan_mle_order_last_entries(int8_t interface_id, mac_
{
mac_neighbor_table_entry_t *last;
mac_neighbor_table_entry_t *first_ordered = NULL;
etx_storage_t * etx_last, *etx_cur;
etx_storage_t *etx_last, *etx_cur;
uint8_t count = 0;
do {
last = NULL;
@ -1358,7 +1357,7 @@ static uint8_t protocol_6lowpan_mle_order_last_entries(int8_t interface_id, mac_
if (count == entry_count) {
break;
}
// If no lasts anymore then exits
// If no lasts anymore then exits
} else {
break;
}
@ -1393,21 +1392,21 @@ static void lowpan_mle_receive_security_bypass_cb(int8_t interface_id, mle_messa
if (mle_msg->message_type == MLE_COMMAND_REJECT) {
if ((interface->lowpan_info & (INTERFACE_NWK_BOOTSRAP_ACTIVE | INTERFACE_NWK_BOOTSRAP_PANA_AUTHENTICATION)) != (INTERFACE_NWK_BOOTSRAP_ACTIVE | INTERFACE_NWK_BOOTSRAP_PANA_AUTHENTICATION)) {
return;
}
return;
}
if (protocol_6lowpan_interface_compare_cordinator_netid(interface, mle_msg->packet_src_address + 8) != 0) {
return;
}
if (protocol_6lowpan_interface_compare_cordinator_netid(interface, mle_msg->packet_src_address + 8) != 0) {
return;
}
if (interface->nwk_bootstrap_state != ER_PANA_AUTH) {
return;
}
if (interface->nwk_bootstrap_state != ER_PANA_AUTH) {
return;
}
//Stop Pana and call ECC
tr_debug("MLE Link reject from cordinator");
pana_reset_client_session();
bootsrap_next_state_kick(ER_PANA_AUTH_ERROR, interface);
//Stop Pana and call ECC
tr_debug("MLE Link reject from cordinator");
pana_reset_client_session();
bootsrap_next_state_kick(ER_PANA_AUTH_ERROR, interface);
}
#endif
}
@ -1416,14 +1415,14 @@ void arm_6lowpan_security_init_ifup(protocol_interface_info_entry_t *cur)
{
if (cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_MLE) {
mle_service_security_init(cur->id, cur->if_lowpan_security_params->security_level,cur->if_lowpan_security_params->mle_security_frame_counter, NULL, protocol_6lowpan_mle_service_security_notify_cb);
mle_service_security_init(cur->id, cur->if_lowpan_security_params->security_level, cur->if_lowpan_security_params->mle_security_frame_counter, NULL, protocol_6lowpan_mle_service_security_notify_cb);
switch (cur->if_lowpan_security_params->nwk_security_mode) {
case NET_SEC_MODE_PSK_LINK_SECURITY:
mle_service_security_set_security_key(cur->id, cur->if_lowpan_security_params->psk_key_info.security_key, cur->if_lowpan_security_params->psk_key_info.key_id, true);
mle_service_security_set_frame_counter(cur->id, cur->if_lowpan_security_params->mle_security_frame_counter);
break;
mle_service_security_set_security_key(cur->id, cur->if_lowpan_security_params->psk_key_info.security_key, cur->if_lowpan_security_params->psk_key_info.key_id, true);
mle_service_security_set_frame_counter(cur->id, cur->if_lowpan_security_params->mle_security_frame_counter);
break;
case NET_SEC_MODE_PANA_LINK_SECURITY:
mle_service_interface_receiver_bypass_handler_update(cur->id, lowpan_mle_receive_security_bypass_cb);
break;
@ -1442,7 +1441,7 @@ void arm_6lowpan_security_init_ifup(protocol_interface_info_entry_t *cur)
case NET_SEC_MODE_PSK_LINK_SECURITY:
mac_helper_security_default_key_set(cur, cur->if_lowpan_security_params->psk_key_info.security_key, cur->if_lowpan_security_params->psk_key_info.key_id, MAC_KEY_ID_MODE_IDX);
/* fall through */
/* fall through */
default:
cur->lowpan_info &= ~INTERFACE_NWK_BOOTSRAP_PANA_AUTHENTICATION;
break;
@ -1464,7 +1463,7 @@ static int8_t arm_6lowpan_bootstrap_up(protocol_interface_info_entry_t *cur)
if (!mle_service_interface_registeration_validate(cur->id)) {
//Register
if (mle_service_interface_register(cur->id, cur, mle_6lowpan_message_handler, cur->mac,8) != 0) {
if (mle_service_interface_register(cur->id, cur, mle_6lowpan_message_handler, cur->mac, 8) != 0) {
tr_error("Mle Service init Fail");
return -1;
}
@ -1679,7 +1678,7 @@ int8_t arm_6lowpan_bootstarp_bootstrap_set(int8_t interface_id, net_6lowpan_mode
}
mac_neighbor_info(cur) = mac_neighbor_table_create(buffer.device_decription_table_size, lowpan_neighbor_entry_remove_notify
, lowpan_neighbor_entry_nud_notify, cur);
, lowpan_neighbor_entry_nud_notify, cur);
if (!mac_neighbor_info(cur)) {
return -1;
}
@ -1719,7 +1718,7 @@ int8_t arm_6lowpan_bootstarp_bootstrap_set(int8_t interface_id, net_6lowpan_mode
return -2;
#else
cur->comm_status_ind_cb = lowpan_comm_status_indication_cb;
if (mle_service_interface_register(cur->id, cur, mle_6lowpan_message_handler, cur->mac,8) != 0) {
if (mle_service_interface_register(cur->id, cur, mle_6lowpan_message_handler, cur->mac, 8) != 0) {
tr_error("Mle Service init Fail");
return -1;
}
@ -1736,7 +1735,7 @@ int8_t arm_6lowpan_bootstarp_bootstrap_set(int8_t interface_id, net_6lowpan_mode
if (mle_6lowpan_data) {
if (mle_service_interface_token_bucket_settings_set(cur->id, mle_6lowpan_data->token_bucket_size,
mle_6lowpan_data->token_bucket_rate, mle_6lowpan_data->token_bucket_count) < 0) {
mle_6lowpan_data->token_bucket_rate, mle_6lowpan_data->token_bucket_count) < 0) {
tr_error("Mle Service tokens set Fail");
return -1;
}
@ -1773,7 +1772,7 @@ int8_t arm_6lowpan_bootstarp_bootstrap_set(int8_t interface_id, net_6lowpan_mode
}
}
bootstrap_finish_check:
bootstrap_finish_check:
if (ret_val == 0) {
/**
* Do Thread dealloc
@ -1965,7 +1964,7 @@ static void protocol_6lowpan_nd_ready(protocol_interface_info_entry_t *cur)
addrtype_t addrType;
uint8_t tempAddr[8];
addrType = mac_helper_coordinator_address_get(cur, tempAddr);
mac_neighbor_table_entry_t * neig_info = mac_neighbor_table_address_discover(mac_neighbor_info(cur), tempAddr, addrType);
mac_neighbor_table_entry_t *neig_info = mac_neighbor_table_address_discover(mac_neighbor_info(cur), tempAddr, addrType);
if (neig_info) {
if (neig_info->lifetime > MLE_TABLE_CHALLENGE_TIMER) {
@ -1982,7 +1981,7 @@ static void protocol_6lowpan_address_reg_ready(protocol_interface_info_entry_t *
nd_router_t *cur;
cur = nd_get_object_by_nwk_id(cur_interface->nwk_id);
if(!cur) {
if (!cur) {
return;
}
@ -2029,7 +2028,7 @@ void protocol_6lowpan_bootstrap_nd_ready(protocol_interface_info_entry_t *cur_in
} else {
//Here we need to verify address mode
tr_debug("Synch MAC16 with parent");
if (protocol_6lowpan_parent_address_synch(cur_interface, true) != 0 ) {
if (protocol_6lowpan_parent_address_synch(cur_interface, true) != 0) {
nwk_bootsrap_state_update(ARM_NWK_NWK_CONNECTION_DOWN, cur_interface);
}
}
@ -2307,7 +2306,7 @@ static void nwk_6lowpan_bootsrap_pana_authentication_start(protocol_interface_in
static void coordinator_black_list(protocol_interface_info_entry_t *cur)
{
uint8_t coord_pan_address[10];
addrtype_t cord_adr_type = mac_helper_coordinator_address_get(cur, coord_pan_address +2);
addrtype_t cord_adr_type = mac_helper_coordinator_address_get(cur, coord_pan_address + 2);
if (cord_adr_type != ADDR_NONE) {
uint16_t pana_id = mac_helper_panid_get(cur);
@ -2323,7 +2322,7 @@ static void coordinator_black_list(protocol_interface_info_entry_t *cur)
static void nwk_6lowpan_network_authentication_fail(protocol_interface_info_entry_t *cur)
{
nwk_scan_params_t *scan_params =
&cur->mac_parameters->nwk_scan_params;
&cur->mac_parameters->nwk_scan_params;
tr_warn("Pana Auhth er");
@ -2380,9 +2379,9 @@ static void nwk_protocol_network_key_init_from_pana(protocol_interface_info_entr
mac_helper_security_default_key_set(cur, (key_ptr + 16), cur->pana_sec_info_temp->key_id, MAC_KEY_ID_MODE_IDX);
//mac_security_interface_link_frame_counter_reset(cur->id);
mac_helper_default_security_level_set(cur, SEC_ENC_MIC32);
mac_helper_default_security_key_id_mode_set(cur,MAC_KEY_ID_MODE_IDX);
mac_helper_default_security_key_id_mode_set(cur, MAC_KEY_ID_MODE_IDX);
//Init MLE Frame counter and key's and security
mle_service_security_init(cur->id, SEC_ENC_MIC32,cur->if_lowpan_security_params->mle_security_frame_counter, NULL, protocol_6lowpan_mle_service_security_notify_cb);
mle_service_security_init(cur->id, SEC_ENC_MIC32, cur->if_lowpan_security_params->mle_security_frame_counter, NULL, protocol_6lowpan_mle_service_security_notify_cb);
mle_service_security_set_security_key(cur->id, key_ptr, cur->pana_sec_info_temp->key_id, true);
mle_service_security_set_frame_counter(cur->id, cur->if_lowpan_security_params->mle_security_frame_counter);
}
@ -2484,7 +2483,7 @@ bool protocol_6lowpan_bootsrap_start(protocol_interface_info_entry_t *interface)
if (interface->if_lowpan_security_params->nwk_security_mode == NET_SEC_MODE_PSK_LINK_SECURITY) {
tr_debug("SET Security Mode");
mac_helper_default_security_level_set(interface, interface->mac_parameters->mac_configured_sec_level);
mac_helper_default_security_key_id_mode_set(interface,MAC_KEY_ID_MODE_IDX);
mac_helper_default_security_key_id_mode_set(interface, MAC_KEY_ID_MODE_IDX);
}
//Check first pana and then MLE and else start RS scan pahse
@ -2508,7 +2507,7 @@ bool protocol_6lowpan_bootsrap_start(protocol_interface_info_entry_t *interface)
}
void protocol_6lowpan_mac_scan_confirm(int8_t if_id, const mlme_scan_conf_t* conf)
void protocol_6lowpan_mac_scan_confirm(int8_t if_id, const mlme_scan_conf_t *conf)
{
nwk_pan_descriptor_t *result;
nwk_pan_descriptor_t *best;
@ -2587,8 +2586,8 @@ void bootstrap_timer_handle(uint16_t ticks)
start_req.BeaconOrder = 0x0f;
start_req.SuperframeOrder = 0x0f;
start_req.PANCoordinator = 1;
if( cur->mac_api ){
cur->mac_api->mlme_req(cur->mac_api, MLME_START, (void*)&start_req);
if (cur->mac_api) {
cur->mac_api->mlme_req(cur->mac_api, MLME_START, (void *)&start_req);
tr_error("Restart MAC");
}
}
@ -2606,7 +2605,7 @@ void protocol_6lowpan_bootstrap(protocol_interface_info_entry_t *cur)
mlme_scan_t req;
mac_create_scan_request(MAC_ACTIVE_SCAN, &cur->mac_parameters->mac_channel_list, cur->mac_parameters->nwk_scan_params.scan_duration, &req);
if( cur->mac_api ){
if (cur->mac_api) {
cur->scan_cb = protocol_6lowpan_mac_scan_confirm;
cur->mac_parameters->nwk_scan_params.active_scan_active = true;
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
@ -2738,7 +2737,7 @@ int protocol_6lowpan_set_ll16(protocol_interface_info_entry_t *cur, uint16_t mac
if_address_entry_t *address_entry;
uint8_t address[16];
memcpy(address, ADDR_LINK_LOCAL_PREFIX, 8);
memcpy(address + 8, ADDR_SHORT_ADR_SUFFIC , 6);
memcpy(address + 8, ADDR_SHORT_ADR_SUFFIC, 6);
common_write_16_bit(mac_short_address, &address[14]);
address_entry = addr_add(cur, address, 64, ADDR_SOURCE_UNKNOWN, 0xffffffff, 0xffffffff, false);
@ -2753,10 +2752,10 @@ static void protocol_6lowpan_generate_link_reject(protocol_interface_info_entry_
uint8_t address[16];
memcpy(address, ADDR_LINK_LOCAL_PREFIX, 8);
if (status->SrcAddrMode == MAC_ADDR_MODE_16_BIT) {
memcpy(address + 8, ADDR_SHORT_ADR_SUFFIC , 6);
memcpy(address + 14,status->SrcAddr, 2);
memcpy(address + 8, ADDR_SHORT_ADR_SUFFIC, 6);
memcpy(address + 14, status->SrcAddr, 2);
} else {
memcpy(address + 8,status->SrcAddr, 8);
memcpy(address + 8, status->SrcAddr, 8);
address[8] ^= 2;
}
if (mac_helper_default_security_level_get(cur)) {
@ -2767,14 +2766,14 @@ static void protocol_6lowpan_generate_link_reject(protocol_interface_info_entry_
}
static void lowpan_comm_status_indication_cb(int8_t if_id, const mlme_comm_status_t* status)
static void lowpan_comm_status_indication_cb(int8_t if_id, const mlme_comm_status_t *status)
{
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(if_id);
if (!cur) {
return;
}
mac_neighbor_table_entry_t * entry_ptr;
mac_neighbor_table_entry_t *entry_ptr;
switch (status->status) {
case MLME_UNSUPPORTED_SECURITY:

View File

@ -219,7 +219,7 @@ static void reassembly_entry_free(reassembly_interface_t *interface_ptr, reassem
}
}
static void reassembly_list_free(reassembly_interface_t *interface_ptr )
static void reassembly_list_free(reassembly_interface_t *interface_ptr)
{
ns_list_foreach_safe(reassembly_entry_t, reassembly_entry, &interface_ptr->rx_list) {
reassembly_entry_free(interface_ptr, reassembly_entry);
@ -303,7 +303,7 @@ buffer_t *cipv6_frag_reassembly(int8_t interface_id, buffer_t *buf)
goto resassembly_error;
}
buffer_t *reassembly_buffer = buffer_get(1 + ((datagram_size+7) & ~7));
buffer_t *reassembly_buffer = buffer_get(1 + ((datagram_size + 7) & ~7));
if (!reassembly_buffer) {
//Put allocated back to free
reassembly_entry_free(interface_ptr, frag_ptr);
@ -509,14 +509,14 @@ int8_t reassembly_interface_init(int8_t interface_id, uint8_t reassembly_session
return -1;
}
memset(interface_ptr, 0 ,sizeof(reassembly_interface_t));
memset(interface_ptr, 0, sizeof(reassembly_interface_t));
interface_ptr->interface_id = interface_id;
interface_ptr->timeout = reassembly_timeout;
interface_ptr->entry_pointer_buffer = reassemply_ptr;
ns_list_init(&interface_ptr->free_list);
ns_list_init(&interface_ptr->rx_list);
for (uint8_t i=0; i<reassembly_session_limit ; i++) {
for (uint8_t i = 0; i < reassembly_session_limit ; i++) {
ns_list_add_to_end(&interface_ptr->free_list, reassemply_ptr);
reassemply_ptr++;
}

View File

@ -27,7 +27,7 @@
#define TRACE_GROUP "iphc"
typedef struct iphc_compress_state {
const lowpan_context_list_t * const context_list;
const lowpan_context_list_t *const context_list;
const uint8_t *in;
uint8_t *out;
uint16_t len;
@ -249,7 +249,7 @@ static bool compress_udp(iphc_compress_state_t *restrict cs)
}
*ptr++ = NHC_UDP | NHC_UDP_PORT_COMPRESS_BOTH;
*ptr++ = (src_port & 0xF) << 4 |
(dst_port & 0xF);
(dst_port & 0xF);
} else if ((src_port & 0xff00) == 0xf000) {
if (cs->out_space < 7) {
return false;

View File

@ -329,7 +329,7 @@ static bool decompress_addr(const lowpan_context_list_t *context_list, uint8_t *
}
typedef struct iphc_decompress_state {
const lowpan_context_list_t * const context_list;
const lowpan_context_list_t *const context_list;
const uint8_t *in;
const uint8_t *const end;
uint8_t *out;
@ -546,7 +546,7 @@ buffer_t *iphc_decompress(const lowpan_context_list_t *context_list, buffer_t *b
/* Copy compressed header into temporary buffer */
iphc = ns_dyn_mem_temporary_alloc(hc_size);
if (!iphc) {
tr_warn("IPHC header alloc fail %d",hc_size);
tr_warn("IPHC header alloc fail %d", hc_size);
goto decomp_error;
}
memcpy(iphc, buffer_data_pointer(buf), hc_size);
@ -555,7 +555,7 @@ buffer_t *iphc_decompress(const lowpan_context_list_t *context_list, buffer_t *b
buffer_data_strip_header(buf, hc_size);
buf = buffer_headroom(buf, ip_size);
if (!buf) {
tr_warn("IPHC headroom get fail %d",ip_size);
tr_warn("IPHC headroom get fail %d", ip_size);
goto decomp_error;
}
buffer_data_reserve_header(buf, ip_size);

View File

@ -31,14 +31,14 @@
#define TRACE_GROUP "BHlr"
static mlme_pan_descriptor_t *duplicate_pan_descriptor(const mlme_pan_descriptor_t *desc);
static nwk_pan_descriptor_t * get_local_description(uint16_t payload_length, uint8_t *payload_ptr);
static nwk_pan_descriptor_t *get_local_description(uint16_t payload_length, uint8_t *payload_ptr);
static uint8_t *beacon_optional_tlv_field_get(uint8_t len, uint8_t *ptr, uint8_t offset, uint8_t type);
static bool beacon_join_priority_tlv_val_get(uint8_t len, uint8_t *ptr, uint8_t offset, uint8_t *join_priority);
static bool beacon_join_priority_tlv_val_set(uint8_t len, uint8_t *ptr, uint8_t offset, uint8_t join_priority);
static bool beacon_join_priority_tlv_add(uint8_t len, uint8_t *ptr, uint8_t offset, uint8_t join_priority);
void beacon_received(int8_t if_id, const mlme_beacon_ind_t* data)
void beacon_received(int8_t if_id, const mlme_beacon_ind_t *data)
{
protocol_interface_info_entry_t *interface = protocol_stack_interface_info_get_by_id(if_id);
if (!interface || !data) {
@ -52,9 +52,9 @@ void beacon_received(int8_t if_id, const mlme_beacon_ind_t* data)
uint8_t coord_pan_address[10];
common_write_16_bit(data->PANDescriptor.CoordPANId, coord_pan_address);
memcpy(coord_pan_address + 2,data->PANDescriptor.CoordAddress, 8 );
memcpy(coord_pan_address + 2, data->PANDescriptor.CoordAddress, 8);
if (data->PANDescriptor.CoordAddrMode == MAC_ADDR_MODE_16_BIT) {
memset(coord_pan_address +4, 0, 6);
memset(coord_pan_address + 4, 0, 6);
}
if (pan_cordinator_blacklist_filter(&interface->pan_cordinator_black_list, coord_pan_address)) {
@ -108,7 +108,7 @@ void beacon_received(int8_t if_id, const mlme_beacon_ind_t* data)
//Here possible dynamic function API Call
uint8_t *b_data = ns_dyn_mem_temporary_alloc(data->beacon_data_length);
if( !b_data ){
if (!b_data) {
return;
}
uint16_t b_len = data->beacon_data_length;
@ -119,7 +119,7 @@ void beacon_received(int8_t if_id, const mlme_beacon_ind_t* data)
uint8_t join_priority;
if (beacon_join_priority_tlv_val_get(b_len, b_data, PLAIN_BEACON_PAYLOAD_SIZE, &join_priority)) {
lqi = interface->mac_parameters->beacon_compare_rx_cb_ptr(
interface->id, join_priority, data->PANDescriptor.LinkQuality);
interface->id, join_priority, data->PANDescriptor.LinkQuality);
}
}
@ -131,10 +131,10 @@ void beacon_received(int8_t if_id, const mlme_beacon_ind_t* data)
while (cur) {
cur_desc = cur->pan_descriptor;
if (cur_desc->LogicalChannel == data->PANDescriptor.LogicalChannel &&
cur_desc->CoordPANId == data->PANDescriptor.CoordPANId) {
cur_desc->CoordPANId == data->PANDescriptor.CoordPANId) {
//Compare address to primary we need to check that we are not storage same parent twice FHSS
if (memcmp(cur_desc->CoordAddress,data->PANDescriptor.CoordAddress , 8) == 0) {
if (memcmp(cur_desc->CoordAddress, data->PANDescriptor.CoordAddress, 8) == 0) {
//Update allways better LQI
if (cur_desc->LinkQuality < lqi) {
cur_desc->LinkQuality = lqi;
@ -154,7 +154,7 @@ void beacon_received(int8_t if_id, const mlme_beacon_ind_t* data)
}
ns_dyn_mem_free(cur->beacon_payload);
cur->beacon_payload = temp_payload;
memcpy(cur->beacon_payload, b_data,b_len);
memcpy(cur->beacon_payload, b_data, b_len);
} else {
ns_dyn_mem_free(cur->beacon_payload);
cur->beacon_payload = NULL;
@ -195,7 +195,7 @@ void beacon_received(int8_t if_id, const mlme_beacon_ind_t* data)
}
new_entry->pan_descriptor = duplicate_pan_descriptor(&data->PANDescriptor);
if( !new_entry->pan_descriptor ){
if (!new_entry->pan_descriptor) {
ns_dyn_mem_free(new_entry->beacon_payload);
ns_dyn_mem_free(new_entry);
return;
@ -214,7 +214,7 @@ void beacon_received(int8_t if_id, const mlme_beacon_ind_t* data)
}
new_entry->pan_descriptor = duplicate_pan_descriptor(&data->PANDescriptor);
if( !new_entry->pan_descriptor ){
if (!new_entry->pan_descriptor) {
ns_dyn_mem_free(new_entry->beacon_payload);
ns_dyn_mem_free(new_entry);
return;
@ -256,7 +256,7 @@ static bool beacon_join_priority_tlv_add(uint8_t len, uint8_t *ptr, uint8_t offs
{
// Invalid length
if (len < offset + BEACON_OPTION_JOIN_PRIORITY_LEN) {
return false;
return false;
}
ptr += offset;
@ -273,7 +273,8 @@ static bool beacon_join_priority_tlv_add(uint8_t len, uint8_t *ptr, uint8_t offs
return true;
}
static nwk_pan_descriptor_t * get_local_description(uint16_t payload_length, uint8_t *payload_ptr) {
static nwk_pan_descriptor_t *get_local_description(uint16_t payload_length, uint8_t *payload_ptr)
{
nwk_pan_descriptor_t *description = ns_dyn_mem_temporary_alloc(sizeof(nwk_pan_descriptor_t));
if (description) {
memset(description, 0, sizeof(nwk_pan_descriptor_t));
@ -300,7 +301,7 @@ static uint8_t *beacon_optional_tlv_field_get(uint8_t len, uint8_t *ptr, uint8_t
tlv_ptr = ptr + offset + tlvs_len;
if (*tlv_ptr == BEACON_OPTION_END_DELIMITER) {
break;
// If TLV is found
// If TLV is found
} else if (*tlv_ptr >> 4 == type) {
// Validates TLV length
if (len >= offset + tlvs_len + 1 + (*tlv_ptr & 0x0F)) {
@ -320,7 +321,7 @@ static uint8_t *beacon_optional_tlv_field_get(uint8_t len, uint8_t *ptr, uint8_t
static mlme_pan_descriptor_t *duplicate_pan_descriptor(const mlme_pan_descriptor_t *desc)
{
mlme_pan_descriptor_t *ret = ns_dyn_mem_temporary_alloc(sizeof(mlme_pan_descriptor_t));
if(!ret){
if (!ret) {
return NULL;
}
memset(ret, 0, sizeof(mlme_pan_descriptor_t));
@ -407,7 +408,7 @@ void beacon_join_priority_update(int8_t interface_id)
protocol_interface_info_entry_t *interface = protocol_stack_interface_info_get_by_id(interface_id);
if (!interface || !interface->mac_parameters ||
!interface->mac_parameters->beacon_join_priority_tx_cb_ptr) {
!interface->mac_parameters->beacon_join_priority_tx_cb_ptr) {
return;
}

View File

@ -38,9 +38,9 @@ void beacon_optional_tlv_fields_skip(uint16_t *len, uint8_t **ptr, uint8_t offse
/* Beacon */
int8_t mac_beacon_link_beacon_compare_rx_callback_set(int8_t interface_id,
beacon_compare_rx_cb *beacon_compare_rx_cb_ptr);
beacon_compare_rx_cb *beacon_compare_rx_cb_ptr);
int8_t mac_beacon_link_beacon_join_priority_tx_callback_set(int8_t interface_id,
beacon_join_priority_tx_cb *beacon_join_priority_tx_cb_ptr);
beacon_join_priority_tx_cb *beacon_join_priority_tx_cb_ptr);
void beacon_join_priority_update(int8_t interface_id);

View File

@ -94,7 +94,7 @@ static int8_t host_link_configuration(bool rx_on_idle, protocol_interface_info_e
mac_helper_pib_boolean_set(cur, macRxOnWhenIdle, rx_on_idle);
if (thread_info(cur)) {
if(rx_on_idle != backUp_bool){
if (rx_on_idle != backUp_bool) {
//If mode have been changed, send child update
thread_bootstrap_child_update_trig(cur);
}
@ -229,7 +229,7 @@ void mac_data_poll_disable(struct protocol_interface_info_entry *cur)
void mac_data_poll_enable_check(protocol_interface_info_entry_t *cur)
{
if (!cur || !cur->rfd_poll_info ) {
if (!cur || !cur->rfd_poll_info) {
return;
}
@ -252,7 +252,7 @@ int8_t mac_data_poll_host_mode_get(struct protocol_interface_info_entry *cur, ne
void mac_poll_timer_trig(uint32_t poll_time, protocol_interface_info_entry_t *cur)
{
if( !cur ){
if (!cur) {
return;
}
eventOS_event_timer_cancel(cur->id, mac_data_poll_tasklet);
@ -262,19 +262,19 @@ void mac_poll_timer_trig(uint32_t poll_time, protocol_interface_info_entry_t *cu
if (poll_time < 20) {
arm_event_s event = {
.receiver = mac_data_poll_tasklet,
.sender = mac_data_poll_tasklet,
.event_id = cur->id,
.data_ptr = NULL,
.event_type = MAC_DATA_POLL_REQUEST_EVENT,
.priority = ARM_LIB_MED_PRIORITY_EVENT,
.receiver = mac_data_poll_tasklet,
.sender = mac_data_poll_tasklet,
.event_id = cur->id,
.data_ptr = NULL,
.event_type = MAC_DATA_POLL_REQUEST_EVENT,
.priority = ARM_LIB_MED_PRIORITY_EVENT,
};
if (eventOS_event_send(&event) != 0) {
tr_error("eventOS_event_send() failed");
}
} else {
if (eventOS_event_timer_request(cur->id, MAC_DATA_POLL_REQUEST_EVENT, mac_data_poll_tasklet, poll_time)!= 0) {
if (eventOS_event_timer_request(cur->id, MAC_DATA_POLL_REQUEST_EVENT, mac_data_poll_tasklet, poll_time) != 0) {
tr_error("Poll Timer start Fail");
}
}
@ -302,13 +302,13 @@ static mac_neighbor_table_entry_t *neighbor_data_poll_referesh(protocol_interfac
void mac_mlme_poll_confirm(protocol_interface_info_entry_t *cur, const mlme_poll_conf_t *confirm)
{
if( !cur || !confirm ){
if (!cur || !confirm) {
return;
}
uint32_t poll_time = 1;
nwk_rfd_poll_setups_s *rf_ptr = cur->rfd_poll_info;
if( !rf_ptr ){
if (!rf_ptr) {
return;
}
@ -344,7 +344,7 @@ void mac_mlme_poll_confirm(protocol_interface_info_entry_t *cur, const mlme_poll
//tr_debug("Parent Poll Fail");
poll_time = 0;
rf_ptr->nwk_parent_poll_fail = 0;
if( rf_ptr->pollFailCb ){
if (rf_ptr->pollFailCb) {
rf_ptr->pollFailCb(cur->id);
}
} else {
@ -392,7 +392,7 @@ static void mac_data_poll_cb_run(int8_t interface_id)
if (cur->mac_api && cur->mac_api->mlme_req) {
rf_ptr->pollActive = true;
cur->mac_api->mlme_req(cur->mac_api, MLME_POLL, (void*) &rf_ptr->poll_req);
cur->mac_api->mlme_req(cur->mac_api, MLME_POLL, (void *) &rf_ptr->poll_req);
} else {
tr_error("MAC not registered to interface");
}
@ -401,13 +401,13 @@ static void mac_data_poll_cb_run(int8_t interface_id)
int8_t mac_data_poll_host_mode_set(struct protocol_interface_info_entry *cur, net_host_mode_t mode, uint32_t poll_time)
{
#ifndef NO_MLE
if( !cur){
if (!cur) {
return -1;
}
int8_t ret_val = 0;
nwk_rfd_poll_setups_s *rf_ptr = cur->rfd_poll_info;
//Check IF Bootsrap Ready and type is Host
if (!rf_ptr ) {
if (!rf_ptr) {
return -1;
}
@ -520,7 +520,7 @@ void mac_data_poll_init(struct protocol_interface_info_entry *cur)
nwk_rfd_poll_setups_s *rfd_ptr = cur->rfd_poll_info;
if (!rfd_ptr) {
if (mac_data_poll_tasklet_init() < 0 ) {
if (mac_data_poll_tasklet_init() < 0) {
tr_error("Mac data poll tasklet init fail");
} else {
rfd_ptr = ns_dyn_mem_alloc(sizeof(nwk_rfd_poll_setups_s));

View File

@ -29,7 +29,7 @@
#define TRACE_GROUP "MACh"
static const uint8_t mac_helper_default_key_source[8] = {0xff,0,0,0,0,0,0,0};
static const uint8_t mac_helper_default_key_source[8] = {0xff, 0, 0, 0, 0, 0, 0, 0};
static uint8_t mac_helper_header_security_aux_header_length(uint8_t keyIdmode);
static uint8_t mac_helper_security_mic_length_get(uint8_t security_level);
@ -51,13 +51,13 @@ static int8_t mac_helper_pib_8bit_set(protocol_interface_info_entry_t *interface
break;
}
if (interface->mac_api && interface->mac_api->mlme_req ) {
if (interface->mac_api && interface->mac_api->mlme_req) {
mlme_set_t set_req;
set_req.attr = attribute;
set_req.attr_index = 0;
set_req.value_pointer = &value;
set_req.value_size = 1;
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
}
return 0;
@ -65,7 +65,7 @@ static int8_t mac_helper_pib_8bit_set(protocol_interface_info_entry_t *interface
void mac_create_scan_request(mac_scan_type_t type, channel_list_s *chanlist, uint8_t scan_duration, mlme_scan_t *request)
{
if( !chanlist || !request ){
if (!chanlist || !request) {
return;
}
@ -93,7 +93,7 @@ nwk_pan_descriptor_t *mac_helper_select_best_lqi(nwk_pan_descriptor_t *list)
void mac_helper_drop_selected_from_the_scanresult(nwk_scan_params_t *scanParams, nwk_pan_descriptor_t *selected)
{
if( !scanParams || !selected ){
if (!scanParams || !selected) {
return;
}
nwk_pan_descriptor_t *cur;
@ -122,7 +122,7 @@ void mac_helper_drop_selected_from_the_scanresult(nwk_scan_params_t *scanParams,
void mac_helper_free_scan_confirm(nwk_scan_params_t *params)
{
if( !params ){
if (!params) {
return;
}
if (params->nwk_scan_res_size) {
@ -142,7 +142,7 @@ void mac_helper_free_scan_confirm(nwk_scan_params_t *params)
params->nwk_cur_active = mac_helper_free_pan_descriptions(params->nwk_cur_active);
}
nwk_pan_descriptor_t * mac_helper_free_pan_descriptions(nwk_pan_descriptor_t *nwk_cur_active)
nwk_pan_descriptor_t *mac_helper_free_pan_descriptions(nwk_pan_descriptor_t *nwk_cur_active)
{
if (nwk_cur_active) {
ns_dyn_mem_free(nwk_cur_active->pan_descriptor);
@ -154,7 +154,7 @@ nwk_pan_descriptor_t * mac_helper_free_pan_descriptions(nwk_pan_descriptor_t *nw
int8_t mac_helper_nwk_id_filter_set(const uint8_t *nw_id, nwk_filter_params_s *filter)
{
if( !filter ){
if (!filter) {
return -1;
}
int8_t ret_val = 0;
@ -182,7 +182,7 @@ void mac_helper_panid_set(protocol_interface_info_entry_t *interface, uint16_t p
set_req.attr_index = 0;
set_req.value_pointer = &panId;
set_req.value_size = 2;
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
}
void mac_helper_mac16_address_set(protocol_interface_info_entry_t *interface, uint16_t mac16)
@ -198,13 +198,13 @@ void mac_helper_mac16_address_set(protocol_interface_info_entry_t *interface, ui
set_req.attr_index = 0;
set_req.value_pointer = &mac16;
set_req.value_size = 2;
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
}
uint16_t mac_helper_mac16_address_get(const protocol_interface_info_entry_t *interface)
{
uint16_t shortAddress = 0xfffe;
if (interface ) {
if (interface) {
shortAddress = interface->mac_parameters->mac_short_address;
}
return shortAddress;
@ -233,14 +233,14 @@ void mac_helper_set_default_key_source(protocol_interface_info_entry_t *interfac
{
mlme_set_t set_req;
set_req.attr_index = 0;
set_req.value_pointer = (void*)mac_helper_default_key_source;
set_req.value_pointer = (void *)mac_helper_default_key_source;
set_req.value_size = 8;
//Set first default key source
set_req.attr = macDefaultKeySource;
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
//Set first default key source
set_req.attr = macAutoRequestKeySource;
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
}
@ -252,7 +252,7 @@ void mac_helper_default_security_level_set(protocol_interface_info_entry_t *inte
} else {
security_enabled = false;
}
mac_helper_pib_8bit_set(interface,macAutoRequestSecurityLevel, securityLevel);
mac_helper_pib_8bit_set(interface, macAutoRequestSecurityLevel, securityLevel);
mac_helper_pib_boolean_set(interface, macSecurityEnabled, security_enabled);
}
@ -264,7 +264,7 @@ uint8_t mac_helper_default_security_level_get(protocol_interface_info_entry_t *i
void mac_helper_default_security_key_id_mode_set(protocol_interface_info_entry_t *interface, uint8_t keyIdMode)
{
mac_helper_pib_8bit_set(interface,macAutoRequestKeyIdMode, keyIdMode);
mac_helper_pib_8bit_set(interface, macAutoRequestKeyIdMode, keyIdMode);
}
uint8_t mac_helper_default_security_key_id_mode_get(protocol_interface_info_entry_t *interface)
@ -280,7 +280,8 @@ static void mac_helper_key_lookup_set(mlme_key_id_lookup_descriptor_t *lookup, u
}
static void mac_helper_keytable_descriptor_set(struct mac_api_s *api, const uint8_t *key, uint8_t id, uint8_t attribute_id) {
static void mac_helper_keytable_descriptor_set(struct mac_api_s *api, const uint8_t *key, uint8_t id, uint8_t attribute_id)
{
mlme_set_t set_req;
mlme_key_id_lookup_descriptor_t lookup_description;
mlme_key_descriptor_entry_t key_description;
@ -301,7 +302,8 @@ static void mac_helper_keytable_descriptor_set(struct mac_api_s *api, const uint
api->mlme_req(api, MLME_SET, &set_req);
}
static void mac_helper_keytable_pairwise_descriptor_set(struct mac_api_s *api, const uint8_t *key, const uint8_t *mac64, uint8_t attribute_id) {
static void mac_helper_keytable_pairwise_descriptor_set(struct mac_api_s *api, const uint8_t *key, const uint8_t *mac64, uint8_t attribute_id)
{
mlme_set_t set_req;
mlme_key_id_lookup_descriptor_t lookup_description;
mlme_key_descriptor_entry_t key_description;
@ -309,7 +311,7 @@ static void mac_helper_keytable_pairwise_descriptor_set(struct mac_api_s *api, c
memcpy(lookup_description.LookupData, mac64, 8);
lookup_description.LookupData[8] = 0;
lookup_description.LookupDataSize = 1;
tr_debug("Key add %u index %s", attribute_id,trace_array(lookup_description.LookupData, 9));
tr_debug("Key add %u index %s", attribute_id, trace_array(lookup_description.LookupData, 9));
memset(&key_description, 0, sizeof(mlme_key_descriptor_entry_t));
memcpy(key_description.Key, key, 16);
key_description.KeyIdLookupList = &lookup_description;
@ -322,7 +324,7 @@ static void mac_helper_keytable_pairwise_descriptor_set(struct mac_api_s *api, c
set_req.value_pointer = &key_description;
set_req.value_size = sizeof(mlme_key_descriptor_entry_t);
api->mlme_req(api,MLME_SET , &set_req);
api->mlme_req(api, MLME_SET, &set_req);
}
@ -332,7 +334,7 @@ int8_t mac_helper_security_default_key_set(protocol_interface_info_entry_t *inte
return -1;
}
mac_helper_pib_8bit_set(interface,macAutoRequestKeyIndex, id);
mac_helper_pib_8bit_set(interface, macAutoRequestKeyIndex, id);
mac_helper_keytable_descriptor_set(interface->mac_api, key, id, interface->mac_parameters->mac_default_key_attribute_id);
return 0;
}
@ -398,12 +400,13 @@ void mac_helper_security_key_swap_next_to_default(protocol_interface_info_entry_
interface->mac_parameters->mac_next_key_index = 0;
interface->mac_parameters->mac_next_key_attribute_id = prev_attribute;
mac_helper_pib_8bit_set(interface,macAutoRequestKeyIndex, interface->mac_parameters->mac_default_key_index);
mac_helper_pib_8bit_set(interface, macAutoRequestKeyIndex, interface->mac_parameters->mac_default_key_index);
}
void mac_helper_security_key_clean(protocol_interface_info_entry_t *interface) {
if (interface->mac_api ) {
void mac_helper_security_key_clean(protocol_interface_info_entry_t *interface)
{
if (interface->mac_api) {
mlme_set_t set_req;
mlme_key_descriptor_entry_t key_description;
memset(&key_description, 0, sizeof(mlme_key_descriptor_entry_t));
@ -413,11 +416,11 @@ void mac_helper_security_key_clean(protocol_interface_info_entry_t *interface) {
set_req.value_pointer = &key_description;
set_req.value_size = sizeof(mlme_key_descriptor_entry_t);
set_req.attr_index = interface->mac_parameters->mac_prev_key_attribute_id;
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
set_req.attr_index = interface->mac_parameters->mac_default_key_attribute_id;
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
set_req.attr_index = interface->mac_parameters->mac_next_key_attribute_id;
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
}
interface->mac_parameters->mac_prev_key_index = 0;
interface->mac_parameters->mac_default_key_index = 0;
@ -445,7 +448,7 @@ void mac_helper_coordinator_address_set(protocol_interface_info_entry_t *interfa
}
if (interface->mac_api) {
interface->mac_api->mlme_req(interface->mac_api, MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
}
}
@ -457,10 +460,10 @@ addrtype_t mac_helper_coordinator_address_get(protocol_interface_info_entry_t *i
}
if (interface->mac_parameters->mac_cordinator_info.cord_adr_mode == MAC_ADDR_MODE_16_BIT) {
memcpy(adr_ptr,interface->mac_parameters->mac_cordinator_info.mac_mlme_coord_address, 2);
memcpy(adr_ptr, interface->mac_parameters->mac_cordinator_info.mac_mlme_coord_address, 2);
ret = ADDR_802_15_4_SHORT;
} else if (interface->mac_parameters->mac_cordinator_info.cord_adr_mode == MAC_ADDR_MODE_64_BIT) {
memcpy(adr_ptr,interface->mac_parameters->mac_cordinator_info.mac_mlme_coord_address, 8);
memcpy(adr_ptr, interface->mac_parameters->mac_cordinator_info.mac_mlme_coord_address, 8);
ret = ADDR_802_15_4_LONG;
}
return ret;
@ -476,7 +479,7 @@ static void mac_helper_beacon_payload_length_set_to_mac(protocol_interface_info_
set_req.attr_index = 0;
set_req.value_pointer = &len;
set_req.value_size = 1;
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
}
}
@ -488,7 +491,7 @@ static void mac_helper_beacon_payload_set_to_mac(protocol_interface_info_entry_t
set_req.attr_index = 0;
set_req.value_pointer = payload;
set_req.value_size = length;
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
}
}
@ -501,13 +504,13 @@ uint8_t *mac_helper_beacon_payload_reallocate(protocol_interface_info_entry_t *i
if (len == interface->mac_parameters->mac_beacon_payload_size) {
// no change to size, return the existing buff
//Set allways length to zero for safe beacon payload manipulate
mac_helper_beacon_payload_length_set_to_mac(interface,0);
mac_helper_beacon_payload_length_set_to_mac(interface, 0);
return interface->mac_parameters->mac_beacon_payload;
}
if (len == 0) {
//SET MAC beacon payload to length to zero
mac_helper_beacon_payload_length_set_to_mac(interface,0);
mac_helper_beacon_payload_length_set_to_mac(interface, 0);
ns_dyn_mem_free(interface->mac_parameters->mac_beacon_payload);
interface->mac_parameters->mac_beacon_payload = NULL;
interface->mac_parameters->mac_beacon_payload_size = 0;
@ -516,7 +519,7 @@ uint8_t *mac_helper_beacon_payload_reallocate(protocol_interface_info_entry_t *i
tr_debug("mac_helper_beacon_payload_reallocate, old len: %d, new: %d", interface->mac_parameters->mac_beacon_payload_size, len);
uint8_t* temp_buff = ns_dyn_mem_alloc(len);
uint8_t *temp_buff = ns_dyn_mem_alloc(len);
if (temp_buff == NULL) {
// no need to proceed, could not allocate more space
@ -524,7 +527,7 @@ uint8_t *mac_helper_beacon_payload_reallocate(protocol_interface_info_entry_t *i
}
//SET MAC beacon payload to length to zero
mac_helper_beacon_payload_length_set_to_mac(interface,0);
mac_helper_beacon_payload_length_set_to_mac(interface, 0);
// copy data into new buffer before freeing old one
if (interface->mac_parameters->mac_beacon_payload_size > 0) {
@ -610,7 +613,7 @@ int8_t mac_helper_pib_boolean_set(protocol_interface_info_entry_t *interface, ml
set_req.attr_index = 0;
set_req.value_pointer = &value;
set_req.value_size = sizeof(bool);
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
}
return 0;
@ -622,13 +625,13 @@ int8_t mac_helper_mac_channel_set(protocol_interface_info_entry_t *interface, ui
if (interface->mac_parameters->mac_channel != new_channel) {
interface->mac_parameters->mac_channel = new_channel;
if (interface->mac_api && interface->mac_api->mlme_req ) {
if (interface->mac_api && interface->mac_api->mlme_req) {
mlme_set_t set_req;
set_req.attr = phyCurrentChannel;
set_req.attr_index = 0;
set_req.value_pointer = &new_channel;
set_req.value_size = 1;
interface->mac_api->mlme_req(interface->mac_api,MLME_SET , &set_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
}
}
return 0;
@ -673,7 +676,7 @@ bool mac_helper_write_our_addr(protocol_interface_info_entry_t *interface, socka
int8_t mac_helper_mac64_set(protocol_interface_info_entry_t *interface, const uint8_t *mac64)
{
memcpy(interface->mac, mac64, 8);
if (interface->mac_api ) {
if (interface->mac_api) {
interface->mac_api->mac64_set(interface->mac_api, mac64);
}
return 0;
@ -736,7 +739,8 @@ uint_fast8_t mac_helper_frame_overhead(protocol_interface_info_entry_t *cur, con
return length;
}
static uint8_t mac_helper_security_mic_length_get(uint8_t security_level) {
static uint8_t mac_helper_security_mic_length_get(uint8_t security_level)
{
uint8_t mic_length;
switch (security_level) {
case SEC_MIC32:
@ -761,16 +765,17 @@ static uint8_t mac_helper_security_mic_length_get(uint8_t security_level) {
return mic_length;
}
static uint8_t mac_helper_header_security_aux_header_length(uint8_t keyIdmode) {
static uint8_t mac_helper_header_security_aux_header_length(uint8_t keyIdmode)
{
uint8_t header_length = 5; //Header + 32-bit counter
switch (keyIdmode) {
case MAC_KEY_ID_MODE_SRC8_IDX:
header_length += 4; //64-bit key source first part
/* fall through */
/* fall through */
case MAC_KEY_ID_MODE_SRC4_IDX:
header_length += 4; //32-bit key source inline
/* fall through */
/* fall through */
case MAC_KEY_ID_MODE_IDX:
header_length += 1;
break;
@ -826,10 +831,10 @@ void mac_helper_devicetable_remove(mac_api_t *mac_api, uint8_t attribute_index)
set_req.attr = macDeviceTable;
set_req.attr_index = attribute_index;
set_req.value_pointer = (void*)&device_desc;
set_req.value_pointer = (void *)&device_desc;
set_req.value_size = sizeof(mlme_device_descriptor_t);
tr_debug("unRegister Device");
mac_api->mlme_req(mac_api,MLME_SET , &set_req);
mac_api->mlme_req(mac_api, MLME_SET, &set_req);
}
void mac_helper_device_description_write(protocol_interface_info_entry_t *cur, mlme_device_descriptor_t *device_desc, uint8_t *mac64, uint16_t mac16, uint32_t frame_counter, bool exempt)
@ -856,10 +861,10 @@ void mac_helper_devicetable_set(const mlme_device_descriptor_t *device_desc, pro
mlme_set_t set_req;
set_req.attr = macDeviceTable;
set_req.attr_index = attribute_index;
set_req.value_pointer = (void*)device_desc;
set_req.value_pointer = (void *)device_desc;
set_req.value_size = sizeof(mlme_device_descriptor_t);
tr_debug("Register Device");
cur->mac_api->mlme_req(cur->mac_api,MLME_SET , &set_req);
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_req);
}

View File

@ -39,7 +39,7 @@ void mac_helper_drop_selected_from_the_scanresult(struct nwk_scan_params *scanPa
void mac_helper_free_scan_confirm(struct nwk_scan_params *params);
struct nwk_pan_descriptor_t * mac_helper_free_pan_descriptions(struct nwk_pan_descriptor_t *nwk_cur_active);
struct nwk_pan_descriptor_t *mac_helper_free_pan_descriptions(struct nwk_pan_descriptor_t *nwk_cur_active);
int8_t mac_helper_nwk_id_filter_set(const uint8_t *nw_id, struct nwk_filter_params *filter);

View File

@ -38,7 +38,7 @@ static void mac_ie_header_parse(mac_header_IE_t *header_element, uint8_t *ptr)
{
uint16_t ie_dummy = common_read_16_bit_inverse(ptr);
header_element->length = (ie_dummy & MAC_IE_HEADER_LENGTH_MASK);
header_element->id = ((ie_dummy & MAC_IE_HEADER_ID_MASK ) >> 7 );
header_element->id = ((ie_dummy & MAC_IE_HEADER_ID_MASK) >> 7);
header_element->content_ptr = ptr + 2;
}
@ -46,7 +46,7 @@ static void mac_ie_payload_parse(mac_payload_IE_t *payload_element, uint8_t *ptr
{
uint16_t ie_dummy = common_read_16_bit_inverse(ptr);
payload_element->length = (ie_dummy & MAC_IE_PAYLOAD_LENGTH_MASK);
payload_element->id = ((ie_dummy & MAC_IE_PAYLOAD_ID_MASK ) >> 11);
payload_element->id = ((ie_dummy & MAC_IE_PAYLOAD_ID_MASK) >> 11);
payload_element->content_ptr = ptr + 2;
}
@ -57,11 +57,11 @@ static void mac_ie_nested_id_parse(mac_nested_payload_IE_t *element, uint8_t *pt
if (ie_dummy & MAC_NESTED_IE_TYPE_LONG_MASK) {
element->type_long = true;
element->length = (ie_dummy & MAC_NESTED_LONG_IE_PAYLOAD_LENGTH_MASK);
element->id = ((ie_dummy & MAC_NESTED_LONG_IE_PAYLOAD_ID_MASK ) >> 11);
element->id = ((ie_dummy & MAC_NESTED_LONG_IE_PAYLOAD_ID_MASK) >> 11);
} else {
element->type_long = false;
element->length = (ie_dummy & MAC_NESTED_SHORT_IE_PAYLOAD_LENGTH_MASK);
element->id = ((ie_dummy & MAC_NESTED_SHORT_IE_PAYLOAD_ID_MASK ) >> 8);
element->id = ((ie_dummy & MAC_NESTED_SHORT_IE_PAYLOAD_ID_MASK) >> 8);
}
element->content_ptr = ptr + 2;
@ -72,7 +72,7 @@ uint8_t *mac_ie_header_base_write(uint8_t *ptr, uint8_t type, uint16_t length)
{
uint16_t ie_dummy = 0; //Header Type
ie_dummy |= (length & MAC_IE_HEADER_LENGTH_MASK);
ie_dummy |= ((type << 7 ) & MAC_IE_HEADER_ID_MASK);
ie_dummy |= ((type << 7) & MAC_IE_HEADER_ID_MASK);
return common_write_16_bit_inverse(ie_dummy, ptr);
}
@ -81,7 +81,7 @@ uint8_t *mac_ie_payload_base_write(uint8_t *ptr, uint8_t type, uint16_t length)
uint16_t ie_dummy = MAC_IE_TYPE_PAYLOAD_MASK; //Payload type
ie_dummy |= (length & MAC_IE_PAYLOAD_LENGTH_MASK);
ie_dummy |= ((type << 11 ) & MAC_IE_PAYLOAD_ID_MASK);
ie_dummy |= ((type << 11) & MAC_IE_PAYLOAD_ID_MASK);
return common_write_16_bit_inverse(ie_dummy, ptr);
}
@ -89,7 +89,7 @@ uint8_t *mac_ie_nested_ie_long_base_write(uint8_t *ptr, uint8_t sub_id, uint16_t
{
uint16_t ie_dummy = MAC_NESTED_IE_TYPE_LONG_MASK;
ie_dummy |= (length & MAC_NESTED_LONG_IE_PAYLOAD_LENGTH_MASK);
ie_dummy |= ((sub_id << 11 ) & MAC_NESTED_LONG_IE_PAYLOAD_ID_MASK);
ie_dummy |= ((sub_id << 11) & MAC_NESTED_LONG_IE_PAYLOAD_ID_MASK);
return common_write_16_bit_inverse(ie_dummy, ptr);
}
@ -98,12 +98,12 @@ uint8_t *mac_ie_nested_ie_short_base_write(uint8_t *ptr, uint8_t sub_id, uint16_
{
uint16_t ie_dummy = 0;
ie_dummy |= (length & MAC_NESTED_SHORT_IE_PAYLOAD_LENGTH_MASK);
ie_dummy |= ((sub_id << 8 ) & MAC_NESTED_SHORT_IE_PAYLOAD_ID_MASK);
ie_dummy |= ((sub_id << 8) & MAC_NESTED_SHORT_IE_PAYLOAD_ID_MASK);
return common_write_16_bit_inverse(ie_dummy, ptr);
}
uint16_t mac_ie_payload_discover(uint8_t *payload_ptr, uint16_t length, mac_payload_IE_t * payload_ie)
uint16_t mac_ie_payload_discover(uint8_t *payload_ptr, uint16_t length, mac_payload_IE_t *payload_ie)
{
mac_payload_IE_t ie_element;
while (length >= 2) {
@ -121,7 +121,7 @@ uint16_t mac_ie_payload_discover(uint8_t *payload_ptr, uint16_t length, mac_payl
return 0;
}
uint16_t mac_ie_nested_discover(uint8_t *payload_ptr, uint16_t length, mac_nested_payload_IE_t * nested_ie)
uint16_t mac_ie_nested_discover(uint8_t *payload_ptr, uint16_t length, mac_nested_payload_IE_t *nested_ie)
{
mac_nested_payload_IE_t ie_element;
while (length >= 2) {
@ -144,7 +144,7 @@ uint16_t mac_ie_nested_discover(uint8_t *payload_ptr, uint16_t length, mac_neste
return 0;
}
uint8_t mac_ie_header_discover(uint8_t *header_ptr, uint16_t length, mac_header_IE_t * header_ie)
uint8_t mac_ie_header_discover(uint8_t *header_ptr, uint16_t length, mac_header_IE_t *header_ie)
{
mac_header_IE_t ie_element;
while (length >= 2) {
@ -162,7 +162,7 @@ uint8_t mac_ie_header_discover(uint8_t *header_ptr, uint16_t length, mac_header_
return 0;
}
uint8_t mac_ie_header_sub_id_discover(uint8_t *header_ptr, uint16_t length, mac_header_IE_t * header_ie, uint8_t sub_id)
uint8_t mac_ie_header_sub_id_discover(uint8_t *header_ptr, uint16_t length, mac_header_IE_t *header_ie, uint8_t sub_id)
{
mac_header_IE_t ie_element;
uint8_t *sub_id_ptr;

View File

@ -27,8 +27,8 @@ struct mac_payload_IE_s;
typedef struct mac_nested_payload_IE_s {
uint8_t *content_ptr; /**< Content data */
uint16_t length; /**< Element length 0- 2047 when type_long true and for short 0- 255*/
unsigned id:7; /**< Group ID 4-bit for long and 7 bit for short type */
bool type_long:1; /**< True when Nested IE long format and false for short */
unsigned id: 7; /**< Group ID 4-bit for long and 7 bit for short type */
bool type_long: 1; /**< True when Nested IE long format and false for short */
} mac_nested_payload_IE_t;
/** IE header element generic header write */
@ -44,15 +44,15 @@ uint8_t *mac_ie_nested_ie_long_base_write(uint8_t *ptr, uint8_t sub_id, uint16_t
uint8_t *mac_ie_nested_ie_short_base_write(uint8_t *ptr, uint8_t sub_id, uint16_t length);
/** Payload IE discover for spesific group ID */
uint16_t mac_ie_payload_discover(uint8_t *payload_ptr, uint16_t length, struct mac_payload_IE_s * payload_ie);
uint16_t mac_ie_payload_discover(uint8_t *payload_ptr, uint16_t length, struct mac_payload_IE_s *payload_ie);
/** Nested IE element discover inside parsed payload element */
uint16_t mac_ie_nested_discover(uint8_t *payload_ptr, uint16_t length, mac_nested_payload_IE_t * nested_ie);
uint16_t mac_ie_nested_discover(uint8_t *payload_ptr, uint16_t length, mac_nested_payload_IE_t *nested_ie);
/** Header IE elemnt discover */
uint8_t mac_ie_header_discover(uint8_t *header_ptr, uint16_t length, struct mac_header_IE_s * header_ie);
uint8_t mac_ie_header_discover(uint8_t *header_ptr, uint16_t length, struct mac_header_IE_s *header_ie);
/** Header IE elemnt discover with sub id */
uint8_t mac_ie_header_sub_id_discover(uint8_t *header_ptr, uint16_t length, mac_header_IE_t * header_ie, uint8_t sub_id);
uint8_t mac_ie_header_sub_id_discover(uint8_t *header_ptr, uint16_t length, mac_header_IE_t *header_ie, uint8_t sub_id);
#endif /* MAC_IE_LIB_H_ */

View File

@ -76,9 +76,10 @@ static mac_pairwise_interface_entry_t *mac_pairwise_key_list_allocate(uint8_t li
return newEntry;
}
static bool mac_pairwise_key_deacriptro_attribute_get(mac_pairwise_interface_entry_t *main_list, uint8_t key_attribute) {
static bool mac_pairwise_key_deacriptro_attribute_get(mac_pairwise_interface_entry_t *main_list, uint8_t key_attribute)
{
mac_pairwise_key_info_t *key_table = main_list->mac_pairwise_key_table;
for (uint8_t i = 0; i<main_list->key_table_size; i++) {
for (uint8_t i = 0; i < main_list->key_table_size; i++) {
if (key_table->key_decriptor_attribute == key_attribute) {
return false;
}
@ -88,16 +89,17 @@ static bool mac_pairwise_key_deacriptro_attribute_get(mac_pairwise_interface_ent
return true;
}
mac_pairwise_key_info_t *mac_pairwise_key_info_get(mac_pairwise_interface_entry_t *main_list, uint8_t device_id) {
mac_pairwise_key_info_t *mac_pairwise_key_info_get(mac_pairwise_interface_entry_t *main_list, uint8_t device_id)
{
mac_pairwise_key_info_t *key_table = main_list->mac_pairwise_key_table;
for (uint8_t i = 0; i<main_list->key_table_size; i++) {
for (uint8_t i = 0; i < main_list->key_table_size; i++) {
if (key_table->device_descriptor_attribute == device_id) {
return key_table;
}
key_table++;
}
if (main_list->key_table_size == main_list->key_list_size ) {
if (main_list->key_table_size == main_list->key_list_size) {
return NULL;
}
@ -107,7 +109,7 @@ mac_pairwise_key_info_t *mac_pairwise_key_info_get(mac_pairwise_interface_entry_
new_entry->device_descriptor_attribute = device_id;
new_entry->key_decriptor_attribute = main_list->network_key_offset;
//Allocate key id
while(!unique_id) {
while (!unique_id) {
unique_id = mac_pairwise_key_deacriptro_attribute_get(main_list, new_entry->key_decriptor_attribute);
if (!unique_id) {
new_entry->key_decriptor_attribute++;
@ -118,12 +120,13 @@ mac_pairwise_key_info_t *mac_pairwise_key_info_get(mac_pairwise_interface_entry_
return new_entry;
}
static bool mac_pairwise_key_info_delete(mac_pairwise_interface_entry_t *main_list, uint8_t device_id, uint8_t *key_attribute) {
static bool mac_pairwise_key_info_delete(mac_pairwise_interface_entry_t *main_list, uint8_t device_id, uint8_t *key_attribute)
{
bool removed_entry = false;
mac_pairwise_key_info_t *cur = main_list->mac_pairwise_key_table;
mac_pairwise_key_info_t *prev = NULL;
for (uint8_t i = 0; i<main_list->key_table_size; i++) {
for (uint8_t i = 0; i < main_list->key_table_size; i++) {
if (removed_entry) {
*prev = *cur;
} else {
@ -170,11 +173,12 @@ static mac_pairwise_interface_entry_t *mac_pairwise_key_main_class(uint8_t key_l
}
static void mac_pairwise_key_list_free(protocol_interface_info_entry_t *interface, mac_pairwise_interface_entry_t *main_list) {
static void mac_pairwise_key_list_free(protocol_interface_info_entry_t *interface, mac_pairwise_interface_entry_t *main_list)
{
//Delete mle entries & Keys
mac_neighbor_table_entry_t *cur_entry;
mac_pairwise_key_info_t *cur = main_list->mac_pairwise_key_table;
for (uint8_t i = 0; i< main_list->key_table_size; i++) {
for (uint8_t i = 0; i < main_list->key_table_size; i++) {
cur_entry = mac_neighbor_table_attribute_discover(mac_neighbor_info(interface), cur->device_descriptor_attribute);
if (cur_entry) {
mac_neighbor_table_neighbor_remove(mac_neighbor_info(interface), cur_entry);
@ -186,7 +190,7 @@ static void mac_pairwise_key_list_free(protocol_interface_info_entry_t *interfac
int mac_pairwise_key_interface_register(int8_t interface_id, uint8_t mac_supported_key_decription_size, uint8_t network_key_size)
{
if (!mac_supported_key_decription_size || !network_key_size ) {
if (!mac_supported_key_decription_size || !network_key_size) {
return -2;
}
@ -285,8 +289,8 @@ int mac_pairwise_key_add(int8_t interface_id, uint32_t valid_life_time, const ui
}
mlme_device_descriptor_t device_desc;
mac_helper_device_description_write(interface, &device_desc, mac_entry->mac64, mac_entry->mac16,0, false);
mac_helper_devicetable_set(&device_desc, interface,mac_entry->index, interface->mac_parameters->mac_default_key_index, new_entry_created);
mac_helper_device_description_write(interface, &device_desc, mac_entry->mac64, mac_entry->mac16, 0, false);
mac_helper_devicetable_set(&device_desc, interface, mac_entry->index, interface->mac_parameters->mac_default_key_index, new_entry_created);
//set key descriptor
if (mac_helper_security_pairwisekey_set(interface, key, eui64, key_desc->key_decriptor_attribute) != 0) {

View File

@ -38,12 +38,13 @@
#define TRACE_GROUP "MRsH"
static void mac_mlme_device_table_confirmation_handle(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation) {
static void mac_mlme_device_table_confirmation_handle(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation)
{
if (confirmation->value_size != sizeof(mlme_device_descriptor_t)) {
return;
}
mlme_device_descriptor_t *descpription = (mlme_device_descriptor_t*)confirmation->value_pointer;
mlme_device_descriptor_t *descpription = (mlme_device_descriptor_t *)confirmation->value_pointer;
tr_debug("Dev stable get confirmation %x", confirmation->status);
@ -71,15 +72,17 @@ static void mac_mlme_device_table_confirmation_handle(protocol_interface_info_en
}
}
static void mac_mlme_frame_counter_confirmation_handle(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation) {
static void mac_mlme_frame_counter_confirmation_handle(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation)
{
if (confirmation->value_size != 4) {
return;
}
uint32_t *temp_ptr = (uint32_t*)confirmation->value_pointer;
uint32_t *temp_ptr = (uint32_t *)confirmation->value_pointer;
info_entry->mac_parameters->security_frame_counter = *temp_ptr;
}
static void mac_mlme_get_confirmation_handler(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation) {
static void mac_mlme_get_confirmation_handler(protocol_interface_info_entry_t *info_entry, mlme_get_conf_t *confirmation)
{
if (!confirmation) {
return;
@ -100,7 +103,7 @@ static void mac_mlme_get_confirmation_handler(protocol_interface_info_entry_t *i
}
}
void mcps_data_confirm_handler( const mac_api_t* api, const mcps_data_conf_t *data )
void mcps_data_confirm_handler(const mac_api_t *api, const mcps_data_conf_t *data)
{
protocol_interface_info_entry_t *info_entry = protocol_stack_interface_info_get_by_id(api->parent_id);
//TODO: create buffer_t and call correct function
@ -108,13 +111,13 @@ void mcps_data_confirm_handler( const mac_api_t* api, const mcps_data_conf_t *da
lowpan_adaptation_interface_tx_confirm(info_entry, data);
}
void mcps_data_indication_handler( const mac_api_t* api, const mcps_data_ind_t *data_ind )
void mcps_data_indication_handler(const mac_api_t *api, const mcps_data_ind_t *data_ind)
{
protocol_interface_info_entry_t *info_entry = protocol_stack_interface_info_get_by_id(api->parent_id);
lowpan_adaptation_interface_data_ind(info_entry, data_ind);
}
void mcps_purge_confirm_handler( const mac_api_t* api, mcps_purge_conf_t *data )
void mcps_purge_confirm_handler(const mac_api_t *api, mcps_purge_conf_t *data)
{
(void)api;
tr_info("MCPS Data Purge confirm status %u, for handle %u", data->status, data->msduHandle);
@ -127,56 +130,56 @@ static void stop_bootstrap_timer(protocol_interface_info_entry_t *info_entry)
}
}
void mlme_confirm_handler( const mac_api_t* api, mlme_primitive id, const void *data )
void mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const void *data)
{
protocol_interface_info_entry_t *info_entry = protocol_stack_interface_info_get_by_id(api->parent_id);
if (!info_entry) {
return;
}
//TODO: create buffer_t and call correct function
switch(id){
case MLME_ASSOCIATE:{
switch (id) {
case MLME_ASSOCIATE: {
//Unsupported
break;
}
case MLME_DISASSOCIATE:{
case MLME_DISASSOCIATE: {
//Unsupported
break;
}
case MLME_GET:{
mlme_get_conf_t *dat = (mlme_get_conf_t*)data;
case MLME_GET: {
mlme_get_conf_t *dat = (mlme_get_conf_t *)data;
mac_mlme_get_confirmation_handler(info_entry, dat);
break;
}
case MLME_GTS:{
case MLME_GTS: {
//Unsupported
break;
}
case MLME_RESET:{
case MLME_RESET: {
// mlme_reset_conf_t *dat = (mlme_reset_conf_t*)data;
break;
}
case MLME_RX_ENABLE:{
case MLME_RX_ENABLE: {
//Unsupported
break;
}
case MLME_SCAN:{
const mlme_scan_conf_t *dat = (mlme_scan_conf_t*)data;
case MLME_SCAN: {
const mlme_scan_conf_t *dat = (mlme_scan_conf_t *)data;
stop_bootstrap_timer(info_entry);
info_entry->scan_cb(api->parent_id, dat);
break;
}
case MLME_SET:{
case MLME_SET: {
// mlme_set_conf_t *dat = (mlme_set_conf_t*)data;
break;
}
case MLME_START:{
case MLME_START: {
// mlme_start_conf_t *dat = (mlme_start_conf_t*)data;
stop_bootstrap_timer(info_entry);
break;
}
case MLME_POLL:{
const mlme_poll_conf_t *dat = (mlme_poll_conf_t*)data;
case MLME_POLL: {
const mlme_poll_conf_t *dat = (mlme_poll_conf_t *)data;
mac_mlme_poll_confirm(info_entry, dat);
break;
}
@ -185,53 +188,53 @@ void mlme_confirm_handler( const mac_api_t* api, mlme_primitive id, const void *
case MLME_COMM_STATUS:
case MLME_SYNC:
case MLME_SYNC_LOSS:
default:{
default: {
tr_error("Invalid state in mlme_confirm_handler(): %d", id);
break;
}
}
}
void mlme_indication_handler( const mac_api_t* api, mlme_primitive id, const void *data )
void mlme_indication_handler(const mac_api_t *api, mlme_primitive id, const void *data)
{
switch(id){
case MLME_ASSOCIATE:{
switch (id) {
case MLME_ASSOCIATE: {
//Unsupported
//mlme_associate_ind_t *dat = (mlme_associate_ind_t*)data;
break;
}
case MLME_DISASSOCIATE:{
case MLME_DISASSOCIATE: {
//Unsupported
//mlme_disassociate_ind_t *dat = (mlme_disassociate_ind_t*)data;
break;
}
case MLME_BEACON_NOTIFY:{
const mlme_beacon_ind_t *dat = (mlme_beacon_ind_t*)data;
case MLME_BEACON_NOTIFY: {
const mlme_beacon_ind_t *dat = (mlme_beacon_ind_t *)data;
protocol_interface_info_entry_t *info_entry = protocol_stack_interface_info_get_by_id(api->parent_id);
if( info_entry && info_entry->beacon_cb ){
if (info_entry && info_entry->beacon_cb) {
info_entry->beacon_cb(api->parent_id, dat);
}
break;
}
case MLME_GTS:{
case MLME_GTS: {
//Unsupported
break;
}
case MLME_ORPHAN:{
case MLME_ORPHAN: {
//Unsupported
break;
}
case MLME_COMM_STATUS:{
mlme_comm_status_t *dat = (mlme_comm_status_t*)data;
case MLME_COMM_STATUS: {
mlme_comm_status_t *dat = (mlme_comm_status_t *)data;
protocol_interface_info_entry_t *info_entry = protocol_stack_interface_info_get_by_id(api->parent_id);
if( info_entry && info_entry->comm_status_ind_cb ){
if (info_entry && info_entry->comm_status_ind_cb) {
info_entry->comm_status_ind_cb(api->parent_id, dat);
}
break;
}
case MLME_SYNC_LOSS:{
mlme_sync_loss_t *dat = (mlme_sync_loss_t*)data;
case MLME_SYNC_LOSS: {
mlme_sync_loss_t *dat = (mlme_sync_loss_t *)data;
protocol_interface_info_entry_t *info_entry = protocol_stack_interface_info_get_by_id(api->parent_id);
if (info_entry) {
if (dat->LossReason == BEACON_LOST) {
@ -248,7 +251,7 @@ void mlme_indication_handler( const mac_api_t* api, mlme_primitive id, const voi
case MLME_START:
case MLME_SYNC:
case MLME_POLL:
default:{
default: {
tr_error("Invalid state in mlme_indication_handler(): %d", id);
break;
}

View File

@ -23,14 +23,14 @@
struct mcps_data_ind_s;
struct mcps_data_conf_t;
void mcps_data_confirm_handler( const mac_api_t* api, const struct mcps_data_conf_s *data );
void mcps_data_confirm_handler(const mac_api_t *api, const struct mcps_data_conf_s *data);
void mcps_data_indication_handler( const mac_api_t* api, const struct mcps_data_ind_s *data );
void mcps_data_indication_handler(const mac_api_t *api, const struct mcps_data_ind_s *data);
void mcps_purge_confirm_handler( const mac_api_t* api, mcps_purge_conf_t *data );
void mcps_purge_confirm_handler(const mac_api_t *api, mcps_purge_conf_t *data);
void mlme_confirm_handler( const mac_api_t* api, mlme_primitive id, const void *data );
void mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const void *data);
void mlme_indication_handler( const mac_api_t* api, mlme_primitive id, const void *data );
void mlme_indication_handler(const mac_api_t *api, mlme_primitive id, const void *data);
#endif // MAC_RESPONSE_HANDLER_H

View File

@ -50,7 +50,7 @@ typedef uint8_t mpx_data_purge_request(const mpx_api_t *api, struct mcps_purge_s
* @param data MCPS-DATA.confirm specific values
* @param user_id MPX user ID
*/
typedef void mpx_data_confirm(const mpx_api_t* api, const struct mcps_data_conf_s *data);
typedef void mpx_data_confirm(const mpx_api_t *api, const struct mcps_data_conf_s *data);
/**
* @brief mpx_data_indication MPX-DATA confirm is called as a response to MPX-DATA request
@ -58,7 +58,7 @@ typedef void mpx_data_confirm(const mpx_api_t* api, const struct mcps_data_conf_
* @param data MCPS-DATA.indication specific values
* @param user_id MPX user ID
*/
typedef void mpx_data_indication(const mpx_api_t* api, const struct mcps_data_ind_s *data);
typedef void mpx_data_indication(const mpx_api_t *api, const struct mcps_data_ind_s *data);
/**
* @brief mpx_header_size_get Function for request MPX user head room size
@ -68,7 +68,7 @@ typedef void mpx_data_indication(const mpx_api_t* api, const struct mcps_data_in
* @return >0 Head room size in bytes
* @return 0 When Unknown User Id
*/
typedef uint16_t mpx_header_size_get(const mpx_api_t * api, uint16_t user_id);
typedef uint16_t mpx_header_size_get(const mpx_api_t *api, uint16_t user_id);
/**
* @brief mpx_data_cb_register MPX-DATA confirm cb register by user
@ -80,16 +80,16 @@ typedef uint16_t mpx_header_size_get(const mpx_api_t * api, uint16_t user_id);
* @return 0 register OK
* @return -1 Unknown User ID
*/
typedef int8_t mpx_data_cb_register(const mpx_api_t* api, mpx_data_confirm *confirm_cb, mpx_data_indication *indication_cb, uint16_t user_id);
typedef int8_t mpx_data_cb_register(const mpx_api_t *api, mpx_data_confirm *confirm_cb, mpx_data_indication *indication_cb, uint16_t user_id);
/**
* \brief Struct mpx_api_s defines functions for MPX user for register call backs and send data.
*/
struct mpx_api_s {
mpx_data_request * mpx_data_request; /**< MPX data request. */
mpx_data_request *mpx_data_request; /**< MPX data request. */
mpx_data_purge_request *mpx_data_purge; /**< MPX data Purge. */
mpx_header_size_get * mpx_headroom_size_get; /**< MPX headroom size get in bytes. */
mpx_data_cb_register * mpx_user_registration; /**< MPX User cb registration must be call before enable to send or RX data*/
mpx_header_size_get *mpx_headroom_size_get; /**< MPX headroom size get in bytes. */
mpx_data_cb_register *mpx_user_registration; /**< MPX User cb registration must be call before enable to send or RX data*/
};

View File

@ -284,7 +284,7 @@ uint8_t icmp_nd_router_prefix_ttl_update(nd_router_t *nd_router_object, protocol
}
if (cur->lifetime != 0xffffffff && cur->lifetime) {
if (cur->lifetime > seconds ) {
if (cur->lifetime > seconds) {
cur->lifetime -= seconds;
} else {
tr_debug("Prefix Expiry");
@ -302,7 +302,7 @@ uint8_t icmp_nd_router_prefix_ttl_update(nd_router_t *nd_router_object, protocol
return 0;
}
static int icmp_nd_slaac_prefix_address_gen(protocol_interface_info_entry_t *cur_interface, uint8_t *prefix,uint8_t prefix_len, uint32_t lifetime,uint32_t preftime , bool borRouterDevice, slaac_src_e slaac_src)
static int icmp_nd_slaac_prefix_address_gen(protocol_interface_info_entry_t *cur_interface, uint8_t *prefix, uint8_t prefix_len, uint32_t lifetime, uint32_t preftime, bool borRouterDevice, slaac_src_e slaac_src)
{
if_address_entry_t *address_entry = NULL;
address_entry = icmpv6_slaac_address_add(cur_interface, prefix, prefix_len, lifetime, preftime, true, slaac_src);
@ -312,7 +312,7 @@ static int icmp_nd_slaac_prefix_address_gen(protocol_interface_info_entry_t *cur
if (borRouterDevice) {
address_entry->state_timer = 0;
} else {
address_entry->state_timer = 45 + randLIB_get_random_in_range( 1, nd_params.timer_random_max);
address_entry->state_timer = 45 + randLIB_get_random_in_range(1, nd_params.timer_random_max);
//Allocate Addres registration state
if (cur_interface->if_6lowpan_dad_process.active == false) {
cur_interface->if_6lowpan_dad_process.count = nd_params.ns_retry_max;
@ -345,7 +345,7 @@ static void lowpan_nd_address_cb(protocol_interface_info_entry_t *interface, if_
switch (reason) {
case ADDR_CALLBACK_DAD_COMPLETE:
if (addr_ipv6_equal(interface->if_6lowpan_dad_process.address,addr->address)) {
if (addr_ipv6_equal(interface->if_6lowpan_dad_process.address, addr->address)) {
tr_info("Address REG OK: %s", trace_ipv6(interface->if_6lowpan_dad_process.address));
interface->if_6lowpan_dad_process.active = false;
interface->global_address_available = true;
@ -355,7 +355,7 @@ static void lowpan_nd_address_cb(protocol_interface_info_entry_t *interface, if_
//Register also GP64 if NET_6LOWPAN_MULTI_GP_ADDRESS mode is enabled
if (interface->lowpan_address_mode == NET_6LOWPAN_MULTI_GP_ADDRESS) {
if (icmp_nd_slaac_prefix_address_gen(interface, addr->address, addr->prefix_len,
addr->valid_lifetime, addr->preferred_lifetime, false, SLAAC_IID_DEFAULT) == 0) {
addr->valid_lifetime, addr->preferred_lifetime, false, SLAAC_IID_DEFAULT) == 0) {
return;
} else {
tr_warning("Secondary Address allocate fail");
@ -431,7 +431,7 @@ static void lowpan_nd_address_cb(protocol_interface_info_entry_t *interface, if_
tr_error("ND cache full--> Black list by given lifetime");
cur = nd_get_object_by_nwk_id(interface->nwk_id);
if (cur) {
pan_blacklist_pan_set(&interface->pan_blaclist_cache,mac_helper_panid_get(interface), cur->life_time);
pan_blacklist_pan_set(&interface->pan_blaclist_cache, mac_helper_panid_get(interface), cur->life_time);
}
break;
@ -447,7 +447,7 @@ static void lowpan_nd_address_cb(protocol_interface_info_entry_t *interface, if_
protocol_6lowpan_allocate_mac16(interface);
interface->if_6lowpan_dad_process.active = false;
if (icmp_nd_slaac_prefix_address_gen(interface, addr->address, addr->prefix_len,
addr->valid_lifetime, addr->preferred_lifetime, false, SLAAC_IID_6LOWPAN_SHORT) == 0) {
addr->valid_lifetime, addr->preferred_lifetime, false, SLAAC_IID_6LOWPAN_SHORT) == 0) {
addr->state_timer = 1;
return;
}
@ -492,7 +492,7 @@ int8_t icmp_nd_router_prefix_update(uint8_t *dptr, nd_router_t *nd_router_object
new_entry->options = pre_setups;
if (new_entry->options & PIO_A) {
if (icmpv6_slaac_prefix_update(cur_interface, new_entry->prefix, new_entry->prefix_len, new_entry->lifetime, new_entry->preftime) != 0) {
icmp_nd_slaac_prefix_address_gen(cur_interface,new_entry->prefix,new_entry->prefix_len, new_entry->lifetime, new_entry->preftime, borRouterDevice, slaac_src);
icmp_nd_slaac_prefix_address_gen(cur_interface, new_entry->prefix, new_entry->prefix_len, new_entry->lifetime, new_entry->preftime, borRouterDevice, slaac_src);
}
}
} else {
@ -515,7 +515,7 @@ void icmp_nd_router_context_ttl_update(nd_router_t *nd_router_object, uint16_t s
{
ns_list_foreach_safe(lowpan_context_t, cur, &nd_router_object->context_list) {
/* We're using seconds in call, but lifetime is in 100ms ticks */
if (cur->lifetime <= (uint32_t)seconds *10) {
if (cur->lifetime <= (uint32_t)seconds * 10) {
/* When lifetime in the ABRO storage runs out, just drop it,
* so we stop advertising it. This is different from the
* interface context handling.
@ -592,9 +592,9 @@ static void icmp_nd_context_parse(buffer_t *buf, nd_router_t *nd_router_object)
if ((len == 16 && ctx_len <= 64) || (len == 24 && ctx_len <= 128)) {
uint8_t c_id = dptr[3] & 0x1f; // ignore reserved fields
uint16_t lifetime_mins = common_read_16_bit(dptr+6);
uint16_t lifetime_mins = common_read_16_bit(dptr + 6);
lowpan_context_update(&nd_router_object->context_list, c_id, lifetime_mins, dptr+8, ctx_len, true);
lowpan_context_update(&nd_router_object->context_list, c_id, lifetime_mins, dptr + 8, ctx_len, true);
} else {
tr_warn("Context len fail");
}
@ -720,8 +720,7 @@ void nd_ns_build(nd_router_t *cur, protocol_interface_info_entry_t *cur_interfac
return;
}
memcpy(router, route->info.next_hop_addr, 16);
}
else
} else
#endif
{
icmp_nd_set_nd_def_router_address(router, cur);
@ -873,8 +872,7 @@ static void nd_update_registration(protocol_interface_info_entry_t *cur_interfac
void nd_remove_registration(protocol_interface_info_entry_t *cur_interface, addrtype_t ll_type, const uint8_t *ll_address)
{
ns_list_foreach_safe(ipv6_neighbour_t, cur, &cur_interface->ipv6_neighbour_cache.list)
{
ns_list_foreach_safe(ipv6_neighbour_t, cur, &cur_interface->ipv6_neighbour_cache.list) {
if ((cur->type == IP_NEIGHBOUR_REGISTERED
|| cur->type == IP_NEIGHBOUR_TENTATIVE)
&& ipv6_neighbour_ll_addr_match(cur, ll_type, ll_address)) {
@ -1094,17 +1092,15 @@ bool nd_ra_process_abro(protocol_interface_info_entry_t *cur, buffer_t *buf, con
dptr += 4;
//If Border Router boot is state
if(cur->border_router_setup)
{
if(memcmp(dptr, cur->border_router_setup->border_router_gp_adr, 16) == 0)
{
if (cur->border_router_setup) {
if (memcmp(dptr, cur->border_router_setup->border_router_gp_adr, 16) == 0) {
if (cur->border_router_setup->initActive) {
//save New Context
if (common_serial_number_greater_32(abro_ver_num, cur->border_router_setup->nd_border_router_configure->abro_version_num)) {
cur->border_router_setup->initActive = false;
cur->border_router_setup->nd_border_router_configure->abro_version_num = (abro_ver_num + 0x00010000);
cur->border_router_setup->nd_nwk->abro_version_num = (abro_ver_num + 0x00010000);
} else if(abro_ver_num == cur->border_router_setup->nd_border_router_configure->abro_version_num) {
} else if (abro_ver_num == cur->border_router_setup->nd_border_router_configure->abro_version_num) {
cur->border_router_setup->initActive = false;
cur->border_router_setup->nd_border_router_configure->abro_version_num = (abro_ver_num + 0x00010000);
@ -1163,8 +1159,7 @@ bool nd_ra_process_abro(protocol_interface_info_entry_t *cur, buffer_t *buf, con
uptodate = true;
//uprouter_info=1;
if(diff_update >= 0x00010000)
{
if (diff_update >= 0x00010000) {
tr_debug("Border Router Boot Trig NS");
router->trig_address_reg = true;
} else {
@ -1258,8 +1253,7 @@ bool nd_ra_process_abro(protocol_interface_info_entry_t *cur, buffer_t *buf, con
}
}
if(uptodate)
{
if (uptodate) {
router->abro_version_num = abro_ver_num;
router->life_time = router_lifetime;
}
@ -1493,7 +1487,7 @@ static uint8_t nd_router_ready_timer(nd_router_t *cur, protocol_interface_info_e
return 0;
}
if (cur->nd_timer > ticks_update ) {
if (cur->nd_timer > ticks_update) {
cur->nd_timer -= ticks_update;
return 0;
}
@ -1531,13 +1525,12 @@ static uint8_t nd_router_ready_timer(nd_router_t *cur, protocol_interface_info_e
cur->nd_state = ND_RS_UNCAST;
set_power_state(ICMP_ACTIVE);
cur->nd_timer = 1;
cur->nd_bootstrap_tick = (nd_base_tick -1);
cur->nd_bootstrap_tick = (nd_base_tick - 1);
if (cur_interface->lowpan_info & INTERFACE_NWK_CONF_MAC_RX_OFF_IDLE) {
mac_data_poll_init_protocol_poll(cur_interface);
}
nd_router_bootstrap_timer(cur,cur_interface,1);
}
else { /* ND_BR_READY */
nd_router_bootstrap_timer(cur, cur_interface, 1);
} else { /* ND_BR_READY */
nd_border_router_setup_refresh(cur->nwk_id, true);
tr_debug("ND BR refresh ABRO");
cur->nd_re_validate = (cur->life_time / 4) * 3;

View File

@ -129,14 +129,14 @@ static void nwk_nvm_params_update_cb(nwk_wpan_nvm_api_t *api, bool if_down_call)
bool push_new_data = false;
if (api->params.mac_security_frame_counter < mac_counter) {
if (mac_counter - api->params.mac_security_frame_counter > COUNTER_NVM_UPDATE_INCREMENT - 50 ) {
if (mac_counter - api->params.mac_security_frame_counter > COUNTER_NVM_UPDATE_INCREMENT - 50) {
push_new_data = true;
api->params.mac_security_frame_counter = mac_counter;
}
}
if (api->params.mle_securit_counter < mlme_counter) {
if (mlme_counter - api->params.mle_securit_counter > COUNTER_NVM_UPDATE_INCREMENT - 50 ) {
if (mlme_counter - api->params.mle_securit_counter > COUNTER_NVM_UPDATE_INCREMENT - 50) {
push_new_data = true;
api->params.mle_securit_counter = mlme_counter;
}

View File

@ -88,10 +88,10 @@ typedef struct {
int8_t br_service_id;
int8_t backbone_interface_id;
int8_t udp_proxy_socket; /* socket to relay messages between BA and nodes */
bool br_info_published:1;
bool br_hosted:1;
bool routing_enabled:1;
bool commissioner_connected:1;
bool br_info_published: 1;
bool br_hosted: 1;
bool routing_enabled: 1;
bool commissioner_connected: 1;
ns_list_link_t link;
} thread_bbr_t;
@ -173,8 +173,8 @@ static int thread_border_router_relay_transmit_cb(int8_t service_id, uint8_t sou
return -1;
}
;
if ( thread_management_get_ml_prefix_112(this->interface_id,destination_address) != 0 ||
2 > thread_meshcop_tlv_data_get_uint16(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_JOINER_ROUTER_LOCATOR,&shortAddress)) {
if (thread_management_get_ml_prefix_112(this->interface_id, destination_address) != 0 ||
2 > thread_meshcop_tlv_data_get_uint16(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_JOINER_ROUTER_LOCATOR, &shortAddress)) {
tr_warn("No joiner router address");
return -1;
}
@ -182,7 +182,7 @@ static int thread_border_router_relay_transmit_cb(int8_t service_id, uint8_t sou
common_write_16_bit(shortAddress, &destination_address[14]);
coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, destination_address, THREAD_MANAGEMENT_PORT,
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_RELAY_TRANSMIT, COAP_CT_OCTET_STREAM, request_ptr->payload_ptr, request_ptr->payload_len, NULL);
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_RELAY_TRANSMIT, COAP_CT_OCTET_STREAM, request_ptr->payload_ptr, request_ptr->payload_len, NULL);
return -1;
}
@ -194,13 +194,13 @@ static int br_commissioner_security_start_cb(int8_t service_id, uint8_t address[
tr_info("brCommissionerDtlsSessionStarted");
thread_bbr_t *this = thread_border_router_find_by_service(service_id);
if(this){
if (this) {
link_configuration_s *linkConfiguration = thread_joiner_application_get_config(this->interface_id);
if( linkConfiguration ){
memcpy(pw, linkConfiguration->PSKc, 16 );
if (linkConfiguration) {
memcpy(pw, linkConfiguration->PSKc, 16);
*pw_len = 16;
ret = 0;
}else{
} else {
*pw_len = 0;
}
// ret = coap_service_security_key_set( service_id, address, port, this->PSKc_ptr, this->PSKc_len );
@ -224,8 +224,9 @@ static int thread_border_router_relay_receive_cb(int8_t service_id, uint8_t sour
(void) source_port;
tr_debug("border router relay receive");
thci_trace("brCommissionerDataRelayedOutbound");
if (!this)
if (!this) {
return -1;
}
coap_service_request_send(this->br_service_id, COAP_REQUEST_OPTIONS_NONE, this->commissioner_address, this->commissioner_port,
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_RELAY_RECEIVE, COAP_CT_OCTET_STREAM, request_ptr->payload_ptr, request_ptr->payload_len, NULL);
@ -248,7 +249,7 @@ static int thread_border_router_leader_petition_resp_cb(int8_t service_id, uint8
return -1;
}
thci_trace("BR recv petition Resp data: %s",trace_array(response_ptr->payload_ptr, response_ptr->payload_len));
thci_trace("BR recv petition Resp data: %s", trace_array(response_ptr->payload_ptr, response_ptr->payload_len));
//tr_debug("border router leader response");
if (!this) {
tr_warn("commissioner service missing!");
@ -257,7 +258,7 @@ static int thread_border_router_leader_petition_resp_cb(int8_t service_id, uint8
if (1 <= thread_meshcop_tlv_find(response_ptr->payload_ptr, response_ptr->payload_len, MESHCOP_TLV_STATE, &ptr) && *ptr == 1) {
// commissioning petition successfull
if(this->commissioner_connected == false) {
if (this->commissioner_connected == false) {
tr_debug("enabling native commissioner");
coap_service_register_uri(this->coap_service_id, THREAD_URI_RELAY_RECEIVE, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_border_router_relay_receive_cb);
@ -270,7 +271,7 @@ static int thread_border_router_leader_petition_resp_cb(int8_t service_id, uint8
coap_service_response_send_by_msg_id(this->br_service_id, COAP_REQUEST_OPTIONS_SECURE_BYPASS, this->commissioner_pet_request_msg_id, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, response_ptr->payload_ptr, response_ptr->payload_len);
this->commissioner_pet_request_msg_id = 0;
if(!this->commissioner_connected){
if (!this->commissioner_connected) {
// Commissioner rejected by leader
thread_border_router_commissioner_info_clear(this);
}
@ -288,7 +289,7 @@ static int thread_border_router_leader_message_resp_cb(int8_t service_id, uint8_
return -1;
}
thci_trace("BR recv Resp data: %s",trace_array(response_ptr->payload_ptr, response_ptr->payload_len));
thci_trace("BR recv Resp data: %s", trace_array(response_ptr->payload_ptr, response_ptr->payload_len));
coap_service_response_send_by_msg_id(this->br_service_id, COAP_REQUEST_OPTIONS_SECURE_BYPASS, this->commissioner_pet_request_msg_id, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, response_ptr->payload_ptr, response_ptr->payload_len);
this->commissioner_pet_request_msg_id = 0;
@ -389,7 +390,7 @@ static void thread_border_router_udp_proxy_tmf_message_receive(int8_t socket_id,
return;
}
payload_len = (2 + 2 + 2 + 2 + tmf_data_len) + (2 + THREAD_IPV6_ADDRESS_TLV_LENGTH);
payload_len = (2 + 2 + 2 + 2 + tmf_data_len) + (2 + THREAD_IPV6_ADDRESS_TLV_LENGTH);
payload_ptr = ptr = ns_dyn_mem_alloc(payload_len);
if (!payload_ptr) {
@ -411,7 +412,7 @@ static void thread_border_router_udp_proxy_tmf_message_receive(int8_t socket_id,
tr_debug("send to: %s, port=%d", trace_ipv6(this->commissioner_address), this->commissioner_port);
tr_debug("UDP_RX.ntf: %s", trace_array(payload_ptr, payload_len));
coap_service_request_send(this->br_service_id, COAP_REQUEST_OPTIONS_NONE, this->commissioner_address, this->commissioner_port,
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_UDP_RECVEIVE_NOTIFICATION, COAP_CT_OCTET_STREAM, payload_ptr, payload_len, NULL);
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_UDP_RECVEIVE_NOTIFICATION, COAP_CT_OCTET_STREAM, payload_ptr, payload_len, NULL);
ns_dyn_mem_free(payload_ptr);
@ -462,19 +463,19 @@ static int thread_border_petition_to_leader_cb(int8_t service_id, uint8_t source
}
if (strncmp(THREAD_URI_COMMISSIONER_PETITION, (const char *)request_ptr->uri_path_ptr, request_ptr->uri_path_len) == 0) {
uri_ptr = THREAD_URI_LEADER_PETITION;
} else if (strncmp(THREAD_URI_COMMISSIONER_KEEP_ALIVE,(const char *)request_ptr->uri_path_ptr,request_ptr->uri_path_len) == 0) {
} else if (strncmp(THREAD_URI_COMMISSIONER_KEEP_ALIVE, (const char *)request_ptr->uri_path_ptr, request_ptr->uri_path_len) == 0) {
uri_ptr = THREAD_URI_LEADER_KEEP_ALIVE;
} else {
return -1;
}
// Update commissioner timeout for deleting the commissioner session if there is no messages.
this->commissioner_timer = THREAD_COMMISSIONER_KEEP_ALIVE_INTERVAL/1000 + 10;
this->commissioner_timer = THREAD_COMMISSIONER_KEEP_ALIVE_INTERVAL / 1000 + 10;
//TODO simple relaying is enough
memcpy(this->commissioner_address, source_address, 16);
this->commissioner_port = source_port;
this->commissioner_pet_request_msg_id = request_ptr->msg_id;//TODO one message at a time causes problems
thci_trace("BR recv uri:%.*s data: %s",request_ptr->uri_path_len,request_ptr->uri_path_ptr,trace_array(request_ptr->payload_ptr, request_ptr->payload_len));
thci_trace("BR recv uri:%.*s data: %s", request_ptr->uri_path_len, request_ptr->uri_path_ptr, trace_array(request_ptr->payload_ptr, request_ptr->payload_len));
//tr_debug("relay data %s",trace_array(request_ptr->payload_ptr, request_ptr->payload_len));
coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, destination_address, THREAD_MANAGEMENT_PORT,
@ -498,16 +499,16 @@ static int thread_border_relay_to_leader_cb(int8_t service_id, uint8_t source_ad
return -1;
}
//buffer length is limited to 10 characters
memset(uri_ptr,0,10);
memcpy(uri_ptr,(const char *)request_ptr->uri_path_ptr,request_ptr->uri_path_len);
memset(uri_ptr, 0, 10);
memcpy(uri_ptr, (const char *)request_ptr->uri_path_ptr, request_ptr->uri_path_len);
// Update commissioner timeout for deleting the commissioner session if there is no messages.
this->commissioner_timer = THREAD_COMMISSIONER_KEEP_ALIVE_INTERVAL/1000 + 10;
this->commissioner_timer = THREAD_COMMISSIONER_KEEP_ALIVE_INTERVAL / 1000 + 10;
//TODO simple relaying is enough
memcpy(this->commissioner_address, source_address, 16);
this->commissioner_port = source_port;
this->commissioner_pet_request_msg_id = request_ptr->msg_id;//TODO one message at a time causes problems
thci_trace("BR recv uri:%.*s data: %s",request_ptr->uri_path_len,request_ptr->uri_path_ptr,trace_array(request_ptr->payload_ptr, request_ptr->payload_len));
thci_trace("BR recv uri:%.*s data: %s", request_ptr->uri_path_len, request_ptr->uri_path_ptr, trace_array(request_ptr->payload_ptr, request_ptr->payload_len));
coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, destination_address, THREAD_MANAGEMENT_PORT,
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, uri_ptr, COAP_CT_OCTET_STREAM, request_ptr->payload_ptr, request_ptr->payload_len, thread_border_router_leader_message_resp_cb);
@ -535,7 +536,7 @@ static bool thread_bbr_i_host_prefix(struct protocol_interface_info_entry *cur,
ns_list_foreach(thread_network_data_prefix_cache_entry_t, prefix, &cur->thread_info->networkDataStorage.localPrefixList) {
if (prefix->servicesPrefixLen != 64 ||
memcmp(prefix_ptr, prefix->servicesPrefix, 8) != 0) {
memcmp(prefix_ptr, prefix->servicesPrefix, 8) != 0) {
continue;
}
@ -568,8 +569,8 @@ static void thread_bbr_network_data_remove(thread_bbr_t *this)
{
tr_info("br: remove default route from network");
thread_border_router_prefix_delete(this->interface_id, this->bbr_prefix, 64);
DHCPv6_server_service_delete(this->interface_id,this->bbr_prefix,true);
memset(this->bbr_prefix,0,8);
DHCPv6_server_service_delete(this->interface_id, this->bbr_prefix, true);
memset(this->bbr_prefix, 0, 8);
this->br_info_published = false;
}
@ -580,7 +581,7 @@ static void thread_bbr_network_data_send(thread_bbr_t *this, uint8_t prefix[8],
tr_info("br: publish default route to network");
// delete old prefix
memset(this->bbr_prefix,0,8);
memset(this->bbr_prefix, 0, 8);
// create new prefix
if (thread_dhcp6_server_init(this->interface_id, prefix, eui64, THREAD_MIN_PREFIX_LIFETIME) != 0) {
tr_warn("DHCP server alloc fail");
@ -588,7 +589,7 @@ static void thread_bbr_network_data_send(thread_bbr_t *this, uint8_t prefix[8],
this->br_delay_timer = 20;
return;
}
memcpy(this->bbr_prefix,prefix,8);
memcpy(this->bbr_prefix, prefix, 8);
br_info.P_default_route = true;
br_info.P_dhcp = true;
@ -641,8 +642,8 @@ static void thread_bbr_status_check(thread_bbr_t *this, uint32_t seconds)
bbr_prefix_ptr = global_address;
}
if ( this->br_info_published &&
(!bbr_prefix_ptr || memcmp(this->bbr_prefix,bbr_prefix_ptr,8) != 0)) {
if (this->br_info_published &&
(!bbr_prefix_ptr || memcmp(this->bbr_prefix, bbr_prefix_ptr, 8) != 0)) {
// Address is changed or address removed
// remove the old prefix and read the status of the new prefix
tr_info("br: Address changed or not valid stop routing");
@ -652,7 +653,7 @@ static void thread_bbr_status_check(thread_bbr_t *this, uint32_t seconds)
}
// Check if network data as border router is possible or modified
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(this->interface_id);
this->br_hosted = thread_bbr_i_host_prefix(cur, bbr_prefix_ptr,&this->br_count, &br_lowest_host);
this->br_hosted = thread_bbr_i_host_prefix(cur, bbr_prefix_ptr, &this->br_count, &br_lowest_host);
if (!this->br_info_published && bbr_prefix_ptr && this->br_count == 0) {
// publish global route either no border routers or our info has changed
@ -690,14 +691,14 @@ static void thread_bbr_status_check(thread_bbr_t *this, uint32_t seconds)
// Race condition More border routers than there should trigger random delay to remove BR
// our implementation prefers lowest RLOC to to stay to reduce problem time
if (br_lowest_host) {
this->br_delete_timer = randLIB_get_random_in_range(20,60);
this->br_delete_timer = randLIB_get_random_in_range(20, 60);
} else {
this->br_delete_timer = randLIB_get_random_in_range(5,10);
this->br_delete_timer = randLIB_get_random_in_range(5, 10);
}
tr_info("br: too many BRs start remove jitter:%"PRIu32, this->br_delete_timer);
return;
}
if (this->br_info_published && !bbr_prefix_ptr ) {
if (this->br_info_published && !bbr_prefix_ptr) {
// Need to disable ND proxy will give a 20 second delay for it We could also disable routing immediately
this->br_delete_timer = 20;
tr_info("br: can not be border router need to remove after: %"PRIu32, this->br_delete_timer);
@ -729,7 +730,7 @@ static bool thread_bbr_activated(thread_bbr_t *this, uint32_t seconds)
// Router id reguest pending we need to wait for response
return false;
}
if(this->router_upgrade_delay_timer) {
if (this->router_upgrade_delay_timer) {
if (this->router_upgrade_delay_timer > seconds) {
this->router_upgrade_delay_timer -= seconds;
} else {
@ -804,7 +805,7 @@ int thread_bbr_commissioner_proxy_service_update(int8_t interface_id)
// Set source parameters, if commissioner is available
ret_val = thread_management_get_commissioner_address(this->interface_id, &ns_source_addr.address[0], 0);
if ( ret_val < 0) {
if (ret_val < 0) {
tr_error("Failed to get commissioner ALOC %d", ret_val);
ret_val = -1;
goto return_fail;
@ -822,9 +823,9 @@ int thread_bbr_commissioner_proxy_service_update(int8_t interface_id)
return 0;
return_fail:
thread_bbr_udp_proxy_service_stop(interface_id);
return ret_val;
return_fail:
thread_bbr_udp_proxy_service_stop(interface_id);
return ret_val;
}
int8_t thread_bbr_init(int8_t interface_id, uint16_t external_commisssioner_port)
{
@ -852,7 +853,7 @@ int8_t thread_bbr_init(int8_t interface_id, uint16_t external_commisssioner_port
this->br_info_published = false;
this->routing_enabled = false;
memset(this->bbr_prefix,0,8);
memset(this->bbr_prefix, 0, 8);
this->joiner_router_rloc = 0xffff;
this->coap_service_id = coap_service_initialize(this->interface_id, THREAD_MANAGEMENT_PORT, COAP_SERVICE_OPTIONS_NONE, NULL, NULL);
if (this->coap_service_id < 0) {
@ -929,9 +930,9 @@ void thread_bbr_seconds_timer(int8_t interface_id, uint32_t seconds)
#ifdef HAVE_THREAD_BORDER_ROUTER
// check if Border router can be active
if (thread_bbr_activated(this,seconds)) {
if (thread_bbr_activated(this, seconds)) {
// Run the BBR SM
thread_bbr_status_check(this,seconds);
thread_bbr_status_check(this, seconds);
}
if (!thread_extension_version_check(thread_version)) {
@ -957,7 +958,7 @@ int thread_bbr_na_send(int8_t interface_id, const uint8_t target[static 16])
}
int thread_bbr_nd_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr, uint32_t lifetime, void *info)
int thread_bbr_nd_entry_add(int8_t interface_id, const uint8_t *addr_data_ptr, uint32_t lifetime, void *info)
{
thread_bbr_t *this = thread_bbr_find_by_interface(interface_id);
if (!this || this->backbone_interface_id < 0) {
@ -976,7 +977,7 @@ int thread_bbr_nd_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
return 0;
}
int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr, uint32_t lifetime, const uint8_t *mleid_ptr)
int thread_bbr_dua_entry_add(int8_t interface_id, const uint8_t *addr_data_ptr, uint32_t lifetime, const uint8_t *mleid_ptr)
{
thread_bbr_t *this = thread_bbr_find_by_interface(interface_id);
thread_pbbr_dua_info_t *map;
@ -984,7 +985,7 @@ int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
return -1;
}
ipv6_route_t *route = ipv6_route_lookup_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, NULL, 0);
if (!route){
if (!route) {
map = ns_dyn_mem_alloc(sizeof(thread_pbbr_dua_info_t));
if (!map) {
goto error;
@ -1013,7 +1014,7 @@ error:
return -2;
}
int thread_bbr_proxy_state_update(int8_t caller_interface_id , int8_t handler_interface_id, bool status)
int thread_bbr_proxy_state_update(int8_t caller_interface_id, int8_t handler_interface_id, bool status)
{
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(handler_interface_id);
(void) caller_interface_id;
@ -1073,11 +1074,11 @@ int thread_bbr_start(int8_t interface_id, int8_t backbone_interface_id)
char service_name[30] = {0};
char *ptr;
if(!this || !link_configuration_ptr || backbone_interface_id < 0) {
if (!this || !link_configuration_ptr || backbone_interface_id < 0) {
return -1;
}
tr_info("Thread BBR start if:%d, bb_if:%d",interface_id, backbone_interface_id);
tr_info("Thread BBR start if:%d, bb_if:%d", interface_id, backbone_interface_id);
this->backbone_interface_id = backbone_interface_id;
ptr = service_name;
@ -1085,9 +1086,9 @@ int thread_bbr_start(int8_t interface_id, int8_t backbone_interface_id)
*ptr++ = 'a' + extended_random_mac[1] % 26;
*ptr++ = 'a' + extended_random_mac[2] % 26;
*ptr++ = 'a' + extended_random_mac[3] % 26;
memcpy(ptr,"-ARM-",5);
memcpy(ptr, "-ARM-", 5);
ptr += 5;
memcpy(ptr,link_configuration_ptr->name,16);
memcpy(ptr, link_configuration_ptr->name, 16);
// Start mdns service
thread_mdns_start(this->interface_id, this->backbone_interface_id, service_name);
@ -1100,7 +1101,7 @@ int thread_bbr_start(int8_t interface_id, int8_t backbone_interface_id)
// Adjust BBR neighbor and destination cache size
arm_nwk_ipv6_max_cache_entries(THREAD_BBR_IPV6_DESTINATION_CACHE_SIZE);
thread_extension_bbr_init(interface_id,backbone_interface_id);
thread_extension_bbr_init(interface_id, backbone_interface_id);
return 0;
#else
@ -1116,7 +1117,7 @@ int thread_bbr_timeout_set(int8_t interface_id, uint32_t timeout_a, uint32_t tim
(void) delay;
#ifdef HAVE_THREAD_BORDER_ROUTER
thread_extension_bbr_timeout_set(interface_id, timeout_a, timeout_b, delay);
return 0;
return 0;
#else
return -1;
#endif // HAVE_THREAD_BORDER_ROUTER
@ -1165,7 +1166,7 @@ void thread_bbr_stop(int8_t interface_id)
thread_bbr_t *this = thread_bbr_find_by_interface(interface_id);
if(!this) {
if (!this) {
return;
}
thread_extension_bbr_delete(interface_id);

View File

@ -80,7 +80,7 @@ int thread_bbr_commissioner_proxy_service_update(int8_t interface_id);
*
* \param interface_id current interface id
*/
int thread_bbr_proxy_state_update(int8_t caller_interface_id , int8_t handler_interface_id, bool status);
int thread_bbr_proxy_state_update(int8_t caller_interface_id, int8_t handler_interface_id, bool status);
/**
* \brief Test if border router routing is enabled
@ -108,7 +108,7 @@ int thread_bbr_nd_entry_add(int8_t interface_id, const uint8_t *addr_data_ptr, u
*
* \param interface_id addr_data_ptr lifetime info mleid_ptr
*/
int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr, uint32_t lifetime, const uint8_t *mleid_ptr);
int thread_bbr_dua_entry_add(int8_t interface_id, const uint8_t *addr_data_ptr, uint32_t lifetime, const uint8_t *mleid_ptr);
/**
* \brief Send na

View File

@ -45,26 +45,26 @@
#define tr_deep(...)
#endif
uint8_t *thread_beacon_calculate_bloom_filter(uint8_t *bloom_filter_ptr,uint8_t bloom_filter_length, uint8_t *joiner_id_ptr, int joiner_id_length)
uint8_t *thread_beacon_calculate_bloom_filter(uint8_t *bloom_filter_ptr, uint8_t bloom_filter_length, uint8_t *joiner_id_ptr, int joiner_id_length)
{
uint8_t bloom_filter_bit_length = bloom_filter_length * 8;
uint8_t bloom_filter_bit_length = bloom_filter_length * 8;
//Find the CRCCCITT and CRCANSI of joiner_id
uint16_t crc_ccitt = crc16_ccitt(joiner_id_ptr, joiner_id_length);
uint16_t crc_ansi = crc16_ansi(joiner_id_ptr, joiner_id_length);
// byte location is calculated from left
uint8_t byte_location_hash1 = (bloom_filter_length - ((crc_ccitt % bloom_filter_bit_length) / 8) - 1);
//Find the CRCCCITT and CRCANSI of joiner_id
uint16_t crc_ccitt = crc16_ccitt(joiner_id_ptr, joiner_id_length);
uint16_t crc_ansi = crc16_ansi(joiner_id_ptr, joiner_id_length);
// byte location is calculated from left
uint8_t byte_location_hash1 = (bloom_filter_length - ((crc_ccitt % bloom_filter_bit_length) / 8) - 1);
// bit location is calculated from right within a byte
uint8_t bit_location_hash1 = ((crc_ccitt % bloom_filter_bit_length) % 8);
uint8_t bit_hash_1 = 1 << bit_location_hash1;
// bit location is calculated from right within a byte
uint8_t bit_location_hash1 = ((crc_ccitt % bloom_filter_bit_length) % 8);
uint8_t bit_hash_1 = 1 << bit_location_hash1;
uint8_t byte_location_hash2 = (bloom_filter_length - ((crc_ansi % bloom_filter_bit_length) / 8) - 1);
uint8_t bit_location_hash2 = ((crc_ansi % bloom_filter_bit_length) % 8);
uint8_t bit_hash_2 = 1 << bit_location_hash2;
uint8_t byte_location_hash2 = (bloom_filter_length - ((crc_ansi % bloom_filter_bit_length) / 8) - 1);
uint8_t bit_location_hash2 = ((crc_ansi % bloom_filter_bit_length) % 8);
uint8_t bit_hash_2 = 1 << bit_location_hash2;
bloom_filter_ptr[byte_location_hash1] = bloom_filter_ptr[byte_location_hash1] | bit_hash_1;
bloom_filter_ptr[byte_location_hash2] = bloom_filter_ptr[byte_location_hash2] | bit_hash_2;
bloom_filter_ptr[byte_location_hash1] = bloom_filter_ptr[byte_location_hash1] | bit_hash_1;
bloom_filter_ptr[byte_location_hash2] = bloom_filter_ptr[byte_location_hash2] | bit_hash_2;
return bloom_filter_ptr;
}

View File

@ -50,11 +50,11 @@
#define THREAD_BEACON_NATIVE_COMMISSIONER_BIT 0x08
/** Calculate bloom filter
* @param bloom_filter_ptr Pointer to array with bloom filter
* @param bloom_filter_ptr Pointer to array with bloom filter
* @param bloom_filter_length Bloom filter length
* @param joiner_id_ptr Joiner ID array
* @param joiner_id_length Joiner ID array length
*/
uint8_t *thread_beacon_calculate_bloom_filter(uint8_t *bloom_filter_ptr,uint8_t bloom_filter_length, uint8_t *joiner_id_ptr, int joiner_id_length);
uint8_t *thread_beacon_calculate_bloom_filter(uint8_t *bloom_filter_ptr, uint8_t bloom_filter_length, uint8_t *joiner_id_ptr, int joiner_id_length);
#endif /* THREAD_BEACON_LIB_H_ */

View File

@ -180,9 +180,9 @@ int8_t thread_mle_class_init(int8_t interface_id)
return -1;
}
if (!mac_neighbor_info(cur) ) {
if (!mac_neighbor_info(cur)) {
mac_neighbor_info(cur) = mac_neighbor_table_create(buffer.device_decription_table_size - 1, thread_neighbor_remove
, thread_neighbor_entry_nud_notify, cur);
, thread_neighbor_entry_nud_notify, cur);
if (!mac_neighbor_info(cur)) {
return -1;
}
@ -276,8 +276,8 @@ uint8_t thread_calculate_link_margin(int8_t dbm, uint8_t compLinkMarginFromParen
bool thread_check_is_this_my_parent(protocol_interface_info_entry_t *cur, mac_neighbor_table_entry_t *entry_temp)
{
if (entry_temp && thread_info(cur)->thread_endnode_parent) {
if(memcmp(entry_temp->mac64, thread_info(cur)->thread_endnode_parent->mac64, 8) == 0) {
return true;
if (memcmp(entry_temp->mac64, thread_info(cur)->thread_endnode_parent->mac64, 8) == 0) {
return true;
}
}
return false;
@ -296,8 +296,7 @@ bool thread_bootstrap_request_network_data(protocol_interface_info_entry_t *cur,
tr_debug("Learn new Network Data");
requestNetworkdata = true;
thread_partition_info_update(cur, leaderData);
}
else if (common_serial_number_greater_8(leaderData->dataVersion, leaderInfo->dataVersion)) {
} else if (common_serial_number_greater_8(leaderData->dataVersion, leaderInfo->dataVersion)) {
requestNetworkdata = true;
} else if (common_serial_number_greater_8(leaderData->stableDataVersion, leaderInfo->stableDataVersion)) {
@ -318,12 +317,11 @@ static int thread_router_check_previous_partition_info(protocol_interface_info_e
return -1;
}
if ((leaderData->partitionId == cur->thread_info->previous_partition_info.partitionId) &&
(leaderData->weighting == cur->thread_info->previous_partition_info.weighting) &&
(routeTlv->dataPtr[0] == cur->thread_info->previous_partition_info.idSequence)) {
(leaderData->weighting == cur->thread_info->previous_partition_info.weighting) &&
(routeTlv->dataPtr[0] == cur->thread_info->previous_partition_info.idSequence)) {
//drop the advertisement from previuos partition
return 1;
}
else {
} else {
//do not drop the advertisement
return 0;
}
@ -357,9 +355,9 @@ int thread_bootstrap_partition_process(protocol_interface_info_entry_t *cur, uin
/*Rule 0: If we are going to form Higher partition than heard we dont try to attach to lower ones
*/
if (thread_extension_enabled(cur) &&
thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_ROUTER) {
thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_ROUTER) {
if (heard_partition_leader_data->weighting < thread_info(cur)->partition_weighting) {
tr_debug("Heard a lower weight partition");
tr_debug("Heard a lower weight partition");
return -2;
}
if (heard_partition_leader_data->weighting > thread_info(cur)->partition_weighting) {
@ -396,7 +394,7 @@ int thread_bootstrap_partition_process(protocol_interface_info_entry_t *cur, uin
/*Rule 3: When comparing two singleton or two non-singleton Thread Network Partitions that have the same 8-bit weight value,
* the one with the higher Partition ID, considered as unsigned 32-bit numbers, has higher priority.
*/
if (heard_partition_leader_data->partitionId > current_leader_data->partitionId){
if (heard_partition_leader_data->partitionId > current_leader_data->partitionId) {
tr_debug("Heard a greater partition id");
return 2;
}
@ -416,18 +414,18 @@ int thread_leader_data_validation(protocol_interface_info_entry_t *cur, thread_l
if (!thread_partition_match(cur, leaderData)) {
uint8_t routers_in_route_tlv = thread_get_router_count_from_route_tlv(routeTlv);
//partition checks
return thread_bootstrap_partition_process(cur,routers_in_route_tlv,leaderData, routeTlv);
return thread_bootstrap_partition_process(cur, routers_in_route_tlv, leaderData, routeTlv);
}
//Should check is there new version numbers
if (common_serial_number_greater_8(leaderData->dataVersion, thread_info(cur)->thread_leader_data->dataVersion) ||
common_serial_number_greater_8(leaderData->stableDataVersion, thread_info(cur)->thread_leader_data->stableDataVersion)) {
common_serial_number_greater_8(leaderData->stableDataVersion, thread_info(cur)->thread_leader_data->stableDataVersion)) {
// Version number increased by some-one else -> there is leader in the network
if (thread_info(cur)->leader_private_data) {
tr_error("Another leader detected -> bootstrap");
thread_bootstrap_reset_restart(cur->id);
return -1;
}
}
tr_debug("NEW Network Data available");
return 1;
}
@ -435,14 +433,14 @@ int thread_leader_data_validation(protocol_interface_info_entry_t *cur, thread_l
return 0;
}
void thread_bootstrap_all_nodes_address_generate(uint8_t multicast_address[16],uint8_t prefix[8], uint8_t scope)
void thread_bootstrap_all_nodes_address_generate(uint8_t multicast_address[16], uint8_t prefix[8], uint8_t scope)
{
memset(multicast_address, 0, 16);
multicast_address[0] = 0xff;
multicast_address[1] = 0x30 | scope; //Thread specification says p and t bits are 1
multicast_address[2] = 0x00; //Reserved
multicast_address[3] = 0x40; //Prefix length 64 bits
memcpy(&multicast_address[4], prefix,8);
memcpy(&multicast_address[4], prefix, 8);
multicast_address[15] = 1;
}
@ -463,13 +461,13 @@ void thread_bootstrap_all_nodes_multicast_register(protocol_interface_info_entry
}
// Register to link local all thread nodes multicast
thread_bootstrap_all_nodes_address_generate(multicast_address,cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_LINK_LOCAL);
tr_debug("Register multicast address: %s",trace_ipv6(multicast_address));
thread_bootstrap_all_nodes_address_generate(multicast_address, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_LINK_LOCAL);
tr_debug("Register multicast address: %s", trace_ipv6(multicast_address));
addr_add_group(cur, multicast_address);
// Register to mesh local all thread nodes multicast
thread_bootstrap_all_nodes_address_generate(multicast_address,cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_REALM_LOCAL);
tr_debug("Register multicast address: %s",trace_ipv6(multicast_address));
thread_bootstrap_all_nodes_address_generate(multicast_address, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_REALM_LOCAL);
tr_debug("Register multicast address: %s", trace_ipv6(multicast_address));
addr_add_group(cur, multicast_address);
}
@ -483,13 +481,13 @@ void thread_bootstrap_all_nodes_multicast_unregister(protocol_interface_info_ent
}
// Unregister to link local all thread nodes multicast
thread_bootstrap_all_nodes_address_generate(multicast_address, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 2);
tr_debug("Free multicast address: %s",trace_ipv6(multicast_address));
tr_debug("Free multicast address: %s", trace_ipv6(multicast_address));
//multicast_free_address(multicast_address);
addr_remove_group(cur, multicast_address);
// Unregister to mesh local all thread nodes multicast
thread_bootstrap_all_nodes_address_generate(multicast_address, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 3);
tr_debug("Free multicast address: %s",trace_ipv6(multicast_address));
tr_debug("Free multicast address: %s", trace_ipv6(multicast_address));
//multicast_free_address(multicast_address);
addr_remove_group(cur, multicast_address);
}
@ -546,7 +544,7 @@ int8_t nwk_thread_host_control(protocol_interface_info_entry_t *cur, net_host_mo
void thread_set_link_local_address(protocol_interface_info_entry_t *cur)
{
ns_list_foreach_safe(if_address_entry_t, addr, &cur->ip_addresses) {
if(memcmp(addr->address, ADDR_LINK_LOCAL_PREFIX,8) == 0) {
if (memcmp(addr->address, ADDR_LINK_LOCAL_PREFIX, 8) == 0) {
tr_debug("deleting address %s", trace_ipv6(addr->address));
ns_list_remove(&cur->ip_addresses, addr);
ns_dyn_mem_free(addr);
@ -577,9 +575,9 @@ static int thread_configuration_security_activate(protocol_interface_info_entry_
// Update the guard timer value
thread_key_guard_timer_calculate(cur, linkConfiguration, true);
//Define KEY's
thread_security_prev_key_generate(cur,linkConfiguration->master_key,linkConfiguration->key_sequence);
thread_security_key_generate(cur,linkConfiguration->master_key,linkConfiguration->key_sequence);
thread_security_next_key_generate(cur,linkConfiguration->master_key,linkConfiguration->key_sequence);
thread_security_prev_key_generate(cur, linkConfiguration->master_key, linkConfiguration->key_sequence);
thread_security_key_generate(cur, linkConfiguration->master_key, linkConfiguration->key_sequence);
thread_security_next_key_generate(cur, linkConfiguration->master_key, linkConfiguration->key_sequence);
return 0;
}
@ -600,11 +598,11 @@ void thread_bootstrap_mac_activate(protocol_interface_info_entry_t *cur, uint16_
thread_discovery_responser_enable(cur->id, coordinator);
if (cur->mac_api) {
cur->mac_api->mlme_req(cur->mac_api, MLME_START, (void*)&start_req);
cur->mac_api->mlme_req(cur->mac_api, MLME_START, (void *)&start_req);
}
}
int thread_configuration_mac_activate(protocol_interface_info_entry_t *cur, uint16_t channel, uint16_t panid,uint8_t *extended_random_mac)
int thread_configuration_mac_activate(protocol_interface_info_entry_t *cur, uint16_t channel, uint16_t panid, uint8_t *extended_random_mac)
{
ipv6_neighbour_cache_flush(&cur->ipv6_neighbour_cache);
mac_helper_mac64_set(cur, extended_random_mac);
@ -621,7 +619,7 @@ int thread_configuration_mac_activate(protocol_interface_info_entry_t *cur, uint
return 0;
}
int thread_configuration_6lowpan_activate(protocol_interface_info_entry_t *cur )
int thread_configuration_6lowpan_activate(protocol_interface_info_entry_t *cur)
{
tr_debug("6lowpan configure");
cur->lowpan_info &= ~INTERFACE_NWK_BOOTSRAP_PANA_AUTHENTICATION;
@ -635,8 +633,8 @@ static void thread_bootstrap_ml_address_update(protocol_interface_info_entry_t *
uint8_t address[16];
if (cur->thread_info->threadPrivatePrefixInfo.ulaValid &&
memcmp(cur->thread_info->threadPrivatePrefixInfo.ulaPrefix,
conf->mesh_local_ula_prefix, 8) != 0) {
memcmp(cur->thread_info->threadPrivatePrefixInfo.ulaPrefix,
conf->mesh_local_ula_prefix, 8) != 0) {
// Current prefix is valid and old vs. new different: update old addresses
// Update the addresses in the neighbor cache (replace the old ULA prefix part)
ns_list_foreach(ipv6_neighbour_t, entry, &cur->ipv6_neighbour_cache.list) {
@ -658,7 +656,7 @@ static void thread_bootstrap_ml_address_update(protocol_interface_info_entry_t *
tr_debug("IP address: %s", trace_ipv6(e->address));
if (bitsequal(e->address, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 64)) {
memcpy(address, conf->mesh_local_ula_prefix, 8);
memcpy(address+8, e->address+8, 8);
memcpy(address + 8, e->address + 8, 8);
tr_debug("Updated to: %s", trace_ipv6(address));
addr_add(cur, address, e->prefix_len, e->source, e->valid_lifetime, e->preferred_lifetime, true);
addr_delete_entry(cur, e);
@ -723,11 +721,11 @@ int thread_configuration_mle_disable(protocol_interface_info_entry_t *cur)
return 0;
}
static int thread_mle_service_register(protocol_interface_info_entry_t *cur, uint8_t *mac64 )
static int thread_mle_service_register(protocol_interface_info_entry_t *cur, uint8_t *mac64)
{
if (mle_service_interface_register(cur->id, cur, thread_mle_parent_discover_receive_cb, mac64,8) != 0) {
tr_error("Mle Service init Fail");
return -1;
if (mle_service_interface_register(cur->id, cur, thread_mle_parent_discover_receive_cb, mac64, 8) != 0) {
tr_error("Mle Service init Fail");
return -1;
}
mle_service_set_frame_counter_check(true);
mle_service_set_fragmented_msg_ll_security(true);
@ -741,7 +739,7 @@ int thread_link_configuration_activate(protocol_interface_info_entry_t *cur, lin
return -1;
}
if (thread_configuration_mac_activate(cur, linkConfiguration->rfChannel, linkConfiguration->panId,thread_joiner_application_random_mac_get(cur->id))) {
if (thread_configuration_mac_activate(cur, linkConfiguration->rfChannel, linkConfiguration->panId, thread_joiner_application_random_mac_get(cur->id))) {
return -1;
}
@ -770,13 +768,13 @@ int thread_bootstrap_announce_send(protocol_interface_info_entry_t *cur, uint8_t
ptr = mle_service_get_data_pointer(buf_id);
ptr = thread_meshcop_tlv_data_write_uint64(ptr,MLE_TYPE_ACTIVE_TIMESTAMP, timestamp);
ptr = thread_meshcop_tlv_data_write_uint16(ptr,MLE_TYPE_PANID, panid);
ptr = thread_meshcop_tlv_data_write_uint64(ptr, MLE_TYPE_ACTIVE_TIMESTAMP, timestamp);
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MLE_TYPE_PANID, panid);
channel_tlv[0] = channel_page;
common_write_16_bit(channel, &channel_tlv[1]);
ptr = thread_meshcop_tlv_data_write(ptr,MLE_TYPE_CHANNEL, 3, channel_tlv);
ptr = thread_meshcop_tlv_data_write(ptr, MLE_TYPE_CHANNEL, 3, channel_tlv);
if (mle_service_update_length_by_ptr(buf_id,ptr)!= 0) {
if (mle_service_update_length_by_ptr(buf_id, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
//SET packet channel
@ -792,16 +790,17 @@ int thread_bootstrap_announce_send(protocol_interface_info_entry_t *cur, uint8_t
mle_service_send_message(buf_id);
return 0;
}
static void thread_announce_ntf_cb(void* arg)
static void thread_announce_ntf_cb(void *arg)
{
if(!arg)
if (!arg) {
return;
}
protocol_interface_info_entry_t *cur = arg;
cur->thread_info->announcement_info->timer = NULL;
thread_bootsrap_event_trig(THREAD_ANNOUNCE_ACTIVE, cur->bootStrapId, ARM_LIB_HIGH_PRIORITY_EVENT);
}
static void thread_announce_success_cb(void* arg)
static void thread_announce_success_cb(void *arg)
{
// We come here when we have succesfully attached to announced channel and then we announce this back
protocol_interface_info_entry_t *cur = arg;
@ -817,13 +816,13 @@ static void thread_announce_success_cb(void* arg)
void thread_bootstrap_announcement_start(protocol_interface_info_entry_t *cur, uint8_t channel_page, uint16_t channel, uint8_t count, uint16_t period)
{
if (!cur->thread_info->announcement_info ) {
if (!cur->thread_info->announcement_info) {
cur->thread_info->announcement_info = ns_dyn_mem_alloc(sizeof(thread_announcement_t));
}
if (!cur->thread_info->announcement_info ) {
if (!cur->thread_info->announcement_info) {
return;
}
tr_info("Start announcement ch: %d",channel);
tr_info("Start announcement ch: %d", channel);
cur->thread_info->announcement_info->channel = channel;
cur->thread_info->announcement_info->period = period;
cur->thread_info->announcement_info->channel_page = channel_page;
@ -848,10 +847,10 @@ void thread_bootstrap_temporary_attach(protocol_interface_info_entry_t *cur, uin
* Save the old info and make a timer to announce it to old channels once if attachment is succesfull
* When we receive attach fail
*/
if (!cur->thread_info->announcement_info ) {
if (!cur->thread_info->announcement_info) {
cur->thread_info->announcement_info = ns_dyn_mem_alloc(sizeof(thread_announcement_t));
}
if (!cur->thread_info->announcement_info ) {
if (!cur->thread_info->announcement_info) {
return;
}
cur->thread_info->announcement_info->channel = linkConfiguration->rfChannel;
@ -860,7 +859,7 @@ void thread_bootstrap_temporary_attach(protocol_interface_info_entry_t *cur, uin
cur->thread_info->announcement_info->count = 1;
cur->thread_info->announcement_info->period = 1000;
cur->thread_info->announcement_info->timestamp = timestamp;
cur->thread_info->announcement_info->timer = eventOS_timeout_ms(thread_announce_success_cb,20000, cur);
cur->thread_info->announcement_info->timer = eventOS_timeout_ms(thread_announce_success_cb, 20000, cur);
// TODO check timer value
cur->thread_info->announcement_info->announce_success = true;
linkConfiguration->channel_page = channel_page;
@ -870,16 +869,14 @@ void thread_bootstrap_temporary_attach(protocol_interface_info_entry_t *cur, uin
thread_bootstrap_reset_restart(cur->id);
}
static const trickle_params_t thread_mpl_data_trickle_params =
{
static const trickle_params_t thread_mpl_data_trickle_params = {
.Imin = 1, /* 50ms */
.Imax = 2, /* 100ms */
.k = 0,
.TimerExpirations = 2 /* MPL core knows to suppress to 0 for non-routers */
};
static const trickle_params_t thread_mpl_control_trickle_params =
{
static const trickle_params_t thread_mpl_control_trickle_params = {
.Imin = 11,
.Imax = 5 * 60 * 20,
.k = 0,
@ -934,7 +931,7 @@ static void thread_interface_bootsrap_mode_init(protocol_interface_info_entry_t
cur->thread_info->thread_device_mode = THREAD_DEVICE_MODE_ROUTER;
cur->lowpan_info &= ~INTERFACE_NWK_ROUTER_DEVICE;
} else if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_HOST &&
cur->thread_info->end_device_link_synch ) {
cur->thread_info->end_device_link_synch) {
tr_debug("Set FED Mode");
cur->thread_info->thread_device_mode = THREAD_DEVICE_MODE_FULL_END_DEVICE;
} else if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_SLEEPY_HOST) {
@ -1078,10 +1075,10 @@ void thread_tasklet(arm_event_s *event)
}
// New timeout needed
cur->thread_info->announcement_info->timer = eventOS_timeout_ms(thread_announce_ntf_cb,cur->thread_info->announcement_info->period, cur);
cur->thread_info->announcement_info->timer = eventOS_timeout_ms(thread_announce_ntf_cb, cur->thread_info->announcement_info->period, cur);
// Send announce_ntf
thread_bootstrap_announce_send(cur,linkConfiguration->channel_page,linkConfiguration->rfChannel,linkConfiguration->panId,linkConfiguration->timestamp, cur->thread_info->announcement_info->channel);
thread_bootstrap_announce_send(cur, linkConfiguration->channel_page, linkConfiguration->rfChannel, linkConfiguration->panId, linkConfiguration->timestamp, cur->thread_info->announcement_info->channel);
} else {
// Last call, delete announcement info
ns_dyn_mem_free(cur->thread_info->announcement_info);
@ -1160,7 +1157,7 @@ void thread_bootstrap_ready(protocol_interface_info_entry_t *cur)
thread_bootstrap_mac_activate(cur, cur->mac_parameters->mac_channel, cur->mac_parameters->pan_id, true);
if (nd_proxy_downstream_interface_register(cur->id,thread_proxy_validate , thread_bbr_proxy_state_update) != 0) {
if (nd_proxy_downstream_interface_register(cur->id, thread_proxy_validate, thread_bbr_proxy_state_update) != 0) {
tr_debug("mesh proxy register fail");
}
}
@ -1244,7 +1241,7 @@ static int thread_bootstrap_attach_start(int8_t interface_id, thread_bootsrap_st
case THREAD_NORMAL_ATTACH:
cur->thread_info->thread_attached_state = THREAD_STATE_NETWORK_DISCOVER;
mac_helper_default_security_level_set(cur, cur->mac_parameters->mac_configured_sec_level);
mac_helper_default_security_key_id_mode_set(cur,MAC_KEY_ID_MODE_IDX);
mac_helper_default_security_key_id_mode_set(cur, MAC_KEY_ID_MODE_IDX);
break;
case THREAD_REATTACH:
@ -1254,7 +1251,7 @@ static int thread_bootstrap_attach_start(int8_t interface_id, thread_bootsrap_st
cur->thread_info->previous_partition_info.weighting = cur->thread_info->thread_leader_data->weighting;
cur->thread_info->previous_partition_info.idSequence = cur->thread_info->routing.router_id_sequence;
cur->thread_info->routerShortAddress = mac_helper_mac16_address_get(cur);
if(cur->thread_info->thread_attached_state != THREAD_STATE_REATTACH_RETRY){
if (cur->thread_info->thread_attached_state != THREAD_STATE_REATTACH_RETRY) {
cur->thread_info->thread_attached_state = THREAD_STATE_REATTACH;
}
break;
@ -1270,7 +1267,7 @@ static int thread_bootstrap_attach_start(int8_t interface_id, thread_bootsrap_st
cur->thread_info->releaseRouterId = true;
cur->thread_info->routerShortAddress = mac_helper_mac16_address_get(cur);
if(cur->thread_info->thread_attached_state != THREAD_STATE_REATTACH_RETRY){
if (cur->thread_info->thread_attached_state != THREAD_STATE_REATTACH_RETRY) {
cur->thread_info->thread_attached_state = THREAD_STATE_REATTACH;
}
break;
@ -1291,8 +1288,10 @@ static void thread_bootsrap_network_discovery_failure(int8_t interface_id)
return;
}
//TODO we should send 3 in burst of 0.1 - 0.6 seconds and then do the exponential backup of 5s -- 80s
uint32_t backof_delay = cur->nwk_nd_re_scan_count*2;
if (backof_delay > 600) backof_delay = 600; //TODO test this and check guess this is 100ms ticks
uint32_t backof_delay = cur->nwk_nd_re_scan_count * 2;
if (backof_delay > 600) {
backof_delay = 600; //TODO test this and check guess this is 100ms ticks
}
tr_debug("Continue network scan");
cur->nwk_bootstrap_state = ER_ACTIVE_SCAN;
@ -1305,8 +1304,7 @@ static void thread_bootstrap_generate_leader_and_link(protocol_interface_info_en
tr_debug("ReAttach Fail - retry");
thread_bootstrap_attach_start(cur->id, THREAD_REATTACH);
cur->thread_info->thread_attached_state = THREAD_STATE_REATTACH_RETRY;
}
else if (cur->thread_info->thread_attached_state == THREAD_STATE_REATTACH_RETRY) {
} else if (cur->thread_info->thread_attached_state == THREAD_STATE_REATTACH_RETRY) {
tr_warn("ReAttach Fail");
thread_bootstrap_attach_start(cur->id, THREAD_ANY_ATTACH);
} else {
@ -1332,20 +1330,20 @@ static int8_t thread_bootstrap_attempt_attach_with_pending_set(protocol_interfac
return -1;
}
if (thread_joiner_application_old_config_exists(cur->id)){
if (thread_joiner_application_old_config_exists(cur->id)) {
//there is an existing old configuration so attempt to attach with it and set the pending timer to expire
thread_joiner_application_old_config_activate(cur->id);
thread_joiner_application_old_config_delete(cur->id);
thread_joiner_application_pending_config_enable(cur->id,20000);
}
else {
thread_joiner_application_pending_config_enable(cur->id, 20000);
} else {
thread_joiner_pending_config_activate(cur->id);
}
return 0;
}
static void thread_bootstrap_orphan_scan_ready_cb(struct protocol_interface_info_entry *cur_interface, announce_discovery_response_t *discover_response) {
static void thread_bootstrap_orphan_scan_ready_cb(struct protocol_interface_info_entry *cur_interface, announce_discovery_response_t *discover_response)
{
if (!discover_response) {
thread_bootstrap_orphan_scan_start(cur_interface);
@ -1423,7 +1421,7 @@ void thread_bootstrap_connection_error(int8_t interface_id, nwk_connect_error_ty
}
if (cur->thread_info->announcement_info && cur->thread_info->announcement_info->timer &&
cur->thread_info->announcement_info->announce_success) {
cur->thread_info->announcement_info->announce_success) {
// Attachment to announce failed we return to previous channel
link_configuration_s *linkConfiguration = thread_joiner_application_get_config(cur->id);
@ -1442,15 +1440,14 @@ void thread_bootstrap_connection_error(int8_t interface_id, nwk_connect_error_ty
break;
}
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_ROUTER){
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_ROUTER) {
if (!thread_router_bootstrap_routing_allowed(cur)) {
thread_discovery_responser_enable(cur->id, false);
thread_bootstrap_orphan_scan_start(cur);
} else {
thread_bootstrap_generate_leader_and_link(cur);
}
}
else {
} else {
thread_bootstrap_orphan_scan_start(cur);
}
break;
@ -1513,7 +1510,7 @@ int thread_bootstrap_reset(protocol_interface_info_entry_t *cur)
cur->nwk_mode = ARM_NWK_GP_IP_MODE;
cur->nwk_bootstrap_state = ER_ACTIVE_SCAN;
cur->nwk_nd_re_scan_count = 0;
if(cur->thread_info->thread_attached_state != THREAD_STATE_REATTACH_RETRY) {
if (cur->thread_info->thread_attached_state != THREAD_STATE_REATTACH_RETRY) {
cur->thread_info->thread_attached_state = THREAD_STATE_NETWORK_DISCOVER;
}
cur->ipv6_neighbour_cache.send_nud_probes = false; //Disable NUD probing
@ -1533,7 +1530,7 @@ void thread_generate_ml64_address(protocol_interface_info_entry_t *cur)
uint8_t ula[16];
memcpy(ula, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 8);
//GENERATE ML-EID64
memcpy(&ula[8], cur->iid_slaac , 8);
memcpy(&ula[8], cur->iid_slaac, 8);
def_address = addr_add(cur, ula, 64, ADDR_SOURCE_UNKNOWN, 0xffffffff, 0xffffffff, true);
if (def_address) {
tr_debug("Generated UL64: %s", trace_ipv6(ula));
@ -1668,7 +1665,7 @@ void thread_bootstrap_attached_finish(protocol_interface_info_entry_t *cur)
thread_bootstrap_network_data_update(cur);
// After successful attach if there is announcement info present, send announcement back to previous channel
if (cur->thread_info->announcement_info && cur->thread_info->announcement_info->announce_success == false) {
cur->thread_info->announcement_info->timer = eventOS_timeout_ms(thread_announce_success_cb,20000, cur);
cur->thread_info->announcement_info->timer = eventOS_timeout_ms(thread_announce_success_cb, 20000, cur);
}
thread_configuration_mle_activate(cur);
@ -1682,7 +1679,7 @@ void thread_bootstrap_attached_finish(protocol_interface_info_entry_t *cur)
thread_nvm_store_link_info_write(parent_mac_addr, mac_helper_mac16_address_get(cur));
thread_bootstrap_ready(cur);
if(thread_is_router_addr(mac_helper_mac16_address_get(cur))) {
if (thread_is_router_addr(mac_helper_mac16_address_get(cur))) {
// Attached as router Trigger routter attach
tr_info("Attaching directly to router");
thread_bootstrap_attached_active_router(cur);
@ -1701,15 +1698,15 @@ bool thread_network_data_timeout(int8_t interface_id, uint16_t msgId, bool usedA
}
/* If network data is not received, send again */
if(thread_info(cur)->networkDataRequested && !usedAllRetries){
if (thread_info(cur)->networkDataRequested && !usedAllRetries) {
return true;
}
if(cur->thread_info->leader_synced) {
if(usedAllRetries) {
if (cur->thread_info->leader_synced) {
if (usedAllRetries) {
// could not learn network data from neighbour, everyone must reregister
cur->thread_info->leader_synced = false;
thread_leader_service_network_data_changed(cur,true,true);
thread_leader_service_network_data_changed(cur, true, true);
return false;
} else {
tr_debug("retrying as leader data not yet synced");
@ -1734,7 +1731,7 @@ bool thread_tlv_request(int8_t interface_id, uint8_t *address, bool delayed_mess
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
uint16_t buf_id;
buf_id = mle_service_msg_allocate(interface_id, 32 + 20 + thread_leader_data_tlv_size(cur), false,MLE_COMMAND_DATA_REQUEST);
buf_id = mle_service_msg_allocate(interface_id, 32 + 20 + thread_leader_data_tlv_size(cur), false, MLE_COMMAND_DATA_REQUEST);
if (!cur || buf_id == 0) {
return false;
@ -1750,7 +1747,7 @@ bool thread_tlv_request(int8_t interface_id, uint8_t *address, bool delayed_mess
ptr = thread_pending_timestamp_write(cur, ptr);
if (mle_service_update_length_by_ptr(buf_id,ptr)!= 0) {
if (mle_service_update_length_by_ptr(buf_id, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
timeout.retrans_max = THREAD_REQUEST_MAX_RETRY_CNT;
@ -1809,10 +1806,8 @@ static int compare_steering_and_joiner_bloom(uint8_t *steering_bloom, uint8_t *j
int loop_iterator;
tr_debug("joiner bloom : %s", trace_array(joiner_bloom, steering_tlv_length));
tr_debug("steering bloom : %s", trace_array(steering_bloom, steering_tlv_length));
for (loop_iterator = 0; loop_iterator < steering_tlv_length; loop_iterator++)
{
if ((joiner_bloom[loop_iterator] != (joiner_bloom[loop_iterator] & steering_bloom[loop_iterator])))
{
for (loop_iterator = 0; loop_iterator < steering_tlv_length; loop_iterator++) {
if ((joiner_bloom[loop_iterator] != (joiner_bloom[loop_iterator] & steering_bloom[loop_iterator]))) {
thci_trace("joinerDiscoveryFailedFiltered");
return 0;
}
@ -1824,7 +1819,7 @@ static bool thread_route_possible_add(thread_attach_device_mode_e threadMode)
{
bool addRoute;
if (threadMode == THREAD_DEVICE_MODE_ROUTER ||
threadMode == THREAD_DEVICE_MODE_FULL_END_DEVICE) {
threadMode == THREAD_DEVICE_MODE_FULL_END_DEVICE) {
addRoute = true;
} else {
addRoute = false;
@ -1858,7 +1853,7 @@ bool thread_dhcpv6_address_entry_available(uint8_t *prefixPtr, if_address_list_t
return addressReady;
}
static int thread_bloom_and_compare(uint8_t *steering_data_ptr,uint8_t steering_data_length,uint8_t *eui64, uint8_t eui64_length)
static int thread_bloom_and_compare(uint8_t *steering_data_ptr, uint8_t steering_data_length, uint8_t *eui64, uint8_t eui64_length)
{
if (steering_data_length == 0 || steering_data_length > 16) {
return 0;
@ -1870,16 +1865,16 @@ static int thread_bloom_and_compare(uint8_t *steering_data_ptr,uint8_t steering_
ns_sha256_nbits(eui64, eui64_length, mac_extended_address, 64);
mac_extended_address[0] |= 2; //local administered bit is set
thread_beacon_calculate_bloom_filter(joiner_bloom_calculated,steering_data_length,mac_extended_address,8);
thread_beacon_calculate_bloom_filter(joiner_bloom_calculated, steering_data_length, mac_extended_address, 8);
return compare_steering_and_joiner_bloom(steering_data_ptr, joiner_bloom_calculated,steering_data_length);
return compare_steering_and_joiner_bloom(steering_data_ptr, joiner_bloom_calculated, steering_data_length);
}
static void thread_network_select_by_steering_data(device_configuration_s *device_configuration_ptr, thread_nwk_discovery_response_list_t *discover_response)
{
ns_list_foreach_safe(discovery_response_list_t, cur_class, discover_response) {
if (!thread_bloom_and_compare(cur_class->steering_data, cur_class->steering_data_valid, device_configuration_ptr->eui64,8) ) {
if (!thread_bloom_and_compare(cur_class->steering_data, cur_class->steering_data_valid, device_configuration_ptr->eui64, 8)) {
ns_list_remove(discover_response, cur_class);
ns_dyn_mem_free(cur_class);
}
@ -1932,7 +1927,7 @@ void thread_bootsrap_discovery_ready_cb(struct protocol_interface_info_entry *cu
exit_failure:
thread_bootstrap_connection_error(cur_interface->id, CON_ERROR_NO_THREAD_NETWORK_AVAILABLE, NULL);
thread_bootstrap_connection_error(cur_interface->id, CON_ERROR_NO_THREAD_NETWORK_AVAILABLE, NULL);
}
static void thread_bootstrap_create_unsecure_link_to_parent(protocol_interface_info_entry_t *interface, discovery_response_list_t *nwk_info)
@ -1952,7 +1947,7 @@ static void thread_bootstrap_create_unsecure_link_to_parent(protocol_interface_i
start_req.SuperframeOrder = 0x0f;
//SET Beacon Payload
mac_helper_beacon_payload_reallocate(interface, 0);
interface->mac_api->mlme_req(interface->mac_api, MLME_START, (void*)&start_req);
interface->mac_api->mlme_req(interface->mac_api, MLME_START, (void *)&start_req);
mac_data_poll_init(interface);
mac_helper_mac16_address_set(interface, 0xffff);
tr_debug("Mac Ready");
@ -1969,7 +1964,7 @@ void thread_discover_native_commissioner_response(protocol_interface_info_entry_
// create list of available networks for native commissioner interface
config_ptr = ns_dyn_mem_alloc(sizeof(thread_commissioning_link_configuration_s) * ns_list_count(nwk_info));
if(!config_ptr) {
if (!config_ptr) {
tr_debug("Mac scan confirm:out of resources");
goto exit_failure;
}
@ -1988,21 +1983,21 @@ void thread_discover_native_commissioner_response(protocol_interface_info_entry_
n++;
}
if(interface->thread_info->native_commissioner_cb) {
interface->thread_info->native_commissioner_cb(interface->id,n,config_ptr);
if (interface->thread_info->native_commissioner_cb) {
interface->thread_info->native_commissioner_cb(interface->id, n, config_ptr);
}
ns_dyn_mem_free(config_ptr);
if(!interface->thread_info->native_commissioner_link) {
if (!interface->thread_info->native_commissioner_link) {
tr_debug("Mac scan confirm:continue scanning");
goto exit_failure;
}
//Free if not matching network found
ns_list_foreach_safe(discovery_response_list_t, cur_class, nwk_info) {
if(cur_class->version != THREAD_PROTOCOL_VERSION ||
if (cur_class->version != THREAD_PROTOCOL_VERSION ||
cur_class->pan_id != interface->thread_info->native_commissioner_link->panId ||
memcmp(interface->thread_info->native_commissioner_link->name,cur_class->network_name,16) != 0 ||
memcmp(interface->thread_info->native_commissioner_link->extented_pan_id,cur_class->extented_pan_id,8) != 0 ) {
memcmp(interface->thread_info->native_commissioner_link->name, cur_class->network_name, 16) != 0 ||
memcmp(interface->thread_info->native_commissioner_link->extented_pan_id, cur_class->extented_pan_id, 8) != 0) {
ns_list_remove(nwk_info, cur_class);
ns_dyn_mem_free(cur_class);
@ -2010,7 +2005,7 @@ void thread_discover_native_commissioner_response(protocol_interface_info_entry_
}
}
if(ns_list_is_empty(nwk_info)) {
if (ns_list_is_empty(nwk_info)) {
tr_debug("Mac scan confirm:no networks available");
goto exit_failure;
}
@ -2156,12 +2151,12 @@ static bool thread_bootstrap_sync_after_reset_start(protocol_interface_info_entr
cur->thread_info->link_sync_allowed = false;
int link_info_err = thread_nvm_store_link_info_get(parent_mac64, &my_short_address);
if ( link_info_err!= THREAD_NVM_FILE_SUCCESS) {
if (link_info_err != THREAD_NVM_FILE_SUCCESS) {
tr_warning("thread_nvm_store_link_info_get returned %d", link_info_err);
return false;
}
link_info_err = thread_nvm_store_link_info_clear();
if ( link_info_err!= THREAD_NVM_FILE_SUCCESS) {
if (link_info_err != THREAD_NVM_FILE_SUCCESS) {
tr_warning("thread_nvm_store_link_info_clear returned %d", link_info_err);
}
if (thread_is_router_addr(my_short_address)) {
@ -2176,7 +2171,7 @@ static bool thread_bootstrap_sync_after_reset_start(protocol_interface_info_entr
}
cur->thread_info->thread_endnode_parent->shortAddress = 0xfffe;
memcpy(cur->thread_info->thread_endnode_parent->mac64,parent_mac64,8);
memcpy(cur->thread_info->thread_endnode_parent->mac64, parent_mac64, 8);
thread_endevice_synch_start(cur);
return true;
}
@ -2188,7 +2183,7 @@ void thread_bootstrap_start_network_discovery(protocol_interface_info_entry_t *c
cur->mac_parameters->nwk_scan_params.stack_chan_list = cur->mac_parameters->mac_channel_list;
if(cur->thread_info->native_commissioner_cb) {
if (cur->thread_info->native_commissioner_cb) {
tr_debug("native commissioner network scan start");
discover_ready = thread_discover_native_commissioner_response;
@ -2205,12 +2200,12 @@ void thread_bootstrap_start_network_discovery(protocol_interface_info_entry_t *c
thci_trace("joinerDiscoveryStarted");
blacklist_params_set(
THREAD_COMM_BLACKLIST_ENTRY_LIFETIME,
THREAD_COMM_BLACKLIST_TIMER_MAX_TIMEOUT,
THREAD_COMM_BLACKLIST_TIMER_TIMEOUT,
THREAD_BLACKLIST_ENTRY_MAX_NBR,
THREAD_BLACKLIST_PURGE_NBR,
THREAD_BLACKLIST_PURGE_TIMER_TIMEOUT);
THREAD_COMM_BLACKLIST_ENTRY_LIFETIME,
THREAD_COMM_BLACKLIST_TIMER_MAX_TIMEOUT,
THREAD_COMM_BLACKLIST_TIMER_TIMEOUT,
THREAD_BLACKLIST_ENTRY_MAX_NBR,
THREAD_BLACKLIST_PURGE_NBR,
THREAD_BLACKLIST_PURGE_TIMER_TIMEOUT);
scan_request.native_commisioner = false;
scan_request.joiner_flag = true;
@ -2221,7 +2216,7 @@ void thread_bootstrap_start_network_discovery(protocol_interface_info_entry_t *c
scan_request.channel_mask = cur->mac_parameters->nwk_scan_params.stack_chan_list.channel_mask[0];
scan_request.filter_tlv_data = NULL;
scan_request.filter_tlv_length = 0;
if (thread_discovery_network_scan(cur, &scan_request, discover_ready) != 0 ) {
if (thread_discovery_network_scan(cur, &scan_request, discover_ready) != 0) {
tr_error("Discovery scan start fail");
}
}
@ -2242,8 +2237,8 @@ void thread_bootstrap_state_machine(protocol_interface_info_entry_t *cur)
//SET Link by Static configuration
tr_info("thread network attach start");
if (thread_mle_service_register(cur,thread_joiner_application_random_mac_get(cur->id)) != 0 ||
thread_link_configuration_activate(cur, linkConfiguration) != 0) {
if (thread_mle_service_register(cur, thread_joiner_application_random_mac_get(cur->id)) != 0 ||
thread_link_configuration_activate(cur, linkConfiguration) != 0) {
tr_error("Network Bootsrap Start Fail");
bootsrap_next_state_kick(ER_BOOTSTRAP_SCAN_FAIL, cur);
return;
@ -2318,7 +2313,7 @@ void thread_bootstrap_child_update_trig(protocol_interface_info_entry_t *cur)
thread_bootsrap_event_trig(THREAD_CHILD_UPDATE, cur->bootStrapId, ARM_LIB_HIGH_PRIORITY_EVENT);
}
}
static void thread_border_router_locator_copy(protocol_interface_info_entry_t *cur,thread_commissioner_t *registered_commissioner , uint8_t *data)
static void thread_border_router_locator_copy(protocol_interface_info_entry_t *cur, thread_commissioner_t *registered_commissioner, uint8_t *data)
{
memcpy(registered_commissioner->border_router_address, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 8);
memcpy(&registered_commissioner->border_router_address[8], ADDR_SHORT_ADR_SUFFIC, 6);
@ -2337,7 +2332,7 @@ static int thread_commission_data_tlv_parse(protocol_interface_info_entry_t *cur
if (length != 2) {
return -1;
}
if(registered_commissioner->session_id != common_read_16_bit(data)){
if (registered_commissioner->session_id != common_read_16_bit(data)) {
registered_commissioner->session_id = common_read_16_bit(data);
return 1;
}
@ -2347,7 +2342,7 @@ static int thread_commission_data_tlv_parse(protocol_interface_info_entry_t *cur
if (length > 16) {
return -1;
}
if(registered_commissioner->steering_data_len != length || memcmp(registered_commissioner->steering_data, data, length)){
if (registered_commissioner->steering_data_len != length || memcmp(registered_commissioner->steering_data, data, length)) {
memcpy(registered_commissioner->steering_data, data, length);
registered_commissioner->steering_data_len = length;
return 1;
@ -2361,9 +2356,9 @@ static int thread_commission_data_tlv_parse(protocol_interface_info_entry_t *cur
registered_commissioner->commissioner_valid = true;
if (!registered_commissioner->commissioner_valid ||
memcmp(&registered_commissioner->border_router_address[14], data, 2) ||
memcmp(registered_commissioner->border_router_address, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 8)) {
thread_border_router_locator_copy(cur,registered_commissioner, data );
memcmp(&registered_commissioner->border_router_address[14], data, 2) ||
memcmp(registered_commissioner->border_router_address, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 8)) {
thread_border_router_locator_copy(cur, registered_commissioner, data);
return 1;
}
break;
@ -2543,7 +2538,7 @@ int thread_bootstrap_network_data_process(protocol_interface_info_entry_t *cur,
} else {
tr_debug("SLAAC address set as NOT preferred.");
}
addr_set_preferred_lifetime(cur, e, genericService.P_preferred ? 0xfffffffff: 0);
addr_set_preferred_lifetime(cur, e, genericService.P_preferred ? 0xfffffffff : 0);
}
}
}
@ -2610,9 +2605,9 @@ int thread_bootstrap_network_data_process(protocol_interface_info_entry_t *cur,
length -= subLength;
data_changed = thread_commission_data_tlv_parse(cur, type, subLength, dptr);
if (data_changed < 0)
if (data_changed < 0) {
tr_debug("Fail");
else {
} else {
if (data_changed == 1) {
update_data = true;
tr_debug("Changed");
@ -2650,7 +2645,7 @@ int thread_bootstrap_network_data_process(protocol_interface_info_entry_t *cur,
dptr += service_entry.S_service_data_length;
tr_debug("Service data: %s, enterprise number: %"PRIu32, trace_array(service_entry.S_service_data,
service_entry.S_service_data_length), service_entry.S_enterprise_number);
service_entry.S_service_data_length), service_entry.S_enterprise_number);
length -= 2 + service_entry.S_service_data_length;
@ -2709,7 +2704,7 @@ int thread_bootstrap_network_data_activate(protocol_interface_info_entry_t *cur)
}
// delete marked data
if (thread_network_data_router_id_free(&cur->thread_info->networkDataStorage, false, cur) ) {
if (thread_network_data_router_id_free(&cur->thread_info->networkDataStorage, false, cur)) {
thread_bootstrap_child_update_trig(cur);
}
@ -2736,7 +2731,7 @@ int thread_bootstrap_network_data_activate(protocol_interface_info_entry_t *cur)
return 0;
}
int thread_bootstrap_network_data_save(protocol_interface_info_entry_t *cur, thread_leader_data_t *leader_data, uint8_t* network_data_ptr, uint16_t network_data_len)
int thread_bootstrap_network_data_save(protocol_interface_info_entry_t *cur, thread_leader_data_t *leader_data, uint8_t *network_data_ptr, uint16_t network_data_len)
{
if (!cur || !cur->thread_info || !leader_data || network_data_len > THREAD_MAX_NETWORK_DATA_SIZE) {
tr_warn("Network data saving failed");
@ -2763,12 +2758,12 @@ int thread_bootstrap_network_data_save(protocol_interface_info_entry_t *cur, thr
thread_info(cur)->thread_leader_data->dataVersion = leader_data->dataVersion;
cur->thread_info->networkDataStorage.temporaryUpdatePushed = true;
}
if ((network_data_len!=cur->thread_info->networkDataStorage.network_data_len ||
memcmp(cur->thread_info->networkDataStorage.network_data,network_data_ptr,network_data_len) != 0)){
if ((network_data_len != cur->thread_info->networkDataStorage.network_data_len ||
memcmp(cur->thread_info->networkDataStorage.network_data, network_data_ptr, network_data_len) != 0)) {
// Network data was changed so at least it will be unstable change
cur->thread_info->networkDataStorage.temporaryUpdatePushed = true;
tr_debug("Network data changed; size %d stable:%d, unstable:%d", network_data_len, cur->thread_info->networkDataStorage.stableUpdatePushed,cur->thread_info->networkDataStorage.temporaryUpdatePushed);
memcpy(cur->thread_info->networkDataStorage.network_data, network_data_ptr,network_data_len);
tr_debug("Network data changed; size %d stable:%d, unstable:%d", network_data_len, cur->thread_info->networkDataStorage.stableUpdatePushed, cur->thread_info->networkDataStorage.temporaryUpdatePushed);
memcpy(cur->thread_info->networkDataStorage.network_data, network_data_ptr, network_data_len);
cur->thread_info->networkDataStorage.network_data_len = network_data_len;
}
@ -2804,8 +2799,8 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
}
weHostService = thread_nd_hosted_by_this_routerid(routerId, &curPrefix->borderRouterList);
if(weHostService) {
tr_debug( "I'm Hosting BR");
if (weHostService) {
tr_debug("I'm Hosting BR");
}
ns_list_foreach(thread_network_server_data_entry_t, curBorderRouter, &curPrefix->borderRouterList) {
@ -2821,7 +2816,7 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
if (thread_nd_on_mesh_address_valid(curBorderRouter)) {
if (validToLearOnMeshRoute) {
if (curBorderRouter->P_dhcp && weHostService && nd_proxy_enabled_for_upstream(cur->id) && nd_proxy_upstream_route_onlink(cur->id,curPrefix->servicesPrefix)) {
if (curBorderRouter->P_dhcp && weHostService && nd_proxy_enabled_for_upstream(cur->id) && nd_proxy_upstream_route_onlink(cur->id, curPrefix->servicesPrefix)) {
// don't add
tr_debug("Suppressing onlink %s for proxy", trace_ipv6_prefix(curPrefix->servicesPrefix, curPrefix->servicesPrefixLen));
} else if (curBorderRouter->P_res1) {
@ -2838,8 +2833,8 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
/* All end device types perform BR RLOC16 -> ALOC16
replacement if stable network data was requested. */
if ((cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_HOST ||
cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_SLEEPY_HOST) &&
cur->thread_info->requestFullNetworkData == false) {
cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_SLEEPY_HOST) &&
cur->thread_info->requestFullNetworkData == false) {
ns_list_foreach(thread_network_data_context_entry_t, curRoute, &curPrefix->contextList) {
curBorderRouter->routerID = 0xfc00;
curBorderRouter->routerID |= curRoute->cid;
@ -2859,8 +2854,8 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
/* All end device types perform RLOC16 -> 0xfffe
replacement if stable network data was requested. */
if ((cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_HOST ||
cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_SLEEPY_HOST) &&
cur->thread_info->requestFullNetworkData == false) {
cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_SLEEPY_HOST) &&
cur->thread_info->requestFullNetworkData == false) {
curBorderRouter->routerID = 0xfffe;
tr_debug("Invalidated router ID: %04x", curBorderRouter->routerID);
}
@ -2873,7 +2868,7 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
}
// generate address based on res1 bit
if (curBorderRouter->P_res1) {
thread_extension_dua_address_generate(cur,curPrefix->servicesPrefix,64);
thread_extension_dua_address_generate(cur, curPrefix->servicesPrefix, 64);
}
} // for each borderRouterList
@ -2885,7 +2880,7 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
flags |= 0x10;
}
lowpan_context_update(&cur->lowpan_contexts, flags , 0xFFFF, curPrefix->servicesPrefix, curPrefix->servicesPrefixLen, curRoute->stableData);
lowpan_context_update(&cur->lowpan_contexts, flags, 0xFFFF, curPrefix->servicesPrefix, curPrefix->servicesPrefixLen, curRoute->stableData);
}
} // for each localPrefixList
}
@ -2948,9 +2943,8 @@ void thread_bootstrap_dynamic_configuration_save(protocol_interface_info_entry_t
// in error situation this returns 0 !!!!
uint32_t mle_frame_counter = mle_service_security_get_frame_counter(cur->id);
if (linkConfiguration) {
thread_nvm_store_fast_data_check_and_write(mac_frame_counter, mle_frame_counter, linkConfiguration->key_sequence);
}
else {
thread_nvm_store_fast_data_check_and_write(mac_frame_counter, mle_frame_counter, linkConfiguration->key_sequence);
} else {
thread_nvm_store_frame_counters_check_and_write(mac_frame_counter, mle_frame_counter);
}
}
@ -2963,7 +2957,7 @@ bool thread_bootstrap_link_create_check(protocol_interface_info_entry_t *interfa
return false;
}
if(mle_class_free_entry_count_get(interface) < 1) {
if (mle_class_free_entry_count_get(interface) < 1) {
// We dont have room for any new links
tr_warn("Link ignore no room for addr:%x", short_address);
return false;
@ -2994,7 +2988,7 @@ bool thread_bootstrap_link_create_allowed(protocol_interface_info_entry_t *inter
(void) short_address;
#endif
// Add blacklist of routers that newer answer to us
if(mle_service_interface_tx_queue_size(interface->id) > THREAD_MAX_PARALLEL_MLE_LINK_REQUEST) {
if (mle_service_interface_tx_queue_size(interface->id) > THREAD_MAX_PARALLEL_MLE_LINK_REQUEST) {
// Maximum parallel link requests
tr_warn("Link ignore too many req addr:%x", short_address);
return false;

View File

@ -119,12 +119,12 @@ void thread_interface_init(struct protocol_interface_info_entry *cur);
* Thread bootstrap layer configurations
*/
int thread_configuration_mac_activate(protocol_interface_info_entry_t *cur, uint16_t channel, uint16_t panid, uint8_t *extended_random_mac);
int thread_configuration_6lowpan_activate(protocol_interface_info_entry_t *cur );
int thread_configuration_6lowpan_activate(protocol_interface_info_entry_t *cur);
int thread_configuration_mle_activate(protocol_interface_info_entry_t *cur);
int thread_configuration_mle_disable(protocol_interface_info_entry_t *cur);
int thread_configuration_thread_activate(protocol_interface_info_entry_t *cur, link_configuration_s *linkConfiguration );
int thread_configuration_thread_activate(protocol_interface_info_entry_t *cur, link_configuration_s *linkConfiguration);
int thread_link_configuration_activate(struct protocol_interface_info_entry *cur, struct link_configuration *linkConfiguration);
int thread_parent_discover_start(int8_t interface_id, uint8_t *mac64 );
int thread_parent_discover_start(int8_t interface_id, uint8_t *mac64);
bool thread_device_synch_timeout(int8_t interface_id, uint16_t msgId, bool usedAllRetries);
bool thread_link_request_timeout(int8_t interface_id, uint16_t msgId, bool usedAllRetries);
@ -161,7 +161,7 @@ int8_t thread_active_configuration_dataset_query_clean(protocol_interface_info_e
void thread_bootstrap_mac_activate(protocol_interface_info_entry_t *cur, uint16_t channel, uint16_t panid, bool coordinator);
int thread_bootstrap_network_data_process(protocol_interface_info_entry_t *cur, uint8_t *network_data_ptr, uint16_t network_data_length);
int thread_bootstrap_network_data_activate(protocol_interface_info_entry_t *cur);
int thread_bootstrap_network_data_save(struct protocol_interface_info_entry *cur, thread_leader_data_t *leader_data, uint8_t* network_data_ptr, uint16_t network_data_len);
int thread_bootstrap_network_data_save(struct protocol_interface_info_entry *cur, thread_leader_data_t *leader_data, uint8_t *network_data_ptr, uint16_t network_data_len);
void thread_bootstrap_network_prefixes_process(struct protocol_interface_info_entry *cur);
void thread_bootstrap_network_data_update(protocol_interface_info_entry_t *cur);
bool thread_bootstrap_link_create_check(protocol_interface_info_entry_t *interface, uint16_t short_address);
@ -172,7 +172,7 @@ void thread_bootstrap_clear_neighbor_entries(protocol_interface_info_entry_t *cu
void thread_bootstrap_dynamic_configuration_save(protocol_interface_info_entry_t *cur);
void thread_bootstrap_update_ml16_address(protocol_interface_info_entry_t *cur, uint16_t mac16);
void thread_bootstrap_pending_configuration_save(protocol_interface_info_entry_t *cur);
void thread_bootstrap_all_nodes_address_generate(uint8_t multicast_address[16],uint8_t prefix[8], uint8_t scope);
void thread_bootstrap_all_nodes_address_generate(uint8_t multicast_address[16], uint8_t prefix[8], uint8_t scope);
/**
* Check advertisement or parent response is from a singleton partition and decide on accepting or dropping the packet
*
@ -185,7 +185,7 @@ void thread_bootstrap_all_nodes_address_generate(uint8_t multicast_address[16],u
* return -2 no merge needs to be triggered or parent response can be dropped
*/
int thread_bootstrap_partition_process(protocol_interface_info_entry_t *cur,uint8_t heard_partition_routers,thread_leader_data_t *heard_partition_leader_data, mle_tlv_info_t *routeTlv);
int thread_bootstrap_partition_process(protocol_interface_info_entry_t *cur, uint8_t heard_partition_routers, thread_leader_data_t *heard_partition_leader_data, mle_tlv_info_t *routeTlv);
/*
* Thread announcement control functions

View File

@ -121,7 +121,7 @@ static uint8_t *thread_management_server_border_router_nd_dnssl_option_read(thre
{
if (this->dns_search_list_option) {
*resp_len = this->dns_search_list_option->option_length;
return (uint8_t*)&this->dns_search_list_option->option_data;
return (uint8_t *)&this->dns_search_list_option->option_data;
} else {
// TODO: Read DNSSL from stored ICMP RA messages.
*resp_len = 0;
@ -139,7 +139,7 @@ static uint8_t *thread_management_server_border_router_nd_rdnss_option_read(thre
{
if (this->recursive_dns_server_option) {
*resp_len = this->recursive_dns_server_option->option_length;
return (uint8_t*)&this->recursive_dns_server_option->option_data;
return (uint8_t *)&this->recursive_dns_server_option->option_data;
} else {
// TODO: Read RDNSS from stored ICMP RA messages.
*resp_len = 0;
@ -215,7 +215,7 @@ static int thread_border_router_neighbor_discovery_data_req_cb(int8_t service_id
}
send_response:
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, return_code, COAP_CT_OCTET_STREAM, resp_payload_ptr, ptr-resp_payload_ptr);
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, return_code, COAP_CT_OCTET_STREAM, resp_payload_ptr, ptr - resp_payload_ptr);
ns_dyn_mem_free(resp_payload_ptr);
return 0;
}
@ -235,7 +235,7 @@ static bool thread_border_router_network_data_prefix_match(thread_network_data_c
// check that prefix is hosted by this router
if (!thread_nd_hosted_by_this_routerid(router_id, &nwk_prefix->routeList) &&
!thread_nd_hosted_by_this_routerid(router_id, &nwk_prefix->borderRouterList)) {
!thread_nd_hosted_by_this_routerid(router_id, &nwk_prefix->borderRouterList)) {
return false;
}
@ -530,14 +530,14 @@ void thread_border_router_seconds_timer(int8_t interface_id, uint32_t seconds)
if (this->nwk_data_resubmit_timer > seconds) {
this->nwk_data_resubmit_timer -= seconds;
} else {
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
this->nwk_data_resubmit_timer = 0;
if (cur) {
if (!thread_border_router_local_srv_data_in_network_data_check(cur)) {
tr_info("nwk data mismatch - resubmit");
thread_border_router_publish(cur->id);
}
}
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
this->nwk_data_resubmit_timer = 0;
if (cur) {
if (!thread_border_router_local_srv_data_in_network_data_check(cur)) {
tr_info("nwk data mismatch - resubmit");
thread_border_router_publish(cur->id);
}
}
}
}
}
@ -554,7 +554,7 @@ void thread_border_router_resubmit_timer_set(int8_t interface_id, int16_t second
this->nwk_data_resubmit_timer = seconds;
} else {
// re-init network data resubmit timer to default value
this->nwk_data_resubmit_timer = THREAD_DATA_RESUBMIT_DELAY + randLIB_get_random_in_range(0, THREAD_DATA_RESUBMIT_DELAY/10);
this->nwk_data_resubmit_timer = THREAD_DATA_RESUBMIT_DELAY + randLIB_get_random_in_range(0, THREAD_DATA_RESUBMIT_DELAY / 10);
}
}
@ -619,7 +619,7 @@ int thread_border_router_prefix_add(int8_t interface_id, uint8_t *prefix_ptr, ui
if (!prefix_info_ptr || !prefix_ptr) {
return -2;
}
if(prefix_info_ptr->P_dhcp == true && prefix_info_ptr->P_slaac == true) {
if (prefix_info_ptr->P_dhcp == true && prefix_info_ptr->P_slaac == true) {
return -3;// Can not configure both services on
}
@ -857,7 +857,7 @@ static void thread_tmf_client_network_data_set_cb(int8_t interface_id, int8_t st
cur->thread_info->localServerDataBase.publish_coap_req_id = 0;
tr_debug("BR a/sd response status: %s, addr: %x",status?"Fail":"OK", cur->thread_info->localServerDataBase.registered_rloc16);
tr_debug("BR a/sd response status: %s, addr: %x", status ? "Fail" : "OK", cur->thread_info->localServerDataBase.registered_rloc16);
if (cur->thread_info->localServerDataBase.publish_pending) {
cur->thread_info->localServerDataBase.publish_pending = false;
@ -928,7 +928,7 @@ int thread_border_router_publish(int8_t interface_id)
cur->thread_info->localServerDataBase.registered_rloc16 != rloc16) {
// Our address has changed so we must register our network with new address and remove the old address
tr_debug("BR address changed - remove old %x", cur->thread_info->localServerDataBase.registered_rloc16);
ptr = thread_tmfcop_tlv_data_write_uint16(ptr,TMFCOP_TLV_RLOC16,cur->thread_info->localServerDataBase.registered_rloc16);
ptr = thread_tmfcop_tlv_data_write_uint16(ptr, TMFCOP_TLV_RLOC16, cur->thread_info->localServerDataBase.registered_rloc16);
}
cur->thread_info->localServerDataBase.registered_rloc16 = rloc16;
@ -975,7 +975,7 @@ int thread_border_router_delete_all(int8_t interface_id)
#endif
}
int thread_border_router_network_data_callback_register(int8_t interface_id, thread_network_data_tlv_cb* nwk_data_cb)
int thread_border_router_network_data_callback_register(int8_t interface_id, thread_network_data_tlv_cb *nwk_data_cb)
{
#ifdef HAVE_THREAD
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
@ -999,7 +999,7 @@ int thread_border_router_network_data_callback_register(int8_t interface_id, thr
#endif
}
int thread_border_router_prefix_tlv_find(uint8_t* network_data_tlv, uint16_t network_data_tlv_length, uint8_t** prefix_tlv, bool *stable)
int thread_border_router_prefix_tlv_find(uint8_t *network_data_tlv, uint16_t network_data_tlv_length, uint8_t **prefix_tlv, bool *stable)
{
#ifdef HAVE_THREAD
uint16_t tlv_length;
@ -1008,7 +1008,7 @@ int thread_border_router_prefix_tlv_find(uint8_t* network_data_tlv, uint16_t net
}
//tr_debug("thread_tlv_lib_prefix_find() len=%d, tlv=%s", network_data_tlv_length, trace_array(network_data_tlv, network_data_tlv_length));
*stable = true;
tlv_length = thread_meshcop_tlv_find_next(network_data_tlv, network_data_tlv_length, THREAD_NWK_DATA_TYPE_PREFIX|THREAD_NWK_STABLE_DATA, prefix_tlv);
tlv_length = thread_meshcop_tlv_find_next(network_data_tlv, network_data_tlv_length, THREAD_NWK_DATA_TYPE_PREFIX | THREAD_NWK_STABLE_DATA, prefix_tlv);
if (tlv_length == 0) {
tlv_length = thread_meshcop_tlv_find_next(network_data_tlv, network_data_tlv_length, THREAD_NWK_DATA_TYPE_PREFIX, prefix_tlv);
*stable = false;
@ -1023,7 +1023,7 @@ int thread_border_router_prefix_tlv_find(uint8_t* network_data_tlv, uint16_t net
#endif
}
int thread_border_router_tlv_find(uint8_t* prefix_tlv, uint16_t prefix_tlv_length, uint8_t** border_router_tlv, bool *stable)
int thread_border_router_tlv_find(uint8_t *prefix_tlv, uint16_t prefix_tlv_length, uint8_t **border_router_tlv, bool *stable)
{
#ifdef HAVE_THREAD
uint16_t tlv_length;
@ -1039,7 +1039,7 @@ int thread_border_router_tlv_find(uint8_t* prefix_tlv, uint16_t prefix_tlv_lengt
// find stable prefix first and if not found return unstable data
*stable = true;
tlv_length = thread_meshcop_tlv_find_next(prefix_tlv, prefix_tlv_length, THREAD_NWK_DATA_TYPE_BORDER_ROUTER|THREAD_NWK_STABLE_DATA, border_router_tlv);
tlv_length = thread_meshcop_tlv_find_next(prefix_tlv, prefix_tlv_length, THREAD_NWK_DATA_TYPE_BORDER_ROUTER | THREAD_NWK_STABLE_DATA, border_router_tlv);
if (tlv_length == 0) {
tlv_length = thread_meshcop_tlv_find_next(prefix_tlv, prefix_tlv_length, THREAD_NWK_DATA_TYPE_BORDER_ROUTER, border_router_tlv);
*stable = false;
@ -1086,7 +1086,7 @@ int thread_border_router_prefix_context_id(uint8_t *prefix_tlv, uint16_t prefix_
#endif
}
int thread_border_router_service_tlv_find(uint8_t* network_data_tlv, uint16_t network_data_tlv_length, uint8_t** service_tlv, bool* stable)
int thread_border_router_service_tlv_find(uint8_t *network_data_tlv, uint16_t network_data_tlv_length, uint8_t **service_tlv, bool *stable)
{
#ifdef HAVE_THREAD
uint16_t tlv_length;
@ -1095,7 +1095,7 @@ int thread_border_router_service_tlv_find(uint8_t* network_data_tlv, uint16_t ne
}
*stable = true;
tlv_length = thread_meshcop_tlv_find_next(network_data_tlv, network_data_tlv_length, THREAD_NWK_DATA_TYPE_SERVICE_DATA|THREAD_NWK_STABLE_DATA, service_tlv);
tlv_length = thread_meshcop_tlv_find_next(network_data_tlv, network_data_tlv_length, THREAD_NWK_DATA_TYPE_SERVICE_DATA | THREAD_NWK_STABLE_DATA, service_tlv);
if (tlv_length == 0) {
tlv_length = thread_meshcop_tlv_find_next(network_data_tlv, network_data_tlv_length, THREAD_NWK_DATA_TYPE_SERVICE_DATA, service_tlv);
*stable = false;
@ -1110,7 +1110,7 @@ int thread_border_router_service_tlv_find(uint8_t* network_data_tlv, uint16_t ne
#endif
}
int thread_border_router_server_tlv_find(uint8_t* service_tlv, uint16_t service_tlv_length, uint8_t** server_tlv, bool* stable)
int thread_border_router_server_tlv_find(uint8_t *service_tlv, uint16_t service_tlv_length, uint8_t **server_tlv, bool *stable)
{
#ifdef HAVE_THREAD
uint16_t tlv_length;
@ -1131,7 +1131,7 @@ int thread_border_router_server_tlv_find(uint8_t* service_tlv, uint16_t service_
service_tlv_length = service_tlv_length - service_data_len - 2;
*stable = true;
tlv_length = thread_meshcop_tlv_find_next(service_tlv, service_tlv_length, THREAD_NWK_DATA_TYPE_SERVER_DATA|THREAD_NWK_STABLE_DATA, server_tlv);
tlv_length = thread_meshcop_tlv_find_next(service_tlv, service_tlv_length, THREAD_NWK_DATA_TYPE_SERVER_DATA | THREAD_NWK_STABLE_DATA, server_tlv);
if (tlv_length == 0) {
tlv_length = thread_meshcop_tlv_find_next(service_tlv, service_tlv_length, THREAD_NWK_DATA_TYPE_SERVER_DATA, server_tlv);
*stable = false;

View File

@ -95,7 +95,7 @@ typedef struct commissioner_entry {
static NS_LIST_DEFINE(instance_list, commissioner_t, link);
const uint8_t any_device[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
const uint8_t any_device[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
/*
* Commissioned device handlers;
@ -144,7 +144,7 @@ static device_t *device_find_by_iid(commissioner_t *commissioner_ptr, uint8_t II
return NULL;
}
ns_list_foreach(device_t, cur_ptr, &commissioner_ptr->device_list) {
tr_debug("device iid %s and commissioner iid %s", trace_array(cur_ptr->IID,8),trace_array(IID,8));
tr_debug("device iid %s and commissioner iid %s", trace_array(cur_ptr->IID, 8), trace_array(IID, 8));
if (memcmp(cur_ptr->IID, IID, 8) == 0) {
this = cur_ptr;
break;
@ -231,7 +231,7 @@ static int commission_finalisation_resp_send(int8_t coap_service_id, device_t *d
ptr = payload;
ptr = thread_meshcop_tlv_data_write_uint8(ptr, MESHCOP_TLV_STATE, (uint8_t)commissioning_meshcop_map_state(state));
thci_trace("Device - Comm|Direction - sent|EUI - %s|Type - JOIN_FIN.resp|Length - %d|Payload - %s",trace_array(device_ptr->EUI64,8), (int)(ptr - payload), trace_array(payload, ptr - payload));
thci_trace("Device - Comm|Direction - sent|EUI - %s|Type - JOIN_FIN.resp|Length - %d|Payload - %s", trace_array(device_ptr->EUI64, 8), (int)(ptr - payload), trace_array(payload, ptr - payload));
tr_debug("finalisation response send state:%d value:%d ", state, (uint8_t)commissioning_meshcop_map_state(state));
coap_service_response_send(coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, payload, ptr - payload);
return 0;
@ -284,7 +284,7 @@ static int commissioning_leader_petition_recv_cb(int8_t service_id, uint8_t sour
(void) source_address;
(void) source_port;
tr_debug("Thread Petition response received service %d",service_id);
tr_debug("Thread Petition response received service %d", service_id);
if (!this) {
return -1;
}
@ -303,14 +303,14 @@ static int commissioning_leader_petition_recv_cb(int8_t service_id, uint8_t sour
this->registered = true;
//@TODO order keep alive timer for the message and start sending it periodically
}
tr_debug("petition response session_id: %d state:%d",session_id, state);
tr_debug("petition response session_id: %d state:%d", session_id, state);
// if registered and native commissioner send ACTIVE_GET to BBR to get mesh parameters
// if not native set leader ALOC from stack
if (this->native_commissioner) {
coap_service_request_send(service_id, COAP_REQUEST_OPTIONS_NONE, this->destination_address, this->destination_port,
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, uri_ptr, COAP_CT_OCTET_STREAM, NULL, 0, thread_commissioning_active_get_cb);
return 0;
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, uri_ptr, COAP_CT_OCTET_STREAM, NULL, 0, thread_commissioning_active_get_cb);
return 0;
} else {
thread_management_get_leader_aloc(this->interface_id, this->leader_address);
}
@ -375,8 +375,8 @@ static int commission_finalisation_req_recv_cb(int8_t service_id, uint8_t source
if (device_ptr) {
ret = 0; // accept even without application confirmation
}
thci_trace("Device - Comm|Direction - recv|EUI - %s|Type - JOIN_FIN.req|Length - %d|Payload - %s",trace_array(device_ptr->EUI64,8), request_ptr->payload_len, trace_array(request_ptr->payload_ptr, request_ptr->payload_len));
memcpy(address,source_address,16);
thci_trace("Device - Comm|Direction - recv|EUI - %s|Type - JOIN_FIN.req|Length - %d|Payload - %s", trace_array(device_ptr->EUI64, 8), request_ptr->payload_len, trace_array(request_ptr->payload_ptr, request_ptr->payload_len));
memcpy(address, source_address, 16);
if (device_ptr) {
if (device_ptr->joining_device_cb_ptr) {
@ -408,12 +408,12 @@ static int commission_application_provision_req_recv_cb(int8_t service_id, uint8
return -1;
}
thci_trace("Device - Comm|Direction - recv|EUI - %s|Type - JOIN_APP.req|Length - %d|Payload - %s",trace_array(&source_address[8],8), request_ptr->payload_len, trace_array(request_ptr->payload_ptr, request_ptr->payload_len));
thci_trace("Device - Comm|Direction - recv|EUI - %s|Type - JOIN_APP.req|Length - %d|Payload - %s", trace_array(&source_address[8], 8), request_ptr->payload_len, trace_array(request_ptr->payload_ptr, request_ptr->payload_len));
ptr = payload;
ptr = thread_meshcop_tlv_data_write_uint8(ptr, MESHCOP_TLV_STATE, 1);
thci_trace("Device - Comm|Direction - sent|EUI - %s|Type - JOIN_APP.resp|Length - %d|Payload - %s",trace_array(&source_address[8],8), (int)(ptr - payload), trace_array(payload, ptr - payload));
thci_trace("Device - Comm|Direction - sent|EUI - %s|Type - JOIN_APP.resp|Length - %d|Payload - %s", trace_array(&source_address[8], 8), (int)(ptr - payload), trace_array(payload, ptr - payload));
coap_service_response_send(service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, payload, ptr - payload);
return 0;
}
@ -431,7 +431,7 @@ static int commission_dataset_changed_notify_recv_cb(int8_t service_id, uint8_t
}
coap_service_request_send(service_id, COAP_REQUEST_OPTIONS_NONE, this->destination_address, this->destination_port,
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_ACTIVE_GET, COAP_CT_OCTET_STREAM, NULL, 0, thread_commissioning_active_get_cb);
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_ACTIVE_GET, COAP_CT_OCTET_STREAM, NULL, 0, thread_commissioning_active_get_cb);
coap_service_response_send(service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_NONE, NULL, 0);
@ -473,20 +473,16 @@ static int thread_commission_udp_proxy_receive_cb(int8_t service_id, uint8_t sou
return -1; // no response sent
}
static uint8_t *bloom_filter_calculate(uint8_t *bloom_filter_ptr,device_list_t device_list, int *steering_tlv_max_length)
static uint8_t *bloom_filter_calculate(uint8_t *bloom_filter_ptr, device_list_t device_list, int *steering_tlv_max_length)
{
memset(bloom_filter_ptr,0,*steering_tlv_max_length);
ns_list_foreach(device_t, cur_ptr, &device_list)
{
if (memcmp(cur_ptr->EUI64, any_device, 8) != 0)
{
tr_debug("eui64 used on commissioning side = %s",trace_array(cur_ptr->EUI64,8));
memset(bloom_filter_ptr, 0, *steering_tlv_max_length);
ns_list_foreach(device_t, cur_ptr, &device_list) {
if (memcmp(cur_ptr->EUI64, any_device, 8) != 0) {
tr_debug("eui64 used on commissioning side = %s", trace_array(cur_ptr->EUI64, 8));
cur_ptr->IID[0] |= 2; //Changed IID to MAC extended address for bloom filter calculation
thread_beacon_calculate_bloom_filter(bloom_filter_ptr,*steering_tlv_max_length,cur_ptr->IID, 8);
thread_beacon_calculate_bloom_filter(bloom_filter_ptr, *steering_tlv_max_length, cur_ptr->IID, 8);
cur_ptr->IID[0] &= ~2;//Restore IID
}
else
{
} else {
bloom_filter_ptr[0] = 0xff;
*steering_tlv_max_length = 1;
break;
@ -509,7 +505,7 @@ static int thread_commissioner_set_steering_data(commissioner_t *this, uint16_t
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MESHCOP_TLV_COMMISSIONER_SESSION_ID, session_id);
tr_debug("thread commissioner set steering data %s", trace_array(steering_data_ptr, steering_data_len));
memcpy(this->final_dest_address, this->leader_address,16);
memcpy(this->final_dest_address, this->leader_address, 16);
//default uri for thread version 1.1
char *uri = THREAD_URI_COMMISSIONER_SET;
@ -535,7 +531,7 @@ static int commission_steering_data_update(commissioner_t *this)
//bloom filter calculation function call
bloom_filter_calculate(bloom_filter_ptr, this->device_list, &steering_tlv_length);
tr_debug("Steering bloom set :%s", trace_array(bloom_filter_ptr, 16));
ret = thread_commissioner_set_steering_data(this, this->session_id,bloom_filter_ptr, steering_tlv_length);
ret = thread_commissioner_set_steering_data(this, this->session_id, bloom_filter_ptr, steering_tlv_length);
if (ret) {
tr_warn("Steering data set failed %d", ret);
return -1;
@ -581,7 +577,7 @@ static int commission_relay_rx_recv_cb(int8_t service_id, uint8_t source_address
if (!device_ptr) {
tr_warn("unknown device connected");
//Interop HACK
device_ptr = device_find(this, (uint8_t*)any_device);
device_ptr = device_find(this, (uint8_t *)any_device);
if (!device_ptr) {
tr_warn("No catch all device added");
return -1;
@ -630,12 +626,12 @@ static int commission_virtual_socket_send_cb(int8_t service_id, uint8_t destinat
if (!payload_ptr) {
return -3;
}
if (this->native_commissioner){
if (this->native_commissioner) {
destination_service_id = this->coap_secure_service_id;
memcpy(destination_address,this->destination_address,16);
memcpy(destination_address, this->destination_address, 16);
destination_port = this->destination_port;
} else {
memset(destination_address,0,16);
memset(destination_address, 0, 16);
destination_service_id = this->coap_service_id;
thread_management_get_ml_prefix(this->interface_id, destination_address);
common_write_16_bit(0xfffe, &destination_address[11]);
@ -700,8 +696,8 @@ static int joiner_commissioner_security_start_cb(int8_t service_id, uint8_t addr
device_t *device_ptr = device_find_by_iid(this, &address[8]);
if( device_ptr ){
memcpy(pw, device_ptr->PSKd, device_ptr->PSKd_len );
if (device_ptr) {
memcpy(pw, device_ptr->PSKd, device_ptr->PSKd_len);
*pw_len = device_ptr->PSKd_len;
ret = 0;
// ret = coap_service_security_key_set( service_id, address, port, device_ptr->PSKd, device_ptr->PSKd_len );
@ -717,8 +713,8 @@ static int commissioner_br_security_start_cb(int8_t service_id, uint8_t address[
(void)port;
tr_info("commissionerBrDtlsSessionStarted");
commissioner_t *this = commissioner_find_by_service(service_id);
if(this){
memcpy(pw, this->PSKc_ptr, 16 );
if (this) {
memcpy(pw, this->PSKc_ptr, 16);
*pw_len = 16;
ret = 0;
// ret = coap_service_security_key_set( service_id, address, port, this->PSKc_ptr, this->PSKc_len );
@ -765,7 +761,7 @@ static int thread_commission_udp_proxy_virtual_socket_send_cb(int8_t service_id,
ptr = payload_ptr;
tr_debug("br_address %s final dest_address %s and port %d", trace_ipv6(this->destination_address),
trace_ipv6(this->final_dest_address), this->destination_port);
trace_ipv6(this->final_dest_address), this->destination_port);
/* MESHCOP_TLV_IPV6_ADDRESS */
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_IPV6_ADDRESS, THREAD_IPV6_ADDRESS_TLV_LENGTH, this->final_dest_address);
@ -782,7 +778,7 @@ static int thread_commission_udp_proxy_virtual_socket_send_cb(int8_t service_id,
/* Send UDP_TX.ntf */
coap_service_request_send(this->coap_secure_service_id, COAP_REQUEST_OPTIONS_NONE, this->destination_address, this->destination_port,
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_UDP_TRANSMIT_NOTIFICATION, COAP_CT_OCTET_STREAM, payload_ptr, ptr - payload_ptr, NULL);
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_UDP_TRANSMIT_NOTIFICATION, COAP_CT_OCTET_STREAM, payload_ptr, ptr - payload_ptr, NULL);
ns_dyn_mem_free(payload_ptr);
@ -795,13 +791,13 @@ Public api functions
int thread_commissioning_register(int8_t interface_id, uint8_t PSKc[static 16])
{
commissioner_t *this = commissioner_find(interface_id);
if (!this) {
this = commissioner_create(interface_id);
if (!this) {
this = commissioner_create(interface_id);
}
if (!this) {
return -2;
}
memcpy(this->PSKc_ptr,PSKc,16);
memcpy(this->PSKc_ptr, PSKc, 16);
if (this->registered) {
return 0;
}
@ -880,7 +876,7 @@ int thread_commissioning_petition_start(int8_t interface_id, char *commissioner_
ptr = payload;
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_COMMISSIONER_ID, commissioner_id_length, (uint8_t *) commissioner_id_ptr);
tr_debug("Thread Petition send to %s:%d id %s ", trace_ipv6(this->destination_address),this->destination_port, commissioner_id_ptr);
tr_debug("Thread Petition send to %s:%d id %s ", trace_ipv6(this->destination_address), this->destination_port, commissioner_id_ptr);
//TODO there must be way to set PSKc for request
//TODO there must be way to make client transactions with security and no security
@ -941,7 +937,7 @@ int thread_commissioning_device_add(int8_t interface_id, bool short_eui64, uint8
device_t *device_ptr = NULL;
this = commissioner_find(interface_id);
if (!this || PSKd_len < 1 || PSKd_len > 32 || !PSKd_ptr ) {
if (!this || PSKd_len < 1 || PSKd_len > 32 || !PSKd_ptr) {
return -1;
}
@ -965,7 +961,7 @@ int thread_commissioning_device_add(int8_t interface_id, bool short_eui64, uint8
}
memcpy(device_ptr->EUI64, EUI64, 8);
if (memcmp(EUI64, any_device, 8) != 0){
if (memcmp(EUI64, any_device, 8) != 0) {
ns_sha256_nbits(EUI64, 8, device_ptr->IID, 64);
device_ptr->IID[0] &= ~2; //local administered bit is set in MAC and flipped in IID
} else {
@ -1008,17 +1004,27 @@ void *thread_commission_device_get_next(void *ptr, int8_t interface_id, bool *sh
if (!this) {
return NULL;
}
device_t *cur_ptr = (device_t*)ptr;
if(cur_ptr == NULL) {
cur_ptr = (device_t*)ns_list_get_first(&this->device_list);
device_t *cur_ptr = (device_t *)ptr;
if (cur_ptr == NULL) {
cur_ptr = (device_t *)ns_list_get_first(&this->device_list);
} else {
cur_ptr = (device_t*)ns_list_get_next(&this->device_list, cur_ptr);
cur_ptr = (device_t *)ns_list_get_next(&this->device_list, cur_ptr);
}
if (!cur_ptr) {
return NULL;
}
if (short_eui64) {
*short_eui64 = cur_ptr->short_eui64;
}
if (EUI64) {
memcpy(EUI64, cur_ptr->EUI64, 8);
}
if (PSKd) {
memcpy(PSKd, cur_ptr->PSKd, 32);
}
if (PSKd_len) {
*PSKd_len = cur_ptr->PSKd_len;
}
if(!cur_ptr) return NULL;
if(short_eui64) *short_eui64 = cur_ptr->short_eui64;
if(EUI64) memcpy(EUI64, cur_ptr->EUI64, 8);
if(PSKd) memcpy(PSKd, cur_ptr->PSKd, 32);
if(PSKd_len) *PSKd_len = cur_ptr->PSKd_len;
return cur_ptr;
}
@ -1030,7 +1036,7 @@ int thread_commissioning_attach(int8_t interface_id, uint8_t *destination_addres
if (!this) {
return -1;
}
memcpy(this->destination_address, destination_address,16);
memcpy(this->destination_address, destination_address, 16);
this->destination_port = destination_port;
this->native_commissioner = true;
return 0;
@ -1042,7 +1048,7 @@ int thread_commissioning_native_commissioner_start(int8_t interface_id, thread_c
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
tr_debug("start native commissioner scanning");
if(!cur || !cur->thread_info) {
if (!cur || !cur->thread_info) {
return -1;
}
cur->thread_info->native_commissioner_link = NULL;
@ -1057,7 +1063,7 @@ int thread_commissioning_native_commissioner_stop(int8_t interface_id)
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
tr_debug("stop native commissioner scanning");
if(!cur || !cur->thread_info) {
if (!cur || !cur->thread_info) {
return -1;
}
ns_dyn_mem_free(cur->thread_info->native_commissioner_link);
@ -1071,11 +1077,11 @@ int thread_commissioning_native_commissioner_connect(int8_t interface_id, thread
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
tr_debug("connect native commissioner");
if(!cur || !cur->thread_info) {
if (!cur || !cur->thread_info) {
return -1;
}
cur->thread_info->native_commissioner_link = ns_dyn_mem_alloc(sizeof(thread_commissioning_link_configuration_s));
if(!cur->thread_info->native_commissioner_link) {
if (!cur->thread_info->native_commissioner_link) {
return -2;
}
*cur->thread_info->native_commissioner_link = *link_ptr;
@ -1089,7 +1095,7 @@ int thread_commissioning_native_commissioner_connect(int8_t interface_id, thread
}
this->native_commissioner = true;
memcpy(this->destination_address, link_ptr->destination_address,16);
memcpy(this->destination_address, link_ptr->destination_address, 16);
this->destination_port = link_ptr->destination_port;
//TODO check that we are scanning for networks and reset backup timers
@ -1104,7 +1110,7 @@ int thread_commissioning_native_commissioner_get_connection_info(int8_t interfac
return -1;
}
memcpy(address_ptr,this->destination_address,16);
memcpy(address_ptr, this->destination_address, 16);
*port = this->destination_port;
return 0;
@ -1122,7 +1128,8 @@ int8_t thread_commissioning_get_management_id(int8_t interface_id)
#else
int thread_commissioning_register(int8_t interface_id, uint8_t PSKc[static 16]) {
int thread_commissioning_register(int8_t interface_id, uint8_t PSKc[static 16])
{
(void)interface_id;
(void)PSKc;
return -1;
@ -1177,36 +1184,42 @@ int thread_commissioning_petition_start(int8_t interface_id, char *commissioner_
return -1;
}
int thread_commissioning_native_commissioner_get_connection_info(int8_t interface_id, uint8_t *address_ptr, uint16_t *port) {
int thread_commissioning_native_commissioner_get_connection_info(int8_t interface_id, uint8_t *address_ptr, uint16_t *port)
{
(void)interface_id;
(void)address_ptr;
(void)port;
return -1;
}
int8_t thread_commissioning_get_management_id(int8_t interface_id) {
int8_t thread_commissioning_get_management_id(int8_t interface_id)
{
(void)interface_id;
return -1;
}
int thread_commissioning_native_commissioner_start(int8_t interface_id, thread_commissioning_native_select_cb *cb_ptr) {
int thread_commissioning_native_commissioner_start(int8_t interface_id, thread_commissioning_native_select_cb *cb_ptr)
{
(void)interface_id;
(void)cb_ptr;
return -1;
}
int thread_commissioning_native_commissioner_stop(int8_t interface_id) {
int thread_commissioning_native_commissioner_stop(int8_t interface_id)
{
(void)interface_id;
return -1;
}
int thread_commissioning_native_commissioner_connect(int8_t interface_id, thread_commissioning_link_configuration_s *link_ptr) {
int thread_commissioning_native_commissioner_connect(int8_t interface_id, thread_commissioning_link_configuration_s *link_ptr)
{
(void)interface_id;
(void)link_ptr;
return -1;
}
int thread_commissioning_attach(int8_t interface_id, uint8_t *destination_address, uint16_t destination_port) {
int thread_commissioning_attach(int8_t interface_id, uint8_t *destination_address, uint16_t destination_port)
{
(void)interface_id;
(void)destination_address;
(void)destination_port;

View File

@ -71,7 +71,7 @@ int thread_commissioning_if_pairwise_key_add(int8_t interface_id, uint32_t valid
int thread_commissioning_if_pairwise_key_del(int8_t interface_id, uint8_t eui64[static 8])
{
int ret;
if (!eui64 ) {
if (!eui64) {
return -1;
}
tr_debug("pairwise key delete interface:%d, iid: %s", interface_id, trace_array(eui64, 8));
@ -117,7 +117,7 @@ int thread_commissioning_if_enable_security(int8_t interface_id)
}
cur->mac_parameters->mac_configured_sec_level = SEC_ENC_MIC32;
mac_helper_default_security_level_set(cur, cur->mac_parameters->mac_configured_sec_level);
mac_helper_default_security_key_id_mode_set(cur,MAC_KEY_ID_MODE_IDX);
mac_helper_default_security_key_id_mode_set(cur, MAC_KEY_ID_MODE_IDX);
return 0;
}

View File

@ -107,8 +107,8 @@ uint8_t thread_version = THREAD_PROTOCOL_VERSION;
thread_leader_data_t *thread_leader_data_generate(void);
thread_parent_info_t *thread_parent_data_allocate(thread_info_t *info);
static uint8_t * thread_joining_port_tlv_write(uint16_t port, uint8_t *ptr);
static uint8_t * thread_commissioner_port_tlv_write(uint16_t port, uint8_t *ptr);
static uint8_t *thread_joining_port_tlv_write(uint16_t port, uint8_t *ptr);
static uint8_t *thread_commissioner_port_tlv_write(uint16_t port, uint8_t *ptr);
static void thread_tx_failure_handler(int8_t nwk_id, uint8_t accumulated_failures, uint8_t attribute_index);
static void thread_address_notification_cb(struct protocol_interface_info_entry *interface, const struct if_address_entry *addr, if_address_callback_t reason);
@ -185,7 +185,7 @@ uint8_t *thread_management_key_request_with_sequence(int8_t interface_id, uint8_
}
return keyPtr;
}
uint8_t * thread_mle_service_security_notify_cb(int8_t interface_id, mle_security_event_t event, uint8_t keyId)
uint8_t *thread_mle_service_security_notify_cb(int8_t interface_id, mle_security_event_t event, uint8_t keyId)
{
(void)keyId;
protocol_interface_info_entry_t *interface = protocol_stack_interface_info_get_by_id(interface_id);
@ -248,13 +248,13 @@ int8_t thread_bootstrap_down(protocol_interface_info_entry_t *cur)
// store frame counters
if (cur->thread_info) {
thread_nvm_fast_data_t fast_data;
memset(&fast_data,0,sizeof(thread_nvm_fast_data_t));
memset(&fast_data, 0, sizeof(thread_nvm_fast_data_t));
link_configuration_s *linkConfiguration = thread_joiner_application_get_config(cur->id);
if(linkConfiguration) {
if (linkConfiguration) {
fast_data.seq_counter = linkConfiguration->key_sequence;
}
mac_helper_link_frame_counter_read(cur->id, &fast_data.mac_frame_counter);
fast_data.mle_frame_counter=mle_service_security_get_frame_counter(cur->id);
fast_data.mle_frame_counter = mle_service_security_get_frame_counter(cur->id);
thread_nvm_store_fast_data_write(&fast_data);
thread_joiner_application_configuration_nvm_save(cur->id);
mac_pairwise_key_flush_list(cur->id);
@ -395,7 +395,7 @@ thread_leader_data_t *thread_leader_data_generate(void)
thread_leader_data_t *leader_data;
leader_data = ns_dyn_mem_alloc(sizeof(thread_leader_data_t));
if (leader_data) {
memset(leader_data,0,sizeof(thread_leader_data_t));
memset(leader_data, 0, sizeof(thread_leader_data_t));
}
return leader_data;
}
@ -417,7 +417,7 @@ thread_parent_info_t *thread_parent_data_allocate(thread_info_t *info)
parent_data = info->thread_endnode_parent;
if (parent_data) {
memset(parent_data,0,sizeof(thread_parent_info_t));
memset(parent_data, 0, sizeof(thread_parent_info_t));
}
return parent_data;
}
@ -487,12 +487,12 @@ int thread_info_allocate_and_init(protocol_interface_info_entry_t *cur)
thread_routing_init(&cur->thread_info->routing);
thread_network_local_server_data_base_init(&cur->thread_info->localServerDataBase);
memset(&cur->thread_info->registered_commissioner,0,sizeof(thread_commissioner_t));
memset(&cur->thread_info->registered_commissioner, 0, sizeof(thread_commissioner_t));
thread_dynamic_reed_initialize(&cur->thread_info->routerSelectParameters);
thread_extension_allocate(cur);
ns_list_init(&cur->thread_info->childIdReqPending);
ns_list_init(&cur->thread_info->child_mcast_list);
if (!thread_leader_data_get(cur->thread_info)){
if (!thread_leader_data_get(cur->thread_info)) {
return -1;
}
} else {
@ -685,7 +685,7 @@ thread_mcast_child_t *thread_child_mcast_entry_find(thread_mcast_children_list_t
bool thread_stable_context_check(protocol_interface_info_entry_t *cur, buffer_t *buf)
{
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur),buf->dst_sa.address + 2 , buf->dst_sa.addr_type);
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), buf->dst_sa.address + 2, buf->dst_sa.addr_type);
if (entry && thread_addr_is_child(mac_helper_mac16_address_get(cur), entry->mac16)) {
/* Check if the child can handle only stable network data (e.g. sleepy device) */
@ -750,7 +750,7 @@ void thread_child_id_request_info_init(thread_pending_child_id_req_t *child_info
thread_pending_child_id_req_t *thread_child_id_request_allocate(void)
{
thread_pending_child_id_req_t *req = ns_dyn_mem_alloc(sizeof(thread_pending_child_id_req_t));
memset(req->eiid, 0 , 8);
memset(req->eiid, 0, 8);
thread_child_id_request_info_init(req);
return req;
}
@ -815,9 +815,9 @@ int thread_init(protocol_interface_info_entry_t *cur)
// set mle security - first allocate instance and then set security
mle_service_security_instance_allocate(cur->id);
if (mle_service_security_init(cur->id, 5,
0,
thread_management_key_request_with_sequence,
thread_mle_service_security_notify_cb) != 0) {
0,
thread_management_key_request_with_sequence,
thread_mle_service_security_notify_cb) != 0) {
tr_error("Mle Service security init Fail");
return -1;
}
@ -830,7 +830,7 @@ int thread_init(protocol_interface_info_entry_t *cur)
thread_leader_service_leader_data_free(cur->thread_info);
thread_data_base_init(cur->thread_info, cur->id);
mac_helper_pib_boolean_set(cur,macThreadForceLongAddressForBeacon , true);
mac_helper_pib_boolean_set(cur, macThreadForceLongAddressForBeacon, true);
mac_helper_mac16_address_set(cur, 0xffff);
return 0;
}
@ -845,7 +845,7 @@ int thread_attach_ready(protocol_interface_info_entry_t *cur)
case THREAD_STATE_CONNECTED:
case THREAD_STATE_CONNECTED_ROUTER:
return 0;
/* break; */
/* break; */
default:
break;
}
@ -855,7 +855,7 @@ int thread_attach_ready(protocol_interface_info_entry_t *cur)
bool thread_attach_active_router(protocol_interface_info_entry_t *cur)
{
if(cur->thread_info->thread_attached_state == THREAD_STATE_CONNECTED_ROUTER) {
if (cur->thread_info->thread_attached_state == THREAD_STATE_CONNECTED_ROUTER) {
return true;
}
@ -1005,13 +1005,13 @@ void thread_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t ticks)
if (thread_joiner_application_next_pending_config_exists(cur->id)) {
thread_management_get_leader_address(cur->id, leader_address);
thread_management_client_pending_set(cur->id, leader_address );
thread_management_client_pending_set(cur->id, leader_address);
thread_joiner_application_next_pending_config_delete(cur->id);
}
// Check if we need to make application provisioning
if (PROVISIONING_STATUS_NOT_DONE == thread_joiner_application_provisioning_get(cur->id) &&
thread_management_get_commissioner_address(cur->id, commissioner_address, &commissioner_port) == 0) {
thread_management_get_commissioner_address(cur->id, commissioner_address, &commissioner_port) == 0) {
// Provisioning not done and commissioner is present
thread_management_client_provision_request(cur->id, commissioner_address, commissioner_port);
}
@ -1019,7 +1019,7 @@ void thread_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t ticks)
// add more checks here when to become router
// If we are doing attach to new partition, do not upgrade
if(cur->nwk_bootstrap_state != ER_BOOTSRAP_DONE && cur->nwk_bootstrap_state != ER_MLE_ATTACH_READY) {
if (cur->nwk_bootstrap_state != ER_BOOTSRAP_DONE && cur->nwk_bootstrap_state != ER_MLE_ATTACH_READY) {
return;
}
@ -1046,14 +1046,14 @@ void thread_network_data_request_send(protocol_interface_info_entry_t *cur, uint
tr_debug("Send MLE network data request");
if(cur->thread_info->networkDataRequested){
if (cur->thread_info->networkDataRequested) {
tr_debug("Pending data request found");
return;
}
cur->thread_info->networkDataRequested = true;
thread_tlv_request(thread_info->interface_id, requestDstAddress,delaydTrig, &req_tlv, 1);
thread_tlv_request(thread_info->interface_id, requestDstAddress, delaydTrig, &req_tlv, 1);
}
void thread_timer(protocol_interface_info_entry_t *cur, uint8_t ticks)
@ -1098,7 +1098,7 @@ int8_t thread_beacon_create_payload(struct protocol_interface_info_entry *cur)
return -1;
}
if(!(leader_link_setup->securityPolicy & SECURITY_POLICY_BEACON_PAYLOAD_ENABLED)){
if (!(leader_link_setup->securityPolicy & SECURITY_POLICY_BEACON_PAYLOAD_ENABLED)) {
mac_helper_beacon_payload_reallocate(cur, 0);
return mac_helper_beacon_payload_register(cur);
}
@ -1115,7 +1115,7 @@ int8_t thread_beacon_create_payload(struct protocol_interface_info_entry *cur)
if (server_data.joiner_router_enabled) {
payload_len += 4/*Joiner UDP port*/;
}
if((leader_link_setup->securityPolicy & SECURITY_POLICY_NATIVE_COMMISSIONING_ALLOWED)){
if ((leader_link_setup->securityPolicy & SECURITY_POLICY_NATIVE_COMMISSIONING_ALLOWED)) {
payload_len += 4/*Commissioner UDP port*/;
}
@ -1130,7 +1130,7 @@ int8_t thread_beacon_create_payload(struct protocol_interface_info_entry *cur)
if (cur->thread_info->registered_commissioner.commissioner_valid && cur->thread_info->registered_commissioner.steering_data_len > 0) {
*ptr |= THREAD_BEACON_JOINING_PERMITTED_BIT; // permit join bit set on
}
if((leader_link_setup->securityPolicy & SECURITY_POLICY_NATIVE_COMMISSIONING_ALLOWED)){
if ((leader_link_setup->securityPolicy & SECURITY_POLICY_NATIVE_COMMISSIONING_ALLOWED)) {
*ptr |= THREAD_BEACON_NATIVE_COMMISSIONER_BIT;
}
ptr++;
@ -1143,13 +1143,13 @@ int8_t thread_beacon_create_payload(struct protocol_interface_info_entry *cur)
/* MESHCOP_TLV_JOINER_UDP_PORT */
ptr = thread_joining_port_tlv_write(server_data.joiner_router_port, ptr);
}
if((leader_link_setup->securityPolicy & SECURITY_POLICY_NATIVE_COMMISSIONING_ALLOWED)){
if ((leader_link_setup->securityPolicy & SECURITY_POLICY_NATIVE_COMMISSIONING_ALLOWED)) {
/* MESHCOP_TLV_COMMISSIONER_UDP_PORT */
ptr = thread_commissioner_port_tlv_write(server_data.commissioner_port, ptr);
}
if (cur->thread_info->registered_commissioner.commissioner_valid && cur->thread_info->registered_commissioner.steering_data_len > 0){
if (cur->thread_info->registered_commissioner.commissioner_valid && cur->thread_info->registered_commissioner.steering_data_len > 0) {
ptr = thread_nd_commission_data_write_steering_data(ptr, cur->thread_info->registered_commissioner.steering_data, cur->thread_info->registered_commissioner.steering_data_len);
}
@ -1223,7 +1223,8 @@ uint8_t *thread_route_option_write(protocol_interface_info_entry_t *cur, uint8_t
ptr, /* ptr to ID sequence (1 byte) */
ptr + 1, /* ptr to ID mask (MLE_ROUTE_ID_MASK_SIZE bytes) */
ptr + MLE_ROUTE_MIN_OPTION_LEN, /* ptr to router table data */
len_ptr) != 0) /* ptr to length */ { /* 0 -> SUCCESS */
len_ptr) != 0) { /* ptr to length */
/* 0 -> SUCCESS */
/* Point to beginning of buffer again */
ptr = saved_ptr;
} else {
@ -1244,11 +1245,11 @@ uint8_t *thread_connectivity_tlv_write(uint8_t *ptr, protocol_interface_info_ent
*ptr++ = 10;
// determine parent priority
if ((mode & MLE_DEV_MASK) == MLE_RFD_DEV && (3*mle_class_rfd_entry_count_get(cur) > 2*THREAD_MAX_MTD_CHILDREN)) {
if ((mode & MLE_DEV_MASK) == MLE_RFD_DEV && (3 * mle_class_rfd_entry_count_get(cur) > 2 * THREAD_MAX_MTD_CHILDREN)) {
*ptr++ = CONNECTIVITY_PP_LOW;
} else if (!(mode & MLE_RX_ON_IDLE) && (3*mle_class_sleepy_entry_count_get(cur) > 2*THREAD_MAX_SED_CHILDREN)) {
} else if (!(mode & MLE_RX_ON_IDLE) && (3 * mle_class_sleepy_entry_count_get(cur) > 2 * THREAD_MAX_SED_CHILDREN)) {
*ptr++ = CONNECTIVITY_PP_LOW;
} else if (3*thread_router_bootstrap_child_count_get(cur) > 2*thread->maxChildCount) {
} else if (3 * thread_router_bootstrap_child_count_get(cur) > 2 * thread->maxChildCount) {
// 1/3 of the child capacity remaining, PP=low
*ptr++ = CONNECTIVITY_PP_LOW;
} else if (mle_class_free_entry_count_get(cur) < THREAD_FREE_MLE_ENTRY_THRESHOLD) {
@ -1261,7 +1262,7 @@ uint8_t *thread_connectivity_tlv_write(uint8_t *ptr, protocol_interface_info_ent
ptr = thread_linkquality_write(cur->id, ptr);
// Route Cost To leader
if (thread->thread_attached_state == THREAD_STATE_CONNECTED_ROUTER){
if (thread->thread_attached_state == THREAD_STATE_CONNECTED_ROUTER) {
// Leader cost
*ptr++ = thread_routing_cost_get_by_router_id(&thread->routing, thread->thread_leader_data->leaderRouterId);
//Router ID sequence
@ -1281,7 +1282,7 @@ uint8_t *thread_connectivity_tlv_write(uint8_t *ptr, protocol_interface_info_ent
uint8_t activeRouters = 0;
if (cur->thread_info->leader_private_data) {
activeRouters = thread_routing_count_active_routers_from_mask(cur->thread_info->leader_private_data->master_router_id_mask);
} else if (thread->thread_device_mode == THREAD_DEVICE_MODE_ROUTER ) {
} else if (thread->thread_device_mode == THREAD_DEVICE_MODE_ROUTER) {
activeRouters = thread_routing_count_active_routers(&thread->routing);
}
*ptr++ = activeRouters;
@ -1347,7 +1348,7 @@ uint16_t thread_network_data_generate_stable_set(protocol_interface_info_entry_t
uint8_t *length_ptr = NULL;
length -= 2;
uint8_t prefix_bytes_len = prefixBits_to_bytes(*(dptr+1));
uint8_t prefix_bytes_len = prefixBits_to_bytes(*(dptr + 1));
if (prefix_bytes_len > length) {
return 0;
@ -1447,7 +1448,7 @@ uint16_t thread_network_data_generate_stable_set(protocol_interface_info_entry_t
}
} else if (type == THREAD_NWK_DATA_TYPE_SERVICE_DATA) {
uint8_t * length_ptr = NULL;
uint8_t *length_ptr = NULL;
uint16_t total_tlv_length = 0;
uint16_t copy_length = 1;
uint8_t T = (*dptr) >> 7;
@ -1460,7 +1461,7 @@ uint16_t thread_network_data_generate_stable_set(protocol_interface_info_entry_t
length -= 4;
}
uint16_t service_data_length = *(dptr+copy_length);
uint16_t service_data_length = *(dptr + copy_length);
if (result_ptr) {
*result_ptr++ = type | THREAD_NWK_STABLE_DATA;
@ -1609,7 +1610,7 @@ bool thread_active_operational_dataset_process(protocol_interface_info_entry_t *
uint64_t timestamp;
link_configuration_s *link_configuration;
if(!cur || !cur->thread_info || !ptr || !len){
if (!cur || !cur->thread_info || !ptr || !len) {
return false;
}
link_configuration = thread_joiner_application_get_config(cur->id);
@ -1630,15 +1631,15 @@ bool thread_active_operational_dataset_process(protocol_interface_info_entry_t *
tr_debug("Update Active dataset");
// New active operational dataset received;
thread_joiner_application_update_configuration(cur->id, ptr, len, false);
thread_joiner_application_active_timestamp_set(cur->id,dataset_timestamp);
thread_configuration_thread_activate(cur,link_configuration);
thread_joiner_application_active_timestamp_set(cur->id, dataset_timestamp);
thread_configuration_thread_activate(cur, link_configuration);
thread_joiner_application_configuration_nvm_save(cur->id);
return true;
}
uint8_t thread_pending_timestamp_tlv_size(protocol_interface_info_entry_t *cur)
{
if (!thread_joiner_application_pending_config_timestamp_get(cur->id) ) {
if (!thread_joiner_application_pending_config_timestamp_get(cur->id)) {
return 0;
}
return 2 + 8;
@ -1649,7 +1650,7 @@ uint8_t *thread_pending_timestamp_write(protocol_interface_info_entry_t *cur, ui
uint64_t pending_timestamp;
pending_timestamp = thread_joiner_application_pending_config_timestamp_get(cur->id);
if (!pending_timestamp ) {
if (!pending_timestamp) {
return ptr;
}
*ptr++ = MLE_TYPE_PENDING_TIMESTAMP;
@ -1689,33 +1690,33 @@ bool thread_pending_operational_dataset_process(protocol_interface_info_entry_t
{
uint32_t delay_timer;
if(!cur || !cur->thread_info ){
if (!cur || !cur->thread_info) {
return false;
}
tr_debug("process pending dataset");
if( !ptr || !len){
if (!ptr || !len) {
// No pending set received
return false;
}
if (4 > thread_meshcop_tlv_data_get_uint32(ptr, len,MESHCOP_TLV_DELAY_TIMER, &delay_timer)){
if (4 > thread_meshcop_tlv_data_get_uint32(ptr, len, MESHCOP_TLV_DELAY_TIMER, &delay_timer)) {
tr_warn("Delay timer not present");
return false;
}
if (mle_pending_timestamp < thread_joiner_application_pending_config_timestamp_get(cur->id) ) {
if (mle_pending_timestamp < thread_joiner_application_pending_config_timestamp_get(cur->id)) {
// Saving this config for later use first we get the current active
tr_debug("save pending set for future");
thread_joiner_application_next_pending_config_save(cur->id);
}
if( 0 != thread_joiner_application_pending_config_create(cur->id, ptr, len)){
if (0 != thread_joiner_application_pending_config_create(cur->id, ptr, len)) {
tr_error("pending set creation failed");
return false;
}
tr_debug("updating pending dataset");
thread_joiner_application_pending_config_timestamp_set(cur->id,mle_pending_timestamp);
thread_joiner_application_pending_config_enable(cur->id,delay_timer);
thread_joiner_application_pending_config_timestamp_set(cur->id, mle_pending_timestamp);
thread_joiner_application_pending_config_enable(cur->id, delay_timer);
return true;
}
@ -1756,7 +1757,7 @@ bool thread_addresses_needs_to_be_registered(protocol_interface_info_entry_t *cu
// check for addresses
ns_list_foreach(if_address_entry_t, e, &cur->ip_addresses) {
if (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_GLOBAL || (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_REALM_LOCAL
&& !thread_addr_is_mesh_local_16(e->address, cur))) {
&& !thread_addr_is_mesh_local_16(e->address, cur))) {
ctx = lowpan_context_get_by_address(&cur->lowpan_contexts, e->address);
if (!ctx) {
return true;
@ -1771,8 +1772,7 @@ bool thread_addresses_needs_to_be_registered(protocol_interface_info_entry_t *cu
// check for multicast groups
thread_bootstrap_all_nodes_address_generate(thread_realm_local_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_REALM_LOCAL);
thread_bootstrap_all_nodes_address_generate(thread_ll_unicast_prefix_based_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_LINK_LOCAL);
ns_list_foreach(if_group_entry_t, entry, &cur->ip_groups)
{
ns_list_foreach(if_group_entry_t, entry, &cur->ip_groups) {
if (!memcmp((entry->group), ADDR_MULTICAST_SOLICITED, 13)) {
/* Skip solicited node multicast address */
continue;
@ -1808,7 +1808,7 @@ uint8_t *thread_ml_address_tlv_write(uint8_t *ptr, protocol_interface_info_entry
uint8_t *address_len_ptr;
if (thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_SLEEPY_END_DEVICE &&
thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_END_DEVICE) {
thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_END_DEVICE) {
// No address registration for others than MED or SED
return ptr;
}
@ -1819,7 +1819,7 @@ uint8_t *thread_ml_address_tlv_write(uint8_t *ptr, protocol_interface_info_entry
ns_list_foreach(if_address_entry_t, e, &cur->ip_addresses) {
if (*address_len_ptr > 148 ) {
if (*address_len_ptr > 148) {
// Maximum length of address registrations
continue;
}
@ -1845,7 +1845,7 @@ uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_
uint8_t *address_len_ptr;
if (thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_SLEEPY_END_DEVICE &&
thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_END_DEVICE) {
thread_info(cur)->thread_device_mode != THREAD_DEVICE_MODE_END_DEVICE) {
// No address registration for others than MED or SED
return ptr;
}
@ -1856,12 +1856,12 @@ uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_
// Register all global addressess
ns_list_foreach(if_address_entry_t, e, &cur->ip_addresses) {
if (*address_len_ptr > 148 ) {
if (*address_len_ptr > 148) {
// Maximum length of address registrations
continue;
}
if (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_GLOBAL || (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_REALM_LOCAL
&& !thread_addr_is_mesh_local_16(e->address, cur))) {
&& !thread_addr_is_mesh_local_16(e->address, cur))) {
ctx = lowpan_context_get_by_address(&cur->lowpan_contexts, e->address);
if (ctx) {
//Write TLV to list
@ -1881,8 +1881,7 @@ uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_
/* Registers multicast addresses to the parent */
thread_bootstrap_all_nodes_address_generate(thread_realm_local_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_REALM_LOCAL);
thread_bootstrap_all_nodes_address_generate(thread_ll_unicast_prefix_based_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_LINK_LOCAL);
ns_list_foreach(if_group_entry_t, entry, &cur->ip_groups)
{
ns_list_foreach(if_group_entry_t, entry, &cur->ip_groups) {
if (*address_len_ptr > 148) {
// Maximum length of address registrations
continue;
@ -1950,7 +1949,7 @@ int thread_link_reject_send(protocol_interface_info_entry_t *interface, const ui
*ptr++ = 1;
*ptr++ = MLE_STATUS_ERROR;
if (mle_service_update_length_by_ptr(buf_id,ptr)!= 0) {
if (mle_service_update_length_by_ptr(buf_id, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
@ -1965,14 +1964,14 @@ int thread_link_reject_send(protocol_interface_info_entry_t *interface, const ui
}
static uint8_t * thread_joining_port_tlv_write(uint16_t port, uint8_t *ptr)
static uint8_t *thread_joining_port_tlv_write(uint16_t port, uint8_t *ptr)
{
*ptr++ = MESHCOP_TLV_JOINER_UDP_PORT;
*ptr++ = 2;
return common_write_16_bit(port, ptr);
}
static uint8_t * thread_commissioner_port_tlv_write(uint16_t port, uint8_t *ptr)
static uint8_t *thread_commissioner_port_tlv_write(uint16_t port, uint8_t *ptr)
{
*ptr++ = MESHCOP_TLV_COMMISSIONER_UDP_PORT;
*ptr++ = 2;
@ -1994,7 +1993,7 @@ static void thread_tx_failure_handler(int8_t nwk_id, uint8_t accumulated_failure
return;
}
if (accumulated_failures >= THREAD_MAC_TRANSMISSIONS*THREAD_FAILED_CHILD_TRANSMISSIONS) {
if (accumulated_failures >= THREAD_MAC_TRANSMISSIONS * THREAD_FAILED_CHILD_TRANSMISSIONS) {
mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), neighbor);
}
}
@ -2005,7 +2004,7 @@ void thread_reset_neighbour_info(protocol_interface_info_entry_t *cur, mac_neigh
thread_parent_info_t *thread_endnode_parent = thread_info(cur)->thread_endnode_parent;
if (!thread_i_am_router(cur) && thread_endnode_parent && thread_endnode_parent->shortAddress == neighbour->mac16) {
if(cur->nwk_bootstrap_state != ER_CHILD_ID_REQ) {
if (cur->nwk_bootstrap_state != ER_CHILD_ID_REQ) {
tr_warn("End device lost parent, reset!\n");
thread_bootstrap_connection_error(cur->id, CON_PARENT_CONNECT_DOWN, NULL);
}
@ -2020,14 +2019,17 @@ void thread_reset_neighbour_info(protocol_interface_info_entry_t *cur, mac_neigh
uint8_t thread_get_router_count_from_route_tlv(mle_tlv_info_t *routeTlv)
{
if (!routeTlv)
if (!routeTlv) {
return 0;
}
if (routeTlv->tlvLen < (MLE_ROUTE_ID_MASK_SIZE + 1))
if (routeTlv->tlvLen < (MLE_ROUTE_ID_MASK_SIZE + 1)) {
return 0;
}
if (!routeTlv->dataPtr)
if (!routeTlv->dataPtr) {
return 0;
}
return routeTlv->tlvLen - MLE_ROUTE_ID_MASK_SIZE - 1;
}
@ -2060,24 +2062,25 @@ static bool thread_mcast_should_register_address(struct protocol_interface_info_
{
uint8_t thread_realm_local_mcast_addr[16];
uint8_t thread_ll_unicast_prefix_based_mcast_addr[16];
if (addr_ipv6_multicast_scope(addr) < IPV6_SCOPE_LINK_LOCAL) {
return false;
}
if (memcmp(addr, ADDR_MULTICAST_SOLICITED, 13) == 0) {
return false;
}
if (memcmp(addr, ADDR_LINK_LOCAL_ALL_NODES, 16) == 0) {
return false;
}
if (memcmp(addr, ADDR_LINK_LOCAL_ALL_ROUTERS, 16) == 0) {
return false;
}
thread_bootstrap_all_nodes_address_generate(thread_realm_local_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_REALM_LOCAL);
if (memcmp(addr, thread_realm_local_mcast_addr, 16) == 0) {
return false;
}
thread_bootstrap_all_nodes_address_generate(thread_ll_unicast_prefix_based_mcast_addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, IPV6_SCOPE_LINK_LOCAL);
if (addr_ipv6_multicast_scope(addr) >= IPV6_SCOPE_LINK_LOCAL) {
if (memcmp(addr, ADDR_MULTICAST_SOLICITED, 13) == 0) {
return false;
}
if (memcmp(addr, thread_realm_local_mcast_addr, 16) == 0) {
return false;
}
if (memcmp(addr, thread_ll_unicast_prefix_based_mcast_addr, 16) == 0) {
return false;
}
if (memcmp(addr, ADDR_LINK_LOCAL_ALL_NODES, 16) == 0) {
return false;
}
if (memcmp(addr, ADDR_LINK_LOCAL_ALL_ROUTERS, 16) == 0) {
return false;
}
if (memcmp(addr, thread_ll_unicast_prefix_based_mcast_addr, 16) == 0) {
return false;
}
return true;
}
@ -2128,7 +2131,7 @@ bool thread_partition_match(protocol_interface_info_entry_t *cur, thread_leader_
{
if (thread_info(cur)->thread_leader_data) {
if ((thread_info(cur)->thread_leader_data->partitionId == leaderData->partitionId) &&
(thread_info(cur)->thread_leader_data->weighting == leaderData->weighting)) {
(thread_info(cur)->thread_leader_data->weighting == leaderData->weighting)) {
return true;
}
}

View File

@ -98,8 +98,8 @@ typedef struct thread_neigh_table_entry_s {
uint8_t mlEid[8];
uint32_t last_contact_time; /*!< monotonic time - hard to define "contact"; used for Thread Leasequery replies */
uint16_t link_margin;
bool secured_data_request:1;
bool request_full_data_set:1;
bool secured_data_request: 1;
bool request_full_data_set: 1;
} thread_neigh_table_entry_t ;
/**
@ -229,8 +229,8 @@ typedef struct thread_master_secret_material_s {
uint8_t historyKey[32];
uint32_t keySwitchGuardTimer;
uint32_t keyRotation;
bool historyKeyValid:1;
bool valid_Info:1;
bool historyKeyValid: 1;
bool valid_Info: 1;
uint8_t historyKeyId;
} thread_master_secret_material_t;
@ -243,7 +243,7 @@ typedef struct thread_commissioner {
uint16_t session_id; /* session_id is valid even if commissioner is not valid */
thread_commissioner_register_status_e commissioner_registration; /* Only for Leader */
uint8_t steering_data_len;
bool commissioner_valid:1;
bool commissioner_valid: 1;
} thread_commissioner_t;
typedef struct thread_announcement_s {
@ -328,8 +328,8 @@ typedef struct thread_info_s {
bool networkDataRequested: 1;
bool end_device_link_synch: 1;
bool router_mc_addrs_registered: 1;
bool link_sync_allowed:1;
bool leader_synced:1; // flag used by leader after restart
bool link_sync_allowed: 1;
bool leader_synced: 1; // flag used by leader after restart
} thread_info_t;
#ifdef HAVE_THREAD

View File

@ -241,8 +241,8 @@
* least one (1) 106-octet IPv6 datagram per attached SED".
*
* The defines below tell how many small (i.e. up to the big packet
* threshold) packets per sleepy child and big (i.e. over the big
* packet threshold) packets total we buffer in the indirect TX
* threshold) packets per sleepy child and big (i.e. over the big
* packet threshold) packets total we buffer in the indirect TX
* queue. The minimum values are 1 for both, but here we use larger
* value for better performance.
*/

View File

@ -64,7 +64,7 @@ static void thread_dhcp_address_prefer_remove_cb(int8_t interfaceId, uint8_t *ta
}
if (!targetAddress) {
//Clear All targets routes
ipv6_route_table_remove_info(interfaceId, ROUTE_THREAD_PROXIED_HOST,prefix_info);
ipv6_route_table_remove_info(interfaceId, ROUTE_THREAD_PROXIED_HOST, prefix_info);
} else {
tr_debug("Address Preferred Timeout");
ipv6_route_delete(targetAddress, 128, interfaceId, NULL, ROUTE_THREAD_PROXIED_HOST);
@ -87,9 +87,9 @@ static bool thread_dhcp_address_add_cb(int8_t interfaceId, dhcp_address_cache_up
thread_service_remove_GUA_from_neighcache(curPtr, address_info->allocatedAddress);
}
if (thread_bbr_nd_entry_add(interfaceId,address_info->allocatedAddress, address_info->validLifeTime, route_src) == -1) {
if (thread_bbr_nd_entry_add(interfaceId, address_info->allocatedAddress, address_info->validLifeTime, route_src) == -1) {
// No nanostack BBR present we will put entry for application implemented BBR
ipv6_route_t *route = ipv6_route_add_with_info(address_info->allocatedAddress, 128, interfaceId, NULL, ROUTE_THREAD_PROXIED_HOST,route_src,0, address_info->validLifeTime, 0);
ipv6_route_t *route = ipv6_route_add_with_info(address_info->allocatedAddress, 128, interfaceId, NULL, ROUTE_THREAD_PROXIED_HOST, route_src, 0, address_info->validLifeTime, 0);
if (!route) {
return false;
}

View File

@ -104,7 +104,7 @@ static uint8_t *thread_diagnostic_child_table_tlv_build(uint8_t *data_ptr, proto
*data_ptr++ = (3 * child_count); // Length
ns_list_foreach(mac_neighbor_table_entry_t, cur_entry, mac_table_list) {
if (thread_router_addr_from_addr(cur_entry->mac16) == mac_helper_mac16_address_get(cur)){
if (thread_router_addr_from_addr(cur_entry->mac16) == mac_helper_mac16_address_get(cur)) {
/* |0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|2|3| */
/* |Timeout |Rsv| Child ID | Mode | */
calculated_timeout = thread_log2_aprx(cur_entry->link_lifetime - 1) + 4;
@ -115,8 +115,8 @@ static uint8_t *thread_diagnostic_child_table_tlv_build(uint8_t *data_ptr, proto
*data_ptr = 0x00; //reserved bytes to zero
*data_ptr = calculated_timeout << 3;
if(cur_entry->mac16 & 0x0100){
*data_ptr = *data_ptr | 0x01;
if (cur_entry->mac16 & 0x0100) {
*data_ptr = *data_ptr | 0x01;
}
data_ptr++;
*data_ptr++ = (uint8_t)(cur_entry->mac16 & 0x00ff);
@ -163,80 +163,80 @@ static int thread_diagnostic_configuration_calc(protocol_interface_info_entry_t
int payload_len = 0;
uint16_t address_count = 0;
if(!tlv_list || list_len < 1) {
if (!tlv_list || list_len < 1) {
return 0;
}
while(list_len --){
switch (*tlv_list){
case DIAGCOP_TLV_EXTENDED_MAC_ADDRESS:
payload_len += 2 + 8;
break;
while (list_len --) {
switch (*tlv_list) {
case DIAGCOP_TLV_EXTENDED_MAC_ADDRESS:
payload_len += 2 + 8;
break;
case DIAGCOP_TLV_ADDRESS16:
payload_len += 2 + 2;
break;
case DIAGCOP_TLV_ADDRESS16:
payload_len += 2 + 2;
break;
case DIAGCOP_TLV_MODE:
payload_len += 2 + 1;
break;
case DIAGCOP_TLV_MODE:
payload_len += 2 + 1;
break;
case DIAGCOP_TLV_TIMEOUT:
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE ||
cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_END_DEVICE ) {
case DIAGCOP_TLV_TIMEOUT:
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE ||
cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_END_DEVICE) {
payload_len += 2 + 4;
}
break;
case DIAGCOP_TLV_CONNECTIVITY:
payload_len += 2 + 10;
break;
case DIAGCOP_TLV_ROUTE64:
payload_len += thread_route_option_size(cur);
break;
case DIAGCOP_TLV_LEADER_DATA:
payload_len += 2 + 8; // TLV header + uint16 pan id
break;
case DIAGCOP_TLV_NETWORK_DATA:
payload_len += 2; // TLV header
payload_len += thread_network_data_tlv_size(cur, 1);
break;
case DIAGCOP_TLV_IPV6_ADDRESS_LIST:
arm_net_interface_address_list_size(cur->id, &address_count);
payload_len += 2 + (address_count * 16);
break;
case DIAGCOP_TLV_MAC_COUNTERS:
payload_len += 2 + 36;
break;
case DIAGCOP_TLV_BATTERY_LEVEL:
payload_len += 2 + 1;
break;
case DIAGCOP_TLV_SUPPLY_VOLTAGE:
payload_len += 2 + 2;
break;
case DIAGCOP_TLV_CHILD_TABLE:
/* Value length = Type + Length + 3 * child count */
payload_len += 2 + (3 * thread_router_bootstrap_child_count_get(cur));
break;
case DIAGCOP_TLV_CHANNEL_PAGES:
payload_len += 2 + 1;
break;
case DIAGCOP_TLV_MAX_CHILD_TIMEOUT:
payload_len += 2 + 4;
}
break;
break;
case DIAGCOP_TLV_CONNECTIVITY:
payload_len += 2 + 10;
break;
case DIAGCOP_TLV_ROUTE64:
payload_len += thread_route_option_size(cur);
break;
case DIAGCOP_TLV_LEADER_DATA:
payload_len += 2 + 8; // TLV header + uint16 pan id
break;
case DIAGCOP_TLV_NETWORK_DATA:
payload_len += 2; // TLV header
payload_len += thread_network_data_tlv_size(cur,1);
break;
case DIAGCOP_TLV_IPV6_ADDRESS_LIST:
arm_net_interface_address_list_size(cur->id, &address_count);
payload_len += 2 + (address_count * 16);
break;
case DIAGCOP_TLV_MAC_COUNTERS:
payload_len += 2+36;
break;
case DIAGCOP_TLV_BATTERY_LEVEL:
payload_len += 2 + 1;
break;
case DIAGCOP_TLV_SUPPLY_VOLTAGE:
payload_len += 2 + 2;
break;
case DIAGCOP_TLV_CHILD_TABLE:
/* Value length = Type + Length + 3 * child count */
payload_len += 2 + (3 * thread_router_bootstrap_child_count_get(cur));
break;
case DIAGCOP_TLV_CHANNEL_PAGES:
payload_len += 2+1;
break;
case DIAGCOP_TLV_MAX_CHILD_TIMEOUT:
payload_len += 2 + 4;
break;
default:
// todo: Other TLV's not supported atm
break;
default:
// todo: Other TLV's not supported atm
break;
}
tlv_list++;
@ -247,7 +247,7 @@ static int thread_diagnostic_configuration_calc(protocol_interface_info_entry_t
static uint8_t *thread_diagnostic_get_build(protocol_interface_info_entry_t *cur, uint8_t *response_ptr, uint8_t *tlv_list, uint16_t list_len)
{
if(!tlv_list || list_len < 1) {
if (!tlv_list || list_len < 1) {
// Request all
return response_ptr;
}
@ -268,105 +268,105 @@ static uint8_t *thread_diagnostic_get_build(protocol_interface_info_entry_t *cur
uint8_t ipv6_address_list[ipv6_address_count * 16];
tr_debug("tlv list length %d", list_len);
while(list_len --){
switch (*tlv_list){
while (list_len --) {
switch (*tlv_list) {
case DIAGCOP_TLV_EXTENDED_MAC_ADDRESS:
if (cur->mac_api) {
//Read dynamicaly generated current extented address from MAC.
cur->mac_api->mac64_get(cur->mac_api,MAC_EXTENDED_DYNAMIC, extended_address);
}
response_ptr = thread_diagcop_tlv_data_write(response_ptr, DIAGCOP_TLV_EXTENDED_MAC_ADDRESS, 8, extended_address);
break;
case DIAGCOP_TLV_EXTENDED_MAC_ADDRESS:
if (cur->mac_api) {
//Read dynamicaly generated current extented address from MAC.
cur->mac_api->mac64_get(cur->mac_api, MAC_EXTENDED_DYNAMIC, extended_address);
}
response_ptr = thread_diagcop_tlv_data_write(response_ptr, DIAGCOP_TLV_EXTENDED_MAC_ADDRESS, 8, extended_address);
break;
case DIAGCOP_TLV_ADDRESS16:
response_ptr = thread_diagcop_tlv_data_write_uint16(response_ptr, DIAGCOP_TLV_ADDRESS16, mac_helper_mac16_address_get(cur));
break;
case DIAGCOP_TLV_ADDRESS16:
response_ptr = thread_diagcop_tlv_data_write_uint16(response_ptr, DIAGCOP_TLV_ADDRESS16, mac_helper_mac16_address_get(cur));
break;
case DIAGCOP_TLV_MODE:
response_ptr = thread_diagcop_tlv_data_write_uint8(response_ptr, DIAGCOP_TLV_MODE, thread_diag_mode_get_by_interface_ptr(cur));
break;
case DIAGCOP_TLV_MODE:
response_ptr = thread_diagcop_tlv_data_write_uint8(response_ptr, DIAGCOP_TLV_MODE, thread_diag_mode_get_by_interface_ptr(cur));
break;
case DIAGCOP_TLV_TIMEOUT:
//must be sleeping poll rate
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE ||
cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_END_DEVICE ) {
response_ptr = thread_diagcop_tlv_data_write_uint32(response_ptr, DIAGCOP_TLV_TIMEOUT, cur->thread_info->host_link_timeout);
}
break;
case DIAGCOP_TLV_TIMEOUT:
//must be sleeping poll rate
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE ||
cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_END_DEVICE) {
response_ptr = thread_diagcop_tlv_data_write_uint32(response_ptr, DIAGCOP_TLV_TIMEOUT, cur->thread_info->host_link_timeout);
}
break;
case DIAGCOP_TLV_CONNECTIVITY:
ptr = response_ptr;
response_ptr = thread_connectivity_tlv_write(response_ptr, cur, 0x0f);
if (ptr != response_ptr) {
ptr[0]=DIAGCOP_TLV_CONNECTIVITY;
}
break;
case DIAGCOP_TLV_CONNECTIVITY:
ptr = response_ptr;
response_ptr = thread_connectivity_tlv_write(response_ptr, cur, 0x0f);
if (ptr != response_ptr) {
ptr[0] = DIAGCOP_TLV_CONNECTIVITY;
}
break;
case DIAGCOP_TLV_ROUTE64:
ptr = response_ptr;
response_ptr = thread_route_option_write(cur,response_ptr);
if (ptr != response_ptr) {
ptr[0]=DIAGCOP_TLV_ROUTE64;
}
break;
case DIAGCOP_TLV_ROUTE64:
ptr = response_ptr;
response_ptr = thread_route_option_write(cur, response_ptr);
if (ptr != response_ptr) {
ptr[0] = DIAGCOP_TLV_ROUTE64;
}
break;
case DIAGCOP_TLV_LEADER_DATA:
ptr = response_ptr;
response_ptr = thread_leader_data_tlv_write(response_ptr,cur);
if (ptr != response_ptr) {
ptr[0]=DIAGCOP_TLV_LEADER_DATA;
}
break;
case DIAGCOP_TLV_LEADER_DATA:
ptr = response_ptr;
response_ptr = thread_leader_data_tlv_write(response_ptr, cur);
if (ptr != response_ptr) {
ptr[0] = DIAGCOP_TLV_LEADER_DATA;
}
break;
case DIAGCOP_TLV_NETWORK_DATA:
ptr = response_ptr;
response_ptr = thread_network_data_tlv_write(cur, response_ptr, true);
if (ptr != response_ptr) {
ptr[0]=DIAGCOP_TLV_NETWORK_DATA;
}
break;
case DIAGCOP_TLV_NETWORK_DATA:
ptr = response_ptr;
response_ptr = thread_network_data_tlv_write(cur, response_ptr, true);
if (ptr != response_ptr) {
ptr[0] = DIAGCOP_TLV_NETWORK_DATA;
}
break;
case DIAGCOP_TLV_IPV6_ADDRESS_LIST:
arm_net_address_list_get(cur->id, ipv6_address_count * 16,ipv6_address_list,&written_address_count);
response_ptr = thread_diagcop_tlv_data_write(response_ptr, DIAGCOP_TLV_IPV6_ADDRESS_LIST, ipv6_address_count*16, ipv6_address_list);
break;
case DIAGCOP_TLV_IPV6_ADDRESS_LIST:
arm_net_address_list_get(cur->id, ipv6_address_count * 16, ipv6_address_list, &written_address_count);
response_ptr = thread_diagcop_tlv_data_write(response_ptr, DIAGCOP_TLV_IPV6_ADDRESS_LIST, ipv6_address_count * 16, ipv6_address_list);
break;
case DIAGCOP_TLV_MAC_COUNTERS:
/* The following elements from [RFC 2863] are included in this order:
* ifInUnknownProtos (4), ifInErrors (4), ifOutErrors (4), ifInUcastPkts (4),
* ifInBroadcastPkts (4), ifInDiscards (4), ifOutUcastPkts (4), ifOutBroadcastPkts (4), ifOutDiscards (4) */
response_ptr = thread_diagcop_tlv_data_write(response_ptr, DIAGCOP_TLV_MAC_COUNTERS, 36, dummy_data);
break;
case DIAGCOP_TLV_MAC_COUNTERS:
/* The following elements from [RFC 2863] are included in this order:
* ifInUnknownProtos (4), ifInErrors (4), ifOutErrors (4), ifInUcastPkts (4),
* ifInBroadcastPkts (4), ifInDiscards (4), ifOutUcastPkts (4), ifOutBroadcastPkts (4), ifOutDiscards (4) */
response_ptr = thread_diagcop_tlv_data_write(response_ptr, DIAGCOP_TLV_MAC_COUNTERS, 36, dummy_data);
break;
case DIAGCOP_TLV_BATTERY_LEVEL:
response_ptr = thread_diagcop_tlv_data_write_uint8(response_ptr, DIAGCOP_TLV_BATTERY_LEVEL, 0);
break;
case DIAGCOP_TLV_BATTERY_LEVEL:
response_ptr = thread_diagcop_tlv_data_write_uint8(response_ptr, DIAGCOP_TLV_BATTERY_LEVEL, 0);
break;
case DIAGCOP_TLV_SUPPLY_VOLTAGE:
response_ptr = thread_diagcop_tlv_data_write_uint16(response_ptr, DIAGCOP_TLV_SUPPLY_VOLTAGE, 0);
break;
case DIAGCOP_TLV_SUPPLY_VOLTAGE:
response_ptr = thread_diagcop_tlv_data_write_uint16(response_ptr, DIAGCOP_TLV_SUPPLY_VOLTAGE, 0);
break;
case DIAGCOP_TLV_CHILD_TABLE:
if (thread_router_bootstrap_child_count_get(cur)) {
response_ptr = thread_diagnostic_child_table_tlv_build(response_ptr, cur);
}
break;
case DIAGCOP_TLV_CHILD_TABLE:
if (thread_router_bootstrap_child_count_get(cur)) {
response_ptr = thread_diagnostic_child_table_tlv_build(response_ptr, cur);
}
break;
case DIAGCOP_TLV_CHANNEL_PAGES:
// Only supporting channel page 0
response_ptr = thread_diagcop_tlv_data_write_uint8(response_ptr, DIAGCOP_TLV_CHANNEL_PAGES, 0);
break;
case DIAGCOP_TLV_CHANNEL_PAGES:
// Only supporting channel page 0
response_ptr = thread_diagcop_tlv_data_write_uint8(response_ptr, DIAGCOP_TLV_CHANNEL_PAGES, 0);
break;
case DIAGCOP_TLV_MAX_CHILD_TIMEOUT:
if (thread_router_bootstrap_child_max_timeout_get(cur, &max_child_timeout) == 0) {
response_ptr = thread_diagcop_tlv_data_write_uint32(response_ptr, DIAGCOP_TLV_MAX_CHILD_TIMEOUT, max_child_timeout);
}
break;
case DIAGCOP_TLV_MAX_CHILD_TIMEOUT:
if (thread_router_bootstrap_child_max_timeout_get(cur, &max_child_timeout) == 0) {
response_ptr = thread_diagcop_tlv_data_write_uint32(response_ptr, DIAGCOP_TLV_MAX_CHILD_TIMEOUT, max_child_timeout);
}
break;
default:
default:
break;
break;
}
tlv_list++;
@ -384,7 +384,7 @@ static int thread_diagnostic_command_request_cb(int8_t service_id, uint8_t sourc
thread_diagnostic_command_t *this = thread_diagnostic_find_by_service(service_id);
protocol_interface_info_entry_t *cur;
uint8_t *ptr = NULL;
uint8_t *request_tlv_ptr = NULL;
uint8_t *request_tlv_ptr = NULL;
uint16_t request_tlv_len;
int response_len;
uint8_t *response_ptr = NULL;
@ -404,8 +404,8 @@ static int thread_diagnostic_command_request_cb(int8_t service_id, uint8_t sourc
// the following function calculates the total memory that is needed to be allocated for response.
// If the request_tlv_len is 0 then the memory allocated is for all the diagnostic command tlvs
response_len = thread_diagnostic_configuration_calc(cur,request_tlv_ptr, request_tlv_len);
if(response_len < 1){
response_len = thread_diagnostic_configuration_calc(cur, request_tlv_ptr, request_tlv_len);
if (response_len < 1) {
if (request_tlv_len > 0) {
// TLV was ommitted but ok request. respond with ok status
goto send_response;
@ -419,12 +419,12 @@ static int thread_diagnostic_command_request_cb(int8_t service_id, uint8_t sourc
}
ptr = thread_diagnostic_get_build(cur, ptr, request_tlv_ptr,
request_tlv_len);
request_tlv_len);
send_response:
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE,
request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM,
response_ptr,ptr - response_ptr );
request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM,
response_ptr, ptr - response_ptr);
ns_dyn_mem_free(response_ptr);
return 0;
@ -448,7 +448,7 @@ static int thread_diagnostic_command_reset_cb(int8_t service_id, uint8_t source_
tr_debug("Thread diagnostic command reset request");
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE,
request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_TEXT_PLAIN, NULL, 0);
request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_TEXT_PLAIN, NULL, 0);
return 0;
}
@ -487,7 +487,7 @@ static int thread_diagnostic_command_query_cb(int8_t service_id, uint8_t source_
// the following function calculates the total memory that is needed to be allocated for response.
// If the request_tlv_len is 0 then the memory allocated is for all the diagnostic command tlvs
response_len = thread_diagnostic_configuration_calc(cur, request_tlv_ptr, request_tlv_len);
if(response_len < 1){
if (response_len < 1) {
if (request_tlv_len > 0) {
// TLV was ommitted but ok request. respond with ok status
goto send_response;
@ -504,7 +504,7 @@ static int thread_diagnostic_command_query_cb(int8_t service_id, uint8_t source_
ptr = thread_diagnostic_get_build(cur, response_ptr, request_tlv_ptr, request_tlv_len);
/* Send ACK to confirmable request */
if(request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE){
if (request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE) {
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, return_code, COAP_CT_NONE, NULL, 0);
response = 0;
}
@ -512,14 +512,14 @@ static int thread_diagnostic_command_query_cb(int8_t service_id, uint8_t source_
/* Send reply to d/da */
send_response:
coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, address_copy, source_port, COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST,
THREAD_URI_DIAGNOSTIC_ANSWER, COAP_CT_OCTET_STREAM, response_ptr, ptr - response_ptr, NULL);
THREAD_URI_DIAGNOSTIC_ANSWER, COAP_CT_OCTET_STREAM, response_ptr, ptr - response_ptr, NULL);
ns_dyn_mem_free(response_ptr);
return response;
failure:
if(request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE){
if (request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE) {
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, return_code, COAP_CT_NONE, NULL, 0);
response = 0;
}

View File

@ -65,7 +65,7 @@ typedef struct {
uint8_t type;
uint8_t *data;
uint16_t length;
}mescop_tlv_t;
} mescop_tlv_t;
#define TRACE_GROUP "tdis"
@ -83,9 +83,9 @@ typedef struct {
thread_discovery_ready_cb *response_cb;
uint8_t active_channel;
uint8_t channel_page;
bool waiting_response:1;
bool joiner_flag:1;
bool native_commisioner_scan:1;
bool waiting_response: 1;
bool joiner_flag: 1;
bool native_commisioner_scan: 1;
uint8_t filter_tlv_length; //Optional Filter data length
uint8_t filter_tlv_data[]; //Do not anything after this definition
} thread_discovery_request_info_t;
@ -100,7 +100,7 @@ typedef struct {
uint64_t active_time_stamp;
thread_announce_scan_ready_cb *response_cb;
announce_discovery_response_t *network;
bool waiting_response:1;
bool waiting_response: 1;
} thread_announce_request_info_t;
@ -142,7 +142,7 @@ static discovery_response_list_t *thread_discover_response_msg_get_discover_from
static int stringlen(const char *s, int n)
{
char *end = memchr(s, 0, n);
return end?end-s:n;
return end ? end - s : n;
}
static void thread_discover_timer_trig(void)
@ -154,9 +154,9 @@ static void thread_discover_timer_trig(void)
thread_discover_timer_active = true;
}
static thread_discovery_request_info_t * thread_discovery_request_allocate(thread_discover_reques_t *scan_request, thread_discovery_ready_cb *response_cb)
static thread_discovery_request_info_t *thread_discovery_request_allocate(thread_discover_reques_t *scan_request, thread_discovery_ready_cb *response_cb)
{
thread_discovery_request_info_t * discover_request = ns_dyn_mem_temporary_alloc(sizeof(thread_discovery_request_info_t) + scan_request->filter_tlv_length);
thread_discovery_request_info_t *discover_request = ns_dyn_mem_temporary_alloc(sizeof(thread_discovery_request_info_t) + scan_request->filter_tlv_length);
if (discover_request) {
discover_request->waiting_response = false;
discover_request->active_timer = 0;
@ -176,9 +176,9 @@ static thread_discovery_request_info_t * thread_discovery_request_allocate(threa
}
static thread_announce_request_info_t * thread_announce_discovery_request_allocate(thread_announce_discover_reques_t *scan_request, thread_announce_scan_ready_cb *response_cb)
static thread_announce_request_info_t *thread_announce_discovery_request_allocate(thread_announce_discover_reques_t *scan_request, thread_announce_scan_ready_cb *response_cb)
{
thread_announce_request_info_t * discover_request = ns_dyn_mem_temporary_alloc(sizeof(thread_announce_request_info_t));
thread_announce_request_info_t *discover_request = ns_dyn_mem_temporary_alloc(sizeof(thread_announce_request_info_t));
if (discover_request) {
discover_request->waiting_response = false;
discover_request->active_timer = 0;
@ -207,7 +207,7 @@ static bool thread_discovery_server_msg_buffer_allocate(thread_discovery_class_t
return false;
}
class->msg_buffers = msg_buffer;
for (uint8_t i = 0; i< 4; i++) {
for (uint8_t i = 0; i < 4; i++) {
ns_list_add_to_start(&class->srv_respose_msg_buffers, msg_buffer++);
}
return true;
@ -319,7 +319,7 @@ static void thread_discovery_prepare(protocol_interface_info_entry_t *interface,
mac_helper_beacon_payload_reallocate(interface, 0); // No beacons for thread
mac_data_poll_init(interface);
mac_helper_mac16_address_set(interface, 0xffff);
mac_helper_mac64_set(interface,discovery->temporary_mac64);
mac_helper_mac64_set(interface, discovery->temporary_mac64);
thread_set_link_local_address(interface); // only to generate IID
discovery->active_timer = 1;
discovery->waiting_response = false;
@ -339,16 +339,15 @@ static void thread_announce_discovery_prepare(protocol_interface_info_entry_t *i
thread_discover_timer_trig();
}
static bool thread_discovery_proces_ready(thread_discovery_request_info_t *discovery) {
static bool thread_discovery_proces_ready(thread_discovery_request_info_t *discovery)
{
//Get next free channel
uint8_t i;
uint32_t mask = 1;
for (i=0; i<32; i++)
{
if (discovery->channel_mask & mask)
{
for (i = 0; i < 32; i++) {
if (discovery->channel_mask & mask) {
discovery->channel_mask &= ~mask;
discovery->active_channel = i;
discovery->channel_page = 0; //Support only chnnel page 0
@ -359,16 +358,15 @@ static bool thread_discovery_proces_ready(thread_discovery_request_info_t *disco
return true;
}
static bool thread_announce_discovery_process_ready(thread_announce_request_info_t *discovery) {
static bool thread_announce_discovery_process_ready(thread_announce_request_info_t *discovery)
{
//Get next free channel
uint8_t i;
uint32_t mask = 0x80000000;
for (i=0; i<32; i++)
{
if (discovery->channel_mask & mask)
{
for (i = 0; i < 32; i++) {
if (discovery->channel_mask & mask) {
discovery->channel_mask &= ~mask;
discovery->active_channel = i;
return false;
@ -402,8 +400,8 @@ static void thread_discovery_link_activate(protocol_interface_info_entry_t *inte
start_req.BeaconOrder = 0x0f;
start_req.SuperframeOrder = 0x0f;
if( interface->mac_api ){
interface->mac_api->mlme_req(interface->mac_api, MLME_START, (void*)&start_req);
if (interface->mac_api) {
interface->mac_api->mlme_req(interface->mac_api, MLME_START, (void *)&start_req);
}
}
@ -411,10 +409,10 @@ static uint16_t thread_discover_tlv_get(uint8_t version, bool dynamic_bit)
{
uint16_t thread_discover_tlv = 0;
thread_discover_tlv |= (uint16_t) (version << 12);
thread_discover_tlv |= (uint16_t)(version << 12);
if (dynamic_bit) {
thread_discover_tlv |= (uint16_t) (1 << 11);
thread_discover_tlv |= (uint16_t)(1 << 11);
}
return thread_discover_tlv;
@ -446,7 +444,7 @@ static int thread_discovery_request_send(thread_discovery_class_t *class, thread
ptr += discovery->filter_tlv_length;
}
if (mle_service_update_length_by_ptr(buf_id,ptr)!= 0) {
if (mle_service_update_length_by_ptr(buf_id, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
@ -481,15 +479,15 @@ static int thread_discovery_announce_request_send(thread_discovery_class_t *clas
uint8_t *ptr = mle_service_get_data_pointer(buf_id);
uint8_t channel_tlv[3];
ptr = thread_meshcop_tlv_data_write_uint64(ptr,MLE_TYPE_ACTIVE_TIMESTAMP, discovery->active_time_stamp);
ptr = thread_meshcop_tlv_data_write_uint16(ptr,MLE_TYPE_PANID, discovery->pan_id);
ptr = thread_meshcop_tlv_data_write_uint64(ptr, MLE_TYPE_ACTIVE_TIMESTAMP, discovery->active_time_stamp);
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MLE_TYPE_PANID, discovery->pan_id);
channel_tlv[0] = 0;
common_write_16_bit(discovery->active_channel, &channel_tlv[1]);
ptr = thread_meshcop_tlv_data_write(ptr,MLE_TYPE_CHANNEL, 3, channel_tlv);
ptr = thread_meshcop_tlv_data_write(ptr, MLE_TYPE_CHANNEL, 3, channel_tlv);
if (mle_service_update_length_by_ptr(buf_id,ptr)!= 0) {
if (mle_service_update_length_by_ptr(buf_id, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
@ -524,13 +522,13 @@ static int thread_discovery_response_send(thread_discovery_class_t *class, threa
// Calculate length
uint16_t message_length = 16; // Default data to response always
message_length += stringlen((char*)&linkConfiguration->name, 16);
message_length += stringlen((char *)&linkConfiguration->name, 16);
// [Joiner UDP Port TLV]
if (server_data.joiner_router_enabled && server_data.joiner_router_port) {
message_length += 4;
// [Steering Data TLV]
if (cur->thread_info->registered_commissioner.commissioner_valid && cur->thread_info->registered_commissioner.steering_data_len){
if (cur->thread_info->registered_commissioner.commissioner_valid && cur->thread_info->registered_commissioner.steering_data_len) {
message_length += cur->thread_info->registered_commissioner.steering_data_len + 2;
}
}
@ -550,7 +548,7 @@ static int thread_discovery_response_send(thread_discovery_class_t *class, threa
//SET ll64 from euid64
uint8_t *ll64 = mle_service_get_msg_destination_address_pointer(buf_id);
memcpy(ll64, ADDR_LINK_LOCAL_PREFIX, 8);
memcpy(ll64 + 8,msg_buffers->extentedAddress , 8);
memcpy(ll64 + 8, msg_buffers->extentedAddress, 8);
//No link layer security and no mle security.
mle_service_msg_update_security_params(buf_id, 0, 0, 0);
uint8_t *ptr = mle_service_get_data_pointer(buf_id);
@ -563,7 +561,7 @@ static int thread_discovery_response_send(thread_discovery_class_t *class, threa
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MESHCOP_TLV_DISCOVERY_RESPONSE, discover_response_tlv);
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_XPANID, 8, linkConfiguration->extented_pan_id);
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_NETWORK_NAME, stringlen((char*)&linkConfiguration->name, 16), linkConfiguration->name);
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_NETWORK_NAME, stringlen((char *)&linkConfiguration->name, 16), linkConfiguration->name);
//Optional Part
if (linkConfiguration->securityPolicy & SECURITY_POLICY_NATIVE_COMMISSIONING_ALLOWED) {
@ -579,7 +577,7 @@ static int thread_discovery_response_send(thread_discovery_class_t *class, threa
ptr = thread_extension_discover_response_write(cur, ptr);
if (mle_service_update_length_by_ptr(buf_id,ptr)!= 0) {
if (mle_service_update_length_by_ptr(buf_id, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
@ -629,7 +627,7 @@ static bool thread_announce_discovery_request_timer_update(thread_discovery_clas
return true;
}
if (thread_announce_discovery_process_ready(class->thread_announce_request) ) {
if (thread_announce_discovery_process_ready(class->thread_announce_request)) {
thread_discovery_process_end(class->interface);
announce_discovery_response_t *result = class->thread_announce_request->network;
thread_announce_scan_ready_cb *response_cb = class->thread_announce_request->response_cb;
@ -788,7 +786,7 @@ static bool thread_discovery_request_filter_validate(link_configuration_s *linkC
common_write_16_bit(linkConfiguration->panId, compare_tlv.data);
if (thread_discovery_tlv_spesific_data_discover(data_ptr, length, &compare_tlv) ) {
if (thread_discovery_tlv_spesific_data_discover(data_ptr, length, &compare_tlv)) {
return false;
}
@ -796,7 +794,7 @@ static bool thread_discovery_request_filter_validate(link_configuration_s *linkC
compare_tlv.length = 8;
compare_tlv.type = MESHCOP_TLV_XPANID;
if (thread_discovery_tlv_spesific_data_discover(data_ptr, length, &compare_tlv) ) {
if (thread_discovery_tlv_spesific_data_discover(data_ptr, length, &compare_tlv)) {
return false;
}
@ -804,10 +802,10 @@ static bool thread_discovery_request_filter_validate(link_configuration_s *linkC
}
static void thread_discovery_request_msg_handler(thread_discovery_class_t * discovery_class, mle_message_t *mle_msg)
static void thread_discovery_request_msg_handler(thread_discovery_class_t *discovery_class, mle_message_t *mle_msg)
{
//Validate that server is enabled
if (!discovery_class->discovery_server_active ) {
if (!discovery_class->discovery_server_active) {
return;
}
@ -849,8 +847,8 @@ static void thread_discovery_request_msg_handler(thread_discovery_class_t * disc
if (joiner_flag) {
//Can we respond
thread_management_server_data_t joiner_router_info;
if (0 != thread_management_server_commisoner_data_get(discovery_class->interface_id , &joiner_router_info) ||
!joiner_router_info.joiner_router_enabled) {
if (0 != thread_management_server_commisoner_data_get(discovery_class->interface_id, &joiner_router_info) ||
!joiner_router_info.joiner_router_enabled) {
if (!thread_extension_joining_enabled(discovery_class->interface_id)) {
tr_debug("Drop by Joining disabled");
return;
@ -876,7 +874,8 @@ static bool thread_seering_data_accept_any(uint8_t length, uint8_t *data)
return false;
}
static void thread_discovery_nwk_push_to_list_by_lqi(thread_nwk_discovery_response_list_t *result_list, discovery_response_list_t *nwk_info) {
static void thread_discovery_nwk_push_to_list_by_lqi(thread_nwk_discovery_response_list_t *result_list, discovery_response_list_t *nwk_info)
{
if (ns_list_count(result_list)) {
ns_list_foreach_safe(discovery_response_list_t, cur_entry, result_list) {
if (nwk_info->dbm > cur_entry->dbm) {
@ -891,7 +890,8 @@ static void thread_discovery_nwk_push_to_list_by_lqi(thread_nwk_discovery_respon
}
}
static void thread_discovery_joiner_set(thread_nwk_discovery_response_list_t *result_list, discovery_response_list_t *nwk_info, bool new_accept_any) {
static void thread_discovery_joiner_set(thread_nwk_discovery_response_list_t *result_list, discovery_response_list_t *nwk_info, bool new_accept_any)
{
if (ns_list_count(result_list)) {
bool cur_acept_any;
@ -923,7 +923,7 @@ static void thread_discovery_joiner_set(thread_nwk_discovery_response_list_t *re
static void thread_discovery_response_msg_handler(thread_discovery_class_t * discovery_class, mle_message_t *mle_msg)
static void thread_discovery_response_msg_handler(thread_discovery_class_t *discovery_class, mle_message_t *mle_msg)
{
if (!discovery_class->discovery_request || !discovery_class->discovery_request->waiting_response) {
return;
@ -943,8 +943,8 @@ static void thread_discovery_response_msg_handler(thread_discovery_class_t * dis
nwk_name_length = thread_meshcop_tlv_find(discovery_tlv.dataPtr, discovery_tlv.tlvLen, MESHCOP_TLV_NETWORK_NAME, &nwk_name);
if (thread_meshcop_tlv_data_get_uint16(discovery_tlv.dataPtr, discovery_tlv.tlvLen, MESHCOP_TLV_DISCOVERY_RESPONSE, &discover_response_tlv) < 2
|| thread_meshcop_tlv_find(discovery_tlv.dataPtr, discovery_tlv.tlvLen, MESHCOP_TLV_XPANID, &extented_panid) < 8
|| nwk_name_length > 16) {
|| thread_meshcop_tlv_find(discovery_tlv.dataPtr, discovery_tlv.tlvLen, MESHCOP_TLV_XPANID, &extented_panid) < 8
|| nwk_name_length > 16) {
tr_debug("discover response not include all mandatory TLV's");
return;
@ -987,14 +987,14 @@ static void thread_discovery_response_msg_handler(thread_discovery_class_t * dis
tr_debug("Dropped, no joiner info");
}
} else {
tr_debug("Dropped by no valid joiner info %u %u",joiner_port_valid, steerin_data_length);
tr_debug("Dropped by no valid joiner info %u %u", joiner_port_valid, steerin_data_length);
return;
}
}
discovery_response_list_t *nwk_info = thread_discover_response_msg_get_discover_from_list(
&discovery_class->discovered_network,
discovery_class->discovery_request->active_channel, pan_id);
&discovery_class->discovered_network,
discovery_class->discovery_request->active_channel, pan_id);
if (nwk_info) {
if (nwk_info->dbm < mle_msg->dbm) {
goto save_optional_data;
@ -1034,7 +1034,7 @@ save_optional_data:
memcpy(nwk_info->extented_mac, mle_msg->packet_src_address + 8, 8);
nwk_info->extented_mac[0] ^= 2;
if (steerin_data_length) {
memcpy(nwk_info->steering_data,steering_data, steerin_data_length);
memcpy(nwk_info->steering_data, steering_data, steerin_data_length);
nwk_info->steering_data_valid = steerin_data_length;
}
@ -1049,7 +1049,7 @@ static void thread_announce_discovery_message_receiver_cb(int8_t interface_id, m
if (mle_msg->message_type != MLE_COMMAND_DATASET_ANNOUNCE) {
return;
}
thread_discovery_class_t * discovery_class = thread_discovery_class_get(interface_id);
thread_discovery_class_t *discovery_class = thread_discovery_class_get(interface_id);
if (!discovery_class || !discovery_class->thread_announce_request) {
return;
}
@ -1061,15 +1061,15 @@ static void thread_announce_discovery_message_receiver_cb(int8_t interface_id, m
uint16_t channel;
tr_debug("Host Recv Dataset Announce %s", trace_ipv6(mle_msg->packet_src_address));
if (8 > thread_tmfcop_tlv_data_get_uint64(mle_msg->data_ptr, mle_msg->data_length,MLE_TYPE_ACTIVE_TIMESTAMP,&timestamp)) {
if (8 > thread_tmfcop_tlv_data_get_uint64(mle_msg->data_ptr, mle_msg->data_length, MLE_TYPE_ACTIVE_TIMESTAMP, &timestamp)) {
tr_error("Missing timestamp TLV");
return;
}
if (2 > thread_tmfcop_tlv_data_get_uint16(mle_msg->data_ptr, mle_msg->data_length,MLE_TYPE_PANID,&panid)) {
if (2 > thread_tmfcop_tlv_data_get_uint16(mle_msg->data_ptr, mle_msg->data_length, MLE_TYPE_PANID, &panid)) {
tr_error("Missing Panid TLV");
return;
}
if (3 > thread_tmfcop_tlv_find(mle_msg->data_ptr, mle_msg->data_length,MLE_TYPE_CHANNEL,&ptr)) {
if (3 > thread_tmfcop_tlv_find(mle_msg->data_ptr, mle_msg->data_length, MLE_TYPE_CHANNEL, &ptr)) {
tr_error("Missing Channel TLV");
return;
}
@ -1084,7 +1084,7 @@ static void thread_announce_discovery_message_receiver_cb(int8_t interface_id, m
announce_discovery_response_t *response = NULL;
if (discovery_class->thread_announce_request->network) {
response = discovery_class->thread_announce_request->network;
if (timestamp <= discovery_class->thread_announce_request->network->active_timestamp ) {
if (timestamp <= discovery_class->thread_announce_request->network->active_timestamp) {
response = NULL;
}
} else {
@ -1107,7 +1107,7 @@ static void thread_announce_discover_receive_cb(int8_t interface_id, mle_message
(void)security_headers;
/* Check that message is from link-local scope */
if(!addr_is_ipv6_link_local(mle_msg->packet_src_address)) {
if (!addr_is_ipv6_link_local(mle_msg->packet_src_address)) {
return;
}
@ -1117,7 +1117,7 @@ static void thread_announce_discover_receive_cb(int8_t interface_id, mle_message
static void thread_discovery_message_receiver_cb(int8_t interface_id, mle_message_t *mle_msg)
{
//Discovery interface get
thread_discovery_class_t * discovery_class = thread_discovery_class_get(interface_id);
thread_discovery_class_t *discovery_class = thread_discovery_class_get(interface_id);
if (!discovery_class) {
return;
}
@ -1174,7 +1174,7 @@ int thread_discovery_init(int8_t interface_id, struct protocol_interface_info_en
return -2;
}
thread_discovery_class_t * discovery_class = thread_discovery_class_get(interface_id);
thread_discovery_class_t *discovery_class = thread_discovery_class_get(interface_id);
if (discovery_class) {
//Verify reed boolean
@ -1197,7 +1197,7 @@ int thread_discovery_init(int8_t interface_id, struct protocol_interface_info_en
//Allocate new entry
discovery_class = thread_discovery_class_allocate(reedDevice);
if (!discovery_class ) {
if (!discovery_class) {
mle_service_interface_receiver_bypass_handler_update(interface_id, NULL);
return -1;
}
@ -1215,8 +1215,8 @@ return_ok:
*/
int thread_discovery_reset(int8_t interface_id)
{
thread_discovery_class_t * discovery_class = thread_discovery_class_get(interface_id);
if (!discovery_class ) {
thread_discovery_class_t *discovery_class = thread_discovery_class_get(interface_id);
if (!discovery_class) {
return -1;
}
thread_discovery_request_free(discovery_class);
@ -1237,11 +1237,11 @@ static bool thread_discovery_timer_update(void)
keep_timer_active = true;
}
} else if (cur_class->discovery_request) {
if (thread_discovery_request_timer_update(cur_class) ) {
if (thread_discovery_request_timer_update(cur_class)) {
keep_timer_active = true;
}
} else if(cur_class->thread_announce_request) {
if ( thread_announce_discovery_request_timer_update(cur_class) ) {
} else if (cur_class->thread_announce_request) {
if (thread_announce_discovery_request_timer_update(cur_class)) {
keep_timer_active = true;
}
}
@ -1254,7 +1254,7 @@ static bool thread_discovery_timer_update(void)
*/
int thread_discovery_responser_enable(int8_t interface_id, bool enable_service)
{
thread_discovery_class_t * discovery_class = thread_discovery_class_get(interface_id);
thread_discovery_class_t *discovery_class = thread_discovery_class_get(interface_id);
if (!discovery_class || !discovery_class->msg_buffers) {
return -1;
}
@ -1284,7 +1284,7 @@ static void thread_discovery_normal_receive_cb(int8_t interface_id, mle_message_
int thread_discovery_network_scan(struct protocol_interface_info_entry *cur_interface, thread_discover_reques_t *scan_request, thread_discovery_ready_cb *ready_cb)
{
thread_discovery_class_t * discovery_class = thread_discovery_class_get(cur_interface->id);
thread_discovery_class_t *discovery_class = thread_discovery_class_get(cur_interface->id);
if (!discovery_class || !ready_cb || !scan_request) {
return -1;
}
@ -1304,7 +1304,7 @@ int thread_discovery_network_scan(struct protocol_interface_info_entry *cur_inte
return -3;
}
if (mle_service_interface_register(cur_interface->id, cur_interface, thread_discovery_normal_receive_cb, discovery_class->discovery_request->temporary_mac64,8) != 0) {
if (mle_service_interface_register(cur_interface->id, cur_interface, thread_discovery_normal_receive_cb, discovery_class->discovery_request->temporary_mac64, 8) != 0) {
thread_discovery_request_free(discovery_class);
return -1;
}
@ -1323,46 +1323,46 @@ int thread_discovery_network_scan(struct protocol_interface_info_entry *cur_inte
int thread_discovery_announce_network_scan(int8_t interface_id, thread_announce_discover_reques_t *scan_request, thread_announce_scan_ready_cb *ready_cb)
{
thread_discovery_class_t * discovery_class = thread_discovery_class_get(interface_id);
thread_discovery_class_t *discovery_class = thread_discovery_class_get(interface_id);
if (!discovery_class || !ready_cb || !scan_request) {
return -1;
}
//Check Is discovery started already
if (discovery_class->discovery_request || discovery_class->thread_announce_request) {
return -2;
}
//Check Is discovery started already
if (discovery_class->discovery_request || discovery_class->thread_announce_request) {
return -2;
}
if (!scan_request->channel_mask) {
return -1;
}
if (!scan_request->channel_mask) {
return -1;
}
discovery_class->thread_announce_request = thread_announce_discovery_request_allocate(scan_request, ready_cb);
discovery_class->thread_announce_request = thread_announce_discovery_request_allocate(scan_request, ready_cb);
if (!discovery_class->thread_announce_request) {
return -3;
}
if (!discovery_class->thread_announce_request) {
return -3;
}
//Update receiver callback
if (mle_service_interface_receiver_handler_update(interface_id, thread_announce_discover_receive_cb) != 0) {
thread_announce_discovery_request_free(discovery_class);
return -1;
}
//Update receiver callback
if (mle_service_interface_receiver_handler_update(interface_id, thread_announce_discover_receive_cb) != 0) {
thread_announce_discovery_request_free(discovery_class);
return -1;
}
if (mle_service_interface_receiver_bypass_handler_update(interface_id, thread_announce_discovery_message_receiver_cb) != 0) {
thread_discovery_request_free(discovery_class);
return -1;
}
if (mle_service_interface_receiver_bypass_handler_update(interface_id, thread_announce_discovery_message_receiver_cb) != 0) {
thread_discovery_request_free(discovery_class);
return -1;
}
//Set temporary mac and generate ll64
thread_announce_discovery_prepare(discovery_class->interface, discovery_class->thread_announce_request);
return 0;
//Set temporary mac and generate ll64
thread_announce_discovery_prepare(discovery_class->interface, discovery_class->thread_announce_request);
return 0;
}
discovery_response_list_t *thread_discovery_network_description_get(int8_t interface_id)
{
thread_discovery_class_t * discovery_class = thread_discovery_class_get(interface_id);
if (!discovery_class ) {
thread_discovery_class_t *discovery_class = thread_discovery_class_get(interface_id);
if (!discovery_class) {
return NULL;
}
@ -1382,8 +1382,8 @@ discovery_response_list_t *thread_discovery_network_description_get(int8_t inter
*/
int thread_discovery_free(int8_t interface_id)
{
thread_discovery_class_t * discovery_class = thread_discovery_class_get(interface_id);
if (!discovery_class ) {
thread_discovery_class_t *discovery_class = thread_discovery_class_get(interface_id);
if (!discovery_class) {
return -1;
}

View File

@ -43,8 +43,8 @@ typedef struct discovery_response_list {
uint16_t commissioner_port;
uint8_t channel;
int8_t dbm;
unsigned version:4;
unsigned steering_data_valid:5;
unsigned version: 4;
unsigned steering_data_valid: 5;
ns_list_link_t link;
} discovery_response_list_t;
@ -62,7 +62,7 @@ typedef struct {
uint8_t *extented_pan_id;
uint8_t *network_name;
uint16_t pan_id;
unsigned version:4;
unsigned version: 4;
} discover_server_info_t;
/**
@ -70,7 +70,7 @@ typedef struct {
*/
typedef struct {
uint32_t channel_mask;
bool joiner_flag:1;
bool joiner_flag: 1;
bool native_commisioner; //Set for native commisioner
uint8_t filter_tlv_length; //Optional Filter data length
uint8_t *filter_tlv_data; //Pointer for filter specific data

View File

@ -105,7 +105,7 @@ void thread_child_set_default_route(protocol_interface_info_entry_t *cur)
uint8_t ula[16];
// SET Default route to ::/0
memcpy(ula, ADDR_LINK_LOCAL_PREFIX, 8);
memcpy(&ula[8], parent->mac64 , 8);
memcpy(&ula[8], parent->mac64, 8);
ula[8] ^= 2;
if (ipv6_route_add(NULL, 0, cur->id, ula, ROUTE_THREAD, 0xffffffff, 0) == NULL) {
tr_error("fail to add default route");
@ -156,8 +156,8 @@ static bool thread_parent_discover_timeout_cb(int8_t interface_id, uint16_t msgI
}
/* SED requires that scanned parent is added to MLE table */
memcpy(ll64, ADDR_LINK_LOCAL_PREFIX , 8);
memcpy(&ll64[8], parent->mac64 , 8);
memcpy(ll64, ADDR_LINK_LOCAL_PREFIX, 8);
memcpy(&ll64[8], parent->mac64, 8);
ll64[8] ^= 2;
entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), ll64, true, &new_entry_created);
if (entry_temp == NULL) {
@ -175,8 +175,8 @@ static bool thread_parent_discover_timeout_cb(int8_t interface_id, uint16_t msgI
thread_key_guard_timer_calculate(cur, linkConfiguration, true);
mlme_device_descriptor_t device_desc;
mac_helper_device_description_write(cur, &device_desc, entry_temp->mac64, entry_temp->mac16,parent->linLayerFrameCounter, false);
mac_helper_devicetable_set(&device_desc, cur,entry_temp->index, mac_helper_default_key_index_get(cur), new_entry_created);
mac_helper_device_description_write(cur, &device_desc, entry_temp->mac64, entry_temp->mac16, parent->linLayerFrameCounter, false);
mac_helper_devicetable_set(&device_desc, cur, entry_temp->index, mac_helper_default_key_index_get(cur), new_entry_created);
mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, THREAD_DEFAULT_LINK_LIFETIME);
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) {
@ -239,9 +239,9 @@ static int thread_parent_request_build(protocol_interface_info_entry_t *cur)
timeout.delay = MLE_STANDARD_RESPONSE_DELAY;
if (cur->thread_info->thread_attached_state == THREAD_STATE_REATTACH ||
cur->thread_info->thread_attached_state == THREAD_STATE_REATTACH_RETRY ||
cur->thread_info->thread_attached_state == THREAD_STATE_CONNECTED ||
cur->thread_info->thread_attached_state == THREAD_STATE_CONNECTED_ROUTER) {
cur->thread_info->thread_attached_state == THREAD_STATE_REATTACH_RETRY ||
cur->thread_info->thread_attached_state == THREAD_STATE_CONNECTED ||
cur->thread_info->thread_attached_state == THREAD_STATE_CONNECTED_ROUTER) {
// When doing re-attach End devices are immediately accepted as parents
scanMask |= 0x40;
timeout.timeout_init = THREAD_PARENT_REQ_SCANMASK_RE_TIMEOUT;
@ -266,7 +266,7 @@ static int thread_parent_request_build(protocol_interface_info_entry_t *cur)
}
ptr = mle_tlv_write_mode(ptr, mode);
if (mle_service_update_length_by_ptr(buf_id,ptr)!= 0) {
if (mle_service_update_length_by_ptr(buf_id, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
@ -291,7 +291,7 @@ void thread_network_attach_start(protocol_interface_info_entry_t *cur)
cur->nwk_bootstrap_state = ER_MLE_SCAN;
cur->bootsrap_state_machine_cnt = 0;
/* advance trickle timer by 6 (in 100ms ticks) seconds if needed */
thread_routing_trickle_advance(&cur->thread_info->routing, 6*10);
thread_routing_trickle_advance(&cur->thread_info->routing, 6 * 10);
} else {
cur->bootsrap_state_machine_cnt = 5;
}
@ -312,7 +312,7 @@ static int thread_end_device_synch_response_validate(protocol_interface_info_ent
tr_debug("Validate Link Synch Response");
//Check First Status
if (mle_tlv_read_8_bit_tlv(MLE_TYPE_STATUS, ptr, data_length, &status)) {
tr_debug("Synch status response %x",status);
tr_debug("Synch status response %x", status);
//Clean synch state and start
return -1;
}
@ -368,9 +368,9 @@ static int thread_end_device_synch_response_validate(protocol_interface_info_ent
}
thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, entry_temp->index, linkMargin, new_entry_created);
thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, entry_temp->index);
/*
/*
*/
*/
entry_temp->mac16 = srcAddress;
entry_temp->connected_device = 1;
entry_temp->link_role = PRIORITY_PARENT_NEIGHBOUR; // Make this our parent
@ -380,7 +380,7 @@ static int thread_end_device_synch_response_validate(protocol_interface_info_ent
mac_neighbor_table_neighbor_refresh(mac_neighbor_info(cur), entry_temp, thread_info(cur)->host_link_timeout);
mlme_device_descriptor_t device_desc;
mac_helper_device_description_write(cur, &device_desc, entry_temp->mac64, entry_temp->mac16,llFrameCounter, false);
mac_helper_device_description_write(cur, &device_desc, entry_temp->mac64, entry_temp->mac16, llFrameCounter, false);
mac_helper_devicetable_set(&device_desc, cur, entry_temp->index, securityHeader->KeyIndex, new_entry_created);
thread_info(cur)->thread_attached_state = THREAD_STATE_CONNECTED;
@ -417,7 +417,7 @@ static void thread_child_synch_receive_cb(int8_t interface_id, mle_message_t *ml
protocol_interface_info_entry_t *cur = mle_msg->interface_ptr;
/* Check that message is from link-local scope */
if(!addr_is_ipv6_link_local(mle_msg->packet_src_address)) {
if (!addr_is_ipv6_link_local(mle_msg->packet_src_address)) {
return;
}
@ -425,44 +425,44 @@ static void thread_child_synch_receive_cb(int8_t interface_id, mle_message_t *ml
uint8_t linkMargin = thread_compute_link_margin(mle_msg->dbm);
//State machine What packet shuold accept in this case
switch (mle_msg->message_type) {
case MLE_COMMAND_CHILD_UPDATE_RESPONSE:
case MLE_COMMAND_CHILD_UPDATE_RESPONSE:
messageId = mle_tlv_validate_response(mle_msg->data_ptr, mle_msg->data_length);
messageId = mle_tlv_validate_response(mle_msg->data_ptr, mle_msg->data_length);
if (messageId == 0) {
tr_debug("No matching challenge");
return;
}
if (messageId == 0) {
tr_debug("No matching challenge");
return;
}
if (thread_end_device_synch_response_validate(cur, mle_msg->data_ptr, mle_msg->data_length, linkMargin, mle_msg->packet_src_address, security_headers) != 0) {
tr_warn("End device synch failed");
mle_service_msg_free(messageId);
thread_bootsrap_device_synch_fail(cur);
return;
}
mle_tlv_info_t networkDataTlv;
thread_leader_data_t leaderData;
tr_debug("End device synch Possible");
cur->thread_info->thread_attached_state = THREAD_STATE_CONNECTED;
// read network data, and leader data check. Send data request sent if pending set is not in sync
if (mle_tlv_read_tlv(MLE_TYPE_NETWORK_DATA, mle_msg->data_ptr, mle_msg->data_length, &networkDataTlv) &&
thread_leader_data_parse(mle_msg->data_ptr, mle_msg->data_length, &leaderData) && thread_joiner_application_pending_delay_timer_in_sync(cur->id)) {
thread_bootstrap_network_data_save(cur, &leaderData, networkDataTlv.dataPtr, networkDataTlv.tlvLen);
} else {
thread_bootstrap_parent_network_data_request(cur, true);
}
thread_bootstrap_attached_ready(cur);
//SET For sleepy state and mode update
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) {
nwk_thread_host_control(cur, NET_HOST_FAST_POLL_MODE, 1);
//TRIG Child Update state
thread_bootstrap_child_update_trig(cur);
}
if (thread_end_device_synch_response_validate(cur, mle_msg->data_ptr, mle_msg->data_length, linkMargin, mle_msg->packet_src_address, security_headers) != 0) {
tr_warn("End device synch failed");
mle_service_msg_free(messageId);
thread_bootsrap_device_synch_fail(cur);
return;
}
mle_tlv_info_t networkDataTlv;
thread_leader_data_t leaderData;
tr_debug("End device synch Possible");
cur->thread_info->thread_attached_state = THREAD_STATE_CONNECTED;
// read network data, and leader data check. Send data request sent if pending set is not in sync
if (mle_tlv_read_tlv(MLE_TYPE_NETWORK_DATA, mle_msg->data_ptr, mle_msg->data_length, &networkDataTlv) &&
thread_leader_data_parse(mle_msg->data_ptr, mle_msg->data_length, &leaderData) && thread_joiner_application_pending_delay_timer_in_sync(cur->id)) {
thread_bootstrap_network_data_save(cur, &leaderData, networkDataTlv.dataPtr, networkDataTlv.tlvLen);
} else {
thread_bootstrap_parent_network_data_request(cur, true);
}
thread_bootstrap_attached_ready(cur);
//SET For sleepy state and mode update
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) {
nwk_thread_host_control(cur, NET_HOST_FAST_POLL_MODE, 1);
//TRIG Child Update state
thread_bootstrap_child_update_trig(cur);
}
mle_service_msg_free(messageId);
break;
break;
}
}
@ -502,7 +502,7 @@ void thread_mle_parent_discover_receive_cb(int8_t interface_id, mle_message_t *m
protocol_interface_info_entry_t *cur = mle_msg->interface_ptr;
/* Check that message is from link-local scope */
if(!addr_is_ipv6_link_local(mle_msg->packet_src_address)) {
if (!addr_is_ipv6_link_local(mle_msg->packet_src_address)) {
return;
}
@ -583,8 +583,8 @@ void thread_mle_parent_discover_receive_cb(int8_t interface_id, mle_message_t *m
}
}
} else if (thread_info(cur)->thread_attached_state == THREAD_STATE_ATTACH_ANY ||
thread_info(cur)->thread_attached_state == THREAD_STATE_CONNECTED ||
thread_info(cur)->thread_attached_state == THREAD_STATE_CONNECTED_ROUTER) {
thread_info(cur)->thread_attached_state == THREAD_STATE_CONNECTED ||
thread_info(cur)->thread_attached_state == THREAD_STATE_CONNECTED_ROUTER) {
if (thread_info(cur)->thread_leader_data) {
if (thread_partition_match(cur, &leaderData)) {
//accept only different ID at anyattach phase
@ -623,8 +623,8 @@ void thread_mle_parent_discover_receive_cb(int8_t interface_id, mle_message_t *m
}
if (thread_extension_enabled(cur) &&
thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_ROUTER &&
leaderData.weighting < thread_info(cur)->partition_weighting) {
thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_ROUTER &&
leaderData.weighting < thread_info(cur)->partition_weighting) {
// Only applies to extensions and only routers that can form new partitions can ignore lower weight
tr_debug("Drop parent due weighting %d<%d", leaderData.weighting, thread_info(cur)->partition_weighting);
return;
@ -643,17 +643,16 @@ void thread_mle_parent_discover_receive_cb(int8_t interface_id, mle_message_t *m
uint32_t currentPartitionId = thread_info(cur)->thread_attach_scanned_parent->leader_data.partitionId;
uint8_t currentWeighting = thread_info(cur)->thread_attach_scanned_parent->leader_data.weighting;
tr_debug("Current partition %"PRIu32" old:%"PRIu32" weighting %"PRIu8" old:%"PRIu8,
currentPartitionId, leaderData.partitionId, currentWeighting, leaderData.weighting);
currentPartitionId, leaderData.partitionId, currentWeighting, leaderData.weighting);
if ((leaderData.partitionId != currentPartitionId) ||
(leaderData.weighting != currentWeighting)) {
int retVal = thread_bootstrap_partition_process(cur, connectivityTlv.activeRouters, &leaderData,NULL);
(leaderData.weighting != currentWeighting)) {
int retVal = thread_bootstrap_partition_process(cur, connectivityTlv.activeRouters, &leaderData, NULL);
if (retVal > 0) {
// New partition is Higher
scan_result = thread_info(cur)->thread_attach_scanned_parent;
}
}
else if (leaderData.partitionId == currentPartitionId) {
} else if (leaderData.partitionId == currentPartitionId) {
thread_link_quality_e currentLqi;
//Calculate Current summed LQI
scan_result = thread_info(cur)->thread_attach_scanned_parent;
@ -669,7 +668,7 @@ void thread_mle_parent_discover_receive_cb(int8_t interface_id, mle_message_t *m
if (newLqi == currentLqi) {
//Compare if REED
if (thread_is_router_addr(scan_result->shortAddress) &&
!thread_is_router_addr(srcAddress) ) {
!thread_is_router_addr(srcAddress)) {
scan_result = NULL;
tr_debug("Dropped Response from REED over router");
} else if (connectivityTlv.parentPriority > scan_result->parentPriority) {
@ -679,8 +678,8 @@ void thread_mle_parent_discover_receive_cb(int8_t interface_id, mle_message_t *m
scan_result = NULL;
} else {
tr_debug("Similar LQI check connectivity old: %d,%d,%d new:%d,%d,%d",
scan_result->linkQuality3, scan_result->linkQuality2, scan_result->linkQuality1,
connectivityTlv.linkQuality3, connectivityTlv.linkQuality2, connectivityTlv.linkQuality1);
scan_result->linkQuality3, scan_result->linkQuality2, scan_result->linkQuality1,
connectivityTlv.linkQuality3, connectivityTlv.linkQuality2, connectivityTlv.linkQuality1);
if (scan_result->linkQuality3 > connectivityTlv.linkQuality3) {
scan_result = NULL;
@ -696,7 +695,7 @@ void thread_mle_parent_discover_receive_cb(int8_t interface_id, mle_message_t *m
scan_result->linkQuality1 > connectivityTlv.linkQuality1) {
scan_result = NULL;
}
if(!scan_result) {
if (!scan_result) {
tr_debug("Dropped Connectivity is not as good");
}
}
@ -705,7 +704,7 @@ void thread_mle_parent_discover_receive_cb(int8_t interface_id, mle_message_t *m
}
}
}
if (scan_result && thread_host_prefer_parent_response(cur, scan_result, version, &connectivityTlv)){
if (scan_result && thread_host_prefer_parent_response(cur, scan_result, version, &connectivityTlv)) {
scan_result = NULL;
}
@ -741,7 +740,7 @@ void thread_mle_parent_discover_receive_cb(int8_t interface_id, mle_message_t *m
scan_result->keySequence = common_read_32_bit(security_headers->Keysource);
tr_debug("Current %"PRIu32" RX %"PRIu32" Cnt%"PRIu32, scan_result->leader_data.partitionId, leaderData.partitionId, scan_result->linLayerFrameCounter);
}
break;
break;
}
default:
break;
@ -773,7 +772,7 @@ static void thread_mle_child_request_receive_cb(int8_t interface_id, mle_message
}
/* Check that message is from link-local scope */
if(!addr_is_ipv6_link_local(mle_msg->packet_src_address)) {
if (!addr_is_ipv6_link_local(mle_msg->packet_src_address)) {
return;
}
@ -879,7 +878,7 @@ static void thread_mle_child_request_receive_cb(int8_t interface_id, mle_message
scan_result->security_key_index = security_headers->KeyIndex;
}
mlme_device_descriptor_t device_desc;
mac_helper_device_description_write(cur, &device_desc, entry_temp->mac64, entry_temp->mac16,scan_result->linLayerFrameCounter, false);
mac_helper_device_description_write(cur, &device_desc, entry_temp->mac64, entry_temp->mac16, scan_result->linLayerFrameCounter, false);
mac_helper_devicetable_set(&device_desc, cur, entry_temp->index, security_headers->KeyIndex, new_entry_created);
thread_info(cur)->thread_attached_state = THREAD_STATE_CONNECTED;
@ -909,7 +908,7 @@ static void thread_mle_child_request_receive_cb(int8_t interface_id, mle_message
//
if (routeTlv.tlvType == MLE_TYPE_ROUTE && routeTlv.tlvLen) {
thread_router_bootstrap_route_tlv_push(cur, routeTlv.dataPtr, routeTlv.tlvLen , thread_compute_link_margin(mle_msg->dbm), entry_temp);
thread_router_bootstrap_route_tlv_push(cur, routeTlv.dataPtr, routeTlv.tlvLen, thread_compute_link_margin(mle_msg->dbm), entry_temp);
}
thread_bootstrap_attached_ready(cur);
@ -926,7 +925,7 @@ static int8_t thread_end_device_synch_start(protocol_interface_info_entry_t *cur
{
mle_message_timeout_params_t timeout;
uint32_t keySequence;
uint16_t buf_id = mle_service_msg_allocate(cur->id, 150 + 3 + 6 + 10, true,MLE_COMMAND_CHILD_UPDATE_REQUEST);
uint16_t buf_id = mle_service_msg_allocate(cur->id, 150 + 3 + 6 + 10, true, MLE_COMMAND_CHILD_UPDATE_REQUEST);
if (buf_id == 0) {
return -1;
}
@ -955,7 +954,7 @@ static int8_t thread_end_device_synch_start(protocol_interface_info_entry_t *cur
ptr = mle_tlv_req_tlv(ptr, tlv_req, 2);
}
if (mle_service_update_length_by_ptr(buf_id,ptr)!= 0) {
if (mle_service_update_length_by_ptr(buf_id, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
@ -980,7 +979,7 @@ void thread_endevice_synch_start(protocol_interface_info_entry_t *cur)
mac_neighbor_table_entry_t *mac_entry = mac_neighbor_entry_get_by_mac64(mac_neighbor_info(cur), cur->thread_info->thread_endnode_parent->mac64, true, &new_entry_created);
if (mac_entry) {
//Add link margin 64
thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, mac_entry->index,64, new_entry_created);
thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, mac_entry->index, 64, new_entry_created);
thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, mac_entry->index);
mac_entry->mac16 = cur->thread_info->thread_endnode_parent->shortAddress;
@ -992,7 +991,7 @@ void thread_endevice_synch_start(protocol_interface_info_entry_t *cur)
// Add the parent to the MAC table (for e.g. secured/fragmented Child Update Response)
mlme_device_descriptor_t device_desc;
mac_helper_device_description_write(cur, &device_desc, mac_entry->mac64, mac_entry->mac16,0, false);
mac_helper_device_description_write(cur, &device_desc, mac_entry->mac64, mac_entry->mac16, 0, false);
mac_helper_devicetable_set(&device_desc, cur, mac_entry->index, cur->mac_parameters->mac_default_key_index, new_entry_created);
}
}
@ -1046,7 +1045,7 @@ static bool thread_child_id_req_timeout(int8_t interface_id, uint16_t msgId, boo
/* If scanned parent is from other partition, delete from MLE table */
if ((scanned_parent->leader_data.partitionId != thread_info(cur)->thread_leader_data->partitionId) ||
(scanned_parent->leader_data.weighting != thread_info(cur)->thread_leader_data->weighting)) {
(scanned_parent->leader_data.weighting != thread_info(cur)->thread_leader_data->weighting)) {
entry_temp = mac_neighbor_table_address_discover(mac_neighbor_info(cur), scanned_parent->mac64, ADDR_802_15_4_LONG);
if (entry_temp) {
bool my_parent = thread_check_is_this_my_parent(cur, entry_temp);
@ -1060,7 +1059,7 @@ static bool thread_child_id_req_timeout(int8_t interface_id, uint16_t msgId, boo
}
if (thread_info(cur)->thread_endnode_parent) {
mac_helper_coordinator_address_set(cur, ADDR_802_15_4_LONG, thread_info(cur)->thread_endnode_parent->mac64);
mac_helper_coordinator_address_set(cur, ADDR_802_15_4_LONG, thread_info(cur)->thread_endnode_parent->mac64);
}
if (cur->thread_info->routerShortAddress == 0xfffe ||
!thread_is_router_addr(cur->thread_info->routerShortAddress)) {
@ -1100,7 +1099,7 @@ static int thread_attach_child_id_request_build(protocol_interface_info_entry_t
//Set ll64
address_ptr = mle_service_get_msg_destination_address_pointer(buf_id);
memcpy(address_ptr, ADDR_LINK_LOCAL_PREFIX, 8);
memcpy(address_ptr + 8 , scan_parent->mac64, 8);
memcpy(address_ptr + 8, scan_parent->mac64, 8);
address_ptr[8] ^= 2;
thread_management_get_current_keysequence(cur->id, &keySequence);
@ -1124,7 +1123,7 @@ static int thread_attach_child_id_request_build(protocol_interface_info_entry_t
//Add ML-EID
if ((mode & MLE_FFD_DEV) == 0) {
ptr = thread_ml_address_tlv_write(ptr,cur);
ptr = thread_ml_address_tlv_write(ptr, cur);
}
reqTlvCnt = 2;
@ -1142,7 +1141,7 @@ static int thread_attach_child_id_request_build(protocol_interface_info_entry_t
//add only active timestamp to the child id request
ptr = thread_active_timestamp_write(cur, ptr);
if (mle_service_update_length_by_ptr(buf_id,ptr)!= 0) {
if (mle_service_update_length_by_ptr(buf_id, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
timeout.retrans_max = THREAD_CHILD_ID_REQUEST_MAX_RETRY_CNT;
@ -1241,7 +1240,7 @@ bool thread_host_bootstrap_child_update(protocol_interface_info_entry_t *cur, co
ptr = thread_address_registration_tlv_write(ptr, cur);
}
if (mle_service_update_length_by_ptr(bufId,ptr)!= 0) {
if (mle_service_update_length_by_ptr(bufId, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
timeout.retrans_max = 3;
@ -1249,7 +1248,7 @@ bool thread_host_bootstrap_child_update(protocol_interface_info_entry_t *cur, co
timeout.timeout_max = 4;
timeout.delay = MLE_NO_DELAY;
net_host_mode_t macHostMode;
if (mac_data_poll_host_mode_get(cur,&macHostMode) == 0 && macHostMode == NET_HOST_RX_ON_IDLE) {
if (mac_data_poll_host_mode_get(cur, &macHostMode) == 0 && macHostMode == NET_HOST_RX_ON_IDLE) {
thread_end_device_mode_set(cur, false);
}
mac_data_poll_init_protocol_poll(cur);
@ -1289,7 +1288,7 @@ int thread_host_bootstrap_child_update_negative_response(protocol_interface_info
ptr = mle_tlv_write_response(ptr, challenge->dataPtr, challenge->tlvLen);
}
if (mle_service_update_length_by_ptr(bufId,ptr)!= 0) {
if (mle_service_update_length_by_ptr(bufId, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}

File diff suppressed because it is too large Load Diff

View File

@ -92,7 +92,7 @@ typedef struct {
static NS_LIST_DEFINE(leader_service_instance_list, thread_leader_service_t, link);
static void thread_leader_service_commissioner_timeout_cb(void* arg);
static void thread_leader_service_commissioner_timeout_cb(void *arg);
/* Private functions */
static thread_leader_service_t *thread_leader_service_find_by_interface(int8_t interface_id)
@ -119,7 +119,7 @@ static thread_leader_service_t *thread_leader_service_find_by_service(int8_t ser
return this;
}
static char* thread_commissioning_if_commissioner_id_get(int8_t interface_id)
static char *thread_commissioning_if_commissioner_id_get(int8_t interface_id)
{
protocol_interface_info_entry_t *cur;
@ -141,16 +141,16 @@ static bool thread_leader_service_commissioner_address_changed(int8_t interface_
return false;
}
if(!memcmp(cur->thread_info->registered_commissioner.border_router_address, border_router_address, 16)) {
if (!memcmp(cur->thread_info->registered_commissioner.border_router_address, border_router_address, 16)) {
// Border router address is same
return false;
}
if( common_read_16_bit(&border_router_address[14]) >= 0xfc00 ) {
if (common_read_16_bit(&border_router_address[14]) >= 0xfc00) {
// Address is not valid RLOC we dont change address to this.
return false;
}
memcpy(cur->thread_info->registered_commissioner.border_router_address, border_router_address, 16);
thread_leader_service_network_data_changed(cur,false,true);
thread_leader_service_network_data_changed(cur, false, true);
// This will trigger advertisement either from following commands or from leader tick
return true;
}
@ -192,12 +192,14 @@ static bool thread_leader_service_commissioner_unregister(int8_t interface_id, u
link_configuration_s *linkConfiguration;
linkConfiguration = thread_joiner_application_get_config(interface_id);
if(!linkConfiguration)
if (!linkConfiguration) {
return false;
}
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur || !cur->thread_info || !cur->thread_info->leader_private_data)
if (!cur || !cur->thread_info || !cur->thread_info->leader_private_data) {
return false;
}
if (cur->thread_info->registered_commissioner.session_id != session_id) {
tr_debug("Commissioner session id not valid - unregister failed");
@ -206,9 +208,9 @@ static bool thread_leader_service_commissioner_unregister(int8_t interface_id, u
// Removing commissioner we need to increase the session id
cur->thread_info->registered_commissioner.session_id++;
if(cur->thread_info->registered_commissioner.commissioner_id_ptr){
ns_dyn_mem_free(cur->thread_info->registered_commissioner.commissioner_id_ptr);
cur->thread_info->registered_commissioner.commissioner_id_ptr = NULL;
if (cur->thread_info->registered_commissioner.commissioner_id_ptr) {
ns_dyn_mem_free(cur->thread_info->registered_commissioner.commissioner_id_ptr);
cur->thread_info->registered_commissioner.commissioner_id_ptr = NULL;
}
cur->thread_info->registered_commissioner.commissioner_valid = false;
@ -234,7 +236,7 @@ static bool thread_leader_service_commissioner_session_refresh(int8_t interface_
return false;
}
if(cur->thread_info->registered_commissioner.commissioner_registration == THREAD_COMMISSIONER_NOT_REGISTERED) {
if (cur->thread_info->registered_commissioner.commissioner_registration == THREAD_COMMISSIONER_NOT_REGISTERED) {
tr_debug("Commissioner not registered - refresh failed");
return false;
}
@ -252,7 +254,7 @@ static bool thread_leader_service_commissioner_session_refresh(int8_t interface_
return true;
}
static void thread_leader_service_commissioner_timeout_cb(void* arg)
static void thread_leader_service_commissioner_timeout_cb(void *arg)
{
thread_info_t *thread_ptr = arg;
@ -266,32 +268,30 @@ static void thread_leader_service_commissioner_timeout_cb(void* arg)
return;
}
switch(thread_ptr->registered_commissioner.commissioner_registration)
{
case THREAD_COMMISSIONER_REGISTRATION_OBSOLETE:
thread_ptr->registered_commissioner.commissioner_registration = THREAD_COMMISSIONER_NOT_REGISTERED;
if(false == thread_leader_service_commissioner_unregister(thread_ptr->interface_id, thread_ptr->registered_commissioner.session_id)){
tr_debug("Commissioner registration remove failed");
}
else{
tr_debug("Commissioner registration removed");
}
break;
case THREAD_COMMISSIONER_REGISTERED:
tr_debug("Commissioner registration obsoleted");
thread_ptr->registered_commissioner.commissioner_registration = THREAD_COMMISSIONER_REGISTRATION_OBSOLETE;
thread_ptr->registered_commissioner.commissioner_timeout = eventOS_timeout_ms(thread_leader_service_commissioner_timeout_cb, COMMISSIONER_REMOVE_TIMEOUT, thread_ptr);
break;
case THREAD_COMMISSIONER_NOT_REGISTERED:
default:
break;
switch (thread_ptr->registered_commissioner.commissioner_registration) {
case THREAD_COMMISSIONER_REGISTRATION_OBSOLETE:
thread_ptr->registered_commissioner.commissioner_registration = THREAD_COMMISSIONER_NOT_REGISTERED;
if (false == thread_leader_service_commissioner_unregister(thread_ptr->interface_id, thread_ptr->registered_commissioner.session_id)) {
tr_debug("Commissioner registration remove failed");
} else {
tr_debug("Commissioner registration removed");
}
break;
case THREAD_COMMISSIONER_REGISTERED:
tr_debug("Commissioner registration obsoleted");
thread_ptr->registered_commissioner.commissioner_registration = THREAD_COMMISSIONER_REGISTRATION_OBSOLETE;
thread_ptr->registered_commissioner.commissioner_timeout = eventOS_timeout_ms(thread_leader_service_commissioner_timeout_cb, COMMISSIONER_REMOVE_TIMEOUT, thread_ptr);
break;
case THREAD_COMMISSIONER_NOT_REGISTERED:
default:
break;
}
}
static int thread_leader_service_commissioner_register(int8_t interface_id, uint8_t border_router_address[static 16],
uint8_t *commissioner_id_ptr, uint16_t commissioner_id_len,
uint16_t *session_id)
uint8_t *commissioner_id_ptr, uint16_t commissioner_id_len,
uint16_t *session_id)
{
/* Save commissioner data to new commissioner structure and start advertise it
Commissioner session id
@ -317,7 +317,7 @@ static int thread_leader_service_commissioner_register(int8_t interface_id, uint
}
/* If commissioner already registered */
if(cur->thread_info->registered_commissioner.commissioner_valid &&
if (cur->thread_info->registered_commissioner.commissioner_valid &&
cur->thread_info->registered_commissioner.commissioner_registration == THREAD_COMMISSIONER_REGISTERED) {
return -2;
}
@ -385,7 +385,7 @@ static int thread_leader_service_active_set_cb(int8_t service_id, uint8_t source
}
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(this->interface_id);
linkConfiguration = thread_joiner_application_get_config(this->interface_id);
if(!cur || !cur->thread_info || !linkConfiguration || !cur->thread_info->leader_private_data){
if (!cur || !cur->thread_info || !linkConfiguration || !cur->thread_info->leader_private_data) {
return -1;
}
@ -399,7 +399,7 @@ static int thread_leader_service_active_set_cb(int8_t service_id, uint8_t source
}
if (3 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_CHANNEL, &ptr) &&
(linkConfiguration->rfChannel != common_read_16_bit(&ptr[1]) || linkConfiguration->channel_page != *ptr)){
(linkConfiguration->rfChannel != common_read_16_bit(&ptr[1]) || linkConfiguration->channel_page != *ptr)) {
tr_debug("Channel changed");
changing_connectivity = true;
// validity check for channel page
@ -410,7 +410,7 @@ static int thread_leader_service_active_set_cb(int8_t service_id, uint8_t source
}
}
if (2 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_PANID, &ptr) &&
linkConfiguration->panId != common_read_16_bit(ptr)){
linkConfiguration->panId != common_read_16_bit(ptr)) {
tr_debug("PANID changed");
changing_connectivity = true;
if (common_read_16_bit(ptr) > 0xfffe) {
@ -427,13 +427,13 @@ static int thread_leader_service_active_set_cb(int8_t service_id, uint8_t source
}
}
if ( 8 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA, &ptr) &&
memcmp(linkConfiguration->mesh_local_ula_prefix,ptr,8) != 0) {
if (8 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA, &ptr) &&
memcmp(linkConfiguration->mesh_local_ula_prefix, ptr, 8) != 0) {
tr_debug("ML prefix changed");
changing_connectivity = true;
}
if ( 16 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_NETWORK_MASTER_KEY, &ptr) &&
memcmp(linkConfiguration->master_key,ptr,16) != 0) {
if (16 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_NETWORK_MASTER_KEY, &ptr) &&
memcmp(linkConfiguration->master_key, ptr, 16) != 0) {
tr_debug("Master key changed");
changing_connectivity = true;
}
@ -456,17 +456,17 @@ static int thread_leader_service_active_set_cb(int8_t service_id, uint8_t source
}
}
if(8 > thread_meshcop_tlv_data_get_uint64(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_ACTIVE_TIME_STAMP, &timestamp)){
if (8 > thread_meshcop_tlv_data_get_uint64(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_ACTIVE_TIME_STAMP, &timestamp)) {
tr_warn("no timestamp");
ret = -1;
goto send_response;
}
if (timestamp < linkConfiguration->timestamp){
if (timestamp < linkConfiguration->timestamp) {
tr_warn("older timestamp");
ret = -1;
goto send_response;
}
if (timestamp == linkConfiguration->timestamp){
if (timestamp == linkConfiguration->timestamp) {
tr_warn("same timestamp");
ret = -1;
goto send_response;
@ -477,8 +477,8 @@ static int thread_leader_service_active_set_cb(int8_t service_id, uint8_t source
// Node changed settings and Registered commissioner send changed_notify to commissioner
tr_info("Notify commissioner that settings are changed");
coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, cur->thread_info->registered_commissioner.border_router_address,
THREAD_MANAGEMENT_PORT, COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_DATASET_CHANGED,
COAP_CT_OCTET_STREAM, NULL, 0, NULL);
THREAD_MANAGEMENT_PORT, COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_DATASET_CHANGED,
COAP_CT_OCTET_STREAM, NULL, 0, NULL);
}
}
if (changing_connectivity) {
@ -486,7 +486,7 @@ static int thread_leader_service_active_set_cb(int8_t service_id, uint8_t source
tr_info("creating pending configuration");
if (thread_joiner_application_pending_config_exists(this->interface_id) &&
thread_joiner_application_pending_config_timestamp_get(this->interface_id) >= timestamp ) {
thread_joiner_application_pending_config_timestamp_get(this->interface_id) >= timestamp) {
tr_info("Pending config is newer we reject");
ret = -1;
goto send_response;
@ -500,7 +500,7 @@ static int thread_leader_service_active_set_cb(int8_t service_id, uint8_t source
// Start distributing pending configuration
thread_joiner_application_pending_config_add_missing_fields(this->interface_id);
thread_joiner_application_pending_config_timestamp_set(this->interface_id, timestamp);
thread_joiner_application_pending_config_enable(this->interface_id, thread_delay_timer_default*1000);
thread_joiner_application_pending_config_enable(this->interface_id, thread_delay_timer_default * 1000);
} else {
tr_info("updating active configuration");
@ -553,7 +553,7 @@ static int thread_leader_service_pending_set_cb(int8_t service_id, uint8_t sourc
}
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(this->interface_id);
linkConfiguration = thread_joiner_application_get_config(this->interface_id);
if(!cur || !cur->thread_info || !linkConfiguration || !cur->thread_info->leader_private_data){
if (!cur || !cur->thread_info || !linkConfiguration || !cur->thread_info->leader_private_data) {
return -1;
}
@ -574,23 +574,23 @@ static int thread_leader_service_pending_set_cb(int8_t service_id, uint8_t sourc
thread_leader_service_commissioner_address_changed(this->interface_id, source_address);
msg_from_commissioner = true;
}
if ( 16 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_NETWORK_MASTER_KEY, &secret_ptr) &&
memcmp(linkConfiguration->master_key,secret_ptr,16) != 0) {
if (16 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_NETWORK_MASTER_KEY, &secret_ptr) &&
memcmp(linkConfiguration->master_key, secret_ptr, 16) != 0) {
tr_debug("Master key changed");
master_key_changed = true;
}
if(8 > thread_meshcop_tlv_data_get_uint64(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_PENDING_TIMESTAMP, &pending_timestamp)){
if (8 > thread_meshcop_tlv_data_get_uint64(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_PENDING_TIMESTAMP, &pending_timestamp)) {
tr_warn("no timestamp");
ret = -1;
goto send_response;
}
if(4 > thread_meshcop_tlv_data_get_uint32(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_DELAY_TIMER, &delay_timer)){
if (4 > thread_meshcop_tlv_data_get_uint32(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_DELAY_TIMER, &delay_timer)) {
tr_warn("no delay timer");
ret = -1;
goto send_response;
}
if(8 > thread_meshcop_tlv_data_get_uint64(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_ACTIVE_TIME_STAMP, &active_timestamp)){
if (8 > thread_meshcop_tlv_data_get_uint64(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_ACTIVE_TIME_STAMP, &active_timestamp)) {
tr_warn("no active timestamp");
ret = -1;
goto send_response;
@ -602,27 +602,27 @@ static int thread_leader_service_pending_set_cb(int8_t service_id, uint8_t sourc
}
if (thread_joiner_application_pending_config_exists(this->interface_id) &&
pending_timestamp <= thread_joiner_application_pending_config_timestamp_get(this->interface_id)){
pending_timestamp <= thread_joiner_application_pending_config_timestamp_get(this->interface_id)) {
tr_warn("Older or same pending timestamp");
ret = -1;
goto send_response;
}
if (delay_timer > THREAD_MAX_DELAY_TIMER_SECONDS*1000) {
delay_timer = THREAD_MAX_DELAY_TIMER_SECONDS*1000;
if (delay_timer > THREAD_MAX_DELAY_TIMER_SECONDS * 1000) {
delay_timer = THREAD_MAX_DELAY_TIMER_SECONDS * 1000;
}
if (master_key_changed &&
delay_timer < thread_delay_timer_default*1000) {
delay_timer < thread_delay_timer_default * 1000) {
//If message Changes the master key default value is used
delay_timer = thread_delay_timer_default*1000;
delay_timer = thread_delay_timer_default * 1000;
}
if (delay_timer < THREAD_DELAY_TIMER_MINIMAL_SECONDS*1000) {
if (delay_timer < THREAD_DELAY_TIMER_MINIMAL_SECONDS * 1000) {
// Absolute minimum value allowed
delay_timer = THREAD_DELAY_TIMER_MINIMAL_SECONDS*1000;
delay_timer = THREAD_DELAY_TIMER_MINIMAL_SECONDS * 1000;
}
if (thread_joiner_application_pending_config_create(this->interface_id, request_ptr->payload_ptr, request_ptr->payload_len) != 0){
if (thread_joiner_application_pending_config_create(this->interface_id, request_ptr->payload_ptr, request_ptr->payload_len) != 0) {
tr_error("Could not create pending config");
response_code = COAP_MSG_CODE_RESPONSE_INTERNAL_SERVER_ERROR;
goto send_error_response;
@ -634,8 +634,8 @@ static int thread_leader_service_pending_set_cb(int8_t service_id, uint8_t sourc
// Node changed settings and Registered commissioner send changed_notify to commissioner
tr_info("Notify commissioner that settings are changed");
coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, cur->thread_info->registered_commissioner.border_router_address,
THREAD_MANAGEMENT_PORT, COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_DATASET_CHANGED,
COAP_CT_OCTET_STREAM, NULL, 0, NULL);
THREAD_MANAGEMENT_PORT, COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_DATASET_CHANGED,
COAP_CT_OCTET_STREAM, NULL, 0, NULL);
}
}
@ -676,7 +676,7 @@ static int thread_leader_service_commissioner_set_cb(int8_t service_id, uint8_t
return -1;
}
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(this->interface_id);
if(!cur || !cur->thread_info || !cur->thread_info->leader_private_data){
if (!cur || !cur->thread_info || !cur->thread_info->leader_private_data) {
return -1;
}
@ -687,13 +687,13 @@ static int thread_leader_service_commissioner_set_cb(int8_t service_id, uint8_t
goto send_error_response;
}
//Check if the CoAp payload is greater than maximum commissioner data size and reject
if (request_ptr->payload_len > THREAD_MAX_COMMISSIONER_DATA_SIZE){
if (request_ptr->payload_len > THREAD_MAX_COMMISSIONER_DATA_SIZE) {
tr_error("Payload length greater than maximum commissioner data size");
ret = -1;
goto send_response;
}
//TODO must be checked against a list of all non permissible TLVs
if (2 <= thread_meshcop_tlv_data_get_uint16(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_BORDER_ROUTER_LOCATOR, &br_locator)){
if (2 <= thread_meshcop_tlv_data_get_uint16(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_BORDER_ROUTER_LOCATOR, &br_locator)) {
tr_error("BORDER ROUTER TLV should not be present");
ret = -1;
goto send_response;
@ -716,7 +716,7 @@ static int thread_leader_service_commissioner_set_cb(int8_t service_id, uint8_t
thread_leader_service_commissioner_address_changed(this->interface_id, source_address);
/* Set steering data */
if(thread_meshcop_tlv_exist(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_STEERING_DATA)){
if (thread_meshcop_tlv_exist(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_STEERING_DATA)) {
steering_data_len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_STEERING_DATA, &steering_data_ptr);
ret = thread_leader_service_steering_data_set(this->interface_id, steering_data_ptr, steering_data_len);
tr_info("steering data set : %s, ret %d", trace_array(steering_data_ptr, steering_data_len), ret);
@ -818,7 +818,7 @@ static int thread_leader_service_router_id_allocate(const uint8_t *eui64, protoc
}
//We need to allocate new Router ID
uint16_t random_base = randLIB_get_random_in_range(0,64);
uint16_t random_base = randLIB_get_random_in_range(0, 64);
// New addresses are assigned randomly
for (i = 0; i < 64; i++) {
uint16_t id = (random_base + i) % (MAX_ROUTER_ID + 1);
@ -909,7 +909,7 @@ static int thread_leader_service_routerid_assign(protocol_interface_info_entry_t
}
*router_id = router_id_response.shortAddress;
router_id_mask_out[0] = router_id_response.dataSeq;
memcpy(&router_id_mask_out[1], router_id_response.routerID , 8);
memcpy(&router_id_mask_out[1], router_id_response.routerID, 8);
return 0;
}
@ -965,13 +965,13 @@ static int thread_leader_service_assign_cb(int8_t service_id, uint8_t source_add
// LOCATOR is optional others are mandatory
(void)thread_meshcop_tlv_data_get_uint16(request_ptr->payload_ptr, request_ptr->payload_len, TMFCOP_TLV_RLOC16, &router_id);
if (8 > thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, TMFCOP_TLV_MAC_ADDRESS, &mac_ptr) ) {
if (8 > thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, TMFCOP_TLV_MAC_ADDRESS, &mac_ptr)) {
// Failure in message
return -1;
}
// Failure in message
if (1 > thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, TMFCOP_TLV_STATUS, &status) ) {
// Failure in message
if (1 > thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, TMFCOP_TLV_STATUS, &status)) {
return -1;
}
@ -1088,10 +1088,10 @@ static int thread_leader_service_petition_cb(int8_t service_id, uint8_t source_a
// Commissioner already registered - reject and send commissioner ID
ptr = thread_meshcop_tlv_data_write_uint8(ptr, MESHCOP_TLV_STATE, 0xff);
commissioner_id_ptr = thread_commissioning_if_commissioner_id_get(this->interface_id);
if(commissioner_id_ptr)
if (commissioner_id_ptr) {
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_COMMISSIONER_ID, strlen(commissioner_id_ptr), (uint8_t *)commissioner_id_ptr);
}
else{
}
} else {
// Reject, anyhow, no commissioner registered - no commissioner ID
ptr = thread_meshcop_tlv_data_write_uint8(ptr, MESHCOP_TLV_STATE, 0xff);
}
@ -1134,11 +1134,10 @@ static int thread_leader_service_petition_ka_cb(int8_t service_id, uint8_t sourc
if (2 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_COMMISSIONER_SESSION_ID, &ptr)) {
session_id = common_read_16_bit(ptr);
}
if (1 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_STATE, &ptr))
{
if (1 <= thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_STATE, &ptr)) {
if (*ptr == 0x01) {
state = thread_leader_service_commissioner_session_refresh(this->interface_id, session_id);
} else if(*ptr == 0xff) {
} else if (*ptr == 0xff) {
thread_leader_service_commissioner_unregister(this->interface_id, session_id);
state = false;
}
@ -1273,7 +1272,7 @@ static int thread_leader_service_leader_start(protocol_interface_info_entry_t *c
cur->lowpan_info |= INTERFACE_NWK_ROUTER_DEVICE;
cur->lowpan_info &= ~INTERFACE_NWK_CONF_MAC_RX_OFF_IDLE;
mac_helper_default_security_level_set(cur, SEC_ENC_MIC32);
mac_helper_default_security_key_id_mode_set(cur,MAC_KEY_ID_MODE_IDX);
mac_helper_default_security_key_id_mode_set(cur, MAC_KEY_ID_MODE_IDX);
thread_discovery_responser_enable(cur->id, true);
if (cur->mac_api) {
mlme_start_t start_req;
@ -1283,7 +1282,7 @@ static int thread_leader_service_leader_start(protocol_interface_info_entry_t *c
start_req.PANCoordinator = true;
start_req.LogicalChannel = cur->mac_parameters->mac_channel;
start_req.PANId = cur->mac_parameters->pan_id;
cur->mac_api->mlme_req(cur->mac_api, MLME_START , &start_req);
cur->mac_api->mlme_req(cur->mac_api, MLME_START, &start_req);
}
return 0;
}
@ -1293,7 +1292,7 @@ static int thread_leader_service_leader_init(protocol_interface_info_entry_t *cu
//Clean All allocated stuff's
thread_info_t *thread_info = cur->thread_info;
// mark and delete previous leader network data information
thread_network_data_router_id_mark_delete(&thread_info->networkDataStorage,thread_router_addr_from_id(cur->thread_info->thread_leader_data->leaderRouterId), true);
thread_network_data_router_id_mark_delete(&thread_info->networkDataStorage, thread_router_addr_from_id(cur->thread_info->thread_leader_data->leaderRouterId), true);
thread_network_data_router_id_free(&thread_info->networkDataStorage, false, cur);
thread_leader_service_leader_data_free(thread_info);
@ -1330,7 +1329,7 @@ static void thread_leader_service_private_routemask_init(thread_leader_info_t *l
memset(leader_info, 0, sizeof(thread_leader_info_t));
leader_info->maskSeq = randLIB_get_8bit();
uint8_t i;
for (i=0; i<64; i++) {
for (i = 0; i < 64; i++) {
leader_info->thread_router_id_list[i].reUsePossible = true;
leader_info->thread_router_id_list[i].validLifeTime = 0xffffffff;
}
@ -1345,7 +1344,7 @@ static void thread_leader_service_interface_setup_activate(protocol_interface_in
thread_leader_service_leader_data_initialize(cur, routerId);
// Test code
if(cur->thread_info->testRandomPartitionId != 0){
if (cur->thread_info->testRandomPartitionId != 0) {
cur->thread_info->thread_leader_data->partitionId = cur->thread_info->testRandomPartitionId;
cur->thread_info->testRandomPartitionId = 0;
}
@ -1539,8 +1538,7 @@ void thread_leader_service_timer(protocol_interface_info_entry_t *cur, uint32_t
if (cur->thread_info->leader_private_data->leader_nvm_sync_timer) {
if ((cur->thread_info->leader_private_data->leader_nvm_sync_timer) > ticks) {
cur->thread_info->leader_private_data->leader_nvm_sync_timer -= ticks;
}
else {
} else {
cur->thread_info->leader_private_data->leader_nvm_sync_timer = 0;
thread_leader_mleid_rloc_map_to_nvm_write(cur);
}
@ -1613,9 +1611,9 @@ void thread_leader_service_thread_partitition_generate(int8_t interface_id, bool
cur->thread_info->routerShortAddress = leaderRloc;
if (cur->thread_info->routerShortAddress == 0xfffe ||
!thread_is_router_addr(cur->thread_info->routerShortAddress)) {
!thread_is_router_addr(cur->thread_info->routerShortAddress)) {
//If we were REED do not use reed address
cur->thread_info->routerShortAddress = thread_router_addr_from_id(randLIB_get_random_in_range(0,MAX_ROUTER_ID));
cur->thread_info->routerShortAddress = thread_router_addr_from_id(randLIB_get_random_in_range(0, MAX_ROUTER_ID));
}
// clean network data
@ -1673,7 +1671,7 @@ int thread_leader_service_thread_partitition_restart(int8_t interface_id, mle_tl
}
// initialize private data
thread_info(cur)->leader_private_data->maskSeq = *routing->dataPtr;
memcpy(thread_info(cur)->leader_private_data->master_router_id_mask,routing->dataPtr + 1, 8);
memcpy(thread_info(cur)->leader_private_data->master_router_id_mask, routing->dataPtr + 1, 8);
for (int i = 0; i < 64; i++) {
if (bit_test(thread_info(cur)->leader_private_data->master_router_id_mask, i)) {
//Active ID
@ -1788,18 +1786,18 @@ static uint8_t *thread_unstable_commission_data_write(protocol_interface_info_en
{
uint8_t length = thread_unstable_commission_data_length(cur);
if( !length) {
if (!length) {
// No unstable TLV in thread 1.0 or if TLV is empty we skip it
return ptr;
}
*ptr++ = THREAD_NWK_DATA_TYPE_COMMISSION_DATA ;
*ptr++ = length;
ptr = thread_meshcop_tlv_data_write_uint16(ptr,MESHCOP_TLV_COMMISSIONER_SESSION_ID, cur->thread_info->registered_commissioner.session_id);
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MESHCOP_TLV_COMMISSIONER_SESSION_ID, cur->thread_info->registered_commissioner.session_id);
if (cur->thread_info->registered_commissioner.commissioner_valid) {
//SET Commision TLV
ptr = thread_meshcop_tlv_data_write(ptr,MESHCOP_TLV_BORDER_ROUTER_LOCATOR, 2, &cur->thread_info->registered_commissioner.border_router_address[14]);
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_BORDER_ROUTER_LOCATOR, 2, &cur->thread_info->registered_commissioner.border_router_address[14]);
if (cur->thread_info->registered_commissioner.steering_data_len) {
ptr = thread_meshcop_tlv_data_write(ptr,MESHCOP_TLV_STEERING_DATA, cur->thread_info->registered_commissioner.steering_data_len, cur->thread_info->registered_commissioner.steering_data);
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_STEERING_DATA, cur->thread_info->registered_commissioner.steering_data_len, cur->thread_info->registered_commissioner.steering_data);
}
}
return ptr;

View File

@ -36,7 +36,8 @@
* Dummy implementation for thread_lowpower_api.
*/
int thread_lowpower_test_probe_send(int8_t interface_id, uint8_t *address, uint8_t *metrics_ptr, uint8_t metrics_len, thread_lowpower_resp_cb response_cb) {
int thread_lowpower_test_probe_send(int8_t interface_id, uint8_t *address, uint8_t *metrics_ptr, uint8_t metrics_len, thread_lowpower_resp_cb response_cb)
{
(void)interface_id;
(void)address;
(void)metrics_ptr;
@ -44,7 +45,8 @@ int thread_lowpower_test_probe_send(int8_t interface_id, uint8_t *address, uint8
(void)response_cb;
return -1;
}
int thread_lowpower_metrics_management_request_send(int8_t interface_id, uint8_t *address, uint8_t series_id, uint8_t series_flags, uint16_t timeout, uint8_t *metrics_ptr, uint8_t metrics_len, thread_lowpower_resp_cb response_cb) {
int thread_lowpower_metrics_management_request_send(int8_t interface_id, uint8_t *address, uint8_t series_id, uint8_t series_flags, uint16_t timeout, uint8_t *metrics_ptr, uint8_t metrics_len, thread_lowpower_resp_cb response_cb)
{
(void)interface_id;
(void)address;

View File

@ -57,7 +57,7 @@ typedef struct management_session {
uint16_t destination_port;
management_set_response_cb *set_response_cb_ptr;
management_get_response_cb *get_response_cb_ptr;
bool native_interface:1;
bool native_interface: 1;
int8_t instance_id;
int8_t interface_id;
int8_t coap_service_id;
@ -153,7 +153,7 @@ int thread_management_recv_get_response_cb(int8_t service_id, uint8_t source_add
} else if (*ptr == 0) {
state = MANAGEMENT_STATE_PENDING;
} else {
state = MANAGEMENT_STATE_REJECT;
state = MANAGEMENT_STATE_REJECT;
}
}
@ -170,7 +170,7 @@ static int thread_management_get_remote_addr(management_session_t *this)
this->destination_port = THREAD_MANAGEMENT_PORT;
this->native_interface = false;
} else if (0 == thread_commissioning_native_commissioner_get_connection_info(this->interface_id,
this->destination_address, &this->destination_port)) {
this->destination_address, &this->destination_port)) {
tr_debug("native interface: dest addr=%s, dest port=%d", trace_ipv6(this->destination_address), this->destination_port);
this->native_interface = true;
} else {
@ -260,7 +260,7 @@ static int thread_management_udp_proxy_virtual_socket_send_cb(int8_t service_id,
/* Send UDP_TX.ntf */
coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, this->destination_address, port,
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_UDP_TRANSMIT_NOTIFICATION, COAP_CT_OCTET_STREAM, payload_ptr, ptr - payload_ptr, NULL);
COAP_MSG_TYPE_NON_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_UDP_TRANSMIT_NOTIFICATION, COAP_CT_OCTET_STREAM, payload_ptr, ptr - payload_ptr, NULL);
ns_dyn_mem_free(payload_ptr);
@ -291,7 +291,7 @@ int thread_management_register(int8_t interface_id)
}
ns_list_add_to_start(&instance_list, this);
if(this->native_interface) {
if (this->native_interface) {
this->coap_service_id = coap_service_initialize(this->interface_id, THREAD_COMMISSIONING_PORT, COAP_SERVICE_OPTIONS_SECURE | COAP_SERVICE_OPTIONS_SECURE_BYPASS, NULL, NULL);
/* Register for UDP_RX.ntf */
coap_service_register_uri(this->coap_service_id, THREAD_URI_UDP_RECVEIVE_NOTIFICATION, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_management_udp_proxy_receive_cb);
@ -343,12 +343,12 @@ int thread_management_set_security_policy(int8_t instance_id, uint8_t options, u
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_SECURITY_POLICY, 3, tlv);
tr_debug("thread management set security policy options:%d rotation time %d", options, rotation_time);
coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE,this->destination_address, this->destination_port,
coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, this->destination_address, this->destination_port,
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_MANAGEMENT_SET, COAP_CT_OCTET_STREAM, payload, ptr - payload, thread_management_recv_set_response_cb);
return 0;
}
int thread_management_set_steering_data(int8_t instance_id,uint16_t session_id, uint8_t *steering_data_ptr, uint8_t steering_data_len, management_set_response_cb *cb_ptr)
int thread_management_set_steering_data(int8_t instance_id, uint16_t session_id, uint8_t *steering_data_ptr, uint8_t steering_data_len, management_set_response_cb *cb_ptr)
{
management_session_t *this = management_find(instance_id);
uint8_t payload[24];/* 4 + 16 + 4*/
@ -412,21 +412,20 @@ int thread_management_get(int8_t instance_id, uint8_t dst_addr[static 16], char
int8_t service_id;
bool wrap_to_udp_tx = false; // messages to Border Agent are send directly without wrapping to UDP_TX
if (!this || fields_count > 32 ) {
if (!this || fields_count > 32) {
return -1;
}
if (!uri_ptr) {
uri_ptr = THREAD_URI_ACTIVE_GET;
uri_ptr = THREAD_URI_ACTIVE_GET;
}
if(!dst_addr) {
if (!dst_addr) {
if (thread_management_get_remote_addr(this)) {
return -2;
}
memcpy(this->final_dest_address, this->destination_address, 16);
}
else{
} else {
if (this->native_interface) {
memcpy(this->final_dest_address, dst_addr, 16);
wrap_to_udp_tx = true;
@ -465,17 +464,16 @@ int thread_management_set(int8_t instance_id, uint8_t dst_addr[static 16], char
if (!this || !data_ptr || data_len < 2) {
return -1;
}
if (uri_ptr == NULL){
uri_ptr = THREAD_URI_MANAGEMENT_SET;
if (uri_ptr == NULL) {
uri_ptr = THREAD_URI_MANAGEMENT_SET;
}
if(!dst_addr){
if (!dst_addr) {
if (thread_management_get_remote_addr(this)) {
return -2;
}
memcpy(this->final_dest_address, this->destination_address, 16);
}
else{
} else {
if (this->native_interface) {
// native commissioner sending to address, need to encapsulate
memcpy(this->final_dest_address, dst_addr, 16);
@ -503,17 +501,20 @@ int thread_management_set(int8_t instance_id, uint8_t dst_addr[static 16], char
return 0;
}
#else
int thread_management_register(int8_t interface_id) {
int thread_management_register(int8_t interface_id)
{
(void)interface_id;
return -1;
}
int thread_management_unregister(int8_t instance_id) {
int thread_management_unregister(int8_t instance_id)
{
(void)instance_id;
return -1;
}
int thread_management_set_security_policy(int8_t instance_id, uint8_t options, uint16_t rotation_time, management_set_response_cb *cb_ptr) {
int thread_management_set_security_policy(int8_t instance_id, uint8_t options, uint16_t rotation_time, management_set_response_cb *cb_ptr)
{
(void)instance_id;
(void) options;
(void)rotation_time;
@ -521,7 +522,8 @@ int thread_management_set_security_policy(int8_t instance_id, uint8_t options, u
return -1;
}
int thread_management_set_steering_data(int8_t instance_id, uint16_t session_id, uint8_t *steering_data_ptr, uint8_t steering_data_len, management_set_response_cb *cb_ptr) {
int thread_management_set_steering_data(int8_t instance_id, uint16_t session_id, uint8_t *steering_data_ptr, uint8_t steering_data_len, management_set_response_cb *cb_ptr)
{
(void)instance_id;
(void) session_id;
(void) steering_data_ptr;
@ -530,7 +532,8 @@ int thread_management_set_steering_data(int8_t instance_id, uint16_t session_id,
return -1;
}
int thread_management_set_commissioning_data_timestamp(int8_t instance_id, uint64_t time, management_set_response_cb *cb_ptr) {
int thread_management_set_commissioning_data_timestamp(int8_t instance_id, uint64_t time, management_set_response_cb *cb_ptr)
{
(void)instance_id;
(void) time;
(void)cb_ptr;

View File

@ -206,7 +206,7 @@ int thread_management_client_router_id_get(int8_t interface_id, uint8_t mac[8],
ptr = thread_tmfcop_tlv_data_write_uint8(ptr, TMFCOP_TLV_STATUS, status);
return coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, destination, THREAD_MANAGEMENT_PORT,
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_ROUTER_ID_ASSIGNMENT, COAP_CT_OCTET_STREAM, payload, ptr - payload, thread_management_client_get_cb);
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_ROUTER_ID_ASSIGNMENT, COAP_CT_OCTET_STREAM, payload, ptr - payload, thread_management_client_get_cb);
}
int thread_management_client_router_id_release(int8_t interface_id, uint8_t mac[8], uint16_t router_id, thread_management_client_router_id_cb *id_cb)
@ -274,7 +274,7 @@ int thread_management_client_network_data_register(int8_t interface_id, uint8_t
tr_debug("thread network data send to %s", trace_ipv6(destination));
return coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, destination, THREAD_MANAGEMENT_PORT,
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_NETWORK_DATA, COAP_CT_OCTET_STREAM, data_ptr, data_len, thread_management_client_register_cb);
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_NETWORK_DATA, COAP_CT_OCTET_STREAM, data_ptr, data_len, thread_management_client_register_cb);
}
int thread_management_client_network_data_unregister(int8_t interface_id, uint16_t rloc16)
@ -292,12 +292,12 @@ int thread_management_client_network_data_unregister(int8_t interface_id, uint16
return -2;
}
ptr = payload;
ptr = thread_tmfcop_tlv_data_write_uint16(ptr,TMFCOP_TLV_RLOC16,rloc16);
ptr = thread_tmfcop_tlv_data_write_uint16(ptr, TMFCOP_TLV_RLOC16, rloc16);
tr_debug("thread network data unregister");
coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, destination, THREAD_MANAGEMENT_PORT,
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_NETWORK_DATA, COAP_CT_OCTET_STREAM, payload, ptr - payload, thread_management_client_register_cb);
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_NETWORK_DATA, COAP_CT_OCTET_STREAM, payload, ptr - payload, thread_management_client_register_cb);
return 0;
}
@ -366,17 +366,17 @@ static int thread_management_client_active_set_response_cb(int8_t service_id, ui
tr_debug("Receiving active set response from leader");
if(!this){
if (!this) {
return -1;
}
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(this->interface_id);
if(!cur || !cur->thread_info){
if (!cur || !cur->thread_info) {
return -2;
}
if(!response_ptr || response_ptr->coap_status == COAP_STATUS_BUILDER_MESSAGE_SENDING_FAILED || !response_ptr->payload_ptr){
if (!response_ptr || response_ptr->coap_status == COAP_STATUS_BUILDER_MESSAGE_SENDING_FAILED || !response_ptr->payload_ptr) {
tr_error("active set failed");
goto getout;
}
@ -409,14 +409,14 @@ int8_t thread_management_client_active_set(int8_t interface_id, uint8_t *dst_add
}
response_ptr = ns_dyn_mem_alloc(response_len);
if(!response_ptr) {
if (!response_ptr) {
tr_warn("Out of mem");
return -2;
}
ptr = thread_joiner_application_next_active_config_write(interface_id, response_ptr);
if (0 == coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, dst_address, THREAD_MANAGEMENT_PORT,
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_ACTIVE_SET, COAP_CT_OCTET_STREAM, response_ptr, (uint16_t)(ptr -response_ptr), thread_management_client_active_set_response_cb)) {
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_ACTIVE_SET, COAP_CT_OCTET_STREAM, response_ptr, (uint16_t)(ptr - response_ptr), thread_management_client_active_set_response_cb)) {
tr_warn("request send failed");
}
ns_dyn_mem_free(response_ptr);
@ -433,17 +433,17 @@ static int thread_management_client_pending_set_response_cb(int8_t service_id, u
tr_debug("Receiving pending set response from leader");
if(!this){
if (!this) {
return -1;
}
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(this->interface_id);
if(!cur || !cur->thread_info){
if (!cur || !cur->thread_info) {
return -2;
}
if(!response_ptr || response_ptr->coap_status == COAP_STATUS_BUILDER_MESSAGE_SENDING_FAILED || !response_ptr->payload_ptr){
if (!response_ptr || response_ptr->coap_status == COAP_STATUS_BUILDER_MESSAGE_SENDING_FAILED || !response_ptr->payload_ptr) {
tr_error("pending set failed");
goto getout;
}
@ -472,14 +472,14 @@ int8_t thread_management_client_pending_set(int8_t interface_id, uint8_t *dst_ad
response_len = thread_joiner_application_next_pending_config_length(interface_id);
response_ptr = ns_dyn_mem_alloc(response_len);
if(!response_ptr) {
if (!response_ptr) {
tr_warn("Out of mem");
return -2;
}
ptr = thread_joiner_application_next_pending_config_build(interface_id,response_ptr);
ptr = thread_joiner_application_next_pending_config_build(interface_id, response_ptr);
if (0 == coap_service_request_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, dst_address, THREAD_MANAGEMENT_PORT,
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_PENDING_SET, COAP_CT_OCTET_STREAM, response_ptr, (uint16_t) (ptr - response_ptr), thread_management_client_pending_set_response_cb)) {
COAP_MSG_TYPE_CONFIRMABLE, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_PENDING_SET, COAP_CT_OCTET_STREAM, response_ptr, (uint16_t)(ptr - response_ptr), thread_management_client_pending_set_response_cb)) {
tr_warn("request send failed");
}
ns_dyn_mem_free(response_ptr);
@ -502,7 +502,7 @@ static int thread_management_client_provision_request_cb(int8_t service_id, uint
thread_joiner_application_provisioning_set(this->interface_id, PROVISIONING_STATUS_NOT_DONE);
// CoAP request timed out
if(!response_ptr) {
if (!response_ptr) {
return 0;
}
@ -514,11 +514,11 @@ static int thread_management_client_provision_request_cb(int8_t service_id, uint
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(this->interface_id);
if(!cur || !cur->thread_info || 1 > thread_meshcop_tlv_data_get_uint8(response_ptr->payload_ptr, response_ptr->payload_len, MESHCOP_TLV_STATE, &state)){
if (!cur || !cur->thread_info || 1 > thread_meshcop_tlv_data_get_uint8(response_ptr->payload_ptr, response_ptr->payload_len, MESHCOP_TLV_STATE, &state)) {
tr_error("provisioning response failed");
return 0;
}
tr_debug("Thread provisioning status %d",state);
tr_debug("Thread provisioning status %d", state);
if (state == 1) {
thread_joiner_application_provisioning_set(this->interface_id, PROVISIONING_STATUS_DONE);
@ -544,7 +544,7 @@ int thread_management_client_provision_request(int8_t interface_id, uint8_t *dst
this = thread_management_find(interface_id);
device_configuration_s *device_configuration_ptr = thread_joiner_application_get_device_config(interface_id);
if(!this || !device_configuration_ptr) {
if (!this || !device_configuration_ptr) {
return -1;
}
length = thread_joiner_application_device_configuration_length(device_configuration_ptr);

View File

@ -88,8 +88,8 @@
#ifdef HAVE_THREAD
#define TRACE_GROUP "thrm"
static const uint8_t thread_discovery_key[16] = {0x78, 0x58, 0x16, 0x86, 0xfd, 0xb4, 0x58,0x0f, 0xb0, 0x92, 0x54, 0x6a, 0xec, 0xbd, 0x15, 0x66};
static const uint8_t thread_discovery_extented_address[8] = {0x35,0x06, 0xfe, 0xb8, 0x23, 0xd4, 0x87, 0x12};
static const uint8_t thread_discovery_key[16] = {0x78, 0x58, 0x16, 0x86, 0xfd, 0xb4, 0x58, 0x0f, 0xb0, 0x92, 0x54, 0x6a, 0xec, 0xbd, 0x15, 0x66};
static const uint8_t thread_discovery_extented_address[8] = {0x35, 0x06, 0xfe, 0xb8, 0x23, 0xd4, 0x87, 0x12};
uint32_t thread_delay_timer_default = THREAD_DELAY_TIMER_DEFAULT_SECONDS;
uint32_t thread_router_selection_jitter = THREAD_ROUTER_SELECTION_JITTER;
@ -99,7 +99,8 @@ uint16_t thread_joiner_port = THREAD_DEFAULT_JOINER_PORT;
* Prototypes
*/
static void thread_discover_key_descriptor_set(struct mac_api_s *api, const uint8_t *key, uint8_t id, uint32_t key32_bit_src, uint8_t attribute_index) {
static void thread_discover_key_descriptor_set(struct mac_api_s *api, const uint8_t *key, uint8_t id, uint32_t key32_bit_src, uint8_t attribute_index)
{
mlme_set_t set_req;
mlme_key_id_lookup_descriptor_t lookup_description;
mlme_key_descriptor_entry_t key_description;
@ -147,10 +148,10 @@ static void thread_discover_device_descriptor_set(struct mac_api_s *api, const u
set_req.attr = macDeviceTable;
set_req.attr_index = attribute_index;
set_req.value_pointer = (void*)&device_desc;
set_req.value_pointer = (void *)&device_desc;
set_req.value_size = sizeof(mlme_device_descriptor_t);
tr_debug("Register Discovery device descriptor");
api->mlme_req(api,MLME_SET , &set_req);
api->mlme_req(api, MLME_SET, &set_req);
}
static void thread_discover_security_material_update(protocol_interface_info_entry_t *cur, const mlme_security_t *security_params)
@ -170,7 +171,7 @@ static void thread_discover_security_material_update(protocol_interface_info_ent
if (!cur->mac_api || !cur->mac_api->mac_storage_sizes_get || cur->mac_api->mac_storage_sizes_get(cur->mac_api, &buffer) != 0) {
return;
}
thread_discover_device_descriptor_set(cur->mac_api, thread_discovery_extented_address, buffer.device_decription_table_size -1);
thread_discover_device_descriptor_set(cur->mac_api, thread_discovery_extented_address, buffer.device_decription_table_size - 1);
}
static void thread_security_trig_pending_key(protocol_interface_info_entry_t *cur)
@ -193,8 +194,8 @@ static void thread_mac_security_key_update_cb(protocol_interface_info_entry_t *c
if (!cur->thread_info || !cur->mac_parameters) {
return;
}
if (cur->mac_parameters->mac_next_key_index && (security_params->KeyIndex == cur->mac_parameters->mac_next_key_index)){
if(cur->thread_info->masterSecretMaterial.keySwitchGuardTimer == 0) {
if (cur->mac_parameters->mac_next_key_index && (security_params->KeyIndex == cur->mac_parameters->mac_next_key_index)) {
if (cur->thread_info->masterSecretMaterial.keySwitchGuardTimer == 0) {
tr_debug("Trig Next Key");
thread_security_trig_pending_key(cur);
}
@ -275,9 +276,9 @@ int8_t thread_node_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootst
cur->lowpan_info |= INTERFACE_NWK_BOOTSRAP_MLE;
rpl_control_remove_domain_from_interface(cur);
//SET MAC key id mode 2 key and device
thread_discover_key_descriptor_set(cur->mac_api, thread_discovery_key,THREAD_DISCOVERY_SECURITY_KEY_INDEX, THREAD_DISCOVERY_SECURITY_KEY_SOURCE,buffer.device_decription_table_size -1);
thread_discover_key_descriptor_set(cur->mac_api, thread_discovery_key, THREAD_DISCOVERY_SECURITY_KEY_INDEX, THREAD_DISCOVERY_SECURITY_KEY_SOURCE, buffer.device_decription_table_size - 1);
thread_discover_device_descriptor_set(cur->mac_api, thread_discovery_extented_address, buffer.device_decription_table_size -1);
thread_discover_device_descriptor_set(cur->mac_api, thread_discovery_extented_address, buffer.device_decription_table_size - 1);
cur->mac_security_key_usage_update_cb = thread_mac_security_key_update_cb;
return 0;
@ -404,7 +405,7 @@ void thread_security_prev_key_generate(protocol_interface_info_entry_t *cur, uin
return;
}
thrKeySequenceCounter = keySequence - 1;
/* Produced keys from Thread security material: MAC key | MLE key */
/* Produced keys from Thread security material: MAC key | MLE key */
thread_key_get(masterKey, key_material, thrKeySequenceCounter);
/* Update keys as primary keys */
key_index = THREAD_KEY_INDEX(thrKeySequenceCounter);
@ -454,9 +455,9 @@ int thread_management_key_sets_calc(protocol_interface_info_entry_t *cur, link_c
// Store all frame counters as zero and update the sequence counter
thread_nvm_store_fast_data_write_all(0, 0, thrKeySequenceCounter);
thread_security_prev_key_generate(cur,linkConfiguration->master_key,linkConfiguration->key_sequence);
thread_security_key_generate(cur,linkConfiguration->master_key,linkConfiguration->key_sequence);
thread_security_next_key_generate(cur,linkConfiguration->master_key,linkConfiguration->key_sequence);
thread_security_prev_key_generate(cur, linkConfiguration->master_key, linkConfiguration->key_sequence);
thread_security_key_generate(cur, linkConfiguration->master_key, linkConfiguration->key_sequence);
thread_security_next_key_generate(cur, linkConfiguration->master_key, linkConfiguration->key_sequence);
ret_val = 0;
}
return ret_val;
@ -538,7 +539,8 @@ int thread_management_increment_key_sequence_counter(int8_t interface_id)
}
int thread_management_get_ml_prefix(int8_t interface_id, uint8_t *prefix_ptr)
{// TODO get from static configuration
{
// TODO get from static configuration
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur || !prefix_ptr) {
@ -754,7 +756,7 @@ static mac_neighbor_table_entry_t *neighbor_data_poll_referesh(protocol_interfac
entry->lifetime = entry->link_lifetime;
return entry;
}
void thread_comm_status_indication_cb(int8_t if_id, const mlme_comm_status_t* status)
void thread_comm_status_indication_cb(int8_t if_id, const mlme_comm_status_t *status)
{
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(if_id);
if (!cur) {
@ -855,7 +857,7 @@ int thread_management_node_init(
arm_nwk_ipv6_opaque_iid_enable(cur->id, true);
}
// Copy the channel list
memset(&cur->mac_parameters->mac_channel_list,0,sizeof(channel_list_s));
memset(&cur->mac_parameters->mac_channel_list, 0, sizeof(channel_list_s));
if (channel_list) {
// Application has given limited set of channels
cur->mac_parameters->mac_channel_list = *channel_list;
@ -865,7 +867,7 @@ int thread_management_node_init(
}
scan_params = &cur->mac_parameters->nwk_scan_params;
memset(&scan_params->stack_chan_list,0,sizeof(channel_list_s));
memset(&scan_params->stack_chan_list, 0, sizeof(channel_list_s));
if (channel_list) {
// Application has given limited set of channels
scan_params->stack_chan_list = *channel_list;
@ -891,9 +893,9 @@ int thread_management_node_init(
cur->ip_forwarding = false;
lowpan_adaptation_indirect_queue_params_set(cur,
THREAD_INDIRECT_BIG_PACKET_THRESHOLD,
THREAD_INDIRECT_BIG_PACKETS_TOTAL,
THREAD_INDIRECT_SMALL_PACKETS_PER_CHILD);
THREAD_INDIRECT_BIG_PACKET_THRESHOLD,
THREAD_INDIRECT_BIG_PACKETS_TOTAL,
THREAD_INDIRECT_SMALL_PACKETS_PER_CHILD);
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_SLEEPY_HOST) {
cur->thread_info->requestFullNetworkData = false;
@ -926,17 +928,14 @@ int thread_management_device_type_set(int8_t interface_id, thread_device_type_e
if (device_type == THREAD_DEVICE_REED) {
// Change mode to router
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_ROUTER;
}
else if (device_type == THREAD_DEVICE_FED) {
} else if (device_type == THREAD_DEVICE_FED) {
//FED devices makes links and makes address resolutions
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_HOST;
cur->thread_info->end_device_link_synch = true;
}
else if (device_type == THREAD_DEVICE_MED) {
} else if (device_type == THREAD_DEVICE_MED) {
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_HOST;
cur->thread_info->end_device_link_synch = false;
}
else if (device_type == THREAD_DEVICE_SED) {
} else if (device_type == THREAD_DEVICE_SED) {
cur->bootsrap_mode = ARM_NWK_BOOTSRAP_MODE_6LoWPAN_SLEEPY_HOST;
cur->thread_info->end_device_link_synch = false;
}
@ -1101,9 +1100,9 @@ int thread_management_get_leader_address(int8_t interface_id, uint8_t *address_b
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (cur) {
if ((cur->thread_info) && (thread_attach_ready(cur) == 0) &&
(cur->thread_info->threadPrivatePrefixInfo.ulaValid) ) {
thread_addr_write_mesh_local_16(address_buffer, thread_router_addr_from_id(cur->thread_info->thread_leader_data->leaderRouterId), cur->thread_info);
return 0;
(cur->thread_info->threadPrivatePrefixInfo.ulaValid)) {
thread_addr_write_mesh_local_16(address_buffer, thread_router_addr_from_id(cur->thread_info->thread_leader_data->leaderRouterId), cur->thread_info);
return 0;
}
}
return -1;
@ -1123,9 +1122,9 @@ int thread_management_get_leader_aloc(int8_t interface_id, uint8_t *address_buff
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (cur) {
if ((cur->thread_info) && (thread_attach_ready(cur) == 0) &&
(cur->thread_info->threadPrivatePrefixInfo.ulaValid)) {
thread_addr_write_mesh_local_16(address_buffer, 0xfc00, cur->thread_info);
return 0;
(cur->thread_info->threadPrivatePrefixInfo.ulaValid)) {
thread_addr_write_mesh_local_16(address_buffer, 0xfc00, cur->thread_info);
return 0;
}
}
return -1;
@ -1193,7 +1192,7 @@ int thread_management_get_parent_address(int8_t interface_id, uint8_t *address_p
if (!cur || !cur->thread_info || !address_ptr) {
return -1;
}
memset(address_ptr,0,16);
memset(address_ptr, 0, 16);
if (cur->thread_info->thread_endnode_parent) {
memcpy(address_ptr, ADDR_LINK_LOCAL_PREFIX, 8);
address_ptr += 8;
@ -1215,14 +1214,14 @@ int thread_management_get_commissioner_address(int8_t interface_id, uint8_t *add
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur || !cur->thread_info|| !address_ptr ) {
if (!cur || !cur->thread_info || !address_ptr) {
return -1;
}
if (!cur->thread_info->registered_commissioner.commissioner_valid) {
return -2;
}
memcpy(address_ptr,cur->thread_info->threadPrivatePrefixInfo.ulaPrefix,8);
memcpy(address_ptr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 8);
memcpy(address_ptr + 8, ADDR_SHORT_ADR_SUFFIC, 6);
common_write_16_bit(0xfc30 + (cur->thread_info->registered_commissioner.session_id % 8), address_ptr + 14);
@ -1241,7 +1240,7 @@ int thread_management_get_commissioner_address(int8_t interface_id, uint8_t *add
int8_t thread_management_set_link_timeout(int8_t interface_id, uint32_t link_timeout)
{
#ifdef HAVE_THREAD
protocol_interface_info_entry_t *cur;
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur) {
@ -1269,7 +1268,7 @@ int8_t thread_management_get_link_timeout(int8_t interface_id, uint32_t *link_ti
#ifdef HAVE_THREAD
const protocol_interface_info_entry_t *cur;
if(!link_timeout) {
if (!link_timeout) {
tr_warn("Invalid input ptr");
return -3;
}
@ -1322,7 +1321,7 @@ int8_t thread_management_get_request_full_nwk_data(int8_t interface_id, bool *fu
#ifdef HAVE_THREAD
const protocol_interface_info_entry_t *cur;
if(!full_nwk_data) {
if (!full_nwk_data) {
tr_warn("Invalid input ptr");
return -3;
}

View File

@ -113,7 +113,7 @@ typedef struct thread_management_server {
} thread_management_server_t;
static NS_LIST_DEFINE(instance_list, thread_management_server_t, link);
void thread_energy_scan_timeout_cb(void* arg);
void thread_energy_scan_timeout_cb(void *arg);
static bool thread_channel_mask_is_channel_set(uint8_t *mask_ptr, uint8_t channel)
{
@ -123,10 +123,12 @@ static bool thread_channel_mask_is_channel_set(uint8_t *mask_ptr, uint8_t channe
n = (channel) / 8;
bit = 1 << (7 - (channel) % 8);
if (n > 5 || channel > 27)
if (n > 5 || channel > 27) {
return false;
if( mask_ptr[n+2] & bit )
}
if (mask_ptr[n + 2] & bit) {
return true;
}
return false;
}
@ -137,14 +139,15 @@ static uint8_t thread_channel_mask_count(uint8_t *mask_ptr)
uint8_t result = 0;
uint32_t bits;
bits = common_read_32_bit(mask_ptr+2);
bits = common_read_32_bit(mask_ptr + 2);
bits = bits >> 5;// five lover bits are not used
for (n= 0; n < 27;n++) {
if((bits & 1)== 1)
for (n = 0; n < 27; n++) {
if ((bits & 1) == 1) {
result++;
}
bits = bits >> 1;
}
tr_debug ("Channel mask count = %d ", result);
tr_debug("Channel mask count = %d ", result);
return result;
}
@ -156,14 +159,14 @@ static uint8_t thread_channels_to_be_scanned(uint8_t *mask_ptr)
uint8_t val = 1;
uint8_t *ptr = mask_ptr + 2; // first two bytes do not contain the channels to be scanned
uint8_t j = 0;
while (j<4){
while (j < 4) {
// one channel for every bit that is set in the mask ptr
for (int i = 0; i<8 ; i++){
if (val & (*ptr)){
for (int i = 0; i < 8 ; i++) {
if (val & (*ptr)) {
result++;
}
val = val << 1;
val = val << 1;
}
val = 1;
ptr++;
@ -212,9 +215,10 @@ static bool tlv_is_requested(uint8_t *tlv_list, uint16_t list_len, uint8_t tlv)
if (!list_len || !tlv_list) {
return true;
}
for(uint16_t n = 0; n<list_len; n++) {
if (tlv_list[n] == tlv )
for (uint16_t n = 0; n < list_len; n++) {
if (tlv_list[n] == tlv) {
return true;
}
}
return false;
}
@ -231,7 +235,7 @@ static int thread_management_server_management_get_respond(int8_t interface_id,
link_configuration = thread_joiner_application_get_config(interface_id);
device_configuration = thread_joiner_application_get_device_config(interface_id);
if(!link_configuration || !device_configuration){
if (!link_configuration || !device_configuration) {
return -1;
}
@ -248,7 +252,7 @@ static int thread_management_server_management_get_respond(int8_t interface_id,
return_code = COAP_MSG_CODE_RESPONSE_CHANGED;
send_response:
coap_service_response_send(coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, return_code, COAP_CT_OCTET_STREAM, response_ptr, ptr -response_ptr);
coap_service_response_send(coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, return_code, COAP_CT_OCTET_STREAM, response_ptr, ptr - response_ptr);
ns_dyn_mem_free(response_ptr);
return 0;
}
@ -267,7 +271,7 @@ static int thread_management_server_active_get_respond(uint8_t interface_id, int
sn_coap_msg_code_e return_code = COAP_MSG_CODE_RESPONSE_CHANGED;
link_configuration = thread_joiner_application_get_config(interface_id);
if(!link_configuration){
if (!link_configuration) {
return -1;
}
@ -275,16 +279,16 @@ static int thread_management_server_active_get_respond(uint8_t interface_id, int
request_tlv_len = thread_tmfcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_GET, &request_tlv_ptr);
if(!request_tlv_len){
if (!request_tlv_len) {
request_tlv_copy = request_tlv_ptr = thread_joiner_application_active_config_tlv_list_get(interface_id, &request_tlv_len);
}
if(!request_tlv_ptr){
if (!request_tlv_ptr) {
return_code = COAP_MSG_CODE_RESPONSE_INTERNAL_SERVER_ERROR;
goto send_response;
}
if(request_tlv_len && !(link_configuration->securityPolicy & SECURITY_POLICY_OUT_OF_BAND_COMMISSIONING_ALLOWED)){
if (request_tlv_len && !(link_configuration->securityPolicy & SECURITY_POLICY_OUT_OF_BAND_COMMISSIONING_ALLOWED)) {
request_tlv_len = thread_meshcop_tlv_list_remove(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_NETWORK_MASTER_KEY);
request_tlv_len = thread_meshcop_tlv_list_remove(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_SECURITY_POLICY);
}
@ -296,7 +300,7 @@ static int thread_management_server_active_get_respond(uint8_t interface_id, int
response_len = thread_joiner_application_active_config_length(interface_id, request_tlv_ptr, request_tlv_len, NULL, 0);
payload_ptr = ptr = error_msg;
if(response_len < 1){
if (response_len < 1) {
//Error in message is responded with Thread status or if we have access rights problem
goto send_response;
}
@ -310,7 +314,7 @@ static int thread_management_server_active_get_respond(uint8_t interface_id, int
ptr = thread_joiner_application_active_config_write(interface_id, ptr, request_tlv_ptr, request_tlv_len, NULL, 0);
send_response:
coap_service_response_send(coap_service_id, COAP_REQUEST_OPTIONS_NONE,request_ptr, return_code, COAP_CT_OCTET_STREAM,payload_ptr, ptr - payload_ptr);
coap_service_response_send(coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, return_code, COAP_CT_OCTET_STREAM, payload_ptr, ptr - payload_ptr);
ns_dyn_mem_free(response_ptr);
ns_dyn_mem_free(request_tlv_copy);
return 0;
@ -343,16 +347,16 @@ static int thread_management_server_pending_get_respond(int8_t interface_id, int
request_tlv_len = thread_tmfcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_GET, &request_tlv_ptr);
if(!request_tlv_len){
if (!request_tlv_len) {
request_tlv_copy = request_tlv_ptr = thread_joiner_application_pending_config_tlv_list_get(interface_id, &request_tlv_len);
}
if(!request_tlv_ptr){
if (!request_tlv_ptr) {
return_code = COAP_MSG_CODE_RESPONSE_INTERNAL_SERVER_ERROR;
goto send_response;
}
if(request_tlv_len && !(link_configuration->securityPolicy & SECURITY_POLICY_OUT_OF_BAND_COMMISSIONING_ALLOWED)){
if (request_tlv_len && !(link_configuration->securityPolicy & SECURITY_POLICY_OUT_OF_BAND_COMMISSIONING_ALLOWED)) {
request_tlv_len = thread_meshcop_tlv_list_remove(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_NETWORK_MASTER_KEY);
request_tlv_len = thread_meshcop_tlv_list_remove(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_SECURITY_POLICY);
}
@ -370,10 +374,10 @@ static int thread_management_server_pending_get_respond(int8_t interface_id, int
}
memset(response_ptr, 0, response_len);
ptr = thread_joiner_application_pending_config_build(interface_id, ptr,request_tlv_ptr, request_tlv_len, NULL, 0);
ptr = thread_joiner_application_pending_config_build(interface_id, ptr, request_tlv_ptr, request_tlv_len, NULL, 0);
send_response:
coap_service_response_send(coap_service_id, COAP_REQUEST_OPTIONS_NONE,request_ptr, return_code, COAP_CT_OCTET_STREAM, payload_ptr, ptr - payload_ptr);
coap_service_response_send(coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, return_code, COAP_CT_OCTET_STREAM, payload_ptr, ptr - payload_ptr);
ns_dyn_mem_free(response_ptr);
ns_dyn_mem_free(request_tlv_copy);
return 0;
@ -413,7 +417,7 @@ static int thread_management_server_commissioner_get_cb(int8_t service_id, uint8
protocol_interface_info_entry_t *cur;
thread_management_server_t *this = thread_management_find_by_service(service_id);
sn_coap_msg_code_e return_code = COAP_MSG_CODE_RESPONSE_CHANGED;
uint8_t response_msg[2+2 + 2+2 + 2+16 +2+2];
uint8_t response_msg[2 + 2 + 2 + 2 + 2 + 16 + 2 + 2];
uint8_t *request_tlv_ptr = NULL;
uint16_t request_tlv_len;
uint8_t *ptr;
@ -439,17 +443,20 @@ static int thread_management_server_commissioner_get_cb(int8_t service_id, uint8
ptr = thread_tmfcop_tlv_data_write_uint8(ptr, MESHCOP_TLV_STATE, 0xff);
goto send_response;
}
uint16_t border_router_locator = common_read_16_bit( &cur->thread_info->registered_commissioner.border_router_address[14]);
uint16_t border_router_locator = common_read_16_bit(&cur->thread_info->registered_commissioner.border_router_address[14]);
request_tlv_len = thread_tmfcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_GET, &request_tlv_ptr);
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_BORDER_ROUTER_LOCATOR))
ptr = thread_meshcop_tlv_data_write_uint16(ptr,MESHCOP_TLV_BORDER_ROUTER_LOCATOR, border_router_locator);
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_BORDER_ROUTER_LOCATOR)) {
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MESHCOP_TLV_BORDER_ROUTER_LOCATOR, border_router_locator);
}
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_COMMISSIONER_SESSION_ID))
ptr = thread_meshcop_tlv_data_write_uint16(ptr,MESHCOP_TLV_COMMISSIONER_SESSION_ID, cur->thread_info->registered_commissioner.session_id);
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_COMMISSIONER_SESSION_ID)) {
ptr = thread_meshcop_tlv_data_write_uint16(ptr, MESHCOP_TLV_COMMISSIONER_SESSION_ID, cur->thread_info->registered_commissioner.session_id);
}
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_STEERING_DATA))
ptr = thread_meshcop_tlv_data_write(ptr,MESHCOP_TLV_STEERING_DATA, cur->thread_info->registered_commissioner.steering_data_len, cur->thread_info->registered_commissioner.steering_data);
if (tlv_is_requested(request_tlv_ptr, request_tlv_len, MESHCOP_TLV_STEERING_DATA)) {
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_STEERING_DATA, cur->thread_info->registered_commissioner.steering_data_len, cur->thread_info->registered_commissioner.steering_data);
}
if (payload_ptr == ptr) {
tr_warn("No TLVs found");
@ -457,56 +464,55 @@ static int thread_management_server_commissioner_get_cb(int8_t service_id, uint8
goto send_response;
}
send_response:
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE,request_ptr, return_code, COAP_CT_OCTET_STREAM,payload_ptr, ptr - payload_ptr);
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, return_code, COAP_CT_OCTET_STREAM, payload_ptr, ptr - payload_ptr);
return 0;
}
static int thread_start_mac_with_link_configuration(protocol_interface_info_entry_t *cur, link_configuration_s *linkConfiguration)
{
mlme_start_t start_req;
memset(&start_req, 0, sizeof(mlme_start_t));
/*Enable RF interface */
if (!(cur->lowpan_info & INTERFACE_NWK_CONF_MAC_RX_OFF_IDLE)) {
mac_helper_pib_boolean_set(cur, macRxOnWhenIdle, true);
} else {
mac_helper_pib_boolean_set(cur, macRxOnWhenIdle, false);
}
mlme_start_t start_req;
memset(&start_req, 0, sizeof(mlme_start_t));
/*Enable RF interface */
if (!(cur->lowpan_info & INTERFACE_NWK_CONF_MAC_RX_OFF_IDLE)) {
mac_helper_pib_boolean_set(cur, macRxOnWhenIdle, true);
} else {
mac_helper_pib_boolean_set(cur, macRxOnWhenIdle, false);
}
mac_helper_default_security_level_set(cur, SEC_ENC_MIC32);
mac_helper_default_security_key_id_mode_set(cur,MAC_KEY_ID_MODE_IDX);
mac_helper_default_security_level_set(cur, SEC_ENC_MIC32);
mac_helper_default_security_key_id_mode_set(cur, MAC_KEY_ID_MODE_IDX);
cur->mac_parameters->mac_channel = linkConfiguration->rfChannel;
cur->mac_parameters->pan_id = linkConfiguration->panId;
cur->mac_parameters->mac_channel = linkConfiguration->rfChannel;
cur->mac_parameters->mac_channel = linkConfiguration->rfChannel;
cur->mac_parameters->pan_id = linkConfiguration->panId;
cur->mac_parameters->mac_channel = linkConfiguration->rfChannel;
start_req.PANId = linkConfiguration->panId;
start_req.LogicalChannel = linkConfiguration->rfChannel;
start_req.ChannelPage = 0;
start_req.BeaconOrder = 0x0f;
start_req.SuperframeOrder = 0x0f;
start_req.PANId = linkConfiguration->panId;
start_req.LogicalChannel = linkConfiguration->rfChannel;
start_req.ChannelPage = 0;
start_req.BeaconOrder = 0x0f;
start_req.SuperframeOrder = 0x0f;
cur->interface_mode = INTERFACE_UP;
thread_discovery_responser_enable(cur->id, false);
if( cur->mac_api ){
cur->mac_api->mlme_req(cur->mac_api, MLME_START, (void*)&start_req);
}
if (cur->thread_info->sleepy_host_poll_time != 0) {
mac_data_poll_host_mode_set(cur,NET_HOST_SLOW_POLL_MODE,cur->thread_info->sleepy_host_poll_time);
} else {
mac_data_poll_init(cur);
}
cur->interface_mode = INTERFACE_UP;
thread_discovery_responser_enable(cur->id, false);
if (cur->mac_api) {
cur->mac_api->mlme_req(cur->mac_api, MLME_START, (void *)&start_req);
}
if (cur->thread_info->sleepy_host_poll_time != 0) {
mac_data_poll_host_mode_set(cur, NET_HOST_SLOW_POLL_MODE, cur->thread_info->sleepy_host_poll_time);
} else {
mac_data_poll_init(cur);
}
return 0;
return 0;
}
static void thread_panid_conflict_timeout_cb(void* arg)
static void thread_panid_conflict_timeout_cb(void *arg)
{
uint8_t payload[12];// 2+6 + 2+2
uint8_t *ptr;
thread_management_server_t *this = arg;
if(!this || !this->scan_ptr)
{
if (!this || !this->scan_ptr) {
tr_error("panid conflict scan ptr missing");
return;
}
@ -525,17 +531,16 @@ static void thread_panid_conflict_timeout_cb(void* arg)
//style = 0 means thread style, style = anything else means zigbee style
// for thread style the bit is set from left to right and for zigbee style it is set from right to left
static void set_channel_mask(uint8_t *channel_mask,uint8_t channel_number, uint8_t style)
static void set_channel_mask(uint8_t *channel_mask, uint8_t channel_number, uint8_t style)
{
uint8_t byte_position;
uint8_t bit_position;
if (0 == style){
if (0 == style) {
byte_position = channel_number / 8;
bit_position = 7 - (channel_number % 8);
channel_mask[byte_position + 2] |= (1 << bit_position);
return;
}
else {
} else {
byte_position = 3 - (channel_number / 8);
bit_position = channel_number % 8;
channel_mask[byte_position + 2] |= (1 << bit_position);
@ -546,71 +551,72 @@ static uint32_t reverse_bits(uint32_t num)
{
uint32_t NO_OF_BITS = sizeof(num) * 8;
uint32_t reversed_value = 0, i, temp;
for (i = 0; i < NO_OF_BITS; i++){
for (i = 0; i < NO_OF_BITS; i++) {
temp = (num & (1 << i));
if(temp)
if (temp) {
reversed_value |= (1 << ((NO_OF_BITS - 1) - i));
}
}
return reversed_value;
}
static void thread_panid_scan_response(int8_t if_id, const mlme_scan_conf_t* conf)
static void thread_panid_scan_response(int8_t if_id, const mlme_scan_conf_t *conf)
{
bool conflict_occured = false;
nwk_scan_params_t *scan_parameters_ptr;
nwk_pan_descriptor_t *result;
protocol_interface_info_entry_t *interface;
link_configuration_s *linkConfiguration;
bool conflict_occured = false;
nwk_scan_params_t *scan_parameters_ptr;
nwk_pan_descriptor_t *result;
protocol_interface_info_entry_t *interface;
link_configuration_s *linkConfiguration;
if (conf->ScanType != MAC_ACTIVE_SCAN) {
tr_error("Not active scan");
return;
}
if (conf->ScanType != MAC_ACTIVE_SCAN) {
tr_error("Not active scan");
return;
}
interface = protocol_stack_interface_info_get_by_id(if_id);
if (!interface) {
tr_error("Mac scan confirm:Unknow Interface");
return;
}
interface = protocol_stack_interface_info_get_by_id(if_id);
if (!interface) {
tr_error("Mac scan confirm:Unknow Interface");
return;
}
linkConfiguration = thread_joiner_application_get_config(if_id);
if (!linkConfiguration) {
return;
}
linkConfiguration = thread_joiner_application_get_config(if_id);
if (!linkConfiguration) {
return;
}
scan_parameters_ptr = &interface->mac_parameters->nwk_scan_params; //mac_mlme_get_scan_params(interface);
if (!scan_parameters_ptr ||!scan_parameters_ptr->nwk_response_info || !conf->ResultListSize) {
tr_debug("Mac scan confirm:No Beacons");
thread_start_mac_with_link_configuration(interface,linkConfiguration);
return;
}
scan_parameters_ptr->active_scan_active = false;
scan_parameters_ptr = &interface->mac_parameters->nwk_scan_params; //mac_mlme_get_scan_params(interface);
if (!scan_parameters_ptr || !scan_parameters_ptr->nwk_response_info || !conf->ResultListSize) {
tr_debug("Mac scan confirm:No Beacons");
thread_start_mac_with_link_configuration(interface, linkConfiguration);
return;
}
scan_parameters_ptr->active_scan_active = false;
thread_management_server_t *this = thread_management_server_find(if_id);
thread_management_server_t *this = thread_management_server_find(if_id);
if (!this) {
return;
}
if (!this) {
return;
}
result = scan_parameters_ptr->nwk_response_info;
// reset all channel masks
this->scan_ptr->channel_mask[2] = 0x00;
this->scan_ptr->channel_mask[3] = 0x00;
this->scan_ptr->channel_mask[4] = 0x00;
this->scan_ptr->channel_mask[5] = 0x00;
result = scan_parameters_ptr->nwk_response_info;
// reset all channel masks
this->scan_ptr->channel_mask[2] = 0x00;
this->scan_ptr->channel_mask[3] = 0x00;
this->scan_ptr->channel_mask[4] = 0x00;
this->scan_ptr->channel_mask[5] = 0x00;
do {
tr_debug("Mac scan confirm:scanning results");
if(result->pan_descriptor->CoordPANId == this->scan_ptr->panid) { //if pan id matches then send a conflict message
tr_debug("Same pan id was found on channel %d", result->pan_descriptor->LogicalChannel);
set_channel_mask(this->scan_ptr->channel_mask,result->pan_descriptor->LogicalChannel,0);
conflict_occured = true;
}
result = result->next;
if (result->pan_descriptor->CoordPANId == this->scan_ptr->panid) { //if pan id matches then send a conflict message
tr_debug("Same pan id was found on channel %d", result->pan_descriptor->LogicalChannel);
set_channel_mask(this->scan_ptr->channel_mask, result->pan_descriptor->LogicalChannel, 0);
conflict_occured = true;
}
result = result->next;
} while (result);
if (conflict_occured){
if (conflict_occured) {
tr_debug("conflict occured");
this->scan_ptr->timer = eventOS_timeout_ms(thread_panid_conflict_timeout_cb, 2000, this);
}
thread_start_mac_with_link_configuration(interface,linkConfiguration);
thread_start_mac_with_link_configuration(interface, linkConfiguration);
//TODO if no conflict scan again after delay seconds
}
static int thread_management_server_energy_scan_response_resp_cb(int8_t service_id, uint8_t source_address[static 16], uint16_t source_port, sn_coap_hdr_s *response_ptr)
@ -641,13 +647,13 @@ static void thread_energy_scan_coap(thread_management_server_t *arg)
return;
}
thread_start_mac_with_link_configuration(interface,linkConfiguration);
thread_start_mac_with_link_configuration(interface, linkConfiguration);
uint8_t channel_count = thread_channels_to_be_scanned(this->scan_ptr->channel_mask);
tr_debug("energy scan result mask %s, result %s, count %d",trace_array(this->scan_ptr->channel_mask,6),
trace_array(this->scan_ptr->energy_list_ptr,channel_count* this->scan_ptr->count),channel_count);
tr_debug("energy scan result mask %s, result %s, count %d", trace_array(this->scan_ptr->channel_mask, 6),
trace_array(this->scan_ptr->energy_list_ptr, channel_count * this->scan_ptr->count), channel_count);
uint8_t *payload_ptr = ns_dyn_mem_alloc( 2 + 6 + 2 + channel_count * this->scan_ptr->count);
uint8_t *payload_ptr = ns_dyn_mem_alloc(2 + 6 + 2 + channel_count * this->scan_ptr->count);
if (!payload_ptr) {
tr_error("out of resources");
return;
@ -665,14 +671,14 @@ static void thread_energy_scan_coap(thread_management_server_t *arg)
this->scan_ptr = NULL;
}
static void energy_scan_confirm_cb(int8_t if_id, const mlme_scan_conf_t* conf)
static void energy_scan_confirm_cb(int8_t if_id, const mlme_scan_conf_t *conf)
{
if (conf->ScanType != MAC_ED_SCAN_TYPE) {
tr_error("Not energy scan");
return;
}
if (conf->ResultListSize < 1){
if (conf->ResultListSize < 1) {
tr_error("No scan responses");
return;
}
@ -691,7 +697,7 @@ static void energy_scan_confirm_cb(int8_t if_id, const mlme_scan_conf_t* conf)
// reduce the scan_count by one since one scan has been performed and results are also obtained
this->scan_ptr->scan_count--;
for( int i=0; i < conf->ResultListSize; i++){
for (int i = 0; i < conf->ResultListSize; i++) {
*this->scan_ptr->energy_list_ptr++ = conf->ED_values[i];
}
@ -704,13 +710,12 @@ static void energy_scan_confirm_cb(int8_t if_id, const mlme_scan_conf_t* conf)
this->scan_ptr->energy_list_length += conf->ResultListSize;
// if all scans have been completed then, move the energy_list_ptr back to the beginning
if (this->scan_ptr->scan_count == 0){
this->scan_ptr->energy_list_ptr-=this->scan_ptr->energy_list_length;
if (this->scan_ptr->scan_count == 0) {
this->scan_ptr->energy_list_ptr -= this->scan_ptr->energy_list_length;
thread_energy_scan_coap(this);
}
else{
} else {
// if all scans have not been completed, enable RF, wait for scan period and call energy scan method again
thread_start_mac_with_link_configuration(interface,linkConfiguration);
thread_start_mac_with_link_configuration(interface, linkConfiguration);
if (this->scan_ptr->timer) {
eventOS_timeout_cancel(this->scan_ptr->timer);
}
@ -718,11 +723,11 @@ static void energy_scan_confirm_cb(int8_t if_id, const mlme_scan_conf_t* conf)
}
}
void thread_energy_scan_timeout_cb(void* arg)
void thread_energy_scan_timeout_cb(void *arg)
{
link_configuration_s *linkConfiguration;
thread_management_server_t *this = arg;
if(!this || !this->scan_ptr || !this->scan_ptr->energy_list_ptr){
if (!this || !this->scan_ptr || !this->scan_ptr->energy_list_ptr) {
tr_error("Invalid query");
return;
}
@ -742,7 +747,7 @@ void thread_energy_scan_timeout_cb(void* arg)
}
uint32_t channel_mask = 0;
channel_mask = (this->scan_ptr->channel_mask[2]<<24) | (this->scan_ptr->channel_mask[3]<<16)| (this->scan_ptr->channel_mask[4]<<8) | (this->scan_ptr->channel_mask[5]);
channel_mask = (this->scan_ptr->channel_mask[2] << 24) | (this->scan_ptr->channel_mask[3] << 16) | (this->scan_ptr->channel_mask[4] << 8) | (this->scan_ptr->channel_mask[5]);
//Modify reversed_mask after the right way to interpret channel mask is obtained
uint32_t reversed_mask = reverse_bits(channel_mask);
channel_mask = reversed_mask;
@ -752,7 +757,7 @@ void thread_energy_scan_timeout_cb(void* arg)
// Convert duration in ms to MAC exponent value
uint8_t duration_n;
if(this->scan_ptr->duration <= (CHANNEL_PAGE_0_SUPERFRAME_DURATION * 2)) {
if (this->scan_ptr->duration <= (CHANNEL_PAGE_0_SUPERFRAME_DURATION * 2)) {
duration_n = 0;
} else {
duration_n = thread_log2_aprx((this->scan_ptr->duration / CHANNEL_PAGE_0_SUPERFRAME_DURATION) - 1);
@ -767,18 +772,19 @@ void thread_energy_scan_timeout_cb(void* arg)
mac_data_poll_disable(s);
mlme_scan_t req;
mac_create_scan_request(MAC_ED_SCAN_TYPE, &s->mac_parameters->nwk_scan_params.stack_chan_list, duration_n, &req);
if( s->mac_api ){
if (s->mac_api) {
s->scan_cb = energy_scan_confirm_cb;
s->mac_api->mlme_req(s->mac_api, MLME_SCAN, &req);
}
}
static void thread_panid_scan_timeout_cb(void* arg)
static void thread_panid_scan_timeout_cb(void *arg)
{
thread_management_server_t *this = arg;
if(!this || !this->scan_ptr)
if (!this || !this->scan_ptr) {
return;
}
this->scan_ptr->timer = NULL;
@ -791,7 +797,7 @@ static void thread_panid_scan_timeout_cb(void* arg)
}
uint32_t channel_mask = 0;
channel_mask = (this->scan_ptr->channel_mask[2]<<24) | (this->scan_ptr->channel_mask[3]<<16)| (this->scan_ptr->channel_mask[4]<<8) | (this->scan_ptr->channel_mask[5]);
channel_mask = (this->scan_ptr->channel_mask[2] << 24) | (this->scan_ptr->channel_mask[3] << 16) | (this->scan_ptr->channel_mask[4] << 8) | (this->scan_ptr->channel_mask[5]);
//Modify reversed_mask after the right way to interpret channel mask is obtained
uint32_t reversed_mask = reverse_bits(channel_mask);
channel_mask = reversed_mask;
@ -807,7 +813,7 @@ static void thread_panid_scan_timeout_cb(void* arg)
than just the beacons from its current PAN, as described in 5.1.6.2. On completion of the scan, the MAC
sub-layer shall restore the value of macPANId to the value stored before the scan began.
*/
mac_helper_panid_set(s,0xffff);
mac_helper_panid_set(s, 0xffff);
s->scan_cb = thread_panid_scan_response;
s->mac_parameters->nwk_scan_params.active_scan_active = true;
@ -840,7 +846,7 @@ static int thread_management_server_panid_query_cb(int8_t service_id, uint8_t so
goto error_exit;
}
mask_len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_CHANNEL_MASK, &mask_ptr);
if (mask_len < 6 ) {
if (mask_len < 6) {
tr_warn("Missing channel mask TLV");
goto error_exit;
}
@ -848,7 +854,7 @@ static int thread_management_server_panid_query_cb(int8_t service_id, uint8_t so
if (!this->scan_ptr) {
this->scan_ptr = ns_dyn_mem_alloc(sizeof(scan_query_t));
memset(this->scan_ptr,0,sizeof(scan_query_t));
memset(this->scan_ptr, 0, sizeof(scan_query_t));
} else {
eventOS_timeout_cancel(this->scan_ptr->timer);
this->scan_ptr->timer = NULL;
@ -866,20 +872,20 @@ static int thread_management_server_panid_query_cb(int8_t service_id, uint8_t so
}
this->scan_ptr->coap_service_id = service_id;
memcpy(this->scan_ptr->channel_mask,mask_ptr,mask_len);
memcpy(this->scan_ptr->channel_mask, mask_ptr, mask_len);
this->scan_ptr->channel_mask_len = mask_len;
this->scan_ptr->port = source_port;
memcpy(this->scan_ptr->address,source_address,16);
memcpy(this->scan_ptr->address, source_address, 16);
this->scan_ptr->panid = panid;
this->scan_ptr->panid_scan = true;
if (request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE ){
if (request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE) {
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, NULL, 0);
return 0;
}
return -1;
error_exit:
if (request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE ){
if (request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE) {
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, response_code, COAP_CT_OCTET_STREAM, NULL, 0);
return 0;
}
@ -922,20 +928,20 @@ static int thread_management_server_energy_scan_cb(int8_t service_id, uint8_t so
goto error_exit;
}
mask_len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_CHANNEL_MASK, &mask_ptr);
if (mask_len < 6 ) {
if (mask_len < 6) {
tr_warn("Missing channel mask TLV");
goto error_exit;
}
tr_info("Channel mask TLV %s, period %d, count %d, duration %d", trace_array(mask_ptr, mask_len), period, count, duration);
if (count < 1 || thread_channel_mask_count(mask_ptr) < 1 ) {
if (count < 1 || thread_channel_mask_count(mask_ptr) < 1) {
// Sanity checks
response_code = COAP_MSG_CODE_RESPONSE_NOT_ACCEPTABLE;
goto error_exit;
}
if (!this->scan_ptr) {
this->scan_ptr = ns_dyn_mem_alloc(sizeof(scan_query_t));
memset(this->scan_ptr,0,sizeof(scan_query_t));
memset(this->scan_ptr, 0, sizeof(scan_query_t));
} else {
eventOS_timeout_cancel(this->scan_ptr->timer);
this->scan_ptr->timer = NULL;
@ -951,13 +957,13 @@ static int thread_management_server_energy_scan_cb(int8_t service_id, uint8_t so
// allocate memory for the energy scan results
this->scan_ptr->energy_list_ptr = ns_dyn_mem_temporary_alloc(channel_count * this->scan_ptr->scan_count);
if(!this->scan_ptr->energy_list_ptr){
if (!this->scan_ptr->energy_list_ptr) {
response_code = COAP_MSG_CODE_RESPONSE_NOT_ACCEPTABLE;
tr_debug ("Exiting after no energy list ptr was allocated");
tr_debug("Exiting after no energy list ptr was allocated");
goto error_exit;
}
memset(this->scan_ptr->energy_list_ptr,0,(channel_count* this->scan_ptr->scan_count));
memset(this->scan_ptr->energy_list_ptr, 0, (channel_count * this->scan_ptr->scan_count));
this->scan_ptr->timer = eventOS_timeout_ms(thread_energy_scan_timeout_cb, 500, this);
@ -967,29 +973,29 @@ static int thread_management_server_energy_scan_cb(int8_t service_id, uint8_t so
}
this->scan_ptr->coap_service_id = service_id;
memcpy(this->scan_ptr->channel_mask,mask_ptr,mask_len);
memcpy(this->scan_ptr->channel_mask, mask_ptr, mask_len);
this->scan_ptr->channel_mask_len = mask_len;
this->scan_ptr->port = source_port;
memcpy(this->scan_ptr->address,source_address,16);
memcpy(this->scan_ptr->address, source_address, 16);
this->scan_ptr->count = count;
this->scan_ptr->duration = duration;
this->scan_ptr->period = period;
this->scan_ptr->energy_scan = true;
if (request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE ){
if (request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE) {
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, NULL, 0);
return 0;
}
return -1;
error_exit:
if(this->scan_ptr) {
if (this->scan_ptr) {
ns_dyn_mem_free(this->scan_ptr->energy_list_ptr);
ns_dyn_mem_free(this->scan_ptr);
}
this->scan_ptr = NULL;
if (request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE ){
if (request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE) {
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, response_code, COAP_CT_OCTET_STREAM, NULL, 0);
return 0;
}
@ -997,13 +1003,13 @@ error_exit:
return -1;
}
static void thread_announce_timeout_cb(void* arg)
static void thread_announce_timeout_cb(void *arg)
{
link_configuration_s *linkConfiguration;
thread_management_server_t *this = arg;
protocol_interface_info_entry_t *cur;
if(!this || !this->announce_ptr) {
if (!this || !this->announce_ptr) {
return;
}
@ -1015,20 +1021,20 @@ static void thread_announce_timeout_cb(void* arg)
return;
}
while (this->announce_ptr->channel < 27) {
if(thread_channel_mask_is_channel_set(this->announce_ptr->channel_mask, this->announce_ptr->channel)) {
if (thread_channel_mask_is_channel_set(this->announce_ptr->channel_mask, this->announce_ptr->channel)) {
break;
}
this->announce_ptr->channel++;
}
if(this->announce_ptr->channel > 26) {
if (this->announce_ptr->channel > 26) {
tr_debug("Announce done");
ns_dyn_mem_free(this->announce_ptr);
this->announce_ptr = NULL;
return;
}
tr_debug("Announce to channel %d",this->announce_ptr->channel);
tr_debug("Announce to channel %d", this->announce_ptr->channel);
thread_bootstrap_announcement_start(cur,this->announce_ptr->channel_mask[0],this->announce_ptr->channel, this->announce_ptr->count, this->announce_ptr->period);
thread_bootstrap_announcement_start(cur, this->announce_ptr->channel_mask[0], this->announce_ptr->channel, this->announce_ptr->count, this->announce_ptr->period);
this->announce_ptr->channel++; // Next time we start the next channel
this->announce_ptr->timer = eventOS_timeout_ms(thread_announce_timeout_cb, 5000, this);
@ -1076,12 +1082,12 @@ static int thread_management_server_announce_begin_cb(int8_t service_id, uint8_t
goto error_exit;
}
mask_len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_CHANNEL_MASK, &mask_ptr);
if (mask_len < 6 ) {
if (mask_len < 6) {
tr_warn("Missing channel mask TLV");
goto error_exit;
}
// TODO validity checks session id must be validated
tr_info("start announcing session id %d, mask TLV %s, period %d, count %d",session_id, trace_array(mask_ptr, mask_len), period, count);
tr_info("start announcing session id %d, mask TLV %s, period %d, count %d", session_id, trace_array(mask_ptr, mask_len), period, count);
if (!this->announce_ptr) {
this->announce_ptr = ns_dyn_mem_alloc(sizeof(announce_t));
@ -1099,7 +1105,7 @@ static int thread_management_server_announce_begin_cb(int8_t service_id, uint8_t
response_code = COAP_MSG_CODE_RESPONSE_INTERNAL_SERVER_ERROR;
goto error_exit;
}
memcpy(this->announce_ptr->channel_mask,mask_ptr,mask_len);
memcpy(this->announce_ptr->channel_mask, mask_ptr, mask_len);
this->announce_ptr->channel_mask_len = mask_len;
this->announce_ptr->count = count;
this->announce_ptr->period = period;
@ -1107,7 +1113,7 @@ static int thread_management_server_announce_begin_cb(int8_t service_id, uint8_t
// Set own information to announce
response_code = COAP_MSG_CODE_RESPONSE_CHANGED;
error_exit:
error_exit:
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, response_code, COAP_CT_OCTET_STREAM, NULL, 0);
return 0;
}
@ -1135,8 +1141,8 @@ int thread_management_server_init(int8_t interface_id)
this->scan_ptr = NULL;
this->announce_ptr = NULL;
this->join_ent_timer = NULL;
memset(this->destination_address,0,16);
memset(this->one_time_key,0,16);
memset(this->destination_address, 0, 16);
memset(this->one_time_key, 0, 16);
this->external_commissioner_port = THREAD_COMMISSIONING_PORT;
#ifdef HAVE_THREAD_ROUTER
@ -1294,12 +1300,12 @@ static int thread_management_server_entrust_send(thread_management_server_t *thi
response_len = 6 + thread_joiner_application_active_config_length(this->interface_id, entrust_dataset_tlvs, entrust_dataset_tlvs_size(), NULL, 0);
ptr = response_ptr = ns_dyn_mem_alloc(response_len);
if(!response_ptr) {
if (!response_ptr) {
tr_warn("Out of mem");
return -2;
}
ptr = thread_joiner_application_active_config_write(this->interface_id, ptr, entrust_dataset_tlvs, entrust_dataset_tlvs_size(), NULL, 0);
ptr = thread_meshcop_tlv_data_write_uint32(ptr,MESHCOP_TLV_NETWORK_KEY_SEQUENCE, link_configuration_ptr->key_sequence);
ptr = thread_meshcop_tlv_data_write_uint32(ptr, MESHCOP_TLV_NETWORK_KEY_SEQUENCE, link_configuration_ptr->key_sequence);
thci_trace("joinerrouterJoinerAccepted");
/*We must null out the master secret*/
@ -1307,19 +1313,19 @@ static int thread_management_server_entrust_send(thread_management_server_t *thi
uint8_t *master_secret_ptr;
uint8_t *pskc_ptr;
if (thread_meshcop_tlv_find(response_ptr, ptr - response_ptr, MESHCOP_TLV_NETWORK_MASTER_KEY, &master_secret_ptr) >= 16) {
memset(master_secret_ptr,0,16);
memset(master_secret_ptr, 0, 16);
}
if (thread_meshcop_tlv_find(response_ptr, ptr - response_ptr, MESHCOP_TLV_PSKC, &pskc_ptr) >= 16) {
memset(pskc_ptr,0,16);
memset(pskc_ptr, 0, 16);
}
memcpy(Joiner_iid, &destination_address[8], 8);
thci_trace("Device - Joiner Router|Direction - sent|IID - %s|Type - JOIN_ent.req|Length - %d|Payload - %s", trace_array(Joiner_iid, 8),(int) (ptr - response_ptr), trace_array(response_ptr, ptr - response_ptr));
thci_trace("Device - Joiner Router|Direction - sent|IID - %s|Type - JOIN_ent.req|Length - %d|Payload - %s", trace_array(Joiner_iid, 8), (int)(ptr - response_ptr), trace_array(response_ptr, ptr - response_ptr));
if (master_secret_ptr) {
memcpy(master_secret_ptr,link_configuration_ptr->master_key,16);
memcpy(master_secret_ptr, link_configuration_ptr->master_key, 16);
}
if (pskc_ptr) {
memcpy(pskc_ptr,link_configuration_ptr->PSKc,16);
memcpy(pskc_ptr, link_configuration_ptr->PSKc, 16);
}
#endif
coap_service_request_send(this->coap_service_id, options, destination_address, THREAD_MANAGEMENT_PORT,
@ -1331,7 +1337,7 @@ static int thread_management_server_entrust_send(thread_management_server_t *thi
static void thread_join_ent_timeout_cb(void *arg)
{
thread_management_server_t *this = arg;
if(!this || !this->join_ent_timer) {
if (!this || !this->join_ent_timer) {
return;
}
@ -1469,12 +1475,12 @@ int thread_management_server_joiner_router_init(int8_t interface_id)
// Thread 1.1 commissioner is present
enable = true;
}
if(this->joiner_router_enabled == enable &&
this->relay_port_joiner == thread_joiner_port) {
if (this->joiner_router_enabled == enable &&
this->relay_port_joiner == thread_joiner_port) {
// Joiner router is in correct state
return 0;
}
if(this->joiner_router_enabled) {
if (this->joiner_router_enabled) {
// Need to disable Joiner router either because port changed or moving to disabled
thread_management_server_joiner_router_deinit(interface_id);
}
@ -1493,7 +1499,7 @@ int thread_management_server_joiner_router_init(int8_t interface_id)
this->listen_socket_joiner = socket_open(SOCKET_UDP, this->relay_port_joiner, joiner_router_recv_commission_msg);
if (this->listen_socket_joiner < 0) {
// Try other ports
while((this->listen_socket_joiner < 0) && (this->relay_port_joiner < thread_joiner_port + 10)) {
while ((this->listen_socket_joiner < 0) && (this->relay_port_joiner < thread_joiner_port + 10)) {
// We try 10 ports after default port
this->relay_port_joiner++;
this->listen_socket_joiner = socket_open(SOCKET_UDP, this->relay_port_joiner, joiner_router_recv_commission_msg);
@ -1556,7 +1562,7 @@ bool thread_management_server_source_address_check(int8_t interface_id, uint8_t
}
if (memcmp(source_address, linkConfiguration->mesh_local_ula_prefix, 8) == 0 &&
memcmp(source_address + 8, ADDR_SHORT_ADR_SUFFIC, 6) == 0 ) {
memcmp(source_address + 8, ADDR_SHORT_ADR_SUFFIC, 6) == 0) {
// Source address is RLOC or ALOC
} else if (memcmp(source_address, linkConfiguration->mesh_local_ula_prefix, 8) == 0) {
// Source address is ML64 TODO this should check that destination address is ALOC or RLOC CoaP Service does not support
@ -1564,8 +1570,8 @@ bool thread_management_server_source_address_check(int8_t interface_id, uint8_t
// Source address is from Link local address
} else {
tr_error("Message out of thread network; ML prefix: %s, src addr: %s",
trace_ipv6_prefix(linkConfiguration->mesh_local_ula_prefix, 64),
trace_ipv6(source_address));
trace_ipv6_prefix(linkConfiguration->mesh_local_ula_prefix, 64),
trace_ipv6(source_address));
return false;
}
// TODO: Add other (security) related checks here
@ -1579,9 +1585,9 @@ int thread_management_server_tmf_get_request_handler(int8_t interface_id, int8_t
if (strncmp(THREAD_URI_ACTIVE_GET, (const char *)request_ptr->uri_path_ptr, request_ptr->uri_path_len) == 0) {
ret_val = thread_management_server_active_get_respond(interface_id, coap_service_id, request_ptr);
} else if (strncmp(THREAD_URI_PENDING_GET,(const char *)request_ptr->uri_path_ptr,request_ptr->uri_path_len) == 0) {
} else if (strncmp(THREAD_URI_PENDING_GET, (const char *)request_ptr->uri_path_ptr, request_ptr->uri_path_len) == 0) {
ret_val = thread_management_server_pending_get_respond(interface_id, coap_service_id, request_ptr);
} else if (strncmp(THREAD_URI_MANAGEMENT_GET,(const char *)request_ptr->uri_path_ptr,request_ptr->uri_path_len) == 0) {
} else if (strncmp(THREAD_URI_MANAGEMENT_GET, (const char *)request_ptr->uri_path_ptr, request_ptr->uri_path_len) == 0) {
ret_val = thread_management_server_management_get_respond(interface_id, coap_service_id, request_ptr);
} else {
// unrecognized message

View File

@ -101,7 +101,7 @@ static uint8_t *thread_mdns_txt_record_sb_get(int interface_id, uint8_t *buf, ui
/* Thread Interface Status
* 2, Thread interface is initialized with a set of valid operational parameters and is actively part of a Thread Network Partition
* */
state_bitmap |= 0x02<<3;
state_bitmap |= 0x02 << 3;
/* Availability
* 1: High availability The Border Agent device and its Thread interface are part of stable, always-on network infrastructure
@ -137,7 +137,7 @@ static uint8_t *thread_mdns_txt_record_nn_key_fill(int8_t interface_id, uint8_t
uint8_t length;
const char nn_string[4] = "nn=";
if (! (state_bitmap & THREAD_MDNS_TXT_SB_CONNECTION_MODE_BM)) {
if (!(state_bitmap & THREAD_MDNS_TXT_SB_CONNECTION_MODE_BM)) {
// if connection mode is not allowed, elide nn-key
return ptr;
}
@ -176,7 +176,7 @@ static uint8_t *thread_mdns_txt_record_xp_key_fill(int8_t interface_id, uint8_t
int length;
const uint8_t xp_string[4] = { 11, 'x', 'p', '=' };
if (! (state_bitmap & THREAD_MDNS_TXT_SB_CONNECTION_MODE_BM)) {
if (!(state_bitmap & THREAD_MDNS_TXT_SB_CONNECTION_MODE_BM)) {
// if connection mode not allowed, skip xb-key
return ptr;
}
@ -185,7 +185,7 @@ static uint8_t *thread_mdns_txt_record_xp_key_fill(int8_t interface_id, uint8_t
memcpy(ptr, xp_string, length);
ptr += length;
if(state_bitmap & THREAD_MDNS_TXT_SB_INTERFACE_STATUS_BM) {
if (state_bitmap & THREAD_MDNS_TXT_SB_INTERFACE_STATUS_BM) {
link_configuration_s *link_configuration = thread_management_configuration_get(interface_id);
if (!link_configuration) {
tr_error("Failed to read link configuration");
@ -219,7 +219,7 @@ static uint8_t *thread_mdns_txt_record_fill(int8_t interface_id, uint8_t *buf)
/* tv */
*ptr++ = sizeof(mDNS_thread_version) - 1; /* tv length */
memcpy(ptr, mDNS_thread_version, sizeof(mDNS_thread_version)- 1);
memcpy(ptr, mDNS_thread_version, sizeof(mDNS_thread_version) - 1);
ptr += sizeof(mDNS_thread_version) - 1;
/* state bitmap */
@ -261,7 +261,7 @@ static const uint8_t *thread_mdns_txt_record_callback(void)
if (!thread_mdns_ptr->txt_record_buffer) {
tr_error("mDNS record not allocated");
return (uint8_t*)'\0';
return (uint8_t *)'\0';
}
memcpy(thread_mdns_ptr->txt_record_buffer, buffer, new_record_length);

View File

@ -45,7 +45,7 @@ uint8_t *thread_meshcop_tlv_data_write(uint8_t *ptr, uint8_t type, uint16_t leng
} else {
*ptr++ = length;
}
if ( length > 0 && data) {
if (length > 0 && data) {
memcpy(ptr, data, length);
}
return ptr + length;
@ -205,7 +205,7 @@ static const uint8_t *thread_meshcop_next_tlv(const uint8_t *ptr, uint16_t lengt
}
return ptr + 4 + common_read_16_bit(&ptr[2]);
}
return ptr + 2 + ptr[1];
return ptr + 2 + ptr[1];
}
int16_t thread_meshcop_tlv_length(const uint8_t *ptr, uint16_t length)
{
@ -219,7 +219,7 @@ int16_t thread_meshcop_tlv_length(const uint8_t *ptr, uint16_t length)
}
return common_read_16_bit(&ptr[2]);
}
return ptr[1];
return ptr[1];
}
int16_t thread_meshcop_tlv_length_required(const uint8_t *ptr, uint16_t length)
@ -234,7 +234,7 @@ int16_t thread_meshcop_tlv_length_required(const uint8_t *ptr, uint16_t length)
}
return 4 + common_read_16_bit(&ptr[2]);
}
return 2 + ptr[1];
return 2 + ptr[1];
}
const uint8_t *thread_meshcop_tlv_get_next(const uint8_t *ptr, uint16_t *length)
@ -243,7 +243,7 @@ const uint8_t *thread_meshcop_tlv_get_next(const uint8_t *ptr, uint16_t *length)
return NULL;
}
const uint8_t *next_ptr = thread_meshcop_next_tlv(ptr,*length);
const uint8_t *next_ptr = thread_meshcop_next_tlv(ptr, *length);
if (!next_ptr) {
// No next TLV present
@ -260,26 +260,26 @@ bool thread_meshcop_tlv_list_present(const uint8_t *ptr, uint16_t length, const
return false;
}
for(uint8_t n = 0;n < sizeof(required_tlv_len);n++) {
if(0 == thread_meshcop_tlv_find(ptr, length, required_tlv_ptr[n], NULL)){
for (uint8_t n = 0; n < sizeof(required_tlv_len); n++) {
if (0 == thread_meshcop_tlv_find(ptr, length, required_tlv_ptr[n], NULL)) {
return false;
}
}
return true;
}
uint16_t thread_meshcop_tlv_list_generate(const uint8_t *ptr, uint16_t length,uint8_t *result_ptr, uint16_t *result_len)
uint16_t thread_meshcop_tlv_list_generate(const uint8_t *ptr, uint16_t length, uint8_t *result_ptr, uint16_t *result_len)
{
if (!ptr || length < 2 || !result_len) {
return 0;
}
*result_len = 0;
while(ptr && length) {
while (ptr && length) {
if (result_ptr) {
*result_ptr++ = *ptr; // write the TLV name
}
(*result_len)++; // Count the amount of TLVs
ptr = thread_meshcop_tlv_get_next(ptr,&length);
ptr = thread_meshcop_tlv_get_next(ptr, &length);
}
return *result_len;
}
@ -287,22 +287,22 @@ uint16_t thread_meshcop_tlv_list_remove(uint8_t *tlv_ptr, uint16_t tlv_len, uint
{
uint8_t *start_ptr = tlv_ptr;
if((!tlv_ptr) || (!tlv_len)){
if ((!tlv_ptr) || (!tlv_len)) {
return 0;
}
/* Go through TLV's */
while((tlv_ptr - start_ptr) < tlv_len){
while ((tlv_ptr - start_ptr) < tlv_len) {
/* If match, remove it from list */
if(*tlv_ptr == tlv_type){
if (*tlv_ptr == tlv_type) {
/* If not last TLV in list, shift */
if(((tlv_ptr - start_ptr) + 1) < tlv_len){
if (((tlv_ptr - start_ptr) + 1) < tlv_len) {
memmove(tlv_ptr, tlv_ptr + 1, (tlv_len - ((tlv_ptr - start_ptr) + 1)));
}
/* Update length */
tlv_len--;
/* No match, go to next... */
} else{
/* No match, go to next... */
} else {
tlv_ptr++;
}
}
@ -312,7 +312,7 @@ uint16_t thread_meshcop_tlv_list_remove(uint8_t *tlv_ptr, uint16_t tlv_len, uint
bool thread_meshcop_tlv_list_type_available(const uint8_t *list_ptr, uint16_t list_len, uint8_t tlv_type)
{
for (uint16_t i = 0 ;i < list_len; i++) {
for (uint16_t i = 0 ; i < list_len; i++) {
if (*(list_ptr + i) == tlv_type) {
return true;
}
@ -320,26 +320,26 @@ bool thread_meshcop_tlv_list_type_available(const uint8_t *list_ptr, uint16_t li
return false;
}
uint16_t thread_meshcop_tlv_find_next(uint8_t* tlv_ba, uint16_t tlv_ba_length, uint8_t tlv_id, uint8_t** found_tlv)
uint16_t thread_meshcop_tlv_find_next(uint8_t *tlv_ba, uint16_t tlv_ba_length, uint8_t tlv_id, uint8_t **found_tlv)
{
//tr_debug("thread_meshcop_tlv_find_next TLV ID=%d ", tlv_id);
uint8_t* prev_tlv = *found_tlv;
uint16_t tlv_length = thread_meshcop_tlv_find((const uint8_t*)tlv_ba, tlv_ba_length, tlv_id, found_tlv);
uint8_t *prev_tlv = *found_tlv;
uint16_t tlv_length = thread_meshcop_tlv_find((const uint8_t *)tlv_ba, tlv_ba_length, tlv_id, found_tlv);
if (!prev_tlv || tlv_length == 0) {
// first TLV requested or TLV not found
return tlv_length;
}
while (tlv_length > 0) {
tlv_ba_length = tlv_ba_length - tlv_length - (*found_tlv - tlv_ba); // adjust length
tlv_ba = *found_tlv + tlv_length; //+ 2; // skip already found TLV
if (*found_tlv == prev_tlv) {
// current TLV is matching previous one, return next TLV
return thread_meshcop_tlv_find((const uint8_t*)tlv_ba, tlv_ba_length, tlv_id, found_tlv);
return thread_meshcop_tlv_find((const uint8_t *)tlv_ba, tlv_ba_length, tlv_id, found_tlv);
}
tlv_length = thread_meshcop_tlv_find((const uint8_t*)tlv_ba, tlv_ba_length, tlv_id, found_tlv);
tlv_length = thread_meshcop_tlv_find((const uint8_t *)tlv_ba, tlv_ba_length, tlv_id, found_tlv);
}
return tlv_length;
@ -395,7 +395,8 @@ uint8_t thread_meshcop_tlv_data_get_uint64(const uint8_t *ptr, uint16_t length,
}
#else
uint16_t thread_meshcop_tlv_find(const uint8_t *ptr, uint16_t length, uint8_t type, uint8_t **result_ptr) {
uint16_t thread_meshcop_tlv_find(const uint8_t *ptr, uint16_t length, uint8_t type, uint8_t **result_ptr)
{
(void)ptr;
(void)length;
(void)type;
@ -403,7 +404,8 @@ uint16_t thread_meshcop_tlv_find(const uint8_t *ptr, uint16_t length, uint8_t ty
return 0;
}
uint8_t *thread_meshcop_tlv_data_write(uint8_t *ptr, uint8_t type, uint16_t length, const uint8_t *data) {
uint8_t *thread_meshcop_tlv_data_write(uint8_t *ptr, uint8_t type, uint16_t length, const uint8_t *data)
{
(void)ptr;
(void)type;
(void)length;
@ -435,7 +437,8 @@ uint8_t *thread_meshcop_tlv_data_write_uint32(uint8_t *ptr, uint8_t type, uint32
return NULL;
}
uint8_t *thread_meshcop_tlv_data_write_uint64(uint8_t *ptr, uint8_t type, uint64_t data) {
uint8_t *thread_meshcop_tlv_data_write_uint64(uint8_t *ptr, uint8_t type, uint64_t data)
{
(void) ptr;
(void)type;
(void)data;
@ -478,7 +481,7 @@ bool thread_meshcop_tlv_list_present(const uint8_t *ptr, uint16_t length, const
(void)required_tlv_len;
return false;
}
uint16_t thread_meshcop_tlv_list_generate(const uint8_t *ptr, uint16_t length,uint8_t *result_ptr, uint16_t *result_len)
uint16_t thread_meshcop_tlv_list_generate(const uint8_t *ptr, uint16_t length, uint8_t *result_ptr, uint16_t *result_len)
{
(void)ptr;
(void)length;
@ -502,7 +505,7 @@ bool thread_meshcop_tlv_list_type_available(const uint8_t *list_ptr, uint16_t li
return false;
}
uint16_t thread_meshcop_tlv_find_next(uint8_t* tlv_ba, uint16_t tlv_ba_length, uint8_t tlv_id, uint8_t** found_tlv)
uint16_t thread_meshcop_tlv_find_next(uint8_t *tlv_ba, uint16_t tlv_ba_length, uint8_t tlv_id, uint8_t **found_tlv)
{
(void)tlv_ba;
(void)tlv_ba_length;

View File

@ -80,7 +80,7 @@ void thread_general_mle_receive_cb(int8_t interface_id, mle_message_t *mle_msg,
protocol_interface_info_entry_t *cur = mle_msg->interface_ptr;
/* Check that message is from link-local scope */
if(!addr_is_ipv6_link_local(mle_msg->packet_src_address)) {
if (!addr_is_ipv6_link_local(mle_msg->packet_src_address)) {
return;
}
@ -90,61 +90,60 @@ void thread_general_mle_receive_cb(int8_t interface_id, mle_message_t *mle_msg,
thread_lowpower_process_request(mle_msg);
switch (mle_msg->message_type) {
case MLE_COMMAND_ACCEPT: {
thread_parse_accept(cur, mle_msg, security_headers, linkMargin);
break;
}
case MLE_COMMAND_METRIC_MANAGEMENT_REQUEST: {
thread_lowpower_metrics_management_query_request_process(cur, mle_msg, security_headers, linkMargin);
break;
}
case MLE_COMMAND_REJECT: {
mac_neighbor_table_entry_t *entry_temp;
tr_warn("Reject Link");
entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL);
if (entry_temp) {
mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), entry_temp);
case MLE_COMMAND_ACCEPT: {
thread_parse_accept(cur, mle_msg, security_headers, linkMargin);
break;
}
break;
}
case MLE_COMMAND_DATASET_ANNOUNCE: {
thread_parse_annoucement(cur, mle_msg);
break;
}
case MLE_COMMAND_ADVERTISEMENT: {
thread_parse_advertisement(cur, mle_msg, security_headers, linkMargin);
break;
}
case MLE_COMMAND_DATA_RESPONSE: {
thread_parse_data_response(cur, mle_msg, linkMargin);
break;
}
case MLE_COMMAND_CHILD_UPDATE_RESPONSE:
{
thread_parse_child_update_response(cur, mle_msg, security_headers, linkMargin);
break;
}
case MLE_COMMAND_PARENT_RESPONSE: {
tr_debug("MLE parent response received");
thread_mle_parent_discover_receive_cb(interface_id, mle_msg, security_headers);
break;
}
default:
if ((thread_am_host(cur) || thread_am_reed(cur)) && mle_msg->message_type == MLE_COMMAND_CHILD_UPDATE_REQUEST){
// Thread host and router in REED mode answer the message same way. Routers only process messages from child
thread_host_child_update_request_process(cur, mle_msg, linkMargin);
} else if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_ROUTER) {
thread_router_bootstrap_mle_receive_cb(interface_id, mle_msg, security_headers);
} else {
tr_warn("Not supported MLE message for host %d", mle_msg->message_type);
case MLE_COMMAND_METRIC_MANAGEMENT_REQUEST: {
thread_lowpower_metrics_management_query_request_process(cur, mle_msg, security_headers, linkMargin);
break;
}
case MLE_COMMAND_REJECT: {
mac_neighbor_table_entry_t *entry_temp;
tr_warn("Reject Link");
entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL);
if (entry_temp) {
mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), entry_temp);
}
break;
}
case MLE_COMMAND_DATASET_ANNOUNCE: {
thread_parse_annoucement(cur, mle_msg);
break;
}
case MLE_COMMAND_ADVERTISEMENT: {
thread_parse_advertisement(cur, mle_msg, security_headers, linkMargin);
break;
}
case MLE_COMMAND_DATA_RESPONSE: {
thread_parse_data_response(cur, mle_msg, linkMargin);
break;
}
case MLE_COMMAND_CHILD_UPDATE_RESPONSE: {
thread_parse_child_update_response(cur, mle_msg, security_headers, linkMargin);
break;
}
case MLE_COMMAND_PARENT_RESPONSE: {
tr_debug("MLE parent response received");
thread_mle_parent_discover_receive_cb(interface_id, mle_msg, security_headers);
break;
}
default:
if ((thread_am_host(cur) || thread_am_reed(cur)) && mle_msg->message_type == MLE_COMMAND_CHILD_UPDATE_REQUEST) {
// Thread host and router in REED mode answer the message same way. Routers only process messages from child
thread_host_child_update_request_process(cur, mle_msg, linkMargin);
} else if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_ROUTER) {
thread_router_bootstrap_mle_receive_cb(interface_id, mle_msg, security_headers);
} else {
tr_warn("Not supported MLE message for host %d", mle_msg->message_type);
}
}
}
@ -200,7 +199,7 @@ static int8_t thread_link_request_start(protocol_interface_info_entry_t *cur, ui
tr_debug("Synch Req");
if (mle_service_update_length_by_ptr(bufId,ptr)!= 0) {
if (mle_service_update_length_by_ptr(bufId, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
@ -277,7 +276,7 @@ static void thread_update_mle_entry(protocol_interface_info_entry_t *cur, mle_me
uint8_t linkMargin = thread_compute_link_margin(mle_msg->dbm);
mle_neigh_entry_frame_counter_update(entry_temp, mle_msg->data_ptr, mle_msg->data_length, cur, security_headers->KeyIndex);
thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, entry_temp->index,linkMargin, false);
thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, entry_temp->index, linkMargin, false);
thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, entry_temp->index);
if (!thread_attach_active_router(cur) && !thread_check_is_this_my_parent(cur, entry_temp)) {
@ -323,7 +322,7 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle
// Check device mode & bootstrap state
if ((thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) ||
(cur->nwk_bootstrap_state != ER_BOOTSRAP_DONE && cur->nwk_bootstrap_state != ER_MLE_ATTACH_READY)) {
(cur->nwk_bootstrap_state != ER_BOOTSRAP_DONE && cur->nwk_bootstrap_state != ER_MLE_ATTACH_READY)) {
return;
}
@ -350,7 +349,7 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle
thread_management_key_synch_req(cur->id, common_read_32_bit(security_headers->Keysource));
}
if (entry_temp && !adv_from_my_partition && !my_parent ) {
if (entry_temp && !adv_from_my_partition && !my_parent) {
// Remove MLE entry that are located in other partition and is not my parent
mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), entry_temp);
entry_temp = NULL;
@ -378,7 +377,7 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle
thread_link_request_start(cur, mle_msg->packet_src_address);
return;
}
/* Advertisement from higher / lower partition */
/* Advertisement from higher / lower partition */
} else {
// Check if better partition is heard
if (thread_bootstrap_partition_process(cur, thread_get_router_count_from_route_tlv(&routeTlv), &leaderData, &routeTlv) > 0) {
@ -388,13 +387,13 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle
}
// REED advertisement to lower partition to help merge faster
if (thread_heard_lower_partition(cur,leaderData)) {
if (thread_heard_lower_partition(cur, leaderData)) {
thread_router_bootstrap_reed_merge_advertisement(cur);
}
}
/* ROUTER */
/* ROUTER */
} else {
if (!thread_router_leader_data_process(cur, mle_msg->packet_src_address, &leaderData, &routeTlv, entry_temp) ) {
if (!thread_router_leader_data_process(cur, mle_msg->packet_src_address, &leaderData, &routeTlv, entry_temp)) {
return;
}
thread_router_bootstrap_advertiment_analyze(cur, mle_msg->packet_src_address, entry_temp, shortAddress);
@ -402,9 +401,9 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle
}
// Process route TLV
if ((entry_temp && routeTlv.dataPtr && routeTlv.tlvLen) && thread_partition_match(cur, &leaderData)){
if ((entry_temp && routeTlv.dataPtr && routeTlv.tlvLen) && thread_partition_match(cur, &leaderData)) {
tr_debug("Update Route TLV %x", entry_temp->mac16);
thread_router_bootstrap_route_tlv_push(cur, routeTlv.dataPtr, routeTlv.tlvLen , linkMargin, entry_temp);
thread_router_bootstrap_route_tlv_push(cur, routeTlv.dataPtr, routeTlv.tlvLen, linkMargin, entry_temp);
}
}
static void thread_parse_accept(protocol_interface_info_entry_t *cur, mle_message_t *mle_msg, mle_security_header_t *security_headers, uint8_t linkMargin)
@ -464,7 +463,7 @@ static void thread_parse_accept(protocol_interface_info_entry_t *cur, mle_messag
// Set full data as REED needs full data and SED will not make links
thread_neighbor_class_request_full_data_setup_set(&cur->thread_info->neighbor_class, entry_temp->index, true);
mlme_device_descriptor_t device_desc;
mac_helper_device_description_write(cur, &device_desc, entry_temp->mac64, entry_temp->mac16,llFrameCounter, false);
mac_helper_device_description_write(cur, &device_desc, entry_temp->mac64, entry_temp->mac16, llFrameCounter, false);
mac_helper_devicetable_set(&device_desc, cur, entry_temp->index, security_headers->KeyIndex, new_entry_created);
uint32_t timeout;
@ -501,15 +500,15 @@ static void thread_parse_annoucement(protocol_interface_info_entry_t *cur, mle_m
tr_info("Recv Dataset Announce");
if (8 > thread_tmfcop_tlv_data_get_uint64(mle_msg->data_ptr, mle_msg->data_length,MLE_TYPE_ACTIVE_TIMESTAMP,&timestamp)) {
if (8 > thread_tmfcop_tlv_data_get_uint64(mle_msg->data_ptr, mle_msg->data_length, MLE_TYPE_ACTIVE_TIMESTAMP, &timestamp)) {
tr_error("Missing timestamp TLV");
return;
}
if (2 > thread_tmfcop_tlv_data_get_uint16(mle_msg->data_ptr, mle_msg->data_length,MLE_TYPE_PANID,&panid)) {
if (2 > thread_tmfcop_tlv_data_get_uint16(mle_msg->data_ptr, mle_msg->data_length, MLE_TYPE_PANID, &panid)) {
tr_error("Missing Panid TLV");
return;
}
if (3 > thread_tmfcop_tlv_find(mle_msg->data_ptr, mle_msg->data_length,MLE_TYPE_CHANNEL,&ptr)) {
if (3 > thread_tmfcop_tlv_find(mle_msg->data_ptr, mle_msg->data_length, MLE_TYPE_CHANNEL, &ptr)) {
tr_error("Missing Channel TLV");
return;
}
@ -522,7 +521,7 @@ static void thread_parse_annoucement(protocol_interface_info_entry_t *cur, mle_m
return;
}
if (cur->thread_info->announcement_info && cur->thread_info->announcement_info->timestamp == timestamp){
if (cur->thread_info->announcement_info && cur->thread_info->announcement_info->timestamp == timestamp) {
// We received same timestamp again
tr_debug("Processing announce with same timestamp");
return;
@ -536,7 +535,7 @@ static void thread_parse_annoucement(protocol_interface_info_entry_t *cur, mle_m
}
tr_debug("New configuration received");
thread_bootstrap_temporary_attach(cur,channel_page, channel, panid, timestamp);
thread_bootstrap_temporary_attach(cur, channel_page, channel, panid, timestamp);
}
static void thread_parse_data_response(protocol_interface_info_entry_t *cur, mle_message_t *mle_msg, uint8_t linkMargin)
@ -569,7 +568,7 @@ static void thread_parse_data_response(protocol_interface_info_entry_t *cur, mle
thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, entry_temp->index);
}
if(cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_ROUTER ||
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_ROUTER ||
cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_FULL_END_DEVICE) {
if (thread_info(cur)->thread_attached_state == THREAD_STATE_CONNECTED) {
// We are attached as child and just learn new data
@ -583,7 +582,7 @@ static void thread_parse_data_response(protocol_interface_info_entry_t *cur, mle
}
}
} else if (thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_END_DEVICE ||
thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) {
thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) {
if (!entry_temp) {
tr_debug("Unknown neighbor");
return;
@ -611,7 +610,7 @@ static void thread_parse_data_response(protocol_interface_info_entry_t *cur, mle
mle_tlv_read_tlv(MLE_TYPE_OPERATIONAL_DATASET, mle_msg->data_ptr, mle_msg->data_length, &ConfigurationTlv);
if (mle_tlv_read_64_bit_tlv(MLE_TYPE_ACTIVE_TIMESTAMP, mle_msg->data_ptr, mle_msg->data_length, &active_timestamp)) {
thread_active_operational_dataset_process(cur,ConfigurationTlv.dataPtr, ConfigurationTlv.tlvLen, active_timestamp);
thread_active_operational_dataset_process(cur, ConfigurationTlv.dataPtr, ConfigurationTlv.tlvLen, active_timestamp);
}
// TODO check if result is true then need to update all configurations
mle_tlv_read_tlv(MLE_TYPE_PENDING_OPERATIONAL_DATASET, mle_msg->data_ptr, mle_msg->data_length, &ConfigurationTlv);
@ -623,16 +622,16 @@ static void thread_parse_data_response(protocol_interface_info_entry_t *cur, mle
if (thread_joiner_application_active_timestamp_get(cur->id) < active_timestamp
|| thread_joiner_application_pending_config_timestamp_get(cur->id) < pending_timestamp) {
tr_debug("Request new network data with configurations active %"PRIX64", %"PRIX64" Pending %"PRIX64", %"PRIX64,
active_timestamp, thread_joiner_application_active_timestamp_get(cur->id),
pending_timestamp, thread_joiner_application_pending_config_timestamp_get(cur->id));
active_timestamp, thread_joiner_application_active_timestamp_get(cur->id),
pending_timestamp, thread_joiner_application_pending_config_timestamp_get(cur->id));
thread_network_data_request_send(cur, mle_msg->packet_src_address, true);
return;
}
//Check Network Data TLV
if (accept_new_data) {
if (mle_tlv_read_tlv(MLE_TYPE_NETWORK_DATA, mle_msg->data_ptr, mle_msg->data_length, &networkDataTlv)) {
thread_bootstrap_network_data_save(cur, &leaderData, networkDataTlv.dataPtr, networkDataTlv.tlvLen);
thread_bootstrap_network_data_update(cur);
thread_bootstrap_network_data_save(cur, &leaderData, networkDataTlv.dataPtr, networkDataTlv.tlvLen);
thread_bootstrap_network_data_update(cur);
} else {
tr_debug("SET NWK data Request state");
}
@ -677,12 +676,12 @@ static int thread_host_child_update_response_send(protocol_interface_info_entry_
ptr = thread_leader_data_tlv_write(ptr, cur);
//Set Addresss TLV
if (requestTlv && mle_tlv_requested(requestTlv->dataPtr,requestTlv->tlvLen,MLE_TYPE_ADDRESS_REGISTRATION) &&
(mode & MLE_FFD_DEV) == 0) {
if (requestTlv && mle_tlv_requested(requestTlv->dataPtr, requestTlv->tlvLen, MLE_TYPE_ADDRESS_REGISTRATION) &&
(mode & MLE_FFD_DEV) == 0) {
ptr = thread_address_registration_tlv_write(ptr, cur);
}
if (requestTlv && mle_tlv_requested(requestTlv->dataPtr,requestTlv->tlvLen,MLE_TYPE_TIMEOUT)) {
if (requestTlv && mle_tlv_requested(requestTlv->dataPtr, requestTlv->tlvLen, MLE_TYPE_TIMEOUT)) {
ptr = mle_tlv_write_timeout(ptr, cur->thread_info->host_link_timeout);
}
@ -693,7 +692,7 @@ static int thread_host_child_update_response_send(protocol_interface_info_entry_
ptr = mle_tlv_write_framecounter(ptr, mle_service_security_get_frame_counter(cur->id));
}
if (mle_service_update_length_by_ptr(bufId,ptr)!= 0) {
if (mle_service_update_length_by_ptr(bufId, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
mle_service_set_msg_destination_address(bufId, dst_address);
@ -734,7 +733,7 @@ static bool thread_address_registration_tlv_check(protocol_interface_info_entry_
ns_list_foreach_safe(if_address_entry_t, e, &cur->ip_addresses) {
if (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_GLOBAL || (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_REALM_LOCAL &&
!thread_addr_is_mesh_local_16(e->address, cur))) {
!thread_addr_is_mesh_local_16(e->address, cur))) {
if (thread_address_registration_tlv_search(e, tlv_info) == false) {
tr_debug("Address %s registration to parent failed", trace_ipv6(e->address));
@ -766,8 +765,8 @@ static void thread_host_child_update_request_process(protocol_interface_info_ent
entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL);
if (!thread_leader_data_parse(mle_msg->data_ptr, mle_msg->data_length, &leaderData) ||
!entry_temp ||
!thread_check_is_this_my_parent(cur, entry_temp)) {
!entry_temp ||
!thread_check_is_this_my_parent(cur, entry_temp)) {
// Dropped if no leader data or not from parent
tr_warn("invalid message");
return;
@ -785,8 +784,8 @@ static void thread_host_child_update_request_process(protocol_interface_info_ent
}
//Check Network Data TLV
if (mle_tlv_read_tlv(MLE_TYPE_NETWORK_DATA, mle_msg->data_ptr, mle_msg->data_length, &networkDataTlv)) {
thread_bootstrap_network_data_save(cur, &leaderData, networkDataTlv.dataPtr, networkDataTlv.tlvLen);
thread_bootstrap_network_data_update(cur);
thread_bootstrap_network_data_save(cur, &leaderData, networkDataTlv.dataPtr, networkDataTlv.tlvLen);
thread_bootstrap_network_data_update(cur);
}
// Check Address Registration TLV
@ -795,7 +794,7 @@ static void thread_host_child_update_request_process(protocol_interface_info_ent
}
if (thread_info(cur)->thread_leader_data->stableDataVersion != leaderData.stableDataVersion ||
thread_info(cur)->thread_leader_data->dataVersion != leaderData.dataVersion) {
thread_info(cur)->thread_leader_data->dataVersion != leaderData.dataVersion) {
// version numbers not in sync need to send data request
data_request_needed = true;
}
@ -803,7 +802,7 @@ static void thread_host_child_update_request_process(protocol_interface_info_ent
// update operational datasets
mle_tlv_read_tlv(MLE_TYPE_OPERATIONAL_DATASET, mle_msg->data_ptr, mle_msg->data_length, &ConfigurationTlv);
if (mle_tlv_read_64_bit_tlv(MLE_TYPE_ACTIVE_TIMESTAMP, mle_msg->data_ptr, mle_msg->data_length, &active_timestamp)) {
thread_active_operational_dataset_process(cur,ConfigurationTlv.dataPtr, ConfigurationTlv.tlvLen, active_timestamp);
thread_active_operational_dataset_process(cur, ConfigurationTlv.dataPtr, ConfigurationTlv.tlvLen, active_timestamp);
}
mle_tlv_read_tlv(MLE_TYPE_PENDING_OPERATIONAL_DATASET, mle_msg->data_ptr, mle_msg->data_length, &ConfigurationTlv);
if (mle_tlv_read_64_bit_tlv(MLE_TYPE_PENDING_TIMESTAMP, mle_msg->data_ptr, mle_msg->data_length, &pending_timestamp)) {
@ -811,10 +810,10 @@ static void thread_host_child_update_request_process(protocol_interface_info_ent
}
// Check if operational datasets are in sync
if (thread_joiner_application_active_timestamp_get(cur->id) < active_timestamp ||
thread_joiner_application_pending_config_timestamp_get(cur->id) < pending_timestamp) {
thread_joiner_application_pending_config_timestamp_get(cur->id) < pending_timestamp) {
tr_debug("Request new network data with configurations active %"PRIX64", %"PRIX64" Pending %"PRIX64", %"PRIX64,
active_timestamp, thread_joiner_application_active_timestamp_get(cur->id),
pending_timestamp, thread_joiner_application_pending_config_timestamp_get(cur->id));
active_timestamp, thread_joiner_application_active_timestamp_get(cur->id),
pending_timestamp, thread_joiner_application_pending_config_timestamp_get(cur->id));
data_request_needed = true;
}
thread_host_child_update_response_send(cur, mle_msg->packet_src_address, &challengeTlv, &tlv_req);
@ -845,7 +844,7 @@ static void thread_parse_child_update_response(protocol_interface_info_entry_t *
entry_temp = mac_neighbor_entry_get_by_ll64(mac_neighbor_info(cur), mle_msg->packet_src_address, false, NULL);
if (mle_tlv_read_8_bit_tlv(MLE_TYPE_STATUS, mle_msg->data_ptr, mle_msg->data_length, &status) &&
status == 1 && thread_check_is_this_my_parent(cur, entry_temp)) {
status == 1 && thread_check_is_this_my_parent(cur, entry_temp)) {
tr_debug("parent has connection error");
mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), entry_temp);
thread_bootstrap_connection_error(cur->id, CON_PARENT_CONNECT_DOWN, NULL);
@ -892,7 +891,7 @@ static void thread_parse_child_update_response(protocol_interface_info_entry_t *
}
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) {
if (cur->thread_info->childUpdateReqTimer < 1) {
if (cur->thread_info->childUpdateReqTimer < 1) {
cur->thread_info->childUpdateReqTimer = 0.8 * timeout;
}
}

View File

@ -165,7 +165,7 @@ static void thread_nd_coap_notification_callback(int8_t interface_id, const uint
}
}
static bool thread_nd_coap_transmit(protocol_interface_info_entry_t *cur, ipv6_neighbour_t *entry , uint8_t seq)
static bool thread_nd_coap_transmit(protocol_interface_info_entry_t *cur, ipv6_neighbour_t *entry, uint8_t seq)
{
if (thread_resolution_client_resolve(cur->id, entry->ip_address, thread_nd_coap_response_callback) < 0) {
@ -248,22 +248,22 @@ static int thread_nd_address_query_lookup(int8_t interface_id, const uint8_t tar
/* Verify DHCP Server Status */
bool can_route_of_mesh = false;
if (!nd_proxy_enabled_for_upstream(interface_id) ) {
if (!nd_proxy_enabled_for_upstream(interface_id)) {
//ND proxy not enabled can not answer
return -1;
}
// TODO needed for eternal border router applications can be removed later
if ( libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface_id, target_addr) ){
if (libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface_id, target_addr)) {
can_route_of_mesh = true;
}
// Check if we are registered as border router in network data.
if(thread_bbr_routing_enabled(cur)) {
if (thread_bbr_routing_enabled(cur)) {
can_route_of_mesh = true;
}
if (thread_extension_bbr_nd_query_process(cur,target_addr, *rloc)){
if (thread_extension_bbr_nd_query_process(cur, target_addr, *rloc)) {
return -1;
}
@ -379,8 +379,8 @@ buffer_t *thread_nd_snoop(protocol_interface_info_entry_t *cur, buffer_t *buf, c
/* Packet must have been mesh-addressed to a minimal-function child. This always */
/* indicates a cache error, unless the IP destination was an ML16 (RLOC16). */
if (!thread_addr_is_mesh_local_16(buf->dst_sa.address, cur) ||
buf->dst_sa.address[14] != ll_dst->address[2] ||
buf->dst_sa.address[15] != ll_dst->address[3]) {
buf->dst_sa.address[14] != ll_dst->address[2] ||
buf->dst_sa.address[15] != ll_dst->address[3]) {
goto bounce;
}
@ -474,7 +474,7 @@ buffer_t *thread_nd_special_forwarding(protocol_interface_info_entry_t *cur, buf
return buf;
}
/* If it was addressed to us as an IP router, it's okay if the packet is for a child */
/* If it was addressed to us as an IP router, it's okay if the packet is for a child */
if (thread_i_am_router(cur)) {
//Check Registered Addresses
ns_list_foreach(ipv6_neighbour_t, n, &cur->ipv6_neighbour_cache.list) {
@ -580,7 +580,7 @@ int thread_nd_map_anycast_address(protocol_interface_info_entry_t *cur, uint16_t
{
// Nothing implemented for now
uint16_t anycastAddress = *addr16;
if(anycastAddress == 0xfc00) {
if (anycastAddress == 0xfc00) {
// this is leader anycast address
*addr16 = thread_router_addr_from_id(cur->thread_info->thread_leader_data->leaderRouterId);
return 0;
@ -606,13 +606,13 @@ int thread_nd_map_anycast_address(protocol_interface_info_entry_t *cur, uint16_t
if (!cur->thread_info->registered_commissioner.commissioner_valid) {
return -1;
}
if ( (anycastAddress & 0x0007) != cur->thread_info->registered_commissioner.session_id % 8 ) {
if ((anycastAddress & 0x0007) != cur->thread_info->registered_commissioner.session_id % 8) {
return -1;
}
*addr16 = common_read_16_bit(cur->thread_info->registered_commissioner.border_router_address + 14);
return 0;
}
if (thread_extension_aloc_map(cur,addr16)) {
if (thread_extension_aloc_map(cur, addr16)) {
return 0;
}

View File

@ -38,7 +38,7 @@
#include "6LoWPAN/Thread/thread_neighbor_class.h"
static thread_neigh_table_entry_t * thread_neighbor_class_table_entry_get(thread_neighbor_class_t *class_ptr, uint8_t attribute_index)
static thread_neigh_table_entry_t *thread_neighbor_class_table_entry_get(thread_neighbor_class_t *class_ptr, uint8_t attribute_index)
{
if (!class_ptr->neigh_info_list || attribute_index >= class_ptr->list_size) {
return NULL;
@ -56,8 +56,8 @@ bool thread_neighbor_class_create(thread_neighbor_class_t *class_ptr, uint8_t ne
}
class_ptr->list_size = neigh_table_size;
thread_neigh_table_entry_t * list_ptr = class_ptr->neigh_info_list;
for (uint8_t i = 0; i< neigh_table_size; i++) {
thread_neigh_table_entry_t *list_ptr = class_ptr->neigh_info_list;
for (uint8_t i = 0; i < neigh_table_size; i++) {
memset(list_ptr, 0, sizeof(thread_neigh_table_entry_t));
list_ptr++;
}
@ -73,16 +73,16 @@ void thread_neighbor_class_delete(thread_neighbor_class_t *class_ptr)
void thread_neighbor_class_add_mleid(struct thread_neighbor_class_s *class_ptr, uint8_t attribute_index, const uint8_t *mleid)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (!entry) {
return;
}
memcpy(entry->mlEid, mleid, 8);
}
uint8_t * thread_neighbor_class_get_mleid(struct thread_neighbor_class_s *class_ptr, uint8_t attribute_index)
uint8_t *thread_neighbor_class_get_mleid(struct thread_neighbor_class_s *class_ptr, uint8_t attribute_index)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (!entry) {
return NULL;
}
@ -91,7 +91,7 @@ uint8_t * thread_neighbor_class_get_mleid(struct thread_neighbor_class_s *class_
void thread_neighbor_last_communication_time_update(thread_neighbor_class_t *class_ptr, uint8_t attribute_index)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (!entry) {
return;
}
@ -100,7 +100,7 @@ void thread_neighbor_last_communication_time_update(thread_neighbor_class_t *cla
void thread_neighbor_class_update_link(thread_neighbor_class_t *class_ptr, uint8_t attribute_index, uint8_t linkmargin, bool new_link)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (!entry) {
return;
}
@ -114,7 +114,7 @@ void thread_neighbor_class_update_link(thread_neighbor_class_t *class_ptr, uint8
uint16_t thread_neighbor_entry_linkmargin_get(thread_neighbor_class_t *class_ptr, uint8_t attribute_index)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (!entry) {
return 0;
}
@ -123,7 +123,7 @@ uint16_t thread_neighbor_entry_linkmargin_get(thread_neighbor_class_t *class_ptr
uint32_t thread_neighbor_last_communication_time_get(thread_neighbor_class_t *class_ptr, uint8_t attribute_index)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (!entry) {
return 0;
}
@ -132,7 +132,7 @@ uint32_t thread_neighbor_last_communication_time_get(thread_neighbor_class_t *cl
bool thread_neighbor_class_mleid_compare(thread_neighbor_class_t *class_ptr, uint8_t attribute_index, const uint8_t *mleid)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (!entry || memcmp(entry->mlEid, mleid, 8)) {
return false;
}
@ -141,7 +141,7 @@ bool thread_neighbor_class_mleid_compare(thread_neighbor_class_t *class_ptr, uin
bool thread_neighbor_class_request_full_data_setup(thread_neighbor_class_t *class_ptr, uint8_t attribute_index)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (!entry) {
return false;
}
@ -151,7 +151,7 @@ bool thread_neighbor_class_request_full_data_setup(thread_neighbor_class_t *clas
bool thread_neighbor_class_secured_data_request(thread_neighbor_class_t *class_ptr, uint8_t attribute_index)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (!entry) {
return false;
}
@ -160,7 +160,7 @@ bool thread_neighbor_class_secured_data_request(thread_neighbor_class_t *class_p
void thread_neighbor_class_request_full_data_setup_set(thread_neighbor_class_t *class_ptr, uint8_t attribute_index, bool value)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (entry) {
entry->request_full_data_set = value;
}
@ -168,7 +168,7 @@ void thread_neighbor_class_request_full_data_setup_set(thread_neighbor_class_t *
void thread_neighbor_class_secured_data_request_set(thread_neighbor_class_t *class_ptr, uint8_t attribute_index, bool value)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (entry) {
entry->secured_data_request = value;
}
@ -176,7 +176,7 @@ void thread_neighbor_class_secured_data_request_set(thread_neighbor_class_t *cla
void thread_neighbor_class_mode_parse_to_entry(thread_neighbor_class_t *class_ptr, uint8_t attribute_index, uint8_t mode)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (entry) {
entry->request_full_data_set = mode & MLE_THREAD_REQ_FULL_DATA_SET;
entry->secured_data_request = mode & MLE_THREAD_SECURED_DATA_REQUEST;
@ -186,7 +186,7 @@ void thread_neighbor_class_mode_parse_to_entry(thread_neighbor_class_t *class_pt
uint8_t thread_neighbor_class_mode_write_from_entry(thread_neighbor_class_t *class_ptr, uint8_t attribute_index)
{
uint8_t mode = 0;
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (entry) {
if (entry->request_full_data_set) {
mode |= MLE_THREAD_REQ_FULL_DATA_SET;
@ -202,7 +202,7 @@ uint8_t thread_neighbor_class_mode_write_from_entry(thread_neighbor_class_t *cla
void thread_neighbor_class_entry_remove(thread_neighbor_class_t *class_ptr, uint8_t attribute_index)
{
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr,attribute_index);
thread_neigh_table_entry_t *entry = thread_neighbor_class_table_entry_get(class_ptr, attribute_index);
if (entry) {
memset(entry, 0, sizeof(thread_neigh_table_entry_t));
}

View File

@ -44,7 +44,7 @@ void thread_neighbor_class_add_link(struct thread_neighbor_class_s *class_ptr, u
void thread_neighbor_class_add_mleid(struct thread_neighbor_class_s *class_ptr, uint8_t attribute_index, const uint8_t *mleid);
uint8_t * thread_neighbor_class_get_mleid(struct thread_neighbor_class_s *class_ptr, uint8_t attribute_index);
uint8_t *thread_neighbor_class_get_mleid(struct thread_neighbor_class_s *class_ptr, uint8_t attribute_index);
void thread_neighbor_class_update_link(struct thread_neighbor_class_s *class_ptr, uint8_t attribute_index, uint8_t linkmargin, bool new_link);

View File

@ -310,7 +310,7 @@ int thread_nd_local_data_length_updated(thread_network_data_cache_entry_t *netwo
int ret_val = -1;
uint16_t localDataLength = 0;
localDataLength = thread_network_data_prefix_set_size(networkDataList, true)
+ thread_network_data_service_set_size(networkDataList, true);
+ thread_network_data_service_set_size(networkDataList, true);
if (localDataLength != networkDataList->networkDataTlvSize) {
networkDataList->networkDataTlvSize = localDataLength;
@ -364,7 +364,7 @@ thread_network_server_data_entry_t *thread_server_entry_allocate(thread_border_r
{
thread_network_server_data_entry_t *newEntry = ns_dyn_mem_alloc(sizeof(thread_network_server_data_entry_t));
if (newEntry) {
tr_debug("Create new server entry addr: %04x",service->routerID);
tr_debug("Create new server entry addr: %04x", service->routerID);
newEntry->routerID = service->routerID;
newEntry->stableData = service->stableData;
newEntry->P_configure = service->P_configure;
@ -710,8 +710,7 @@ thread_network_server_data_entry_t *thread_server_entry_get(thread_network_serve
return NULL;
}
tr_info("New server entry made");
ns_list_foreach(thread_network_server_data_entry_t, cur, list)
{
ns_list_foreach(thread_network_server_data_entry_t, cur, list) {
if (service->routerID < cur->routerID) { //Add always longer or same length to before last one
//add before new
tr_debug("Add smaller id");
@ -1025,7 +1024,7 @@ bool thread_network_data_router_id_free(thread_network_data_cache_entry_t *cache
bool address_removed = false;
ns_list_foreach_safe(thread_network_data_prefix_cache_entry_t, cur, &cachePtr->localPrefixList) {
//GET Context
if (thread_server_data_clean_by_router_id(cachePtr, &cur->borderRouterList, cur, false, curInterface) ) {
if (thread_server_data_clean_by_router_id(cachePtr, &cur->borderRouterList, cur, false, curInterface)) {
address_removed = true;
}
thread_server_data_clean_by_router_id(cachePtr, &cur->routeList, cur, true, curInterface);
@ -1077,7 +1076,7 @@ bool thread_network_data_router_id_free(thread_network_data_cache_entry_t *cache
if (cachePtr->temporaryUpdatePushed || cachePtr->stableUpdatePushed) {
//Validate that Length will be always updated
cachePtr->networkDataTlvSize = thread_network_data_prefix_set_size(cachePtr, true)
+ thread_network_data_service_set_size(cachePtr, true);
+ thread_network_data_service_set_size(cachePtr, true);
}
return address_removed;
}
@ -1104,8 +1103,8 @@ void thread_network_data_context_re_use_timer_update(int8_t id, thread_network_d
}
}
if (ns_list_is_empty(&cur->borderRouterList) &&
ns_list_is_empty(&cur->routeList) &&
ns_list_is_empty(&cur->contextList)) {
ns_list_is_empty(&cur->routeList) &&
ns_list_is_empty(&cur->contextList)) {
ns_list_remove(&cachePtr->localPrefixList, cur);
ns_dyn_mem_free(cur);
}
@ -1207,7 +1206,7 @@ static bool thread_network_data_has_subtlv(uint8_t *network_data_ptr, uint16_t n
}
if (prefix_bytes_len != prefix_bytes_length ||
memcmp(prefix, prefix_tlv.Prefix, prefix_bytes_len) != 0) {
memcmp(prefix, prefix_tlv.Prefix, prefix_bytes_len) != 0) {
dptr += length;
continue;
}
@ -1528,16 +1527,16 @@ int thread_nd_local_list_add_service(thread_network_data_cache_entry_t *networkD
return -1;
}
if (entry->server_data_length != server->server_data_length || memcmp(entry->server_data,server->server_data,server->server_data_length) != 0) {
if (entry->server_data_length != server->server_data_length || memcmp(entry->server_data, server->server_data, server->server_data_length) != 0) {
// Server data changed
if (entry->server_data_length != server->server_data_length ) {
if (entry->server_data_length != server->server_data_length) {
ns_dyn_mem_free(entry->server_data);
entry->server_data = ns_dyn_mem_alloc(server->server_data_length);
if (!entry->server_data) {
return -1;
}
}
memcpy(entry->server_data,server->server_data,server->server_data_length);
memcpy(entry->server_data, server->server_data, server->server_data_length);
entry->server_data_length = server->server_data_length;
changed = true;
}
@ -1570,9 +1569,9 @@ int thread_nd_local_list_add_on_mesh_prefix(thread_network_data_cache_entry_t *n
thread_network_data_prefix_cache_entry_t *prefix_entry;
thread_network_server_data_entry_t *server_entry;
if (service->P_dhcp) {
tr_debug("Add DHCPv6 prefix:%s server: %04x", trace_ipv6_prefix(prefixTlv->Prefix, prefixTlv->PrefixLen),service->routerID);
tr_debug("Add DHCPv6 prefix:%s server: %04x", trace_ipv6_prefix(prefixTlv->Prefix, prefixTlv->PrefixLen), service->routerID);
} else {
tr_debug("Add SLAAC prefix:%s server: %04x", trace_ipv6_prefix(prefixTlv->Prefix, prefixTlv->PrefixLen),service->routerID);
tr_debug("Add SLAAC prefix:%s server: %04x", trace_ipv6_prefix(prefixTlv->Prefix, prefixTlv->PrefixLen), service->routerID);
}
if (!networkDataList) {
@ -1715,8 +1714,8 @@ int thread_local_server_list_add_on_mesh_server(thread_network_local_data_cache_
{
int retVal = -1;
tr_debug("Add prefix: %s prf:%d %s%s%s%s%s%s", trace_ipv6_prefix(prefixTlv->Prefix, prefixTlv->PrefixLen), service->Prf,
service->P_default_route?"Default Route ":"",service->P_dhcp?"DHCPv6 Server ":"", service->P_configure?"DHCPv6 Configuration ":"",
service->P_slaac?"SLAAC ":"",service->P_preferred?"Preferred ":"",service->P_res1?"P_res1 ":"");
service->P_default_route ? "Default Route " : "", service->P_dhcp ? "DHCPv6 Server " : "", service->P_configure ? "DHCPv6 Configuration " : "",
service->P_slaac ? "SLAAC " : "", service->P_preferred ? "Preferred " : "", service->P_res1 ? "P_res1 " : "");
if (networkDataList) {
thread_network_local_data_entry_t *prefix_entry = thread_local_prefix_entry_get(&networkDataList->prefix_list, prefixTlv);
@ -2104,7 +2103,7 @@ static bool thread_check_local_data_prefix_stable_boolean(thread_network_local_d
return false;
}
static uint8_t *thread_nd_hosted_prefix_header_write(uint8_t *ptr, uint8_t length,thread_network_local_data_entry_t *cur)
static uint8_t *thread_nd_hosted_prefix_header_write(uint8_t *ptr, uint8_t length, thread_network_local_data_entry_t *cur)
{
uint8_t prefixBytesLen = prefixBits_to_bytes(cur->servicesPrefixLen);
if (thread_check_local_data_prefix_stable_boolean(cur)) {
@ -2247,11 +2246,11 @@ static uint8_t *thread_service_has_route_tlv_write(uint8_t *ptr, uint8_t tlvType
{
*ptr++ = tlvType;
*ptr++ = THREAD_HAS_ROUTE_TLV_LENGTH;
ptr = thread_nd_network_data_has_route_tlv_write(ptr, routerId, preference);
ptr = thread_nd_network_data_has_route_tlv_write(ptr, routerId, preference);
return ptr;
}
uint8_t * thread_nd_own_service_list_data_write(thread_network_local_data_cache_entry_t *serverDataList, uint8_t *ptr, uint16_t routerID)
uint8_t *thread_nd_own_service_list_data_write(thread_network_local_data_cache_entry_t *serverDataList, uint8_t *ptr, uint16_t routerID)
{
uint8_t tlvType;
uint8_t servicesLen;
@ -2269,7 +2268,7 @@ uint8_t * thread_nd_own_service_list_data_write(thread_network_local_data_cache_
ns_list_foreach(thread_network_local_data_entry_t, cur, &serverDataList->prefix_list) {
servicesLen = thread_server_prefix_length(cur);
if (servicesLen) {
ptr = thread_nd_hosted_prefix_header_write(ptr,servicesLen, cur);
ptr = thread_nd_hosted_prefix_header_write(ptr, servicesLen, cur);
if (cur->routeActive) {
if (!(cur->brActive && cur->defaultRoute)) {
// HasRoute is added if BorderRouter TLV does not have default route bit
@ -2458,7 +2457,7 @@ uint8_t *thread_network_data_service_set_write(thread_network_data_cache_entry_t
tlvLength = thread_nd_service_based_on_list_entry_size(cur, true);
if (tlvLength) {
ptr = thread_nd_service_header_write(ptr, cur, tlvLength);
tr_debug("Service: sid:%d e:%"PRIu32" data:%s",cur->S_id, cur->S_enterprise_number, trace_array(cur->S_service_data, cur->S_service_data_length));
tr_debug("Service: sid:%d e:%"PRIu32" data:%s", cur->S_id, cur->S_enterprise_number, trace_array(cur->S_service_data, cur->S_service_data_length));
ptr = thread_nd_service_server_list_write(&cur->server_list, ptr, true);
}
}

View File

@ -148,7 +148,7 @@ typedef struct thread_network_local_data_entry_s {
bool defaultRoute: 1;
bool onMesh: 1;
bool ndDns: 1;
bool res1:1;
bool res1: 1;
ns_list_link_t link; /*!< List link entry */
} thread_network_local_data_entry_t;
@ -188,8 +188,8 @@ typedef struct thread_network_local_data_cache_entry_s {
thread_network_data_service_list_t service_list;
uint16_t registered_rloc16;/*!< Address used for latest registration */
uint16_t publish_coap_req_id;/*!< Non-zero when publish is active */
bool release_old_address:1;/*!< true if network data can be released from old address */
bool publish_pending:1;/*!< true when publish attempt made during active publish */
bool release_old_address: 1; /*!< true if network data can be released from old address */
bool publish_pending: 1; /*!< true when publish attempt made during active publish */
} thread_network_local_data_cache_entry_t;
/**
@ -345,7 +345,7 @@ uint8_t *thread_network_data_service_set_write(thread_network_data_cache_entry_t
bool thread_network_data_service_hosted_by_this_router_id(thread_network_data_service_cache_entry_t *dataList, uint16_t router_id);
uint16_t thread_network_data_service_child_id_from_networkdata_get(thread_network_data_cache_entry_t *networkDataList, uint16_t router_short_addr);
thread_network_data_prefix_cache_entry_t *thread_prefix_entry_find(thread_network_prefix_list_t *list, thread_prefix_tlv_t *prefixTlv);
uint8_t * thread_nd_own_service_list_data_write(thread_network_local_data_cache_entry_t *serverDataList, uint8_t *ptr, uint16_t routerID);
uint8_t *thread_nd_own_service_list_data_write(thread_network_local_data_cache_entry_t *serverDataList, uint8_t *ptr, uint16_t routerID);
uint16_t thread_nd_own_service_list_data_size(thread_network_local_data_cache_entry_t *serverDataList);

View File

@ -194,9 +194,9 @@ void thread_dynamic_storage_child_info_clear(int8_t interface_id, struct mac_nei
{
thread_sync_child_info_t *child_info = thread_dynamic_storage_child_info_find(interface_id, child);
if (child_info){
if (child_info) {
// Clear child information
memset (child_info,0,sizeof(thread_sync_child_info_t));
memset(child_info, 0, sizeof(thread_sync_child_info_t));
tr_debug("Dynamic storage: cleared child; mac16=%04x", child->mac16);
return;
}
@ -277,10 +277,10 @@ void thread_dynamic_storage_build_mle_table(int8_t interface_id)
// Set MAC layer frame counter for the child
mlme_device_descriptor_t device_desc;
thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, mac_entry->index,64, new_entry_created);
thread_neighbor_class_mode_parse_to_entry(&cur->thread_info->neighbor_class, mac_entry->index,storeEntry->networ_dynamic_data_parameters.children[i].mode);
thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, mac_entry->index, 64, new_entry_created);
thread_neighbor_class_mode_parse_to_entry(&cur->thread_info->neighbor_class, mac_entry->index, storeEntry->networ_dynamic_data_parameters.children[i].mode);
thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, mac_entry->index);
mac_helper_device_description_write(cur, &device_desc, mac_entry->mac64, mac_entry->mac16,storeEntry->networ_dynamic_data_parameters.children[i].mac_frame_counter, false);
mac_helper_device_description_write(cur, &device_desc, mac_entry->mac64, mac_entry->mac16, storeEntry->networ_dynamic_data_parameters.children[i].mac_frame_counter, false);
mac_helper_devicetable_set(&device_desc, cur, mac_entry->index, cur->mac_parameters->mac_default_key_index, new_entry_created);
}
}

View File

@ -75,12 +75,12 @@ const char *DEVICE_CONF_FILE = "s_d";
const char *THREAD_NVM_PENDING_CONF_FILE = "p_c";
#define PENDING_CONF_DATA_VERSION 1
static const char* thread_nvm_store_get_root_path(void);
static const char *thread_nvm_store_get_root_path(void);
static int root_path_valid(void);
static int thread_nvm_store_read(const char *file_name, void *data, uint32_t data_size, uint32_t *version);
static int thread_nvm_store_write(const char *file_name, void *data, uint32_t data_size, uint32_t version);
static void thread_nvm_store_create_path(char* fast_data_path, const char* file_name);
static int thread_nvm_store_fast_data_save(thread_nvm_fast_data_t* fast_data_to_set);
static void thread_nvm_store_create_path(char *fast_data_path, const char *file_name);
static int thread_nvm_store_fast_data_save(thread_nvm_fast_data_t *fast_data_to_set);
static int thread_nvm_store_all_counters_store(uint32_t mac_frame_counter, uint32_t mle_frame_counter, uint32_t seq_counter);
static void thread_nvm_store_link_info_delayed_write(uint32_t seconds);
@ -97,15 +97,15 @@ static void thread_nvm_store_link_info_delayed_write(uint32_t seconds);
thread_nvm_fast_data_t cached_fast_data;
thread_nvm_store_link_info_t cached_link_info = {
.nvm_link_info.short_addr = LINK_INFO_SHORT_ADDR_NOT_SET,
.nvm_link_info.mac = {0,0,0,0,0,0,0,0},
.nvm_link_info.mac = {0, 0, 0, 0, 0, 0, 0, 0},
.write_delay = LINK_INFO_WRITE_DELAY,
.loaded = false
};
static const char* thread_nvm_store_get_root_path(void)
static const char *thread_nvm_store_get_root_path(void)
{
char* path = ns_file_system_get_root_path();
if (NULL==path) {
char *path = ns_file_system_get_root_path();
if (NULL == path) {
return "";
}
return path;
@ -113,10 +113,11 @@ static const char* thread_nvm_store_get_root_path(void)
static int root_path_valid(void)
{
if (NULL==ns_file_system_get_root_path())
if (NULL == ns_file_system_get_root_path()) {
return 0;
}
int path_len = strlen(thread_nvm_store_get_root_path());
if(path_len==0 || path_len>MAX_ROOT_PATH_LEN) {
if (path_len == 0 || path_len > MAX_ROOT_PATH_LEN) {
return 0;
}
return 1;
@ -137,7 +138,7 @@ int thread_nvm_store_mleid_rloc_map_read(thread_nvm_mleid_rloc_map *mleid_rloc_m
{
char lc_data_path[LEADER_INFO_STRING_LEN];
uint32_t version;
if (NULL==mleid_rloc_map) {
if (NULL == mleid_rloc_map) {
return THREAD_NVM_FILE_PARAMETER_INVALID;
}
if (!root_path_valid()) {
@ -147,13 +148,13 @@ int thread_nvm_store_mleid_rloc_map_read(thread_nvm_mleid_rloc_map *mleid_rloc_m
int ret = thread_nvm_store_read(lc_data_path, mleid_rloc_map, sizeof(thread_nvm_mleid_rloc_map), &version);
if (THREAD_NVM_FILE_SUCCESS!=ret) {
if (THREAD_NVM_FILE_SUCCESS != ret) {
tr_info("Leader data map read failed");
thread_nvm_store_mleid_rloc_map_remove();
return ret;
}
if (LEADER_INFO_DATA_VERSION!=version) {
if (LEADER_INFO_DATA_VERSION != version) {
tr_info("Leader data map version mismatch %"PRIu32, version);
thread_nvm_store_mleid_rloc_map_remove();
return THREAD_NVM_FILE_VERSION_WRONG;
@ -175,22 +176,22 @@ int thread_nvm_store_mleid_rloc_map_remove(void)
thread_nvm_store_create_path(lc_data_path, LEADER_INFO_FILE);
status = remove(lc_data_path);
if (status != 0) {
return THREAD_NVM_FILE_REMOVE_ERROR;
return THREAD_NVM_FILE_REMOVE_ERROR;
}
return THREAD_NVM_FILE_SUCCESS;
}
int thread_nvm_store_device_configuration_write(uint8_t *mac_ptr, uint8_t *mleid_ptr)
{
thread_nvm_device_conf_t d_c;
if (!root_path_valid()) {
return THREAD_NVM_FILE_ROOT_PATH_INVALID;
}
memcpy(d_c.mac, mac_ptr, sizeof(d_c.mac));
memcpy(d_c.mle_id, mleid_ptr, sizeof(d_c.mle_id));
char device_conf_path[DEVICE_CONF_STRING_LEN];
thread_nvm_store_create_path(device_conf_path, DEVICE_CONF_FILE);
return thread_nvm_store_write(device_conf_path, &d_c, sizeof(thread_nvm_device_conf_t), DEVICE_CONF_VERSION);
thread_nvm_device_conf_t d_c;
if (!root_path_valid()) {
return THREAD_NVM_FILE_ROOT_PATH_INVALID;
}
memcpy(d_c.mac, mac_ptr, sizeof(d_c.mac));
memcpy(d_c.mle_id, mleid_ptr, sizeof(d_c.mle_id));
char device_conf_path[DEVICE_CONF_STRING_LEN];
thread_nvm_store_create_path(device_conf_path, DEVICE_CONF_FILE);
return thread_nvm_store_write(device_conf_path, &d_c, sizeof(thread_nvm_device_conf_t), DEVICE_CONF_VERSION);
}
int thread_nvm_store_device_configuration_read(uint8_t *mac_ptr, uint8_t *mleid_ptr)
@ -205,12 +206,11 @@ int thread_nvm_store_device_configuration_read(uint8_t *mac_ptr, uint8_t *mleid_
thread_nvm_device_conf_t d_c;
ret = thread_nvm_store_read(device_conf_path, &d_c, sizeof(thread_nvm_device_conf_t), &version);
if(THREAD_NVM_FILE_SUCCESS==ret) {
if (THREAD_NVM_FILE_SUCCESS==ret && DEVICE_CONF_VERSION!=version) {
if (THREAD_NVM_FILE_SUCCESS == ret) {
if (THREAD_NVM_FILE_SUCCESS == ret && DEVICE_CONF_VERSION != version) {
tr_info("fast data version mismatch %"PRIu32, version);
ret = THREAD_NVM_FILE_VERSION_WRONG;
}
else {
} else {
memcpy(mac_ptr, d_c.mac, sizeof(d_c.mac));
memcpy(mleid_ptr, d_c.mle_id, sizeof(d_c.mle_id));
}
@ -221,7 +221,7 @@ int thread_nvm_store_device_configuration_read(uint8_t *mac_ptr, uint8_t *mleid_
int thread_nvm_store_pending_configuration_write(void *data, uint16_t size)
{
char pc_data_path[PENDING_CONF_STRING_LEN];
if (NULL==data) {
if (NULL == data) {
return THREAD_NVM_FILE_PARAMETER_INVALID;
}
if (!root_path_valid()) {
@ -235,7 +235,7 @@ int thread_nvm_store_pending_configuration_read(void *data, uint16_t size)
{
char pc_data_path[PENDING_CONF_STRING_LEN];
uint32_t version;
if (NULL==data) {
if (NULL == data) {
return THREAD_NVM_FILE_PARAMETER_INVALID;
}
if (!root_path_valid()) {
@ -244,7 +244,7 @@ int thread_nvm_store_pending_configuration_read(void *data, uint16_t size)
thread_nvm_store_create_path(pc_data_path, THREAD_NVM_PENDING_CONF_FILE);
int ret = thread_nvm_store_read(pc_data_path, data, size, &version);
if (THREAD_NVM_FILE_SUCCESS==ret && PENDING_CONF_DATA_VERSION!=version) {
if (THREAD_NVM_FILE_SUCCESS == ret && PENDING_CONF_DATA_VERSION != version) {
tr_info("Pending configuration version mismatch %"PRIu32, version);
return THREAD_NVM_FILE_VERSION_WRONG;
}
@ -254,7 +254,7 @@ int thread_nvm_store_pending_configuration_read(void *data, uint16_t size)
int thread_nvm_store_active_configuration_write(void *data, uint16_t data_size)
{
char ac_data_path[ACTIVE_CONF_STRING_LEN];
if (NULL==data) {
if (NULL == data) {
return THREAD_NVM_FILE_PARAMETER_INVALID;
}
if (!root_path_valid()) {
@ -269,7 +269,7 @@ int thread_nvm_store_active_configuration_read(void *data, uint16_t data_size)
{
char ac_data_path[ACTIVE_CONF_STRING_LEN];
uint32_t version;
if (NULL==data) {
if (NULL == data) {
return THREAD_NVM_FILE_PARAMETER_INVALID;
}
if (!root_path_valid()) {
@ -278,7 +278,7 @@ int thread_nvm_store_active_configuration_read(void *data, uint16_t data_size)
thread_nvm_store_create_path(ac_data_path, THREAD_NVM_ACTIVE_CONF_FILE);
int ret = thread_nvm_store_read(ac_data_path, data, data_size, &version);
if (THREAD_NVM_FILE_SUCCESS==ret && ACTIVE_CONF_DATA_VERSION!=version) {
if (THREAD_NVM_FILE_SUCCESS == ret && ACTIVE_CONF_DATA_VERSION != version) {
tr_info("active configuration version mismatch %"PRIu32, version);
return THREAD_NVM_FILE_VERSION_WRONG;
}
@ -294,7 +294,7 @@ int thread_nvm_store_active_configuration_remove(void)
thread_nvm_store_create_path(ac_data_path, THREAD_NVM_ACTIVE_CONF_FILE);
int status = remove(ac_data_path);
if (status != 0) {
return THREAD_NVM_FILE_REMOVE_ERROR;
return THREAD_NVM_FILE_REMOVE_ERROR;
}
return THREAD_NVM_FILE_SUCCESS;
}
@ -308,7 +308,7 @@ int thread_nvm_store_pending_configuration_remove(void)
thread_nvm_store_create_path(ac_data_path, THREAD_NVM_PENDING_CONF_FILE);
int status = remove(ac_data_path);
if (status != 0) {
return THREAD_NVM_FILE_REMOVE_ERROR;
return THREAD_NVM_FILE_REMOVE_ERROR;
}
return THREAD_NVM_FILE_SUCCESS;
}
@ -317,9 +317,9 @@ int thread_nvm_store_pending_configuration_remove(void)
int thread_nvm_store_seq_counter_write(uint32_t network_seq_counter)
{
int ret = THREAD_NVM_FILE_SUCCESS;
if (cached_fast_data.seq_counter!=network_seq_counter) {
if (cached_fast_data.seq_counter != network_seq_counter) {
ret = thread_nvm_store_all_counters_store(cached_fast_data.mac_frame_counter, cached_fast_data.mle_frame_counter, network_seq_counter);
cached_fast_data.seq_counter=network_seq_counter;
cached_fast_data.seq_counter = network_seq_counter;
}
return ret;
}
@ -327,13 +327,13 @@ int thread_nvm_store_seq_counter_write(uint32_t network_seq_counter)
int thread_nvm_store_fast_data_check_and_write(uint32_t mac_frame_counter, uint32_t mle_frame_counter, uint32_t network_seq_counter)
{
int ret = THREAD_NVM_FILE_SUCCESS;
if( ((int)(mac_frame_counter - cached_fast_data.mac_frame_counter) > MAC_FRAME_COUNTER_LIMIT) ||
((int)(mle_frame_counter - cached_fast_data.mle_frame_counter) > MLE_FRAME_COUNTER_LIMIT) ||
cached_fast_data.seq_counter!=network_seq_counter) {
ret = thread_nvm_store_all_counters_store(mac_frame_counter, mle_frame_counter, network_seq_counter);
cached_fast_data.mac_frame_counter = mac_frame_counter;
cached_fast_data.mle_frame_counter = mle_frame_counter;
cached_fast_data.seq_counter=network_seq_counter;
if (((int)(mac_frame_counter - cached_fast_data.mac_frame_counter) > MAC_FRAME_COUNTER_LIMIT) ||
((int)(mle_frame_counter - cached_fast_data.mle_frame_counter) > MLE_FRAME_COUNTER_LIMIT) ||
cached_fast_data.seq_counter != network_seq_counter) {
ret = thread_nvm_store_all_counters_store(mac_frame_counter, mle_frame_counter, network_seq_counter);
cached_fast_data.mac_frame_counter = mac_frame_counter;
cached_fast_data.mle_frame_counter = mle_frame_counter;
cached_fast_data.seq_counter = network_seq_counter;
}
return ret;
}
@ -344,18 +344,18 @@ int thread_nvm_store_fast_data_write_all(uint32_t mac_frame_counter, uint32_t ml
ret = thread_nvm_store_all_counters_store(mac_frame_counter, mle_frame_counter, network_seq_counter);
cached_fast_data.mac_frame_counter = mac_frame_counter;
cached_fast_data.mle_frame_counter = mle_frame_counter;
cached_fast_data.seq_counter=network_seq_counter;
cached_fast_data.seq_counter = network_seq_counter;
return ret;
}
int thread_nvm_store_frame_counters_check_and_write(uint32_t mac_frame_counter, uint32_t mle_frame_counter)
{
int ret = THREAD_NVM_FILE_SUCCESS;
if( ((int)(mac_frame_counter - cached_fast_data.mac_frame_counter) > MAC_FRAME_COUNTER_LIMIT) ||
((int)(mle_frame_counter - cached_fast_data.mle_frame_counter) > MLE_FRAME_COUNTER_LIMIT)) {
ret = thread_nvm_store_all_counters_store(mac_frame_counter, mle_frame_counter, cached_fast_data.seq_counter);
cached_fast_data.mac_frame_counter = mac_frame_counter;
cached_fast_data.mle_frame_counter = mle_frame_counter;
if (((int)(mac_frame_counter - cached_fast_data.mac_frame_counter) > MAC_FRAME_COUNTER_LIMIT) ||
((int)(mle_frame_counter - cached_fast_data.mle_frame_counter) > MLE_FRAME_COUNTER_LIMIT)) {
ret = thread_nvm_store_all_counters_store(mac_frame_counter, mle_frame_counter, cached_fast_data.seq_counter);
cached_fast_data.mac_frame_counter = mac_frame_counter;
cached_fast_data.mle_frame_counter = mle_frame_counter;
}
return ret;
}
@ -368,13 +368,12 @@ static int thread_nvm_store_all_counters_store(uint32_t mac_frame_counter, uint3
fast_data.seq_counter = network_seq_counter;
if (root_path_valid()) {
return thread_nvm_store_fast_data_save(&fast_data);
}
else{
} else {
return THREAD_NVM_FILE_ROOT_PATH_INVALID;
}
}
int thread_nvm_store_fast_data_write(thread_nvm_fast_data_t* fast_data)
int thread_nvm_store_fast_data_write(thread_nvm_fast_data_t *fast_data)
{
cached_fast_data.mac_frame_counter = fast_data->mac_frame_counter;
cached_fast_data.mle_frame_counter = fast_data->mle_frame_counter;
@ -382,19 +381,18 @@ int thread_nvm_store_fast_data_write(thread_nvm_fast_data_t* fast_data)
if (root_path_valid()) {
return thread_nvm_store_fast_data_save(fast_data);
}
else {
} else {
return THREAD_NVM_FILE_ROOT_PATH_INVALID;
}
}
static void thread_nvm_store_create_path(char* fast_data_path, const char* file_name)
static void thread_nvm_store_create_path(char *fast_data_path, const char *file_name)
{
strcpy(fast_data_path, thread_nvm_store_get_root_path());
strcat(fast_data_path, file_name);
}
int thread_nvm_store_fast_data_read(thread_nvm_fast_data_t* fast_data)
int thread_nvm_store_fast_data_read(thread_nvm_fast_data_t *fast_data)
{
int ret = THREAD_NVM_FILE_SUCCESS;
@ -403,12 +401,11 @@ int thread_nvm_store_fast_data_read(thread_nvm_fast_data_t* fast_data)
thread_nvm_store_create_path(fast_data_path, FAST_DATA_FILE);
uint32_t version;
ret = thread_nvm_store_read(fast_data_path, fast_data, sizeof(thread_nvm_fast_data_t), &version);
if (THREAD_NVM_FILE_SUCCESS==ret && FAST_DATA_VERSION!=version) {
if (THREAD_NVM_FILE_SUCCESS == ret && FAST_DATA_VERSION != version) {
tr_info("fast data version mismatch %"PRIu32, version);
return THREAD_NVM_FILE_VERSION_WRONG;
}
}
else {
} else {
fast_data->mac_frame_counter = cached_fast_data.mac_frame_counter;
fast_data->mle_frame_counter = cached_fast_data.mle_frame_counter;
fast_data->seq_counter = cached_fast_data.seq_counter;
@ -416,7 +413,7 @@ int thread_nvm_store_fast_data_read(thread_nvm_fast_data_t* fast_data)
return ret;
}
static int thread_nvm_store_fast_data_save(thread_nvm_fast_data_t* fast_data_to_set)
static int thread_nvm_store_fast_data_save(thread_nvm_fast_data_t *fast_data_to_set)
{
char fast_data_path[FAST_DATA_STRING_LEN];
thread_nvm_store_create_path(fast_data_path, FAST_DATA_FILE);
@ -426,13 +423,13 @@ static int thread_nvm_store_fast_data_save(thread_nvm_fast_data_t* fast_data_to_
static int thread_nvm_store_write(const char *file_name, void *data, uint32_t data_size, uint32_t version)
{
FILE *fp = fopen(file_name, "w");
if(fp == NULL) {
if (fp == NULL) {
tr_error("NVM open error: %s", file_name);
return THREAD_NVM_FILE_CANNOT_OPEN;
}
size_t n_bytes = fwrite(&version, 1, sizeof(uint32_t), fp);
if (n_bytes!=sizeof(uint32_t)) {
if (n_bytes != sizeof(uint32_t)) {
tr_warning("NVM version write error");
fclose(fp);
return THREAD_NVM_FILE_WRITE_ERROR;
@ -440,11 +437,10 @@ static int thread_nvm_store_write(const char *file_name, void *data, uint32_t da
n_bytes = fwrite(data, 1, data_size, fp);
fclose(fp);
if (n_bytes!=data_size) {
if (n_bytes != data_size) {
tr_error("NVM write error %s", file_name);
return THREAD_NVM_FILE_WRITE_ERROR;
}
else {
} else {
return THREAD_NVM_FILE_SUCCESS;
}
}
@ -453,13 +449,13 @@ static int thread_nvm_store_write(const char *file_name, void *data, uint32_t da
static int thread_nvm_store_read(const char *file_name, void *data, uint32_t data_size, uint32_t *version)
{
FILE *fp = fopen(file_name, "r");
if(fp == NULL) {
if (fp == NULL) {
tr_warning("File not found: %s", file_name);
return THREAD_NVM_FILE_CANNOT_OPEN;
}
size_t n_bytes = fread(version, 1, sizeof(uint32_t), fp);
if (n_bytes!=sizeof(uint32_t)) {
if (n_bytes != sizeof(uint32_t)) {
tr_warning("NVM version read error %s", file_name);
fclose(fp);
return THREAD_NVM_FILE_READ_ERROR;
@ -467,11 +463,10 @@ static int thread_nvm_store_read(const char *file_name, void *data, uint32_t dat
n_bytes = fread(data, 1, data_size, fp);
fclose(fp);
if (n_bytes!=data_size) {
if (n_bytes != data_size) {
tr_error("NVM read error %s", file_name);
return THREAD_NVM_FILE_READ_ERROR;
}
else {
} else {
return THREAD_NVM_FILE_SUCCESS; // return how many bytes was written.
}
}
@ -483,7 +478,7 @@ int thread_nvm_store_link_info_read(void)
if (!ns_file_system_get_root_path()) {
if (!memcmp(cached_link_info.nvm_link_info.mac, ADDR_UNSPECIFIED, 8) &&
cached_link_info.nvm_link_info.short_addr == LINK_INFO_SHORT_ADDR_NOT_SET) {
cached_link_info.nvm_link_info.short_addr == LINK_INFO_SHORT_ADDR_NOT_SET) {
tr_info("link info not cached");
return THREAD_NVM_FILE_READ_ERROR;
}
@ -493,19 +488,18 @@ int thread_nvm_store_link_info_read(void)
strcpy(link_info_path, thread_nvm_store_get_root_path());
strcat(link_info_path, LINK_INFO_FILE);
uint32_t version=0;
uint32_t version = 0;
status = thread_nvm_store_read(link_info_path, &nvm_link_info_tmp, sizeof(nvm_link_info_t), &version);
if (status != THREAD_NVM_FILE_SUCCESS) {
if (!memcmp(cached_link_info.nvm_link_info.mac, ADDR_UNSPECIFIED, 8) &&
cached_link_info.nvm_link_info.short_addr == LINK_INFO_SHORT_ADDR_NOT_SET) {
cached_link_info.nvm_link_info.short_addr == LINK_INFO_SHORT_ADDR_NOT_SET) {
tr_info("link info not cached and read error %d", status);
cached_link_info.loaded = false;
return THREAD_NVM_FILE_READ_ERROR;
}
return status;
}
else if (ACTIVE_CONF_DATA_VERSION != version) {
} else if (ACTIVE_CONF_DATA_VERSION != version) {
tr_info("link info version mismatch %"PRIu32, version);
return THREAD_NVM_FILE_VERSION_WRONG;
}
@ -518,7 +512,7 @@ int thread_nvm_store_link_info_read(void)
int thread_nvm_store_link_info_get(uint8_t *parent_mac64, uint16_t *my_short_address)
{
if (!memcmp(cached_link_info.nvm_link_info.mac, ADDR_UNSPECIFIED, 8) &&
cached_link_info.nvm_link_info.short_addr == LINK_INFO_SHORT_ADDR_NOT_SET) {
cached_link_info.nvm_link_info.short_addr == LINK_INFO_SHORT_ADDR_NOT_SET) {
tr_info("thread_nvm_store_link_info_get addr zeros");
return THREAD_NVM_FILE_READ_ERROR;
}
@ -556,7 +550,7 @@ int thread_nvm_store_link_info_clear(void)
status = remove(link_info_path);
if (status != 0) {
return THREAD_NVM_FILE_REMOVE_ERROR;
return THREAD_NVM_FILE_REMOVE_ERROR;
}
return THREAD_NVM_FILE_SUCCESS;
@ -589,8 +583,7 @@ static void thread_nvm_store_link_info_delayed_write(uint32_t seconds)
{
if (cached_link_info.write_delay == LINK_INFO_WRITE_DONE) {
return;
}
else if (cached_link_info.write_delay > seconds) {
} else if (cached_link_info.write_delay > seconds) {
cached_link_info.write_delay -= seconds;
return;
}

View File

@ -77,9 +77,9 @@ typedef struct {
} thread_nvm_mleid_rloc_map;
/* reads all fast data from nvm, if the return values is THREAD_NVM_FILE_ROOT_PATH_INVALID, the cached values are returned. */
int thread_nvm_store_fast_data_read(thread_nvm_fast_data_t* fast_data);
int thread_nvm_store_fast_data_read(thread_nvm_fast_data_t *fast_data);
/* stores all fast data to nvm */
int thread_nvm_store_fast_data_write(thread_nvm_fast_data_t* fast_data);
int thread_nvm_store_fast_data_write(thread_nvm_fast_data_t *fast_data);
/* stores new frame counters to nvm only if the any frame counter threshold is passed*/
int thread_nvm_store_frame_counters_check_and_write(uint32_t mac_frame_counter, uint32_t mle_frame_counter);
/* stores the frame counter and seq counter to nvm only if any threshold is passed*/

View File

@ -84,7 +84,7 @@ static NS_LIST_DEFINE(instance_list, thread_resolution_client_t, link);
static thread_resolution_client_t *thread_resolution_client_find(int8_t interface_id)
{
ns_list_foreach(thread_resolution_client_t , cur_ptr, &instance_list) {
ns_list_foreach(thread_resolution_client_t, cur_ptr, &instance_list) {
if (cur_ptr->interface_id == interface_id) {
return cur_ptr;
}
@ -361,7 +361,7 @@ int thread_resolution_client_address_error(int8_t interface_id, const uint8_t de
msg_type = COAP_MSG_TYPE_NON_CONFIRMABLE;
}
tr_debug("TX thread address error: target %s, mle %s, dest %s", trace_ipv6(target_ip_addr) ,trace_array(ml_eid, 8), trace_ipv6(dest_ip_addr));
tr_debug("TX thread address error: target %s, mle %s, dest %s", trace_ipv6(target_ip_addr), trace_array(ml_eid, 8), trace_ipv6(dest_ip_addr));
/* We don't expect a response to this POST, so we don't specify a callback. */
coap_service_request_send(this->coap_service_id, options,
@ -399,11 +399,11 @@ int thread_resolution_client_resolve(int8_t interface_id, uint8_t ip_addr[16], t
ns_list_remove(&this->queries, query);
} else {
/* Get a new set entry - periodic timer will clear up if we go above limit */
query = ns_dyn_mem_alloc(sizeof *query);
query = ns_dyn_mem_alloc(sizeof * query);
if (!query) {
return -1;
}
memset(query, 0, sizeof *query);
memset(query, 0, sizeof * query);
memcpy(query->eid, ip_addr, 16);
}
ns_list_add_to_start(&this->queries, query);

File diff suppressed because it is too large Load Diff

View File

@ -515,8 +515,8 @@ void thread_routing_force_next_hop(protocol_interface_info_entry_t *cur, uint8_t
*/
static thread_router_link_t *thread_routing_update_link_margin_internal(thread_info_t *thread,
uint16_t sender,
uint8_t link_margin_db)
uint16_t sender,
uint8_t link_margin_db)
{
thread_router_id_t sender_id = thread_router_id_from_addr(sender);
@ -546,9 +546,9 @@ static thread_router_link_t *thread_routing_update_link_margin_internal(thread_i
}
int_fast8_t thread_routing_update_link_margin(protocol_interface_info_entry_t *cur,
uint16_t sender,
uint8_t link_margin_db,
uint8_t outgoing_link_margin_db)
uint16_t sender,
uint8_t link_margin_db,
uint8_t outgoing_link_margin_db)
{
thread_info_t *thread = cur->thread_info;
/* Sanity check that the source is a Thread router */
@ -582,8 +582,8 @@ int_fast8_t thread_routing_update_link_margin(protocol_interface_info_entry_t *c
}
int_fast8_t thread_routing_force_link_margin(protocol_interface_info_entry_t *cur,
uint16_t addr,
uint8_t link_margin_db)
uint16_t addr,
uint8_t link_margin_db)
{
thread_info_t *thread = cur->thread_info;
if (!thread || !cur->mac_parameters || !thread_is_router_addr(addr)) {
@ -691,8 +691,8 @@ int_fast8_t thread_routing_add_link(protocol_interface_info_entry_t *cur,
if (our_quality_to_other_neighbour < QUALITY_10dB) {
continue;
}
thread_link_quality_e neighbours_incoming_quality_to_other_neighbour = (thread_link_quality_e) ((byte & ROUTE_DATA_IN_MASK) >> ROUTE_DATA_IN_SHIFT);
thread_link_quality_e neighbours_outgoing_quality_to_other_neighbour = (thread_link_quality_e) ((byte & ROUTE_DATA_OUT_MASK) >> ROUTE_DATA_OUT_SHIFT);
thread_link_quality_e neighbours_incoming_quality_to_other_neighbour = (thread_link_quality_e)((byte & ROUTE_DATA_IN_MASK) >> ROUTE_DATA_IN_SHIFT);
thread_link_quality_e neighbours_outgoing_quality_to_other_neighbour = (thread_link_quality_e)((byte & ROUTE_DATA_OUT_MASK) >> ROUTE_DATA_OUT_SHIFT);
thread_link_quality_e neighbours_quality_to_other_neighbour = thread_quality_combine(neighbours_incoming_quality_to_other_neighbour,
neighbours_outgoing_quality_to_other_neighbour);
if (neighbours_quality_to_other_neighbour < our_quality_to_other_neighbour) {
@ -822,16 +822,16 @@ uint8_t thread_routing_get_route_data_size(protocol_interface_info_entry_t *cur)
return len;
}
uint_fast8_t thread_routing_cost_get_by_router_id(thread_routing_info_t *routing , uint8_t routerId)
uint_fast8_t thread_routing_cost_get_by_router_id(thread_routing_info_t *routing, uint8_t routerId)
{
return thread_compute_route_cost(routing, routerId, NULL);
}
int_fast8_t thread_routing_get_route_data(protocol_interface_info_entry_t *cur,
uint8_t *id_seq,
uint8_t *id_mask,
uint8_t *data,
uint8_t *len_out)
uint8_t *id_seq,
uint8_t *id_mask,
uint8_t *data,
uint8_t *len_out)
{
uint8_t len = 0;
thread_info_t *thread = cur->thread_info;
@ -972,13 +972,13 @@ static void thread_trickle_accelerate(trickle_t *t, const trickle_params_t *para
}
if (t->now > t->t) {
// if now is larger than t move t to trigger event again during this period
t->t = t->now + randLIB_get_random_in_range(0, params->Imin/2);
t->t = t->now + randLIB_get_random_in_range(0, params->Imin / 2);
}
}
void thread_routing_trickle_advance(thread_routing_info_t *routing, uint16_t ticks)
{
trickle_t *t =&routing->mle_advert_timer;
trickle_t *t = &routing->mle_advert_timer;
if (!trickle_running(t, &thread_mle_advert_trickle_params)) {
return;
@ -1003,11 +1003,11 @@ void thread_routing_leader_connection_validate(thread_info_t *thread, uint16_t d
if (disconnect_period < NETWORK_ID_SPEEDUP) {
return;
}
if (disconnect_period > NETWORK_ID_SPEEDUP_MAX ) {
tr_debug("Leader restored:accelerate reset: %d",disconnect_period);
if (disconnect_period > NETWORK_ID_SPEEDUP_MAX) {
tr_debug("Leader restored:accelerate reset: %d", disconnect_period);
trickle_inconsistent_heard(&routing->mle_advert_timer, &thread_mle_advert_trickle_params);
} else {
tr_debug("Leader restored:accelerate: %d",disconnect_period);
tr_debug("Leader restored:accelerate: %d", disconnect_period);
thread_trickle_accelerate(&routing->mle_advert_timer, &thread_mle_advert_trickle_params, 100);// 10 second with 100ms tics
}
}

View File

@ -81,10 +81,12 @@ typedef enum {
/* The draft-kelsey-thread-routing-00 Link Set */
/* XXX - probably don't need this - put it into mle_neigh_table? */
typedef struct thread_router_link_s {
// *INDENT-OFF* astyle
unsigned router_id : THREAD_ROUTER_ID_BITS;
unsigned incoming_quality : THREAD_QUALITY_BITS;
unsigned outgoing_quality : THREAD_QUALITY_BITS;
unsigned link_margin : THREAD_LINK_MARGIN_BITS;
// *INDENT-ON*
unsigned age : 12; /* 100ms ticks, so good for ~2 hours */
bool outgoing_quality_known : 1;
bool as_good : 1;
@ -93,9 +95,11 @@ typedef struct thread_router_link_s {
/* The draft-kelsey-thread-routing-00 Route Set */
typedef struct thread_route_s {
unsigned destination : THREAD_ROUTER_ID_BITS;
unsigned next_hop : THREAD_ROUTER_ID_BITS;
unsigned route_cost : THREAD_COST_BITS; /* Cost according to next_hop - doesn't include our cost to next_hop */
// *INDENT-OFF* astyle
unsigned destination : THREAD_ROUTER_ID_BITS;
unsigned next_hop : THREAD_ROUTER_ID_BITS;
unsigned route_cost : THREAD_COST_BITS; /* Cost according to next_hop - doesn't include our cost to next_hop */
// *INDENT-ON* astyle
ns_list_link_t link;
} thread_route_t;
@ -191,7 +195,7 @@ void thread_routing_trickle_advance(thread_routing_info_t *routing, uint16_t tic
void thread_routing_leader_connection_validate(struct thread_info_s *thread, uint16_t disconnect_period);
void thread_routing_set_mesh_callbacks(protocol_interface_info_entry_t *cur);
uint_fast8_t thread_routing_cost_get_by_router_id(thread_routing_info_t *routing , uint8_t routerId);
uint_fast8_t thread_routing_cost_get_by_router_id(thread_routing_info_t *routing, uint8_t routerId);
bool router_id_sequence_is_greater(const thread_routing_info_t *routing, uint8_t seq);
uint_fast8_t thread_routing_count_neighbours_for_downgrade(thread_routing_info_t *routing, uint_fast8_t *as_good);
@ -203,12 +207,12 @@ void thread_routing_update_id_set(protocol_interface_info_entry_t *cur, uint8_t
void thread_routing_force_next_hop(protocol_interface_info_entry_t *cur, uint8_t id_seq, const uint8_t *id_mask, thread_router_id_t next_hop_id);
int_fast8_t thread_routing_update_link_margin(protocol_interface_info_entry_t *cur,
uint16_t sender,
uint8_t link_margin_db,
uint8_t outgoing_link_margin_db);
uint16_t sender,
uint8_t link_margin_db,
uint8_t outgoing_link_margin_db);
int_fast8_t thread_routing_force_link_margin(protocol_interface_info_entry_t *cur,
uint16_t addr,
uint8_t link_margin_db);
uint16_t addr,
uint8_t link_margin_db);
int_fast8_t thread_routing_add_link(protocol_interface_info_entry_t *cur,
uint16_t sender, uint8_t link_margin_db,
uint8_t id_seq,
@ -221,10 +225,10 @@ int_fast8_t thread_routing_remove_link(protocol_interface_info_entry_t *cur,
uint8_t thread_routing_get_route_data_size(protocol_interface_info_entry_t *cur);
int_fast8_t thread_routing_get_route_data(protocol_interface_info_entry_t *cur,
uint8_t *id_seq,
uint8_t *id_mask,
uint8_t *data,
uint8_t *len_out);
uint8_t *id_seq,
uint8_t *id_mask,
uint8_t *data,
uint8_t *len_out);
#else // HAVE_THREAD_ROUTER
#define thread_i_am_router(cur) false

View File

@ -160,9 +160,9 @@ void arm_nwk_6lowpan_thread_test_print_routing_database(int8_t interface_id)
if (thread_i_am_router(cur)) {
ns_list_foreach(const thread_route_t, route, &thread->routing.route_set) {
tr_debug("Route Set - Dest:%d Next hop:%d Cost:%d",
route->destination,
route->next_hop,
route->route_cost);
route->destination,
route->next_hop,
route->route_cost);
}
}
#else
@ -175,7 +175,7 @@ int8_t thread_routing_set_network_id_timeout(int8_t interface_id, uint16_t netwo
#ifdef HAVE_THREAD
const protocol_interface_info_entry_t *cur;
if( network_id_timeout < 5 ) {
if (network_id_timeout < 5) {
tr_warn("Too small timeout value, min: 5");
return -3;
}
@ -203,7 +203,7 @@ int8_t thread_routing_get_network_id_timeout(int8_t interface_id, uint16_t *netw
#ifdef HAVE_THREAD
const protocol_interface_info_entry_t *cur;
if(!network_id_timeout) {
if (!network_id_timeout) {
tr_warn("Invalid input ptr");
return -3;
}
@ -358,7 +358,7 @@ int8_t thread_reed_set_advertisement_interval(int8_t interface_id, uint16_t adve
#ifdef HAVE_THREAD
const protocol_interface_info_entry_t *cur;
if(!advertisement_interval) {
if (!advertisement_interval) {
tr_warn("Invalid input ptr");
return -3;
}
@ -371,12 +371,12 @@ int8_t thread_reed_set_advertisement_interval(int8_t interface_id, uint16_t adve
tr_warn("Thread not active");
return -2;
}
if (!jitter_interval){
if (!jitter_interval) {
jitter_interval = 0;
}
cur->thread_info->routerSelectParameters.reedAdvertisementInterval = (uint16_t) advertisement_interval;
cur->thread_info->routerSelectParameters.reedAdvertisementJitterInterval = (uint16_t) jitter_interval;
tr_debug("new advertisement interval set to %d seconds and jitter %d seconds",(uint16_t) advertisement_interval, (uint16_t) jitter_interval);
tr_debug("new advertisement interval set to %d seconds and jitter %d seconds", (uint16_t) advertisement_interval, (uint16_t) jitter_interval);
return 0;
#else
(void)interface_id;
@ -695,10 +695,10 @@ static int thread_test_panid_conflict_cb(int8_t service_id, uint8_t source_addre
uint16_t len MAYBE_UNUSED;
tr_debug("Thread test panid conflict request");
if (2 <= thread_meshcop_tlv_data_get_uint16(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_PANID, &panid)) {
tr_info("PANID TLV %02x",panid);
tr_info("PANID TLV %02x", panid);
}
if ( (len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_CHANNEL_MASK, &ptr)) > 0) {
tr_info("Channel mask TLV %s",trace_array(ptr,len));
if ((len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_CHANNEL_MASK, &ptr)) > 0) {
tr_info("Channel mask TLV %s", trace_array(ptr, len));
}
coap_service_response_send(service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, NULL, 0);
return 0;
@ -714,11 +714,11 @@ static int thread_test_energy_scan_result_cb(int8_t service_id, uint8_t source_a
uint16_t len MAYBE_UNUSED;
tr_debug("Thread test energy scan result");
if ( (len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_CHANNEL_MASK, &ptr)) > 0) {
tr_info("Channel mask TLV %s",trace_array(ptr,len));
if ((len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_CHANNEL_MASK, &ptr)) > 0) {
tr_info("Channel mask TLV %s", trace_array(ptr, len));
}
if ( (len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_ENERGY_LIST, &ptr)) > 0) {
tr_info("Energy list TLV %s",trace_array(ptr,len));
if ((len = thread_meshcop_tlv_find(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_ENERGY_LIST, &ptr)) > 0) {
tr_info("Energy list TLV %s", trace_array(ptr, len));
}
coap_service_response_send(service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, NULL, 0);
return 0;
@ -738,10 +738,11 @@ static int thread_test_response_cb(int8_t service_id, uint8_t source_address[sta
return -1;
}
/* Call callback function when receiving response, but do not call when receiving message code "empty" (Just ACK - not piggybacked response) */
if (generic_response_cb_ptr && (response_ptr->msg_code != COAP_MSG_CODE_EMPTY))
if (generic_response_cb_ptr && (response_ptr->msg_code != COAP_MSG_CODE_EMPTY)) {
generic_response_cb_ptr(service_id, response_ptr->payload_ptr, response_ptr->payload_len);
}
if(response_ptr->uri_path_ptr && (!memcmp(response_ptr->uri_path_ptr, THREAD_URI_DIAGNOSTIC_ANSWER, strlen(THREAD_URI_DIAGNOSTIC_ANSWER)))){
if (response_ptr->uri_path_ptr && (!memcmp(response_ptr->uri_path_ptr, THREAD_URI_DIAGNOSTIC_ANSWER, strlen(THREAD_URI_DIAGNOSTIC_ANSWER)))) {
coap_service_response_send(service_id, COAP_REQUEST_OPTIONS_NONE, response_ptr, COAP_MSG_CODE_RESPONSE_CHANGED, COAP_CT_OCTET_STREAM, NULL, 0);
}
return 0;
@ -754,7 +755,7 @@ static int thread_coap_response_cb(int8_t service_id, uint8_t source_address[sta
(void) source_port;
#endif
tr_debug("Thread coap response received %s :%d",trace_ipv6(source_address),source_port);
tr_debug("Thread coap response received %s :%d", trace_ipv6(source_address), source_port);
if (!response_ptr) {
if (coap_response_cb_ptr) {
coap_response_cb_ptr(service_id, 0xff, 0xff, NULL, 0);
@ -776,7 +777,7 @@ static int thread_coap_multicast_response_cb(int8_t service_id, uint8_t source_a
(void) source_port;
#endif
tr_debug("Thread coap multicast response received %s :%d",trace_ipv6(source_address),source_port);
tr_debug("Thread coap multicast response received %s :%d", trace_ipv6(source_address), source_port);
/* Call callback function when receiving response, but do not call when receiving message code "empty" (Just ACK - not piggybacked response) */
if (coap_response_cb_ptr) {
@ -802,11 +803,11 @@ static uint8_t *channel_mask_write(uint8_t *ptr, uint8_t channel_page, uint8_t *
{
uint8_t mask_len = 0;
uint8_t mask_tlv[6];//
if (channel_page == 0){
if (channel_page == 0) {
mask_len = 6;
mask_tlv[0] = channel_page;
mask_tlv[1] = 4;
memcpy(&mask_tlv[2],mask_ptr,4);
memcpy(&mask_tlv[2], mask_ptr, 4);
}
ptr = thread_meshcop_tlv_data_write(ptr, MESHCOP_TLV_CHANNEL_MASK, mask_len, mask_tlv);
return ptr;
@ -819,7 +820,7 @@ int thread_test_panid_query_send(int8_t interface_id, uint8_t *address_ptr, uint
uint8_t payload[16];// 2+6 + 2+2 + 2+2
uint8_t *ptr;
thread_test_service_init(interface_id);
if (address_ptr[0] == 0xff){
if (address_ptr[0] == 0xff) {
msg_type = COAP_MSG_TYPE_NON_CONFIRMABLE;
} else {
msg_type = COAP_MSG_TYPE_CONFIRMABLE;
@ -846,10 +847,10 @@ int thread_test_energy_scan_send(int8_t interface_id, uint8_t *address_ptr, uint
{
#ifdef HAVE_THREAD
sn_coap_msg_type_e msg_type;
uint8_t payload[2+2 + 2+1 + 2+1 + 2+6 + 2+2];
uint8_t payload[2 + 2 + 2 + 1 + 2 + 1 + 2 + 6 + 2 + 2];
uint8_t *ptr;
thread_test_service_init(interface_id);
if (address_ptr[0] == 0xff){
if (address_ptr[0] == 0xff) {
msg_type = COAP_MSG_TYPE_NON_CONFIRMABLE;
} else {
msg_type = COAP_MSG_TYPE_CONFIRMABLE;
@ -878,10 +879,10 @@ int thread_test_energy_scan_send(int8_t interface_id, uint8_t *address_ptr, uint
#endif
}
int thread_test_diagnostic_command_send(int8_t interface_id, uint8_t *address_ptr,const char *uri_ptr, uint8_t request_length, uint8_t *request_ptr, response_cb *resp_cb)
int thread_test_diagnostic_command_send(int8_t interface_id, uint8_t *address_ptr, const char *uri_ptr, uint8_t request_length, uint8_t *request_ptr, response_cb *resp_cb)
{
#ifdef HAVE_THREAD
uint8_t payload[17+2] = {0};
uint8_t payload[17 + 2] = {0};
uint8_t *ptr = NULL;
generic_response_cb_ptr = resp_cb;
sn_coap_msg_type_e msg_type;
@ -889,17 +890,17 @@ int thread_test_diagnostic_command_send(int8_t interface_id, uint8_t *address_pt
thread_test_service_init(interface_id);
if(request_length > 17 || !address_ptr) {
if (request_length > 17 || !address_ptr) {
return -1;
}
if (address_ptr[0] == 0xff){
if (address_ptr[0] == 0xff) {
msg_type = COAP_MSG_TYPE_NON_CONFIRMABLE;
} else {
msg_type = COAP_MSG_TYPE_CONFIRMABLE;
}
if(!strcmp(uri_ptr, "d/dr")){
if (!strcmp(uri_ptr, "d/dr")) {
msg_code = COAP_MSG_CODE_REQUEST_POST;
}
@ -929,7 +930,7 @@ int thread_test_coap_request_send(int8_t interface_id, uint8_t *address_ptr, uin
thread_test_service_init(interface_id);
coap_service_request_send(coap_service, COAP_REQUEST_OPTIONS_NONE, address_ptr, port,
(sn_coap_msg_type_e)msg_type, (sn_coap_msg_code_e)msg_code, uri_ptr, (sn_coap_content_format_e) content_format, request_ptr, request_length, thread_coap_response_cb);
(sn_coap_msg_type_e)msg_type, (sn_coap_msg_code_e)msg_code, uri_ptr, (sn_coap_content_format_e) content_format, request_ptr, request_length, thread_coap_response_cb);
return 0;
#else
@ -955,7 +956,7 @@ int thread_test_announce_ntf_send(int8_t interface_id, uint8_t *address_ptr, uin
(void)address_ptr;
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur || !cur->thread_info ) {
if (!cur || !cur->thread_info) {
return -1;
}
return thread_bootstrap_announce_send(cur, (uint8_t)(channel >> 16), (uint16_t) channel, panid, timestamp, (uint16_t) channel);
@ -972,12 +973,12 @@ int thread_test_announce_ntf_send(int8_t interface_id, uint8_t *address_ptr, uin
int thread_test_announce_begin_send(int8_t interface_id, uint8_t *address_ptr, uint16_t session_id, uint8_t channel_page, uint8_t *mask_ptr, uint16_t period, uint8_t count)
{
#ifdef HAVE_THREAD
uint8_t payload[ 2+2 + 2+2 + 2+1 + 2+6];
uint8_t payload[ 2 + 2 + 2 + 2 + 2 + 1 + 2 + 6];
uint8_t *ptr;
sn_coap_msg_type_e msg_type;
thread_test_service_init(interface_id);
if (address_ptr[0] == 0xff){
if (address_ptr[0] == 0xff) {
msg_type = COAP_MSG_TYPE_NON_CONFIRMABLE;
} else {
msg_type = COAP_MSG_TYPE_CONFIRMABLE;
@ -989,7 +990,7 @@ int thread_test_announce_begin_send(int8_t interface_id, uint8_t *address_ptr, u
ptr = thread_meshcop_tlv_data_write_uint8(ptr, MESHCOP_TLV_COUNT, count);
ptr = channel_mask_write(ptr, channel_page, mask_ptr);
coap_service_request_send(coap_service, COAP_REQUEST_OPTIONS_NONE, address_ptr, THREAD_MANAGEMENT_PORT,
msg_type, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_MANAGEMENT_ANNOUNCE_BEGIN, COAP_CT_OCTET_STREAM, payload, ptr - payload, thread_test_response_cb);
msg_type, COAP_MSG_CODE_REQUEST_POST, THREAD_URI_MANAGEMENT_ANNOUNCE_BEGIN, COAP_CT_OCTET_STREAM, payload, ptr - payload, thread_test_response_cb);
return 0;
#else
@ -1048,7 +1049,7 @@ int thread_test_partition_info_set(int8_t interface_id, uint32_t partition_id)
#ifdef HAVE_THREAD
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur || !cur->thread_info ) {
if (!cur || !cur->thread_info) {
return -1;
}
cur->thread_info->testRandomPartitionId = partition_id;
@ -1076,8 +1077,8 @@ int8_t thread_test_thread_information_get(int8_t interface_id, uint16_t *short_a
}
if (network_stable) {
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE ||
cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_END_DEVICE ||
cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_FULL_END_DEVICE) {
cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_END_DEVICE ||
cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_FULL_END_DEVICE) {
*network_stable = true;
} else {
*network_stable = !(thread_router_bootstrap_reed_upgrade(cur) ||
@ -1111,11 +1112,11 @@ int8_t thread_test_child_count_get(int8_t interface_id)
#endif
}
int8_t thread_test_child_info_get(int8_t interface_id, uint8_t index, uint16_t *short_addr, bool *sleepy, uint8_t *mac64,uint8_t *margin)
int8_t thread_test_child_info_get(int8_t interface_id, uint8_t index, uint16_t *short_addr, bool *sleepy, uint8_t *mac64, uint8_t *margin)
{
#ifdef HAVE_THREAD
protocol_interface_info_entry_t *cur;
uint8_t n= 0;
uint8_t n = 0;
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur || !cur->mac_parameters || !cur->thread_info || cur->thread_info->thread_device_mode != THREAD_DEVICE_MODE_ROUTER) {
return -1;
@ -1130,12 +1131,12 @@ int8_t thread_test_child_info_get(int8_t interface_id, uint8_t index, uint16_t *
if (thread_router_addr_from_addr(cur_entry->mac16) == thread_router_addr_from_addr(mac16)) {
if (n == index) {
*short_addr = cur_entry->mac16;
memcpy(mac64,cur_entry->mac64, 8);
memcpy(mac64, cur_entry->mac64, 8);
*sleepy = cur_entry->rx_on_idle != true;
*margin = thread_neighbor_entry_linkmargin_get(&cur->thread_info->neighbor_class, cur_entry->index);
return 0;
}
n++;
n++;
}
}
return -1;
@ -1153,7 +1154,7 @@ int8_t thread_test_neighbour_info_get(int8_t interface_id, uint8_t index, uint16
{
#ifdef HAVE_THREAD
protocol_interface_info_entry_t *cur;
uint8_t n= 0;
uint8_t n = 0;
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur || !cur->thread_info) {
return -1;
@ -1168,7 +1169,7 @@ int8_t thread_test_neighbour_info_get(int8_t interface_id, uint8_t index, uint16
if (thread_router_addr_from_addr(cur_entry->mac16) != thread_router_addr_from_addr(mac16)) {
if (n == index) {
*short_addr = cur_entry->mac16;
memcpy(mac64,cur_entry->mac64, 8);
memcpy(mac64, cur_entry->mac64, 8);
*margin = thread_neighbor_entry_linkmargin_get(&cur->thread_info->neighbor_class, cur_entry->index);
return 0;
}
@ -1311,7 +1312,7 @@ int thread_test_mle_message_send(int8_t interface_id, uint8_t *dst_address, uint
ptr = thread_leader_data_tlv_write(ptr, cur);
}
if (write_timestamp) {
ptr = thread_active_timestamp_write(cur,ptr);
ptr = thread_active_timestamp_write(cur, ptr);
ptr = thread_pending_operational_dataset_write(cur, ptr);
}
@ -1324,11 +1325,11 @@ int thread_test_mle_message_send(int8_t interface_id, uint8_t *dst_address, uint
}
// Add any user decided TLVs
if (msg_ptr && msg_len) {
memcpy(ptr,msg_ptr,msg_len);
memcpy(ptr, msg_ptr, msg_len);
ptr += msg_len;
}
if (mle_service_update_length_by_ptr(bufId,ptr)!= 0) {
if (mle_service_update_length_by_ptr(bufId, ptr) != 0) {
tr_debug("Buffer overflow at message write");
}
mle_service_set_msg_destination_address(bufId, dst_address);

View File

@ -68,10 +68,10 @@ typedef struct {
uint16_t unfrag_ptr; /*!< Offset within buf of headers that precede the FRAG header */
uint16_t frag_len;
uint8_t unfrag_len; /*!< Length of headers that precede the FRAG header */
bool fragmented_data:1;
bool first_fragment:1;
bool indirect_data:1;
bool indirect_data_cached:1; /*!< Data cached for delayed transmission as mac request is already active */
bool fragmented_data: 1;
bool first_fragment: 1;
bool indirect_data: 1;
bool indirect_data_cached: 1; /*!< Data cached for delayed transmission as mac request is already active */
buffer_t *buf;
uint8_t *fragmenter_buf;
ns_list_link_t link; /*!< List link entry */
@ -106,8 +106,8 @@ static NS_LIST_DEFINE(fragmenter_interface_list, fragmenter_interface_t, link);
static fragmenter_interface_t *lowpan_adaptation_interface_discover(int8_t interfaceId);
/* Interface direct message pending queue functions */
static void lowpan_adaptation_tx_queue_write(fragmenter_interface_t *interface_ptr , buffer_t *buf);
static buffer_t * lowpan_adaptation_tx_queue_read(fragmenter_interface_t *interface_ptr, protocol_interface_info_entry_t *cur);
static void lowpan_adaptation_tx_queue_write(fragmenter_interface_t *interface_ptr, buffer_t *buf);
static buffer_t *lowpan_adaptation_tx_queue_read(fragmenter_interface_t *interface_ptr, protocol_interface_info_entry_t *cur);
/* Data direction and message length validation */
static bool lowpan_adaptation_indirect_data_request(mac_neighbor_table_entry_t *mle_entry);
@ -117,13 +117,13 @@ static bool lowpan_adaptation_request_longer_than_mtu(protocol_interface_info_en
static void lowpan_active_buffer_state_reset(fragmenter_tx_entry_t *tx_buffer);
static uint8_t lowpan_data_request_unique_handle_get(fragmenter_interface_t *interface_ptr);
static fragmenter_tx_entry_t *lowpan_indirect_entry_allocate(uint16_t fragment_buffer_size);
static fragmenter_tx_entry_t * lowpan_adaptation_tx_process_init(fragmenter_interface_t *interface_ptr, bool indirect, bool fragmented, bool is_unicast);
static fragmenter_tx_entry_t *lowpan_adaptation_tx_process_init(fragmenter_interface_t *interface_ptr, bool indirect, bool fragmented, bool is_unicast);
static void lowpan_adaptation_data_request_primitiv_set(const buffer_t *buf, mcps_data_req_t *dataReq, protocol_interface_info_entry_t *cur);
static void lowpan_data_request_to_mac(protocol_interface_info_entry_t *cur, buffer_t *buf, fragmenter_tx_entry_t *tx_ptr, fragmenter_interface_t *interface_ptr);
/* Tx confirmation local functions */
static bool lowpan_active_tx_handle_verify(uint8_t handle, buffer_t *buf);
static fragmenter_tx_entry_t * lowpan_indirect_tx_handle_verify(uint8_t handle, fragmenter_tx_list_t *indirect_tx_queue);
static fragmenter_tx_entry_t *lowpan_indirect_tx_handle_verify(uint8_t handle, fragmenter_tx_list_t *indirect_tx_queue);
static void lowpan_adaptation_data_process_clean(fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr, uint8_t socket_event);
static uint8_t map_mlme_status_to_socket_event(uint8_t mlme_status);
static bool lowpan_adaptation_tx_process_ready(fragmenter_tx_entry_t *tx_ptr);
@ -133,7 +133,7 @@ static int8_t lowpan_message_fragmentation_init(buffer_t *buf, fragmenter_tx_ent
static bool lowpan_message_fragmentation_message_write(const fragmenter_tx_entry_t *frag_entry, mcps_data_req_t *dataReq);
static bool lowpan_adaptation_indirect_queue_free_message(struct protocol_interface_info_entry *cur, fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr);
static fragmenter_tx_entry_t* lowpan_adaptation_indirect_mac_data_request_active(fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr);
static fragmenter_tx_entry_t *lowpan_adaptation_indirect_mac_data_request_active(fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr);
static void lowpan_adaptation_etx_update_cb(protocol_interface_info_entry_t *cur, buffer_t *buf, const mcps_data_conf_t *confirm)
{
@ -150,9 +150,9 @@ static void lowpan_adaptation_etx_update_cb(protocol_interface_info_entry_t *cur
// Gets table entry
mac_neighbor_table_entry_t *neigh_table_ptr = mac_neighbor_table_address_discover(mac_neighbor_info(cur), buf->dst_sa.address + PAN_ID_LEN, buf->dst_sa.addr_type);
if (neigh_table_ptr) {
etx_transm_attempts_update(cur->id, 1 + confirm->tx_retries , success, neigh_table_ptr->index);
etx_transm_attempts_update(cur->id, 1 + confirm->tx_retries, success, neigh_table_ptr->index);
// Updates ETX statistics
etx_storage_t * etx_entry = etx_storage_entry_get(cur->id, neigh_table_ptr->index);
etx_storage_t *etx_entry = etx_storage_entry_get(cur->id, neigh_table_ptr->index);
if (etx_entry) {
if (neigh_table_ptr->link_role == PRIORITY_PARENT_NEIGHBOUR) {
protocol_stats_update(STATS_ETX_1ST_PARENT, etx_entry->etx >> 4);
@ -185,7 +185,7 @@ static fragmenter_interface_t *lowpan_adaptation_interface_discover(int8_t inter
return NULL;
}
static struct protocol_interface_info_entry *lowpan_adaptation_network_interface_discover(const mpx_api_t* api)
static struct protocol_interface_info_entry *lowpan_adaptation_network_interface_discover(const mpx_api_t *api)
{
ns_list_foreach(fragmenter_interface_t, interface_ptr, &fragmenter_interface_list) {
@ -198,7 +198,7 @@ static struct protocol_interface_info_entry *lowpan_adaptation_network_interface
}
static void lowpan_adaptation_tx_queue_write(fragmenter_interface_t *interface_ptr , buffer_t *buf)
static void lowpan_adaptation_tx_queue_write(fragmenter_interface_t *interface_ptr, buffer_t *buf)
{
buffer_t *lower_priority_buf = NULL;
@ -216,7 +216,7 @@ static void lowpan_adaptation_tx_queue_write(fragmenter_interface_t *interface_p
}
}
static buffer_t * lowpan_adaptation_tx_queue_read(fragmenter_interface_t *interface_ptr, protocol_interface_info_entry_t *cur)
static buffer_t *lowpan_adaptation_tx_queue_read(fragmenter_interface_t *interface_ptr, protocol_interface_info_entry_t *cur)
{
/* Currently this function is called only when data confirm is received for previously sent packet.
* Data confirm has freed the corresponding "active buffer" and this function will look for new buffer to be set as active buffer.
@ -227,7 +227,7 @@ static buffer_t * lowpan_adaptation_tx_queue_read(fragmenter_interface_t *interf
if (fragmented_needed && interface_ptr->fragmenter_active) {
tr_debug("Do not trig Second active fragmentation");
} else if ((buf->link_specific.ieee802_15_4.requestAck && !interface_ptr->active_unicast_tx_buf.buf)
|| (!buf->link_specific.ieee802_15_4.requestAck && !interface_ptr->active_broadcast_tx_buf.buf)) {
|| (!buf->link_specific.ieee802_15_4.requestAck && !interface_ptr->active_broadcast_tx_buf.buf)) {
ns_list_remove(&interface_ptr->directTxQueue, buf);
return buf;
}
@ -285,7 +285,7 @@ static bool lowpan_active_tx_handle_verify(uint8_t handle, buffer_t *buf)
static fragmenter_tx_entry_t * lowpan_indirect_tx_handle_verify(uint8_t handle, fragmenter_tx_list_t *indirect_tx_queue)
static fragmenter_tx_entry_t *lowpan_indirect_tx_handle_verify(uint8_t handle, fragmenter_tx_list_t *indirect_tx_queue)
{
ns_list_foreach(fragmenter_tx_entry_t, entry, indirect_tx_queue) {
if (entry->buf->seq == handle) {
@ -301,10 +301,10 @@ static uint8_t lowpan_data_request_unique_handle_get(fragmenter_interface_t *int
{
bool valid_info = false;
uint8_t handle;
while(!valid_info) {
while (!valid_info) {
handle = interface_ptr->msduHandle++;
if (!lowpan_active_tx_handle_verify(handle,interface_ptr->active_unicast_tx_buf.buf)
&& !lowpan_active_tx_handle_verify(handle,interface_ptr->active_broadcast_tx_buf.buf)
if (!lowpan_active_tx_handle_verify(handle, interface_ptr->active_unicast_tx_buf.buf)
&& !lowpan_active_tx_handle_verify(handle, interface_ptr->active_broadcast_tx_buf.buf)
&& !lowpan_indirect_tx_handle_verify(handle, &interface_ptr->indirect_tx_queue)) {
valid_info = true;
}
@ -313,7 +313,7 @@ static uint8_t lowpan_data_request_unique_handle_get(fragmenter_interface_t *int
}
static void lowpan_indirect_entry_free(fragmenter_tx_list_t *list , fragmenter_tx_entry_t *entry)
static void lowpan_indirect_entry_free(fragmenter_tx_list_t *list, fragmenter_tx_entry_t *entry)
{
ns_list_remove(list, entry);
if (entry->buf) {
@ -325,7 +325,7 @@ static void lowpan_indirect_entry_free(fragmenter_tx_list_t *list , fragmenter_t
static void lowpan_indirect_queue_free(fragmenter_tx_list_t *list)
{
while(!ns_list_is_empty(list)) {
while (!ns_list_is_empty(list)) {
fragmenter_tx_entry_t *entry = ns_list_get_first(list);
lowpan_indirect_entry_free(list, entry);
}
@ -349,7 +349,7 @@ int8_t lowpan_adaptation_interface_init(int8_t interface_id, uint16_t mac_mtu_si
return -1;
}
memset(interface_ptr, 0 ,sizeof(fragmenter_interface_t));
memset(interface_ptr, 0, sizeof(fragmenter_interface_t));
interface_ptr->interface_id = interface_id;
interface_ptr->fragment_indirect_tx_buffer = tx_buffer;
interface_ptr->mtu_size = mac_mtu_size;
@ -420,16 +420,16 @@ int8_t lowpan_adaptation_interface_reset(int8_t interface_id)
return 0;
}
static void lowpan_adaptation_mpx_data_confirm(const mpx_api_t* api, const struct mcps_data_conf_s *data)
static void lowpan_adaptation_mpx_data_confirm(const mpx_api_t *api, const struct mcps_data_conf_s *data)
{
protocol_interface_info_entry_t * interface = lowpan_adaptation_network_interface_discover(api);
protocol_interface_info_entry_t *interface = lowpan_adaptation_network_interface_discover(api);
lowpan_adaptation_interface_tx_confirm(interface, data);
}
static void lowpan_adaptation_mpx_data_indication(const mpx_api_t* api, const struct mcps_data_ind_s *data)
static void lowpan_adaptation_mpx_data_indication(const mpx_api_t *api, const struct mcps_data_ind_s *data)
{
protocol_interface_info_entry_t * interface = lowpan_adaptation_network_interface_discover(api);
protocol_interface_info_entry_t *interface = lowpan_adaptation_network_interface_discover(api);
lowpan_adaptation_interface_data_ind(interface, data);
}
@ -579,7 +579,7 @@ static bool lowpan_message_fragmentation_message_write(const fragmenter_tx_entry
return frag_entry->offset * 8 + frag_entry->frag_len < frag_entry->size;
}
static fragmenter_tx_entry_t * lowpan_adaptation_tx_process_init(fragmenter_interface_t *interface_ptr, bool indirect, bool fragmented, bool is_unicast)
static fragmenter_tx_entry_t *lowpan_adaptation_tx_process_init(fragmenter_interface_t *interface_ptr, bool indirect, bool fragmented, bool is_unicast)
{
fragmenter_tx_entry_t *tx_entry;
if (!indirect) {
@ -608,7 +608,7 @@ static fragmenter_tx_entry_t * lowpan_adaptation_tx_process_init(fragmenter_inte
return tx_entry;
}
buffer_t * lowpan_adaptation_data_process_tx_preprocess(protocol_interface_info_entry_t *cur, buffer_t *buf)
buffer_t *lowpan_adaptation_data_process_tx_preprocess(protocol_interface_info_entry_t *cur, buffer_t *buf)
{
mac_neighbor_table_entry_t *neigh_entry_ptr = NULL;
@ -618,7 +618,7 @@ buffer_t * lowpan_adaptation_data_process_tx_preprocess(protocol_interface_info_
goto tx_error_handler;
}
if (addr_check_broadcast(buf->dst_sa.address, buf->dst_sa.addr_type) == eOK ) {
if (addr_check_broadcast(buf->dst_sa.address, buf->dst_sa.addr_type) == eOK) {
buf->dst_sa.addr_type = ADDR_802_15_4_SHORT;
buf->dst_sa.address[2] = 0xff;
buf->dst_sa.address[3] = 0xff;
@ -647,7 +647,7 @@ buffer_t * lowpan_adaptation_data_process_tx_preprocess(protocol_interface_info_
if (buf->link_specific.ieee802_15_4.key_id_mode != B_SECURITY_KEY_ID_2) {
if (!buf->link_specific.ieee802_15_4.requestAck ) {
if (!buf->link_specific.ieee802_15_4.requestAck) {
buf->link_specific.ieee802_15_4.key_id_mode = B_SECURITY_KEY_ID_MODE_DEFAULT;
} else if (ws_info(cur) || (neigh_entry_ptr && !neigh_entry_ptr->trusted_device)) {
buf->link_specific.ieee802_15_4.key_id_mode = B_SECURITY_KEY_ID_MODE_DEFAULT;
@ -658,7 +658,7 @@ buffer_t * lowpan_adaptation_data_process_tx_preprocess(protocol_interface_info_
return buf;
tx_error_handler:
tx_error_handler:
if (neigh_entry_ptr && neigh_entry_ptr->nud_active) {
mac_neighbor_info(cur)->active_nud_process--;
neigh_entry_ptr->nud_active = false;
@ -761,7 +761,7 @@ static bool lowpan_adaptation_indirect_cache_trigger(protocol_interface_info_ent
return lowpan_adaptation_indirect_cache_sanity_check(cur, interface_ptr);
}
static fragmenter_tx_entry_t* lowpan_adaptation_indirect_mac_data_request_active(fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr)
static fragmenter_tx_entry_t *lowpan_adaptation_indirect_mac_data_request_active(fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr)
{
ns_list_foreach(fragmenter_tx_entry_t, fragmenter_tx_entry, &interface_ptr->indirect_tx_queue) {
if (fragmenter_tx_entry->indirect_data_cached == false) {
@ -774,7 +774,7 @@ static fragmenter_tx_entry_t* lowpan_adaptation_indirect_mac_data_request_active
return NULL;
}
static fragmenter_tx_entry_t* lowpan_adaptation_indirect_first_cached_request_get(fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr)
static fragmenter_tx_entry_t *lowpan_adaptation_indirect_first_cached_request_get(fragmenter_interface_t *interface_ptr, fragmenter_tx_entry_t *tx_ptr)
{
ns_list_foreach(fragmenter_tx_entry_t, fragmenter_tx_entry, &interface_ptr->indirect_tx_queue) {
if (fragmenter_tx_entry->indirect_data_cached == true) {
@ -909,7 +909,7 @@ int8_t lowpan_adaptation_interface_tx(protocol_interface_info_entry_t *cur, buff
if (fragmented_needed) {
//Fragmentation init
if (lowpan_message_fragmentation_init(buf, tx_ptr, cur, interface_ptr) ) {
if (lowpan_message_fragmentation_init(buf, tx_ptr, cur, interface_ptr)) {
tr_error("Fragment init fail");
if (indirect) {
ns_dyn_mem_free(tx_ptr->fragmenter_buf);
@ -1040,7 +1040,7 @@ static void lowpan_adaptation_data_process_clean(fragmenter_interface_t *interfa
int8_t lowpan_adaptation_interface_tx_confirm(protocol_interface_info_entry_t *cur, const mcps_data_conf_t *confirm)
{
if( !cur || !confirm ){
if (!cur || !confirm) {
return -1;
}
@ -1054,10 +1054,10 @@ int8_t lowpan_adaptation_interface_tx_confirm(protocol_interface_info_entry_t *c
bool active_direct_confirm;
bool is_unicast = true;
if (lowpan_active_tx_handle_verify(confirm->msduHandle,interface_ptr->active_unicast_tx_buf.buf)) {
if (lowpan_active_tx_handle_verify(confirm->msduHandle, interface_ptr->active_unicast_tx_buf.buf)) {
active_direct_confirm = true;
tx_ptr = &interface_ptr->active_unicast_tx_buf;
} else if (lowpan_active_tx_handle_verify(confirm->msduHandle,interface_ptr->active_broadcast_tx_buf.buf)) {
} else if (lowpan_active_tx_handle_verify(confirm->msduHandle, interface_ptr->active_broadcast_tx_buf.buf)) {
active_direct_confirm = true;
tx_ptr = &interface_ptr->active_broadcast_tx_buf;
is_unicast = false;
@ -1076,8 +1076,7 @@ int8_t lowpan_adaptation_interface_tx_confirm(protocol_interface_info_entry_t *c
//Indirect data expiration
if (confirm->status == MLME_TRANSACTION_EXPIRED && !active_direct_confirm) {
if (buf->link_specific.ieee802_15_4.indirectTTL > 7000)
{
if (buf->link_specific.ieee802_15_4.indirectTTL > 7000) {
buf->link_specific.ieee802_15_4.indirectTTL -= 7000;
//Push Back to MAC
lowpan_data_request_to_mac(cur, buf, tx_ptr, interface_ptr);
@ -1130,9 +1129,9 @@ int8_t lowpan_adaptation_interface_tx_confirm(protocol_interface_info_entry_t *c
default:
tr_error("MCPS Data fail by status %u", confirm->status);
if (buf->dst_sa.addr_type == ADDR_802_15_4_SHORT) {
tr_info("Dest addr: %x", common_read_16_bit(buf->dst_sa.address+2));
tr_info("Dest addr: %x", common_read_16_bit(buf->dst_sa.address + 2));
} else if (buf->dst_sa.addr_type == ADDR_802_15_4_LONG) {
tr_info("Dest addr: %s", trace_array(buf->dst_sa.address+2, 8));
tr_info("Dest addr: %s", trace_array(buf->dst_sa.address + 2, 8));
}
#ifdef HAVE_RPL
@ -1173,7 +1172,7 @@ static bool mac_data_is_broadcast_addr(const sockaddr_t *addr)
static bool mcps_data_indication_neighbor_validate(protocol_interface_info_entry_t *cur, const sockaddr_t *addr)
{
if (thread_info(cur) || ws_info(cur) || (cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_MLE)) {
mac_neighbor_table_entry_t * neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr->address + 2, addr->addr_type);
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr->address + 2, addr->addr_type);
if (neighbor && (neighbor->connected_device || neighbor->trusted_device)) {
return true;
}
@ -1337,7 +1336,7 @@ int8_t lowpan_adaptation_indirect_free_messages_from_queues_by_address(struct pr
{
fragmenter_interface_t *interface_ptr = lowpan_adaptation_interface_discover(cur->id);
if (!interface_ptr ) {
if (!interface_ptr) {
return -1;
}

View File

@ -39,7 +39,7 @@ int8_t lowpan_adaptation_interface_mpx_register(int8_t interface_id, struct mpx_
/**
* \brief call this before normatl TX. This function prepare buffer link spesific metadata and verify packet destination
*/
struct buffer * lowpan_adaptation_data_process_tx_preprocess(struct protocol_interface_info_entry *cur, struct buffer *buf);
struct buffer *lowpan_adaptation_data_process_tx_preprocess(struct protocol_interface_info_entry *cur, struct buffer *buf);
int8_t lowpan_adaptation_interface_tx(struct protocol_interface_info_entry *cur, struct buffer *buf);

View File

@ -32,21 +32,21 @@ struct ws_pan_information_s;
struct ws_neighbor_class_s;
typedef struct parent_info_s {
uint16_t pan_id; /**< PAN ID */
uint8_t addr[8]; /**< address */
uint8_t link_quality; /**< LQI value measured during reception of the MPDU */
int8_t signal_dbm; /**< This extension for normal IEEE 802.15.4 Data indication */
ws_pan_information_t pan_information;
ws_utt_ie_t ws_utt;
ws_us_ie_t ws_us;
uint32_t timestamp; /**< Timestamp when packet was received */
}parent_info_t;
uint16_t pan_id; /**< PAN ID */
uint8_t addr[8]; /**< address */
uint8_t link_quality; /**< LQI value measured during reception of the MPDU */
int8_t signal_dbm; /**< This extension for normal IEEE 802.15.4 Data indication */
ws_pan_information_t pan_information;
ws_utt_ie_t ws_utt;
ws_us_ie_t ws_us;
uint32_t timestamp; /**< Timestamp when packet was received */
} parent_info_t;
typedef struct ws_nud_table_entry {
void *neighbor_info;
uint16_t timer; /*!< Timer which resolution is 100ms*/
unsigned retry_count:2;
bool wait_response:1; /*!< True when NS is sended and wait NA, False when random timer is active*/
unsigned retry_count: 2;
bool wait_response: 1; /*!< True when NS is sended and wait NA, False when random timer is active*/
bool nud_process;
ns_list_link_t link;
} ws_nud_table_entry_t;
@ -68,11 +68,11 @@ typedef struct ws_info_s {
uint32_t pan_version_timeout_timer; /**< routers will fallback to previous state after this */
uint8_t gtkhash[32];
bool address_registration_event_active : 1;
bool configuration_learned:1;
bool trickle_pas_running:1;
bool trickle_pa_running:1;
bool trickle_pcs_running:1;
bool trickle_pc_running:1;
bool configuration_learned: 1;
bool trickle_pas_running: 1;
bool trickle_pa_running: 1;
bool trickle_pcs_running: 1;
bool trickle_pc_running: 1;
// default fhss parameters for this device
uint8_t fhss_uc_dwell_interval;
uint8_t fhss_bc_dwell_interval;

View File

@ -58,9 +58,9 @@ typedef struct ws_pan_information_s {
uint16_t pan_size; /**< Number devices connected to Border Router. */
uint16_t routing_cost; /**< ETX to border Router. */
uint16_t pan_version; /**< Pan configuration version will be updatd by Border router at PAN. */
bool use_parent_bs:1; /**< 1 for force to follow parent broadcast schedule. 0 node may define own schedule. */
bool rpl_routing_method:1; /**< 1 when RPL routing is selected and 0 when L2 routing. */
unsigned version:3; /**< Pan version support. */
bool use_parent_bs: 1; /**< 1 for force to follow parent broadcast schedule. 0 node may define own schedule. */
bool rpl_routing_method: 1; /**< 1 when RPL routing is selected and 0 when L2 routing. */
unsigned version: 3; /**< Pan version support. */
} ws_pan_information_t;
/**
@ -117,7 +117,7 @@ typedef struct ws_channel_plan_zero {
*/
typedef struct ws_channel_plan_one {
uint_fast24_t ch0;
unsigned channel_spacing:4;
unsigned channel_spacing: 4;
uint16_t number_of_channel;
} ws_channel_plan_one_t;
@ -143,9 +143,9 @@ typedef struct ws_us_ie {
uint8_t dwell_interval;
uint8_t clock_drift;
uint8_t timing_accurancy;
unsigned channel_plan:3;
unsigned channel_function:3;
unsigned excluded_channel_ctrl:2;
unsigned channel_plan: 3;
unsigned channel_function: 3;
unsigned excluded_channel_ctrl: 2;
union {
ws_channel_plan_zero_t zero;
ws_channel_plan_one_t one;
@ -165,9 +165,9 @@ typedef struct ws_bs_ie {
uint8_t dwell_interval;
uint8_t clock_drift;
uint8_t timing_accurancy;
unsigned channel_plan:3;
unsigned channel_function:3;
unsigned excluded_channel_ctrl:2;
unsigned channel_plan: 3;
unsigned channel_function: 3;
unsigned excluded_channel_ctrl: 2;
union {
ws_channel_plan_zero_t zero;
ws_channel_plan_one_t one;

View File

@ -28,9 +28,9 @@ typedef struct ws_neighbor_class_entry {
uint16_t rsl_in; /*!< RSL EWMA heard from neighbour*/
uint16_t rsl_out; /*!< RSL EWMA heard by neighbour*/
uint16_t routing_cost; /*!< ETX to border Router. */
bool candidate_parent:1;
bool broadcast_timing_info_stored:1;
bool broadcast_shedule_info_stored:1;
bool candidate_parent: 1;
bool broadcast_timing_info_stored: 1;
bool broadcast_shedule_info_stored: 1;
} ws_neighbor_class_entry_t;
/**
@ -71,7 +71,7 @@ void ws_neighbor_class_dealloc(ws_neighbor_class_t *class_data);
* \return Pointer to neighbor hopping info
*
*/
ws_neighbor_class_entry_t * ws_neighbor_class_entry_get(ws_neighbor_class_t *class_data, uint8_t attribute_index);
ws_neighbor_class_entry_t *ws_neighbor_class_entry_get(ws_neighbor_class_t *class_data, uint8_t attribute_index);
/**
* ws_neighbor_class_entry_t a function for search hopping info for giving neighbor attribute index

View File

@ -103,8 +103,7 @@ void nd_border_router_setup_refresh(nwk_interface_id id, bool fresh_abro)
return;
} else if (cur_interface->border_router_setup == 0) {
return;
}
else if (!cur_interface->border_router_setup->nd_nwk) {
} else if (!cur_interface->border_router_setup->nd_nwk) {
return;
} else if (!cur_interface->border_router_setup->nd_border_router_configure) {
return;
@ -499,9 +498,9 @@ void border_router_start(protocol_interface_info_entry_t *cur, bool warm_link_re
start_req.BeaconOrder = 0x0f;
start_req.SuperframeOrder = 0x0f;
start_req.PANCoordinator = 1;
if( cur->mac_api ){
if (cur->mac_api) {
protocol_timer_start(PROTOCOL_TIMER_BOOTSTRAP_TIM, bootstrap_timer_handle, BOOTSTRAP_START_TIMEOUT);
cur->mac_api->mlme_req(cur->mac_api, MLME_START, (void*)&start_req);
cur->mac_api->mlme_req(cur->mac_api, MLME_START, (void *)&start_req);
}
if (warm_link_restart) {
return;
@ -539,8 +538,8 @@ void border_router_start(protocol_interface_info_entry_t *cur, bool warm_link_re
static int arm_mac_channel_list_analyze(protocol_interface_info_entry_t *cur)
{
int number_of_channels = 0;
for (int i=0; i<8; i++) {
for (int j=0; j<4; j++) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 4; j++) {
number_of_channels += common_count_bits((uint8_t)(cur->mac_parameters->mac_channel_list.channel_mask[i] >> (j * 8)));
}
}
@ -780,14 +779,15 @@ int8_t arm_nwk_6lowpan_borderrouter_init(protocol_interface_info_entry_t *cur)
#else
int8_t arm_nwk_6lowpan_border_router_init(int8_t interface_id, const border_router_setup_s *border_router_setup_ptr) {
int8_t arm_nwk_6lowpan_border_router_init(int8_t interface_id, const border_router_setup_s *border_router_setup_ptr)
{
(void) interface_id;
(void) border_router_setup_ptr;
return -3;
}
int8_t arm_nwk_6lowpan_border_router_context_parameter_update(int8_t interface_id, uint8_t c_id,
uint8_t compress_mode, uint16_t ttl)
uint8_t compress_mode, uint16_t ttl)
{
(void) interface_id;
(void) c_id;
@ -809,13 +809,15 @@ int8_t arm_nwk_6lowpan_border_router_configure_push(int8_t interface_id)
return -1;
}
int8_t arm_nwk_6lowpan_border_router_nd_context_load(int8_t interface_id, uint8_t *contex_data) {
int8_t arm_nwk_6lowpan_border_router_nd_context_load(int8_t interface_id, uint8_t *contex_data)
{
(void) interface_id;
(void) contex_data;
return -1;
}
int8_t arm_nwk_6lowpan_border_router_context_update(int8_t interface_id, uint8_t c_id_flags, uint8_t context_len, uint16_t ttl, const uint8_t *context_ptr) {
int8_t arm_nwk_6lowpan_border_router_context_update(int8_t interface_id, uint8_t c_id_flags, uint8_t context_len, uint16_t ttl, const uint8_t *context_ptr)
{
(void) interface_id;
(void) c_id_flags;
(void) context_len;
@ -824,7 +826,8 @@ int8_t arm_nwk_6lowpan_border_router_context_update(int8_t interface_id, uint8_t
return -1;
}
int8_t arm_nwk_6lowpan_border_route_nd_default_prefix_timeout_set(int8_t interface_id, uint32_t time) {
int8_t arm_nwk_6lowpan_border_route_nd_default_prefix_timeout_set(int8_t interface_id, uint32_t time)
{
(void) interface_id;
(void) time;
return -1;

View File

@ -604,7 +604,7 @@ if_address_entry_t *icmpv6_slaac_address_add(protocol_interface_info_entry_t *cu
case SLAAC_IID_OPAQUE:
addr_generate_opaque_iid(cur, ipv6_address);
break;
case SLAAC_IID_6LOWPAN_SHORT:
case SLAAC_IID_6LOWPAN_SHORT:
if (cur->nwk_id != IF_6LoWPAN || !cur->mac_parameters) {
return NULL;
}
@ -850,7 +850,7 @@ static buffer_t *icmpv6_ra_handler(buffer_t *buf)
} else if (type == ICMPV6_OPT_6LOWPAN_CONTEXT) {
nd_ra_process_lowpan_context_option(cur, dptr - 2);
}
next_option:
next_option:
//UPdate length and
data_len -= length;
dptr += length - 2;
@ -1084,7 +1084,7 @@ buffer_t *icmpv6_up(buffer_t *buf)
case ICMPV6_TYPE_INFO_ECHO_REPLY:
ipv6_neighbour_reachability_confirmation(buf->src_sa.address, buf->interface->id);
/* fall through */
/* fall through */
case ICMPV6_TYPE_ERROR_DESTINATION_UNREACH:
#ifdef HAVE_RPL_ROOT
@ -1092,7 +1092,7 @@ buffer_t *icmpv6_up(buffer_t *buf)
buf = rpl_control_source_route_error_handler(buf, cur);
}
#endif
/* no break */
/* no break */
default:
if (buf) {

View File

@ -131,7 +131,7 @@ buffer_routing_info_t *ipv6_buffer_route_to(buffer_t *buf, const uint8_t *next_h
if (next_hop && next_if) {
if (interface_specific && next_if != buf->interface) {
tr_err("Next hop interface mismatch %s%%%d vs %s%%%d", trace_ipv6(buf->dst_sa.address), buf->interface->id,
trace_ipv6(next_hop), next_if->id);
trace_ipv6(next_hop), next_if->id);
}
memcpy(route->route_info.next_hop_addr, next_hop, 16);
route->route_info.interface_id = next_if->id;
@ -159,7 +159,7 @@ buffer_routing_info_t *ipv6_buffer_route_to(buffer_t *buf, const uint8_t *next_h
memcpy(route->route_info.next_hop_addr, next_hop ? next_hop : buf->dst_sa.address, 16);
route->route_info.pmtu = 0xFFFF;
route->route_info.source = ROUTE_MULTICAST;
} else /* unicast, normal */ {
} else { /* unicast, normal */
ipv6_route_predicate_fn_t *predicate = NULL;
#ifdef HAVE_RPL
@ -194,8 +194,8 @@ buffer_routing_info_t *ipv6_buffer_route_to(buffer_t *buf, const uint8_t *next_h
#ifdef HAVE_MPL
if (outgoing_if->mpl_seed && buf->options.mpl_permitted &&
addr_is_ipv6_multicast(buf->dst_sa.address) &&
addr_ipv6_multicast_scope(buf->dst_sa.address) >= IPV6_SCOPE_REALM_LOCAL) {
addr_is_ipv6_multicast(buf->dst_sa.address) &&
addr_ipv6_multicast_scope(buf->dst_sa.address) >= IPV6_SCOPE_REALM_LOCAL) {
/* Special handling for MPL. Once we have decided we're sending to a
* multicast next hop for a greater-than-realm-local destination,
* if we're functioning as an MPL seed on that interface, we turn this
@ -639,7 +639,7 @@ buffer_t *ipv6_forwarding_down(buffer_t *buf)
/* Hop Limit copied from inner packet (maybe already decremented) */
/* ECN copied from inner packet (RFC 6040 normal mode) */
#ifdef RFC6040_COMPATIBILITY_MODE
buf->options.traffic_class &=~ IP_TCLASS_ECN_MASK;
buf->options.traffic_class &= ~ IP_TCLASS_ECN_MASK;
#endif
/* DSCP copied from inner packet */
buf->options.type = IPV6_NH_IPV6;
@ -836,11 +836,11 @@ static buffer_t *ipv6_handle_options(buffer_t *buf, protocol_interface_info_entr
return icmpv6_error(buf, NULL, ICMPV6_TYPE_ERROR_PARAMETER_PROBLEM, ICMPV6_CODE_PARAM_PRB_UNREC_IPV6_OPT, (opt - 2) - buffer_data_pointer(buf));
}
/* falling to */
drop:
drop:
protocol_stats_update(STATS_IP_RX_DROP, 1);
return buffer_free(buf);
len_err:
len_err:
return icmpv6_error(buf, cur, ICMPV6_TYPE_ERROR_PARAMETER_PROBLEM, ICMPV6_CODE_PARAM_PRB_HDR_ERR, (opt - 1) - buffer_data_pointer(buf));
}
opt += optlen;
@ -897,7 +897,7 @@ static buffer_t *ipv6_consider_forwarding_unicast_packet(buffer_t *buf, protocol
{
/* Security checks needed here before forwarding */
if (buf->options.ll_security_bypass_rx) {
tr_warn("IP Forward: Security check fail dst %s",trace_ipv6(buf->dst_sa.address));
tr_warn("IP Forward: Security check fail dst %s", trace_ipv6(buf->dst_sa.address));
protocol_stats_update(STATS_IP_RX_DROP, 1);
return buffer_free(buf);
}
@ -948,7 +948,7 @@ static buffer_t *ipv6_consider_forwarding_unicast_packet(buffer_t *buf, protocol
#ifdef HAVE_RPL
/* We must not let RPL-bearing packets out of or into a RPL domain */
if (buf->options.ip_extflags & (IPEXT_HBH_RPL|IPEXT_SRH_RPL)) {
if (buf->options.ip_extflags & (IPEXT_HBH_RPL | IPEXT_SRH_RPL)) {
if (out_interface->rpl_domain != cur->rpl_domain || !rpl_data_is_rpl_route(routing->route_info.source)) {
return icmpv6_error(buf, cur, ICMPV6_TYPE_ERROR_DESTINATION_UNREACH, ICMPV6_CODE_DST_UNREACH_ADM_PROHIB, 0);
}
@ -1118,7 +1118,7 @@ static buffer_t *ipv6_consider_forwarding_multicast_packet(buffer_t *buf, protoc
interface->zone_index[group_scope] == cur->zone_index[group_scope] &&
interface->zone_index[src_scope] == cur->zone_index[src_scope] &&
(group_scope >= interface->ip_mcast_fwd_for_scope ||
addr_multicast_fwd_check(interface, buf->dst_sa.address))) {
addr_multicast_fwd_check(interface, buf->dst_sa.address))) {
/* This interface seems to want a packet. Couple more checks first */
if (buffer_data_length(buf) > interface->ipv6_neighbour_cache.link_mtu) {
@ -1195,7 +1195,7 @@ buffer_t *ipv6_forwarding_up(buffer_t *buf)
// we won't re-parse them, and expect the metadata (from the first fragment)
// to survive reassembly.
frag_offset = buf->offset;
buf->options.ip_extflags &=~ IPEXT_FRAGMENT;
buf->options.ip_extflags &= ~ IPEXT_FRAGMENT;
tr_debug("Processing fragment from %d", frag_offset);
} else {
// Clear all info - extension header parsers will set
@ -1401,7 +1401,7 @@ buffer_t *ipv6_forwarding_up(buffer_t *buf)
* a RPL or MPL HbH option header, or RPL SRH header. Gives security, as
* long as border router doesn't forward such packets into RPL/MPL domain.
*/
if (!(buf->options.ip_extflags & (IPEXT_HBH_RPL|IPEXT_SRH_RPL|IPEXT_HBH_MPL))) {
if (!(buf->options.ip_extflags & (IPEXT_HBH_RPL | IPEXT_SRH_RPL | IPEXT_HBH_MPL))) {
goto bad_nh;
}
buffer_note_predecessor(buf, &ll_src);
@ -1419,8 +1419,8 @@ buffer_t *ipv6_forwarding_up(buffer_t *buf)
buf->info = (buffer_info_t)(B_DIR_UP | B_TO_APP | B_FROM_IPV6_FWD);
goto upper_layer;
}
bad_nh:
return icmpv6_error(buf, cur, ICMPV6_TYPE_ERROR_PARAMETER_PROBLEM, ICMPV6_CODE_PARAM_PRB_UNREC_NEXT_HDR, nh_ptr - buffer_data_pointer(buf));
bad_nh:
return icmpv6_error(buf, cur, ICMPV6_TYPE_ERROR_PARAMETER_PROBLEM, ICMPV6_CODE_PARAM_PRB_UNREC_NEXT_HDR, nh_ptr - buffer_data_pointer(buf));
}
if (hdrlen == 0) {
/* Something went wrong in an extension header - it will have freed buf or turned it into an ICMP error */

View File

@ -31,7 +31,7 @@ bool ipv6_flow_auto_label = true;
static inline uint_fast24_t fold_32_to_flow(uint32_t val32)
{
uint_fast24_t flow = (uint_fast24_t) ((val32 ^ (val32 >> 20)) & 0xFFFFF);
uint_fast24_t flow = (uint_fast24_t)((val32 ^ (val32 >> 20)) & 0xFFFFF);
if (flow == 0) {
flow = 1;
}

View File

@ -125,9 +125,9 @@ static void free_datagram(ip_fragmented_datagram_t *dgram)
*/
uint16_t ipv6_frag_set_mru(uint16_t frag_mru)
{
frag_mru = (frag_mru + 7) &~ UINT16_C(7);
frag_mru = (frag_mru + 7) & ~ UINT16_C(7);
if (frag_mru < IPV6_MIN_FRAG_MRU) {
frag_mru = (IPV6_MIN_FRAG_MRU + 7) &~ UINT16_C(7);
frag_mru = (IPV6_MIN_FRAG_MRU + 7) & ~ UINT16_C(7);
}
if (ipv6_frag_mru != frag_mru) {
/* I don't want to worry about the complications of changing MRU while

View File

@ -58,7 +58,7 @@ void ipv6_interface_resolve_send_ns(ipv6_neighbour_cache_t *cache, ipv6_neighbou
#ifdef HAVE_IPV6_ND
tr_debug("Sending %s NS for: %s",
(unicast ? "unicast" : "multicast"), trace_ipv6(entry->ip_address));
(unicast ? "unicast" : "multicast"), trace_ipv6(entry->ip_address));
buffer_t *prompting_packet = ns_list_get_first(&entry->queue);
buffer_t *buf = icmpv6_build_ns(cur_interface, entry->ip_address,

View File

@ -41,8 +41,7 @@
* only if there is no more data in queue (because the state is entered
* while queue not empty).
*/
static const uint8_t state_flag[TCP_STATES] =
{
static const uint8_t state_flag[TCP_STATES] = {
[TCP_STATE_CLOSED] = TCP_FLAG_RST | TCP_FLAG_ACK,
[TCP_STATE_SYN_SENT] = TCP_FLAG_SYN,
[TCP_STATE_SYN_RECEIVED] = TCP_FLAG_SYN | TCP_FLAG_ACK,
@ -60,22 +59,25 @@ static uint8_t rx_drops[TCP_STATES];
static uint8_t tx_drops[TCP_STATES];
/*Test - functions*/
int8_t tcp_test_drop_tx(int state, uint8_t count) {
int8_t tcp_test_drop_tx(int state, uint8_t count)
{
tx_drops[state] = count;
return 0;
}
int8_t tcp_test_drop_rx(int state, uint8_t count) {
int8_t tcp_test_drop_rx(int state, uint8_t count)
{
rx_drops[state] = count;
return 0;
}
void tcp_test_drop_reset() {
void tcp_test_drop_reset()
{
memset(rx_drops, 0, sizeof rx_drops);
memset(tx_drops, 0, sizeof tx_drops);
memset(rx_drops, 0, sizeof rx_drops);
memset(tx_drops, 0, sizeof tx_drops);
}
#endif
@ -403,7 +405,8 @@ static buffer_t *tcp_build_reset_packet(const sockaddr_t *dst_addr, const sockad
return (buf);
}
static void tcp_session_send_reset_to_abort_connection(tcp_session_t *tcp_info) {
static void tcp_session_send_reset_to_abort_connection(tcp_session_t *tcp_info)
{
sockaddr_t dst, src;
memcpy(&dst.address, tcp_info->inet_pcb->remote_address, 16);
@ -559,7 +562,7 @@ tcp_error tcp_session_abort(tcp_session_t *tcp_session)
case TCP_STATE_FIN_WAIT_2:
case TCP_STATE_CLOSE_WAIT:
tcp_session_send_reset_to_abort_connection(tcp_session);
/* fall through */
/* fall through */
case TCP_STATE_LISTEN:
case TCP_STATE_SYN_SENT:
tcp_session_delete_with_error(tcp_session, SOCKET_CONNECTION_RESET);
@ -604,7 +607,7 @@ static void tcp_segment_start(tcp_session_t *tcp_info, bool timeout)
if (!tx_data) {
// Should only be called with no data if needing to send a SYN or FIN
if ((state_flag[tcp_info->state] & TCP_FLAG_SYN) ||
((state_flag[tcp_info->state] & TCP_FLAG_FIN) && !tcp_info->sent_fin)) {
((state_flag[tcp_info->state] & TCP_FLAG_FIN) && !tcp_info->sent_fin)) {
data_length = 0;
tcp_info->persist = false;
goto build;
@ -708,7 +711,7 @@ static uint16_t tcp_compute_window_incr(tcp_session_t *tcp_info)
if (window > 0xffff) {
window = 0xffff;
}
if (window < (int32_t) (tcp_info->receive_adv - tcp_info->receive_next)) {
if (window < (int32_t)(tcp_info->receive_adv - tcp_info->receive_next)) {
// Don't move left
return 0;
}
@ -717,7 +720,7 @@ static uint16_t tcp_compute_window_incr(tcp_session_t *tcp_info)
uint16_t incr = tcp_info->receive_next + window - tcp_info->receive_adv;
if (incr > 0) {
if (incr < tcp_info->inet_pcb->socket->rcvq.data_byte_limit / 2 &&
incr < tcp_info->send_mss_eff) {
incr < tcp_info->send_mss_eff) {
incr = 0;
} else {
tcp_info->receive_adv += incr;
@ -865,7 +868,7 @@ static void tcp_ack_segment(uint32_t ack, tcp_session_t *tcp_info)
}
if (tcp_info->srtt8 == INT16_MAX) {
tcp_info->srtt8 = R << 3; // srtt := R
tcp_info->srttvar4 = R << (2-1); // rttvar := R / 2
tcp_info->srttvar4 = R << (2 - 1); // rttvar := R / 2
} else {
/* 1/8 gain and scaling on smoothed RTT measurement */
int16_t R_diff = R - (tcp_info->srtt8 >> 3);
@ -889,7 +892,7 @@ static void tcp_ack_segment(uint32_t ack, tcp_session_t *tcp_info)
tcp_info->timer = 0;
if (remaining_bytes ||
((state_flag[tcp_info->state] & TCP_FLAG_FIN) && !tcp_info->sent_fin)) {
((state_flag[tcp_info->state] & TCP_FLAG_FIN) && !tcp_info->sent_fin)) {
tcp_segment_start(tcp_info, false);
} else {
tcp_info->busy = false;
@ -977,11 +980,11 @@ static socket_t *tcp_find_listen_socket(const uint8_t addr[static 16], uint16_t
FUNC_ENTRY_TRACE("tcp_find_listen_socket() %d", port);
ns_list_foreach(socket_t, so, &socket_list) {
if ((so->flags & SOCKET_LISTEN_STATE) &&
socket_is_ipv6(so) &&
so->inet_pcb->local_port == port &&
(addr_ipv6_equal(so->inet_pcb->local_address, ns_in6addr_any) ||
addr_ipv6_equal(so->inet_pcb->local_address, addr))
) {
socket_is_ipv6(so) &&
so->inet_pcb->local_port == port &&
(addr_ipv6_equal(so->inet_pcb->local_address, ns_in6addr_any) ||
addr_ipv6_equal(so->inet_pcb->local_address, addr))
) {
return so;
}
}
@ -1023,7 +1026,7 @@ static void tcp_build(buffer_t *buf, tcp_session_t *tcp_info)
if (!tcp_info) {
tr_error("DW No Session: dst: %s, src port: %d, dst port: %d", tr_ipv6(buf->dst_sa.address), buf->src_sa.port,
buf->dst_sa.port);
buf->dst_sa.port);
buffer_free(buf);
return;
}
@ -1246,7 +1249,7 @@ buffer_t *tcp_up(buffer_t *buf)
}
if (len > options_len) {
bad_opts:
bad_opts:
malformed_options = true;
tr_err("Malformed options");
break;
@ -1255,7 +1258,7 @@ buffer_t *tcp_up(buffer_t *buf)
if (type == TCP_OPTION_MSS && len == 4) {
mss_option = common_read_16_bit(ptr + 2);
tr_debug("MSS %"PRIu16, mss_option);
} else if (type != TCP_OPTION_NOP){
} else if (type != TCP_OPTION_NOP) {
tr_info("Unsupported option %d", type);
}
ptr += len;
@ -1268,7 +1271,7 @@ buffer_t *tcp_up(buffer_t *buf)
inet_pcb = so ? so->inet_pcb : NULL;
tcp_info = inet_pcb ? inet_pcb->session : NULL;
// if not found, and it's a SYN, look for a listening socket
if (tcp_info == NULL && !malformed_options) find_listen: { // Can jump here from TIME-WAIT, with tcp_info set
if (tcp_info == NULL && !malformed_options) find_listen: { // Can jump here from TIME-WAIT, with tcp_info set
socket_t *listen_socket = tcp_find_listen_socket(buf->dst_sa.address, buf->dst_sa.port);
if (listen_socket) {
tr_debug("UP: Packet for LISTEN socket %d", listen_socket->id);
@ -1363,7 +1366,7 @@ buffer_t *tcp_up(buffer_t *buf)
return buffer_free(buf);
}
if (!(flags & TCP_FLAG_ACK)) {
return tcp_reset_response(tcp_info, SOCKET_CONNECTION_RESET, buf, 0, seq_no + seg_len, TCP_FLAG_RST|TCP_FLAG_ACK);
return tcp_reset_response(tcp_info, SOCKET_CONNECTION_RESET, buf, 0, seq_no + seg_len, TCP_FLAG_RST | TCP_FLAG_ACK);
}
return tcp_reset_response(tcp_info, SOCKET_CONNECTION_RESET, buf, ack_no, 0, TCP_FLAG_RST);
}
@ -1424,7 +1427,7 @@ buffer_t *tcp_up(buffer_t *buf)
// Early escape from TIME-WAIT: processing of SYN segments as per RFC 6191
// (simple non-timestamp case)
if ((flags & (TCP_FLAG_SYN|TCP_FLAG_FIN|TCP_FLAG_ACK|TCP_FLAG_RST)) == TCP_FLAG_SYN && tcp_info->state == TCP_STATE_TIME_WAIT) {
if ((flags & (TCP_FLAG_SYN | TCP_FLAG_FIN | TCP_FLAG_ACK | TCP_FLAG_RST)) == TCP_FLAG_SYN && tcp_info->state == TCP_STATE_TIME_WAIT) {
if (tcp_seq_ge(seq_no, tcp_info->receive_next)) {
goto find_listen;
} else {
@ -1437,7 +1440,7 @@ buffer_t *tcp_up(buffer_t *buf)
if (receive_window < 0) {
receive_window = 0;
}
if (receive_window < (int32_t) (tcp_info->receive_adv - tcp_info->receive_next)) {
if (receive_window < (int32_t)(tcp_info->receive_adv - tcp_info->receive_next)) {
receive_window = tcp_info->receive_adv - tcp_info->receive_next;
}
@ -1527,7 +1530,7 @@ buffer_t *tcp_up(buffer_t *buf)
return buffer_free(buf);
}
if (!(flags & TCP_FLAG_ACK)) {
return tcp_reset_response(tcp_info, SOCKET_CONNECTION_RESET, buf, 0, seq_no + seg_len, TCP_FLAG_RST|TCP_FLAG_ACK);
return tcp_reset_response(tcp_info, SOCKET_CONNECTION_RESET, buf, 0, seq_no + seg_len, TCP_FLAG_RST | TCP_FLAG_ACK);
}
return tcp_reset_response(tcp_info, SOCKET_CONNECTION_RESET, buf, ack_no, 0, TCP_FLAG_RST);
}
@ -1558,7 +1561,7 @@ buffer_t *tcp_up(buffer_t *buf)
buf = tcp_ack_buffer(tcp_info, 0);
tcp_build(buf, tcp_info);
return NULL;
} else /* SND.UNA <= SEG.ACK <= SND.NXT */ {
} else { /* SND.UNA <= SEG.ACK <= SND.NXT */
/* Update window, if packet not older than last window information */
if (tcp_seq_gt(seq_no, tcp_info->send_wl1) ||
(seq_no == tcp_info->send_wl1 && tcp_seq_ge(ack_no, tcp_info->send_wl2))) {
@ -1655,7 +1658,7 @@ syn_sent_to_established:
//tr_debug("data up");
sockbuf_append_and_compress(&so->rcvq, buf);
buf = NULL;
if ((flags & (TCP_FLAG_FIN|TCP_FLAG_PSH)) || sockbuf_space(&so->rcvq) <= (int32_t) (so->rcvq.data_byte_limit / 2)) {
if ((flags & (TCP_FLAG_FIN | TCP_FLAG_PSH)) || sockbuf_space(&so->rcvq) <= (int32_t)(so->rcvq.data_byte_limit / 2)) {
socket_data_queued_event_push(so);
}
}
@ -1715,7 +1718,7 @@ const char *tcp_state_name(const tcp_session_t *tcp_info)
{
switch (tcp_info->state) {
case TCP_STATE_LISTEN:
return "LISTEN";
return "LISTEN";
case TCP_STATE_SYN_SENT:
return "SYN-SENT";
case TCP_STATE_SYN_RECEIVED:

View File

@ -92,7 +92,7 @@ static uint8_t addr_iid_secret_key_len;
static bool addr_am_implicit_group_member(const uint8_t group[static 16])
{
static const uint8_t * const implicit_groups[] = {
static const uint8_t *const implicit_groups[] = {
ADDR_LINK_LOCAL_ALL_NODES,
ADDR_IF_LOCAL_ALL_NODES,
};
@ -283,7 +283,7 @@ bool addr_multicast_fwd_add(protocol_interface_info_entry_t *interface, const ui
}
return true;
}
entry = ns_dyn_mem_alloc(sizeof *entry);
entry = ns_dyn_mem_alloc(sizeof * entry);
if (!entry) {
return false;
}
@ -379,15 +379,25 @@ static void addr_policy_table_reset(void)
}
/* Default policy table from RFC 6724 */
addr_policy_table_add_entry(ADDR_LOOPBACK, 128, 50 , 0);
addr_policy_table_add_entry(NULL, 0, 40 , 1);
addr_policy_table_add_entry(ADDR_LOOPBACK, 128, 50, 0);
addr_policy_table_add_entry(NULL, 0, 40, 1);
addr_policy_table_add_entry(ADDR_IPV4_MAPPED_PREFIX, 96, 35, 4);
addr_policy_table_add_entry((const uint8_t[]) { 0x20, 0x02 }, 16, 30, 2);
addr_policy_table_add_entry((const uint8_t[]) { 0x20, 0x01, 0, 0 }, 32, 5, 5);
addr_policy_table_add_entry((const uint8_t[]) { 0xfc }, 7, 3, 13);
addr_policy_table_add_entry((const uint8_t[]) {
0x20, 0x02
}, 16, 30, 2);
addr_policy_table_add_entry((const uint8_t[]) {
0x20, 0x01, 0, 0
}, 32, 5, 5);
addr_policy_table_add_entry((const uint8_t[]) {
0xfc
}, 7, 3, 13);
addr_policy_table_add_entry(ADDR_IPV4_COMPATIBLE, 96, 1, 3);
addr_policy_table_add_entry((const uint8_t[]) { 0xfe, 0xc0 }, 10, 1, 11);
addr_policy_table_add_entry((const uint8_t[]) { 0x3f, 0xfe }, 16, 1, 12);
addr_policy_table_add_entry((const uint8_t[]) {
0xfe, 0xc0
}, 10, 1, 11);
addr_policy_table_add_entry((const uint8_t[]) {
0x3f, 0xfe
}, 16, 1, 12);
//addr_policy_table_print();
}
@ -726,8 +736,7 @@ const uint8_t *addr_select_with_prefix(protocol_interface_info_entry_t *cur, con
/* Rule 3: Avoid deprecated addresses */
if (SA->preferred_lifetime != 0 && SB->preferred_lifetime == 0) {
PREFER_SA;
}
else if (SB->preferred_lifetime != 0 && SA->preferred_lifetime == 0) {
} else if (SB->preferred_lifetime != 0 && SA->preferred_lifetime == 0) {
PREFER_SB;
}
@ -945,7 +954,7 @@ if_address_entry_t *addr_add(protocol_interface_info_entry_t *cur, const uint8_t
return NULL;
}
memset(entry, 0, sizeof *entry);
memset(entry, 0, sizeof * entry);
entry->cb = NULL;
memcpy(entry->address, address, 16);
entry->prefix_len = prefix_len;
@ -1200,7 +1209,7 @@ opaque_retry:
if (addr_initial_iid && !cur->dad_failures) {
// This is test implementations use only normally should not need this.
memcpy(addr + 8,addr_initial_iid,8);
memcpy(addr + 8, addr_initial_iid, 8);
return;
}
{
@ -1391,7 +1400,7 @@ int8_t addr_interface_select_source(protocol_interface_info_entry_t *cur, uint8_
#define FEA_TRACE_SUPPORT 1
#include "mbed-trace/mbed_trace.h"
#endif
char* trace_sockaddr(const sockaddr_t* addr, bool panid_prefix)
char *trace_sockaddr(const sockaddr_t *addr, bool panid_prefix)
{
uint8_t length = addr_len_from_type(addr->addr_type);
@ -1401,7 +1410,7 @@ char* trace_sockaddr(const sockaddr_t* addr, bool panid_prefix)
/* Awkward hack for 802.15.4 address types */
if (addr->addr_type == ADDR_802_15_4_SHORT ||
addr->addr_type == ADDR_802_15_4_LONG) {
addr->addr_type == ADDR_802_15_4_LONG) {
length -= (panid_prefix) ? 0 : 2;
}

View File

@ -81,7 +81,7 @@ buffer_t *buffer_get_specific(uint16_t headroom, uint16_t size, uint16_t minspac
/* Round total size up to at least be a neat multiple - allocation must
* anyway be this much aligned. */
total_size = (total_size + 3) &~ 3;
total_size = (total_size + 3) & ~ 3;
// Note - as well as this alloc+init, buffers can also be "realloced"
// in buffer_headroom()
@ -132,7 +132,7 @@ buffer_t *buffer_headroom(buffer_t *buf, uint16_t size)
if (buf->size < (curr_len + size)) {
/* This buffer isn't big enough at all - allocate a new block */
// TODO - should we be giving them extra? probably
uint16_t new_total = (curr_len + size + 3) &~ 3;
uint16_t new_total = (curr_len + size + 3) & ~ 3;
buffer_t *restrict new_buf = ns_dyn_mem_temporary_alloc(sizeof(buffer_t) + new_total);
if (new_buf) {
// Copy the buffer_t header
@ -248,9 +248,9 @@ buffer_t *buffer_turnaround(buffer_t *buf)
void buffer_note_predecessor(buffer_t *buf, const sockaddr_t *addr)
{
if (buf->options.need_predecessor && !buf->predecessor) {
buf->predecessor = ns_dyn_mem_temporary_alloc(sizeof *buf->predecessor);
buf->predecessor = ns_dyn_mem_temporary_alloc(sizeof * buf->predecessor);
if (buf->predecessor) {
memcpy(buf->predecessor, addr, sizeof *buf->predecessor);
memcpy(buf->predecessor, addr, sizeof * buf->predecessor);
}
}
}

View File

@ -93,9 +93,9 @@ typedef struct if_address_entry {
uint32_t preferred_lifetime; // seconds remaining; 0 if deprecated, 0xffffffff = infinite
uint32_t state_timer; // ticks to state change - used by DAD, then can be used by protocol
uint8_t count; // general count field - used by DAD, then can be used by protocol
bool temporary:1; // RFC 4941 temporary address
bool tentative:1; // Tentative address (Duplicate Address Detection running)
bool group_added:1; // Solicited-Node group added
bool temporary: 1; // RFC 4941 temporary address
bool tentative: 1; // Tentative address (Duplicate Address Detection running)
bool group_added: 1; // Solicited-Node group added
uint8_t addr_reg_pend; // Bitmask for pending address registrations. Based on RPL path control bits
uint8_t addr_reg_done; // Bitmask for address registration done. Based on RPL path control bits
if_address_source_t source; //
@ -109,7 +109,7 @@ typedef NS_LIST_HEAD(if_address_entry_t, link) if_address_list_t;
/* Groups we are a member of on an interface */
typedef struct if_group_entry {
uint8_t group[16];
bool mld_last_reporter:1;
bool mld_last_reporter: 1;
uint16_t mld_timer; // Or used by MLD alternative, eg Thread registration
uint16_t ref_count;
ns_list_link_t link;
@ -169,7 +169,7 @@ void addr_set_preferred_lifetime(struct protocol_interface_info_entry *interface
int_fast8_t addr_policy_table_add_entry(const uint8_t *prefix, uint8_t len, uint8_t precedence, uint8_t label);
int_fast8_t addr_policy_table_delete_entry(const uint8_t *prefix, uint8_t len);
uint8_t addr_len_from_type(addrtype_t addr_type);
char* trace_sockaddr(const sockaddr_t* addr, bool panid_prefix);
char *trace_sockaddr(const sockaddr_t *addr, bool panid_prefix);
const uint8_t *addr_select_source(struct protocol_interface_info_entry *interface, const uint8_t dest[__static 16], uint32_t addr_preferences);
const uint8_t *addr_select_with_prefix(struct protocol_interface_info_entry *cur, const uint8_t *prefix, uint8_t prefix_len, uint32_t addr_preferences);

View File

@ -120,15 +120,15 @@ typedef struct buffer_options {
bool ll_multicast_rx: 1; /*!< Was received as link-layer multicast */
bool ll_not_ours_rx: 1; /*!< Not addressed to us at link layer - snooped */
bool lowpan_mesh_rx: 1; /*!< Had a 6LoWPAN mesh header */
bool tunnelled:1; /*!< We tunnelled it as part of (RPL?) routing */
bool need_predecessor:1; /*!< Used as an indicator that predecessor address needed */
bool multicast_loop:1; /*!< We want loopback if we're a group member (TX), or this IS the loopback if RX */
bool mpl_permitted:1; /*!< MPL will be used if enabled on interface and scope >=3 */
bool tunnelled: 1; /*!< We tunnelled it as part of (RPL?) routing */
bool need_predecessor: 1; /*!< Used as an indicator that predecessor address needed */
bool multicast_loop: 1; /*!< We want loopback if we're a group member (TX), or this IS the loopback if RX */
bool mpl_permitted: 1; /*!< MPL will be used if enabled on interface and scope >=3 */
#ifndef NO_IP_FRAGMENT_TX
bool ipv6_dontfrag:1; /*!< Don't IPv6 fragment (RFC 3542) */
bool ipv6_dontfrag: 1; /*!< Don't IPv6 fragment (RFC 3542) */
#endif
#ifndef NO_IPV6_PMTUD
signed ipv6_use_min_mtu:2; /*!< Use minimum 1280-byte MTU (RFC 3542) - three settings +1, 0, -1 */
signed ipv6_use_min_mtu: 2; /*!< Use minimum 1280-byte MTU (RFC 3542) - three settings +1, 0, -1 */
#endif
uint8_t traffic_class; /*!< Traffic class */
int_least24_t flow_label; /*!< IPv6 flow label; -1 means unspecified (may auto-generate); -2 means auto-generate required */
@ -167,7 +167,7 @@ typedef enum {
B_FROM_IPV6_TXRX = 0x0090,
B_FROM_DNSSD = 0x00A0,
B_FROM_IPV6_FWD = 0x00B0,
B_FROM_LOCAL = 0x00C0,
B_FROM_LOCAL = 0x00C0,
B_FROM_MESH_ROUTING = 0x00D0,
B_FROM_APP = 0x00F0,
B_FROM_MASK = 0x00F0,
@ -212,8 +212,8 @@ typedef struct buffer {
uint16_t payload_length; /*!< Socket payload length */
uint8_t IPHC_NH;
uint8_t rpl_instance;
bool rpl_instance_known:1;
bool ip_routed_up:1;
bool rpl_instance_known: 1;
bool ip_routed_up: 1;
uint8_t rpl_flag_error;
//uint8_t bc_sending_superframe; /*FHSS uses this randomly chosen superframe to send this packet (if broadcast)*/
//uint8_t fhss_channel_retries_left;
@ -230,7 +230,7 @@ typedef struct buffer {
buffer_routing_info_t *route; /* A pointer last to try to get neat alignment for data */
void (*ack_receive_cb)(struct buffer *buffer_ptr, uint8_t status); /*!< ACK receive callback. If set, will be called when TX is done */
uint8_t buf[]; /*!< Trailing buffer data */
} buffer_t;
} buffer_t;
typedef NS_LIST_HEAD(buffer_t, link) buffer_list_t;
NS_STATIC_ASSERT(offsetof(buffer_t, link) == 0, "Some use NS_LIST_HEAD_INCOMPLETE")

Some files were not shown because too many files have changed in this diff Show More