1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-02-12 22:11:58 +00:00
Commit graph

339 commits

Author SHA1 Message Date
David Herrmann
67de17a511 rtsp/wpas: pass va_list by reference
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>
2014-08-05 13:10:03 +02:00
Andrey Gusakov
9196c5c426 wifi: handle P2P_GROUP_FORMATION_FAILURE
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>
2014-08-05 13:02:18 +02:00
Andrey Gusakov
2a84a2d868 dbus: use 'int' instead of 'bool' in sd_bus
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>
2014-08-05 12:37:20 +02:00
Andrey Gusakov
97323d905c dbus: update to systemd API >=213
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>
2014-08-05 11:57:56 +02:00
David Herrmann
3dcb89e98b shl: update shl-macro.h
Fix a bug in SHL_ALIGN_POWER2 and add new shl_closep helpers.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-05-12 14:32:41 +02:00
David Herrmann
5c88e3df66 build: update README
Update some old information in README.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-05-09 09:39:44 +02:00
David Herrmann
7a73bee0f0 build: remove libwfd dependency
libwfd is no longer used, remove the dependency.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-05-09 09:39:22 +02:00
David Herrmann
0f9ca6e7b8 build: adjust to new libsystemd-event API
The individual timer-sources were replaced by a unified timer-source.
Adjust to that.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-05-09 09:29:39 +02:00
David Herrmann
37c2169c9e ctl: spawn gstreamer on sink-connect
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>
2014-05-09 09:28:57 +02:00
David Herrmann
4907155317 ctl: add sinkctl
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>
2014-05-08 15:29:46 +02:00
David Herrmann
95866f54f4 ctl: advertise wifi-connected changes after updating props
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>
2014-05-08 15:23:53 +02:00
David Herrmann
f275a60401 rtsp: strip remote-cookie during reply-matching
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>
2014-05-08 15:23:17 +02:00
David Herrmann
4ea4bb7d82 wifi: parse P2P_DEVICE_FOUND immediately
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>
2014-05-08 12:24:19 +02:00
David Herrmann
f6e434e86a rtsp: add rtsp bus
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>
2014-05-08 11:39:02 +02:00
David Herrmann
0d5b431367 ctl: make cli_bus and cli_event global
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>
2014-05-08 11:35:33 +02:00
David Herrmann
430d565ccc wifi: declare supplicant_set_wfd_subelements()
The declaration is missing, add it to suppress 'unknown function'
warnings.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-05-08 11:34:51 +02:00
David Herrmann
b3f4527444 ctl: suppress unused-result warnings
Use the 'v' variants of cli_vENOMEM() if the result is unused.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-05-08 11:34:17 +02:00
David Herrmann
63a0580695 wifi: send P2P_FIND on each p2p_scan() request
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>
2014-05-08 11:11:02 +02:00
David Herrmann
b5f4870edc test: include sys/socket.h to suppress warnings
We use pipes and socketpairs, so include socket.h.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-05-08 11:07:30 +02:00
David Herrmann
e2781c0a7a wifi: fix unused-result warning in log_ENOMEM()
Use log_vENOMEM() as we don't use the return-code.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-05-08 11:06:07 +02:00
David Herrmann
78cf818484 ctl: publish objects after parsing properties
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>
2014-04-23 12:30:20 +02:00
David Herrmann
d0a85ac46c ctl: parse wfd-subelements
Parse and show wfd-subelements.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-04-23 12:09:03 +02:00
David Herrmann
e624d5f81a wifi: add wfd-subelement properties
Allow dbus API users to read and modify WFD subelements.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-04-23 12:07:23 +02:00
David Herrmann
61db4a1d71 shl: fix shl_qstr_tokenize() quote parser
The parser is simply broken, fix it.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-29 12:51:40 +01:00
David Herrmann
9cb0a092c2 test: add valgrind memory checks
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>
2014-03-28 12:48:10 +01:00
David Herrmann
729acb64ca test: don't leak sd_event in wpas tests
Correctly free the sd_event object we allocate, otherwise valgrind will
complain loudly.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-28 12:46:38 +01:00
David Herrmann
9fdda3b09a wpas: drain input-queues before signalling HUP
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>
2014-03-28 12:40:17 +01:00
David Herrmann
fc02c0aaf6 test: make wpas tests safe to run in parallel
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>
2014-03-28 12:39:50 +01:00
David Herrmann
4f55a01dc3 shl: remove custom offsetof helpers
Use the generic shl_container_of() instead of all the custom helpers.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-21 12:17:08 +01:00
David Herrmann
12bf5e026e shl: add ring-buffer helpers
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>
2014-03-21 12:15:57 +01:00
David Herrmann
920f3ae250 shl: add u64 htable helpers
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>
2014-03-21 11:54:45 +01:00
David Herrmann
87b804c481 Remove old wifi code in miracled
The wifi code is now moved to miracle-wifid, no need to keep it anymore.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-19 13:31:01 +01:00
David Herrmann
89a268109e Remove old miraclectl
The miraclectl tool is no longer needed, remove it.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-19 13:23:58 +01:00
David Herrmann
6f9ab46448 Add new miracle-wifictl program
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>
2014-03-19 13:10:30 +01:00
David Herrmann
8ecc84d634 build: ignore test_wpas binary
This binary is build by "make check" and runs the wpas tests. Ignore it.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-19 13:09:39 +01:00
David Herrmann
18a5094bc0 Add new miracle-wifid daemon
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>
2014-03-19 13:08:25 +01:00
David Herrmann
b0b53f986c test: add wpas tests
Add extensive test-suite to verify our wpas-helpers work correctly.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-19 13:06:11 +01:00
David Herrmann
f34face988 shared: add wpa_supplicant bus-helpers
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>
2014-03-19 13:03:32 +01:00
David Herrmann
cf53290608 build: ignore local wpa-supplicant binaries
As we need pretty recent wpas binaries, ignore them in the build tree.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-19 13:02:00 +01:00
David Herrmann
c6ac2b612a Change license to LGPL
Apply LGPL to all code that is not scheduled for removal.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-19 13:01:23 +01:00
David Herrmann
4f740dfffb shl: update shl dlist/util
Two new helpers to verify empty strings and list-link-state.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-19 12:36:49 +01:00
David Herrmann
bc69f5b27b shl: update shl files
Sync files with upstream libshl. See upstream commits for changes/fixes.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-14 19:44:53 +01:00
David Herrmann
06be8854c5 Update to new libsystemd API
The upstream API changed (isn't released, yet!). Update our code to use
the new systemd-211 API.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-03-12 11:53:57 +01:00
David Herrmann
3bd83f1572 res: add dbus policy file
An example policy file to use with miracled. Simply copy it into
/etc/dbus/system.d/.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-22 14:50:02 +01:00
David Herrmann
8c2f95257c Move gdhcp and miracle-dhcp to ./src/dhcp/
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>
2014-02-18 14:04:51 +01:00
David Herrmann
47539226cd Move shared helpers into ./src/shared/
Move all shared helpers into a separate subdirectory and rename to
libmiracle-shared.la.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-18 13:56:12 +01:00
David Herrmann
fc30d8b920 miracled: skip run-time device-monitor if running unmanaged
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>
2014-02-17 16:50:20 +01:00
David Herrmann
fe571fb729 miracled: try at most 5 times to connect to wpas
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>
2014-02-17 16:47:24 +01:00
David Herrmann
6a37cbe6b8 miracled: support managed wpa_supplicant
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>
2014-02-17 16:42:54 +01:00
David Herrmann
5fb83c9159 shl: util: add _shl_sentinel_ marker for strjoin
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>
2014-02-17 16:19:48 +01:00