[PATCH 1/6] frame-xchg: Add no-cck-rate flag only for P2P interfaces
by Andrew Zaborowski
We want to use this flag only on the interfaces with one of the three
P2P iftypes so set the flag automatically depending on the iftype from
the last 'config' notification.
---
src/frame-xchg.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/frame-xchg.c b/src/frame-xchg.c
index 2ea8504a..d26e0c54 100644
--- a/src/frame-xchg.c
+++ b/src/frame-xchg.c
@@ -115,6 +115,7 @@ struct frame_xchg_data {
unsigned int resp_timeout;
unsigned int retries_on_ack;
struct wiphy_radio_work_item work;
+ bool no_cck_rates;
};
struct frame_xchg_watch_data {
@@ -951,10 +952,13 @@ static bool frame_xchg_tx_retry(struct wiphy_radio_work_item *item)
l_genl_msg_append_attr(msg, NL80211_ATTR_WDEV, 8, &fx->wdev_id);
l_genl_msg_append_attr(msg, NL80211_ATTR_WIPHY_FREQ, 4, &fx->freq);
l_genl_msg_append_attr(msg, NL80211_ATTR_OFFCHANNEL_TX_OK, 0, NULL);
- l_genl_msg_append_attr(msg, NL80211_ATTR_TX_NO_CCK_RATE, 0, NULL);
l_genl_msg_append_attr(msg, NL80211_ATTR_FRAME,
fx->tx_mpdu_len, fx->tx_mpdu);
+ if (fx->no_cck_rates)
+ l_genl_msg_append_attr(msg, NL80211_ATTR_TX_NO_CCK_RATE, 0,
+ NULL);
+
if (duration)
l_genl_msg_append_attr(msg, NL80211_ATTR_DURATION, 4,
&duration);
@@ -1102,6 +1106,14 @@ static const struct wiphy_radio_work_item_ops work_ops = {
.destroy = frame_xchg_destroy,
};
+static bool frame_xchg_wdev_match(const void *a, const void *b)
+{
+ const struct wdev_info *wdev = a;
+ const uint64_t *id = b;
+
+ return wdev->id == *id;
+}
+
uint32_t frame_xchg_startv(uint64_t wdev_id, struct iovec *frame, uint32_t freq,
unsigned int retry_interval, unsigned int resp_timeout,
unsigned int retries_on_ack, uint32_t group_id,
@@ -1112,6 +1124,7 @@ uint32_t frame_xchg_startv(uint64_t wdev_id, struct iovec *frame, uint32_t freq,
size_t frame_len;
struct iovec *iov;
uint8_t *ptr;
+ struct wdev_info *wdev;
for (frame_len = 0, iov = frame; iov->iov_base; iov++)
frame_len += iov->iov_len;
@@ -1150,6 +1163,12 @@ uint32_t frame_xchg_startv(uint64_t wdev_id, struct iovec *frame, uint32_t freq,
for (iov = frame; iov->iov_base; ptr += iov->iov_len, iov++)
memcpy(ptr, iov->iov_base, iov->iov_len);
+ wdev = l_queue_find(wdevs, frame_xchg_wdev_match, &wdev_id);
+ fx->no_cck_rates = wdev &&
+ (wdev->iftype == NL80211_IFTYPE_P2P_DEVICE ||
+ wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||
+ wdev->iftype == NL80211_IFTYPE_P2P_GO);
+
/*
* Subscribe to the response frames now instead of in the ACK
* callback to save ourselves race condition considerations.
@@ -1265,14 +1284,6 @@ static void frame_xchg_mlme_notify(struct l_genl_msg *msg, void *user_data)
}
}
-static bool frame_xchg_wdev_match(const void *a, const void *b)
-{
- const struct wdev_info *wdev = a;
- const uint64_t *id = b;
-
- return wdev->id == *id;
-}
-
static void frame_xchg_config_notify(struct l_genl_msg *msg, void *user_data)
{
uint64_t wdev_id;
--
2.25.1
1 year, 8 months
[PATCH] auto-t: remove requirement for /var/lib/{ead,iwd}
by James Prestwood
The host systems configuration directories for IWD/EAD were
being mounted in the virtual machine. This required that the
host create these directories before hand. Instead we can
just set up the system and IWD/EAD to use directories in /tmp
that we create when we start the VM. This avoids the need for
any host configuration.
---
autotests/testEAD/connection_test.py | 11 ++++++++---
autotests/util/iwd.py | 10 +++++-----
tools/test-runner | 6 +++---
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/autotests/testEAD/connection_test.py b/autotests/testEAD/connection_test.py
index c51d7237..bdf242b6 100644
--- a/autotests/testEAD/connection_test.py
+++ b/autotests/testEAD/connection_test.py
@@ -2,6 +2,7 @@
import unittest
import sys
+import os
sys.path.append('../util')
from iwd import IWD
@@ -11,7 +12,9 @@ from ead import EAD
class Test(unittest.TestCase):
def test_connection_success(self):
- ctx.start_process(['ead', '-i', 'eth1', '-d'])
+ env = os.environ.copy()
+ env['STATE_DIRECTORY'] = '/tmp/ead'
+ ctx.start_process(['ead', '-i', 'eth1', '-d'], env=env)
ead = EAD()
@@ -25,11 +28,13 @@ class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
- IWD.copy_to_storage('default.8021x', storage_dir='/var/lib/ead')
+ os.mkdir('/tmp/ead')
+
+ IWD.copy_to_storage('default.8021x', storage_dir='/tmp/ead')
@classmethod
def tearDownClass(cls):
- IWD.clear_storage()
+ IWD.clear_storage(storage_dir='/tmp/ead')
if __name__ == '__main__':
unittest.main(exit=True)
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index ef843a95..76d96289 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -17,8 +17,8 @@ from enum import Enum
from config import ctx
-IWD_STORAGE_DIR = '/var/lib/iwd'
-IWD_CONFIG_DIR = '/etc/iwd'
+IWD_STORAGE_DIR = '/tmp/iwd'
+IWD_CONFIG_DIR = '/tmp'
DBUS_OBJECT_MANAGER = 'org.freedesktop.DBus.ObjectManager'
DBUS_PROPERTIES = 'org.freedesktop.DBus.Properties'
@@ -909,9 +909,9 @@ class IWD(AsyncOpAbstract):
GLib.source_remove(timeout)
@staticmethod
- def clear_storage():
- os.system('rm -rf ' + IWD_STORAGE_DIR + '/*')
- os.system('rm -rf ' + IWD_STORAGE_DIR + '/hotspot/*')
+ def clear_storage(storage_dir=IWD_STORAGE_DIR):
+ os.system('rm -rf ' + storage_dir + '/*')
+ os.system('rm -rf ' + storage_dir + '/hotspot/*')
@staticmethod
def create_in_storage(file_name, file_content):
diff --git a/tools/test-runner b/tools/test-runner
index 94c10199..a63b9154 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -112,8 +112,6 @@ mount_table = [
MountInfo('devpts', '/dev/pts', 'mode=0620', MS_NOSUID|MS_NOEXEC),
MountInfo('tmpfs', '/dev/shm', 'mode=1777', MS_NOSUID|MS_NODEV|MS_STRICTATIME),
MountInfo('tmpfs', '/run', 'mode=0755', MS_NOSUID|MS_NODEV|MS_STRICTATIME),
- MountInfo('tmpfs', '/var/lib/iwd', 'mode=0755', 0),
- MountInfo('tmpfs', '/var/lib/ead', 'mode=0755', 0),
MountInfo('tmpfs', '/tmp', '', 0),
MountInfo('tmpfs', '/usr/share/dbus-1', 'mode=0755', MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME),
MountInfo('debugfs', '/sys/kernel/debug', '', 0)
@@ -571,7 +569,7 @@ class TestContext:
env = os.environ.copy()
env['CONFIGURATION_DIRECTORY'] = config_dir
- env['STATE_DIRECTORY'] = '/var/lib/iwd'
+ env['STATE_DIRECTORY'] = '/tmp/iwd'
pid = self.start_process(args, env=env)
return pid
@@ -735,6 +733,8 @@ def prepare_sandbox():
for entry in dev_table:
os.symlink(entry.target, entry.linkpath)
+ os.mkdir('/tmp/iwd')
+
os.setsid()
fcntl.ioctl(STDIN_FILENO, TIOCSTTY, 1)
--
2.26.2
1 year, 8 months
[PATCH] test-runner: add iwmon options
by James Prestwood
This extends test-runner to also use iwmon if --log is enabled.
For this case the iwmon log will be found inside each test
log directory.
A new option, --monitor <file> was added in case full logging isn't
desired (potentially for timing issues) but a iwmon log is needed.
Be aware that when --monitor is used test-runner will mount the
entire parent directory. test-runner itself will only write to the
file specified, but just know that the parent directory is available
as read-write inside the VM.
--log takes precedence over --monitor, meaning the iwmon log will
be written to <logdir>/<test>/iwmon instead of the file specified
with --monitor if both options are provided.
---
tools/test-runner | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/tools/test-runner b/tools/test-runner
index 6443af15..94c10199 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -163,7 +163,8 @@ class Process:
run over the entire test run and will not be killed after each
test exits.
'''
- def __init__(self, args, wait=False, multi_test=False, env=None, ctx=None, check=False):
+ def __init__(self, args, wait=False, multi_test=False, env=None, ctx=None, check=False,
+ outfile=None):
self.args = args
self.wait = wait
self.name = args[0]
@@ -185,6 +186,9 @@ class Process:
self.args.extend(args)
set_stdout = True
+ if outfile:
+ set_stdout = True
+
# Anything labeled as multi_test isn't important to
# log. These are processes such as dbus-daemon and
# haveged.
@@ -200,6 +204,9 @@ class Process:
self.stdout = open('%s/%s' % (test_dir, args[0]), 'w')
self.stderr = open('%s/%s' % (test_dir, args[0]), 'w')
+ elif outfile:
+ self.stdout = open(outfile, 'w')
+ self.stderr = open(outfile, 'w')
else:
self.stdout = sys.__stdout__
self.stderr = sys.__stderr__
@@ -872,6 +879,11 @@ def pre_test(ctx, test):
ctx.start_hostapd()
ctx.start_ofono()
+ if ctx.args.log:
+ ctx.start_process(['iwmon'])
+ elif ctx.args.monitor:
+ ctx.start_process(['iwmon'], outfile=ctx.args.monitor)
+
if ctx.hw_config.has_option('SETUP', 'start_iwd'):
start = ctx.hw_config.getboolean('SETUP', 'start_iwd')
else:
@@ -1028,6 +1040,7 @@ def run_tests():
parser.add_argument('--log-gid')
parser.add_argument('--log-uid')
parser.add_argument('--hw')
+ parser.add_argument('--monitor')
args = parser.parse_args(options)
@@ -1057,6 +1070,9 @@ def run_tests():
if args.log:
mount('logdir', args.log, '9p', 0, 'trans=virtio,version=9p2000.L')
+ elif args.monitor:
+ parent = os.path.abspath(os.path.join(args.monitor, os.pardir))
+ mount('mondir', parent, '9p', 0, 'trans=virtio,version=9p2000.L')
if config.ctx.args.unit_tests is None:
run_auto_tests(config.ctx, args)
@@ -1091,6 +1107,8 @@ class Main:
help='Directory for log files')
self.parser.add_argument('--hw', '-w', type=str, nargs=1,
help='Use physical adapters for tests (passthrough)')
+ self.parser.add_argument('--monitor', '-m', type=str,
+ help='Enables iwmon output to file')
# Prevent --autotest/--unittest from being used together
auto_unit_group = self.parser.add_mutually_exclusive_group()
@@ -1199,6 +1217,10 @@ class Main:
options += ' --log-gid %u' % gid
options += ' --log-uid %u' % uid
+ if self.args.monitor:
+ self.args.monitor = os.path.abspath(self.args.monitor)
+ mon_parent_dir = os.path.abspath(os.path.join(self.args.monitor, os.pardir))
+
denylist = [
'auto_tests',
'qemu',
@@ -1271,6 +1293,13 @@ class Main:
% self.args.log
])
+ if self.args.monitor:
+ qemu_cmdline.extend([
+ '-virtfs',
+ 'local,path=%s,mount_tag=mondir,security_model=passthrough,id=mondir' \
+ % mon_parent_dir
+ ])
+
os.execlp(qemu_cmdline[0], *qemu_cmdline)
if __name__ == '__main__':
--
2.26.2
1 year, 8 months
Does IWD support having AP on a bridged interface?
by shemgp@gmail.com
Hello,
Just want to know if IWD currently, or is it planned to support, being on AP mode where the interface is on a bridge?
Example:
[br1 address: 192.168.6.1, provides DHCP] <----> [wlan1 ssid: testing password: testing123]
^-------------------------------[wlan2 ssid: testing password: testing123]
Thank you for your answer.
All the best,
Shem Pasamba
1 year, 8 months
[PATCH 1/5] resolve: Exit methods if resolve is NULL
by Andrew Zaborowski
If no resolve method gets configured, the resolve_new() call in
netconfig returns NULL. To avoid adding checks netconfig every time
netconfig->resolve is used, add these checks directly in the resolve_*
methods. Fixes the following crash:
src/netconfig.c:netconfig_destroy()
Aborting (signal 11) [/path/iwd]
++++++++ backtrace ++++++++
#0 0x7f3ee427f210 in /lib/x86_64-linux-gnu/libc.so.6
#1 0x43bcf4 in resolve_revert() at src/resolve.c:85
#2 0x43ae2d in netconfig_destroy() at src/netconfig.c:1206
#3 0x440cd6 in p2p_connection_reset() at src/p2p.c:662
#4 0x47200f in process_unicast() at ell/genl.c:979
#5 0x46e807 in io_callback() at ell/io.c:126
#6 0x46d9bd in l_main_iterate() at ell/main.c:467 (discriminator 2)
#7 0x46da8c in l_main_run() at ell/main.c:516
#8 0x4047c6 in main() at src/main.c:506
#9 0x7f3ee42600b3 in /lib/x86_64-linux-gnu/libc.so.6
+++++++++++++++++++++++++++
---
src/resolve.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/resolve.c b/src/resolve.c
index 066e4c87..07eee5a9 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -60,7 +60,7 @@ static inline void _resolve_init(struct resolve *resolve, uint32_t ifindex,
void resolve_add_dns(struct resolve *resolve, uint8_t type, char **dns_list)
{
- if (!dns_list || !*dns_list)
+ if (!resolve || !dns_list || !*dns_list)
return;
if (!resolve->ops->add_dns)
@@ -71,7 +71,7 @@ void resolve_add_dns(struct resolve *resolve, uint8_t type, char **dns_list)
void resolve_add_domain_name(struct resolve *resolve, const char *domain_name)
{
- if (!domain_name)
+ if (!resolve || !domain_name)
return;
if (!resolve->ops->add_domain_name)
@@ -82,7 +82,7 @@ void resolve_add_domain_name(struct resolve *resolve, const char *domain_name)
void resolve_revert(struct resolve *resolve)
{
- if (!resolve->ops->revert)
+ if (!resolve || !resolve->ops->revert)
return;
resolve->ops->revert(resolve);
@@ -90,6 +90,9 @@ void resolve_revert(struct resolve *resolve)
void resolve_free(struct resolve *resolve)
{
+ if (!resolve)
+ return;
+
resolve->ops->destroy(resolve);
}
--
2.25.1
1 year, 9 months
[PATCH 1/5] resolve: Exit methods if resolve is NULL
by Andrew Zaborowski
If no resolve method gets configured, the resolve_new() call in
netconfig returns NULL. To avoid adding checks netconfig every time
netconfig->resolve is used, add these checks directly in the resolve_*
methods. Fixes the following crash:
src/netconfig.c:netconfig_destroy()
Aborting (signal 11) [/path/iwd]
++++++++ backtrace ++++++++
#0 0x7f3ee427f210 in /lib/x86_64-linux-gnu/libc.so.6
#1 0x43bcf4 in resolve_revert() at src/resolve.c:85
#2 0x43ae2d in netconfig_destroy() at src/netconfig.c:1206
#3 0x440cd6 in p2p_connection_reset() at src/p2p.c:662
#4 0x47200f in process_unicast() at ell/genl.c:979
#5 0x46e807 in io_callback() at ell/io.c:126
#6 0x46d9bd in l_main_iterate() at ell/main.c:467 (discriminator 2)
#7 0x46da8c in l_main_run() at ell/main.c:516
#8 0x4047c6 in main() at src/main.c:506
#9 0x7f3ee42600b3 in /lib/x86_64-linux-gnu/libc.so.6
+++++++++++++++++++++++++++
---
src/resolve.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/resolve.c b/src/resolve.c
index 066e4c87..07eee5a9 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -60,7 +60,7 @@ static inline void _resolve_init(struct resolve *resolve, uint32_t ifindex,
void resolve_add_dns(struct resolve *resolve, uint8_t type, char **dns_list)
{
- if (!dns_list || !*dns_list)
+ if (!resolve || !dns_list || !*dns_list)
return;
if (!resolve->ops->add_dns)
@@ -71,7 +71,7 @@ void resolve_add_dns(struct resolve *resolve, uint8_t type, char **dns_list)
void resolve_add_domain_name(struct resolve *resolve, const char *domain_name)
{
- if (!domain_name)
+ if (!resolve || !domain_name)
return;
if (!resolve->ops->add_domain_name)
@@ -82,7 +82,7 @@ void resolve_add_domain_name(struct resolve *resolve, const char *domain_name)
void resolve_revert(struct resolve *resolve)
{
- if (!resolve->ops->revert)
+ if (!resolve || !resolve->ops->revert)
return;
resolve->ops->revert(resolve);
@@ -90,6 +90,9 @@ void resolve_revert(struct resolve *resolve)
void resolve_free(struct resolve *resolve)
{
+ if (!resolve)
+ return;
+
resolve->ops->destroy(resolve);
}
--
2.25.1
1 year, 9 months
[PATCH 1/6] auto-t: modify copy_to_storage to take optional dir
by James Prestwood
This is to prepare for testing EAD, and in this case we need
to copy the 8021x config to /var/lib/ead instead of IWD's
config dir.
---
autotests/util/iwd.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index 67bb6e41..e812a4e4 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -921,12 +921,12 @@ class IWD(AsyncOpAbstract):
fo.close()
@staticmethod
- def copy_to_storage(source):
+ def copy_to_storage(source, storage_dir=IWD_STORAGE_DIR):
import shutil
assert not os.path.isabs(source)
- shutil.copy(source, IWD_STORAGE_DIR)
+ shutil.copy(source, storage_dir)
@staticmethod
def copy_to_hotspot(source):
--
2.26.2
1 year, 9 months
[PATCH] auto-t: fix testNetconfig
by James Prestwood
The interface was hard coded to wln0 which works when running single
tests but not when running multiple. Instead use the actual ifname
that hostapd is using.
---
autotests/testNetconfig/connection_test.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/autotests/testNetconfig/connection_test.py b/autotests/testNetconfig/connection_test.py
index 3a590aeb..6818ceff 100644
--- a/autotests/testNetconfig/connection_test.py
+++ b/autotests/testNetconfig/connection_test.py
@@ -8,6 +8,7 @@ import iwd
from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
+from hostapd import HostapdCLI
import testutil
from config import ctx
@@ -54,10 +55,11 @@ class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
+ hapd = HostapdCLI()
# TODO: This could be moved into test-runner itself if other tests ever
# require this functionality (p2p, FILS, etc.). Since its simple
# enough it can stay here for now.
- ctx.start_process(['ifconfig', 'wln0', '192.168.1.1', 'netmask', '255.255.255.0'],
+ ctx.start_process(['ifconfig', hapd.ifname, '192.168.1.1', 'netmask', '255.255.255.0'],
wait=True)
ctx.start_process(['touch', '/tmp/dhcpd.leases'], wait=True)
ctx.start_process(['dhcpd', '-cf', '/tmp/dhcpd.conf', '-lf', '/tmp/dhcpd.leases'])
--
2.26.2
1 year, 9 months
[PATCH 1/6] ap: Pass "ops" struct to ap_start()
by Andrew Zaborowski
Pass the event callback function pointer in a "struct ap_ops" instead of
as individual ap_start() argument to make adding new callbacks easier.
---
src/ap.c | 65 +++++++++++++++++++++++++++++++-------------------------
src/ap.h | 9 +++++---
2 files changed, 42 insertions(+), 32 deletions(-)
diff --git a/src/ap.c b/src/ap.c
index dfa12444..7c135150 100644
--- a/src/ap.c
+++ b/src/ap.c
@@ -53,7 +53,7 @@
struct ap_state {
struct netdev *netdev;
struct l_genl_family *nl80211;
- ap_event_func_t event_func;
+ const struct ap_ops *ops;
ap_stopped_func_t stopped_func;
void *user_data;
struct ap_config *config;
@@ -211,7 +211,7 @@ static void ap_del_station(struct sta_state *sta, uint16_t reason,
sta->associated = false;
if (sta->rsna) {
- if (ap->event_func) {
+ if (ap->ops->handle_event) {
memset(&event_data, 0, sizeof(event_data));
event_data.mac = sta->addr;
event_data.reason = reason;
@@ -229,8 +229,8 @@ static void ap_del_station(struct sta_state *sta, uint16_t reason,
ap_stop_handshake(sta);
if (send_event)
- ap->event_func(AP_EVENT_STATION_REMOVED, &event_data,
- ap->user_data);
+ ap->ops->handle_event(AP_EVENT_STATION_REMOVED, &event_data,
+ ap->user_data);
}
static bool ap_sta_match_addr(const void *a, const void *b)
@@ -270,12 +270,12 @@ static void ap_new_rsna(struct sta_state *sta)
sta->rsna = true;
- if (ap->event_func) {
+ if (ap->ops->handle_event) {
struct ap_event_station_added_data event_data = {};
event_data.mac = sta->addr;
event_data.rsn_ie = sta->assoc_rsne;
- ap->event_func(AP_EVENT_STATION_ADDED, &event_data,
- ap->user_data);
+ ap->ops->handle_event(AP_EVENT_STATION_ADDED, &event_data,
+ ap->user_data);
}
}
@@ -309,11 +309,11 @@ static void ap_drop_rsna(struct sta_state *sta)
ap_stop_handshake(sta);
- if (ap->event_func) {
+ if (ap->ops->handle_event) {
struct ap_event_station_removed_data event_data = {};
event_data.mac = sta->addr;
- ap->event_func(AP_EVENT_STATION_REMOVED, &event_data,
- ap->user_data);
+ ap->ops->handle_event(AP_EVENT_STATION_REMOVED, &event_data,
+ ap->user_data);
}
}
@@ -544,7 +544,7 @@ static void ap_wsc_exit_pbc(struct ap_state *ap)
ap->wsc_dpid = 0;
ap_update_beacon(ap);
- ap->event_func(AP_EVENT_PBC_MODE_EXIT, NULL, ap->user_data);
+ ap->ops->handle_event(AP_EVENT_PBC_MODE_EXIT, NULL, ap->user_data);
}
static uint32_t ap_send_mgmt_frame(struct ap_state *ap,
@@ -751,8 +751,9 @@ static void ap_wsc_handshake_event(struct handshake_state *hs,
&expiry_data);
event_data.mac = sta->addr;
- sta->ap->event_func(AP_EVENT_REGISTRATION_SUCCESS, &event_data,
- sta->ap->user_data);
+ sta->ap->ops->handle_event(AP_EVENT_REGISTRATION_SUCCESS,
+ &event_data,
+ sta->ap->user_data);
break;
default:
break;
@@ -1336,8 +1337,8 @@ static void ap_assoc_reassoc(struct sta_state *sta, bool reassoc,
sta->wsc_v2 = wsc_req.version2;
event_data.mac = sta->addr;
- ap->event_func(AP_EVENT_REGISTRATION_START, &event_data,
- ap->user_data);
+ ap->ops->handle_event(AP_EVENT_REGISTRATION_START, &event_data,
+ ap->user_data);
/*
* Since we're starting the PBC Registration Protocol
@@ -1920,7 +1921,8 @@ static void ap_start_cb(struct l_genl_msg *msg, void *user_data)
if (l_genl_msg_get_error(msg) < 0) {
l_error("START_AP failed: %i", l_genl_msg_get_error(msg));
- ap->event_func(AP_EVENT_START_FAILED, NULL, ap->user_data);
+ ap->ops->handle_event(AP_EVENT_START_FAILED, NULL,
+ ap->user_data);
ap_reset(ap);
l_genl_family_free(ap->nl80211);
l_free(ap);
@@ -1928,7 +1930,7 @@ static void ap_start_cb(struct l_genl_msg *msg, void *user_data)
}
ap->started = true;
- ap->event_func(AP_EVENT_STARTED, NULL, ap->user_data);
+ ap->ops->handle_event(AP_EVENT_STARTED, NULL, ap->user_data);
}
static struct l_genl_msg *ap_build_cmd_start_ap(struct ap_state *ap)
@@ -2015,11 +2017,12 @@ static void ap_mlme_notify(struct l_genl_msg *msg, void *user_data)
l_genl_family_cancel(ap->nl80211,
ap->start_stop_cmd_id);
ap->start_stop_cmd_id = 0;
- ap->event_func(AP_EVENT_START_FAILED, NULL,
- ap->user_data);
+ ap->ops->handle_event(AP_EVENT_START_FAILED, NULL,
+ ap->user_data);
} else if (ap->started) {
ap->started = false;
- ap->event_func(AP_EVENT_STOPPING, NULL, ap->user_data);
+ ap->ops->handle_event(AP_EVENT_STOPPING, NULL,
+ ap->user_data);
}
ap_reset(ap);
@@ -2032,17 +2035,17 @@ static void ap_mlme_notify(struct l_genl_msg *msg, void *user_data)
/*
* Start a simple independent WPA2 AP on given netdev.
*
- * @event_func is required and must react to AP_EVENT_START_FAILED
- * and AP_EVENT_STOPPING by forgetting the ap_state struct, which
- * is going to be freed automatically.
- * In the @config struct only .ssid and .psk need to be non-NUL,
+ * @ops.handle_event is required and must react to AP_EVENT_START_FAILED
+ * and AP_EVENT_STOPPING by forgetting the ap_state struct, which is
+ * going to be freed automatically.
+ * In the @config struct only .ssid and .psk need to be non-NULL,
* other fields are optional. If @ap_start succeeds, the returned
* ap_state takes ownership of @config and the caller shouldn't
* free it or any of the memory pointed to by its members (they
* also can't be static).
*/
struct ap_state *ap_start(struct netdev *netdev, struct ap_config *config,
- ap_event_func_t event_func, void *user_data)
+ const struct ap_ops *ops, void *user_data)
{
struct ap_state *ap;
struct wiphy *wiphy = netdev_get_wiphy(netdev);
@@ -2053,7 +2056,7 @@ struct ap_state *ap_start(struct netdev *netdev, struct ap_config *config,
ap->nl80211 = l_genl_family_new(iwd_get_genl(), NL80211_GENL_NAME);
ap->config = config;
ap->netdev = netdev;
- ap->event_func = event_func;
+ ap->ops = ops;
ap->user_data = user_data;
if (!config->channel)
@@ -2184,7 +2187,7 @@ static struct l_genl_msg *ap_build_cmd_stop_ap(struct ap_state *ap)
/*
* Schedule the running @ap to be stopped and freed. The original
- * event_func and user_data are forgotten and a new callback can be
+ * ops and user_data are forgotten and a new callback can be
* provided if the caller needs to know when the interface becomes
* free, for example for a new ap_start call.
*
@@ -2201,7 +2204,7 @@ void ap_shutdown(struct ap_state *ap, ap_stopped_func_t stopped_func,
if (ap->started) {
ap->started = false;
- ap->event_func(AP_EVENT_STOPPING, NULL, ap->user_data);
+ ap->ops->handle_event(AP_EVENT_STOPPING, NULL, ap->user_data);
}
ap_reset(ap);
@@ -2371,6 +2374,10 @@ static void ap_if_event_func(enum ap_event_type type, const void *event_data,
}
}
+static const struct ap_ops ap_dbus_ops = {
+ .handle_event = ap_if_event_func,
+};
+
static struct l_dbus_message *ap_dbus_start(struct l_dbus *dbus,
struct l_dbus_message *message, void *user_data)
{
@@ -2391,7 +2398,7 @@ static struct l_dbus_message *ap_dbus_start(struct l_dbus *dbus,
config->ssid = l_strdup(ssid);
config->psk = l_strdup(wpa2_psk);
- ap_if->ap = ap_start(ap_if->netdev, config, ap_if_event_func, ap_if);
+ ap_if->ap = ap_start(ap_if->netdev, config, &ap_dbus_ops, ap_if);
if (!ap_if->ap) {
ap_config_free(config);
return dbus_error_invalid_args(message);
diff --git a/src/ap.h b/src/ap.h
index cb5238d1..bbfecd6d 100644
--- a/src/ap.h
+++ b/src/ap.h
@@ -52,8 +52,6 @@ struct ap_event_registration_success_data {
const uint8_t *mac;
};
-typedef void (*ap_event_func_t)(enum ap_event_type type, const void *event_data,
- void *user_data);
typedef void (*ap_stopped_func_t)(void *user_data);
struct ap_config {
@@ -67,10 +65,15 @@ struct ap_config {
bool no_cck_rates : 1;
};
+struct ap_ops {
+ void (*handle_event)(enum ap_event_type type, const void *event_data,
+ void *user_data);
+};
+
void ap_config_free(struct ap_config *config);
struct ap_state *ap_start(struct netdev *netdev, struct ap_config *config,
- ap_event_func_t event_func, void *user_data);
+ const struct ap_ops *ops, void *user_data);
void ap_shutdown(struct ap_state *ap, ap_stopped_func_t stopped_func,
void *user_data);
void ap_free(struct ap_state *ap);
--
2.25.1
1 year, 9 months
[PATCH] test-runner: open up dbus config for dbus-monitor
by James Prestwood
dbus-monitor was not able to eavesdrop on method calls without
some changed to the dbus config.
---
tools/test-runner | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/test-runner b/tools/test-runner
index d1e1d42c..8a257be1 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -149,6 +149,8 @@ busconfig.dtd\">
<allow receive_type=\"signal\"/>
<allow receive_type=\"method_return\"/>
<allow receive_type=\"error\"/>
+<allow send_destination=\"*\" eavesdrop=\"true\"/>
+<allow eavesdrop=\"true\"/>
</policy>
</busconfig>
'''
--
2.26.2
1 year, 9 months