Loading...
Searching...
No Matches
coap_uri.h File Reference

Helper functions for URI treatment. More...

`#include <stdint.h>`
`#include "coap_str.h"`
Include dependency graph for coap_uri.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | coap_uri_t
| Representation of parsed URI. More...

## Macros

#define | COAP_URI_SCHEME_SECURE_MASK 0x01
| This mask can be used to check if a parsed URI scheme is secure.
#define | COAP_URI_SCHEME_COAP_BIT (1 << COAP_URI_SCHEME_COAP)
#define | COAP_URI_SCHEME_COAPS_BIT (1 << COAP_URI_SCHEME_COAPS)
#define | COAP_URI_SCHEME_COAP_TCP_BIT (1 << COAP_URI_SCHEME_COAP_TCP)
#define | COAP_URI_SCHEME_COAPS_TCP_BIT (1 << COAP_URI_SCHEME_COAPS_TCP)
#define | COAP_URI_SCHEME_HTTP_BIT (1 << COAP_URI_SCHEME_HTTP)
#define | COAP_URI_SCHEME_HTTPS_BIT (1 << COAP_URI_SCHEME_HTTPS)
#define | COAP_URI_SCHEME_COAP_WS_BIT (1 << COAP_URI_SCHEME_COAP_WS)
#define | COAP_URI_SCHEME_COAPS_WS_BIT (1 << COAP_URI_SCHEME_COAPS_WS)
#define | COAP_URI_SCHEME_ALL_COAP_BITS

## Typedefs

typedef enum coap_uri_scheme_t | coap_uri_scheme_t
| The scheme specifiers.

## Enumerations

enum | coap_uri_scheme_t { COAP_URI_SCHEME_COAP = 0 , COAP_URI_SCHEME_COAPS , COAP_URI_SCHEME_COAP_TCP , COAP_URI_SCHEME_COAPS_TCP , COAP_URI_SCHEME_HTTP , COAP_URI_SCHEME_HTTPS , COAP_URI_SCHEME_COAP_WS , COAP_URI_SCHEME_COAPS_WS , COAP_URI_SCHEME_LAST }
| The scheme specifiers. More...

## Functions

