libcoap  4.2.1
uri.h
Go to the documentation of this file.
1 /*
2  * uri.h -- helper functions for URI treatment
3  *
4  * Copyright (C) 2010-2011,2016 Olaf Bergmann <bergmann@tzi.org>
5  *
6  * This file is part of the CoAP library libcoap. Please see README for terms
7  * of use.
8  */
9 
10 #ifndef COAP_URI_H_
11 #define COAP_URI_H_
12 
13 #include <stdint.h>
14 
15 #include "str.h"
16 struct coap_pdu_t;
17 
27 };
28 
30 #define COAP_URI_SCHEME_SECURE_MASK 0x01
31 
36 typedef struct {
38  uint16_t port;
44  enum coap_uri_scheme_t scheme;
45 } coap_uri_t;
46 
47 static inline int
49  return uri && ((uri->scheme & COAP_URI_SCHEME_SECURE_MASK) != 0);
50 }
51 
62 coap_uri_t *coap_new_uri(const uint8_t *uri, unsigned int length);
63 
69 
91 int coap_split_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri);
92 
106 int coap_split_path(const uint8_t *s,
107  size_t length,
108  unsigned char *buf,
109  size_t *buflen);
110 
126 int coap_split_query(const uint8_t *s,
127  size_t length,
128  unsigned char *buf,
129  size_t *buflen);
130 
136 coap_string_t *coap_get_query(const struct coap_pdu_t *request);
137 
143 coap_string_t *coap_get_uri_path(const struct coap_pdu_t *request);
144 
147 #endif /* COAP_URI_H_ */
Representation of parsed URI.
Definition: uri.h:36
coap_uri_t * coap_clone_uri(const coap_uri_t *uri)
Clones the specified coap_uri_t object.
Definition: uri.c:447
coap_string_t * coap_get_uri_path(const struct coap_pdu_t *request)
Extract uri_path string from request PDU.
int coap_split_query(const uint8_t *s, size_t length, unsigned char *buf, size_t *buflen)
Splits the given URI query into segments.
Definition: uri.c:402
coap_str_const_t host
host part of the URI
Definition: uri.h:37
Coap string data definition.
Definition: str.h:25
Coap string data definition with const data.
Definition: str.h:33
int coap_split_path(const uint8_t *s, size_t length, unsigned char *buf, size_t *buflen)
Splits the given URI path into segments.
Definition: uri.c:390
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...
Definition: pdu.h:287
static int coap_uri_scheme_is_secure(const coap_uri_t *uri)
Definition: uri.h:48
enum coap_uri_scheme_t scheme
The parsed scheme specifier.
Definition: uri.h:44
coap_uri_scheme_t
The scheme specifiers.
Definition: uri.h:22
uint16_t port
The port in host byte order.
Definition: uri.h:38
coap_string_t * coap_get_query(const struct coap_pdu_t *request)
Extract query string from request PDU according to escape rules in 6.5.8.
coap_uri_t * coap_new_uri(const uint8_t *uri, unsigned int length)
Creates a new coap_uri_t object from the specified URI.
Definition: uri.c:428
coap_str_const_t query
The query part if present.
Definition: uri.h:41
int coap_split_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri)
Parses a given string into URI components.
Definition: uri.c:43
#define COAP_URI_SCHEME_SECURE_MASK
This mask can be used to check if a parsed URI scheme is secure.
Definition: uri.h:30
unsigned char uint8_t
Definition: uthash.h:79
coap_str_const_t path
Beginning of the first path segment.
Definition: uri.h:39