mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 04:30:09 +01:00
* src/NetworkManagerUtils.c
(nm_utils_is_empty_ssid):
(nm_utils_escape_ssid):
(nm_utils_same_ssid): Remove. These functions are copied and
pasted in a
lot of places, so they belong to libnm-utils instead.
Now with 100% less compiler warnings:
* libnm-util/nm-utils.c (nm_dbus_escape_object_path): Remove,
* unused.
(nm_dbus_unescape_object_path): Ditto.
(nm_utils_ssid_to_utf8): Ditto.
(nm_utils_is_empty_ssid): Move here from
src/NetworkManagerUtils.c
(nm_utils_escape_ssid): Ditto.
(nm_utils_same_ssid): Ditto.
* src/nm-manager.c: Include 'netinet/ether.h' for ether_aton_r.
(add_one_connection_element): Remove an unused variable.
(impl_manager_get_active_connections): Ditto.
* src/NetworkManagerPolicy.c (get_device_connection): Remove an
* unused
variable.
* src/nm-dbus-manager.c (nm_dbus_manager_start_service): Remove
* a leftover
from the previous commit.
* src/nm-device-802-11-wireless.c (set_current_ap): Remove
* unused variable.
(real_act_stage1_prepare): Ditto.
(activation_success_handler): Ditto.
(get_property): Ditto.
* src/nm-device-802-3-ethernet.c (real_get_best_connection):
* Remove unused
variable.
* src/ppp-manager/nm-pppd-plugin.c (nm_ip_up): Remove the check
* for 'ifname',
it's always set.
* src/supplicant-manager/nm-supplicant-config.c
(nm_supplicant_config_add_setting_wireless): Cast the
GByteArray's 'guint8 *'
to expected "char *".
(nm_supplicant_config_add_setting_wireless): Ditto.
(nm_supplicant_config_remove_option): Remove, not used.
* libnm-glib/libnm-glib-test.c (dump_access_point): Frequency is
* a guint32,
not double.
(test_wireless_enabled): Ifdef out unused function.
(device_deactivate): Ditto.
(device_state_changed): Ditto.
(nm_utils_is_empty_ssid): Remove, it's now in libnm-utils.
(nm_utils_escape_ssid): Ditto.
* test/nm-tool.c (nm_utils_escape_ssid): Remove, it's now in
* libnm-utils.
(nm_utils_is_empty_ssid): Ditto.
* libnm-glib/nm-client.c
* (nm_client_free_active_connection_element): Remove
unused variable.
* libnm-util/nm-setting.c (setting_wireless_destroy): Remove
* unused variable.
(setting_vpn_properties_update_secrets): Ditto.
(int_to_gvalue): Ifdef out for now, not used.
(byte_to_gvalue): Ditto.
* libnm-util/dbus-dict-helpers.c
* (_nmu_dbus_add_dict_entry_string_array):
Unused, remove.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2960 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
163 lines
3.8 KiB
C
163 lines
3.8 KiB
C
/* NetworkManager -- Network link manager
|
|
*
|
|
* Ray Strode <rstrode@redhat.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*
|
|
* (C) Copyright 2005 Red Hat, Inc.
|
|
*/
|
|
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <iwlib.h>
|
|
#include <wireless.h>
|
|
|
|
#include <glib.h>
|
|
#include <glib-object.h>
|
|
#include <dbus/dbus.h>
|
|
#include "nm-utils.h"
|
|
|
|
/* Shamelessly ripped from the Linux kernel ieee80211 stack */
|
|
gboolean
|
|
nm_utils_is_empty_ssid (const char * ssid, int len)
|
|
{
|
|
/* Single white space is for Linksys APs */
|
|
if (len == 1 && ssid[0] == ' ')
|
|
return TRUE;
|
|
|
|
/* Otherwise, if the entire ssid is 0, we assume it is hidden */
|
|
while (len--) {
|
|
if (ssid[len] != '\0')
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
const char *
|
|
nm_utils_escape_ssid (const guint8 * ssid, guint32 len)
|
|
{
|
|
static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
|
|
const guint8 *s = ssid;
|
|
char *d = escaped;
|
|
|
|
if (nm_utils_is_empty_ssid ((const char *) ssid, len)) {
|
|
memcpy (escaped, "<hidden>", sizeof ("<hidden>"));
|
|
return escaped;
|
|
}
|
|
|
|
len = MIN (len, (guint32) IW_ESSID_MAX_SIZE);
|
|
while (len--) {
|
|
if (*s == '\0') {
|
|
*d++ = '\\';
|
|
*d++ = '0';
|
|
s++;
|
|
} else {
|
|
*d++ = *s++;
|
|
}
|
|
}
|
|
*d = '\0';
|
|
return escaped;
|
|
}
|
|
|
|
gboolean
|
|
nm_utils_same_ssid (const GByteArray * ssid1,
|
|
const GByteArray * ssid2,
|
|
gboolean ignore_trailing_null)
|
|
{
|
|
guint32 ssid1_len, ssid2_len;
|
|
|
|
if (ssid1 == ssid2)
|
|
return TRUE;
|
|
if ((ssid1 && !ssid2) || (!ssid1 && ssid2))
|
|
return FALSE;
|
|
|
|
ssid1_len = ssid1->len;
|
|
ssid2_len = ssid2->len;
|
|
if (ssid1_len && ssid2_len && ignore_trailing_null) {
|
|
if (ssid1->data[ssid1_len - 1] == '\0')
|
|
ssid1_len--;
|
|
if (ssid2->data[ssid2_len - 1] == '\0')
|
|
ssid2_len--;
|
|
}
|
|
|
|
if (ssid1_len != ssid2_len)
|
|
return FALSE;
|
|
|
|
return memcmp (ssid1->data, ssid2->data, ssid1_len) == 0 ? TRUE : FALSE;
|
|
}
|
|
|
|
static void
|
|
value_destroy (gpointer data)
|
|
{
|
|
GValue *value = (GValue *) data;
|
|
|
|
g_value_unset (value);
|
|
g_slice_free (GValue, value);
|
|
}
|
|
|
|
static void
|
|
value_dup (gpointer key, gpointer val, gpointer user_data)
|
|
{
|
|
GHashTable *dup = (GHashTable *) user_data;
|
|
GValue *value = (GValue *) val;
|
|
GValue *dup_value;
|
|
|
|
dup_value = g_slice_new0 (GValue);
|
|
g_value_init (dup_value, G_VALUE_TYPE (val));
|
|
g_value_copy (value, dup_value);
|
|
|
|
g_hash_table_insert (dup, g_strdup ((char *) key), dup_value);
|
|
}
|
|
|
|
GHashTable *
|
|
nm_utils_gvalue_hash_dup (GHashTable *hash)
|
|
{
|
|
GHashTable *dup;
|
|
|
|
g_return_val_if_fail (hash != NULL, NULL);
|
|
|
|
dup = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
(GDestroyNotify) g_free,
|
|
value_destroy);
|
|
|
|
g_hash_table_foreach (hash, value_dup, dup);
|
|
|
|
return dup;
|
|
}
|
|
|
|
char *
|
|
nm_utils_garray_to_string (GArray *array)
|
|
{
|
|
GString *str;
|
|
int i;
|
|
char c;
|
|
|
|
g_return_val_if_fail (array != NULL, NULL);
|
|
|
|
str = g_string_sized_new (array->len);
|
|
for (i = 0; i < array->len; i++) {
|
|
c = array->data[i];
|
|
|
|
/* Convert NULLs to spaces to increase the readability. */
|
|
if (c == '\0')
|
|
c = ' ';
|
|
str = g_string_append_c (str, c);
|
|
}
|
|
str = g_string_append_c (str, '\0');
|
|
|
|
return g_string_free (str, FALSE);
|
|
}
|