diff --git a/CMakeLists.txt b/CMakeLists.txt index a94c9041..38fce5a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ OPTION(BUILD_ENABLE_DEBUG "Enable Debug" ON ) OPTION(RELY_UDEV "Rely in udev tag to select device" OFF ) OPTION(BUILD_TESTS "Enable TEST" ON ) OPTION(BUILD_ENABLE_CPPCHECK "Enable CPPCheck static analysis" OFF ) +SET(IP_BINARY "/bin/ip" CACHE STRING "Path to ip binary") if(BUILD_ENABLE_DEBUG) add_definitions(-DBUILD_ENABLE_DEBUG) diff --git a/COPYING b/COPYING index 0dbad094..e6f33def 100644 --- a/COPYING +++ b/COPYING @@ -8,7 +8,7 @@ This software was written by: This software is licensed under the terms of the LGPL. Please see each source file for the related copyright notice and license. -If a file does not contain a copright notice, the following notice shall apply: +If a file does not contain a copyright notice, the following notice shall apply: MiracleCast - Wifi-Display/Miracast Implementation diff --git a/README.md b/README.md index f2326a35..cd579f19 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The MiracleCast project provides software to connect external monitors to your system via Wi-Fi. It is compatible to the Wifi-Display specification also known as Miracast. MiracleCast implements the Display-Source as well as Display-Sink side. -The Display-Source side allows you to connect external displays to your system and stream local content to the device. A lot of effort is put into making this as easy as connecting external displays via HDMI. *Note: This is not implemented yet. Please see [#4](./issues/4)* +The Display-Source side allows you to connect external displays to your system and stream local content to the device. A lot of effort is put into making this as easy as connecting external displays via HDMI. *Note: This is not implemented yet. Please see [#4](../../issues/4).* On the other hand, the Display-Sink side allows you to create wifi-capable external displays yourself. You can use it on your embedded devices or even on full desktops to allow other systems to use your device as external display. @@ -21,13 +21,15 @@ The MiracleCast projects requires the following software to be installed: - **glib**: A utility library. Used by the current DHCP implementation. Will be removed once sd-dns gains DHCP-server capabilities. *required*: ~=glib2-2.38 (might work with older releases, untested..) - - **check**: Test-suite for C programs. Used for optional tests of the MiracleCast code base. - *optional*: ~=check-0.9.11 (might work with older releases, untested..) - - **gstreamer**: MiracleCast rely on gstreamer to show cast its output. You can test if all needed is installed launching [res/test-viewer.sh](https://github.com/albfan/miraclecast/blob/master/res/test-viewer.sh) + - **wpa_supplicant**: MiracleCast spawns wpa_supplicant with a custom config. + - **P2P Wi-Fi device** Although widespread these days, there are some devices not compatible with [Wi-Fi Direct](http://en.wikipedia.org/wiki/Wi-Fi_Direct) (prior know as Wi-Fi P2P). Test yours with [res/test-hardware-capabilities.sh](https://github.com/albfan/miraclecast/blob/master/res/test-hardware-capabilities.sh) + - **check**: Test-suite for C programs. Used for optional tests of the MiracleCast code base. + *optional*: ~=check-0.9.11 (might work with older releases, untested..) + - copy the dbus policy **res/org.freedesktop.miracle.conf** to `/etc/dbus-1/system.d/` ## Build and install diff --git a/autogen.sh b/autogen.sh index 7912a7ce..48dc21e3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -29,22 +29,18 @@ if [ "x$1" = "xc" ]; then shift args="$args $@" $topdir/configure CFLAGS='-g -O0 -ftrapv' $args - make clean elif [ "x$1" = "xg" ]; then shift args="$args $@" $topdir/configure CFLAGS='-g -O0 -ftrapv' $args - make clean elif [ "x$1" = "xa" ]; then shift args="$args $@" $topdir/configure CFLAGS='-g -O0 -Wsuggest-attribute=pure -Wsuggest-attribute=const -ftrapv' $args - make clean elif [ "x$1" = "xl" ]; then shift args="$args $@" $topdir/configure CC=clang CFLAGS='-g -O0 -ftrapv' $args - make clean elif [ "x$1" = "xs" ]; then shift args="$args $@" diff --git a/config.h.cmake b/config.h.cmake index ddc0cd19..f4689e44 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -2,6 +2,8 @@ #define CONFIG_H #cmakedefine BUILD_BINDIR "@BUILD_BINDIR@" +#cmakedefine RELY_UDEV @RELY_UDEV@ +#cmakedefine IP_BINARY @IP_BINARY@ #cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" diff --git a/configure.ac b/configure.ac index aeff177b..bdbce1b7 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,12 @@ AC_ARG_ENABLE([rely-udev], AS_HELP_STRING([--enable-rely-udev], [Use tagged device with miraclecast]), AC_DEFINE([RELY_UDEV], [], [Rely on udev to find miraclecast device])) AC_ARG_ENABLE([log-debug], AS_HELP_STRING([--disable-log-debug], [Disable log debug]), , AC_DEFINE([BUILD_ENABLE_DEBUG], [], [Enable debug log level])) +AC_ARG_VAR(IP_BINARY, [Path for ip binary]) +if test -z "$IP_BINARY"; then + IP_BINARY=/bin/ip +fi +AC_DEFINE_UNQUOTED([IP_BINARY], [$IP_BINARY], [Path for ip binary]) + # # Mandatory dependencies # @@ -165,13 +171,15 @@ AC_MSG_NOTICE([Build configuration: bindir: $bindir libdir: $libdir includedir: $includedir + sysconfdir: $sysconfdir + ip-binary: $IP_BINARY Miscellaneous Options: building tests: $have_check code coverage: $use_gcov + rely udev: ${enable_rely_udev:-no} Compilation - mkdir build && cd build "${MAKE-make}" to start compilation process "${MAKE-make}" check to pass test]) else @@ -181,11 +189,13 @@ AC_MSG_NOTICE([Build configuration: bindir: $bindir libdir: $libdir includedir: $includedir + sysconfdir: $sysconfdir + ip-binary: $IP_BINARY Miscellaneous Options: building tests: $have_check + rely udev: ${enable_rely_udev:-no} Compilation - mkdir build && cd build "${MAKE-make}" to start compilation process]) fi diff --git a/meson.build b/meson.build index c74b9ba3..32beeb79 100644 --- a/meson.build +++ b/meson.build @@ -32,6 +32,8 @@ if get_option('rely-udev') add_project_arguments('-DRELY_UDEV', language: 'c') endif +add_project_arguments('-DIP_BINARY='+get_option('ip-binary'), language: 'c') + glib2 = dependency('glib-2.0') udev = dependency('libudev') libsystemd = dependency('libsystemd') diff --git a/meson_options.txt b/meson_options.txt index 34002ffc..86a6862e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -10,3 +10,7 @@ option('build-tests', type: 'boolean', value: true, description: 'Enable TEST') +option('ip-binary', + type: 'string', + value: '/bin/ip', + description: 'Path for ip binary') diff --git a/res/meson.build b/res/meson.build index 037a7595..9a0992c5 100644 --- a/res/meson.build +++ b/res/meson.build @@ -9,5 +9,5 @@ install_data('miracle-gst', 'gstplayer', 'uibc-viewer', install_data( 'miracle-wifid', 'miracle-sinkctl', 'miracle-wifictl', - install_dir: join_paths(get_option('datadir'), 'bash-completions', 'completions') + install_dir: join_paths(get_option('datadir'), 'bash-completion', 'completions') ) diff --git a/res/miraclecast.spec b/res/miraclecast.spec index e199155b..0ba2eabe 100644 --- a/res/miraclecast.spec +++ b/res/miraclecast.spec @@ -1,60 +1,68 @@ -%global commit c3c868e523f450ad4f0d77f5484a3b61f08120b7 +%global commit 264a222d242734da369ca287aa6cfc6ca4f1f7bf %global shortcommit %(c=%{commit}; echo ${c:0:7}) Name: miraclecast Version: 1.0 -Release: 1.git%{shortcommit}%{?dist} -Summary: Connect external monitors to your system via Wifi-Display -License: LGPL +Release: 2.git%{shortcommit}%{?dist} +Summary: Connect external monitors to your system via Wi-Fi Display (miracast) +License: LGPLv2 URL: https://github.com/albfan/miraclecast Source0: https://github.com/albfan/miraclecast/archive/%{commit}/%{name}-%{shortcommit}.tar.gz -BuildRequires: autoconf, automake, libtool -BuildRequires: readline-devel, glib2-devel, systemd-devel -%description -The MiracleCast project provides software to connect external monitors to your system via Wi-Fi. It is compatible to the Wifi-Display specification also known as Miracast. MiracleCast implements the Display-Source as well as Display-Sink side. +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: libtool -The Display-Source side allows you to connect external displays to your system and stream local content to the device. A lot of effort is put into making this as easy as connecting external displays via HDMI. +BuildRequires: glib2-devel +BuildRequires: readline-devel +BuildRequires: systemd-devel -On the other hand, the Display-Sink side allows you to create wifi-capable external displays yourself. You can use it on your embedded devices or even on full desktops to allow other systems to use your device as external display. +# "Recommends" is stronger than "Suggests", and gets installed by default by DNF. +# for gstplayer +Recommends: python3-gobject-base -%prep -%autosetup -n %{name}-%{shortcommit} +# for miracle-gst (/usr/bin/gst-launch-1.0) +Suggests: gstreamer + +# for miracle-omxplayer +Suggests: omxplayer + +%description +The MiracleCast project provides software to connect external monitors to your +system via Wi-Fi. It is compatible to the Wi-Fi Display specification also +known as Miracast. MiracleCast implements the Display-Source as well as +Display-Sink side. + +The Display-Source side allows you to connect external displays to your system +and stream local content to the device. A lot of effort is put into making +this as easy as connecting external displays via HDMI. +On the other hand, the Display-Sink side allows you to create Wi-Fi capable +external displays yourself. You can use it on your embedded devices or even on +full desktops to allow other systems to use your device as external display. + +%prep +%autosetup -n %{name}-%{commit} %build -mkdir build -cd build -../autogen.sh g --prefix=%{_prefix} +autoreconf -fiv +%configure %make_build - %install -rm -rf $RPM_BUILD_ROOT -cd build %make_install - %files %license COPYING LICENSE_gdhcp LICENSE_htable LICENSE_lgpl %doc README.md -%{_sysconfdir}/dbus-1/system.d/org.freedesktop.miracle.conf -%{_bindir}/miracle-wifictl -%{_bindir}/miracle-omxplayer -%{_bindir}/miracle-gst -%{_bindir}/miracle-sinkctl -%{_bindir}/miracled -%{_bindir}/miracle-dhcp -%{_bindir}/miracle-uibcctl -%{_bindir}/miracle-wifid -%{_bindir}/gstplayer -%{_bindir}/uibc-viewer -%{_datadir}/bash-completion/completions/miracle-wifictl -%{_datadir}/bash-completion/completions/miracle-sinkctl -%{_datadir}/bash-completion/completions/miracle-wifid - +%config(noreplace) %{_sysconfdir}/dbus-1/system.d/org.freedesktop.miracle.conf +%{_bindir}/* +%{_datadir}/bash-completion/completions/* %changelog +* Wed Jan 05 2022 Korenberg Mark +- Fix .spec-file, bump version + * Wed Nov 21 2018 Graham White - first build diff --git a/res/normal-wifi.sh b/res/normal-wifi.sh index 1e03201a..30c56157 100755 --- a/res/normal-wifi.sh +++ b/res/normal-wifi.sh @@ -10,7 +10,7 @@ ETHER_COUNT=$(echo "$ETHER_NAMES" | wc -l) if [ 0 = $ETHER_COUNT ] then - echo There is no net devices avaliable + echo There is no net devices available exit 1 elif [ 1 = $ETHER_COUNT ] then diff --git a/res/sinkctl.protocol-extension.example b/res/sinkctl.protocol-extension.example new file mode 100644 index 00000000..a0205fe2 --- /dev/null +++ b/res/sinkctl.protocol-extension.example @@ -0,0 +1,18 @@ +#Example of extra parameters to extend sink request + +[sinkctl] +extends.wfd_video_formats=40 00 01 10 0001bdeb 051557ff 00000fff 10 0000 001f 11 0780 0438, 02 10 0001bdeb 155557ff 00000fff 10 0000 001f 11 0780 0438 +extends.wfd_audio_codecs=LPCM 00000003 00, AAC 0000000f 00, AC3 00000007 00 +extends.wfd_display_edid=0001 00ffffffffffff0051f38f50010000000e100104a51d10ff2f0000a057499b2610484f000000010101010101010101010101010101011a36809c70381f403020350025a510000018000000fc00496e7465726e616c204c43440a000000fd003c3c9a9a0e00000000000000000000000000000000000000000000000000000030 +extends.wfd_connector_type=05 +extends.microsoft_cursor=none +extends.microsoft_rtcp_capability=none +extends.wfd_idr_request_capability=1 +extends.microsoft_latency_management_capability=none +extends.microsoft_format_change_capability=none +extends.microsoft_diagnostics_capability=none +extends.intel_friendly_name=miraclecast +extends.intel_sink_manufacturer_name=GNU Linux +extends.intel_sink_model_name=Arch linux +extends.intel_sink_device_URL=http://github.com/albfan/miraclecast +extends.wfd_uibc_capability=input_category_list=GENERIC, HIDC;generic_cap_list=Keyboard;hidc_cap_list=Keyboard/USB, Mouse/USB, MultiTouch/USB, Gesture/USB, RemoteControl/USB;port=none diff --git a/res/write-udev-rule.sh b/res/write-udev-rule.sh index 6786dc9f..73095da7 100755 --- a/res/write-udev-rule.sh +++ b/res/write-udev-rule.sh @@ -8,7 +8,7 @@ ETHER_COUNT=$(echo "$ETHER_NAMES" | wc -l) if [ 0 = $ETHER_COUNT ] then - echo There is no net devices avaliable + echo There is no net devices available exit 1 elif [ 1 = $ETHER_COUNT ] then diff --git a/src/ctl/ctl-sink.c b/src/ctl/ctl-sink.c index fe652cc4..aeb59bf8 100644 --- a/src/ctl/ctl-sink.c +++ b/src/ctl/ctl-sink.c @@ -87,51 +87,68 @@ static void sink_handle_get_parameter(struct ctl_sink *s, return cli_vERR(r); /* wfd_content_protection */ - if (rtsp_message_read(m, "{<>}", "wfd_content_protection") >= 0) { - r = rtsp_message_append(rep, "{&}", - "wfd_content_protection: none"); - if (r < 0) - return cli_vERR(r); - } + check_and_response_option("wfd_content_protection", "none"); + GHashTable* protocol_extensions = s->protocol_extensions; /* wfd_video_formats */ - if (rtsp_message_read(m, "{<>}", "wfd_video_formats") >= 0) { - char wfd_video_formats[128]; - sprintf(wfd_video_formats, - "wfd_video_formats: 00 00 03 10 %08x %08x %08x 00 0000 0000 10 none none", - s->resolutions_cea, s->resolutions_vesa, s->resolutions_hh); - r = rtsp_message_append(rep, "{&}", wfd_video_formats); - if (r < 0) - return cli_vERR(r); - } + gchar* wfd_video_formats = NULL; + if (protocol_extensions != NULL) { + gchar* wfd_video_formats_extension = g_hash_table_lookup(protocol_extensions, WFD_VIDEO_FORMATS); + if (wfd_video_formats_extension != NULL) { + wfd_video_formats = wfd_video_formats_extension; + } + } + if (wfd_video_formats == NULL) { + char video_formats[128]; + sprintf(video_formats, "00 00 03 10 %08x %08x %08x 00 0000 0000 10 none none", + s->resolutions_cea, s->resolutions_vesa, s->resolutions_hh); + wfd_video_formats = video_formats; + } + check_and_response_option(WFD_VIDEO_FORMATS, wfd_video_formats); + /* wfd_audio_codecs */ - if (rtsp_message_read(m, "{<>}", "wfd_audio_codecs") >= 0) { - r = rtsp_message_append(rep, "{&}", - "wfd_audio_codecs: AAC 00000007 00"); - if (r < 0) - return cli_vERR(r); - } + gchar* wfd_audio_codecs = "AAC 00000007 00"; + if (protocol_extensions != NULL) { + gchar* wfd_audio_codecs_extension = g_hash_table_lookup(protocol_extensions, WFD_AUDIO_CODECS); + if (wfd_audio_codecs_extension != NULL) { + wfd_audio_codecs = wfd_audio_codecs_extension; + } + } + check_and_response_option(WFD_AUDIO_CODECS, wfd_audio_codecs); + /* wfd_client_rtp_ports */ - if (rtsp_message_read(m, "{<>}", "wfd_client_rtp_ports") >= 0) { - char wfd_client_rtp_ports[128]; - sprintf(wfd_client_rtp_ports, - "wfd_client_rtp_ports: RTP/AVP/UDP;unicast %d 0 mode=play", rstp_port); - r = rtsp_message_append(rep, "{&}", - wfd_client_rtp_ports); - if (r < 0) - return cli_vERR(r); - } + char wfd_client_rtp_ports[128]; + sprintf(wfd_client_rtp_ports, "RTP/AVP/UDP;unicast %d 0 mode=play", rstp_port); + check_and_response_option("wfd_client_rtp_ports", wfd_client_rtp_ports); + + if (protocol_extensions != NULL) { + GList* extension_keys = g_hash_table_get_keys(protocol_extensions); + for (int i = 0; i}", "wfd_uibc_capability") >= 0 && uibc_option) { - char wfd_uibc_capability[512]; - sprintf(wfd_uibc_capability, - "wfd_uibc_capability: input_category_list=GENERIC;" - "generic_cap_list=Mouse,SingleTouch;" - "hidc_cap_list=none;port=none"); - r = rtsp_message_append(rep, "{&}", wfd_uibc_capability); - if (r < 0) - return cli_vERR(r); + if (uibc_option) { + gchar* wfd_uibc_capability = "input_category_list=GENERIC;" + "generic_cap_list=Mouse,SingleTouch;" + "hidc_cap_list=none;" + "port=none"; + if (protocol_extensions != NULL) { + gchar* wfd_uibc_capability_extension = g_hash_table_lookup(protocol_extensions, WFD_UIBC_CAPABILITY); + if (wfd_uibc_capability_extension != NULL) { + wfd_uibc_capability = wfd_uibc_capability_extension; + } + } + check_and_response_option(WFD_UIBC_CAPABILITY, wfd_uibc_capability); } + rtsp_message_seal(rep); cli_debug("OUTGOING: %s\n", rtsp_message_get_raw(rep)); @@ -140,6 +157,10 @@ static void sink_handle_get_parameter(struct ctl_sink *s, return cli_vERR(r); } +bool check_rtsp_option(struct rtsp_message *m, char *option) { + return rtsp_message_read(m, "{<>}", option) >= 0; +} + static int sink_setup_fn(struct rtsp *bus, struct rtsp_message *m, void *data) { _rtsp_message_unref_ struct rtsp_message *rep = NULL; @@ -545,6 +566,7 @@ void ctl_sink_free(struct ctl_sink *s) free(s->session); free(s->url); sd_event_unref(s->event); + g_hash_table_destroy(s->protocol_extensions); free(s); } diff --git a/src/ctl/ctl-sink.h b/src/ctl/ctl-sink.h index 72185832..22c84013 100644 --- a/src/ctl/ctl-sink.h +++ b/src/ctl/ctl-sink.h @@ -32,6 +32,7 @@ #include #include #include +#include #include "ctl.h" #include "rtsp.h" @@ -39,6 +40,10 @@ #include "shl_util.h" #include "wfd.h" +#define WFD_VIDEO_FORMATS "wfd_video_formats" +#define WFD_AUDIO_CODECS "wfd_audio_codecs" +#define WFD_UIBC_CAPABILITY "wfd_uibc_capability" + extern int rstp_port; extern bool uibc_option; extern bool uibc_enabled; @@ -68,6 +73,20 @@ struct ctl_sink { int hres; int vres; + + GHashTable* protocol_extensions; }; +bool check_rtsp_option(struct rtsp_message *m, char *option); + +#define check_and_response_option(option, response) \ + if (check_rtsp_option(m, option)) { \ + char option_response[512]; \ + sprintf(option_response, "%s: %s", option, response); \ + r = rtsp_message_append(rep, "{&}", option_response); \ + if (r < 0) {\ + return cli_vERR(r); \ + } \ + } + #endif /* CTL_SINK_H */ diff --git a/src/ctl/sinkctl.c b/src/ctl/sinkctl.c index 3078f686..d53ff51b 100644 --- a/src/ctl/sinkctl.c +++ b/src/ctl/sinkctl.c @@ -66,6 +66,7 @@ bool external_player; int rstp_port; int uibc_port; char* player; +GHashTable* protocol_extensions; unsigned int wfd_supported_res_cea = 0x0001ffff; unsigned int wfd_supported_res_vesa = 0x1fffffff; @@ -712,7 +713,7 @@ void cli_fn_help() printf("%s [OPTIONS...] ...\n\n" "Control a dedicated local sink via MiracleCast.\n" " -h --help Show this help\n" - " --help-commands Show avaliable commands\n" + " --help-commands Show available commands\n" " --version Show package version\n" " --log-level Maximum level for log messages\n" " --log-journal-level Maximum level for journal log messages\n" @@ -726,7 +727,7 @@ void cli_fn_help() " default CEA %08X\n" " default VESA %08X\n" " default HH %08X\n" - " --help-res Shows avaliable values for res\n" + " --help-res Shows available values for res\n" "\n" , program_invocation_short_name, gst_audio_en, DEFAULT_RSTP_PORT, wfd_supported_res_cea, wfd_supported_res_vesa, wfd_supported_res_hh @@ -748,6 +749,7 @@ static int ctl_interactive(char **argv, int argc) r = ctl_sink_new(&sink, cli_event); if (r < 0) goto error; + sink->protocol_extensions = protocol_extensions; ctl_wifi_fetch(wifi); @@ -918,7 +920,7 @@ int main(int argc, char **argv) } gchar* autocmd; autocmd = g_key_file_get_string (gkf, "sinkctl", "autocmd", NULL); - if (autocmd && argc == 1) { + if (autocmd) { gchar** autocmds = g_strsplit(autocmd, " ", -1); autocmds_free = autocmds; while (*autocmds) { @@ -938,6 +940,22 @@ int main(int argc, char **argv) } g_free(autocmd); } + gchar** sinkctl_keys; + gsize len = 0; + protocol_extensions = g_hash_table_new(g_str_hash, g_str_equal); + + sinkctl_keys = g_key_file_get_keys (gkf, + "sinkctl", + &len, + NULL); + for (int i = 0; i < (int)len; i++) { + if (g_str_has_prefix(sinkctl_keys[i], "extends.")) { + gchar* orig_key = sinkctl_keys[i]; + gchar* key = orig_key+8; + gchar* value = g_key_file_get_string (gkf, "sinkctl", orig_key, NULL); + g_hash_table_insert(protocol_extensions, key, value); + } + } g_key_file_free(gkf); } diff --git a/src/ctl/wifictl.c b/src/ctl/wifictl.c index faf78808..d862b9c8 100644 --- a/src/ctl/wifictl.c +++ b/src/ctl/wifictl.c @@ -478,7 +478,7 @@ void cli_fn_help() "Send control command to or query the MiracleCast Wifi-Manager. If no arguments\n" "are given, an interactive command-line tool is provided.\n\n" " -h --help Show this help\n" - " --help-commands Show avaliable commands\n" + " --help-commands Show available commands\n" " --version Show package version\n" " --log-level Maximum level for log messages\n" " --log-journal-level Maximum level for journal log messages\n" diff --git a/src/dhcp/dhcp.c b/src/dhcp/dhcp.c index 5457764f..83e7295b 100644 --- a/src/dhcp/dhcp.c +++ b/src/dhcp/dhcp.c @@ -35,7 +35,7 @@ * of Wifi-P2P support in common network managers. Once they gain proper * support, we will drop this helper! * - * The "ip" invokation is quite fragile and ugly. However, performing these + * The "ip" invocation is quite fragile and ugly. However, performing these * steps directly involves netlink operations and more. As no-one came up with * patches, yet, we keep the hack. To anyone trying to fix it: Please, spend * this time hacking on NetworkManager, connman and friends instead! If they @@ -67,8 +67,11 @@ #include "shl_log.h" #include "config.h" +#define XSTR(x) STR(x) +#define STR(x) #x + static const char *arg_netdev; -static const char *arg_ip_binary = "/bin/ip"; +static const char *arg_ip_binary = XSTR(IP_BINARY); static bool arg_server; static char arg_local[INET_ADDRSTRLEN]; static char arg_gateway[INET_ADDRSTRLEN]; @@ -749,7 +752,7 @@ static int help(void) " --log-time Prefix log-messages with timestamp\n" "\n" " --netdev Network device to run on\n" - " --ip-binary Path to 'ip' binary [default: /bin/ip]\n" + " --ip-binary Path to 'ip' binary [default: "XSTR(IP_BINARY)"]\n" " --comm-fd Comm-socket FD passed through execve()\n" "\n" "Server Options:\n" diff --git a/src/shared/shl_util.c b/src/shared/shl_util.c index 1d3f6629..24176244 100644 --- a/src/shared/shl_util.c +++ b/src/shared/shl_util.c @@ -31,7 +31,7 @@ * variants to allow these. * Base-prefix parsing is only done if base=0 is requested. Otherwise, * base-prefixes are forbidden. - * The input string must be ASCII compatbile (which includes UTF8). + * The input string must be ASCII compatible (which includes UTF8). * * We also always check for overflows and return errors (but continue parsing!) * so callers can catch it correctly. diff --git a/src/uibc/miracle-uibcctl.c b/src/uibc/miracle-uibcctl.c index 2c8835b4..3aee587b 100644 --- a/src/uibc/miracle-uibcctl.c +++ b/src/uibc/miracle-uibcctl.c @@ -314,7 +314,7 @@ void getUIBCGenericKeyPacket(const char *inEventDesc, typeId = atoi(*(splitedStr + i)); log_info("getUIBCGenericKeyPacket typeId=[%d]\n", typeId); genericPacketLen = 5; - uibcBodyLen = genericPacketLen + 7; // Generic header legth = 7 + uibcBodyLen = genericPacketLen + 7; // Generic header length = 7 outData = (char*)malloc(uibcBodyLen + 1); // UIBC header outData[0] = 0x00; //Version (3 bits),T (1 bit),Reserved(8 bits),Input Category (4 bits) diff --git a/src/wifi/wifid-dbus.c b/src/wifi/wifid-dbus.c index 8aed6f4d..a856cd2c 100644 --- a/src/wifi/wifid-dbus.c +++ b/src/wifi/wifid-dbus.c @@ -938,7 +938,7 @@ int manager_dbus_connect(struct manager *m) r = sd_bus_request_name(m->bus, "org.freedesktop.miracle.wifi", 0); if (r < 0) { if (r == -EEXIST) { - log_info("cannot claim org.freedesktop.miracle.wifi bus-name: it is already being adquired"); + log_info("cannot claim org.freedesktop.miracle.wifi bus-name: it is already being acquired"); } else { log_error("cannot claim org.freedesktop.miracle.wifi bus-name: %d", r); diff --git a/src/wifi/wifid-link.c b/src/wifi/wifid-link.c index 9b375719..1093fc44 100644 --- a/src/wifi/wifid-link.c +++ b/src/wifi/wifid-link.c @@ -135,22 +135,23 @@ void link_free(struct link *l) free(l->friendly_name); free(l->ifname); free(l->config_methods); + free(l->ip_binary); free(l); } void link_use_dev(struct link *l) { - l->use_dev = true; + l->use_dev = true; } bool link_is_using_dev(struct link *l) { - return l->use_dev; + return l->use_dev; } int link_set_config_methods(struct link *l, char *config_methods) { - char *cm; + char *cm; if (!config_methods) return log_EINVAL(); @@ -160,8 +161,24 @@ int link_set_config_methods(struct link *l, char *config_methods) return log_ENOMEM(); free(l->config_methods); - l->config_methods = config_methods; - return 0; + l->config_methods = cm; + return 0; +} + +int link_set_ip_binary(struct link *l, const char *ip_binary) +{ + char *ipb; + + if (!ip_binary) + return log_EINVAL(); + + ipb = strdup(ip_binary); + if (!ipb) + return log_ENOMEM(); + + free(l->ip_binary); + l->ip_binary = ipb; + return 0; } bool link_get_managed(struct link *l) diff --git a/src/wifi/wifid-supplicant.c b/src/wifi/wifid-supplicant.c index fef362df..7679d7f4 100644 --- a/src/wifi/wifid-supplicant.c +++ b/src/wifi/wifid-supplicant.c @@ -397,6 +397,10 @@ static int supplicant_group_spawn_dhcp_server(struct supplicant_group *g, argv[i++] = g->ifname; argv[i++] = "--comm-fd"; argv[i++] = commfd; + if (g->s->l->ip_binary) { + argv[i++] = "--ip-binary"; + argv[i++] = g->s->l->ip_binary; + } argv[i] = NULL; if (execvpe(argv[0], argv, environ)< 0) { @@ -458,6 +462,10 @@ static int supplicant_group_spawn_dhcp_client(struct supplicant_group *g) argv[i++] = g->ifname; argv[i++] = "--comm-fd"; argv[i++] = commfd; + if (g->s->l->ip_binary) { + argv[i++] = "--ip-binary"; + argv[i++] = g->s->l->ip_binary; + } argv[i] = NULL; if (execvpe(argv[0], argv, environ) < 0) { @@ -876,7 +884,7 @@ static void supplicant_parse_peer(struct supplicant *s, /* TODO: wfd_dev_info only contains the dev-info sub-elem, * while wfd_sublemens contains all. Fix that! The user has no * chance to distinguish both. - * We currently use it only as boolen (set/unset) but once we + * We currently use it only as boolean (set/unset) but once we * parse it we _definitely_ have to provide proper data. */ r = wpas_message_dict_read(m, "wfd_dev_info", 's', &val); if (r >= 0) { @@ -2211,7 +2219,7 @@ static int supplicant_global_attach_fn(struct wpas *w, * Devices with P2P_DEVICE support (instead of direct P2P_GO/CLIENT * support) are broken with a *lot* of wpa_supplicant versions on the * global interface. Therefore, try to open the p2p-dev-* interface - * after the global-ATTACH succeded (which means the iface is properly + * after the global-ATTACH succeeded (which means the iface is properly * set up). If this works, use the p2p-dev-* interface, otherwise, just * copy the global interface over to bus_dev. * Event-forwarding is broken on the global-interface in such cases, diff --git a/src/wifi/wifid.c b/src/wifi/wifid.c index 4b46f647..7a45b941 100644 --- a/src/wifi/wifid.c +++ b/src/wifi/wifid.c @@ -40,12 +40,16 @@ #include "wifid.h" #include "config.h" +#define XSTR(x) STR(x) +#define STR(x) #x const char *interface_name = NULL; const char *config_methods = NULL; unsigned int arg_wpa_loglevel = LOG_NOTICE; bool arg_wpa_syslog = false; bool use_dev = false; bool lazy_managed = false; +const char *arg_ip_binary = NULL; + /* * Manager Handling @@ -104,13 +108,15 @@ static void manager_add_udev_link(struct manager *m, if (r < 0) return; - if (m->friendly_name && l->managed) - link_set_friendly_name(l, m->friendly_name); - if (m->config_methods) - link_set_config_methods(l, m->config_methods); + if (m->friendly_name && l->managed) + link_set_friendly_name(l, m->friendly_name); + if (m->config_methods) + link_set_config_methods(l, m->config_methods); if(use_dev) - link_use_dev(l); + link_use_dev(l); + if(arg_ip_binary) + link_set_ip_binary(l, arg_ip_binary); #ifdef RELY_UDEV bool managed = udev_device_has_tag(d, "miracle") && !lazy_managed; @@ -484,6 +490,7 @@ static int help(void) " --wpa-syslog wpa_supplicant use syslog\n" " --use-dev enable workaround for 'no ifname' issue\n" " --lazy-managed manage interface only when user decide to do\n" + " --ip-binary path to 'ip' binary [default: "XSTR(IP_BINARY)"]\n" , program_invocation_short_name); /* * 80-char barrier: @@ -504,6 +511,7 @@ static int parse_argv(int argc, char *argv[]) ARG_USE_DEV, ARG_CONFIG_METHODS, ARG_LAZY_MANAGED, + ARG_IP_BINARY, }; static const struct option options[] = { { "help", no_argument, NULL, 'h' }, @@ -517,6 +525,7 @@ static int parse_argv(int argc, char *argv[]) { "use-dev", no_argument, NULL, ARG_USE_DEV }, { "config-methods", required_argument, NULL, ARG_CONFIG_METHODS }, { "lazy-managed", no_argument, NULL, ARG_LAZY_MANAGED }, + { "ip-binary", required_argument, NULL, ARG_IP_BINARY }, {} }; int c; @@ -552,6 +561,9 @@ static int parse_argv(int argc, char *argv[]) case ARG_WPA_SYSLOG: arg_wpa_syslog = true; break; + case ARG_IP_BINARY: + arg_ip_binary = optarg; + break; case '?': return -EINVAL; } diff --git a/src/wifi/wifid.h b/src/wifi/wifid.h index d07c29f4..db78f189 100644 --- a/src/wifi/wifid.h +++ b/src/wifi/wifid.h @@ -130,6 +130,7 @@ struct link { char *friendly_name; char *wfd_subelements; char *config_methods; + char *ip_binary; size_t peer_cnt; struct shl_htable peers; @@ -159,6 +160,8 @@ void link_free(struct link *l); void link_use_dev(struct link *l); bool link_is_using_dev(struct link *l); +int link_set_ip_binary(struct link *l, const char *ip_binary); + int link_set_managed(struct link *l, bool set); bool link_get_managed(struct link *l); int link_renamed(struct link *l, const char *ifname); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a6e3b44b..1363051f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -41,7 +41,7 @@ if(CHECK_FOUND) add_custom_target(memcheck DEPENDS memcheck-verify - COMMAND for i in $(MEMTESTS) | + COMMAND for i in $$(MEMTESTS) | do | ${VALGRIND} --log-file=${CMAKE_SOURCE_DIR}/$$i.memlog | ${CMAKE_SOURCE_DIR}/$$i >/dev/null || (echo "memcheck failed on: $$i" ; exit 1) ; |