static int | coap_uri_scheme_is_secure (const coap_uri_t *uri)
int | coap_host_is_unix_domain (const coap_str_const_t *host)
| Determines from the `host` whether this is a Unix Domain socket request.
coap_uri_t * | coap_new_uri (const uint8_t *uri, unsigned int length)
| Creates a new coap_uri_t object from the specified URI.
coap_uri_t * | coap_clone_uri (const coap_uri_t *uri)
| Clones the specified coap_uri_t object.
void | coap_delete_uri (coap_uri_t *uri)
| Removes the specified coap_uri_t object.
int | coap_split_uri (const uint8_t *str_var, size_t len, coap_uri_t *uri)
| Parses a given string into URI components.
int | coap_split_proxy_uri (const uint8_t *str_var, size_t len, coap_uri_t *uri)
| Parses a given string into URI components.
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`.
int | coap_uri_into_optlist (const coap_uri_t *uri, const coap_address_t *dst, coap_optlist_t **optlist_chain, int create_port_host_opt)
| Takes a coap_uri_t and then adds CoAP options into the `optlist_chain`.
int | coap_split_path (const uint8_t *path, size_t length, unsigned char *buf, size_t *buflen)
| Splits the given URI path into segments.
int | coap_path_into_optlist (const uint8_t *path, size_t length, coap_option_num_t optnum, coap_optlist_t **optlist_chain)
| Splits the given URI path into '/' separate segments, and then adds the Uri-Path / Location-Path option for each segment to the `optlist_chain`.
int | coap_split_query (const uint8_t *query, size_t length, unsigned char *buf, size_t *buflen)
| Splits the given URI query into segments.
int | coap_query_into_optlist (const uint8_t *query, size_t length, coap_option_num_t optnum, coap_optlist_t **optlist_chain)
| Splits the given URI query into '&' separate segments, and then adds the Uri-Query / Location-Query option for each segment to the `optlist_chain`.
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.
coap_string_t * | coap_get_uri_path (const coap_pdu_t *request)
| Extract uri_path string from request PDU.

## Detailed Description

Helper functions for URI treatment.

Definition in file coap_uri.h.

## Macro Definition Documentation

## COAP_URI_SCHEME_ALL_COAP_BITS

#define COAP_URI_SCHEME_ALL_COAP_BITS

Value:
(COAP_URI_SCHEME_COAP_BIT | \
COAP_URI_SCHEME_COAPS_BIT | \
COAP_URI_SCHEME_COAP_TCP_BIT | \
COAP_URI_SCHEME_COAPS_TCP_BIT | \
COAP_URI_SCHEME_COAP_WS_BIT | \
COAP_URI_SCHEME_COAPS_WS_BIT)
COAP_URI_SCHEME_COAPS_WS_BIT
#define COAP_URI_SCHEME_COAPS_WS_BIT
Definition coap_uri.h:50
COAP_URI_SCHEME_COAP_WS_BIT
#define COAP_URI_SCHEME_COAP_WS_BIT
Definition coap_uri.h:49
COAP_URI_SCHEME_COAPS_BIT
#define COAP_URI_SCHEME_COAPS_BIT
Definition coap_uri.h:44
COAP_URI_SCHEME_COAPS_TCP_BIT
#define COAP_URI_SCHEME_COAPS_TCP_BIT
Definition coap_uri.h:46
COAP_URI_SCHEME_COAP_BIT
#define COAP_URI_SCHEME_COAP_BIT
Definition coap_uri.h:43
COAP_URI_SCHEME_COAP_TCP_BIT
#define COAP_URI_SCHEME_COAP_TCP_BIT
Definition coap_uri.h:45

Definition at line 52 of file coap_uri.h.

## COAP_URI_SCHEME_COAP_BIT

#define COAP_URI_SCHEME_COAP_BIT (1 << COAP_URI_SCHEME_COAP)

Definition at line 43 of file coap_uri.h.

## COAP_URI_SCHEME_COAP_TCP_BIT

#define COAP_URI_SCHEME_COAP_TCP_BIT (1 << COAP_URI_SCHEME_COAP_TCP)

Definition at line 45 of file coap_uri.h.

## COAP_URI_SCHEME_COAP_WS_BIT

#define COAP_URI_SCHEME_COAP_WS_BIT (1 << COAP_URI_SCHEME_COAP_WS)

Definition at line 49 of file coap_uri.h.

## COAP_URI_SCHEME_COAPS_BIT

#define COAP_URI_SCHEME_COAPS_BIT (1 << COAP_URI_SCHEME_COAPS)

Definition at line 44 of file coap_uri.h.

## COAP_URI_SCHEME_COAPS_TCP_BIT

#define COAP_URI_SCHEME_COAPS_TCP_BIT (1 << COAP_URI_SCHEME_COAPS_TCP)

Definition at line 46 of file coap_uri.h.

## COAP_URI_SCHEME_COAPS_WS_BIT

#define COAP_URI_SCHEME_COAPS_WS_BIT (1 << COAP_URI_SCHEME_COAPS_WS)

Definition at line 50 of file coap_uri.h.

## COAP_URI_SCHEME_HTTP_BIT

#define COAP_URI_SCHEME_HTTP_BIT (1 << COAP_URI_SCHEME_HTTP)

Definition at line 47 of file coap_uri.h.

## COAP_URI_SCHEME_HTTPS_BIT

#define COAP_URI_SCHEME_HTTPS_BIT (1 << COAP_URI_SCHEME_HTTPS)

Definition at line 48 of file coap_uri.h.

## COAP_URI_SCHEME_SECURE_MASK

#define COAP_URI_SCHEME_SECURE_MASK 0x01

This mask can be used to check if a parsed URI scheme is secure.

Definition at line 41 of file coap_uri.h.

## Typedef Documentation

## coap_uri_scheme_t

typedef enum coap_uri_scheme_t coap_uri_scheme_t

The scheme specifiers.

Secure schemes have an odd numeric value, others are even.

## Enumeration Type Documentation

## coap_uri_scheme_t

enum coap_uri_scheme_t

The scheme specifiers.

Secure schemes have an odd numeric value, others are even.

Enumerator
COAP_URI_SCHEME_COAP |
COAP_URI_SCHEME_COAPS |
COAP_URI_SCHEME_COAP_TCP |
COAP_URI_SCHEME_COAPS_TCP |
COAP_URI_SCHEME_HTTP |
COAP_URI_SCHEME_HTTPS |
COAP_URI_SCHEME_COAP_WS |
COAP_URI_SCHEME_COAPS_WS |
COAP_URI_SCHEME_LAST |

Definition at line 28 of file coap_uri.h.

## Function Documentation

## coap_clone_uri()

coap_uri_t * coap_clone_uri | ( | const coap_uri_t * | uri | ) |

Clones the specified coap_uri_t object.

This function allocates sufficient memory to hold the coap_uri_t structure and its contents. The object should be released with delete_uri().

Parameters

  uri | The coap_uri_t structure to copy.

Returns
  New URI object or NULL on error.

Definition at line 873 of file coap_uri.c.

Here is the call graph for this function:

## coap_delete_uri()

void coap_delete_uri | ( | coap_uri_t * | uri | ) |

Removes the specified coap_uri_t object.

Parameters

  uri | The coap_uri_t structure to remove.

Definition at line 915 of file coap_uri.c.

Here is the call graph for this function:

## coap_host_is_unix_domain()

int coap_host_is_unix_domain | ( | const coap_str_const_t * | host | ) |

Determines from the `host` whether this is a Unix Domain socket request.

Parameters

  host | The host object.

Returns
  `0` on failure, or `1` on success.

Definition at line 384 of file coap_uri.c.

Here is the caller graph for this function:

## coap_new_uri()

coap_uri_t * coap_new_uri | ( | const uint8_t * | uri,
|  | unsigned int | length )

Creates a new coap_uri_t object from the specified URI.

Returns the new object or NULL on error. The memory allocated by the new coap_uri_t should be released using coap_delete_uri().

Parameters

  uri | The URI path to copy.
  length | The length of uri.

Returns
  New URI object or NULL on error.

Definition at line 852 of file coap_uri.c.

Here is the call graph for this function:

## coap_uri_scheme_is_secure()

int coap_uri_scheme_is_secure | ( | const coap_uri_t * | uri | ) |

inline static

Definition at line 81 of file coap_uri.h.

Here is the caller graph for this function: