return FALSE;
}
-static int __net_extract_common_info(const char *key, GVariant *variant, net_profile_info_s* ProfInfo)
-{
- __NETWORK_FUNC_ENTER__;
+static inline int _net_extract_cinfo_state(const gchar *value)
+{
+ if (g_strcmp0(value, "idle") == 0)
+ return NET_STATE_TYPE_IDLE;
+ else if (g_strcmp0(value, "failure") == 0)
+ return NET_STATE_TYPE_FAILURE;
+ else if (g_strcmp0(value, "association") == 0)
+ return NET_STATE_TYPE_ASSOCIATION;
+ else if (g_strcmp0(value, "configuration") == 0)
+ return NET_STATE_TYPE_CONFIGURATION;
+ else if (g_strcmp0(value, "ready") == 0)
+ return NET_STATE_TYPE_READY;
+ else if (g_strcmp0(value, "disconnect") == 0)
+ return NET_STATE_TYPE_DISCONNECT;
+ else if (g_strcmp0(value, "online") == 0)
+ return NET_STATE_TYPE_ONLINE;
+ else
+ return NET_STATE_TYPE_UNKNOWN;
+}
+
+static inline int _net_extract_cinfo_error(const gchar *value)
+{
+ if (g_strcmp0(value, "invalid-key") == 0)
+ return NET_STATE_ERROR_INVALID_KEY;
+ else if (g_strcmp0(value, "connect-failed") == 0)
+ return NET_STATE_ERROR_CONNECT_FAILED;
+ else if (g_strcmp0(value, "auth-failed") == 0)
+ return NET_STATE_ERROR_AUTH_FAILED;
+ else if (g_strcmp0(value, "login-failed") == 0)
+ return NET_STATE_ERROR_LOGIN_FAILED;
+ else if (g_strcmp0(value, "dhcp-failed") == 0)
+ return NET_STATE_ERROR_DHCP_FAILED;
+ else if (g_strcmp0(value, "out-of-range") == 0)
+ return NET_STATE_ERROR_OUT_OF_RANGE;
+ else if (g_strcmp0(value, "pin-missing") == 0)
+ return NET_STATE_ERROR_PIN_MISSING;
+ else
+ return NET_STATE_ERROR_NONE;
+}
- net_err_e Error = NET_ERR_NONE;
- const gchar *subKey = NULL;
+static inline void _net_extract_cinfo_ethernet(GVariant *variant, net_dev_info_s *net_info)
+{
+ GVariant *var = NULL;
+ GVariantIter *iter = NULL;
const gchar *value = NULL;
- net_dev_info_s* net_info = NULL;
+ const gchar *subKey = NULL;
+
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Interface") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(net_info->DevName, value, NET_MAX_DEVICE_NAME_LEN);
+ } else if (g_strcmp0(subKey, "Address") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(net_info->MacAddr, value, WIFI_MAC_ADDR_LEN + 1);
+ }
+ }
+ g_variant_iter_free(iter);
+}
+
+static inline void _net_extract_cinfo_ipv4(GVariant *variant, net_dev_info_s *net_info)
+{
GVariant *var = NULL;
GVariantIter *iter = NULL;
+ const gchar *value = NULL;
+ const gchar *subKey = NULL;
- net_info = &(ProfInfo->net_info);
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Method") == 0) {
+ value = g_variant_get_string(var, NULL);
- if (g_strcmp0(key, "State") == 0) {
- value = g_variant_get_string(variant, NULL);
+ if (g_strcmp0(value, "dhcp") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
+ else if (g_strcmp0(value, "manual") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
+ else if (g_strcmp0(value, "fixed") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_FIXED;
+ else if (g_strcmp0(value, "off") == 0)
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_OFF;
+
+ if (net_info->IpConfigType != NET_IP_CONFIG_TYPE_DYNAMIC) {
+ net_info->BServerAddr = FALSE;
+ net_info->ServerAddr.Type = NET_ADDR_IPV4;
+ net_info->ServerAddr.Data.Ipv4.s_addr = 0;
+ }
- if (g_strcmp0(value, "idle") == 0)
- ProfInfo->ProfileState = NET_STATE_TYPE_IDLE;
- else if (g_strcmp0(value, "failure") == 0)
- ProfInfo->ProfileState = NET_STATE_TYPE_FAILURE;
- else if (g_strcmp0(value, "association") == 0)
- ProfInfo->ProfileState = NET_STATE_TYPE_ASSOCIATION;
- else if (g_strcmp0(value, "configuration") == 0)
- ProfInfo->ProfileState = NET_STATE_TYPE_CONFIGURATION;
- else if (g_strcmp0(value, "ready") == 0)
- ProfInfo->ProfileState = NET_STATE_TYPE_READY;
- else if (g_strcmp0(value, "disconnect") == 0)
- ProfInfo->ProfileState = NET_STATE_TYPE_DISCONNECT;
- else if (g_strcmp0(value, "online") == 0)
- ProfInfo->ProfileState = NET_STATE_TYPE_ONLINE;
- else
- ProfInfo->ProfileState = NET_STATE_TYPE_UNKNOWN;
- } else if (g_strcmp0(key, "Error") == 0) {
- value = g_variant_get_string(variant, NULL);
+ } else if (g_strcmp0(subKey, "Address") == 0) {
+ value = g_variant_get_string(var, NULL);
- if (g_strcmp0(value, "invalid-key") == 0)
- ProfInfo->ProfileErrorState = NET_STATE_ERROR_INVALID_KEY;
- else if (g_strcmp0(value, "connect-failed") == 0)
- ProfInfo->ProfileErrorState = NET_STATE_ERROR_CONNECT_FAILED;
- else if (g_strcmp0(value, "auth-failed") == 0)
- ProfInfo->ProfileErrorState = NET_STATE_ERROR_AUTH_FAILED;
- else if (g_strcmp0(value, "login-failed") == 0)
- ProfInfo->ProfileErrorState = NET_STATE_ERROR_LOGIN_FAILED;
- else if (g_strcmp0(value, "dhcp-failed") == 0)
- ProfInfo->ProfileErrorState = NET_STATE_ERROR_DHCP_FAILED;
- else if (g_strcmp0(value, "out-of-range") == 0)
- ProfInfo->ProfileErrorState = NET_STATE_ERROR_OUT_OF_RANGE;
- else if (g_strcmp0(value, "pin-missing") == 0)
- ProfInfo->ProfileErrorState = NET_STATE_ERROR_PIN_MISSING;
- } else if (g_strcmp0(key, "Favorite") == 0) {
- gboolean val = g_variant_get_boolean(variant);
+ __net_extract_ip(value, &net_info->IpAddr);
+ } else if (g_strcmp0(subKey, "Netmask") == 0) {
+ value = g_variant_get_string(var, NULL);
- if (val)
- ProfInfo->Favourite = (char)TRUE;
- else
- ProfInfo->Favourite = (char)FALSE;
- } else if (g_strcmp0(key, "Ethernet") == 0) {
- g_variant_get(variant, "a{sv}", &iter);
- while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
- if (g_strcmp0(subKey, "Interface") == 0) {
- value = g_variant_get_string(var, NULL);
+ __net_extract_ip(value, &net_info->SubnetMask);
+ net_info->PrefixLen = __net_get_prefix_len(value);
+ net_info->BNetmask = TRUE;
+ } else if (g_strcmp0(subKey, "Gateway") == 0) {
+ value = g_variant_get_string(var, NULL);
- if (value != NULL)
- g_strlcpy(net_info->DevName, value, NET_MAX_DEVICE_NAME_LEN);
- } else if (g_strcmp0(subKey, "Address") == 0) {
- value = g_variant_get_string(var, NULL);
+ __net_extract_ip(value, &net_info->GatewayAddr);
+ net_info->BDefGateway = TRUE;
+ } else if (g_strcmp0(subKey, "DHCPServerIP") == 0) {
+ value = g_variant_get_string(var, NULL);
- if (value != NULL)
- g_strlcpy(net_info->MacAddr, value, WIFI_MAC_ADDR_LEN + 1);
- }
+ __net_extract_ip(value, &net_info->ServerAddr);
+ net_info->BServerAddr = TRUE;
+ } else if (g_strcmp0(subKey, "DHCPLeaseDuration") == 0) {
+ net_info->DHCPLeaseDuration = g_variant_get_int32(var);
}
- g_variant_iter_free(iter);
- } else if (g_strcmp0(key, "IPv4") == 0) {
+ }
+ g_variant_iter_free(iter);
+}
+
+static inline void _net_extract_cinfo_ipv4_configuration(GVariant *variant, net_dev_info_s *net_info)
+{
+ GVariant *var = NULL;
+ GVariantIter *iter = NULL;
+ const gchar *value = NULL;
+ const gchar *subKey = NULL;
+
+ if (net_info->IpConfigType != NET_IP_CONFIG_TYPE_DYNAMIC &&
+ net_info->IpConfigType != NET_IP_CONFIG_TYPE_STATIC &&
+ net_info->IpConfigType != NET_IP_CONFIG_TYPE_FIXED &&
+ net_info->IpConfigType != NET_IP_CONFIG_TYPE_OFF) {
+
g_variant_get(variant, "a{sv}", &iter);
while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
if (g_strcmp0(subKey, "Method") == 0) {
else if (g_strcmp0(value, "off") == 0)
net_info->IpConfigType = NET_IP_CONFIG_TYPE_OFF;
- if (net_info->IpConfigType != NET_IP_CONFIG_TYPE_DYNAMIC) {
- net_info->BServerAddr = FALSE;
- net_info->ServerAddr.Type = NET_ADDR_IPV4;
- net_info->ServerAddr.Data.Ipv4.s_addr = 0;
- }
-
- } else if (g_strcmp0(subKey, "Address") == 0) {
+ } else if (g_strcmp0(subKey, "Address") == 0 &&
+ net_info->IpAddr.Data.Ipv4.s_addr == 0) {
value = g_variant_get_string(var, NULL);
__net_extract_ip(value, &net_info->IpAddr);
- } else if (g_strcmp0(subKey, "Netmask") == 0) {
+ } else if (g_strcmp0(subKey, "Netmask") == 0 &&
+ net_info->SubnetMask.Data.Ipv4.s_addr == 0) {
value = g_variant_get_string(var, NULL);
__net_extract_ip(value, &net_info->SubnetMask);
net_info->PrefixLen = __net_get_prefix_len(value);
net_info->BNetmask = TRUE;
- } else if (g_strcmp0(subKey, "Gateway") == 0) {
+ } else if (g_strcmp0(subKey, "Gateway") == 0 &&
+ net_info->GatewayAddr.Data.Ipv4.s_addr == 0) {
value = g_variant_get_string(var, NULL);
__net_extract_ip(value, &net_info->GatewayAddr);
net_info->BDefGateway = TRUE;
- } else if (g_strcmp0(subKey, "DHCPServerIP") == 0) {
- value = g_variant_get_string(var, NULL);
-
- __net_extract_ip(value, &net_info->ServerAddr);
- net_info->BServerAddr = TRUE;
- } else if (g_strcmp0(subKey, "DHCPLeaseDuration") == 0) {
- net_info->DHCPLeaseDuration = g_variant_get_int32(var);
}
}
g_variant_iter_free(iter);
- } else if (g_strcmp0(key, "IPv4.Configuration") == 0) {
- if (net_info->IpConfigType != NET_IP_CONFIG_TYPE_DYNAMIC &&
- net_info->IpConfigType != NET_IP_CONFIG_TYPE_STATIC &&
- net_info->IpConfigType != NET_IP_CONFIG_TYPE_FIXED &&
- net_info->IpConfigType != NET_IP_CONFIG_TYPE_OFF) {
-
- g_variant_get(variant, "a{sv}", &iter);
- while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
- if (g_strcmp0(subKey, "Method") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (g_strcmp0(value, "dhcp") == 0)
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
- else if (g_strcmp0(value, "manual") == 0)
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
- else if (g_strcmp0(value, "fixed") == 0)
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_FIXED;
- else if (g_strcmp0(value, "off") == 0)
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_OFF;
-
- } else if (g_strcmp0(subKey, "Address") == 0 &&
- net_info->IpAddr.Data.Ipv4.s_addr == 0) {
- value = g_variant_get_string(var, NULL);
-
- __net_extract_ip(value, &net_info->IpAddr);
- } else if (g_strcmp0(subKey, "Netmask") == 0 &&
- net_info->SubnetMask.Data.Ipv4.s_addr == 0) {
- value = g_variant_get_string(var, NULL);
-
- __net_extract_ip(value, &net_info->SubnetMask);
- net_info->PrefixLen = __net_get_prefix_len(value);
- net_info->BNetmask = TRUE;
- } else if (g_strcmp0(subKey, "Gateway") == 0 &&
- net_info->GatewayAddr.Data.Ipv4.s_addr == 0) {
- value = g_variant_get_string(var, NULL);
-
- __net_extract_ip(value, &net_info->GatewayAddr);
- net_info->BDefGateway = TRUE;
- }
- }
- g_variant_iter_free(iter);
- }
- } else if (g_strcmp0(key, "IPv6") == 0) {
- g_variant_get(variant, "a{sv}", &iter);
- while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
- if (g_strcmp0(subKey, "Method") == 0) {
- value = g_variant_get_string(var, NULL);
+ }
+}
- if (g_strcmp0(value, "manual") == 0)
- net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_STATIC;
- else if (g_strcmp0(value, "off") == 0)
- net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_OFF;
- else if (g_strcmp0(value, "auto") == 0)
- net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_AUTO_IP;
+static inline void _net_extract_cinfo_ipv6(GVariant *variant, net_dev_info_s *net_info)
+{
+ GVariant *var = NULL;
+ GVariantIter *iter = NULL;
+ const gchar *value = NULL;
+ const gchar *subKey = NULL;
- } else if (g_strcmp0(subKey, "Address") == 0) {
- value = g_variant_get_string(var, NULL);
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Method") == 0) {
+ value = g_variant_get_string(var, NULL);
- inet_pton(AF_INET6, value, &net_info->IpAddr6.Data.Ipv6);
- } else if (g_strcmp0(subKey, "PrefixLength") == 0) {
- net_info->PrefixLen6 = g_variant_get_byte(var);
- } else if (g_strcmp0(subKey, "Gateway") == 0) {
- value = g_variant_get_string(var, NULL);
+ if (g_strcmp0(value, "manual") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_STATIC;
+ else if (g_strcmp0(value, "off") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_OFF;
+ else if (g_strcmp0(value, "auto") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_AUTO_IP;
- inet_pton(AF_INET6, value, &net_info->GatewayAddr6.Data.Ipv6);
- net_info->BDefGateway6 = TRUE;
- } else if (g_strcmp0(subKey, "Privacy") == 0) {
- value = g_variant_get_string(var, NULL);
+ } else if (g_strcmp0(subKey, "Address") == 0) {
+ value = g_variant_get_string(var, NULL);
- if (value != NULL)
- g_strlcpy(net_info->Privacy6, value, NET_IPV6_MAX_PRIVACY_LEN);
- }
+ inet_pton(AF_INET6, value, &net_info->IpAddr6.Data.Ipv6);
+ } else if (g_strcmp0(subKey, "PrefixLength") == 0) {
+ net_info->PrefixLen6 = g_variant_get_byte(var);
+ } else if (g_strcmp0(subKey, "Gateway") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ inet_pton(AF_INET6, value, &net_info->GatewayAddr6.Data.Ipv6);
+ net_info->BDefGateway6 = TRUE;
+ } else if (g_strcmp0(subKey, "Privacy") == 0) {
+ value = g_variant_get_string(var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(net_info->Privacy6, value, NET_IPV6_MAX_PRIVACY_LEN);
}
- g_variant_iter_free(iter);
- } else if (g_strcmp0(key, "IPv6.Configuration") == 0) {
- g_variant_get(variant, "a{sv}", &iter);
- while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
- if (g_strcmp0(subKey, "Method") == 0) {
- value = g_variant_get_string(var, NULL);
+ }
+ g_variant_iter_free(iter);
+}
- if (g_strcmp0(value, "manual") == 0)
- net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_STATIC;
- else if (g_strcmp0(value, "off") == 0)
- net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_OFF;
- else if (g_strcmp0(value, "auto") == 0)
- net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_AUTO_IP;
+static inline void _net_extract_cinfo_ipv6_configuration(GVariant *variant, net_dev_info_s *net_info)
+{
+ GVariant *var = NULL;
+ GVariantIter *iter = NULL;
+ const gchar *value = NULL;
+ const gchar *subKey = NULL;
- } else if (g_strcmp0(subKey, "Address") == 0) {
- value = g_variant_get_string(var, NULL);
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Method") == 0) {
+ value = g_variant_get_string(var, NULL);
- inet_pton(AF_INET6, value, &net_info->IpAddr6.Data.Ipv6);
- } else if (g_strcmp0(subKey, "PrefixLength") == 0) {
- net_info->PrefixLen6 = g_variant_get_byte(var);
- } else if (g_strcmp0(subKey, "Gateway") == 0) {
- value = g_variant_get_string(var, NULL);
+ if (g_strcmp0(value, "manual") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_STATIC;
+ else if (g_strcmp0(value, "off") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_OFF;
+ else if (g_strcmp0(value, "auto") == 0)
+ net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_AUTO_IP;
- inet_pton(AF_INET6, value, &net_info->GatewayAddr6.Data.Ipv6);
- net_info->BDefGateway6 = TRUE;
- } else if (g_strcmp0(subKey, "Privacy") == 0) {
- value = g_variant_get_string(var, NULL);
+ } else if (g_strcmp0(subKey, "Address") == 0) {
+ value = g_variant_get_string(var, NULL);
- if (value != NULL)
- g_strlcpy(net_info->Privacy6, value, NET_IPV6_MAX_PRIVACY_LEN);
- }
- }
- g_variant_iter_free(iter);
- } else if (g_strcmp0(key, "Nameservers") == 0) {
- int dnsCount = 0;
- int dnsCount6 = 0;
- gchar *dns_value = NULL;
- gchar *dns_type = NULL;
-
- g_variant_get(variant, "as", &iter);
-
- while (g_variant_iter_loop(iter, "s", &dns_value)) {
- if (__net_check_address_type(AF_INET6, dns_value)) {
- if (dnsCount6 < NET_DNS_ADDR_MAX) {
- net_info->DnsAddr6[dnsCount6].Type =
- NET_ADDR_IPV6;
- inet_pton(AF_INET6, dns_value,
- &net_info->DnsAddr6[dnsCount6]\
- .Data.Ipv6);
- dnsCount6++;
- }
- } else if (__net_check_address_type(AF_INET, dns_value)) {
- if (dnsCount < NET_DNS_ADDR_MAX) {
- net_info->DnsAddr[dnsCount].Type =
- NET_ADDR_IPV4;
- __net_extract_ip(dns_value,
- &net_info->DnsAddr[dnsCount]);
- dnsCount++;
- }
- } else { /* DNS Type */
- dns_type = g_strdup(dns_value);
- if (g_strcmp0(dns_type, "ipv4.manual") == 0)
- net_info->DnsConfigType =
- NET_DNS_CONFIG_TYPE_STATIC;
- else if (g_strcmp0(dns_type, "ipv4.dhcp") == 0)
- net_info->DnsConfigType =
- NET_DNS_CONFIG_TYPE_DYNAMIC;
- if (g_strcmp0(dns_type, "ipv6.manual") == 0)
- net_info->DnsConfigType6 =
- NET_DNS_CONFIG_TYPE_STATIC;
- else if (g_strcmp0(dns_type, "ipv6.dhcp") == 0)
- net_info->DnsConfigType6 =
- NET_DNS_CONFIG_TYPE_DYNAMIC;
- g_free(dns_type);
- }
- }
- g_variant_iter_free(iter);
+ inet_pton(AF_INET6, value, &net_info->IpAddr6.Data.Ipv6);
+ } else if (g_strcmp0(subKey, "PrefixLength") == 0) {
+ net_info->PrefixLen6 = g_variant_get_byte(var);
+ } else if (g_strcmp0(subKey, "Gateway") == 0) {
+ value = g_variant_get_string(var, NULL);
- net_info->DnsCount = dnsCount;
- net_info->DnsCount6 = dnsCount6;
- } else if (g_strcmp0(key, "Nameservers.Configuration") == 0 && net_info->DnsCount == 0) {
- int dnsCount = 0;
- int dnsCount6 = 0;
- gchar *dns_value = NULL;
- gchar *dns_type = NULL;
-
- g_variant_get(variant, "as", &iter);
-
- while (g_variant_iter_loop(iter, "s", &dns_value)) {
- if (__net_check_address_type(AF_INET6, dns_value)) {
- if (dnsCount6 < NET_DNS_ADDR_MAX) {
- net_info->DnsAddr6[dnsCount6].Type =
- NET_ADDR_IPV6;
- inet_pton(AF_INET6, dns_value,
- &net_info->DnsAddr6[dnsCount6]\
- .Data.Ipv6);
- dnsCount6++;
- }
- } else if (__net_check_address_type(AF_INET, dns_value)) {
- if (dnsCount < NET_DNS_ADDR_MAX) {
- net_info->DnsAddr[dnsCount].Type =
- NET_ADDR_IPV4;
- __net_extract_ip(dns_value,
- &net_info->DnsAddr[dnsCount]);
- dnsCount++;
- }
- } else { /* DNS Type */
- dns_type = g_strdup(dns_value);
- if (g_strcmp0(dns_type, "ipv4.manual") == 0)
- net_info->DnsConfigType =
- NET_DNS_CONFIG_TYPE_STATIC;
- else if (g_strcmp0(dns_type, "ipv4.dhcp") == 0)
- net_info->DnsConfigType =
- NET_DNS_CONFIG_TYPE_DYNAMIC;
- if (g_strcmp0(dns_type, "ipv6.manual") == 0)
- net_info->DnsConfigType6 =
- NET_DNS_CONFIG_TYPE_STATIC;
- else if (g_strcmp0(dns_type, "ipv6.dhcp") == 0)
- net_info->DnsConfigType6 =
- NET_DNS_CONFIG_TYPE_DYNAMIC;
- g_free(dns_type);
- }
- }
- g_variant_iter_free(iter);
+ inet_pton(AF_INET6, value, &net_info->GatewayAddr6.Data.Ipv6);
+ net_info->BDefGateway6 = TRUE;
+ } else if (g_strcmp0(subKey, "Privacy") == 0) {
+ value = g_variant_get_string(var, NULL);
- net_info->DnsCount = dnsCount;
- net_info->DnsCount6 = dnsCount6;
- } else if (g_strcmp0(key, "Domains") == 0) {
- } else if (g_strcmp0(key, "Domains.Configuration") == 0) {
- } else if (g_strcmp0(key, "Proxy") == 0) {
- const gchar *url = NULL;
- gchar *servers = NULL;
+ if (value != NULL)
+ g_strlcpy(net_info->Privacy6, value, NET_IPV6_MAX_PRIVACY_LEN);
+ }
+ }
+ g_variant_iter_free(iter);
+}
- g_variant_get(variant, "a{sv}", &iter);
- while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
- if (g_strcmp0(subKey, "Method") == 0) {
- value = g_variant_get_string(var, NULL);
+static void _net_extract_cinfo_nameservers(GVariant *variant, net_dev_info_s *net_info)
+{
+ int dnsCount = 0;
+ int dnsCount6 = 0;
+ gchar *dns_value = NULL;
+ gchar *dns_type = NULL;
+ GVariantIter *iter = NULL;
- if (g_strcmp0(value, "direct") == 0)
- net_info->ProxyMethod = NET_PROXY_TYPE_DIRECT;
- else if (g_strcmp0(value, "auto") == 0)
- net_info->ProxyMethod = NET_PROXY_TYPE_AUTO;
- else if (g_strcmp0(value, "manual") == 0)
- net_info->ProxyMethod = NET_PROXY_TYPE_MANUAL;
- else
- net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN;
- } else if (g_strcmp0(subKey, "URL") == 0) {
- url = g_variant_get_string(var, NULL);
- } else if (g_strcmp0(subKey, "Servers") == 0) {
- GVariantIter *iter_sub = NULL;
-
- g_variant_get(var, "as", &iter_sub);
- if (!g_variant_iter_loop(iter_sub, "s", &servers))
- WIFI_LOG(WIFI_ERROR, "There was no value");
- g_variant_iter_free(iter_sub);
+ g_variant_get(variant, "as", &iter);
+ while (g_variant_iter_loop(iter, "s", &dns_value)) {
+ if (__net_check_address_type(AF_INET6, dns_value)) {
+ if (dnsCount6 < NET_DNS_ADDR_MAX) {
+ net_info->DnsAddr6[dnsCount6].Type = NET_ADDR_IPV6;
+ inet_pton(AF_INET6, dns_value,
+ &net_info->DnsAddr6[dnsCount6].Data.Ipv6);
+ dnsCount6++;
}
+ } else if (__net_check_address_type(AF_INET, dns_value)) {
+ if (dnsCount < NET_DNS_ADDR_MAX) {
+ net_info->DnsAddr[dnsCount].Type = NET_ADDR_IPV4;
+ __net_extract_ip(dns_value, &net_info->DnsAddr[dnsCount]);
+ dnsCount++;
+ }
+ } else { /* DNS Type */
+ dns_type = g_strdup(dns_value);
+ if (g_strcmp0(dns_type, "ipv4.manual") == 0)
+ net_info->DnsConfigType = NET_DNS_CONFIG_TYPE_STATIC;
+ else if (g_strcmp0(dns_type, "ipv4.dhcp") == 0)
+ net_info->DnsConfigType = NET_DNS_CONFIG_TYPE_DYNAMIC;
+ if (g_strcmp0(dns_type, "ipv6.manual") == 0)
+ net_info->DnsConfigType6 = NET_DNS_CONFIG_TYPE_STATIC;
+ else if (g_strcmp0(dns_type, "ipv6.dhcp") == 0)
+ net_info->DnsConfigType6 = NET_DNS_CONFIG_TYPE_DYNAMIC;
+ g_free(dns_type);
}
- g_variant_iter_free(iter);
+ }
+ g_variant_iter_free(iter);
- if (net_info->ProxyMethod == NET_PROXY_TYPE_AUTO && url != NULL)
- g_strlcpy(net_info->ProxyAddr, url, NET_PROXY_LEN_MAX);
- else if (net_info->ProxyMethod == NET_PROXY_TYPE_MANUAL && servers != NULL)
- g_strlcpy(net_info->ProxyAddr, servers, NET_PROXY_LEN_MAX);
+ net_info->DnsCount = dnsCount;
+ net_info->DnsCount6 = dnsCount6;
+}
- if (servers)
- g_free(servers);
- } else if (g_strcmp0(key, "Proxy.Configuration") == 0 &&
- net_info->ProxyMethod != NET_PROXY_TYPE_AUTO &&
- net_info->ProxyMethod != NET_PROXY_TYPE_MANUAL) {
+static void _net_extract_cinfo_proxy(GVariant *variant, net_dev_info_s *net_info)
+{
+ GVariant *var = NULL;
+ GVariantIter *iter = NULL;
+ const gchar *value = NULL;
+ const gchar *subKey = NULL;
+ const gchar *url = NULL;
+ gchar *servers = NULL;
- const gchar *url = NULL;
- gchar *servers = NULL;
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "Method") == 0) {
+ value = g_variant_get_string(var, NULL);
- g_variant_get(variant, "a{sv}", &iter);
- while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
- if (g_strcmp0(subKey, "Method") == 0) {
- value = g_variant_get_string(var, NULL);
+ if (g_strcmp0(value, "direct") == 0)
+ net_info->ProxyMethod = NET_PROXY_TYPE_DIRECT;
+ else if (g_strcmp0(value, "auto") == 0)
+ net_info->ProxyMethod = NET_PROXY_TYPE_AUTO;
+ else if (g_strcmp0(value, "manual") == 0)
+ net_info->ProxyMethod = NET_PROXY_TYPE_MANUAL;
+ else
+ net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN;
+ } else if (g_strcmp0(subKey, "URL") == 0) {
+ url = g_variant_get_string(var, NULL);
+ } else if (g_strcmp0(subKey, "Servers") == 0) {
+ GVariantIter *iter_sub = NULL;
- if (g_strcmp0(value, "direct") == 0)
- net_info->ProxyMethod = NET_PROXY_TYPE_DIRECT;
- else if (g_strcmp0(value, "auto") == 0)
- net_info->ProxyMethod = NET_PROXY_TYPE_AUTO;
- else if (g_strcmp0(value, "manual") == 0)
- net_info->ProxyMethod = NET_PROXY_TYPE_MANUAL;
- else
- net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN;
- } else if (g_strcmp0(subKey, "URL") == 0) {
- url = g_variant_get_string(var, NULL);
- } else if (g_strcmp0(subKey, "Servers") == 0) {
- GVariantIter *iter_sub = NULL;
+ g_variant_get(var, "as", &iter_sub);
+ if (!g_variant_iter_loop(iter_sub, "s", &servers))
+ WIFI_LOG(WIFI_ERROR, "There was no value");
+ g_variant_iter_free(iter_sub);
+ }
+ }
+ g_variant_iter_free(iter);
- g_variant_get(var, "as", &iter_sub);
- if (!g_variant_iter_loop(iter_sub, "s", &servers))
- WIFI_LOG(WIFI_ERROR, "There was no value");
+ if (net_info->ProxyMethod == NET_PROXY_TYPE_AUTO && url != NULL)
+ g_strlcpy(net_info->ProxyAddr, url, NET_PROXY_LEN_MAX);
+ else if (net_info->ProxyMethod == NET_PROXY_TYPE_MANUAL && servers != NULL)
+ g_strlcpy(net_info->ProxyAddr, servers, NET_PROXY_LEN_MAX);
- g_variant_iter_free(iter_sub);
- }
- }
- g_variant_iter_free(iter);
+ if (servers)
+ g_free(servers);
+}
- if (net_info->ProxyMethod == NET_PROXY_TYPE_AUTO && url != NULL)
- g_strlcpy(net_info->ProxyAddr, url, NET_PROXY_LEN_MAX);
- else if (net_info->ProxyMethod == NET_PROXY_TYPE_MANUAL && servers != NULL)
- g_strlcpy(net_info->ProxyAddr, servers, NET_PROXY_LEN_MAX);
+static int __net_extract_common_info(const char *key, GVariant *variant, net_profile_info_s* ProfInfo)
+{
+ __NETWORK_FUNC_ENTER__;
- if (servers)
- g_free(servers);
+ const gchar *value = NULL;
+ net_dev_info_s* net_info = NULL;
+
+ net_info = &(ProfInfo->net_info);
+
+ if (g_strcmp0(key, "State") == 0) {
+ value = g_variant_get_string(variant, NULL);
+ ProfInfo->ProfileState = _net_extract_cinfo_state(value);
+ } else if (g_strcmp0(key, "Error") == 0) {
+ value = g_variant_get_string(variant, NULL);
+ ProfInfo->ProfileErrorState = _net_extract_cinfo_error(value);
+ } else if (g_strcmp0(key, "Favorite") == 0) {
+ gboolean val = g_variant_get_boolean(variant);
+ ProfInfo->Favourite = (val) ? (char)TRUE : (char)FALSE;
+ } else if (g_strcmp0(key, "Ethernet") == 0) {
+ _net_extract_cinfo_ethernet(variant, net_info);
+ } else if (g_strcmp0(key, "IPv4") == 0) {
+ _net_extract_cinfo_ipv4(variant, net_info);
+ } else if (g_strcmp0(key, "IPv4.Configuration") == 0) {
+ _net_extract_cinfo_ipv4_configuration(variant, net_info);
+ } else if (g_strcmp0(key, "IPv6") == 0) {
+ _net_extract_cinfo_ipv6(variant, net_info);
+ } else if (g_strcmp0(key, "IPv6.Configuration") == 0) {
+ _net_extract_cinfo_ipv6_configuration(variant, net_info);
+ } else if (g_strcmp0(key, "Nameservers") == 0) {
+ _net_extract_cinfo_nameservers(variant, net_info);
+ } else if (g_strcmp0(key, "Nameservers.Configuration") == 0
+ && net_info->DnsCount == 0) {
+ _net_extract_cinfo_nameservers(variant, net_info);
+ } else if (g_strcmp0(key, "Domains") == 0) {
+ } else if (g_strcmp0(key, "Domains.Configuration") == 0) {
+ } else if (g_strcmp0(key, "Proxy") == 0) {
+ _net_extract_cinfo_proxy(variant, net_info);
+ } else if (g_strcmp0(key, "Proxy.Configuration") == 0
+ && net_info->ProxyMethod != NET_PROXY_TYPE_AUTO
+ && net_info->ProxyMethod != NET_PROXY_TYPE_MANUAL) {
+ _net_extract_cinfo_proxy(variant, net_info);
} else if (g_strcmp0(key, "Provider") == 0) {
/* Do noting */
}
__NETWORK_FUNC_EXIT__;
- return Error;
+ return NET_ERR_NONE;
}
static wlan_eap_type_e __convert_eap_type_from_string(const char *eap_type)
return Error;
}
-static int __net_extract_wifi_info(GVariantIter *array, net_profile_info_s* ProfInfo)
+static inline int _net_extract_winfo_mode(const gchar *value)
+{
+ if (g_strcmp0(value, "managed") == 0)
+ return NET_WLAN_CONNMODE_INFRA;
+ else if (g_strcmp0(value, "adhoc") == 0)
+ return NET_WLAN_CONNMODE_ADHOC;
+ else
+ return NET_WLAN_CONNMODE_AUTO;
+}
+
+static inline void _net_extract_winfo_security(GVariant *var, net_profile_info_s *ProfInfo)
+{
+ const gchar *value;
+ GVariantIter *iter_sub = NULL;
+
+ g_variant_get(var, "as", &iter_sub);
+ while (g_variant_iter_loop(iter_sub, "s", &value)) {
+ if (g_strcmp0(value, "none") == 0
+ && ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_NONE)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_NONE;
+ else if (g_strcmp0(value, "wep") == 0
+ && ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WEP)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WEP;
+ else if (g_strcmp0(value, "psk") == 0
+ && ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
+ else if (g_strcmp0(value, "ft_psk") == 0
+ && ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_FT_PSK)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA_FT_PSK;
+ else if (g_strcmp0(value, "ieee8021x") == 0
+ && ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_IEEE8021X)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_IEEE8021X;
+ else if (g_strcmp0(value, "wpa") == 0
+ && ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
+ else if (g_strcmp0(value, "rsn") == 0
+ && ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA2_PSK;
+ else if (g_strcmp0(value, "sae") == 0
+ && ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_SAE)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_SAE;
+ else if (g_strcmp0(value, "owe") == 0
+ && ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_SAE)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_OWE;
+ else if (g_strcmp0(value, "dpp") == 0
+ && ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_SAE)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_DPP;
+ else if (g_strcmp0(value, "wps") == 0)
+ ProfInfo->security_info.wps_support = TRUE;
+ else if (ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_NONE)
+ ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_NONE;
+ }
+ g_variant_iter_free(iter_sub);
+}
+
+static inline void _net_extract_winfo_encryptionmode(const gchar *value, net_profile_info_s *ProfInfo)
+{
+ if (g_strcmp0(value, "none") == 0)
+ ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_NONE;
+ else if (g_strcmp0(value, "wep") == 0)
+ ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_WEP;
+ else if (g_strcmp0(value, "tkip") == 0)
+ ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_TKIP;
+ else if (g_strcmp0(value, "aes") == 0)
+ ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_AES;
+ else if (g_strcmp0(value, "mixed") == 0)
+ ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_TKIP_AES_MIXED;
+}
+
+static inline void _net_extract_winfo_passphrase(GVariant *var, net_profile_info_s *ProfInfo)
+{
+ wlan_security_info_s *security_info = &(ProfInfo->security_info);
+ const gchar *value = g_variant_get_string(var, NULL);
+
+ if (security_info->sec_mode == WLAN_SEC_MODE_WEP && value != NULL) {
+ g_strlcpy(security_info->authentication.wep.wepKey,
+ value, NET_WLAN_MAX_WEP_KEY_LEN + 1);
+ } else if ((security_info->sec_mode == WLAN_SEC_MODE_WPA_PSK
+ || security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK)
+ && value != NULL) {
+ g_strlcpy(security_info->authentication.psk.pskKey,
+ value, NET_WLAN_MAX_PSK_PASSPHRASE_LEN + 1);
+ }
+}
+
+static inline void _net_extract_winfo_ssid(GVariant *var, net_profile_info_s *ProfInfo)
+{
+ gsize ssid_len;
+ const gchar *ssid;
+
+ ssid = g_variant_get_fixed_array(var, &ssid_len, sizeof(guchar));
+ memcpy(ProfInfo->raw_ssid, ssid, ssid_len);
+ ProfInfo->raw_ssid_len = ssid_len;
+}
+
+static inline void _net_extract_winfo_vsie(GVariant *var, net_profile_info_s *ProfInfo)
+{
+ gsize size;
+ unsigned char *vsie = NULL;
+ const unsigned char *vsie_bytes;
+
+ vsie_bytes = g_variant_get_fixed_array(var, &size, sizeof(guchar));
+
+ if (vsie_bytes) {
+ vsie = (unsigned char *)g_try_malloc0(size);
+ if (vsie) {
+ memcpy(vsie, vsie_bytes, size);
+ ProfInfo->vsie_list = g_slist_append(ProfInfo->vsie_list, vsie);
+ } else
+ WIFI_LOG(WIFI_ERROR, "Failed to allocate memory.");
+ }
+}
+
+static inline void _net_extract_winfo_bssid_list(GVariant *var, net_profile_info_s *ProfInfo)
+{
+ GVariantIter *iter_sub = NULL;
+ net_profile_bssid_list_s *bssid_list = NULL;
+ gchar *bssid_key = NULL;
+ GVariant *bssid_var = NULL;
+ g_variant_get(var, "a{sv}", &iter_sub);
+
+ while (g_variant_iter_loop(iter_sub, "{sv}", &bssid_key, &bssid_var)) {
+ if (g_strcmp0(bssid_key, "BSSID") == 0) {
+ bssid_list = g_try_malloc0(sizeof(net_profile_bssid_list_s));
+
+ if (bssid_list) {
+ const gchar *value = g_variant_get_string(bssid_var, NULL);
+
+ if (value != NULL)
+ g_strlcpy(bssid_list->bssid, value, 18);
+ else
+ WIFI_LOG(WIFI_ERROR, "Value is empty");
+ } else {
+ WIFI_LOG(WIFI_ERROR, "Failed to allocate memory.");
+ g_variant_unref(bssid_var);
+ g_free(bssid_key);
+ break;
+ }
+ } else if (bssid_list && g_strcmp0(bssid_key, "Strength") == 0) {
+ bssid_list->strength = (int)g_variant_get_uint16(bssid_var);
+ } else if (bssid_list && g_strcmp0(bssid_key, "Frequency") == 0) {
+ bssid_list->frequency = (int)g_variant_get_uint16(bssid_var);
+ ProfInfo->bssid_list = g_slist_append(ProfInfo->bssid_list, bssid_list);
+ }
+ }
+ g_variant_iter_free(iter_sub);
+}
+
+static int __net_extract_wifi_info(GVariantIter *array, net_profile_info_s *ProfInfo)
{
net_err_e Error = NET_ERR_NONE;
GVariant *var = NULL;
if (g_strcmp0(key, "Mode") == 0) {
value = g_variant_get_string(var, NULL);
-
- if (g_strcmp0(value, "managed") == 0)
- ProfInfo->wlan_mode = NET_WLAN_CONNMODE_INFRA;
- else if (g_strcmp0(value, "adhoc") == 0)
- ProfInfo->wlan_mode = NET_WLAN_CONNMODE_ADHOC;
- else
- ProfInfo->wlan_mode = NET_WLAN_CONNMODE_AUTO;
-
+ ProfInfo->wlan_mode = _net_extract_winfo_mode(value);
} else if (g_strcmp0(key, "Security") == 0) {
- GVariantIter *iter_sub = NULL;
-
- g_variant_get(var, "as", &iter_sub);
- while (g_variant_iter_loop(iter_sub, "s", &value)) {
- if (g_strcmp0(value, "none") == 0 &&
- ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_NONE)
- ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_NONE;
- else if (g_strcmp0(value, "wep") == 0 &&
- ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WEP)
- ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WEP;
- else if (g_strcmp0(value, "psk") == 0 &&
- ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
- ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
- else if (g_strcmp0(value, "ft_psk") == 0 &&
- ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_FT_PSK)
- ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA_FT_PSK;
- else if (g_strcmp0(value, "ieee8021x") == 0 &&
- ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_IEEE8021X)
- ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_IEEE8021X;
- else if (g_strcmp0(value, "wpa") == 0 &&
- ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
- ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
- else if (g_strcmp0(value, "rsn") == 0 &&
- ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
- ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_WPA2_PSK;
- else if (g_strcmp0(value, "sae") == 0 &&
- ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_SAE)
- ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_SAE;
- else if (g_strcmp0(value, "owe") == 0 &&
- ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_SAE)
- ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_OWE;
- else if (g_strcmp0(value, "dpp") == 0 &&
- ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_SAE)
- ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_DPP;
- else if (g_strcmp0(value, "wps") == 0)
- ProfInfo->security_info.wps_support = TRUE;
- else if (ProfInfo->security_info.sec_mode < WLAN_SEC_MODE_NONE)
- ProfInfo->security_info.sec_mode = WLAN_SEC_MODE_NONE;
- }
- g_variant_iter_free(iter_sub);
+ _net_extract_winfo_security(var, ProfInfo);
} else if (g_strcmp0(key, "EncryptionMode") == 0) {
value = g_variant_get_string(var, NULL);
-
- if (g_strcmp0(value, "none") == 0)
- ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_NONE;
- else if (g_strcmp0(value, "wep") == 0)
- ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_WEP;
- else if (g_strcmp0(value, "tkip") == 0)
- ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_TKIP;
- else if (g_strcmp0(value, "aes") == 0)
- ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_AES;
- else if (g_strcmp0(value, "mixed") == 0)
- ProfInfo->security_info.enc_mode = WLAN_ENC_MODE_TKIP_AES_MIXED;
-
+ _net_extract_winfo_encryptionmode(value, ProfInfo);
} else if (g_strcmp0(key, "Passpoint") == 0) {
- gboolean passpoint;
-
- passpoint = g_variant_get_boolean(var);
- if (passpoint)
- ProfInfo->passpoint = TRUE;
- else
- ProfInfo->passpoint = FALSE;
-
+ gboolean passpoint = g_variant_get_boolean(var);
+ ProfInfo->passpoint = (passpoint) ? TRUE : FALSE;
} else if (g_strcmp0(key, "Strength") == 0) {
ProfInfo->Strength = g_variant_get_byte(var);
} else if (g_strcmp0(key, "Name") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
g_strlcpy(ProfInfo->essid, value, NET_WLAN_ESSID_LEN + 1);
} else if (g_strcmp0(key, "Passphrase") == 0) {
- wlan_security_info_s *security_info = &(ProfInfo->security_info);
- value = g_variant_get_string(var, NULL);
-
- if (security_info->sec_mode == WLAN_SEC_MODE_WEP && value != NULL)
- g_strlcpy(security_info->authentication.wep.wepKey,
- value, NET_WLAN_MAX_WEP_KEY_LEN+1);
- else if ((security_info->sec_mode == WLAN_SEC_MODE_WPA_PSK ||
- security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK) &&
- value != NULL)
- g_strlcpy(security_info->authentication.psk.pskKey,
- value, NET_WLAN_MAX_PSK_PASSPHRASE_LEN+1);
+ _net_extract_winfo_passphrase(var, ProfInfo);
} else if (g_strcmp0(key, "PassphraseRequired") == 0) {
- gboolean val;
-
- val = g_variant_get_boolean(var);
-
- if (val)
- ProfInfo->PassphraseRequired = TRUE;
- else
- ProfInfo->PassphraseRequired = FALSE;
+ gboolean val = g_variant_get_boolean(var);
+ ProfInfo->PassphraseRequired = (val) ? TRUE : FALSE;
} else if (g_strcmp0(key, "SSID") == 0) {
- const gchar *ssid = NULL;
- gsize ssid_len;
- ssid = g_variant_get_fixed_array(var, &ssid_len, sizeof(guchar));
- memcpy(ProfInfo->raw_ssid, ssid, ssid_len);
- ProfInfo->raw_ssid_len = ssid_len;
+ _net_extract_winfo_ssid(var, ProfInfo);
} else if (g_strcmp0(key, "BSSID") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
g_strlcpy(ProfInfo->bssid, value, WIFI_MAC_ADDR_LEN + 1);
-
} else if (g_strcmp0(key, "MaxSpeed") == 0) {
ProfInfo->max_rate = g_variant_get_int32(var);
-
} else if (g_strcmp0(key, "Frequency") == 0) {
ProfInfo->frequency = (unsigned int)g_variant_get_uint16(var);
} else if (g_strcmp0(key, "Protocol") == 0) {
- value = g_variant_get_string(var, NULL);
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
g_strlcpy(ProfInfo->operation_mode, value, NET_MAX_PROTOCOL_LEN+1);
} else if (g_strcmp0(key, "ConnMode") == 0) {
ProfInfo->connection_mode = (unsigned int)g_variant_get_uint16(var);
-
} else if (g_strcmp0(key, "Vsie") == 0) {
- const unsigned char *vsie_bytes = NULL;
- unsigned char *vsie = NULL;
- gsize size;
-
- vsie_bytes = g_variant_get_fixed_array(var, &size, sizeof(guchar));
-
- if (vsie_bytes) {
- vsie = (unsigned char *)g_try_malloc0(size);
- if (vsie) {
- memcpy(vsie, vsie_bytes, size);
- ProfInfo->vsie_list = g_slist_append(ProfInfo->vsie_list, vsie);
- } else
- WIFI_LOG(WIFI_ERROR, "Failed to allocate memory.");
- }
+ _net_extract_winfo_vsie(var, ProfInfo);
} else if (g_strcmp0(key, "DisconnectReason") == 0) {
ProfInfo->disconnect_reason = g_variant_get_int32(var);
-
} else if (g_strcmp0(key, "AssocStatusCode") == 0) {
ProfInfo->assoc_status_code = g_variant_get_int32(var);
-
} else if (g_strcmp0(key, "EAP") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
ProfInfo->security_info.authentication.eap.eap_type =
- __convert_eap_type_from_string(value);
-
+ __convert_eap_type_from_string(value);
} else if (g_strcmp0(key, "Phase2") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
ProfInfo->security_info.authentication.eap.eap_auth =
- __convert_eap_auth_from_string(value);
-
+ __convert_eap_auth_from_string(value);
} else if (g_strcmp0(key, "Identity") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
g_strlcpy(ProfInfo->security_info.authentication.eap.username,
- value, NET_WLAN_USERNAME_LEN+1);
-
+ value, NET_WLAN_USERNAME_LEN+1);
} else if (g_strcmp0(key, "Password") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
g_strlcpy(ProfInfo->security_info.authentication.eap.password,
value, NET_WLAN_PASSWORD_LEN+1);
-
} else if (g_strcmp0(key, "CACertFile") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
g_strlcpy(ProfInfo->security_info.authentication.eap.ca_cert_filename,
value, NET_WLAN_CA_CERT_FILENAME_LEN+1);
-
} else if (g_strcmp0(key, "ClientCertFile") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
g_strlcpy(ProfInfo->security_info.authentication.eap.client_cert_filename,
value, NET_WLAN_CLIENT_CERT_FILENAME_LEN+1);
-
} else if (g_strcmp0(key, "PrivateKeyFile") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
g_strlcpy(ProfInfo->security_info.authentication.eap.private_key_filename,
value, NET_WLAN_PRIVATE_KEY_FILENAME_LEN+1);
-
} else if (g_strcmp0(key, "PrivateKeyPassphrase") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
g_strlcpy(ProfInfo->security_info.authentication.eap.private_key_passwd,
value, NET_WLAN_PRIVATE_KEY_PASSWD_LEN+1);
-
} else if (g_strcmp0(key, "Keymgmt") == 0) {
ProfInfo->security_info.keymgmt = (unsigned int)g_variant_get_uint32(var);
} else if (g_strcmp0(key, "Country") == 0) {
- value = g_variant_get_string(var, NULL);
-
- if (value != NULL)
+ if ((value = g_variant_get_string(var, NULL)))
g_strlcpy(ProfInfo->country_code, value, NET_WLAN_COUNTRY_CODE_LEN);
} else if (g_strcmp0(key, "BSSID.List") == 0) {
- GVariantIter *iter_sub = NULL;
- net_profile_bssid_list_s *bssid_list = NULL;
- gchar *bssid_key = NULL;
- GVariant *bssid_var = NULL;
- g_variant_get(var, "a{sv}", &iter_sub);
-
- while (g_variant_iter_loop(iter_sub, "{sv}", &bssid_key,
- &bssid_var)) {
- if (g_strcmp0(bssid_key, "BSSID") == 0) {
- bssid_list = (net_profile_bssid_list_s *)g_try_malloc0(sizeof(net_profile_bssid_list_s));
-
- if (bssid_list) {
- value = g_variant_get_string(bssid_var, NULL);
-
- if (value != NULL)
- g_strlcpy(bssid_list->bssid, value, 18);
- else
- WIFI_LOG(WIFI_ERROR, "Value is empty");
- } else {
- WIFI_LOG(WIFI_ERROR, "Failed to allocate memory.");
- g_variant_unref(bssid_var);
- g_free(bssid_key);
- break;
- }
- } else if (bssid_list && g_strcmp0(bssid_key, "Strength") == 0) {
- bssid_list->strength = (int)g_variant_get_uint16(bssid_var);
- } else if (bssid_list && g_strcmp0(bssid_key, "Frequency") == 0) {
- bssid_list->frequency = (int)g_variant_get_uint16(bssid_var);
- ProfInfo->bssid_list = g_slist_append(ProfInfo->bssid_list,
- bssid_list);
- }
- }
- g_variant_iter_free(iter_sub);
+ _net_extract_winfo_bssid_list(var, ProfInfo);
} else if (g_strcmp0(key, "Hidden") == 0) {
ProfInfo->ap_hidden_status = g_variant_get_boolean(var);
} else