in iothub_client/src/iothubtransport_mqtt_common.c [3209:3279]
TRANSPORT_LL_HANDLE IoTHubTransport_MQTT_Common_Create(const IOTHUBTRANSPORT_CONFIG* config, MQTT_GET_IO_TRANSPORT get_io_transport, TRANSPORT_CALLBACKS_INFO* cb_info, void* ctx)
{
PMQTTTRANSPORT_HANDLE_DATA result;
size_t deviceIdSize;
if (config == NULL || get_io_transport == NULL || cb_info == NULL)
{
LogError("Invalid Argument config: %p, get_io_transport: %p, cb_info: %p", config, get_io_transport, cb_info);
result = NULL;
}
else if (config->auth_module_handle == NULL)
{
LogError("Invalid Argument: auth_module_handle is NULL)");
result = NULL;
}
else if (config->upperConfig == NULL ||
config->upperConfig->protocol == NULL ||
config->upperConfig->deviceId == NULL ||
((config->upperConfig->deviceKey != NULL) && (config->upperConfig->deviceSasToken != NULL)) ||
config->upperConfig->iotHubName == NULL ||
config->upperConfig->iotHubSuffix == NULL)
{
LogError("Invalid Argument: upperConfig structure contains an invalid parameter");
result = NULL;
}
else if (config->waitingToSend == NULL)
{
LogError("Invalid Argument: waitingToSend is NULL)");
result = NULL;
}
else if (((deviceIdSize = strlen(config->upperConfig->deviceId)) > 128U) || (deviceIdSize == 0))
{
LogError("Invalid Argument: DeviceId is of an invalid size");
result = NULL;
}
else if ((config->upperConfig->deviceKey != NULL) && (strlen(config->upperConfig->deviceKey) == 0))
{
LogError("Invalid Argument: deviceKey is empty");
result = NULL;
}
else if ((config->upperConfig->deviceSasToken != NULL) && (strlen(config->upperConfig->deviceSasToken) == 0))
{
LogError("Invalid Argument: deviceSasToken is empty");
result = NULL;
}
else if (strlen(config->upperConfig->iotHubName) == 0)
{
LogError("Invalid Argument: iotHubName is empty");
result = NULL;
}
else if (IoTHub_Transport_ValidateCallbacks(cb_info) != 0)
{
LogError("failure checking transport callbacks");
result = NULL;
}
else
{
result = InitializeTransportHandleData(config->upperConfig, config->waitingToSend, config->auth_module_handle, config->moduleId);
if (result != NULL)
{
result->get_io_transport = get_io_transport;
result->http_proxy_hostname = NULL;
result->http_proxy_username = NULL;
result->http_proxy_password = NULL;
result->transport_ctx = ctx;
memcpy(&result->transport_callbacks, cb_info, sizeof(TRANSPORT_CALLBACKS_INFO));
}
}
return result;
}