AWS IoT Device SDK C: Defender
AWS IoT Device Defender library
Return to main page ↑
aws_iot_defender.h
Go to the documentation of this file.
1 /*
2  * AWS IoT Defender V3.0.0
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
28 #ifndef AWS_IOT_DEFENDER_H_
29 #define AWS_IOT_DEFENDER_H_
30 
31 /* The config header is always included first. */
32 #include "iot_config.h"
33 
34 /* Standard includes. */
35 #include <stdint.h>
36 #include <stdlib.h>
37 
38 /* MQTT include. */
39 #include "iot_mqtt.h"
40 
57 #define AWS_IOT_DEFENDER_FORMAT_CBOR 1
58 #define AWS_IOT_DEFENDER_FORMAT_JSON 2
71 #define AWS_IOT_DEFENDER_METRICS_ALL 0xffffffff
73 #define AWS_IOT_DEFENDER_METRICS_TCP_CONNECTIONS_ESTABLISHED_TOTAL 0x00000001
74 #define AWS_IOT_DEFENDER_METRICS_TCP_CONNECTIONS_ESTABLISHED_REMOTE_ADDR 0x00000004
80 #define AWS_IOT_DEFENDER_METRICS_TCP_CONNECTIONS_ESTABLISHED_CONNECTIONS \
81  ( AWS_IOT_DEFENDER_METRICS_TCP_CONNECTIONS_ESTABLISHED_REMOTE_ADDR ) \
82 
83 
87 #define AWS_IOT_DEFENDER_METRICS_TCP_CONNECTIONS_ESTABLISHED \
88  ( AWS_IOT_DEFENDER_METRICS_TCP_CONNECTIONS_ESTABLISHED_CONNECTIONS | AWS_IOT_DEFENDER_METRICS_TCP_CONNECTIONS_ESTABLISHED_TOTAL ) \
89 
90 
99 #define AWS_IOT_DEFENDER_CALLBACK_INITIALIZER \
100  { \
101  .pCallbackContext = NULL, \
102  .function = NULL \
103  }
104 #define AWS_IOT_DEFENDER_START_INFO_INITIALIZER \
105  { .pClientIdentifier = NULL, \
106  .clientIdentifierLength = 0, \
107  .mqttConnection = IOT_MQTT_CONNECTION_INITIALIZER, \
108  .callback = AWS_IOT_DEFENDER_CALLBACK_INITIALIZER \
109  }
130 typedef enum
131 {
134 
139 typedef enum
140 {
148 
153 typedef enum
154 {
160 
173 typedef struct AwsIotDefenderCallbackInfo
174 {
175  const uint8_t * pMetricsReport;
177  const uint8_t * pPayload;
178  size_t payloadLength;
181 
186 typedef struct AwsIotDefenderCallback
187 {
189  void ( * function )( void *,
190  AwsIotDefenderCallbackInfo_t * const );
192 
197 typedef struct AwsIotDefenderStartInfo
198 {
199  const char * pClientIdentifier;
204 
244 /* @[declare_defender_setmetrics] */
246  uint32_t metrics );
247 /* @[declare_defender_setmetrics] */
248 
344 /* @[declare_defender_start] */
346 /* @[declare_defender_start] */
347 
357 /* @[declare_defender_stop] */
358 void AwsIotDefender_Stop( void );
359 /* @[declare_defender_stop] */
360 
375 /* @[declare_defender_setperiod] */
376 AwsIotDefenderError_t AwsIotDefender_SetPeriod( uint32_t periodSeconds );
377 /* @[declare_defender_setperiod] */
378 
384 /* @[declare_defender_getperiod] */
385 uint32_t AwsIotDefender_GetPeriod( void );
386 /* @[declare_defender_getperiod] */
387 
393 /* @[declare_defender_strerror] */
394 const char * AwsIotDefender_strerror( AwsIotDefenderError_t error );
395 /* @[declare_defender_strerror] */
396 
402 /* @[declare_defender_EventType] */
403 const char * AwsIotDefender_EventType( AwsIotDefenderEventType_t eventType );
404 /* @[declare_defender_EventType] */
405 #endif /* AWS_IOT_DEFENDER_H_ */
size_t metricsReportLength
Definition: aws_iot_defender.h:176
uint32_t AwsIotDefender_GetPeriod(void)
Get period in seconds.
AwsIotDefenderError_t AwsIotDefender_SetPeriod(uint32_t periodSeconds)
Set period in seconds.
void AwsIotDefender_Stop(void)
Stop the defender agent.
uint16_t clientIdentifierLength
Length of IotMqttConnectInfo_t.pClientIdentifier (required).
Definition: aws_iot_defender.h:200
Definition: aws_iot_defender.h:158
User provided callback handle.
Definition: aws_iot_defender.h:186
size_t payloadLength
Definition: aws_iot_defender.h:178
Definition: aws_iot_defender.h:141
const uint8_t * pMetricsReport
Definition: aws_iot_defender.h:175
Definition: aws_iot_defender.h:145
Definition: aws_iot_defender.h:155
AwsIotDefenderEventType_t
Event codes passed into AwsIotDefenderCallbackInfo_t.
Definition: aws_iot_defender.h:153
Definition: aws_iot_defender.h:144
const char * pClientIdentifier
MQTT client identifier (required).
Definition: aws_iot_defender.h:199
const uint8_t * pPayload
Definition: aws_iot_defender.h:177
AwsIotDefenderCallback_t callback
Definition: aws_iot_defender.h:202
AwsIotDefenderError_t
Return codes of defender functions.
Definition: aws_iot_defender.h:139
struct _mqttConnection * IotMqttConnection_t
Definition: aws_iot_defender.h:142
AwsIotDefenderError_t AwsIotDefender_SetMetrics(AwsIotDefenderMetricsGroup_t metricsGroup, uint32_t metrics)
Set metrics that defender agent needs to collect for a metrics group.
const char * AwsIotDefender_EventType(AwsIotDefenderEventType_t eventType)
Return a string that describes AwsIotDefenderEventType_t.
Parameters of AwsIotDefender_Start function.
Definition: aws_iot_defender.h:197
const char * AwsIotDefender_strerror(AwsIotDefenderError_t error)
Return a string that describes AwsIotDefenderError_t.
IotMqttConnection_t mqttConnection
MQTT connection used by defender (required).
Definition: aws_iot_defender.h:201
Definition: aws_iot_defender.h:156
AwsIotDefenderError_t AwsIotDefender_Start(AwsIotDefenderStartInfo_t *pStartInfo)
Start the defender agent.
Callback parameters.
Definition: aws_iot_defender.h:173
Definition: aws_iot_defender.h:143
AwsIotDefenderMetricsGroup_t
Metrics group options for AwsIotDefender_SetMetrics() function.
Definition: aws_iot_defender.h:130
Definition: aws_iot_defender.h:157
void * pCallbackContext
Definition: aws_iot_defender.h:188
AwsIotDefenderEventType_t eventType
Definition: aws_iot_defender.h:179
Definition: aws_iot_defender.h:146
Definition: aws_iot_defender.h:132