Add dbus mechanism for fetching all network configuration parameters
This commit is contained in:
parent
71f6e1f697
commit
3d3d305645
3 changed files with 55 additions and 7 deletions
|
@ -1832,6 +1832,59 @@ int wpa_config_set(struct wpa_ssid *ssid, const char *var, const char *value,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* wpa_config_get_all - Get all options from network configuration
|
||||
* @ssid: Pointer to network configuration data
|
||||
* @get_keys: Determines if keys/passwords will be included in returned list
|
||||
* Returns: %NULL terminated list of all set keys and their values in the form
|
||||
* of [key1, val1, key2, val2, ... , NULL]
|
||||
*
|
||||
* This function can be used to get list of all configured network properties.
|
||||
* The caller is responsible for freeing the returned list and all its
|
||||
* elements.
|
||||
*/
|
||||
char ** wpa_config_get_all(struct wpa_ssid *ssid, int get_keys)
|
||||
{
|
||||
const struct parse_data *field;
|
||||
char *key, *value;
|
||||
size_t i;
|
||||
char **props;
|
||||
int fields_num;
|
||||
|
||||
props = os_zalloc(sizeof(char *) * ((2 * NUM_SSID_FIELDS) + 1));
|
||||
if (!props)
|
||||
return NULL;
|
||||
|
||||
fields_num = 0;
|
||||
for (i = 0; i < NUM_SSID_FIELDS; i++) {
|
||||
field = &ssid_fields[i];
|
||||
if (field->key_data && !get_keys)
|
||||
continue;
|
||||
value = field->writer(field, ssid);
|
||||
if (value == NULL || os_strlen(value) == 0)
|
||||
continue;
|
||||
|
||||
key = os_strdup(field->name);
|
||||
if (key == NULL)
|
||||
goto err;
|
||||
|
||||
props[fields_num * 2] = key;
|
||||
props[fields_num * 2 + 1] = value;
|
||||
|
||||
fields_num++;
|
||||
}
|
||||
|
||||
return props;
|
||||
|
||||
err:
|
||||
value = *props;
|
||||
while (value)
|
||||
os_free(value++);
|
||||
os_free(props);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NO_CONFIG_WRITE
|
||||
/**
|
||||
* wpa_config_get - Get a variable in network configuration
|
||||
|
|
|
@ -336,6 +336,7 @@ int wpa_config_remove_network(struct wpa_config *config, int id);
|
|||
void wpa_config_set_network_defaults(struct wpa_ssid *ssid);
|
||||
int wpa_config_set(struct wpa_ssid *ssid, const char *var, const char *value,
|
||||
int line);
|
||||
char ** wpa_config_get_all(struct wpa_ssid *ssid, int get_keys);
|
||||
char * wpa_config_get(struct wpa_ssid *ssid, const char *var);
|
||||
char * wpa_config_get_no_key(struct wpa_ssid *ssid, const char *var);
|
||||
void wpa_config_update_psk(struct wpa_ssid *ssid);
|
||||
|
|
|
@ -3026,13 +3026,7 @@ DBusMessage * wpas_dbus_getter_network_properties(
|
|||
DBusMessage *reply = NULL;
|
||||
DBusMessageIter iter, variant_iter, dict_iter;
|
||||
char **iterator;
|
||||
|
||||
#if 0
|
||||
/* FIX: decide what to do with wpa_config_get_all */
|
||||
char** props = wpa_config_get_all(net->ssid, 0);
|
||||
#else
|
||||
char **props = NULL;
|
||||
#endif
|
||||
char **props = wpa_config_get_all(net->ssid, 0);
|
||||
if (!props) {
|
||||
perror("wpas_dbus_getter_network_properties[dbus] couldn't "
|
||||
"read network properties. out of memory.");
|
||||
|
|
Loading…
Reference in a new issue