in source/device_defender.c [921:958]
int aws_iotdevice_defender_config_create(
struct aws_iotdevice_defender_task_config **config_out,
struct aws_allocator *allocator,
const struct aws_byte_cursor *thing_name,
enum aws_iotdevice_defender_report_format report_format) {
AWS_PRECONDITION(config_out != NULL);
AWS_PRECONDITION(aws_allocator_is_valid(allocator));
AWS_PRECONDITION(aws_byte_cursor_is_valid(thing_name));
struct aws_iotdevice_defender_task_config *config = NULL;
if (report_format != AWS_IDDRF_JSON) {
aws_raise_error(AWS_ERROR_IOTDEVICE_DEFENDER_UNSUPPORTED_REPORT_FORMAT);
goto error_return;
}
config = aws_mem_calloc(allocator, 1, sizeof(struct aws_iotdevice_defender_task_config));
config->thing_name = aws_string_new_from_cursor(allocator, thing_name);
config->allocator = allocator;
config->report_format = report_format;
config->callback_userdata = NULL;
config->task_canceled_fn = NULL;
config->rejected_report_fn = NULL;
config->accepted_report_fn = NULL;
/* defaults here will be consistent across any language on top */
config->task_period_ns = 5ULL * 60ULL * 1000000000ULL;
aws_array_list_init_dynamic(&config->custom_metrics, allocator, 0, sizeof(struct defender_custom_metric *));
config->custom_metrics_len = 0;
*config_out = config;
return AWS_OP_SUCCESS;
error_return:
aws_mem_release(allocator, config);
return AWS_OP_ERR;
}