libcoap 4.3.1
uri.h
Go to the documentation of this file.
1/*
2 * uri.h -- helper functions for URI treatment
3 *
4 * Copyright (C) 2010-2020 Olaf Bergmann <bergmann@tzi.org>
5 *
6 * SPDX-License-Identifier: BSD-2-Clause
7 *
8 * This file is part of the CoAP library libcoap. Please see README for terms
9 * of use.
10 */
11
17#ifndef COAP_URI_H_
18#define COAP_URI_H_
19
20#include <stdint.h>
21
22#include "str.h"
23
28typedef enum coap_uri_scheme_t {
33 COAP_URI_SCHEME_HTTP, /* 4 Proxy-Uri only */
34 COAP_URI_SCHEME_HTTPS /* 5 Proxy-Uri only */
36
38#define COAP_URI_SCHEME_SECURE_MASK 0x01
39
45typedef struct {
47 uint16_t port;
55
56static inline int
58 return uri && ((uri->scheme & COAP_URI_SCHEME_SECURE_MASK) != 0);
59}
60
71coap_uri_t *coap_new_uri(const uint8_t *uri, unsigned int length);
72
78
102int coap_split_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri);
103
120int coap_split_proxy_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri);
121
135int coap_split_path(const uint8_t *s,
136 size_t length,
137 unsigned char *buf,
138 size_t *buflen);
139
155int coap_split_query(const uint8_t *s,
156 size_t length,
157 unsigned char *buf,
158 size_t *buflen);
159
169
179
182#endif /* COAP_URI_H_ */
coap_string_t * coap_get_uri_path(const coap_pdu_t *request)
Extract uri_path string from request PDU.
Definition: uri.c:611
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:449
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:461
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:241
int coap_split_proxy_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri)
Parses a given string into URI components.
Definition: uri.c:246
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.
Definition: uri.c:561
Strings to be used in the CoAP library.
structure for CoAP PDUs
CoAP string data definition with const data.
Definition: str.h:46
CoAP string data definition.
Definition: str.h:38
Representation of parsed URI.
Definition: uri.h:45
enum coap_uri_scheme_t scheme
The parsed scheme specifier.
Definition: uri.h:53
coap_str_const_t path
Beginning of the first path segment.
Definition: uri.h:48
uint16_t port
The port in host byte order.
Definition: uri.h:47
coap_str_const_t query
The query part if present.
Definition: uri.h:50
coap_str_const_t host
host part of the URI
Definition: uri.h:46
static int coap_uri_scheme_is_secure(const coap_uri_t *uri)
Definition: uri.h:57
coap_uri_scheme_t
The scheme specifiers.
Definition: uri.h:28
@ COAP_URI_SCHEME_COAPS_TCP
Definition: uri.h:32
@ COAP_URI_SCHEME_COAPS
Definition: uri.h:30
@ COAP_URI_SCHEME_COAP_TCP
Definition: uri.h:31
@ COAP_URI_SCHEME_HTTPS
Definition: uri.h:34
@ COAP_URI_SCHEME_COAP
Definition: uri.h:29
@ COAP_URI_SCHEME_HTTP
Definition: uri.h:33
#define COAP_URI_SCHEME_SECURE_MASK
This mask can be used to check if a parsed URI scheme is secure.
Definition: uri.h:38
coap_uri_t * coap_clone_uri(const coap_uri_t *uri)
Clones the specified coap_uri_t object.
Definition: uri.c:506
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:487