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
|
|
@ -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