[PATCH] ifupdown plugin - wep-tx-keyidx support
- From: Alexander Sack <asac jwsdot com>
- To: networkmanager-list gnome org
- Subject: [PATCH] ifupdown plugin - wep-tx-keyidx support
- Date: Wed, 1 Oct 2008 23:53:31 +0200
Implement support for wep-tx-keyidx in ifupdown system
config plugin.
- Alexander
=== modified file 'ChangeLog'
--- ChangeLog 2008-09-30 16:48:16 +0000
+++ ChangeLog 2008-10-01 21:35:45 +0000
@@ -1,8 +1,22 @@
+2008-09-31 Alexander Sack <asac ubuntu com>
+
+ Implement support for wep-tx-keyidx in ifupdown system
+ config plugin.
+
+ * system-settings/plugins/ifupdown/parser.c
+ - (update_wireless_security_setting_from_if_block): split
+ type_mapping table into alloc_type_mapping and
+ auto_type_mapping; only free mapped variables produced
+ by auto_type_mappings; add wpa security mapping for
+ wep-tx-keyidx property
+ - (string_to_gpointerint): new function used for the auto_type_mapping
+ of new wep-tx-keyidx property
+
2008-09-30 Dan Williams <dcbw redhat com>
* src/NetworkManagerPolicy.c
- (lookup_thread_worker): don't store the idle handler ID becuase the
idle handler could have already run and freed the LookupThread
structure
2008-09-30 Tambet Ingo <tambet gmail com>
=== modified file 'system-settings/plugins/ifupdown/parser.c'
--- system-settings/plugins/ifupdown/parser.c 2008-09-18 15:29:59 +0000
+++ system-settings/plugins/ifupdown/parser.c 2008-10-01 21:04:07 +0000
@@ -18,16 +18,17 @@
* 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 2008 Canonical Ltd.
*/
#include <string.h>
#include <arpa/inet.h>
+#include <stdlib.h>
#include <nm-connection.h>
#include <NetworkManager.h>
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-ppp.h>
#include <nm-setting-wired.h>
#include <nm-setting-wireless.h>
@@ -202,16 +203,23 @@ static char *normalize_psk (gpointer val
pbkdf2_sha1 (value, (char *) s_wireless->ssid->data, s_wireless->ssid->len, 4096, buf, WPA_PMK_LEN);
normalized = utils_bin2hexstr ((const char *) buf, WPA_PMK_LEN, WPA_PMK_LEN * 2);
g_free (buf);
}
return normalized;
}
static gpointer
+string_to_gpointerint(const gchar* data)
+{
+ gint result = atoi (data);
+ return GINT_TO_POINTER(result);
+}
+
+static gpointer
string_to_glist_of_strings(const gchar* data)
{
GSList *ret = NULL;
gchar *string = (gchar*) data;
while(string) {
gchar* next = NULL;
if( (next = strchr(string, ' ')) ||
(next = strchr(string, '\t')) ||
@@ -247,16 +255,17 @@ update_wireless_security_setting_from_if
{"group", "group"},
{"pairwise", "pairwise"},
{"proto", "proto"},
{"pin", "pin"},
{"wep-key0", "wep-key0"},
{"wep-key1", "wep-key1"},
{"wep-key2", "wep-key2"},
{"wep-key3", "wep-key3"},
+ {"wep-tx-keyidx", "wep-tx-keyidx"},
{ NULL, NULL}
};
struct _Mapping dupe_mapping[] = {
{"psk", normalize_psk},
{"identity", normalize_dupe},
{"password", normalize_dupe},
{"key", normalize_dupe},
@@ -264,26 +273,31 @@ update_wireless_security_setting_from_if
{"group", normalize_tolower},
{"pairwise", normalize_tolower},
{"proto", normalize_tolower},
{"pin", normalize_dupe},
{"wep-key0", normalize_dupe},
{"wep-key1", normalize_dupe},
{"wep-key2", normalize_dupe},
{"wep-key3", normalize_dupe},
+ {"wep-tx-keyidx", normalize_dupe},
{ NULL, NULL}
};
- struct _Mapping type_mapping[] = {
+ struct _Mapping alloc_type_mapping[] = {
{"group", string_to_glist_of_strings},
{"pairwise", string_to_glist_of_strings},
{"proto", string_to_glist_of_strings},
{ NULL, NULL}
};
+ struct _Mapping auto_type_mapping[] = {
+ {"wep-tx-keyidx", string_to_gpointerint},
+ { NULL, NULL}
+ };
NMSettingWirelessSecurity *wireless_security_setting;
NMSettingWireless *s_wireless;
gboolean security = FALSE;
if(value && !strcmp("ppp", value)) {
return;
}
@@ -299,42 +313,47 @@ update_wireless_security_setting_from_if
while(curr) {
if(strlen(curr->key) > wireless_l &&
!strncmp("wireless-", curr->key, wireless_l)) {
gchar *property_value = NULL;
gpointer property_value2 = NULL;
const gchar* newkey = map_by_mapping(mapping, curr->key+wireless_l);
IfupdownStrDupeFunc func = map_by_mapping (dupe_mapping, curr->key+wireless_l);
- IfupdownStrToTypeFunc func1 = map_by_mapping (type_mapping, curr->key+wireless_l);
+ IfupdownStrToTypeFunc func1_alloc = map_by_mapping (alloc_type_mapping, curr->key+wireless_l);
+ IfupdownStrToTypeFunc func1_auto = map_by_mapping (auto_type_mapping, curr->key+wireless_l);
if(!newkey || !func) {
g_warning("no (wireless) mapping found for key: %s", curr->key);
goto next;
}
property_value = (*func) (curr->data, connection);
PLUGIN_PRINT ("SCPlugin-Ifupdown", "setting wireless security key: %s=%s",
newkey, property_value);
- if(func1)
- property_value2 = (*func1) (property_value);
+ if (func1_alloc)
+ property_value2 = (*func1_alloc) (property_value);
+ else if (func1_auto)
+ property_value2 = (*func1_auto) (property_value);
g_object_set(wireless_security_setting,
newkey, property_value2 ? property_value2 : property_value,
NULL);
security = TRUE;
g_free(property_value);
- if(property_value)
+ if (func1_alloc && property_value2)
g_free(property_value2);
+
} else if(strlen(curr->key) > wpa_l &&
!strncmp("wpa-", curr->key, wpa_l)) {
gchar *property_value = NULL;
gpointer property_value2 = NULL;
const gchar* newkey = map_by_mapping(mapping, curr->key+wpa_l);
IfupdownStrDupeFunc func = map_by_mapping (dupe_mapping, curr->key+wpa_l);
- IfupdownStrToTypeFunc func1 = map_by_mapping (type_mapping, curr->key+wpa_l);
+ IfupdownStrToTypeFunc func1_alloc = map_by_mapping (alloc_type_mapping, curr->key+wpa_l);
+ IfupdownStrToTypeFunc func1_auto = map_by_mapping (auto_type_mapping, curr->key+wpa_l);
if(!newkey || !func) {
goto next;
}
property_value = (*func) (curr->data, connection);
PLUGIN_PRINT ("SCPlugin-Ifupdown", "setting wpa security key: %s=%s",
newkey,
#ifdef DEBUG_SECRETS
property_value
@@ -347,24 +366,28 @@ update_wireless_security_setting_from_if
!strcmp("wep-key1", newkey) ||
!strcmp("wep-key2", newkey) ||
!strcmp("wep-key3", newkey) ||
NULL ?
"<omitted>" : property_value
#endif // DEBUG_SECRETS
);
- if(func1)
- property_value2 = (*func1) (property_value);
+ if (func1_alloc)
+ property_value2 = (*func1_alloc) (property_value);
+ else if (func1_auto)
+ property_value2 = (*func1_auto) (property_value);
g_object_set(wireless_security_setting,
newkey, property_value2 ? property_value2 : property_value,
NULL);
security = TRUE;
g_free(property_value);
+ if (func1_alloc && property_value2)
+ g_free (property_value2);
}
next:
curr = curr->next;
}
if(security) {
nm_connection_add_setting(connection, NM_SETTING(wireless_security_setting));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]