Skip to content

Commit

Permalink
Squashed 'features/nanostack/FEATURE_NANOSTACK/coap-service/' changes…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Arto Kinnunen committed Nov 16, 2017
1 parent 9d5a9f5 commit 1bc6ddc
Show file tree
Hide file tree
Showing 18 changed files with 654 additions and 291 deletions.
99 changes: 72 additions & 27 deletions coap-service/coap_service_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ extern const uint8_t COAP_MULTICAST_ADDR_SITE_LOCAL[16]; //!> ff05::fd, COAP sit
*
* Function that handles CoAP service message receiving and parsing
*
* \param msg_id Id number of the current message.
* \param service_id Service handle.
* \param source_address IPv6 source address.
* \param source_port Source port
* \param source_port Source port.
* \param response_ptr Pointer to CoAP header structure.
*
* \return 0 for success / -1 for failure
Expand All @@ -85,10 +85,11 @@ typedef int coap_service_response_recv(int8_t service_id, uint8_t source_address
*
* \param service_id Id number of the current service.
* \param source_address IPv6 source address.
* \param source_port Source port
* \param source_port Source port.
* \param request_ptr Pointer to CoAP header structure.
*
* \return Status
* \return -1 = Message ignored, no response will be sent. Transaction will be deleted.
* 0 = Response is either already sent or will be send. Transaction is not deleted.
*/
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);

Expand All @@ -98,8 +99,10 @@ typedef int coap_service_request_recv_cb(int8_t service_id, uint8_t source_addre
* Starts security service handling and fetches device password.
*
* \param service_id Id number of the current service.
* \param address Address of sender
* \param port Port of the device
* \param address Address of sender.
* \param port Port of the device.
* \param pw Pointer where to write the ecjpake password.
* \param pw_len Pointer where to write length of the ecjpake password.
*
* \return 0 for success / -1 for failure
*/
Expand All @@ -111,8 +114,8 @@ typedef int coap_service_security_start_cb(int8_t service_id, uint8_t address[st
* CoAP service security done callback function.
*
* \param service_id Id number of the current service.
* \param address Address of sender
* \param keyblock Security key (40 bits)
* \param address Address of sender.
* \param keyblock Security key (40 bits).
*
* \return 0 for success / -1 for failure
*/
Expand Down Expand Up @@ -147,23 +150,12 @@ extern void coap_service_delete( int8_t service_id );
*
* Closes secure connection (if present), but leaves socket open.
*
* \param service_id Id number of the current service.
* \param service_id Id number of the current service.
* \param destimation_addr_ptr Connection destination address.
* \param port Connection destination port.
*/
extern void coap_service_close_secure_connection(int8_t service_id, uint8_t destination_addr_ptr[static 16], uint16_t port);

/**
* \brief Sets password for device
*
* \param service_id Service id
* \param address Device address
* \param port Device port
* \param pw_ptr Pointer to password.
* \param pw_len Lenght of password.
*
* \return 0 for success / -1 for failure
*/
//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);

/**
* \brief Virtual socket sent callback.
*
Expand Down Expand Up @@ -213,7 +205,6 @@ extern int16_t coap_service_virtual_socket_set_cb(int8_t service_id, coap_servic
*
* \param service_id Id number of the current service.
* \param *uri Uri address.
* \param port port that Application wants to use for communicate with coap server.
* \param allowed_method Informs method that is allowed to use (used defines described above).
* \param *request_recv_cb CoAP service request receive callback function pointer.
*
Expand All @@ -240,7 +231,7 @@ extern int8_t coap_service_unregister_uri(int8_t service_id, const char *uri);
*
* \param service_id Id number of the current service.
* \param options Options defined above.
* \param destination_addr IPv6 address.
* \param destination_addr IPv6 address.
* \param destination_port Destination port
* \param msg_type Message type can be found from sn_coap_header.
* \param msg_code Message code can be found from sn_coap_header.
Expand All @@ -261,15 +252,39 @@ extern uint16_t coap_service_request_send(int8_t service_id, uint8_t options, co
* Build and sends CoAP service response message.
*
* \param service_id Id number of the current service.
* \param msg_id Message ID number.
* \param options Options defined above.
* \param response_ptr Pointer to CoAP header structure.
* \param request_ptr Pointer to CoAP request message header structure.
* \param message_code Message code can be found from sn_coap_header.
* \param content_type Content type can be found from sn_coap_header.
* \param payload_ptr Pointer to message content.
* \param payload_len Lenght of the message.
*
* \return -1 For failure
*- 0 For success
*/
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);

/**
* \brief Sends CoAP service response
*
* Build and sends CoAP service response message based on CoAP request message id.
*
* \param service_id Id number of the current service.
* \param options Options defined above.
* \param msg_id Request messages ID.
* \param msg_type Message type can be found from sn_coap_header.
* \param message_code Message code can be found from sn_coap_header.
* \param content_type Content type can be found from sn_coap_header.
* \param payload_ptr Pointer to message content.
* \param payload_len Lenght of the message.
*
* \return -1 For failure
*- 0 For success
*/
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);



/**
* \brief Delete CoAP request transaction
*
Expand Down Expand Up @@ -297,18 +312,48 @@ extern int8_t coap_service_request_delete(int8_t service_id, uint16_t msg_id);
*/
extern int8_t coap_service_set_handshake_timeout(int8_t service_id, uint32_t min, uint32_t max);

/**
* \brief Set DTLS handshake limit values
*
* Configures the limits for DTLS sessions. Values must be > 0.
*
* \param handshakes_max Maximum amount of simultaneous handshakes.
* \param connections_max Maximum amount of sessions.
*
* \return -1 For failure
*- 0 For success
*/
extern int8_t coap_service_handshake_limits_set(uint8_t handshakes_max, uint8_t connections_max);

/**
* \brief Set CoAP duplication message buffer size
*
* Configures the CoAP duplication message buffer size.
*
* \param service_id Id number of the current service.
* \param size Buffer size (messages)
* \param size Buffer size (messages).
*
* \return -1 For failure
*- 0 For success
*/
extern int8_t coap_service_set_duplicate_message_buffer(int8_t service_id, uint8_t size);

/**
* \brief Set DTLS certificates
*
* Set DTLS certificates.
*
* \param service_id Id number of the current service.
* \param cert Pointer to certificate chain.
* \param cert_len Certificate length.
* \param priv_key pointer to private key.
* \param priv_key_len length of private key.
*
* \return -1 For failure
*- 0 For success
*/

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);
#ifdef __cplusplus
}
#endif
Expand Down
Loading

0 comments on commit 1bc6ddc

Please sign in to comment.