libcoap 4.3.1
uri.h File Reference

Helper functions for URI treatment. More...

#include <stdint.h>
#include "str.h"
+ Include dependency graph for 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. More...
 

Typedefs

typedef enum coap_uri_scheme_t coap_uri_scheme_t
 The scheme specifiers. More...
 

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
}
 The scheme specifiers. More...
 

Functions

static int coap_uri_scheme_is_secure (const coap_uri_t *uri)
 
coap_uri_tcoap_new_uri (const uint8_t *uri, unsigned int length)
 Creates a new coap_uri_t object from the specified URI. More...
 
coap_uri_tcoap_clone_uri (const coap_uri_t *uri)
 Clones the specified coap_uri_t object. More...
 
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_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_tcoap_get_query (const coap_pdu_t *request)
 Extract query string from request PDU according to escape rules in 6.5.8. More...
 
coap_string_tcoap_get_uri_path (const coap_pdu_t *request)
 Extract uri_path string from request PDU. More...
 

Detailed Description

Helper functions for URI treatment.

Definition in file uri.h.

Macro Definition Documentation

◆ 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 38 of file uri.h.

Typedef Documentation

◆ coap_uri_scheme_t

The scheme specifiers.

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

Enumeration Type Documentation

◆ 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 

Definition at line 28 of file 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.

Thie function allocates sufficient memory to hold the coap_uri_t structure and its contents. The object must be released with coap_free().

Definition at line 506 of file uri.c.

+ Here is the call 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 must be released using coap_free().

Parameters
uriThe URI path to copy.
lengthThe length of uri.
Returns
New URI object or NULL on error.

Definition at line 487 of file uri.c.

+ Here is the call graph for this function:

◆ coap_uri_scheme_is_secure()

static int coap_uri_scheme_is_secure ( const coap_uri_t uri)
inlinestatic

Definition at line 57 of file uri.h.