libcoap 4.3.3
|
API for parsing URIs. More...
Functions | |
int | coap_split_uri (const uint8_t *str_var, size_t len, coap_uri_t *uri) |
Parses a given string into URI components. More... | |
int | coap_split_proxy_uri (const uint8_t *str_var, size_t len, coap_uri_t *uri) |
Parses a given string into URI components. More... | |
int | coap_uri_into_options (const coap_uri_t *uri, const coap_address_t *dst, coap_optlist_t **optlist_chain, int create_port_host_opt, uint8_t *buf, size_t buflen) |
Takes a coap_uri_t and then adds CoAP options into the optlist_chain . More... | |
int | coap_split_path (const uint8_t *s, size_t length, unsigned char *buf, size_t *buflen) |
Splits the given URI path into segments. More... | |
int | coap_split_query (const uint8_t *s, size_t length, unsigned char *buf, size_t *buflen) |
Splits the given URI query into segments. More... | |
coap_string_t * | coap_get_query (const coap_pdu_t *request) |
Extract query string from request PDU according to escape rules in 6.5.8. More... | |
coap_string_t * | coap_get_uri_path (const coap_pdu_t *request) |
Extract uri_path string from request PDU. More... | |
API for parsing URIs.
CoAP PDUs contain normalized URIs with their path and query split into multiple segments. The functions in this module help splitting strings.
coap_string_t * coap_get_query | ( | const coap_pdu_t * | request | ) |
Extract query string from request PDU according to escape rules in 6.5.8.
request | Request PDU. |
NULL
if no query was contained in request
. The coap_string_t object returned by this function must be released with coap_delete_string. Definition at line 718 of file coap_uri.c.
coap_string_t * coap_get_uri_path | ( | const coap_pdu_t * | request | ) |
Extract uri_path string from request PDU.
request | Request PDU. |
NULL
if no URI-Path was contained in request
. The coap_string_t object returned by this function must be released with coap_delete_string. Definition at line 769 of file coap_uri.c.
int coap_split_path | ( | const uint8_t * | s, |
size_t | length, | ||
unsigned char * | buf, | ||
size_t * | buflen | ||
) |
Splits the given URI path into segments.
Each segment is preceded by an option pseudo-header with delta-value 0 and the actual length of the respective segment after percent-decoding.
s | The path string to split. |
length | The actual length of s . |
buf | Result buffer for parsed segments. |
buflen | Maximum length of buf . Will be set to the actual number of bytes written into buf on success. |
-1
on error. Definition at line 600 of file coap_uri.c.
int coap_split_proxy_uri | ( | const uint8_t * | str_var, |
size_t | len, | ||
coap_uri_t * | uri | ||
) |
Parses a given string into URI components.
The identified syntactic components are stored in the result parameter uri
. Optional URI components that are not specified will be set to { 0, 0 }, except for the port which is set to default port for the protocol. This function returns 0
if parsing succeeded, a value less than zero otherwise. Note: This function enforces that the given string is in Proxy-Uri format as well as supports different schema such as http and https.
str_var | The string to split up. |
len | The actual length of str_var |
uri | The coap_uri_t object to store the result. |
0
on success, or < 0 on error. Definition at line 274 of file coap_uri.c.
int coap_split_query | ( | const uint8_t * | s, |
size_t | length, | ||
unsigned char * | buf, | ||
size_t * | buflen | ||
) |
Splits the given URI query into segments.
Each segment is preceded by an option pseudo-header with delta-value 0 and the actual length of the respective query term.
s | The query string to split. |
length | The actual length of s . |
buf | Result buffer for parsed segments. |
buflen | Maximum length of buf . Will be set to the actual number of bytes written into buf on success. |
-1
on error.Definition at line 612 of file coap_uri.c.
int coap_split_uri | ( | const uint8_t * | str_var, |
size_t | len, | ||
coap_uri_t * | uri | ||
) |
Parses a given string into URI components.
The identified syntactic components are stored in the result parameter uri
. Optional URI components that are not specified will be set to { 0, 0 }, except for the port which is set to the default port for the protocol. This function returns 0
if parsing succeeded, a value less than zero otherwise.
str_var | The string to split up. |
len | The actual length of str_var |
uri | The coap_uri_t object to store the result. |
0
on success, or < 0 on error. Definition at line 269 of file coap_uri.c.
int coap_uri_into_options | ( | const coap_uri_t * | uri, |
const coap_address_t * | dst, | ||
coap_optlist_t ** | optlist_chain, | ||
int | create_port_host_opt, | ||
uint8_t * | buf, | ||
size_t | buflen | ||
) |
Takes a coap_uri_t and then adds CoAP options into the optlist_chain
.
If the port is not the default port and create_port_host_opt is not 0, then the Port option is added to the optlist_chain
. If the dst defines an address that does not match the host in uri->host and is not 0, then the Host option is added to the optlist_chain
. Any path or query are broken down into the individual segment Path or Query options and added to the optlist_chain
.
uri | The coap_uri_t object. |
dst | The destination, or NULL if URI_HOST not to be added. |
optlist_chain | Where to store the chain of options. |
buf | Scratch buffer area (needs to be bigger than uri->path.length and uri->query.length) |
buflen | Size of scratch buffer. |
create_port_host_opt | 1 if port/host option to be added (if non-default) else 0 |
0
on success, or < 0 on error. Definition at line 279 of file coap_uri.c.