bool dbus_registered;
#if defined TIZEN_EXT
char **enabled_devices;
+ unsigned int mac_policy;
+ unsigned int preassoc_mac_policy;
+ unsigned int random_mac_lifetime;
#endif
#if defined TIZEN_EXT_WIFI_MESH
DBusMessage *mesh_dbus_msg;
"Tethering.Passphrase",
technology->tethering_passphrase);
+#ifdef TIZEN_EXT
+ if (technology->type == CONNMAN_SERVICE_TYPE_WIFI) {
+ g_key_file_set_uint64(keyfile, identifier, "MacPolicy",
+ technology->mac_policy);
+
+ g_key_file_set_uint64(keyfile, identifier, "PreassocMacPolicy",
+ technology->preassoc_mac_policy);
+
+ g_key_file_set_uint64(keyfile, identifier, "RandomMacLifetime",
+ technology->random_mac_lifetime);
+ }
+#endif /* TIZEN_EXT */
+
done:
g_free(identifier);
technology->tethering_passphrase = g_key_file_get_string(keyfile,
identifier, "Tethering.Passphrase", NULL);
+
+#ifdef TIZEN_EXT
+ if (technology->type == CONNMAN_SERVICE_TYPE_WIFI) {
+ unsigned int val = 0;
+
+ val = g_key_file_get_uint64(keyfile,
+ identifier, "MacPolicy", NULL);
+ if (val <= 2)
+ technology->mac_policy = val;
+ else
+ technology->mac_policy = 0;
+
+ val = g_key_file_get_uint64(keyfile,
+ identifier, "PreassocMacPolicy", NULL);
+ if (val <= 2)
+ technology->preassoc_mac_policy = val;
+ else
+ technology->preassoc_mac_policy = 0;
+
+ val = g_key_file_get_uint64(keyfile,
+ identifier, "RandomMacLifetime", NULL);
+ if (val > 0)
+ technology->random_mac_lifetime = val;
+ else
+ technology->random_mac_lifetime = 60;
+ }
+#endif /* TIZEN_EXT */
+
done:
g_free(identifier);
connman_dbus_dict_append_basic(&dict, "TetheringPassphrase",
DBUS_TYPE_STRING,
&technology->tethering_passphrase);
+
#if defined TIZEN_EXT
+ connman_dbus_dict_append_basic(&dict, "MacPolicy",
+ DBUS_TYPE_UINT32,
+ &(technology->mac_policy));
+
+ connman_dbus_dict_append_basic(&dict, "PreassocMacPolicy",
+ DBUS_TYPE_UINT32,
+ &(technology->preassoc_mac_policy));
+
+ connman_dbus_dict_append_basic(&dict, "RandomMacLifetime",
+ DBUS_TYPE_UINT32,
+ &(technology->random_mac_lifetime));
+
if (technology->type == CONNMAN_SERVICE_TYPE_WIFI)
connman_dbus_dict_append_dict(&dict, "Device.List",
append_devices, technology);
+ if (technology->regdom)
+ connman_dbus_dict_append_basic(&dict, "CountryCode",
+ DBUS_TYPE_STRING,
+ &technology->regdom);
#endif
connman_dbus_dict_close(iter, &dict);
}
return bssid_len;
}
+
+void connman_technology_mac_policy_notify(struct connman_technology *technology,
+ unsigned int policy)
+{
+ DBG("Mac polict set to %u", policy);
+
+ technology->mac_policy = policy;
+ technology_save(technology);
+}
+
+void __connman_technology_notify_mac_policy_by_device(struct connman_device *device,
+ int result, unsigned int policy)
+{
+ struct connman_technology *technology;
+ enum connman_service_type type;
+
+ type = __connman_device_get_service_type(device);
+ technology = technology_find(type);
+
+ if (!technology)
+ return;
+
+ connman_technology_mac_policy_notify(technology, policy);
+}
+
+static DBusMessage *set_mac_policy(struct connman_technology *technology,
+ DBusMessage *msg, unsigned int policy)
+{
+ DBusMessage *reply = NULL;
+ int err = 0;
+ unsigned int last_policy = technology->mac_policy;
+
+ if (technology->rfkill_driven && technology->hardblocked) {
+ err = -EACCES;
+ goto make_reply;
+ }
+
+ for (GSList *list = technology->device_list; list; list = list->next) {
+ struct connman_device *device = list->data;
+
+ err = connman_device_set_mac_policy(device, policy);
+ if (err < 0)
+ break;
+ }
+
+make_reply:
+ if (err < 0) {
+ if (err != -EACCES && err != -EOPNOTSUPP) {
+ for (GSList *list = technology->device_list; list; list = list->next) {
+ struct connman_device *device = list->data;
+
+ connman_device_set_mac_policy(device, last_policy);
+ }
+ }
+
+ reply = __connman_error_failed(msg, -err);
+ } else {
+ reply = g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ }
+
+ return reply;
+}
+
+void connman_technology_preassoc_mac_policy_notify(struct connman_technology *technology,
+ unsigned int policy)
+{
+ DBG("Preassoc mac polict set to %u", policy);
+
+ technology->preassoc_mac_policy = policy;
+ technology_save(technology);
+}
+
+void __connman_technology_notify_preassoc_mac_policy_by_device(struct connman_device *device,
+ int result, unsigned int policy)
+{
+ struct connman_technology *technology;
+ enum connman_service_type type;
+
+ type = __connman_device_get_service_type(device);
+ technology = technology_find(type);
+
+ if (!technology)
+ return;
+
+ connman_technology_preassoc_mac_policy_notify(technology, policy);
+}
+
+static DBusMessage *set_preassoc_mac_policy(struct connman_technology *technology,
+ DBusMessage *msg, unsigned int policy)
+{
+ DBusMessage *reply = NULL;
+ int err = 0;
+ unsigned int last_policy = technology->preassoc_mac_policy;
+
+ if (technology->rfkill_driven && technology->hardblocked) {
+ err = -EACCES;
+ goto make_reply;
+ }
+
+ for (GSList *list = technology->device_list; list; list = list->next) {
+ struct connman_device *device = list->data;
+
+ err = connman_device_set_preassoc_mac_policy(device, policy);
+ if (err < 0)
+ break;
+ }
+
+make_reply:
+ if (err < 0) {
+ if (err != -EACCES && err != -EOPNOTSUPP) {
+ for (GSList *list = technology->device_list; list; list = list->next) {
+ struct connman_device *device = list->data;
+
+ connman_device_set_preassoc_mac_policy(device, last_policy);
+ }
+ }
+
+ reply = __connman_error_failed(msg, -err);
+ } else {
+ reply = g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ }
+
+ return reply;
+}
+
+void connman_technology_random_mac_lifetime_notify(struct connman_technology *technology,
+ unsigned int lifetime)
+{
+ DBG("Random mac lifetime set to %u", lifetime);
+
+ technology->random_mac_lifetime = lifetime;
+ technology_save(technology);
+}
+
+void __connman_technology_notify_random_mac_lifetime_by_device(struct connman_device *device,
+ int result, unsigned int lifetime)
+{
+ struct connman_technology *technology;
+ enum connman_service_type type;
+
+ type = __connman_device_get_service_type(device);
+ technology = technology_find(type);
+
+ if (!technology)
+ return;
+
+ connman_technology_random_mac_lifetime_notify(technology, lifetime);
+}
+
+static DBusMessage *set_random_mac_lifetime(struct connman_technology *technology,
+ DBusMessage *msg, unsigned int lifetime)
+{
+ DBusMessage *reply = NULL;
+ int err = 0;
+ unsigned int last_lifetime = technology->random_mac_lifetime;
+
+ if (technology->rfkill_driven && technology->hardblocked) {
+ err = -EACCES;
+ goto make_reply;
+ }
+
+ for (GSList *list = technology->device_list; list; list = list->next) {
+ struct connman_device *device = list->data;
+
+ err = connman_device_set_random_mac_lifetime(device, lifetime);
+ }
+
+make_reply:
+ if (err < 0) {
+ if (err != -EACCES && err != -EOPNOTSUPP) {
+ for (GSList *list = technology->device_list; list; list = list->next) {
+ struct connman_device *device = list->data;
+
+ connman_device_set_random_mac_lifetime(device, last_lifetime);
+ }
+ }
+
+ reply = __connman_error_failed(msg, -err);
+ } else {
+ reply = g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ }
+
+ return reply;
+}
#endif
static DBusMessage *set_property(DBusConnection *conn,
dbus_message_iter_get_basic(&value, &key);
DBG("BSSID %s", key);
set_connman_bssid(SET_BSSID, key, NULL);
+ } else if (g_str_equal(name, "MacPolicy")) {
+ dbus_uint32_t mac_policy;
+
+ if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
+ return __connman_error_not_supported(msg);
+
+ if (type != DBUS_TYPE_UINT32)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_get_basic(&value, &mac_policy);
+
+ if (mac_policy <= 2)
+ return set_mac_policy(technology, msg, mac_policy);
+ else
+ return __connman_error_invalid_arguments(msg);
+
+ } else if (g_str_equal(name, "PreassocMacPolicy")) {
+ dbus_uint32_t preassoc_mac_policy;
+
+ if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
+ return __connman_error_not_supported(msg);
+
+ if (type != DBUS_TYPE_UINT32)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_get_basic(&value, &preassoc_mac_policy);
+
+ if (preassoc_mac_policy <= 2)
+ return set_preassoc_mac_policy(technology, msg, preassoc_mac_policy);
+ else
+ return __connman_error_invalid_arguments(msg);
+
+ } else if (g_str_equal(name, "RandomMacLifetime")) {
+ dbus_uint32_t random_mac_lifetime;
+
+ if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
+ return __connman_error_not_supported(msg);
+
+ if (type != DBUS_TYPE_UINT32)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_get_basic(&value, &random_mac_lifetime);
+
+ if (random_mac_lifetime > 0)
+ return set_random_mac_lifetime(technology, msg, random_mac_lifetime);
+ else
+ return __connman_error_invalid_arguments(msg);
+
+ } else if (g_str_equal(name, "CountryCode")) {
+ const char *str;
+
+ dbus_message_iter_get_basic(&value, &str);
+ DBG("country code %s", str);
+ connman_technology_set_regdom(str);
#endif
} else
return __connman_error_invalid_property(msg);
dbus_bool_t status = 0;
connman_scan_type_e scan_type = CONNMAN_SCAN_TYPE_UNKNOWN;
- DBG("technology %p ifname %d count %d", technology, ifname, count);
+ DBG("technology %p ifname %s count %d", technology, ifname, count);
list = technology->scan_pending;
reply_scan_pending_device(technology, ifname, count);
return;
-#endif
+#else
if (count == 0)
reply_scan_pending(technology, 0);
+#endif
}
void __connman_technology_notify_regdom_by_device(struct connman_device *device,
#if defined TIZEN_EXT
const char *ifname = connman_device_get_string(device, "Interface");
__connman_technology_notify_device_detected(technology, ifname, true);
+
+ connman_device_set_mac_policy(device, technology->mac_policy);
+ connman_device_set_preassoc_mac_policy(device, technology->preassoc_mac_policy);
+ connman_device_set_random_mac_lifetime(device, technology->random_mac_lifetime);
#endif
return 0;
}