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.
Dependencies: FXAS21002 FXOS8700Q
sn_coap_protocol_internal.h
00001 /* 00002 * Copyright (c) 2011-2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /** 00018 * \file sn_coap_protocol_internal.h 00019 * 00020 * \brief Header file for CoAP Protocol part 00021 * 00022 */ 00023 00024 #ifndef SN_COAP_PROTOCOL_INTERNAL_H_ 00025 #define SN_COAP_PROTOCOL_INTERNAL_H_ 00026 00027 #include "ns_list.h" 00028 #include "sn_coap_header_internal.h" 00029 #include "mbed-coap/sn_config.h" 00030 00031 #ifdef __cplusplus 00032 extern "C" { 00033 #endif 00034 00035 struct sn_coap_hdr_; 00036 00037 #define RESPONSE_RANDOM_FACTOR 1.5 /**< Resending random factor, value is specified in IETF CoAP specification */ 00038 00039 /* * For Option handling * */ 00040 #define COAP_OPTION_MAX_AGE_DEFAULT 60 /**< Default value of Max-Age if option not present */ 00041 #define COAP_OPTION_URI_PORT_NONE (-1) /**< Internal value to represent no Uri-Port option */ 00042 #define COAP_OPTION_BLOCK_NONE (-1) /**< Internal value to represent no Block1/2 option */ 00043 00044 int8_t prepare_blockwise_message(struct coap_s *handle, struct sn_coap_hdr_ *coap_hdr_ptr); 00045 00046 /* Structure which is stored to Linked list for message sending purposes */ 00047 typedef struct coap_send_msg_ { 00048 uint8_t resending_counter; /* Tells how many times message is still tried to resend */ 00049 uint32_t resending_time; /* Tells next resending time */ 00050 00051 sn_nsdl_transmit_s *send_msg_ptr; 00052 00053 struct coap_s *coap; /* CoAP library handle */ 00054 void *param; /* Extra parameter that will be passed to TX/RX callback functions */ 00055 00056 ns_list_link_t link; 00057 } coap_send_msg_s; 00058 00059 typedef NS_LIST_HEAD(coap_send_msg_s, link) coap_send_msg_list_t; 00060 00061 /* Structure which is stored to Linked list for message duplication detection purposes */ 00062 typedef struct coap_duplication_info_ { 00063 uint32_t timestamp; /* Tells when duplication information is stored to Linked list */ 00064 uint16_t msg_id; 00065 uint16_t packet_len; 00066 uint8_t *packet_ptr; 00067 struct coap_s *coap; /* CoAP library handle */ 00068 sn_nsdl_addr_s *address; 00069 void *param; 00070 ns_list_link_t link; 00071 } coap_duplication_info_s; 00072 00073 typedef NS_LIST_HEAD(coap_duplication_info_s, link) coap_duplication_info_list_t; 00074 00075 /* Structure which is stored to Linked list for blockwise messages sending purposes */ 00076 typedef struct coap_blockwise_msg_ { 00077 uint32_t timestamp; /* Tells when Blockwise message is stored to Linked list */ 00078 00079 sn_coap_hdr_s *coap_msg_ptr; 00080 struct coap_s *coap; /* CoAP library handle */ 00081 00082 void *param; 00083 uint16_t msg_id; 00084 00085 ns_list_link_t link; 00086 } coap_blockwise_msg_s; 00087 00088 typedef NS_LIST_HEAD(coap_blockwise_msg_s, link) coap_blockwise_msg_list_t; 00089 00090 /* Structure which is stored to Linked list for blockwise messages receiving purposes */ 00091 typedef struct coap_blockwise_payload_ { 00092 uint32_t timestamp; /* Tells when Payload is stored to Linked list */ 00093 00094 uint8_t addr_len; 00095 uint8_t *addr_ptr; 00096 uint16_t port; 00097 uint32_t block_number; 00098 uint8_t *token_ptr; 00099 uint8_t token_len; 00100 00101 uint16_t payload_len; 00102 uint8_t *payload_ptr; 00103 struct coap_s *coap; /* CoAP library handle */ 00104 00105 ns_list_link_t link; 00106 } coap_blockwise_payload_s; 00107 00108 typedef NS_LIST_HEAD(coap_blockwise_payload_s, link) coap_blockwise_payload_list_t; 00109 00110 struct coap_s { 00111 void *(*sn_coap_protocol_malloc)(uint16_t); 00112 void (*sn_coap_protocol_free)(void *); 00113 00114 uint8_t (*sn_coap_tx_callback)(uint8_t *, uint16_t, sn_nsdl_addr_s *, void *); 00115 int8_t (*sn_coap_rx_callback)(sn_coap_hdr_s *, sn_nsdl_addr_s *, void *); 00116 00117 #if ENABLE_RESENDINGS /* If Message resending is not used at all, this part of code will not be compiled */ 00118 coap_send_msg_list_t linked_list_resent_msgs; /* Active resending messages are stored to this Linked list */ 00119 uint16_t count_resent_msgs; 00120 #endif 00121 00122 #if SN_COAP_DUPLICATION_MAX_MSGS_COUNT /* If Message duplication detection is not used at all, this part of code will not be compiled */ 00123 coap_duplication_info_list_t linked_list_duplication_msgs; /* Messages for duplicated messages detection is stored to this Linked list */ 00124 uint16_t count_duplication_msgs; 00125 #endif 00126 00127 #if SN_COAP_BLOCKWISE_ENABLED || SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* If Message blockwise is not enabled, this part of code will not be compiled */ 00128 coap_blockwise_msg_list_t linked_list_blockwise_sent_msgs; /* Blockwise message to to be sent is stored to this Linked list */ 00129 coap_blockwise_payload_list_t linked_list_blockwise_received_payloads; /* Blockwise payload to to be received is stored to this Linked list */ 00130 #endif 00131 00132 uint32_t system_time; /* System time seconds */ 00133 uint16_t sn_coap_block_data_size; 00134 uint8_t sn_coap_resending_queue_msgs; 00135 uint32_t sn_coap_resending_queue_bytes; 00136 uint8_t sn_coap_resending_count; 00137 uint8_t sn_coap_resending_intervall; 00138 uint8_t sn_coap_duplication_buffer_size; 00139 uint8_t sn_coap_internal_block2_resp_handling; /* If this is set then coap itself sends a next GET request automatically */ 00140 }; 00141 00142 #ifdef __cplusplus 00143 } 00144 #endif 00145 00146 #endif /* SN_COAP_PROTOCOL_INTERNAL_H_ */ 00147
Generated on Tue Jul 12 2022 20:21:03 by
