Simple interface for Mbed Cloud Client
sn_coap_parser.c File Reference
CoAP Header parser. More...
Go to the source code of this file.
Functions | |
static void | sn_coap_parser_header_parse (uint8_t **packet_data_pptr, sn_coap_hdr_s *dst_coap_msg_ptr, coap_version_e *coap_version_ptr) |
Parses CoAP message's Header part from given Packet data. | |
static int8_t | sn_coap_parser_payload_parse (uint16_t packet_data_len, uint8_t *packet_data_start_ptr, uint8_t **packet_data_pptr, sn_coap_hdr_s *dst_coap_msg_ptr) |
Parses CoAP message's Payload part from given Packet data. | |
sn_coap_hdr_s * | sn_coap_parser_init_message (sn_coap_hdr_s *coap_msg_ptr) |
Initialise a message structure to empty. | |
sn_coap_hdr_s * | sn_coap_parser_alloc_message (struct coap_s *handle) |
Allocate an empty message structure. | |
sn_coap_options_list_s * | sn_coap_parser_alloc_options (struct coap_s *handle, sn_coap_hdr_s *coap_msg_ptr) |
Allocates and initializes options list structure. | |
sn_coap_hdr_s * | sn_coap_parser (struct coap_s *handle, uint16_t packet_data_len, uint8_t *packet_data_ptr, coap_version_e *coap_version_ptr) |
Parses CoAP message from given Packet data. | |
void | sn_coap_parser_release_allocated_coap_msg_mem (struct coap_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr) |
Releases memory of given CoAP message. | |
static uint32_t | sn_coap_parser_options_parse_uint (uint8_t **packet_data_pptr, uint8_t option_len) |
Parses a variable-length uint value from an option. |
Detailed Description
CoAP Header parser.
Functionality: Parses CoAP Header
Definition in file sn_coap_parser.c.
Function Documentation
sn_coap_hdr_s* sn_coap_parser | ( | struct coap_s * | handle, |
uint16_t | packet_data_len, | ||
uint8_t * | packet_data_ptr, | ||
coap_version_e * | coap_version_ptr | ||
) |
Parses CoAP message from given Packet data.
- Parameters:
-
*handle Pointer to CoAP library handle packet_data_len is length of given Packet data to be parsed to CoAP message *packet_data_ptr is source for Packet data to be parsed to CoAP message *coap_version_ptr is destination for parsed CoAP specification version
- Returns:
- Return value is pointer to parsed CoAP message.
In following failure cases NULL is returned:
-Failure in given pointer (= NULL)
-Failure in memory allocation (malloc() returns NULL)
Definition at line 115 of file sn_coap_parser.c.
sn_coap_hdr_s* sn_coap_parser_alloc_message | ( | struct coap_s * | handle ) |
Allocate an empty message structure.
- Parameters:
-
*handle Pointer to CoAP library handle
- Returns:
- Return value is pointer to an empty CoAP message.
In following failure cases NULL is returned:
-Failure in given pointer (= NULL)
-Failure in memory allocation (malloc() returns NULL)
Definition at line 67 of file sn_coap_parser.c.
sn_coap_options_list_s* sn_coap_parser_alloc_options | ( | struct coap_s * | handle, |
sn_coap_hdr_s * | coap_msg_ptr | ||
) |
Allocates and initializes options list structure.
- Parameters:
-
*handle Pointer to CoAP library handle *coap_msg_ptr is pointer to CoAP message that will contain the options
If the message already has a pointer to an option structure, that pointer is returned, rather than a new structure being allocated.
- Returns:
- Return value is pointer to the CoAP options structure.
In following failure cases NULL is returned:
-Failure in given pointer (= NULL)
-Failure in memory allocation (malloc() returns NULL)
Definition at line 82 of file sn_coap_parser.c.
static void sn_coap_parser_header_parse | ( | uint8_t ** | packet_data_pptr, |
sn_coap_hdr_s * | dst_coap_msg_ptr, | ||
coap_version_e * | coap_version_ptr | ||
) | [static] |
Parses CoAP message's Header part from given Packet data.
- Parameters:
-
**packet_data_ptr is source for Packet data to be parsed to CoAP message *dst_coap_msg_ptr is destination for parsed CoAP message *coap_version_ptr is destination for parsed CoAP specification version
Definition at line 210 of file sn_coap_parser.c.
sn_coap_hdr_s* sn_coap_parser_init_message | ( | sn_coap_hdr_s * | coap_msg_ptr ) |
Initialise a message structure to empty.
- Parameters:
-
*coap_msg_ptr is pointer to CoAP message to initialise
- Returns:
- Return value is pointer passed in
Definition at line 51 of file sn_coap_parser.c.
static uint32_t sn_coap_parser_options_parse_uint | ( | uint8_t ** | packet_data_pptr, |
uint8_t | option_len | ||
) | [static] |
Parses a variable-length uint value from an option.
- Parameters:
-
**packet_data_pptr is source of option data to be parsed option_len is length of option data (will be 0-4)
- Returns:
- Return value is value of uint
Definition at line 236 of file sn_coap_parser.c.
static int8_t sn_coap_parser_payload_parse | ( | uint16_t | packet_data_len, |
uint8_t * | packet_data_ptr, | ||
uint8_t ** | packet_data_pptr, | ||
sn_coap_hdr_s * | dst_coap_msg_ptr | ||
) | [static] |
Parses CoAP message's Payload part from given Packet data.
- Parameters:
-
packet_data_len is length of given Packet data to be parsed to CoAP message *packet_data_ptr is start of source for Packet data to be parsed to CoAP message **packet_data_pptr is source for Packet data to be parsed to CoAP message *dst_coap_msg_ptr is destination for parsed CoAP message
Definition at line 769 of file sn_coap_parser.c.
void sn_coap_parser_release_allocated_coap_msg_mem | ( | struct coap_s * | handle, |
sn_coap_hdr_s * | freed_coap_msg_ptr | ||
) |
Releases memory of given CoAP message.
Note!!! Does not release Payload part
- Parameters:
-
*handle Pointer to CoAP library handle *freed_coap_msg_ptr is pointer to released CoAP message
Definition at line 152 of file sn_coap_parser.c.
Generated on Tue Jul 12 2022 19:01:38 by 1.7.2