2005-12-16 Dan Williams <dcbw@redhat.com>
* Kill auth_method for access points, since that's now done by NMAPSecurity objects * Add a copy-constructor of sorts to NMAPSecurity (how do you do this properly in glib???) git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1200 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
2005-12-16 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* Kill auth_method for access points, since that's now done
|
||||||
|
by NMAPSecurity objects
|
||||||
|
|
||||||
|
* Add a copy-constructor of sorts to NMAPSecurity
|
||||||
|
(how do you do this properly in glib???)
|
||||||
|
|
||||||
2005-12-15 Dan Williams <dcbw@redhat.com>
|
2005-12-15 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* Exorcise encryption key hashing on APs
|
* Exorcise encryption key hashing on APs
|
||||||
|
@@ -55,11 +55,6 @@ struct NMAccessPoint
|
|||||||
NMAPSecurity * security;
|
NMAPSecurity * security;
|
||||||
GTimeVal timestamp;
|
GTimeVal timestamp;
|
||||||
GSList * user_addresses;
|
GSList * user_addresses;
|
||||||
|
|
||||||
/* Soon to be banished */
|
|
||||||
char * enc_key;
|
|
||||||
NMEncKeyType enc_type;
|
|
||||||
int auth_method; /* from wireless.h; -1 is unknown, zero is none */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This is a controlled list. Want to add to it? Stop. Ask first. */
|
/* This is a controlled list. Want to add to it? Stop. Ask first. */
|
||||||
@@ -90,7 +85,6 @@ NMAccessPoint * nm_ap_new (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ap->mode = IW_MODE_INFRA;
|
ap->mode = IW_MODE_INFRA;
|
||||||
ap->auth_method = -1;
|
|
||||||
ap->refcount = 1;
|
ap->refcount = 1;
|
||||||
|
|
||||||
return (ap);
|
return (ap);
|
||||||
@@ -133,10 +127,10 @@ NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *src_ap)
|
|||||||
new_ap->rate = src_ap->rate;
|
new_ap->rate = src_ap->rate;
|
||||||
new_ap->capabilities = src_ap->capabilities;
|
new_ap->capabilities = src_ap->capabilities;
|
||||||
|
|
||||||
if (src_ap->enc_key && (strlen (src_ap->enc_key) > 0))
|
if (src_ap->security)
|
||||||
new_ap->enc_key = g_strdup (src_ap->enc_key);
|
new_ap->security = nm_ap_security_new_copy (src_ap->security);
|
||||||
|
|
||||||
return (new_ap);
|
return new_ap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -159,7 +153,6 @@ void nm_ap_unref (NMAccessPoint *ap)
|
|||||||
{
|
{
|
||||||
g_free (ap->essid);
|
g_free (ap->essid);
|
||||||
g_free (ap->address);
|
g_free (ap->address);
|
||||||
g_free (ap->enc_key);
|
|
||||||
g_slist_foreach (ap->user_addresses, (GFunc)g_free, NULL);
|
g_slist_foreach (ap->user_addresses, (GFunc)g_free, NULL);
|
||||||
g_slist_free (ap->user_addresses);
|
g_slist_free (ap->user_addresses);
|
||||||
|
|
||||||
@@ -167,7 +160,6 @@ void nm_ap_unref (NMAccessPoint *ap)
|
|||||||
g_object_unref (G_OBJECT (ap->security));
|
g_object_unref (G_OBJECT (ap->security));
|
||||||
|
|
||||||
ap->essid = NULL;
|
ap->essid = NULL;
|
||||||
ap->enc_key = NULL;
|
|
||||||
|
|
||||||
g_free (ap);
|
g_free (ap);
|
||||||
memset (ap, 0, sizeof (NMAccessPoint));
|
memset (ap, 0, sizeof (NMAccessPoint));
|
||||||
@@ -229,7 +221,9 @@ gboolean nm_ap_get_encrypted (const NMAccessPoint *ap)
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, FALSE);
|
g_return_val_if_fail (ap != NULL, FALSE);
|
||||||
|
|
||||||
return (ap->capabilities & NM_802_11_CAP_PROTO_WEP);
|
return ((ap->capabilities & NM_802_11_CAP_PROTO_WEP)
|
||||||
|
|| (ap->capabilities & NM_802_11_CAP_PROTO_WPA)
|
||||||
|
|| (ap->capabilities & NM_802_11_CAP_PROTO_WPA2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean privacy)
|
void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean privacy)
|
||||||
@@ -242,38 +236,6 @@ void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean privacy)
|
|||||||
ap->capabilities &= ~NM_802_11_CAP_PROTO_WEP;
|
ap->capabilities &= ~NM_802_11_CAP_PROTO_WEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the encryption method the user specified for this access point.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NMEncKeyType nm_ap_get_enc_type (const NMAccessPoint *ap)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (ap != NULL, TRUE);
|
|
||||||
|
|
||||||
return (ap->enc_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get/set functions for auth_method
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int nm_ap_get_auth_method (const NMAccessPoint *ap)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (ap != NULL, -1);
|
|
||||||
|
|
||||||
return (ap->auth_method);
|
|
||||||
}
|
|
||||||
|
|
||||||
void nm_ap_set_auth_method (NMAccessPoint *ap, int auth_method)
|
|
||||||
{
|
|
||||||
g_return_if_fail (ap != NULL);
|
|
||||||
|
|
||||||
ap->auth_method = auth_method;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Accessorts for AP security info
|
* Accessorts for AP security info
|
||||||
*
|
*
|
||||||
@@ -296,10 +258,7 @@ void nm_ap_set_security (NMAccessPoint *ap, NMAPSecurity *security)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (security)
|
if (security)
|
||||||
{
|
ap->security = nm_ap_security_new_copy (security);
|
||||||
g_object_ref (G_OBJECT (security));
|
|
||||||
ap->security = security;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -43,11 +43,6 @@ void nm_ap_set_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp);
|
|||||||
char * nm_ap_get_essid (const NMAccessPoint *ap);
|
char * nm_ap_get_essid (const NMAccessPoint *ap);
|
||||||
void nm_ap_set_essid (NMAccessPoint *ap, const char *essid);
|
void nm_ap_set_essid (NMAccessPoint *ap, const char *essid);
|
||||||
|
|
||||||
NMEncKeyType nm_ap_get_enc_type (const NMAccessPoint *ap);
|
|
||||||
|
|
||||||
int nm_ap_get_auth_method (const NMAccessPoint *ap);
|
|
||||||
void nm_ap_set_auth_method (NMAccessPoint *ap, int auth_method);
|
|
||||||
|
|
||||||
gboolean nm_ap_get_encrypted (const NMAccessPoint *ap);
|
gboolean nm_ap_get_encrypted (const NMAccessPoint *ap);
|
||||||
void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean privacy);
|
void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean privacy);
|
||||||
|
|
||||||
|
@@ -458,7 +458,6 @@ gboolean nm_ap_list_merge_scanned_ap (NMAccessPointList *list, NMAccessPoint *me
|
|||||||
const GTimeVal *merge_ap_seen = nm_ap_get_last_seen (merge_ap);
|
const GTimeVal *merge_ap_seen = nm_ap_get_last_seen (merge_ap);
|
||||||
|
|
||||||
nm_ap_set_encrypted (list_ap_addr, nm_ap_get_encrypted (merge_ap));
|
nm_ap_set_encrypted (list_ap_addr, nm_ap_get_encrypted (merge_ap));
|
||||||
nm_ap_set_auth_method (list_ap_addr, nm_ap_get_auth_method (merge_ap));
|
|
||||||
if (nm_ap_get_strength (merge_ap) != nm_ap_get_strength (list_ap_addr))
|
if (nm_ap_get_strength (merge_ap) != nm_ap_get_strength (list_ap_addr))
|
||||||
{
|
{
|
||||||
nm_ap_set_strength (list_ap_addr, nm_ap_get_strength (merge_ap));
|
nm_ap_set_strength (list_ap_addr, nm_ap_get_strength (merge_ap));
|
||||||
@@ -482,7 +481,6 @@ gboolean nm_ap_list_merge_scanned_ap (NMAccessPointList *list, NMAccessPoint *me
|
|||||||
const GTimeVal *list_ap_essid_seen = nm_ap_get_last_seen (list_ap_essid);
|
const GTimeVal *list_ap_essid_seen = nm_ap_get_last_seen (list_ap_essid);
|
||||||
|
|
||||||
nm_ap_set_encrypted (list_ap_essid, nm_ap_get_encrypted (merge_ap));
|
nm_ap_set_encrypted (list_ap_essid, nm_ap_get_encrypted (merge_ap));
|
||||||
nm_ap_set_auth_method (list_ap_essid, nm_ap_get_auth_method (merge_ap));
|
|
||||||
|
|
||||||
if (!((list_ap_essid_seen->tv_sec == merge_ap_seen->tv_sec)
|
if (!((list_ap_essid_seen->tv_sec == merge_ap_seen->tv_sec)
|
||||||
&& (nm_ap_get_strength (list_ap_essid) >= nm_ap_get_strength (merge_ap))))
|
&& (nm_ap_get_strength (list_ap_essid) >= nm_ap_get_strength (merge_ap))))
|
||||||
|
@@ -826,6 +826,7 @@ static void nm_dbus_get_network_data_cb (DBusPendingCall *pcall, void *user_data
|
|||||||
ap = nm_ap_new ();
|
ap = nm_ap_new ();
|
||||||
nm_ap_set_essid (ap, essid);
|
nm_ap_set_essid (ap, essid);
|
||||||
nm_ap_set_security (ap, security);
|
nm_ap_set_security (ap, security);
|
||||||
|
g_object_unref (G_OBJECT (security)); /* set_security copies the object */
|
||||||
|
|
||||||
timestamp = g_malloc0 (sizeof (GTimeVal));
|
timestamp = g_malloc0 (sizeof (GTimeVal));
|
||||||
timestamp->tv_sec = timestamp_secs;
|
timestamp->tv_sec = timestamp_secs;
|
||||||
|
@@ -310,14 +310,7 @@ void nm_device_copy_allowed_to_dev_list (NMDevice *dev, NMAccessPointList *allow
|
|||||||
dev_list = nm_device_ap_list_get (dev);
|
dev_list = nm_device_ap_list_get (dev);
|
||||||
while ((src_ap = nm_ap_list_iter_next (iter)))
|
while ((src_ap = nm_ap_list_iter_next (iter)))
|
||||||
{
|
{
|
||||||
NMAccessPoint *dst_ap = nm_ap_new_from_ap (src_ap);
|
NMAccessPoint * dst_ap = nm_ap_new_from_ap (src_ap);
|
||||||
|
|
||||||
/* Assume that if the allowed list AP has a saved encryption
|
|
||||||
* key that the AP is encrypted.
|
|
||||||
*/
|
|
||||||
if ( (nm_ap_get_auth_method (src_ap) == IW_AUTH_ALG_OPEN_SYSTEM)
|
|
||||||
|| (nm_ap_get_auth_method (src_ap) == IW_AUTH_ALG_SHARED_KEY))
|
|
||||||
nm_ap_set_encrypted (dst_ap, TRUE);
|
|
||||||
|
|
||||||
nm_ap_list_append_ap (dev_list, dst_ap);
|
nm_ap_list_append_ap (dev_list, dst_ap);
|
||||||
nm_ap_unref (dst_ap);
|
nm_ap_unref (dst_ap);
|
||||||
@@ -1475,11 +1468,11 @@ void nm_device_get_ap_address (NMDevice *dev, struct ether_addr *addr)
|
|||||||
*/
|
*/
|
||||||
void nm_device_set_enc_key (NMDevice *dev, const char *key, int auth_method)
|
void nm_device_set_enc_key (NMDevice *dev, const char *key, int auth_method)
|
||||||
{
|
{
|
||||||
NMSock *sk;
|
NMSock * sk;
|
||||||
struct iwreq wreq;
|
struct iwreq wreq;
|
||||||
int keylen;
|
int keylen;
|
||||||
unsigned char safe_key[IW_ENCODING_TOKEN_MAX + 1];
|
unsigned char safe_key[IW_ENCODING_TOKEN_MAX + 1];
|
||||||
gboolean set_key = FALSE;
|
gboolean set_key = FALSE;
|
||||||
|
|
||||||
g_return_if_fail (dev != NULL);
|
g_return_if_fail (dev != NULL);
|
||||||
g_return_if_fail (nm_device_is_802_11_wireless (dev));
|
g_return_if_fail (nm_device_is_802_11_wireless (dev));
|
||||||
@@ -2582,30 +2575,10 @@ static void nm_device_wireless_configure (NMActRequest *req)
|
|||||||
|
|
||||||
if (!link)
|
if (!link)
|
||||||
{
|
{
|
||||||
if (nm_ap_get_auth_method (ap) == IW_AUTH_ALG_OPEN_SYSTEM)
|
nm_debug ("Activation (%s/wireless): no hardware link to '%s'.",
|
||||||
{
|
nm_device_get_iface (dev), nm_ap_get_essid (ap) ? nm_ap_get_essid (ap) : "(none)");
|
||||||
nm_debug ("Activation (%s/wireless): no hardware link to '%s' in Open System mode, trying Shared Key.",
|
nm_policy_schedule_activation_failed (req);
|
||||||
nm_device_get_iface (dev), nm_ap_get_essid (ap) ? nm_ap_get_essid (ap) : "(none)");
|
break;
|
||||||
/* Back down to Shared Key mode */
|
|
||||||
nm_ap_set_auth_method (ap, IW_AUTH_ALG_SHARED_KEY);
|
|
||||||
success = FALSE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (nm_ap_get_auth_method (ap) == IW_AUTH_ALG_SHARED_KEY)
|
|
||||||
{
|
|
||||||
/* Didn't work in Shared Key either. */
|
|
||||||
nm_debug ("Activation (%s/wireless): no hardware link to '%s' in Shared Key mode, need correct key?",
|
|
||||||
nm_device_get_iface (dev), nm_ap_get_essid (ap) ? nm_ap_get_essid (ap) : "(none)");
|
|
||||||
nm_dbus_get_user_key_for_network (data->dbus_connection, req, TRUE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nm_debug ("Activation (%s/wireless): no hardware link to '%s' in non-encrypted mode.",
|
|
||||||
nm_device_get_iface (dev), nm_ap_get_essid (ap) ? nm_ap_get_essid (ap) : "(none)");
|
|
||||||
nm_policy_schedule_activation_failed (req);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2972,25 +2945,17 @@ static gboolean nm_device_activate_stage4_ip_config_timeout (NMActRequest *req)
|
|||||||
else if (nm_device_is_802_11_wireless (dev))
|
else if (nm_device_is_802_11_wireless (dev))
|
||||||
{
|
{
|
||||||
NMAccessPoint *ap = nm_act_request_get_ap (req);
|
NMAccessPoint *ap = nm_act_request_get_ap (req);
|
||||||
|
NMAPSecurity * security;
|
||||||
|
|
||||||
g_assert (ap);
|
g_assert (ap);
|
||||||
|
|
||||||
/* For those broken cards that report successful hardware link even when WEP key is wrong,
|
security = nm_ap_get_security (ap);
|
||||||
* and also for Open System mode (where you cannot know WEP key is wrong ever), we try to
|
|
||||||
* do DHCP and if that fails, fall back to next auth mode and try again.
|
/* FIXME: should we only ask for a new key if the activation request is user-requested? */
|
||||||
*/
|
if (ap && (nm_ap_security_get_we_cipher (security) != IW_AUTH_CIPHER_NONE))
|
||||||
if (nm_ap_get_auth_method (ap) == IW_AUTH_ALG_OPEN_SYSTEM)
|
|
||||||
{
|
{
|
||||||
/* Back down to Shared Key mode */
|
/* Activation failed, we must have bad WEP key */
|
||||||
nm_debug ("Activation (%s/wireless): could not get IP configuration info for '%s' in Open System mode, trying Shared Key.",
|
nm_debug ("Activation (%s/wireless): could not get IP configuration info for '%s', asking for new key.",
|
||||||
nm_device_get_iface (dev), nm_ap_get_essid (ap) ? nm_ap_get_essid (ap) : "(none)");
|
|
||||||
nm_ap_set_auth_method (ap, IW_AUTH_ALG_SHARED_KEY);
|
|
||||||
nm_device_activate_schedule_stage2_device_config (req);
|
|
||||||
}
|
|
||||||
else if ((nm_ap_get_auth_method (ap) == IW_AUTH_ALG_SHARED_KEY))
|
|
||||||
{
|
|
||||||
/* Shared Key mode failed, we must have bad WEP key */
|
|
||||||
nm_debug ("Activation (%s/wireless): could not get IP configuration info for '%s' in Shared Key mode, asking for new key.",
|
|
||||||
nm_device_get_iface (dev), nm_ap_get_essid (ap) ? nm_ap_get_essid (ap) : "(none)");
|
nm_device_get_iface (dev), nm_ap_get_essid (ap) ? nm_ap_get_essid (ap) : "(none)");
|
||||||
nm_dbus_get_user_key_for_network (data->dbus_connection, req, TRUE);
|
nm_dbus_get_user_key_for_network (data->dbus_connection, req, TRUE);
|
||||||
}
|
}
|
||||||
@@ -4519,7 +4484,6 @@ static gboolean process_scan_results (NMDevice *dev, const guint8 *res_buf, guin
|
|||||||
/* New AP with some defaults */
|
/* New AP with some defaults */
|
||||||
ap = nm_ap_new ();
|
ap = nm_ap_new ();
|
||||||
nm_ap_set_address (ap, (const struct ether_addr *)(iwe->u.ap_addr.sa_data));
|
nm_ap_set_address (ap, (const struct ether_addr *)(iwe->u.ap_addr.sa_data));
|
||||||
nm_ap_set_auth_method (ap, IW_AUTH_ALG_OPEN_SYSTEM);
|
|
||||||
nm_ap_set_mode (ap, IW_MODE_INFRA);
|
nm_ap_set_mode (ap, IW_MODE_INFRA);
|
||||||
break;
|
break;
|
||||||
case SIOCGIWMODE:
|
case SIOCGIWMODE:
|
||||||
|
@@ -67,10 +67,6 @@ static gboolean nm_policy_activation_finish (NMActRequest *req)
|
|||||||
/* Cache details in the info-daemon since the connect was successful */
|
/* Cache details in the info-daemon since the connect was successful */
|
||||||
nm_dbus_update_network_info (data->dbus_connection, ap, nm_act_request_get_user_requested (req));
|
nm_dbus_update_network_info (data->dbus_connection, ap, nm_act_request_get_user_requested (req));
|
||||||
|
|
||||||
/* Cache the correct auth method in our AP list too */
|
|
||||||
if ((tmp_ap = nm_ap_list_get_ap_by_essid (data->allowed_ap_list, nm_ap_get_essid (ap))))
|
|
||||||
nm_ap_set_auth_method (tmp_ap, nm_ap_get_auth_method (ap));
|
|
||||||
|
|
||||||
nm_device_get_ap_address (dev, &addr);
|
nm_device_get_ap_address (dev, &addr);
|
||||||
if (!nm_ap_get_address (ap) || !nm_ethernet_address_is_valid (nm_ap_get_address (ap)))
|
if (!nm_ap_get_address (ap) || !nm_ethernet_address_is_valid (nm_ap_get_address (ap)))
|
||||||
nm_ap_set_address (ap, &addr);
|
nm_ap_set_address (ap, &addr);
|
||||||
|
@@ -30,4 +30,6 @@ void nm_ap_security_set_key (NMAPSecurity *self, const char *key, int key_len);
|
|||||||
|
|
||||||
void nm_ap_security_set_description (NMAPSecurity *self, const char *desc);
|
void nm_ap_security_set_description (NMAPSecurity *self, const char *desc);
|
||||||
|
|
||||||
|
void nm_ap_security_copy_properties (NMAPSecurity *self, NMAPSecurity *dst);
|
||||||
|
|
||||||
#endif /* NM_AP_SECURITY_PRIVATE_H */
|
#endif /* NM_AP_SECURITY_PRIVATE_H */
|
||||||
|
@@ -97,6 +97,17 @@ real_device_setup (NMAPSecurity *instance, NMDevice * dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NMAPSecurity *
|
||||||
|
real_copy_constructor (NMAPSecurity *instance)
|
||||||
|
{
|
||||||
|
NMAPSecurityWEP * dst = g_object_new (NM_TYPE_AP_SECURITY_WEP, NULL);
|
||||||
|
NMAPSecurityWEP * self = NM_AP_SECURITY_WEP (instance);
|
||||||
|
|
||||||
|
dst->priv->auth_algorithm = self->priv->auth_algorithm;
|
||||||
|
nm_ap_security_copy_properties (NM_AP_SECURITY (self), NM_AP_SECURITY (dst));
|
||||||
|
return NM_AP_SECURITY (dst);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_ap_security_wep_init (NMAPSecurityWEP * self)
|
nm_ap_security_wep_init (NMAPSecurityWEP * self)
|
||||||
{
|
{
|
||||||
@@ -111,6 +122,7 @@ nm_ap_security_wep_class_init (NMAPSecurityWEPClass *klass)
|
|||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
NMAPSecurityClass *par_class = NM_AP_SECURITY_CLASS (klass);
|
NMAPSecurityClass *par_class = NM_AP_SECURITY_CLASS (klass);
|
||||||
|
|
||||||
|
par_class->copy_constructor_func = real_copy_constructor;
|
||||||
par_class->serialize_func = real_serialize;
|
par_class->serialize_func = real_serialize;
|
||||||
par_class->write_wpa_supplicant_config_func = real_write_wpa_supplicant_config;
|
par_class->write_wpa_supplicant_config_func = real_write_wpa_supplicant_config;
|
||||||
par_class->device_setup_func = real_device_setup;
|
par_class->device_setup_func = real_device_setup;
|
||||||
|
@@ -97,6 +97,18 @@ real_device_setup (NMAPSecurity *self, NMDevice * dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NMAPSecurity *
|
||||||
|
real_copy_constructor (NMAPSecurity *instance)
|
||||||
|
{
|
||||||
|
NMAPSecurityWPA_PSK * dst = g_object_new (NM_TYPE_AP_SECURITY_WPA_PSK, NULL);
|
||||||
|
NMAPSecurityWPA_PSK * self = NM_AP_SECURITY_WPA_PSK (instance);
|
||||||
|
|
||||||
|
dst->priv->wpa_version = self->priv->wpa_version;
|
||||||
|
dst->priv->key_mgt = self->priv->key_mgt;
|
||||||
|
nm_ap_security_copy_properties (NM_AP_SECURITY (self), NM_AP_SECURITY (dst));
|
||||||
|
return NM_AP_SECURITY (dst);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_ap_security_wpa_psk_init (NMAPSecurityWPA_PSK * self)
|
nm_ap_security_wpa_psk_init (NMAPSecurityWPA_PSK * self)
|
||||||
{
|
{
|
||||||
@@ -112,6 +124,7 @@ nm_ap_security_wpa_psk_class_init (NMAPSecurityWPA_PSKClass *klass)
|
|||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
NMAPSecurityClass *par_class = NM_AP_SECURITY_CLASS (klass);
|
NMAPSecurityClass *par_class = NM_AP_SECURITY_CLASS (klass);
|
||||||
|
|
||||||
|
par_class->copy_constructor_func = real_copy_constructor;
|
||||||
par_class->write_wpa_supplicant_config_func = real_write_wpa_supplicant_config;
|
par_class->write_wpa_supplicant_config_func = real_write_wpa_supplicant_config;
|
||||||
par_class->device_setup_func = real_device_setup;
|
par_class->device_setup_func = real_device_setup;
|
||||||
|
|
||||||
|
@@ -138,6 +138,15 @@ nm_ap_security_set_key (NMAPSecurity *self, const char *key, int key_len)
|
|||||||
memcpy (self->priv->key, key, key_len);
|
memcpy (self->priv->key, key, key_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NMAPSecurity *
|
||||||
|
real_copy_constructor (NMAPSecurity *self)
|
||||||
|
{
|
||||||
|
NMAPSecurity * dst = nm_ap_security_new (self->priv->we_cipher);
|
||||||
|
|
||||||
|
nm_ap_security_copy_properties (self, dst);
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
real_serialize (NMAPSecurity *self, DBusMessageIter *iter)
|
real_serialize (NMAPSecurity *self, DBusMessageIter *iter)
|
||||||
{
|
{
|
||||||
@@ -221,6 +230,27 @@ nm_ap_security_serialize (NMAPSecurity *self, DBusMessageIter *iter)
|
|||||||
return NM_AP_SECURITY_GET_CLASS (self)->serialize_func (self, iter);
|
return NM_AP_SECURITY_GET_CLASS (self)->serialize_func (self, iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NMAPSecurity *
|
||||||
|
nm_ap_security_new_copy (NMAPSecurity *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (self != NULL, NULL);
|
||||||
|
|
||||||
|
return NM_AP_SECURITY_GET_CLASS (self)->copy_constructor_func (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nm_ap_security_copy_properties (NMAPSecurity *self, NMAPSecurity *dst)
|
||||||
|
{
|
||||||
|
int key_len;
|
||||||
|
|
||||||
|
g_return_if_fail (self != NULL);
|
||||||
|
g_return_if_fail (dst != NULL);
|
||||||
|
g_return_if_fail (self != dst);
|
||||||
|
|
||||||
|
nm_ap_security_set_we_cipher (dst, self->priv->we_cipher);
|
||||||
|
nm_ap_security_set_key (dst, self->priv->key, strlen (self->priv->key));
|
||||||
|
nm_ap_security_set_description (dst, self->priv->description);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_ap_security_init (NMAPSecurity * self)
|
nm_ap_security_init (NMAPSecurity * self)
|
||||||
@@ -276,6 +306,7 @@ nm_ap_security_class_init (NMAPSecurityClass *klass)
|
|||||||
object_class->dispose = nm_ap_security_dispose;
|
object_class->dispose = nm_ap_security_dispose;
|
||||||
object_class->finalize = nm_ap_security_finalize;
|
object_class->finalize = nm_ap_security_finalize;
|
||||||
|
|
||||||
|
klass->copy_constructor_func = real_copy_constructor;
|
||||||
klass->serialize_func = real_serialize;
|
klass->serialize_func = real_serialize;
|
||||||
klass->write_wpa_supplicant_config_func = real_write_wpa_supplicant_config;
|
klass->write_wpa_supplicant_config_func = real_write_wpa_supplicant_config;
|
||||||
klass->device_setup_func = real_device_setup;
|
klass->device_setup_func = real_device_setup;
|
||||||
|
@@ -51,6 +51,8 @@ struct _NMAPSecurityClass
|
|||||||
GObjectClass parent;
|
GObjectClass parent;
|
||||||
|
|
||||||
/* class members */
|
/* class members */
|
||||||
|
NMAPSecurity * (*copy_constructor_func) (NMAPSecurity *self);
|
||||||
|
|
||||||
int (*serialize_func) (NMAPSecurity *self, DBusMessageIter *iter);
|
int (*serialize_func) (NMAPSecurity *self, DBusMessageIter *iter);
|
||||||
|
|
||||||
void (*write_wpa_supplicant_config_func)(NMAPSecurity *self, int fd);
|
void (*write_wpa_supplicant_config_func)(NMAPSecurity *self, int fd);
|
||||||
@@ -61,6 +63,8 @@ struct _NMAPSecurityClass
|
|||||||
|
|
||||||
GType nm_ap_security_get_type (void);
|
GType nm_ap_security_get_type (void);
|
||||||
|
|
||||||
|
NMAPSecurity * nm_ap_security_new_copy (NMAPSecurity *self);
|
||||||
|
|
||||||
NMAPSecurity * nm_ap_security_new_deserialize (DBusMessageIter *iter);
|
NMAPSecurity * nm_ap_security_new_deserialize (DBusMessageIter *iter);
|
||||||
|
|
||||||
int nm_ap_security_get_we_cipher (NMAPSecurity *self);
|
int nm_ap_security_get_we_cipher (NMAPSecurity *self);
|
||||||
|
Reference in New Issue
Block a user