3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-17 09:29:22 +01:00

wsc: Register WSC interface

This commit is contained in:
Denis Kenzior 2015-09-29 12:15:37 -05:00
parent ca0e3eb940
commit 46da18f23b
2 changed files with 75 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#define IWD_DEVICE_INTERFACE "net.connman.iwd.Device"
#define IWD_NETWORK_INTERFACE "net.connman.iwd.Network"
#define IWD_AGENT_INTERFACE "net.connman.iwd.Agent"
#define IWD_WSC_INTERFACE "net.connman.iwd.WiFiSimpleConfiguration"
#define IWD_MANAGER_PATH "/"

View File

@ -27,7 +27,11 @@
#include <errno.h>
#include <ell/ell.h>
#include "dbus.h"
#include "netdev.h"
#include "wiphy.h"
#include "scan.h"
#include "mpdu.h"
#include "ie.h"
#include "wscutil.h"
#include "wsc.h"
@ -35,6 +39,7 @@
#define WALK_TIME 120
static struct l_genl_family *nl80211 = NULL;
static uint32_t netdev_watch = 0;
struct wsc_sm {
uint8_t *wsc_ies;
@ -42,6 +47,10 @@ struct wsc_sm {
struct l_timeout *walk_timer;
};
struct wsc {
struct netdev *netdev;
};
struct wsc_sm *wsc_sm_new_pushbutton(uint32_t ifindex, const uint8_t *addr,
uint32_t bands)
{
@ -101,8 +110,72 @@ void wsc_sm_free(struct wsc_sm *sm)
l_free(sm);
}
static struct l_dbus_message *wsc_push_button(struct l_dbus *dbus,
struct l_dbus_message *message,
void *user_data)
{
l_debug("");
return dbus_error_not_implemented(message);
}
static struct l_dbus_message *wsc_cancel(struct l_dbus *dbus,
struct l_dbus_message *message,
void *user_data)
{
l_debug("");
return dbus_error_not_implemented(message);
}
static void setup_wsc_interface(struct l_dbus_interface *interface)
{
l_dbus_interface_method(interface, "PushButton", 0,
wsc_push_button, "", "");
l_dbus_interface_method(interface, "Cancel", 0,
wsc_cancel, "", "");
}
static void wsc_free(void *userdata)
{
struct wsc *wsc = userdata;
l_free(wsc);
}
static void netdev_appeared(struct netdev *netdev, void *userdata)
{
struct l_dbus *dbus = dbus_get_bus();
struct wsc *wsc;
wsc = l_new(struct wsc, 1);
wsc->netdev = netdev;
if (!l_dbus_register_interface(dbus, iwd_device_get_path(netdev),
IWD_WSC_INTERFACE,
setup_wsc_interface,
wsc, wsc_free)) {
wsc_free(wsc);
l_info("Unable to register %s interface", IWD_WSC_INTERFACE);
}
}
static void netdev_disappeared(struct netdev *netdev, void *userdata)
{
struct l_dbus *dbus = dbus_get_bus();
if (!l_dbus_unregister_interface(dbus, iwd_device_get_path(netdev),
IWD_WSC_INTERFACE))
l_info("Unable to unregister %s interface", IWD_WSC_INTERFACE);
}
bool wsc_init(struct l_genl_family *in)
{
netdev_watch = netdev_watch_add(netdev_appeared, netdev_disappeared,
NULL, NULL);
if (!netdev_watch)
return false;
nl80211 = in;
return true;
}
@ -114,6 +187,7 @@ bool wsc_exit()
if (!nl80211)
return false;
netdev_watch_remove(netdev_watch);
nl80211 = 0;
return true;