Embed: (wiki syntax)

« Back to documentation index

mle_service_api.h File Reference

mle_service_api.h File Reference

Mle service API for multiple MLE protocol user. More...

Go to the source code of this file.

Typedefs

typedef void( mle_service_receive_cb )(int8_t interface_id, mle_message_t *mle_msg, mle_security_header_t *security_headers)
 MLE service message receiver handler call back function pointer.
typedef void( mle_service_receive_security_bypass_cb )(int8_t interface_id, mle_message_t *mle_msg)
 MLE service security bypass message receiver handler call back function pointer.
typedef uint8_t *( mle_service_key_request_by_counter_cb )(int8_t interface_id, uint8_t keyId, uint32_t keySequnce)
 MLE service security key request by 32-bit key source.
typedef uint8_t *( mle_service_security_notify_cb )(int8_t interface_id, mle_security_event_t event, uint8_t keyId)
 MLE service security event notify.
typedef bool( mle_service_message_timeout_cb )(int8_t interface_id, uint16_t msgId, bool usedAllRetries)
 MLE service message timeout call back.

Enumerations

enum  mle_security_event { MLE_SEC_MAX_FRAME_COUNTER_REACHED = 0, MLE_SEC_KEY_UPDATE_NOTIFY, MLE_SEC_UNKNOWN_KEY }

Functions

void mle_service_interface_tx_queue_clean (int8_t interface_id)
 Delete and free all activated Transaction.
int mle_service_reset_frame_counters (int8_t interfaceId)
 count all activated Transactions.
int mle_service_interface_token_bucket_settings_set (int8_t interface_id, uint8_t size, uint8_t rate, uint8_t count)
 Sets MLE token bucket settings.
uint8_t mle_service_security_next_key_id_get (int8_t interfaceId)
 GET MLE security coming key id.
uint16_t mle_service_msg_allocate (int8_t interface_id, uint16_t data_length, bool challengeAllocate, uint8_t type)
 Allocate MLE transaction buffer and set default security parameters to buffer.
int mle_service_msg_free (uint16_t msgId)
 Free message.
int mle_service_msg_update_security_params (uint16_t msgId, uint8_t security_level, uint8_t key_id_mode, uint32_t keysequence)
 Set new security level and Key id mode.
int mle_service_message_tail_get (uint16_t msgId, uint16_t tail_length)
 MLE message tail get for new payload.
uint8_t * mle_service_get_data_pointer (uint16_t msgId)
 Get MLE message data pointer for write.
uint8_t * mle_service_get_payload_start_point (uint16_t msgId)
 Get MLE message pointer to message start.
uint16_t mle_service_get_payload_length (uint16_t msgId)
 Get MLE message payload length.
int mle_service_update_length (uint16_t msgId, uint16_t tail_length)
 Set MLE message end point by new tail.
int mle_service_update_length_by_ptr (uint16_t msgId, uint8_t *data_end_ptr)
 Set MLE message end point by new data end pointer.
uint8_t * mle_service_get_msg_destination_address_pointer (uint16_t msgId)
 Get MLE message destination address pointer for write purpose.
int mle_service_set_msg_destination_address (uint16_t msgId, const uint8_t *dstAddress)
 Set MLE message destination address.
int mle_service_set_msg_panid (uint16_t msgId, uint16_t panid)
 Set Messages link PAN.
int mle_service_set_msg_timeout_parameters (uint16_t msgId, mle_message_timeout_params_t *timeout_params)
 Set messages timeout parameters.
int mle_service_set_msg_response_true (uint16_t msgId)
 Set MLE message response received state.
bool mle_service_check_msg_response (uint16_t msgId)
 Check MLE message response received state.
bool mle_service_check_msg_sent (uint16_t msgId)
 Check if message has been sent to socket.
int mle_service_set_packet_callback (uint16_t msgId, mle_service_message_timeout_cb *cb)
 MLE message timeout handler set.
int mle_service_send_message (uint16_t msgId)
 Sends MLE message.
bool mle_service_timer_tick (uint16_t ticks)
 Timer tick function.
int mle_service_reject_message_build (int8_t interfaceId, uint8_t *dstIpv6, bool force_unsecure)
 Build and send standard link reject message.
int mle_service_set_msg_token_bucket_priority (uint16_t msgId)
 Sets message a priority over token bucket restrictions.
