mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
Merge pull request #125 from derekdai/master
add option --use-dev to miracle-wifid to workaround the 'no ifname' issue
This commit is contained in:
commit
142ba08987
5 changed files with 33 additions and 6 deletions
|
@ -742,6 +742,7 @@ static int wpas__parse_message(struct wpas *w,
|
||||||
const char *ifname = NULL;
|
const char *ifname = NULL;
|
||||||
unsigned int level;
|
unsigned int level;
|
||||||
char *pos;
|
char *pos;
|
||||||
|
char *orig_raw = raw;
|
||||||
int r, num;
|
int r, num;
|
||||||
bool is_event = false;
|
bool is_event = false;
|
||||||
|
|
||||||
|
@ -751,7 +752,7 @@ static int wpas__parse_message(struct wpas *w,
|
||||||
ifname = pos;
|
ifname = pos;
|
||||||
pos = strchrnul(pos, ' ');
|
pos = strchrnul(pos, ' ');
|
||||||
if (*pos)
|
if (*pos)
|
||||||
*pos++ = 0;
|
pos++;
|
||||||
|
|
||||||
len -= pos - raw;
|
len -= pos - raw;
|
||||||
raw = pos;
|
raw = pos;
|
||||||
|
@ -811,15 +812,12 @@ static int wpas__parse_message(struct wpas *w,
|
||||||
|
|
||||||
m->sealed = true;
|
m->sealed = true;
|
||||||
m->rawlen = len;
|
m->rawlen = len;
|
||||||
m->raw = malloc(len + 1);
|
m->raw = strdup(orig_raw);
|
||||||
if (!m->raw)
|
if (!m->raw)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* copy with 0-terminator */
|
|
||||||
memcpy(m->raw, raw, len + 1);
|
|
||||||
|
|
||||||
if (ifname) {
|
if (ifname) {
|
||||||
m->ifname = strdup(ifname);
|
m->ifname = strndup(ifname, strchrnul(ifname, ' ') - ifname);
|
||||||
if (!m->ifname)
|
if (!m->ifname)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,16 @@ void link_free(struct link *l)
|
||||||
free(l);
|
free(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void link_use_dev(struct link *l)
|
||||||
|
{
|
||||||
|
l->use_dev = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool link_is_using_dev(struct link *l)
|
||||||
|
{
|
||||||
|
return l->use_dev;
|
||||||
|
}
|
||||||
|
|
||||||
void link_set_managed(struct link *l, bool set)
|
void link_set_managed(struct link *l, bool set)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
|
@ -2147,6 +2147,9 @@ static int supplicant_global_fn(struct wpas *w,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ignore events on the global-iface, we only listen on dev-iface */
|
/* ignore events on the global-iface, we only listen on dev-iface */
|
||||||
|
if(link_is_using_dev(s->l) && wpas_message_get_ifname(m)) {
|
||||||
|
supplicant_event(s, m);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
|
|
||||||
const char *interface_name = NULL;
|
const char *interface_name = NULL;
|
||||||
unsigned int arg_wpa_loglevel = LOG_NOTICE;
|
unsigned int arg_wpa_loglevel = LOG_NOTICE;
|
||||||
|
bool use_dev = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Manager Handling
|
* Manager Handling
|
||||||
|
@ -102,6 +103,9 @@ static void manager_add_udev_link(struct manager *m,
|
||||||
|
|
||||||
link_set_friendly_name(l, m->friendly_name);
|
link_set_friendly_name(l, m->friendly_name);
|
||||||
|
|
||||||
|
if(use_dev)
|
||||||
|
link_use_dev(l);
|
||||||
|
|
||||||
#ifdef RELY_UDEV
|
#ifdef RELY_UDEV
|
||||||
if (udev_device_has_tag(d, "miracle")) {
|
if (udev_device_has_tag(d, "miracle")) {
|
||||||
#else
|
#else
|
||||||
|
@ -457,6 +461,7 @@ static int help(void)
|
||||||
" -i --interface Choose the interface to use\n"
|
" -i --interface Choose the interface to use\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --wpa-loglevel <lvl wpa_supplicant log-level\n"
|
" --wpa-loglevel <lvl wpa_supplicant log-level\n"
|
||||||
|
" --use-dev enable workaround for 'no ifname' issue\n"
|
||||||
, program_invocation_short_name);
|
, program_invocation_short_name);
|
||||||
/*
|
/*
|
||||||
* 80-char barrier:
|
* 80-char barrier:
|
||||||
|
@ -474,6 +479,8 @@ static int parse_argv(int argc, char *argv[])
|
||||||
ARG_LOG_TIME,
|
ARG_LOG_TIME,
|
||||||
|
|
||||||
ARG_WPA_LOGLEVEL,
|
ARG_WPA_LOGLEVEL,
|
||||||
|
|
||||||
|
ARG_USE_DEV,
|
||||||
};
|
};
|
||||||
static const struct option options[] = {
|
static const struct option options[] = {
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
|
@ -483,6 +490,7 @@ static int parse_argv(int argc, char *argv[])
|
||||||
|
|
||||||
{ "wpa-loglevel", required_argument, NULL, ARG_WPA_LOGLEVEL },
|
{ "wpa-loglevel", required_argument, NULL, ARG_WPA_LOGLEVEL },
|
||||||
{ "interface", required_argument, NULL, 'i' },
|
{ "interface", required_argument, NULL, 'i' },
|
||||||
|
{ "use-dev", no_argument, NULL, ARG_USE_DEV },
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
int c;
|
int c;
|
||||||
|
@ -503,6 +511,9 @@ static int parse_argv(int argc, char *argv[])
|
||||||
case ARG_LOG_TIME:
|
case ARG_LOG_TIME:
|
||||||
log_init_time();
|
log_init_time();
|
||||||
break;
|
break;
|
||||||
|
case ARG_USE_DEV:
|
||||||
|
use_dev = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case ARG_WPA_LOGLEVEL:
|
case ARG_WPA_LOGLEVEL:
|
||||||
arg_wpa_loglevel = log_parse_arg(optarg);
|
arg_wpa_loglevel = log_parse_arg(optarg);
|
||||||
|
|
|
@ -135,6 +135,7 @@ struct link {
|
||||||
|
|
||||||
bool managed : 1;
|
bool managed : 1;
|
||||||
bool public : 1;
|
bool public : 1;
|
||||||
|
bool use_dev : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define link_from_htable(_l) \
|
#define link_from_htable(_l) \
|
||||||
|
@ -153,6 +154,10 @@ int link_new(struct manager *m,
|
||||||
struct link **out);
|
struct link **out);
|
||||||
void link_free(struct link *l);
|
void link_free(struct link *l);
|
||||||
|
|
||||||
|
/* workaround for the 'no ifname' issue */
|
||||||
|
void link_use_dev(struct link *l);
|
||||||
|
bool link_is_using_dev(struct link *l);
|
||||||
|
|
||||||
void link_set_managed(struct link *l, bool set);
|
void link_set_managed(struct link *l, bool set);
|
||||||
int link_renamed(struct link *l, const char *ifname);
|
int link_renamed(struct link *l, const char *ifname);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue