summaryrefslogtreecommitdiff
path: root/FreeRTOS-Labs/Source/FreeRTOS-IoT-Libraries/c_sdk/platform/types/iot_platform_types.h
blob: 986a1e555b86b83ed81d2d8f7845b192e038c159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
 * IoT Platform V1.1.0
 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

/**
 * @file iot_platform_types.h
 * @brief Types of the platform layer.
 */

#ifndef IOT_PLATFORM_TYPES_H_
#define IOT_PLATFORM_TYPES_H_

/* The config header is always included first. */
#include "iot_config.h"

/* Linear containers (lists and queues) include for metrics types. */
#include "iot_linear_containers.h"

/*------------------------- Thread management types -------------------------*/

/**
 * @brief A value representing the system default for new thread priority.
 */
#ifndef IOT_THREAD_DEFAULT_PRIORITY
#define IOT_THREAD_DEFAULT_PRIORITY      0
#endif

/**
 * @brief A value representing the system default for new thread stack size.
 */
#ifndef IOT_THREAD_DEFAULT_STACK_SIZE
#define IOT_THREAD_DEFAULT_STACK_SIZE    0
#endif

/**
 * @ingroup platform_datatypes_handles
 * @brief The type used to represent mutexes, configured with the type
 * `_IotSystemMutex_t`.
 *
 * For the provided ports, `_IotSystemMutex_t` will be automatically configured.
 * For other ports, `_IotSystemMutex_t` should be set in `iot_config.h`.
 *
 * Mutexes should only be released by the threads that take them.
 *
 * <b>Example</b> <br>
 * To change the type of #IotMutex_t to `long`:
 * @code{c}
 * typedef long _IotSystemMutex_t;
 * #include "iot_threads.h"
 * @endcode
 */
typedef _IotSystemMutex_t       IotMutex_t;

/**
 * @ingroup platform_datatypes_handles
 * @brief The type used to represent semaphores, configured with the type
 * `_IotSystemSemaphore_t`.
 *
 * For the provided ports, `_IotSystemSemaphore_t` will be automatically configured.
 * For other ports, `_IotSystemSemaphore_t` should be set in `iot_config.h`.
 *
 * Semaphores must be counting, and any thread may take (wait on) or release
 * (post to) a semaphore.
 *
 * <b>Example</b> <br>
 * To change the type of #IotSemaphore_t to `long`:
 * @code{c}
 * typedef long _IotSystemSemaphore_t;
 * #include "iot_threads.h"
 * @endcode
 */
typedef _IotSystemSemaphore_t   IotSemaphore_t;

/**
 * @brief Thread routine function.
 *
 * @param[in] void * The argument passed to the @ref
 * platform_threads_function_createdetachedthread. For application use.
 */
typedef void ( * IotThreadRoutine_t )( void * );

/*-------------------------- Clock and timer types --------------------------*/

/**
 * @ingroup platform_datatypes_handles
 * @brief The type used to represent timers, configured with the type
 * `_IotSystemTimer_t`.
 *
 * For the provided ports, `_IotSystemTimer_t` will be automatically configured.
 * For other ports, `_IotSystemTimer_t` should be set in `iot_config.h`.
 *
 * <b>Example</b> <br>
 * To change the type of #IotTimer_t to `long`:
 * @code{c}
 * typedef long _IotSystemTimer_t;
 * #include "iot_clock.h"
 * @endcode
 */
typedef _IotSystemTimer_t IotTimer_t;

/*--------------------------- Network stack types ---------------------------*/

/**
 * @ingroup platform_datatypes_handles
 * @brief The type used to represent network server info, configured with the
 * type `_IotNetworkServerInfo_t`.
 *
 * For the provided ports, `_IotNetworkServerInfo_t` will be automatically configured.
 * For other ports, `_IotNetworkServerInfo_t` should be set in `iot_config.h`.
 *
 * All of the provided ports configure this to #IotNetworkServerInfo, which provides
 * the necessary information to connect to a TCP peer. For other network protocols,
 * this type should be set to an alternate structure as needed by the other protocol.
 */
typedef _IotNetworkServerInfo_t IotNetworkServerInfo_t;

/**
 * @ingroup platform_datatypes_handles
 * @brief The type used to represent network credentials, configured with the
 * type `_IotNetworkCredentials_t`.
 *
 * For the provided ports, `_IotNetworkCredentials_t` will be automatically configured.
 * For other ports, `_IotNetworkCredentials_t` should be set in `iot_config.h`.
 *
 * All of the provided ports configure this to #IotNetworkCredentials, which provides
 * the necessary information to connect to a TLS server over TCP. For other network
 * protocols, this type should be set to an alternate structure as needed by the other
 * protocol.
 */
typedef _IotNetworkCredentials_t IotNetworkCredentials_t;

/**
 * @ingroup platform_datatypes_handles
 * @brief The type used to represent network connections, configured with the
 * type `_IotNetworkConnection_t`.
 *
 * For the provided ports, `_IotNetworkConnection_t` will be automatically configured.
 * For other ports, `_IotNetworkConnection_t` should be set in `iot_config.h`.
 */
typedef _IotNetworkConnection_t IotNetworkConnection_t;

/*------------------------------ Metrics types ------------------------------*/

/**
 * @brief The length of the buffer used to store IP addresses for metrics.
 *
 * This is the length of the longest IPv6 address plus space for the port number
 * and NULL terminator.
 */
#define IOT_METRICS_IP_ADDRESS_LENGTH    54

/**
 * @brief Represents a TCP connection to a remote IPv4 server.
 *
 * A list of these is provided by @ref platform_metrics_function_gettcpconnections.
 */
typedef struct IotMetricsTcpConnection
{
    IotLink_t link;         /**< @brief List link member. */
    void * pNetworkContext; /**< @brief Context that may be used by metrics or Defender. */
    size_t addressLength;   /**< @brief The length of the address stored in #IotMetricsTcpConnection_t.pRemoteAddress. */

    /**
     * @brief NULL-terminated IP address and port in text format.
     *
     * IPv4 addresses will be in the format `xxx.xxx.xxx.xxx:port`.
     * IPv6 addresses will be in the format `[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]:port`.
     */
    char pRemoteAddress[ IOT_METRICS_IP_ADDRESS_LENGTH ];
} IotMetricsTcpConnection_t;

#endif /* ifndef IOT_PLATFORM_TYPES_H_ */