int _net_dbus_config_set_field(const gchar *config_id, const gchar *key, const gchar *value);
int _net_dbus_config_get_passphrase(const gchar *config_id, gchar **passphrase);
int _net_dbus_config_save_configurations(const gchar *config_id, const gchar *name,
- const gchar *ssid, const gchar *passphrase, const gchar *proxy_address, gboolean is_hidden);
+ const gchar *ssid, const gchar *passphrase, const gchar *proxy_address,
+ net_ip_info_config_s *ip_info, gboolean is_hidden);
int _net_dbus_config_save_eap_configurations(const gchar *config_id,
const gchar *name, const gchar *ssid, const gchar *passphrase,
const gchar *proxy_address, net_eap_config_s *eap_config, gboolean is_hidden);
net_wifi_eap_auth_type_e eap_auth_type;
} net_eap_config_s;
+typedef struct {
+ net_ip_config_type_e ip_type;
+ gchar *ip_address;
+ gchar *subnet_mask;
+ int prefix_length;
+ gchar *gateway_address;
+ net_dns_config_type_e dns_type;
+ gchar *dns_address;
+} net_ip_info_config_s;
+
typedef void (*net_event_cb)(const net_event_info_s* net_event, void* user_data);
int net_register_client_ext(net_event_cb event_cb, void *user_data);
int net_config_get_id_list(GSList **list);
int net_config_set_field(const gchar *config_id, const gchar *key, const gchar *value);
int net_config_get_passphrase(const gchar *config_id, gchar **passphrase);
-int net_config_save_configurations(const gchar *config_id, const gchar *name,
- const gchar *ssid, const gchar *passphrase, const gchar *proxy_address, gboolean is_hidden);
+int net_config_save_configurations(const gchar *config_id,
+ const gchar *name, const gchar *ssid, const gchar *passphrase,
+ const gchar *proxy_address, net_ip_info_config_s *ip_info,
+ gboolean is_hidden);
int net_config_save_eap_configurations(const gchar *config_id,
const gchar *name, const gchar *ssid, const gchar *passphrase,
const gchar *proxy_address, void *eap_config, gboolean is_hidden);
#define WIFI_CONFIG_SECURITY_TYPE "Security"
#define WIFI_CONFIG_PROXYADDRESS "ProxyAddress"
#define WIFI_CONFIG_HIDDEN "Hidden"
+#define WIFI_CONFIG_IPV4_METHOD "IPv4.method"
+#define WIFI_CONFIG_IPV6_METHOD "IPv6.method"
#define WIFI_CONFIG_FAILURE "Failure"
#define WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY "AnonymousIdentity"
#define WIFI_CONFIG_EAP_CACERT "CACertFile"
wifi_manager_eap_auth_type_e eap_auth_type;
} wifi_eap_config_s;
+typedef struct {
+ wifi_manager_ip_config_type_e ip_type;
+ gchar *ip_address;
+ gchar *subnet_mask;
+ int prefix_length;
+ gchar *gateway_address;
+ wifi_manager_dns_config_type_e dns_type;
+ gchar *dns_address;
+} wifi_config_ip_info_s;
+
typedef struct {
gchar *name;
gchar *passphrase;
gchar *proxy_address;
wifi_manager_address_family_e address_family;
wifi_eap_config_s *eap_config;
+ wifi_config_ip_info_s *ip_info;
wifi_manager_error_e last_error;
} wifi_config_s;
int _wifi_config_get_config_id_list(GSList **list);
int _wifi_save_configuration(const gchar *name, const gchar *passphrase,
- wifi_manager_security_type_e security_type, const gchar *proxy_address, gboolean is_hidden);
+ wifi_manager_security_type_e security_type, const gchar *proxy_address,
+ wifi_config_ip_info_s *ip_info, gboolean is_hidden);
int _wifi_load_configurations(void);
int _wifi_foreach_configuration(wifi_manager_config_list_cb callback, void *user_data);
int _wifi_remove_configuration(const gchar *config_id);
}
int _net_dbus_config_save_configurations(const gchar *config_id, const gchar *name,
- const gchar *ssid, const gchar *passphrase, const gchar *proxy_address, gboolean is_hidden)
+ const gchar *ssid, const gchar *passphrase, const gchar *proxy_address,
+ net_ip_info_config_s *ip_info, gboolean is_hidden)
{
__NETWORK_FUNC_ENTER__;
GVariantBuilder *b = NULL;
GVariant *params = NULL;
GVariant *message = NULL;
+ const char *manual_method = "manual";
+ const char *dhcp_method = "dhcp";
b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(name));
if (is_hidden == TRUE)
g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string("TRUE"));
+ switch (ip_info->ip_type) {
+ case NET_IP_CONFIG_TYPE_STATIC:
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_METHOD,
+ g_variant_new_string(manual_method));
+ break;
+ case NET_IP_CONFIG_TYPE_DYNAMIC:
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_METHOD,
+ g_variant_new_string(dhcp_method));
+ break;
+ default:
+ break;
+ }
+
params = g_variant_new("(s@a{sv})", config_id, g_variant_builder_end(b));
g_variant_builder_unref(b);
}
int net_config_save_configurations(const gchar *config_id, const gchar *name,
- const gchar *ssid, const gchar *passphrase, const gchar *proxy_address, gboolean is_hidden)
+ const gchar *ssid, const gchar *passphrase, const gchar *proxy_address,
+ net_ip_info_config_s *ip_info, gboolean is_hidden)
{
__NETWORK_FUNC_ENTER__;
return NET_ERR_APP_NOT_REGISTERED; //LCOV_EXCL_LINE
}
- Error = _net_dbus_config_save_configurations(config_id,
- name, ssid, passphrase, proxy_address, is_hidden);
+ Error = _net_dbus_config_save_configurations(config_id, name, ssid,
+ passphrase, proxy_address, ip_info, is_hidden);
if (Error != NET_ERR_NONE)
WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
"Failed to save configurations. Error [%s]",
h->proxy_address = NULL;
h->address_family = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
h->eap_config = NULL;
+ h->ip_info = g_new0(wifi_config_ip_info_s, 1);
+ if (h->ip_info == NULL) {
+ g_free(h->name); //LCOV_EXCL_LINE
+ g_free(h->passphrase); //LCOV_EXCL_LINE
+ g_free(h); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+
+ h->ip_info->ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_NONE;
+ h->ip_info->ip_address = NULL;
+ h->ip_info->subnet_mask = NULL;
+ h->ip_info->prefix_length = 0;
+ h->ip_info->gateway_address = NULL;
+ h->ip_info->dns_type = WIFI_MANAGER_DNS_CONFIG_TYPE_NONE;
+ h->ip_info->dns_address = NULL;
if (security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
h->eap_config = g_new0(wifi_eap_config_s, 1);
if (h->eap_config == NULL) {
g_free(h->name); //LCOV_EXCL_LINE
g_free(h->passphrase); //LCOV_EXCL_LINE
+ g_free(h->ip_info); //LCOV_EXCL_LINE
g_free(h); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
h->proxy_address = g_strdup(config->proxy_address);
h->address_family = config->address_family;
+ if (config->ip_info) {
+ h->ip_info = g_new0(wifi_config_ip_info_s, 1);
+ if (h->ip_info == NULL) {
+ g_free(h->name); //LCOV_EXCL_LINE
+ g_free(h->passphrase); //LCOV_EXCL_LINE
+ g_free(h->proxy_address); //LCOV_EXCL_LINE
+ g_free(h); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+
+ h->ip_info->ip_type = config->ip_info->ip_type;
+ h->ip_info->ip_address = g_strdup(config->ip_info->ip_address);
+ h->ip_info->subnet_mask = g_strdup(config->ip_info->subnet_mask);
+ h->ip_info->prefix_length = config->ip_info->prefix_length;
+ h->ip_info->gateway_address = g_strdup(config->ip_info->gateway_address);
+ h->ip_info->dns_type = config->ip_info->dns_type;
+ h->ip_info->dns_address = g_strdup(config->ip_info->dns_address);
+ }
+
if (config->eap_config) {
h->eap_config = g_new0(wifi_eap_config_s, 1);
if (h->eap_config == NULL) {
g_free(h->name); //LCOV_EXCL_LINE
g_free(h->passphrase); //LCOV_EXCL_LINE
g_free(h->proxy_address); //LCOV_EXCL_LINE
+ g_free(h->ip_info->ip_address); //LCOV_EXCL_LINE
+ g_free(h->ip_info->subnet_mask); //LCOV_EXCL_LINE
+ g_free(h->ip_info->gateway_address); //LCOV_EXCL_LINE
+ g_free(h->ip_info->dns_address); //LCOV_EXCL_LINE
+ g_free(h->ip_info); //LCOV_EXCL_LINE
g_free(h); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
g_free(h->name);
g_free(h->passphrase);
g_free(h->proxy_address);
+ if (h->ip_info) {
+ g_free(h->ip_info->ip_address);
+ g_free(h->ip_info->subnet_mask);
+ g_free(h->ip_info->gateway_address);
+ g_free(h->ip_info->dns_address);
+ g_free(h->ip_info);
+ }
if (h->eap_config) {
g_free(h->eap_config->ca_cert);
g_free(h->eap_config->client_cert);
if (ret != WIFI_MANAGER_ERROR_NONE)
WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_eap_configurations"); //LCOV_EXCL_LINE
} else {
- ret = _wifi_save_configuration(h->name,
- h->passphrase, h->security_type, h->proxy_address, h->is_hidden);
+ ret = _wifi_save_configuration(h->name, h->passphrase, h->security_type,
+ h->proxy_address, h->ip_info, h->is_hidden);
if (ret != WIFI_MANAGER_ERROR_NONE)
WIFI_LOG(WIFI_ERROR, "Fail to save configurations [%d]", ret); //LCOV_EXCL_LINE
}
return WIFI_MANAGER_ERROR_NONE;
}
+EXPORT_API int wifi_manager_config_set_ip_config_type(wifi_manager_config_h config,
+ wifi_manager_address_family_e address_family,
+ wifi_manager_ip_config_type_e type)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6)) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ h->ip_info->ip_type = type;
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
EXPORT_API int wifi_manager_config_get_eap_anonymous_identity(wifi_manager_config_h config,
char **anonymous_identity)
{
}
int _wifi_save_configuration(const gchar *name, const gchar *passphrase,
- wifi_manager_security_type_e security_type, const gchar *proxy_address, gboolean is_hidden)
+ wifi_manager_security_type_e security_type, const gchar *proxy_address,
+ wifi_config_ip_info_s *ip_info, gboolean is_hidden)
{
int rv;
gchar *config_id = NULL;
config_id = _wifi_config_get_config_id(name, security_type);
ssid = __wifi_change_name_to_hexadecimal(name);
- rv = net_config_save_configurations(config_id, name, ssid, passphrase, proxy_address, is_hidden);
+ rv = net_config_save_configurations(config_id, name, ssid, passphrase,
+ proxy_address, (void *)ip_info, is_hidden);
if (rv == NET_ERR_ACCESS_DENIED) {
WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE