Skip to content

Commit 1bc6ddc

Browse files
author
Arto Kinnunen
committed
Squashed 'features/nanostack/FEATURE_NANOSTACK/coap-service/' changes from d65b6b0..b1c9efb
b1c9efb Fix coap_connection_handler_send_data() return values (ARMmbed#81) f9cb04f Delete transaction when not needed (ARMmbed#80) daf3694 Message transaction memory handling changes (ARMmbed#79) adc04c4 Add API to send response to request based on Message ID (ARMmbed#78) 58f0ed5 Limit number of ongoing handshakes (ARMmbed#77) 42c1169 Fix redefinition of mbed TLS error codes (ARMmbed#76) ba7a7c4 Added server mode certificate conf (ARMmbed#74) d108199 Certificate set API changed. (ARMmbed#73) 2d622e0 Support for certificate mode (ARMmbed#72) git-subtree-dir: features/nanostack/FEATURE_NANOSTACK/coap-service git-subtree-split: b1c9efb
1 parent 9d5a9f5 commit 1bc6ddc

18 files changed

+654
-291
lines changed

coap-service/coap_service_api.h

Lines changed: 72 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ extern const uint8_t COAP_MULTICAST_ADDR_SITE_LOCAL[16]; //!> ff05::fd, COAP sit
6969
*
7070
* Function that handles CoAP service message receiving and parsing
7171
*
72-
* \param msg_id Id number of the current message.
72+
* \param service_id Service handle.
7373
* \param source_address IPv6 source address.
74-
* \param source_port Source port
74+
* \param source_port Source port.
7575
* \param response_ptr Pointer to CoAP header structure.
7676
*
7777
* \return 0 for success / -1 for failure
@@ -85,10 +85,11 @@ typedef int coap_service_response_recv(int8_t service_id, uint8_t source_address
8585
*
8686
* \param service_id Id number of the current service.
8787
* \param source_address IPv6 source address.
88-
* \param source_port Source port
88+
* \param source_port Source port.
8989
* \param request_ptr Pointer to CoAP header structure.
9090
*
91-
* \return Status
91+
* \return -1 = Message ignored, no response will be sent. Transaction will be deleted.
92+
* 0 = Response is either already sent or will be send. Transaction is not deleted.
9293
*/
9394
typedef int coap_service_request_recv_cb(int8_t service_id, uint8_t source_address[static 16], uint16_t source_port, sn_coap_hdr_s *request_ptr);
9495

@@ -98,8 +99,10 @@ typedef int coap_service_request_recv_cb(int8_t service_id, uint8_t source_addre
9899
* Starts security service handling and fetches device password.
99100
*
100101
* \param service_id Id number of the current service.
101-
* \param address Address of sender
102-
* \param port Port of the device
102+
* \param address Address of sender.
103+
* \param port Port of the device.
104+
* \param pw Pointer where to write the ecjpake password.
105+
* \param pw_len Pointer where to write length of the ecjpake password.
103106
*
104107
* \return 0 for success / -1 for failure
105108
*/
@@ -111,8 +114,8 @@ typedef int coap_service_security_start_cb(int8_t service_id, uint8_t address[st
111114
* CoAP service security done callback function.
112115
*
113116
* \param service_id Id number of the current service.
114-
* \param address Address of sender
115-
* \param keyblock Security key (40 bits)
117+
* \param address Address of sender.
118+
* \param keyblock Security key (40 bits).
116119
*
117120
* \return 0 for success / -1 for failure
118121
*/
@@ -147,23 +150,12 @@ extern void coap_service_delete( int8_t service_id );
147150
*
148151
* Closes secure connection (if present), but leaves socket open.
149152
*
150-
* \param service_id Id number of the current service.
153+
* \param service_id Id number of the current service.
154+
* \param destimation_addr_ptr Connection destination address.
155+
* \param port Connection destination port.
151156
*/
152157
extern void coap_service_close_secure_connection(int8_t service_id, uint8_t destination_addr_ptr[static 16], uint16_t port);
153158

154-
/**
155-
* \brief Sets password for device
156-
*
157-
* \param service_id Service id
158-
* \param address Device address
159-
* \param port Device port
160-
* \param pw_ptr Pointer to password.
161-
* \param pw_len Lenght of password.
162-
*
163-
* \return 0 for success / -1 for failure
164-
*/
165-
//int coap_service_security_key_set(int8_t service_id, uint8_t address[static 16], uint16_t port, uint8_t *pw_ptr, uint8_t pw_len);
166-
167159
/**
168160
* \brief Virtual socket sent callback.
169161
*
@@ -213,7 +205,6 @@ extern int16_t coap_service_virtual_socket_set_cb(int8_t service_id, coap_servic
213205
*
214206
* \param service_id Id number of the current service.
215207
* \param *uri Uri address.
216-
* \param port port that Application wants to use for communicate with coap server.
217208
* \param allowed_method Informs method that is allowed to use (used defines described above).
218209
* \param *request_recv_cb CoAP service request receive callback function pointer.
219210
*
@@ -240,7 +231,7 @@ extern int8_t coap_service_unregister_uri(int8_t service_id, const char *uri);
240231
*
241232
* \param service_id Id number of the current service.
242233
* \param options Options defined above.
243-
* \param destination_addr IPv6 address.
234+
* \param destination_addr IPv6 address.
244235
* \param destination_port Destination port
245236
* \param msg_type Message type can be found from sn_coap_header.
246237
* \param msg_code Message code can be found from sn_coap_header.
@@ -261,15 +252,39 @@ extern uint16_t coap_service_request_send(int8_t service_id, uint8_t options, co
261252
* Build and sends CoAP service response message.
262253
*
263254
* \param service_id Id number of the current service.
264-
* \param msg_id Message ID number.
265255
* \param options Options defined above.
266-
* \param response_ptr Pointer to CoAP header structure.
256+
* \param request_ptr Pointer to CoAP request message header structure.
257+
* \param message_code Message code can be found from sn_coap_header.
258+
* \param content_type Content type can be found from sn_coap_header.
259+
* \param payload_ptr Pointer to message content.
260+
* \param payload_len Lenght of the message.
267261
*
268262
* \return -1 For failure
269263
*- 0 For success
270264
*/
271265
extern int8_t coap_service_response_send(int8_t service_id, uint8_t options, sn_coap_hdr_s *request_ptr, sn_coap_msg_code_e message_code, sn_coap_content_format_e content_type, const uint8_t *payload_ptr,uint16_t payload_len);
272266

267+
/**
268+
* \brief Sends CoAP service response
269+
*
270+
* Build and sends CoAP service response message based on CoAP request message id.
271+
*
272+
* \param service_id Id number of the current service.
273+
* \param options Options defined above.
274+
* \param msg_id Request messages ID.
275+
* \param msg_type Message type can be found from sn_coap_header.
276+
* \param message_code Message code can be found from sn_coap_header.
277+
* \param content_type Content type can be found from sn_coap_header.
278+
* \param payload_ptr Pointer to message content.
279+
* \param payload_len Lenght of the message.
280+
*
281+
* \return -1 For failure
282+
*- 0 For success
283+
*/
284+
extern int8_t coap_service_response_send_by_msg_id(int8_t service_id, uint8_t options, uint16_t msg_id, sn_coap_msg_code_e message_code, sn_coap_content_format_e content_type, const uint8_t *payload_ptr,uint16_t payload_len);
285+
286+
287+
273288
/**
274289
* \brief Delete CoAP request transaction
275290
*
@@ -297,18 +312,48 @@ extern int8_t coap_service_request_delete(int8_t service_id, uint16_t msg_id);
297312
*/
298313
extern int8_t coap_service_set_handshake_timeout(int8_t service_id, uint32_t min, uint32_t max);
299314

315+
/**
316+
* \brief Set DTLS handshake limit values
317+
*
318+
* Configures the limits for DTLS sessions. Values must be > 0.
319+
*
320+
* \param handshakes_max Maximum amount of simultaneous handshakes.
321+
* \param connections_max Maximum amount of sessions.
322+
*
323+
* \return -1 For failure
324+
*- 0 For success
325+
*/
326+
extern int8_t coap_service_handshake_limits_set(uint8_t handshakes_max, uint8_t connections_max);
327+
300328
/**
301329
* \brief Set CoAP duplication message buffer size
302330
*
303331
* Configures the CoAP duplication message buffer size.
304332
*
305333
* \param service_id Id number of the current service.
306-
* \param size Buffer size (messages)
334+
* \param size Buffer size (messages).
307335
*
308336
* \return -1 For failure
309337
*- 0 For success
310338
*/
311339
extern int8_t coap_service_set_duplicate_message_buffer(int8_t service_id, uint8_t size);
340+
341+
/**
342+
* \brief Set DTLS certificates
343+
*
344+
* Set DTLS certificates.
345+
*
346+
* \param service_id Id number of the current service.
347+
* \param cert Pointer to certificate chain.
348+
* \param cert_len Certificate length.
349+
* \param priv_key pointer to private key.
350+
* \param priv_key_len length of private key.
351+
*
352+
* \return -1 For failure
353+
*- 0 For success
354+
*/
355+
356+
extern int8_t coap_service_certificate_set(int8_t service_id, const unsigned char *cert, uint16_t cert_len, const unsigned char *priv_key, uint8_t priv_key_len);
312357
#ifdef __cplusplus
313358
}
314359
#endif

0 commit comments

Comments
 (0)