Add support for indicating security methods
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 26 Feb 2008 08:35:34 +0000 (09:35 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 26 Feb 2008 08:35:34 +0000 (09:35 +0100)
include/iface.h
plugins/80211.c
src/iface.c

index 5d0a7e7..e5fb05d 100644 (file)
@@ -155,7 +155,7 @@ extern void connman_iface_indicate_carrier_off(struct connman_iface *iface);
 extern void connman_iface_indicate_configured(struct connman_iface *iface);
 
 extern void connman_iface_indicate_station(struct connman_iface *iface,
-                                               const char *name, int strength);
+                               const char *name, int strength, int security);
 
 extern int connman_iface_get_ipv4(struct connman_iface *iface,
                                                struct connman_ipv4 *ipv4);
index a3d5111..eaec342 100644 (file)
@@ -54,6 +54,10 @@ struct station_data {
        int wpa_ie_len;
        unsigned char rsn_ie[40];
        int rsn_ie_len;
+
+       int has_wep;
+       int has_wpa;
+       int has_rsn;
 };
 
 struct iface_data {
@@ -67,13 +71,23 @@ struct iface_data {
 static void report_station(struct connman_iface *iface,
                                                struct station_data *station)
 {
+       int security = 0;
+
        if (station == NULL)
                return;
 
        if (station->name == NULL)
                return;
 
-       connman_iface_indicate_station(iface, station->name, station->qual);
+       if (station->has_wep)
+               security |= 0x01;
+       if (station->has_wpa)
+               security |= 0x02;
+       if (station->has_rsn)
+               security |= 0x04;
+
+       connman_iface_indicate_station(iface, station->name,
+                                               station->qual, security);
 }
 
 static struct station_data *create_station(struct iface_data *iface,
@@ -157,6 +171,9 @@ static void print_stations(struct iface_data *iface)
                //                      station->address, station->mode,
                //                              station->name, station->qual);
 
+               if (station->name == NULL)
+                       continue;
+
                g_key_file_set_string(keyfile, station->address,
                                                "Name", station->name);
 
@@ -338,8 +355,10 @@ static void parse_genie(struct station_data *station,
 
                switch (data[offset]) {
                case 0xdd:      /* WPA1 (and other) */
+                       station->has_wpa = 1;
                        break;
                case 0x30:      /* WPA2 (RSN) */
+                       station->has_rsn = 1;
                        break;
                default:
                        break;
@@ -401,9 +420,8 @@ static void parse_scan_results(struct connman_iface *iface,
                        break;
                case SIOCGIWENCODE:
                        if (station != NULL) {
-                               if (!(event->u.data.flags & IW_ENCODE_DISABLED)) {
-                                       /* privacy */
-                               }
+                               if (!(event->u.data.flags & IW_ENCODE_DISABLED))
+                                       station->has_wep = 1;
                        }
                        break;
                case SIOCGIWRATE:
index a412dab..2d45a22 100644 (file)
@@ -289,9 +289,11 @@ void connman_iface_indicate_configured(struct connman_iface *iface)
        }
 }
 
-static void append_station(DBusMessage *reply, const char *name, int signal)
+static void append_station(DBusMessage *reply, const char *name,
+                                               int signal, int security)
 {
        DBusMessageIter array, dict;
+       const char *wpa = "WPA";
 
        dbus_message_iter_init_append(reply, &array);
 
@@ -303,22 +305,28 @@ static void append_station(DBusMessage *reply, const char *name, int signal)
        append_entry(&dict, "ESSID", DBUS_TYPE_STRING, &name);
        append_entry(&dict, "Signal", DBUS_TYPE_UINT16, &signal);
 
+       if (security > 0)
+               append_entry(&dict, "Security", DBUS_TYPE_STRING, &wpa);
+
        dbus_message_iter_close_container(&array, &dict);
 }
 
 void connman_iface_indicate_station(struct connman_iface *iface,
-                                               const char *name, int strength)
+                               const char *name, int strength, int security)
 {
        DBusMessage *signal;
 
-       DBG("iface %p name %s", iface, name);
+       DBG("iface %p security %d name %s", iface, security, name);
+
+       if (name == NULL || strlen(name) == 0)
+               return;
 
        signal = dbus_message_new_signal(iface->path,
                                CONNMAN_IFACE_INTERFACE, "NetworkFound");
        if (signal == NULL)
                return;
 
-       append_station(signal, name, strength);
+       append_station(signal, name, strength, security);
 
        dbus_connection_send(connection, signal, NULL);
        dbus_message_unref(signal);