mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
Configurable ip binary path
Different OS have ip binary on different locations It can be configured at: - compile time `IP_BINARY` - execution time `--ip-binary`
This commit is contained in:
parent
65a7a0aad1
commit
df12df656c
10 changed files with 62 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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@"
|
||||
|
||||
|
|
|
@ -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
|
||||
#
|
||||
|
@ -166,6 +172,7 @@ AC_MSG_NOTICE([Build configuration:
|
|||
libdir: $libdir
|
||||
includedir: $includedir
|
||||
sysconfdir: $sysconfdir
|
||||
ip-binary: $IP_BINARY
|
||||
|
||||
Miscellaneous Options:
|
||||
building tests: $have_check
|
||||
|
@ -183,6 +190,7 @@ AC_MSG_NOTICE([Build configuration:
|
|||
libdir: $libdir
|
||||
includedir: $includedir
|
||||
sysconfdir: $sysconfdir
|
||||
ip-binary: $IP_BINARY
|
||||
|
||||
Miscellaneous Options:
|
||||
building tests: $have_check
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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 <dev> Network device to run on\n"
|
||||
" --ip-binary <path> Path to 'ip' binary [default: /bin/ip]\n"
|
||||
" --ip-binary <path> Path to 'ip' binary [default: "XSTR(IP_BINARY)"]\n"
|
||||
" --comm-fd <int> Comm-socket FD passed through execve()\n"
|
||||
"\n"
|
||||
"Server Options:\n"
|
||||
|
|
|
@ -135,6 +135,7 @@ void link_free(struct link *l)
|
|||
free(l->friendly_name);
|
||||
free(l->ifname);
|
||||
free(l->config_methods);
|
||||
free(l->ip_binary);
|
||||
free(l);
|
||||
}
|
||||
|
||||
|
@ -164,6 +165,22 @@ int link_set_config_methods(struct link *l, char *config_methods)
|
|||
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)
|
||||
{
|
||||
return l->managed;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
@ -111,6 +115,8 @@ static void manager_add_udev_link(struct manager *m,
|
|||
|
||||
if(use_dev)
|
||||
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> 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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue