2008-10-03 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): introduce free_type_mapping func table; rename a few local variables to improve readability; 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 - (slist_free_all): free func used for mapped slist types git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4148 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:

committed by
Dan Williams

parent
e28b126389
commit
312d04c359
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
|||||||
|
2008-10-03 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): introduce
|
||||||
|
free_type_mapping func table; rename a few local
|
||||||
|
variables to improve readability; 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
|
||||||
|
- (slist_free_all): free func used for mapped slist types
|
||||||
|
|
||||||
2008-10-03 Alexander Sack <asac@ubuntu.com>
|
2008-10-03 Alexander Sack <asac@ubuntu.com>
|
||||||
|
|
||||||
* system-settings/src/main.c:
|
* system-settings/src/main.c:
|
||||||
|
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nm-connection.h>
|
#include <nm-connection.h>
|
||||||
#include <NetworkManager.h>
|
#include <NetworkManager.h>
|
||||||
@@ -206,6 +208,13 @@ static char *normalize_psk (gpointer value, gpointer data) {
|
|||||||
return normalized;
|
return normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
string_to_gpointerint(const gchar* data)
|
||||||
|
{
|
||||||
|
gint result = (gint) strtol (data, NULL, 10);
|
||||||
|
return GINT_TO_POINTER(result);
|
||||||
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
string_to_glist_of_strings(const gchar* data)
|
string_to_glist_of_strings(const gchar* data)
|
||||||
{
|
{
|
||||||
@@ -230,6 +239,14 @@ string_to_glist_of_strings(const gchar* data)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
slist_free_all(gpointer slist)
|
||||||
|
{
|
||||||
|
GSList *list = (GSList *) slist;
|
||||||
|
g_slist_foreach (list, (GFunc) g_free, NULL);
|
||||||
|
g_slist_free (list);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_wireless_security_setting_from_if_block(NMConnection *connection,
|
update_wireless_security_setting_from_if_block(NMConnection *connection,
|
||||||
if_block *block)
|
if_block *block)
|
||||||
@@ -252,6 +269,7 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
|||||||
{"wep-key1", "wep-key1"},
|
{"wep-key1", "wep-key1"},
|
||||||
{"wep-key2", "wep-key2"},
|
{"wep-key2", "wep-key2"},
|
||||||
{"wep-key3", "wep-key3"},
|
{"wep-key3", "wep-key3"},
|
||||||
|
{"wep-tx-keyidx", "wep-tx-keyidx"},
|
||||||
{ NULL, NULL}
|
{ NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -269,6 +287,7 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
|||||||
{"wep-key1", normalize_dupe},
|
{"wep-key1", normalize_dupe},
|
||||||
{"wep-key2", normalize_dupe},
|
{"wep-key2", normalize_dupe},
|
||||||
{"wep-key3", normalize_dupe},
|
{"wep-key3", normalize_dupe},
|
||||||
|
{"wep-tx-keyidx", normalize_dupe},
|
||||||
{ NULL, NULL}
|
{ NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -276,9 +295,16 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
|||||||
{"group", string_to_glist_of_strings},
|
{"group", string_to_glist_of_strings},
|
||||||
{"pairwise", string_to_glist_of_strings},
|
{"pairwise", string_to_glist_of_strings},
|
||||||
{"proto", string_to_glist_of_strings},
|
{"proto", string_to_glist_of_strings},
|
||||||
|
{"wep-tx-keyidx", string_to_gpointerint},
|
||||||
{ NULL, NULL}
|
{ NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _Mapping free_type_mapping[] = {
|
||||||
|
{"group", slist_free_all},
|
||||||
|
{"pairwise", slist_free_all},
|
||||||
|
{"proto", slist_free_all},
|
||||||
|
{ NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
NMSettingWirelessSecurity *wireless_security_setting;
|
NMSettingWirelessSecurity *wireless_security_setting;
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
@@ -301,39 +327,49 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
|||||||
!strncmp("wireless-", curr->key, wireless_l)) {
|
!strncmp("wireless-", curr->key, wireless_l)) {
|
||||||
|
|
||||||
gchar *property_value = NULL;
|
gchar *property_value = NULL;
|
||||||
gpointer property_value2 = NULL;
|
gpointer typed_property_value = NULL;
|
||||||
const gchar* newkey = map_by_mapping(mapping, curr->key+wireless_l);
|
const gchar* newkey = map_by_mapping(mapping, curr->key+wireless_l);
|
||||||
IfupdownStrDupeFunc func = map_by_mapping (dupe_mapping, curr->key+wireless_l);
|
IfupdownStrDupeFunc dupe_func = map_by_mapping (dupe_mapping, curr->key+wireless_l);
|
||||||
IfupdownStrToTypeFunc func1 = map_by_mapping (type_mapping, curr->key+wireless_l);
|
IfupdownStrToTypeFunc type_map_func = map_by_mapping (type_mapping, curr->key+wireless_l);
|
||||||
if(!newkey || !func) {
|
GFreeFunc free_func = map_by_mapping (free_type_mapping, curr->key+wireless_l);
|
||||||
|
if(!newkey || !dupe_func) {
|
||||||
g_warning("no (wireless) mapping found for key: %s", curr->key);
|
g_warning("no (wireless) mapping found for key: %s", curr->key);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
property_value = (*func) (curr->data, connection);
|
property_value = (*dupe_func) (curr->data, connection);
|
||||||
PLUGIN_PRINT ("SCPlugin-Ifupdown", "setting wireless security key: %s=%s",
|
PLUGIN_PRINT ("SCPlugin-Ifupdown", "setting wireless security key: %s=%s",
|
||||||
newkey, property_value);
|
newkey, property_value);
|
||||||
if(func1)
|
|
||||||
property_value2 = (*func1) (property_value);
|
if (type_map_func) {
|
||||||
|
errno = 0;
|
||||||
|
typed_property_value = (*type_map_func) (property_value);
|
||||||
|
if(errno)
|
||||||
|
goto wireless_next;
|
||||||
|
}
|
||||||
|
|
||||||
g_object_set(wireless_security_setting,
|
g_object_set(wireless_security_setting,
|
||||||
newkey, property_value2 ? property_value2 : property_value,
|
newkey, typed_property_value ? typed_property_value : property_value,
|
||||||
NULL);
|
NULL);
|
||||||
security = TRUE;
|
security = TRUE;
|
||||||
|
|
||||||
|
wireless_next:
|
||||||
g_free(property_value);
|
g_free(property_value);
|
||||||
if(property_value)
|
if (typed_property_value && free_func)
|
||||||
g_free(property_value2);
|
(*free_func) (typed_property_value);
|
||||||
|
|
||||||
} else if(strlen(curr->key) > wpa_l &&
|
} else if(strlen(curr->key) > wpa_l &&
|
||||||
!strncmp("wpa-", curr->key, wpa_l)) {
|
!strncmp("wpa-", curr->key, wpa_l)) {
|
||||||
|
|
||||||
gchar *property_value = NULL;
|
gchar *property_value = NULL;
|
||||||
gpointer property_value2 = NULL;
|
gpointer typed_property_value = NULL;
|
||||||
const gchar* newkey = map_by_mapping(mapping, curr->key+wpa_l);
|
const gchar* newkey = map_by_mapping(mapping, curr->key+wpa_l);
|
||||||
IfupdownStrDupeFunc func = map_by_mapping (dupe_mapping, curr->key+wpa_l);
|
IfupdownStrDupeFunc dupe_func = map_by_mapping (dupe_mapping, curr->key+wpa_l);
|
||||||
IfupdownStrToTypeFunc func1 = map_by_mapping (type_mapping, curr->key+wpa_l);
|
IfupdownStrToTypeFunc type_map_func = map_by_mapping (type_mapping, curr->key+wpa_l);
|
||||||
if(!newkey || !func) {
|
GFreeFunc free_func = map_by_mapping (free_type_mapping, curr->key+wpa_l);
|
||||||
|
if(!newkey || !dupe_func) {
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
property_value = (*func) (curr->data, connection);
|
property_value = (*dupe_func) (curr->data, connection);
|
||||||
PLUGIN_PRINT ("SCPlugin-Ifupdown", "setting wpa security key: %s=%s",
|
PLUGIN_PRINT ("SCPlugin-Ifupdown", "setting wpa security key: %s=%s",
|
||||||
newkey,
|
newkey,
|
||||||
#ifdef DEBUG_SECRETS
|
#ifdef DEBUG_SECRETS
|
||||||
@@ -352,14 +388,22 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
|||||||
#endif // DEBUG_SECRETS
|
#endif // DEBUG_SECRETS
|
||||||
);
|
);
|
||||||
|
|
||||||
if(func1)
|
if (type_map_func) {
|
||||||
property_value2 = (*func1) (property_value);
|
errno = 0;
|
||||||
|
typed_property_value = (*type_map_func) (property_value);
|
||||||
|
if(errno)
|
||||||
|
goto wpa_next;
|
||||||
|
}
|
||||||
|
|
||||||
g_object_set(wireless_security_setting,
|
g_object_set(wireless_security_setting,
|
||||||
newkey, property_value2 ? property_value2 : property_value,
|
newkey, typed_property_value ? typed_property_value : property_value,
|
||||||
NULL);
|
NULL);
|
||||||
security = TRUE;
|
security = TRUE;
|
||||||
|
|
||||||
|
wpa_next:
|
||||||
g_free(property_value);
|
g_free(property_value);
|
||||||
|
if (free_func && typed_property_value)
|
||||||
|
(*free_func) (typed_property_value);
|
||||||
}
|
}
|
||||||
next:
|
next:
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
|
Reference in New Issue
Block a user