Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
coap_connection_handler.h
00001 /* 00002 * Copyright (c) 2015-2017, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef __COAP_CONNECTION_HANDLER_H__ 00019 #define __COAP_CONNECTION_HANDLER_H__ 00020 00021 #include <inttypes.h> 00022 #include <stddef.h> 00023 #include <stdbool.h> 00024 #include "ns_address.h" 00025 #include "coap_service_api_internal.h" 00026 #include "coap_security_handler.h" 00027 00028 #define MAX_SECURE_SESSION_COUNT 3 00029 #define MAX_ONGOING_HANDSHAKES 2 00030 #define CLOSED_SECURE_SESSION_TIMEOUT 3600 // Seconds 00031 #define ONGOING_HANDSHAKE_TIMEOUT 600 // Seconds 00032 #define OPEN_SECURE_SESSION_TIMEOUT 18000 // Seconds 00033 #define SECURE_SESSION_CLEAN_INTERVAL 60 // Seconds 00034 00035 struct internal_socket_s; 00036 00037 typedef int send_to_socket_cb(int8_t socket_id, const uint8_t address[static 16], uint16_t port, const void *, int); 00038 typedef int receive_from_socket_cb(int8_t socket_id, int8_t recv_if_id, uint8_t src_address[static 16], uint16_t port, const uint8_t dst_address[static 16], unsigned char *, int); 00039 typedef int get_pw_cb(int8_t socket_id, uint8_t address[static 16], uint16_t port, coap_security_keys_t *security_ptr); 00040 typedef void security_done_cb(int8_t socket_id, uint8_t address[static 16], uint16_t port, uint8_t keyblock[static 40]); 00041 typedef void cch_func_cb(void); 00042 00043 typedef struct coap_conn_handler_s { 00044 struct internal_socket_s *socket; 00045 00046 coap_security_keys_t *security_keys; 00047 receive_from_socket_cb *_recv_cb; 00048 send_to_socket_cb *_send_cb; 00049 get_pw_cb *_get_password_cb; 00050 security_done_cb *_security_done_cb; 00051 00052 int8_t socket_interface_selection; 00053 bool registered_to_multicast; 00054 } coap_conn_handler_t; 00055 00056 coap_conn_handler_t *connection_handler_create(receive_from_socket_cb *recv_from_cb, 00057 send_to_socket_cb *send_to_cb, 00058 get_pw_cb *pw_cb, 00059 security_done_cb *done_cb); 00060 00061 void connection_handler_destroy(coap_conn_handler_t *handler, bool multicast_group_leave); 00062 00063 void connection_handler_close_secure_connection(coap_conn_handler_t *handler, uint8_t destination_addr_ptr[static 16], uint16_t port); 00064 00065 int coap_connection_handler_open_connection(coap_conn_handler_t *handler, uint16_t listen_port, bool use_ephemeral_port, bool is_secure, bool real_socket, bool bypassSec); 00066 00067 //If returns -2, it means security was started and data was not send 00068 /* 00069 * \return > 0 in OK 00070 * \return 0 Session started, data not send 00071 * \return -1 failure 00072 */ 00073 int coap_connection_handler_send_data(coap_conn_handler_t *handler, const ns_address_t *dest_addr, const uint8_t src_address[static 16], uint8_t *data_ptr, uint16_t data_len, bool bypass_link_sec); 00074 00075 int coap_connection_handler_virtual_recv(coap_conn_handler_t *handler, uint8_t address[static 16], uint16_t port, uint8_t *data_ptr, uint16_t data_len); 00076 00077 bool coap_connection_handler_socket_belongs_to(coap_conn_handler_t *handler, int8_t socket_id); 00078 00079 int8_t coap_connection_handler_set_timeout(coap_conn_handler_t *handler, uint32_t min, uint32_t max); 00080 00081 int8_t coap_connection_handler_handshake_limits_set(uint8_t handshakes_limit, uint8_t connections_limit); 00082 00083 void coap_connection_handler_exec(uint32_t time); 00084 00085 coap_conn_handler_t *coap_connection_handler_find_by_socket_port(uint16_t listen_port); 00086 00087 int coap_connection_handler_msg_prevalidate_callback_set(coap_conn_handler_t *handler, cch_func_cb *function_callback); 00088 00089 cch_func_cb *coap_connection_handler_msg_prevalidate_callback_get(coap_conn_handler_t *handler, uint16_t *listen_socket_port); 00090 00091 #endif
Generated on Tue Jul 12 2022 13:54:10 by
