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.
Fork of OmniWheels by
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, 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 00042 typedef struct coap_conn_handler_s{ 00043 struct internal_socket_s *socket; 00044 00045 coap_security_keys_t *security_keys; 00046 receive_from_socket_cb *_recv_cb; 00047 send_to_socket_cb *_send_cb; 00048 get_pw_cb *_get_password_cb; 00049 security_done_cb *_security_done_cb; 00050 00051 int8_t socket_interface_selection; 00052 bool registered_to_multicast; 00053 } coap_conn_handler_t; 00054 00055 coap_conn_handler_t *connection_handler_create(receive_from_socket_cb *recv_from_cb, 00056 send_to_socket_cb *send_to_cb, 00057 get_pw_cb *pw_cb, 00058 security_done_cb *done_cb); 00059 00060 void connection_handler_destroy( coap_conn_handler_t *handler, bool multicast_group_leave); 00061 00062 void connection_handler_close_secure_connection( coap_conn_handler_t *handler, uint8_t destination_addr_ptr[static 16], uint16_t port ); 00063 00064 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); 00065 00066 //If returns -2, it means security was started and data was not send 00067 /* 00068 * \return > 0 in OK 00069 * \return 0 Session started, data not send 00070 * \return -1 failure 00071 */ 00072 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); 00073 00074 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); 00075 00076 bool coap_connection_handler_socket_belongs_to(coap_conn_handler_t *handler, int8_t socket_id); 00077 00078 int8_t coap_connection_handler_set_timeout(coap_conn_handler_t *handler, uint32_t min, uint32_t max); 00079 00080 int8_t coap_connection_handler_handshake_limits_set(uint8_t handshakes_limit, uint8_t connections_limit); 00081 00082 void coap_connection_handler_exec(uint32_t time); 00083 00084 #endif
Generated on Fri Jul 22 2022 04:53:46 by
1.7.2
