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
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 void *param; /* Extra parameter that will be passed to TX/RX callback functions */ 00054 00055 ns_list_link_t link; 00056 } coap_send_msg_s; 00057 00058 typedef NS_LIST_HEAD (coap_send_msg_s, link) coap_send_msg_list_t; 00059 00060 /* Structure which is stored to Linked list for message duplication detection purposes */ 00061 typedef struct coap_duplication_info_ { 00062 uint32_t timestamp; /* Tells when duplication information is stored to Linked list */ 00063 uint16_t msg_id; 00064 uint16_t packet_len; 00065 uint8_t *packet_ptr; 00066 sn_nsdl_addr_s *address; 00067 void *param; 00068 ns_list_link_t link; 00069 } coap_duplication_info_s; 00070 00071 typedef NS_LIST_HEAD (coap_duplication_info_s, link) coap_duplication_info_list_t; 00072 00073 /* Structure which is stored to Linked list for blockwise messages sending purposes */ 00074 typedef struct coap_blockwise_msg_ { 00075 uint32_t timestamp; /* Tells when Blockwise message is stored to Linked list */ 00076 00077 sn_coap_hdr_s *coap_msg_ptr; 00078 00079 void *param; 00080 uint16_t msg_id; 00081 00082 ns_list_link_t link; 00083 } coap_blockwise_msg_s; 00084 00085 typedef NS_LIST_HEAD (coap_blockwise_msg_s, link) coap_blockwise_msg_list_t; 00086 00087 /* Structure which is stored to Linked list for blockwise messages receiving purposes */ 00088 typedef struct coap_blockwise_payload_ { 00089 uint32_t timestamp; /* Tells when Payload is stored to Linked list */ 00090 00091 uint8_t addr_len; 00092 uint8_t *addr_ptr; 00093 uint16_t port; 00094 uint32_t block_number; 00095 uint8_t *token_ptr; 00096 uint8_t token_len; 00097 00098 uint16_t payload_len; 00099 uint8_t *payload_ptr; 00100 unsigned int use_size1:1; 00101 00102 ns_list_link_t link; 00103 } coap_blockwise_payload_s; 00104 00105 typedef NS_LIST_HEAD (coap_blockwise_payload_s, link) coap_blockwise_payload_list_t; 00106 00107 struct coap_s { 00108 void *(*sn_coap_protocol_malloc)(uint16_t); 00109 void (*sn_coap_protocol_free)(void *); 00110 00111 uint8_t (*sn_coap_tx_callback)(uint8_t *, uint16_t, sn_nsdl_addr_s *, void *); 00112 int8_t (*sn_coap_rx_callback)(sn_coap_hdr_s *, sn_nsdl_addr_s *, void *); 00113 00114 #if ENABLE_RESENDINGS /* If Message resending is not used at all, this part of code will not be compiled */ 00115 coap_send_msg_list_t linked_list_resent_msgs; /* Active resending messages are stored to this Linked list */ 00116 uint16_t count_resent_msgs; 00117 #endif 00118 00119 #if SN_COAP_DUPLICATION_MAX_MSGS_COUNT /* If Message duplication detection is not used at all, this part of code will not be compiled */ 00120 coap_duplication_info_list_t linked_list_duplication_msgs; /* Messages for duplicated messages detection is stored to this Linked list */ 00121 uint16_t count_duplication_msgs; 00122 #endif 00123 00124 #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 */ 00125 coap_blockwise_msg_list_t linked_list_blockwise_sent_msgs; /* Blockwise message to to be sent is stored to this Linked list */ 00126 coap_blockwise_payload_list_t linked_list_blockwise_received_payloads; /* Blockwise payload to to be received is stored to this Linked list */ 00127 #endif 00128 00129 uint32_t system_time; /* System time seconds */ 00130 uint16_t sn_coap_block_data_size; 00131 uint8_t sn_coap_resending_queue_msgs; 00132 uint32_t sn_coap_resending_queue_bytes; 00133 uint8_t sn_coap_resending_count; 00134 uint8_t sn_coap_resending_intervall; 00135 uint8_t sn_coap_duplication_buffer_size; 00136 uint8_t sn_coap_internal_block2_resp_handling; /* If this is set then coap itself sends a next GET request automatically */ 00137 }; 00138 00139 /* Utility function which performs a call to sn_coap_protocol_malloc() and memset's the result to zero. */ 00140 void *sn_coap_protocol_calloc(struct coap_s *handle, uint16_t length); 00141 00142 /* Utility function which performs a call to sn_coap_protocol_malloc() and memcopy's the source to result buffer. */ 00143 void *sn_coap_protocol_malloc_copy(struct coap_s *handle, const void *source, uint16_t length); 00144 00145 #ifdef __cplusplus 00146 } 00147 #endif 00148 00149 #endif /* SN_COAP_PROTOCOL_INTERNAL_H_ */ 00150
Generated on Tue Jul 12 2022 13:54:50 by
1.7.2