void mle_service_set_frame_counter_check (bool value)
 Activates MLE Frame counter checking for the interface.
void mle_service_set_fragmented_msg_ll_security (bool value)
 Set 802.15.4 security option for fragmented MLE messages.
void mle_service_set_accept_invalid_frame_counter (bool value)
 Commands MLE service to accept message with invalid MLE frame counter.

Detailed Description

Mle service API for multiple MLE protocol user.

MLE service interface configuration API

  • mle_service_interface_register(), Register interface for first user service will open socket
  • mle_service_interface_unregister(), Unregister service after last user call socket will be closed
  • mle_service_interface_registeration_validate(), Validate has interface registered service already
  • mle_service_interface_receiver_handler_update(), Update registered message handler to new one
  • mle_service_interface_tx_queue_clean(), Free interface active queued messages
  • mle_service_interface_token_bucket_settings_set(), Sets token bucket settings

MLE Security configuration API

  • mle_service_security_init(), allocate security class for interface
  • mle_service_security_set_security_key(), Set security key to security class
  • mle_service_security_set_frame_counter(), Update security class frame counter
  • mle_service_security_key_trig() Indicate mle security class to switch default key

MLE Security class get API

  • mle_service_security_default_key_get(). Get default key pointer
  • mle_service_security_default_key_id_get(), Get default key id
  • mle_service_security_next_key_get(), Get secondary or pending key pointer
  • mle_service_security_next_key_id_get(), Get secondary or pending key id
  • mle_service_security_level_get(), Get configured security level

MLE message Data flow API

Messages TX API

Service Messages timeout API

Definition in file mle_service_api.h.


Typedef Documentation

typedef uint8_t*( mle_service_key_request_by_counter_cb)(int8_t interface_id, uint8_t keyId, uint32_t keySequnce)

MLE service security key request by 32-bit key source.

All service user need to register this function pointer if they support 32-bit key source.

Parameters:
interface_iddefine interface id for receiver
keyIdkey identifier
keySequnce32-bit key source

Definition at line 165 of file mle_service_api.h.

typedef bool( mle_service_message_timeout_cb)(int8_t interface_id, uint16_t msgId, bool usedAllRetries)

MLE service message timeout call back.

This function will be called when msg timeout happen

Parameters:
interface_iddefine interface id for receiver
msgIdkey identifier
usedAllRetriesfalse when
Returns:
true Continue packet retry
false Stop TX process and

Definition at line 190 of file mle_service_api.h.

typedef void( mle_service_receive_cb)(int8_t interface_id, mle_message_t *mle_msg, mle_security_header_t *security_headers)

MLE service message receiver handler call back function pointer.

All service user need to register this function pointer.

Parameters:
interface_iddefine interface id for receiver
mle_msgmle message structure
security_headersindicate messages security parameters

Definition at line 144 of file mle_service_api.h.

typedef void( mle_service_receive_security_bypass_cb)(int8_t interface_id, mle_message_t *mle_msg)

MLE service security bypass message receiver handler call back function pointer.

All service user need to register this function pointer.

Parameters:
interface_iddefine interface id for receiver
mle_msgmle message structure

Definition at line 154 of file mle_service_api.h.

typedef uint8_t*( mle_service_security_notify_cb)(int8_t interface_id, mle_security_event_t event, uint8_t keyId)

MLE service security event notify.

Parameters:
interface_iddefine interface id for receiver
event
keyIdkey identifier

Definition at line 175 of file mle_service_api.h.


Enumeration Type Documentation

Enumerator:
MLE_SEC_MAX_FRAME_COUNTER_REACHED 

MLE security counter reach max 0xffffffff value when device can't use same key anymore

MLE_SEC_KEY_UPDATE_NOTIFY 

MLE security have trigger new default key

MLE_SEC_UNKNOWN_KEY 

MLE security have detect unknown key id

Definition at line 100 of file mle_service_api.h.


Function Documentation

bool mle_service_check_msg_response ( uint16_t  msgId )

Check MLE message response received state.

Usefully function at message timeout call back to check response status

Parameters:
msgIdmessage id.
Returns:
true message has received response
false no response or unknow message id

Definition at line 167 of file mle_service_buffer.c.

bool mle_service_check_msg_sent ( uint16_t  msgId )

Check if message has been sent to socket.

