133 #define SOL_COAP_REQUEST_MASK 0x07
183 #define sol_coap_make_response_code(clas, det) ((clas << 5) | (det))
220 #define SOL_COAP_CODE_EMPTY (0)
269 #ifndef SOL_NO_API_VERSION
270 #define SOL_COAP_RESOURCE_API_VERSION (1)
531 uint16_t cipher_suites_len);
825 const void *cb_data);
879 struct sol_buffer *buf,
size_t offset,
size_t *size);
945 #ifdef SOL_LOG_ENABLED
Definition: sol-coap.h:193
int sol_coap_unobserve_by_token(struct sol_coap_server *server, const struct sol_network_link_addr *cliaddr, uint8_t *token, uint8_t tkl)
Remove observation identified by token from server.
int sol_coap_path_to_buffer(const struct sol_str_slice path[], struct sol_buffer *buf, size_t offset, size_t *size)
Inserts a path given in slices form to a sol-buffer, at a given offset.
struct sol_coap_packet * sol_coap_packet_new_notification(struct sol_coap_server *server, struct sol_coap_resource *resource)
Convenience function to create a packet suitable to send as a notification.
int(* post)(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
POST request.
Definition: sol-coap.h:302
int sol_coap_find_options(const struct sol_coap_packet *pkt, uint16_t code, struct sol_str_slice *vec, uint16_t veclen)
Gets a number of specified option in a packet.
Definition: sol-coap.h:98
Definition: sol-coap.h:205
Definition: sol-coap.h:210
int sol_coap_header_set_code(struct sol_coap_packet *pkt, uint8_t code)
Sets the code of the message.
Confirmable messsage.
Definition: sol-coap.h:148
int sol_coap_header_get_type(const struct sol_coap_packet *pkt, uint8_t *type)
Gets the type of the message container in the packet.
Definition: sol-coap.h:211
sol_coap_message_type
CoAP packets may be of one of these types.
Definition: sol-coap.h:138
sol_coap_content_type
Some content-types available for use with the CONTENT_FORMAT option.
Definition: sol-coap.h:227
int(* put)(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
PUT request.
Definition: sol-coap.h:318
int sol_coap_header_set_id(struct sol_coap_packet *pkt, uint16_t id)
Sets the message ID.
Definition: sol-coap.h:200
int(* del)(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
DELETE request.
Definition: sol-coap.h:334
Definition: sol-coap.h:212
struct sol_coap_packet * sol_coap_packet_ref(struct sol_coap_packet *pkt)
Take a reference of the given packet.
int sol_coap_packet_add_uri_path_option(struct sol_coap_packet *pkt, const char *uri)
Convenience function to add the the SOL_COAP_OPTION_URI_PATH from a string.
struct sol_coap_resource sol_coap_resource
Description for a CoAP resource.
Definition: sol-coap.h:201
Definition: sol-coap.h:206
Definition: sol-coap.h:229
Definition: sol-coap.h:195
Definition: sol-coap.h:89
Definition: sol-coap.h:228
struct sol_str_slice path[]
Path representing the resource.
Definition: sol-coap.h:348
int sol_coap_header_get_id(const struct sol_coap_packet *pkt, uint16_t *id)
Gets the message ID.
static struct sol_http_server * server
Definition: server-https.c:52
uint8_t * sol_coap_header_get_token(const struct sol_coap_packet *pkt, uint8_t *len)
Gets the token of the packet, if any.
static void sol_coap_packet_debug(struct sol_coap_packet *pkt)
Print information about the packet pkt.
Definition: sol-coap.h:949
int sol_coap_send_packet(struct sol_coap_server *server, struct sol_coap_packet *pkt, const struct sol_network_link_addr *cliaddr)
Sends a packet to the given address.
Definition: sol-coap.h:230
#define sol_coap_make_response_code(clas, det)
Macro to create a response code.
Definition: sol-coap.h:183
bool sol_coap_server_is_secure(const struct sol_coap_server *server)
Check if a given CoAP server instance is running over DTLS or not.
int sol_coap_server_set_unknown_resource_handler(struct sol_coap_server *server, int(*handler)(void *data, struct sol_coap_server *server, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr), const void *data)
Register a unknown handler callback.
static struct sol_buffer value
Definition: server.c:42
Definition: sol-coap.h:91
Definition: sol-coap.h:232
void sol_coap_server_unref(struct sol_coap_server *server)
Release a reference from the given server.
int sol_coap_header_set_type(struct sol_coap_packet *pkt, uint8_t type)
Sets the message type in the packet's header.
String slice type.
Definition: sol-str-slice.h:84
Structure to represent a network address, both IPv6 and IPv4 are valid.
Definition: sol-network.h:145
A POST request.
Definition: sol-coap.h:111
int sol_coap_packet_get_payload(struct sol_coap_packet *pkt, struct sol_buffer **buf, size_t *offset)
Gets a pointer to the packet's payload.
A DELETE request.
Definition: sol-coap.h:115
Definition: sol-coap.h:192
sol_coap_response_code
Set of response codes available for a response packet.
Definition: sol-coap.h:190
struct sol_coap_server * sol_coap_server_new_by_cipher_suites(const struct sol_network_link_addr *addr, enum sol_socket_dtls_cipher *cipher_suites, uint16_t cipher_suites_len)
Creates a new DTLS-Secured CoAP server instance.
int sol_coap_add_option(struct sol_coap_packet *pkt, uint16_t code, const void *value, uint16_t len)
Adds an option to the CoAP packet.
struct sol_coap_packet sol_coap_packet
Opaque handler for a CoAP packet.
Definition: sol-coap.h:250
int sol_coap_header_get_code(const struct sol_coap_packet *pkt, uint8_t *code)
Gets the request/response code in the packet.
struct sol_coap_packet * sol_coap_packet_new(struct sol_coap_packet *old)
Creates a new CoAP packet.
Definition: sol-coap.h:194
Definition: sol-coap.h:94
Definition: sol-coap.h:209
struct sol_coap_server * sol_coap_server_new(const struct sol_network_link_addr *addr, bool secure)
Creates a new CoAP server instance.
int sol_coap_server_register_resource(struct sol_coap_server *server, const struct sol_coap_resource *resource, const void *data)
Register a sol_coap_resource with the server.
Definition: sol-coap.h:239
static bool reply_cb(void *data, struct sol_coap_server *server, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
Definition: simple-client.c:72
int sol_coap_server_unregister_resource(struct sol_coap_server *server, const struct sol_coap_resource *resource)
Unregisters a resource from the server.
int sol_coap_header_set_token(struct sol_coap_packet *pkt, uint8_t *token, uint8_t tokenlen)
Sets a token in the packet.
int sol_coap_cancel_send_packet(struct sol_coap_server *server, struct sol_coap_packet *pkt, struct sol_network_link_addr *cliaddr)
Cancel a packet sent using sol_coap_send_packet() or sol_coap_send_packet_with_reply() functions...
int sol_coap_header_set_version(struct sol_coap_packet *pkt, uint8_t ver)
Sets the CoAP protocol version in the packet's header.
If the resource should be exported in the CoRE well-known registry.
Definition: sol-coap.h:241
Reset.
Definition: sol-coap.h:171
Definition: sol-coap.h:203
Definition: sol-coap.h:202
sol_coap_method
Available request methods.
Definition: sol-coap.h:107
enum sol_coap_flags flags
Bitwise OR-ed flags from sol_coap_flags, if any is necessary.
Definition: sol-coap.h:341
Definition: sol-coap.h:196
struct sol_coap_server * sol_coap_server_ref(struct sol_coap_server *server)
Take a reference of the given server.
struct sol_coap_packet * sol_coap_packet_new_request(enum sol_coap_method method, enum sol_coap_message_type type)
Convenience function to create a new packet for a request.
sol_coap_flags
Flags accepted by a sol_coap_resource.
Definition: sol-coap.h:238
sol_coap_option
Set of CoAP packet options we are aware of.
Definition: sol-coap.h:84
Definition: sol-coap.h:92
void sol_coap_packet_unref(struct sol_coap_packet *pkt)
Release a reference from the given packet.
Description for a CoAP resource.
Definition: sol-coap.h:268
Definition: sol-coap.h:99
int sol_coap_notify_by_callback(struct sol_coap_server *server, struct sol_coap_resource *resource, int(*cb)(void *cb_data, struct sol_coap_server *server, struct sol_coap_resource *resource, struct sol_network_link_addr *addr, struct sol_coap_packet **pkt), const void *cb_data)
Sends the notification packet returned by a callback to all registered observers. ...
These are routines that Soletta provides for its string slice implementation.
Definition: sol-coap.h:87
Definition: sol-coap.h:199
const void * sol_coap_find_first_option(const struct sol_coap_packet *pkt, uint16_t code, uint16_t *len)
Finds the first apeearence of the specified option in a packet.
Non-confirmable message.
Definition: sol-coap.h:157
Definition: sol-coap.h:198
Definition: sol-coap.h:85
Definition: sol-coap.h:95
bool sol_coap_packet_has_payload(struct sol_coap_packet *pkt)
Checks if the given packet contains a payload.
Definition: sol-coap.h:96
Definition: sol-coap.h:231
Definition: sol-coap.h:88
Definition: sol-coap.h:86
uint16_t api_version
API version.
Definition: sol-coap.h:272
int sol_coap_notify(struct sol_coap_server *server, struct sol_coap_resource *resource, struct sol_coap_packet *pkt)
Sends the notification packet to all registered observers.
Definition: sol-coap.h:204
int sol_coap_header_get_version(const struct sol_coap_packet *pkt, uint8_t *version)
Gets the CoAP protocol version of the packet.
Definition: sol-coap.h:197
sol_socket_dtls_cipher
Represents supported Cipher Suites for use with DTLS.
Definition: sol-socket.h:47
A sol_buffer is a dynamic array, that can be resized if needed.
Definition: sol-buffer.h:130
A GET request.
Definition: sol-coap.h:109
Definition: sol-coap.h:97
A PUT request.
Definition: sol-coap.h:113
Definition: sol-coap.h:191
Definition: sol-coap.h:208
int sol_coap_send_packet_with_reply(struct sol_coap_server *server, struct sol_coap_packet *pkt, const struct sol_network_link_addr *cliaddr, bool(*reply_cb)(void *data, struct sol_coap_server *server, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr), const void *data)
Sends a packet to the given address.
Definition: sol-coap.h:207
Definition: sol-coap.h:90
struct sol_coap_server sol_coap_server
Opaque handler for a CoAP server.
Definition: sol-coap.h:258
Acknowledge.
Definition: sol-coap.h:164
These are routines that Soletta provides for handling network link interfaces, making it possible to ...
size_t len
Slice length.
Definition: sol-str-slice.h:85
Definition: sol-coap.h:93