Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
coap-endpoint.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2016-2018, SICS, Swedish ICT AB.
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the Institute nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*/
29
30
/**
31
* \file
32
* API to address CoAP endpoints
33
* \author
34
* Niclas Finne <nfi@sics.se>
35
* Joakim Eriksson <joakime@sics.se>
36
*/
37
38
/**
39
* \addtogroup coap-transport
40
* @{
41
*/
42
43
#ifndef COAP_ENDPOINT_H_
44
#define COAP_ENDPOINT_H_
45
46
#include "contiki.h"
47
#include <stdlib.h>
48
#include <stdbool.h>
49
50
#ifndef COAP_ENDPOINT_CUSTOM
51
#include "
net/ipv6/uip.h
"
52
53
typedef
struct
{
54
uip_ipaddr_t
ipaddr
;
55
uint16_t port;
56
bool
secure;
57
} coap_endpoint_t;
58
#endif
/* COAP_ENDPOINT_CUSTOM */
59
60
/**
61
* \brief Copy a CoAP endpoint from one memory area to another.
62
*
63
* \param dest A pointer to a CoAP endpoint to copy to.
64
* \param src A pointer to a CoAP endpoint to copy from.
65
*/
66
void
coap_endpoint_copy
(coap_endpoint_t *dest,
const
coap_endpoint_t *src);
67
68
/**
69
* \brief Compare two CoAP endpoints.
70
*
71
* \param e1 A pointer to the first CoAP endpoint.
72
* \param e2 A pointer to the second CoAP endpoint.
73
* \return Non-zero if the endpoints are identical and zero otherwise.
74
*/
75
int
coap_endpoint_cmp
(
const
coap_endpoint_t *e1,
const
coap_endpoint_t *e2);
76
77
/**
78
* \brief Print a CoAP endpoint via the logging module.
79
*
80
* \param ep A pointer to the CoAP endpoint to log.
81
*/
82
void
coap_endpoint_log
(
const
coap_endpoint_t *ep);
83
84
/**
85
* \brief Print a CoAP endpoint.
86
*
87
* \param ep A pointer to the CoAP endpoint to print.
88
*/
89
void
coap_endpoint_print
(
const
coap_endpoint_t *ep);
90
91
/**
92
* \brief Print a CoAP endpoint to a string. The output is always
93
* null-terminated unless size is zero.
94
*
95
* \param str The string to write to.
96
* \param size The max number of characters to write.
97
* \param ep A pointer to the CoAP endpoint to print.
98
* \return Returns the number of characters needed for the output
99
* excluding the ending null-terminator or negative if an
100
* error occurred.
101
*/
102
int
coap_endpoint_snprint
(
char
*str,
size_t
size,
103
const
coap_endpoint_t *ep);
104
105
/**
106
* \brief Parse a CoAP endpoint.
107
*
108
* \param text The string to parse.
109
* \param size The max number of characters in the string.
110
* \param ep A pointer to the CoAP endpoint to write to.
111
* \return Returns non-zero if the endpoint was successfully parsed and
112
* zero otherwise.
113
*/
114
int
coap_endpoint_parse
(
const
char
*text,
size_t
size, coap_endpoint_t *ep);
115
116
/**
117
* \brief Check if a CoAP endpoint is secure (encrypted).
118
*
119
* \param ep A pointer to a CoAP endpoint.
120
* \return Returns true if the endpoint is secure and false otherwise.
121
*/
122
int
coap_endpoint_is_secure
(
const
coap_endpoint_t *ep);
123
124
/**
125
* \brief Check if a CoAP endpoint is connected.
126
*
127
* \param ep A pointer to a CoAP endpoint.
128
* \return Returns true if the endpoint is connected and false otherwise.
129
*/
130
int
coap_endpoint_is_connected
(
const
coap_endpoint_t *ep);
131
132
/**
133
* \brief Request a connection to a CoAP endpoint.
134
*
135
* \param ep A pointer to a CoAP endpoint.
136
* \return Returns zero if an error occured and non-zero otherwise.
137
*/
138
int
coap_endpoint_connect
(coap_endpoint_t *ep);
139
140
/**
141
* \brief Request that any connection to a CoAP endpoint is discontinued.
142
*
143
* \param ep A pointer to a CoAP endpoint.
144
*/
145
void
coap_endpoint_disconnect
(coap_endpoint_t *ep);
146
147
/**
148
* \brief Setup a DTLS server session. This step is mandatory before
149
* a client can connect.
150
*
151
*/
152
int
coap_secure_server_setup
(
void
);
153
154
#endif
/* COAP_ENDPOINT_H_ */
155
/** @} */
coap_endpoint_disconnect
void coap_endpoint_disconnect(coap_endpoint_t *ep)
Request that any connection to a CoAP endpoint is discontinued.
Definition
coap-uip.c:359
coap_endpoint_cmp
int coap_endpoint_cmp(const coap_endpoint_t *e1, const coap_endpoint_t *e2)
Compare two CoAP endpoints.
Definition
coap-uip.c:168
coap_endpoint_parse
int coap_endpoint_parse(const char *text, size_t size, coap_endpoint_t *ep)
Parse a CoAP endpoint.
Definition
coap-uip.c:206
coap_endpoint_connect
int coap_endpoint_connect(coap_endpoint_t *ep)
Request a connection to a CoAP endpoint.
Definition
coap-uip.c:284
coap_secure_server_setup
int coap_secure_server_setup(void)
Setup a DTLS server session.
coap_endpoint_log
void coap_endpoint_log(const coap_endpoint_t *ep)
Print a CoAP endpoint via the logging module.
Definition
coap-uip.c:99
coap_endpoint_print
void coap_endpoint_print(const coap_endpoint_t *ep)
Print a CoAP endpoint.
Definition
coap-uip.c:115
coap_endpoint_snprint
int coap_endpoint_snprint(char *str, size_t size, const coap_endpoint_t *ep)
Print a CoAP endpoint to a string.
Definition
coap-uip.c:131
coap_endpoint_copy
void coap_endpoint_copy(coap_endpoint_t *dest, const coap_endpoint_t *src)
Copy a CoAP endpoint from one memory area to another.
Definition
coap-uip.c:159
coap_endpoint_is_secure
int coap_endpoint_is_secure(const coap_endpoint_t *ep)
Check if a CoAP endpoint is secure (encrypted).
Definition
coap-uip.c:249
coap_endpoint_is_connected
int coap_endpoint_is_connected(const coap_endpoint_t *ep)
Check if a CoAP endpoint is connected.
Definition
coap-uip.c:255
ipaddr
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
Definition
uip-nd6.c:116
uip.h
Header file for the uIP TCP/IP stack.
os
net
app-layer
coap
coap-endpoint.h
Generated on
for Contiki-NG by
1.17.0