1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-02-12 14:41:57 +00:00
Commit graph

50 commits

Author SHA1 Message Date
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
David Herrmann
77aae60c52 miracle: add now() helper
This returns the current time in usec since EPOCH depending on the
clock-time.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-17 16:18:53 +01:00
David Herrmann
3db84c3822 miracle: fix miracle.h include protection
Move it to the top like we do in all other files..

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-17 16:18:22 +01:00
David Herrmann
b161687cb7 miracled: remove old --help text
These two entries are no longer valid, remove them.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-17 14:57:53 +01:00
David Herrmann
3a8e2ff9e0 miracled: add udev-based link enumeration/monitor
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>
2014-02-17 14:37:25 +01:00
David Herrmann
14aa8368e6 miracled: send ScanStopped events
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>
2014-02-17 13:45:50 +01:00
David Herrmann
533959633e miracled: add wifi-GO support
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>
2014-02-17 13:45:40 +01:00
David Herrmann
f12a042306 dhcp: send comm-events as server
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>
2014-02-17 12:20:06 +01:00
David Herrmann
024ea8c733 dhcp: fix buffer-overflow for addresses
Fix trivial buffer-overflow which caused configuration overwrites.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-17 12:18:55 +01:00
David Herrmann
36da68594b build: update fdo links
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>
2014-02-15 14:10:25 +01:00
David Herrmann
15aa4eeece res: update README
Add some proper information to the README file and point to the website
for more details.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-11 15:48:45 +01:00
David Herrmann
eaea59d324 res: add wpa.conf example
Add example file for wpa_supplicant so users can start testing.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-11 15:23:03 +01:00
David Herrmann
6fbd58e349 miraclectl: hook up connection API
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>
2014-02-11 15:06:24 +01:00
David Herrmann
01292905f0 miracled: send PropsChanged event on explicit peer-disconnect
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>
2014-02-11 15:05:10 +01:00
David Herrmann
9212e72c52 miraclectl: fix crash during shutdown and scan-stop
Fix a NULL deref during shutdown if we try to stop a non-existant scan.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-11 14:34:13 +01:00
David Herrmann
dd3c8eac9c miracled: hook up peer-connection with dbus
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>
2014-02-11 14:27:14 +01:00
David Herrmann
146cf0bdb0 miraclectl: stop scan on link-removal
If a link is removed, stop any pending interactive scan-tracking.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-11 14:13:41 +01:00
David Herrmann
1b1000b254 miraclectl: fix link/peer event formatting
Add colons so the event content is better readable on the CLI.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-11 14:13:01 +01:00
David Herrmann
12bf86c744 miraclectl: suppress useless error on scan-stop
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>
2014-02-11 14:11:26 +01:00
David Herrmann
1c470e46a8 miraclectl: set default log-level to NOTICE
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>
2014-02-11 14:06:23 +01:00
David Herrmann
650920082c miraclectl: use readline
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>
2014-02-11 11:34:33 +01:00
David Herrmann
0ce874d7ce shl: update macro/util helpers
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>
2014-02-11 11:33:47 +01:00
David Herrmann
fe11d1d863 miraclectl: improve verb_list output
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>
2014-02-10 18:51:40 +01:00
David Herrmann
3b188989db miraclectl: fix printf offset for CONNECTED properties
We need at least 9 chars for the string "CONNECTED"..

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-10 18:51:11 +01:00
David Herrmann
bbe1050906 miraclectl: make add-link accept a single argument
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>
2014-02-10 18:36:29 +01:00
David Herrmann
44574b1d81 miraclectl: add scan commands
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>
2014-02-10 18:29:06 +01:00
David Herrmann
837fe1cea1 miracled: split peer allocation and linking
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>
2014-02-10 18:27:21 +01:00
David Herrmann
e60e678d40 miracled: implement Start/StopScan
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>
2014-02-10 16:56:59 +01:00
David Herrmann
8bcf3348e8 miracled: implement InterfacesAdded/Removed
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>
2014-02-10 16:29:02 +01:00
David Herrmann
5d5ab7761f miracled: implement PropertiesChanged signals
We need to send PropertiesChanged signals whenever we change properties
that are annotated as such.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-10 15:57:02 +01:00
David Herrmann
14ca5829b2 miraclectl: add 'show-peer' verb
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>
2014-02-10 14:59:16 +01:00
David Herrmann
fde71e7352 miracled: implement peer properties
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>
2014-02-10 14:58:32 +01:00
David Herrmann
7457a7cf90 miracled: move peer_make_name() definition
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>
2014-02-10 14:22:33 +01:00
David Herrmann
4879057c01 miraclectl: add 80-char marker
Add a marker with 80-char width so the help text will get proper sizes.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-10 14:14:19 +01:00
David Herrmann
d26892b61f miraclectl: add 'set-link-name' verb
The new set-link-name command allows users to change the friendly-name of
a given link.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-10 14:14:19 +01:00
David Herrmann
a765bd29b8 miraclectl: add 'show-link' verb
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>
2014-02-10 14:14:19 +01:00
David Herrmann
27a74298e9 miracle: add few bus helpers
Two new bus helpers to deal with common sd-bus tasks.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-10 14:14:19 +01:00
David Herrmann
2e50d006ad miracled: friendly-name support for local links
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>
2014-02-10 12:58:24 +01:00
David Herrmann
062c73ecf3 miracled: move link_make_name() declaration
Make the header consistent and move independent helpers above the real
object handling.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-02-10 12:15:05 +01:00
David Herrmann
051b584746 Initial MiracleCast Implementation
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>
2014-02-09 18:36:06 +01:00