summaryrefslogtreecommitdiff
path: root/FreeRTOS-Labs/Source/FreeRTOS-IoT-Libraries/c_sdk/platform/iot_metrics.h
blob: a5ece42673524abab3cf2a5d908d6ab7ebce4694 (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
/*
 * IoT Platform V1.1.0
 * Copyright (C) 2018 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_metrics.h
 * @brief Functions for retrieving [Device Defender](@ref defender) metrics.
 *
 * The functions in this header are only required by Device Defender. They do not
 * need to be implemented if Device Defender is not used.
 */

#ifndef IOT_METRICS_H_
#define IOT_METRICS_H_

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

/* Standard includes. */
#include <stdbool.h>

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

/**
 * @functionspage{platform_metrics,platform metrics component,Metrics}
 * - @functionname{platform_metrics_function_init}
 * - @functionname{platform_metrics_function_cleanup}
 * - @functionname{platform_metrics_function_gettcpconnections}
 */

/**
 * @functionpage{IotMetrics_Init,platform_metrics,init}
 * @functionpage{IotMetrics_Cleanup,platform_metrics,cleanup}
 * @functionpage{IotMetrics_GetTcpConnections,platform_metrics,gettcpconnections}
 */

/**
 * @brief One-time initialization function for the platform metrics component.
 *
 * This function initializes the platform metrics component. <b>It must be called
 * once (and only once) before calling any other metrics or [Device Defender function]
 * (@ref defender_functions).</b> Calling this function more than once without first
 * calling @ref platform_metrics_function_cleanup may result in a crash.
 *
 * @return `true` is initialization succeeded; `false` otherwise.
 *
 * @warning No thread-safety guarantees are provided for this function.
 */
/* @[declare_platform_metrics_init] */
bool IotMetrics_Init( void );
/* @[declare_platform_metrics_init] */

/**
 * @brief One-time deinitialization function for the platform metrics component.
 *
 * This function frees resources taken in @ref platform_metrics_function_init.
 * No other metrics or [Device Defender functions](@ref defender_functions) may
 * be called unless @ref platform_metrics_function_init is called again.
 *
 * @warning No thread-safety guarantees are provided for this function.
 */
/* @[declare_platform_metrics_cleanup] */
void IotMetrics_Cleanup( void );
/* @[declare_platform_metrics_cleanup] */

/**
 * @brief Retrieve a list of active TCP connections from the system.
 *
 * The provided connections are reported by Device Defender.
 *
 * @param[in] pContext Context passed as the first parameter of `metricsCallback`.
 * @param[in] metricsCallback Called by this function to provide the list of TCP
 * connections. The list given by this function is should not be used after the
 * callback returns.
 */
/* @[declare_platform_metrics_gettcpconnections] */
void IotMetrics_GetTcpConnections( void * pContext,
                                   void ( * metricsCallback )( void *, const IotListDouble_t * ) );
/* @[declare_platform_metrics_gettcpconnections] */

#endif /* ifndef IOT_METRICS_H_ */