Delay object-broadcasts so we first parse properties and then advertise
the objects. Otherwise, the caller will get almost empty objects which are
rather useless.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Copy over the "make memcheck" target from libshl. It runs the test-suite
again via valgrind and fails on any valgrind warnings. This is very useful
to find memory-leaks and invalid memory-accesses via the test-suite.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
We _must_ aggressively drain input queues before we signal any HUP. There
might be queued messages that tell us important information about the
termination of wpa_supplicant.
Therefore, if a write() operation fails, we only signal HUP if the input
queues are empty. However, we cannot rely on EPOLLIN to be set, as the
input data might have arrived in between epoll_wait() and write(),
therefore, always run the non-blocking read() in case write() failed.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
If you run "make check -jX", the test-suites will run in parallel. This
currently works fine, but someone might copy the wpas tests into something
more complex. In that case, the /tmp/XY files will be shared, which breaks
the test-suite. Therefore, use pid-suffixes so these files are exclusive
to the given test-process.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
The shl_ring helpers manage a dynamically-growing ring-buffer. We need
that for the following RTSP stream parsers, so add them to src/shared/.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Add u64 helpers to shl_htable. They're fairly trivial and just copied from
unsigned-long, however, in case size_t is not 64bit wide we need to do
some trivial hashing.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
The miracle-wifictl program can be used to manage miracle-wifid. It
provides low-level P2P helpers, so the main miraclectl can skip thos.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
The miracle-wifid daemon is a rewrite of the wifi-related parts of
miracled. Unlike miracled, we no longer integrate the wifi-part directly
into the core daemon. This way, we can easily replace the wifi-bridge with
other network managers once they gain P2P capabilities.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
The wpas-helpers provide easy _asynchronous_ access to wpa_supplicant
control interfaces. Compared to the old wpa_ctrl_* stuff it's no longer
synchronous. Thus, it doesn't block our daemon while wpa_supplicant runs
some heavy work again..
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Use a common subdirectory for gdhcp so we can easily replace it once
sd-dhcp has server-side support.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
If we get ADD events from udev for a new link but run in unmanaged mode,
skip the event. It is fairly unlikely that another manager has already
started wpa_supplicant on it (and even if, it would be racy).
Hence, lets not support hotplugging in these cases until external managers
provide us a notification API.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
If, after 5 times (which is 1s), wpa_supplicant is still not reachable, we
now drop the link. This avoids hangup issues during wpas startup that
might happen from time to time.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
If miracled is spawned with --manage-wifi, we run our own copy of
wpa_supplicant on managed devices. This is meant for testing purposes
only. Hopefully, network-manages like NM or connman will provide a P2P API
at some time so we can switch. Until then, we allow the user to control
who is in charge of wpa_supplicant.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This is very handy to catch wrong usage of shl_strjoin(). We now get a gcc
warning if the sentinel (NULL) is omitted.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Allow users to tag devices as "miracle" via udev so they get picked up
automatically. We also add a generic "remove"-monitor so we correctly drop
links as they get unplugged. The wpa_supplicant notification is unreliable
so we want the proper udev-events here.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
We should notify miraclectl about ScanStopped events so we can correctly
track active scans. If we don't do that, we would have to explicitly track
it on connect/disconnect/etc. commands, which seems cumbersome given the
undeterminisc actions they cause.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
If we run as GO we need to support local AP events and dhcp-server
handling. Both was already supported by our code-base so simply hook it up
with miracled-wifi.
Note that this adds a severe restriction: we can only have a single
p2p-connection per interface. The wpa_supplicant events don't provide
enough information to associate the ifnames to devices.
But most drivers only support a single STA, anyway, so that's fine.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Add a gdhcp callback for server-side lease events. Then raise L: and R:
lines for each event we get so miracled can react to it.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
We use "miracle" as project-name and for all links and tokens. The fancy
name stays "MiracleCast".
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Add commands for allow/reject/connect/disconnect and parse all events
properly. Notify the user of any important changes so they can react to
it.
Note that Peer.Connect() is currently not implemented and will stay this
way until we have the dhcp-server and wfd-source ready (or at least
planned).
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
If we explicitly call wifi_dev_disconnect(), no WIFI event is broadcasted,
so handle it manually and send a dbus event if it changed.
Note that we explicitly call into wifi even if the device is not connected
to kill any ongoing connection attempts.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Hook up the peer-dbus API with the underlying peer objects. This allows to
handle incoming requests and deal with connection issues.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
If we stop a scan in an async-manner and the object is no longer around,
don't print an error. Only do that if the scan is stopped explicitly by
the user.
This allows us to correctly kill scans during link-removal in a follow-up
patch. In such cases, the scan-stop may fail of the dbus object has
already been removed.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
We currently suppress all log-messages except FATAL, which is not really
what we want. Initialize the log-level to NOTICE like the default for
shl_log is, too.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>