Basic support for UIBC (single mouse events and key events)
- Option --uibc on miracle-sinkctl to enable it
- Option --log-journal-level to see player execution on journalctl
- Controller for uibc miracle-uibcctl
- Player based on PyGtk to receive and communicate mouse and keyevents
closes#57
Some peers (like Nexus 5 and Nexus 7) send empty GET_PARAMETER
request during streaming. Seems it just some kind of ping. Do not
include unnecessary information in reply.
Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Devices sometimes report sessions followed by ";timeout=..". Cut this off.
Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Properly notify API users if we free peers that are pending. This way,
they don't have to use timers to restart peer discovery on wpa_supplicant
failures.
Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
If there is already a connection pending, don't start a new one.
Unfortunately, wpa_supplicant is unable to deal with this so we have to
enforce this.. Yuck!
We also reset the pending state during P2P_FIND now, this enables API
users to reset failed connections that wpa_supplicant was unable to close
(yeah, beacuse it's so hard to write proper APIs.. *sigh*).
Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
No need to add 'display' to p2p_connect commands. Drop it for future
compatibility.
Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
P2P-PEER reports the device name as 'device_name' while P2P-DEVICE-FOUND
reports it as 'name'. Try both.
Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Forward the --audio and --scale arguments to our gst-spawn helper and
parse them via bash for now.
Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
The sinkctl tool is currently a hack to make Miracast sinks work. The
embedded gst-launch invocation is kinda ugly to handle. Move it into a
bash-script so we can experiment a bit more with different pipelines.
Ultimatively, the goal is obviously to make this work as its own gst
element.
Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
rtsp_message_readv() is a convenience function. If one of the values to be
read fails, it does not restore the previous situation. Therefore, handle
that in sinkctl in case we cannot read a value.
Reported-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
ether_ntoa() function used in DHCP server skips leading zeros so
reformat is needed to make strcmp() work for mac-comparisons.
Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Don't skip leading zeroes for MAC addresses. Some software cannot handle
this well.
Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Copy over recent changes to gdhcp from ConnMan. We should really start
exporting sd-dhcp from libsystemd so we can finally drop this alltogether.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
p->sp->sta_mac is not mandatory set so check it before accessing it.
Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
M6 M7 messages should use URL from wfd_presentation_URL of M4. Parse it
during set_parameter and use it in further requests instead of a
hard-coded URL.
Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
In M7 message session ID should be included. Session ID is returned in M6
response. So we should wait for M6 response.
Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
As it turns out, the C standard forbids passing va_list by value and then
continue using it in the parent function (C Standard, 7.16, paragraph 3).
Luckily, there's a footnote stating:
"It is permitted to create a pointer to a va_list and pass that
pointer to another function, in which case the original function may
take further use of the original list after the other function
returns."
Therefore, we're safe passing va_list by reference and thus can keep the
current coding style.
This fixes weird bugs on ARM32 which really doesn't allow passing va_list
by value.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Forward group-formation-failure events via dbus so sinkctl can restart
p2p-scans immediately. Unfortunately, the event itself does not contain
any useful information at all. Therefore, we have to track the connection
attempts ourselves.
Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
sd_bus never uses 'bool', and given the weird implicit type promotions, it
is totally right to do so. Make sure we never pass pointers to 'bool' to
va_arg sd_bus functions to avoid overwriting stack space.
Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
The libsystemd-bus API changed recently. Update our calls to use the new
API so it compiles with newer systemd versions.
Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Once we have a source connection to our local sink, spawn gstreamer so the
actual video data is rendered.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
miracle-sinkctl is a very basic Miracast-Sink implementation. It is meant
for debugging and as proof-of-concept.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
If we advertise changes in Peer.Connected _before_ updating other props,
they're not available in the callbacks. Delay the notifications after we
parsed all props.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
We need to drop the remote-cookie flag when matching replies. Otherwise,
we will never find the local request.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
If we delay device-parsing until P2P_PEER returns, we might receive other
device events in between which we cannot handle as the peer is unknown.
Avoid that by immediately creating the peer and appending more detailed
data later once P2P_PEER returns.
As P2P_PEER keys and P2P_DEVICE_FOUND keys are different (wholy shit, what
a fucking interface), we need to parse both. Lets hope there won't be any
conflicts.
WARNING: The wfd_subelements field is currently very inconsistent.
Sometimes we only use dev_info fields, somethings the whole IE. Users
shall use it as boolean value, only (set vs. unset). Once we add a proper
IE parser, we will provide more advanced fields.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
WifiDisplay uses RTSP for stream-setups. This adds a basic rtsp-bus
implementations that we can use for sinks and sources.
Note that the implementation is optimized for usability, not speed. RTSP
is used for control-data, not streaming-data so there's no need to
over-optimize it. In case inlined RTP is used, we still provide proper
speed, even though that's usually not used by WifiDisplay implementations
(due to the TCP requirement).
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
The event-loop might be needed in later ctl additions for timeouts, so
make it global. Same for the bus-logic.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
wpa_supplicant is horrible in notifying us about p2p-scans. During failed
connection attempts or other timeouts, we usually are not notified about
scan-stops. Therefore, a following p2p-scan will simply be ignored as we
think it's still running.
Avoid that problem by always forwarding the P2P_FIND command.
wpa_supplicant can deal with redundant requests so we're fine. Note that
this requires the caller to issue these calls in intervals or/and after
any issues wifi request. Once wpas fixes this issue, we can add this guard
again and the redundant requests will be suppressed.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
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>
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>
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>
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>
Add readline support to miraclectl so we can have interactive commands.
This rewrites huge parts of miraclectl but hopefully makes it future proof
so no such rewrite will be needed again.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Add few small helpers to shl-macro/util. This includes some _cleanup_
helpers and the qstr suite for quoted/escaped strings.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Print more information now that we have property-support in miracled. Also
split link and peer information, otherwise the output looks misleading.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
The add-link argument turned out to be confusing so avoid the split input
and use the same name as all the other commands. We now split it
internally so the DBus call will work properly.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Three new commands that control scans on a given link are added:
1) start-scan: Starts scanning in background for a given link
2) stop-scan: Stops scanning in background for a given link
3) scan: Does interactive scanning for a given link
The interactive scanning basically calls start-scan and stop-scan. In
between, it listens for dbus-signals for new peers and displays them if
they are assigned to the given link. This should be used for basic
p2p-device scanning on a link.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
If we don't split peer linking off, the peer might get advertised before
the sub-device related data is set. With dbus, this might trigger
callbacks to not return attributes as the peer-type is unknown. Therefore,
properly initialize the peer before linking/advertising it.
This fixes a bug where the initial InterfacesAdded signal for new peers
does not include all properties of a peer.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Both dbus commands allow external programs to make our device discoverable
for P2P devices and also start scanning for remote devices.
The commands are *not* ref-counted right now, so parallel use is
discouraged. However, these commands can interrupt normal operations on a
wifi-device anyway, so if used in parallel, it is very like to break.
Thus, keep the interface simple and require callers to do
access-management (it's root-only, anyway..).
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Send ObjectManager.Interfaces{Added,Removed} signals whenever new objects
appear. Note that we cannot set DBus interfaces there as sd-bus ignores
them. We'll try to fix that upstream and until then just not expose any of
those.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
We need to send PropertiesChanged signals whenever we change properties
that are annotated as such.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This command prints detailed information on a given peer. This is exactly
the same as 'show-link' but for peers.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Implement basic peer properties and hook them up with dbus. Also add a
device_name parser to the wifi implementation so we correctly read the
friendly-name of remote devices.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Move peer_make_name() to the top to keep consistency with miracled-link.c
and move non-object-based helpers to the top.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
The new show-link command lists detailed information of a given link.
Useful for debugging and introspection.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
The friendly-name is used as name for local links. Default to a random
string and try to read the local hostname during startup.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This initial commit contains the main "miracled" daemon that does
link-management and peer-discovery/control. The "miraclectl" tool can be
used to control this daemon during runtime.
Note that this implementation is still missing a lot of stuff. All it
currently does is provide link-management and basic peer-discovery.
Following commits will hook everything else up.
The actual Miracast/Wifi-Display related runtime control is not being
worked on, yet. Feel free to use the proof-of-concept from the OpenWFD
repository. The MiracleCast implementation will not get any such
functionality unless the basic link-management is properly working.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>