Function can be used whether message has been sent to socket or has been rejected by token bucket.

Parameters:
msgIdmessage id.
Returns:
true message has been sent
false message has not been sent

Definition at line 1186 of file mle_service.c.

uint8_t* mle_service_get_data_pointer ( uint16_t  msgId )

Get MLE message data pointer for write.

Parameters:
msgIdmessage id.
Returns:
>0 Valid pointer for write
NULL Not valid message id

Definition at line 1068 of file mle_service.c.

uint8_t* mle_service_get_msg_destination_address_pointer ( uint16_t  msgId )

Get MLE message destination address pointer for write purpose.

Parameters:
msgIdmessage id.
Returns:
>0 Pointer get OK
NULL message id not valid

Definition at line 1138 of file mle_service.c.

uint16_t mle_service_get_payload_length ( uint16_t  msgId )

Get MLE message payload length.

Parameters:
msgIdmessage id.
Returns:
length of payload

Definition at line 1084 of file mle_service.c.

uint8_t* mle_service_get_payload_start_point ( uint16_t  msgId )

Get MLE message pointer to message start.

Parameters:
msgIdmessage id.
Returns:
>0 Valid pointer for read or verify
NULL Not valid message id

Definition at line 1073 of file mle_service.c.

int mle_service_interface_token_bucket_settings_set ( int8_t  interface_id,
uint8_t  size,
uint8_t  rate,
uint8_t  count 
)

Sets MLE token bucket settings.

Using of message tokens is optional.

Parameters:
sizeBucket size, 0 to 255, 0 means not in use
rateToken rate, 0 to 255, 0 means not in use
count,0to 255, 0 means not in use
Returns:
0 Set is OK
-1 Unknown interface id
-2 Other error

Definition at line 997 of file mle_service.c.

void mle_service_interface_tx_queue_clean ( int8_t  interface_id )

Delete and free all activated Transaction.

Parameters:
interface_idinterface Id.

Definition at line 987 of file mle_service.c.

int mle_service_message_tail_get ( uint16_t  msgId,
uint16_t  tail_length 
)

MLE message tail get for new payload.

Parameters:
msgIdmessage id.
tail_lengthdefine messages new need tail length
Returns:
0 tail allocated OK
-1 tail allocate fail
-2 unknown message id

Definition at line 1197 of file mle_service.c.

uint16_t mle_service_msg_allocate ( int8_t  interface_id,
uint16_t  data_length,
bool  challengeAllocate,
uint8_t  type 
)

Allocate MLE transaction buffer and set default security parameters to buffer.

Configured security params from interface * security level * key id mode MAC_KEY_ID_MODE_IDX Service will automatically set next params * Key id * security frame counter

Parameters:
interface_idinterface Id.
data_lengthPayload max length
challengeAllocateTrue allocate challenge and write that to message automatically
typemessage type
Returns:
> 0 Message id
0 Allocate fail

Definition at line 1014 of file mle_service.c.

int mle_service_msg_free ( uint16_t  msgId )

Free message.

Parameters:
msgIdbuffer Id.
Returns:
0 Free Valid
-1 Unknown Id

Definition at line 1170 of file mle_service.c.

int mle_service_msg_update_security_params ( uint16_t  msgId,
uint8_t  security_level,
uint8_t  key_id_mode,
uint32_t  keysequence 
)

Set new security level and Key id mode.

Parameters:
msgIdmessage id for update.
security_levelvalid values below:

  • AES_NO_SECURITY
  • AES_SECURITY_LEVEL_MIC32
  • AES_SECURITY_LEVEL_MIC64
  • AES_SECURITY_LEVEL_MIC128
  • AES_SECURITY_LEVEL_ENC
  • AES_SECURITY_LEVEL_ENC_MIC32
  • AES_SECURITY_LEVEL_ENC_MIC64
  • AES_SECURITY_LEVEL_ENC_MIC128
key_id_modevalid values below:

  • MAC_KEY_ID_MODE_IDX
  • MAC_KEY_ID_MODE_SRC4_IDX
Returns:
0 Set OK
-1 Unknown message id
-2 Not supported parameters

Definition at line 1109 of file mle_service.c.

int mle_service_reject_message_build ( int8_t  interfaceId,
uint8_t *  dstIpv6,
bool  force_unsecure 
)

Build and send standard link reject message.

