in EAP-TLS_Solution/EAP-TLS Client/lib/eap_tls_lib.c [308:421]
EapTlsResult EapTls_DiagnoseNetwork(const char *networkName)
{
EapTlsResult iRes = EapTlsResult_Error;
if (NULL != networkName)
{
int networkID = WifiConfig_GetNetworkIdByConfigName(networkName);
if (-1 == networkID)
{
iRes = EapTlsResult_NetworkUnknown;
EapTls_Log("Cannot find network configuration '%s': errno=%d (%s)\n", networkName, errno, strerror(errno));
}
else
{
WifiConfig_NetworkDiagnostics networkDiagnostics;
int res = WifiConfig_GetNetworkDiagnostics(networkID, &networkDiagnostics);
if (-1 == res)
{
iRes = EapTlsResult_FailedDiagnosingNetwork;
EapTls_Log("Failed getting diagnostics for network '%s' - Id[%d]: errno=%d (%s)\n", networkName, networkID, errno, strerror(errno));
}
else
{
// Check the connection state, and report eventual errors
if (networkDiagnostics.isConnected)
{
iRes = EapTlsResult_Connected;
}
else
{
switch (networkDiagnostics.error)
{
case 2: // NetworkNotFound = 2 : Network was not found.
{
iRes = EapTlsResult_NetworkUnknown;
EapTls_Log("Network '%s' - Id[%d] not found!\n", networkName, networkID);
}
break;
case 5: // AuthenticationFailed = 5: Authentication failed. This error is thrown for EAP-TLS
{
// Let's attempt requesting new certificates (we already validated the certs at the first state)
switch (networkDiagnostics.certError)
{
case 101: // InvalidRootCA
{
iRes = EapTlsResult_AuthenticationError_InvalidRootCaCert;
}
break;
case 102: // InvalidClientAuth
{
iRes = EapTlsResult_AuthenticationError_InvalidClientCert;
}
break;
case 103: // UnknownClientId
{
iRes = EapTlsResult_AuthenticationError_InvalidClientIdentity;
}
break;
default:
{
iRes = EapTlsResult_AuthenticationError;
}
break;
}
EapTls_Log("Authentication error connecting to network '%s' - Id[%d]: error=%d, certError=%d\n", networkName, networkID, networkDiagnostics.error, networkDiagnostics.certError);
}
break;
case 1: // ConnectionFailed = 1 : Generic error message when connection fails.
case 3: // NoPskIncluded = 3: Network password is missing.
case 4: // WrongKey = 4: Network is using an incorrect password.
case 6: // SecurityTypeMismatch = 6: The stored network's security type does not match the available network.
case 7: // NetworkFrequencyNotAllowed = 7: Network frequency not allowed.
case 8: // NetworkNotEssPbssMbss = 8: Network is not supported because no ESS, PBSS or MBSS was detected.
case 9: // NetworkNotSupported = 9: Network is not supported.
case 10: // NetworkNonWpa = 10: Network is not WPA2PSK, WPA2EAP or Open.
{
iRes = EapTlsResult_ConnectionError;
EapTls_Log("FAILED connecting to network '%s' - Id[%d]: error=%d\n", networkName, networkID, networkDiagnostics.error);
}
break;
default:
{
EapTls_Log("ERROR connecting to network '%s' - Id[%d]: error=%d\n", networkName, networkID, networkDiagnostics.error);
if (!networkDiagnostics.isEnabled)
{
iRes = EapTlsResult_NetworkDisabled;
}
else
{
// This should never happen!
iRes = EapTlsResult_BadParameters;
}
}
break;
}
}
}
}
}
else
{
iRes = EapTlsResult_BadParameters;
}
return iRes;
}