Timothy Beight / Mbed 2 deprecated 6_songs-from-the-cloud

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of 6_songs-from-the-cloud by MakingMusicWorkshop

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sn_coap_protocol_internal.h Source File

sn_coap_protocol_internal.h

Go to the documentation of this file.
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 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 struct coap_s {
00035     void *(*sn_coap_protocol_malloc)(uint16_t);
00036     void (*sn_coap_protocol_free)(void *);
00037 
00038     uint8_t (*sn_coap_tx_callback)(uint8_t *, uint16_t, sn_nsdl_addr_s *, void *);
00039     int8_t (*sn_coap_rx_callback)(sn_coap_hdr_s *, sn_nsdl_addr_s *, void *);
00040 };
00041 
00042 /* * * * * * * * * * * */
00043 /* * * * DEFINES * * * */
00044 /* * * * * * * * * * * */
00045 
00046 /* * For Message resending * */
00047 #define ENABLE_RESENDINGS                               1   /**< Enable / Disable resending from library in building */
00048 
00049 #define SN_COAP_RESENDING_MAX_COUNT                     3   /**< Default number of re-sendings  */
00050 #define SN_COAP_RESENDING_QUEUE_SIZE_MSGS               2   /**< Default re-sending queue size - defines how many messages can be stored. Setting this to 0 disables feature */
00051 #define SN_COAP_RESENDING_QUEUE_SIZE_BYTES              0   /**< Default re-sending queue size - defines size of the re-sending buffer. Setting this to 0 disables feature */
00052 #define DEFAULT_RESPONSE_TIMEOUT                        10  /**< Default re-sending timeout as seconds */
00053 
00054 /* These parameters sets maximum values application can set with API */
00055 #define SN_COAP_MAX_ALLOWED_RESENDING_COUNT             6   /**< Maximum allowed count of re-sending */
00056 #define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS    6   /**< Maximum allowed number of saved re-sending messages */
00057 #define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES   512 /**< Maximum allowed size of re-sending buffer */
00058 #define SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT            40  /**< Maximum allowed re-sending timeout */
00059 
00060 #define RESPONSE_RANDOM_FACTOR                          1   /**< Resending random factor, value is specified in IETF CoAP specification */
00061 
00062 /* * For Message duplication detecting * */
00063 
00064 /* Init value for the maximum count of messages to be stored for duplication detection          */
00065 /* Setting of this value to 0 will disable duplication check, also reduce use of ROM memory     */
00066 #ifndef SN_COAP_DUPLICATION_MAX_MSGS_COUNT
00067 #define SN_COAP_DUPLICATION_MAX_MSGS_COUNT              0
00068 #endif
00069 /* Maximum allowed number of saved messages for duplicate searching */
00070 #define SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT   6
00071 
00072 /* Maximum time in seconds of messages to be stored for duplication detection */
00073 #define SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED    60 /* RESPONSE_TIMEOUT * RESPONSE_RANDOM_FACTOR * (2 ^ MAX_RETRANSMIT - 1) + the expected maximum round trip time */
00074 
00075 /* * For Message blockwising * */
00076 
00077 /* Init value for the maximum payload size to be sent and received at one blockwise message                         */
00078 /* Setting of this value to 0 will disable this feature, and also reduce use of ROM memory                          */
00079 /* Note: Current Coap implementation supports Blockwise transfers specification version draft-ietf-core-block-03    */
00080 /* Note: This define is common for both received and sent Blockwise messages                                        */
00081 #ifndef SN_COAP_BLOCKWISE_MAX_PAYLOAD_SIZE
00082 #define SN_COAP_BLOCKWISE_MAX_PAYLOAD_SIZE          0 /**< Must be 2^x and x is at least 4. Suitable values: 0, 16, 32, 64, 128, 256, 512 and 1024 */
00083 #endif
00084 
00085 #ifndef SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
00086 #define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED      10 /**< Maximum time in seconds of data (messages and payload) to be stored for blockwising */
00087 #endif
00088 
00089 
00090 /* * * * * * * * * * * * * * */
00091 /* * * * ENUMERATIONS  * * * */
00092 /* * * * * * * * * * * * * * */
00093 
00094 /* * * * * * * * * * * * * */
00095 /* * * * STRUCTURES  * * * */
00096 /* * * * * * * * * * * * * */
00097 
00098 
00099 /* Structure which is stored to Linked list for message sending purposes */
00100 typedef struct coap_send_msg_ {
00101     uint8_t             resending_counter;  /* Tells how many times message is still tried to resend */
00102     uint32_t            resending_time;     /* Tells next resending time */
00103 
00104     sn_nsdl_transmit_s *send_msg_ptr;
00105 
00106     struct coap_s       *coap;              /* CoAP library handle */
00107     void                *param;             /* Extra parameter that will be passed to TX/RX callback functions */
00108 
00109     ns_list_link_t      link;
00110 } coap_send_msg_s;
00111 
00112 typedef NS_LIST_HEAD(coap_send_msg_s, link) coap_send_msg_list_t;
00113 
00114 /* Structure which is stored to Linked list for message duplication detection purposes */
00115 typedef struct coap_duplication_info_ {
00116     uint32_t            timestamp; /* Tells when duplication information is stored to Linked list */
00117 
00118     uint8_t             addr_len;
00119     uint8_t            *addr_ptr;
00120     uint16_t            port;
00121 
00122     uint16_t            msg_id;
00123 
00124     struct coap_s       *coap;  /* CoAP library handle */
00125 
00126     ns_list_link_t     link;
00127 } coap_duplication_info_s;
00128 
00129 typedef NS_LIST_HEAD(coap_duplication_info_s, link) coap_duplication_info_list_t;
00130 
00131 /* Structure which is stored to Linked list for blockwise messages sending purposes */
00132 typedef struct coap_blockwise_msg_ {
00133     uint32_t            timestamp;  /* Tells when Blockwise message is stored to Linked list */
00134 
00135     sn_coap_hdr_s       *coap_msg_ptr;
00136     struct coap_s       *coap;      /* CoAP library handle */
00137 
00138     ns_list_link_t     link;
00139 } coap_blockwise_msg_s;
00140 
00141 typedef NS_LIST_HEAD(coap_blockwise_msg_s, link) coap_blockwise_msg_list_t;
00142 
00143 /* Structure which is stored to Linked list for blockwise messages receiving purposes */
00144 typedef struct coap_blockwise_payload_ {
00145     uint32_t            timestamp; /* Tells when Payload is stored to Linked list */
00146 
00147     uint8_t             addr_len;
00148     uint8_t             *addr_ptr;
00149     uint16_t            port;
00150 
00151     uint16_t            payload_len;
00152     uint8_t             *payload_ptr;
00153     struct coap_s       *coap;  /* CoAP library handle */
00154 
00155     ns_list_link_t     link;
00156 } coap_blockwise_payload_s;
00157 
00158 typedef NS_LIST_HEAD(coap_blockwise_payload_s, link) coap_blockwise_payload_list_t;
00159 
00160 #ifdef __cplusplus
00161 }
00162 #endif
00163 
00164 #endif /* SN_COAP_PROTOCOL_INTERNAL_H_ */
00165 
00166