Parameters:
msgIdMessage Id.
dstIpv6rejected link
force_unsecuretrue force force disbale security

Definition at line 1393 of file mle_service.c.

int mle_service_reset_frame_counters ( int8_t  interfaceId )

count all activated Transactions.

Parameters:
interface_idinterface Id.
Returns:
count of active buffers

Definition at line 980 of file mle_service.c.

uint8_t mle_service_security_next_key_id_get ( int8_t  interfaceId )

GET MLE security coming key id.

Parameters:
interface_idId of registered server.
Returns:
> 0 Pointer to key
NULL no available

Definition at line 1357 of file mle_service.c.

int mle_service_send_message ( uint16_t  msgId )

Sends MLE message.

Parameters:
msgIdMessage Id.

Definition at line 1230 of file mle_service.c.

void mle_service_set_accept_invalid_frame_counter ( bool  value )

Commands MLE service to accept message with invalid MLE frame counter.

Parameters:
valueset true to accept invalid frame counters

Definition at line 1493 of file mle_service.c.

void mle_service_set_fragmented_msg_ll_security ( bool  value )

Set 802.15.4 security option for fragmented MLE messages.

Parameters:
valueset true to force security for fragmented packets.
valueset false to use default security for fragmented packets.

Definition at line 1476 of file mle_service.c.

void mle_service_set_frame_counter_check ( bool  value )

Activates MLE Frame counter checking for the interface.

Parameters:
valueset true for check activation.

Definition at line 1469 of file mle_service.c.

int mle_service_set_msg_destination_address ( uint16_t  msgId,
const uint8_t *  dstAddress 
)

Set MLE message destination address.

Parameters:
msgIdmessage id.
dstAddressmessage destination address
Returns:
0 Set OK
-1 message id not valid
-2 address pointer is NULL

Definition at line 1143 of file mle_service.c.

int mle_service_set_msg_panid ( uint16_t  msgId,
uint16_t  panid 
)

Set Messages link PAN.

Parameters:
msgIdmessage id.
panidLink pan-id for this packet
Returns:
0 Set OK
-1 message id not valid

Definition at line 1158 of file mle_service.c.

int mle_service_set_msg_response_true ( uint16_t  msgId )

Set MLE message response received state.

Parameters:
msgIdmessage id.
Returns:
0 Set OK
-1 Unknown Id

Definition at line 1133 of file mle_service.c.

int mle_service_set_msg_timeout_parameters ( uint16_t  msgId,
mle_message_timeout_params_t *  timeout_params 
)

Set messages timeout parameters.

Messages timeout parameters define messages TX count and init timeout and max timeout values is messages delayed. Delayed message will affect random time between 100-900ms

Parameters:
msgIdMessage Id.
timeout_paramsmessages transmission parameters

Definition at line 1202 of file mle_service.c.

int mle_service_set_msg_token_bucket_priority ( uint16_t  msgId )

Sets message a priority over token bucket restrictions.

Parameters:
msgIdMessage Id.
Returns:
0 priority set OK
< 0 unknown message id

Definition at line 1218 of file mle_service.c.

int mle_service_set_packet_callback ( uint16_t  msgId,
mle_service_message_timeout_cb cb 
)

MLE message timeout handler set.

Parameters:
msgIdmessage id.
cbmessage timeout call back
Returns:
0 Callback set OK
< 0 unknown message id

Definition at line 1128 of file mle_service.c.

bool mle_service_timer_tick ( uint16_t  ticks )

Timer tick function.

should be called in 100ms intervals if more time passes before call amount in 100ms units.

Definition at line 261 of file mle_service.c.

int mle_service_update_length ( uint16_t  msgId,
uint16_t  tail_length 
)

Set MLE message end point by new tail.

Parameters:
msgIdmessage id.
tail_lengthhow many new byte added to message end
Returns:
0 Length Update OK
-1 Unknown message id
-2 buffer overflow

Definition at line 1099 of file mle_service.c.

int mle_service_update_length_by_ptr ( uint16_t  msgId,
uint8_t *  data_end_ptr 
)

Set MLE message end point by new data end pointer.

Parameters:
msgIdmessage id.
data_end_ptrnew message end pointer
Returns:
0 Length Update OK
-1 Unknown message id
-2 buffer overflow

Definition at line 1104 of file mle_service.c.