1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-02-12 16:11:54 +00:00

Customizable config_methods

This commit is contained in:
Alberto Fanjul 2018-09-21 13:02:57 +02:00
parent 34595f035e
commit 5bfc97a72c
4 changed files with 42 additions and 5 deletions

View file

@ -129,6 +129,7 @@ void link_free(struct link *l)
free(l->wfd_subelements);
free(l->friendly_name);
free(l->ifname);
free(l->config_methods);
free(l);
}
@ -142,6 +143,22 @@ bool link_is_using_dev(struct link *l)
return l->use_dev;
}
int link_set_config_methods(struct link *l, char *config_methods)
{
char *cm;
if (!config_methods)
return log_EINVAL();
cm = strdup(config_methods);
if (!cm)
return log_ENOMEM();
free(l->config_methods);
l->config_methods = config_methods;
return 0;
}
void link_set_managed(struct link *l, bool set)
{
int r;

View file

@ -2597,10 +2597,9 @@ static int supplicant_write_config(struct supplicant *s)
"driver_param=%s\n"
"ap_scan=%s\n"
"# End of configuration\n",
s->l->friendly_name ? : "unknown",
s->l->friendly_name ?: "unknown",
"1-0050F204-1",
"pbc",
//"pbc keypad pin display",
s->l->config_methods ?: "pbc",
"p2p_device=1",
"1");
if (r < 0) {

View file

@ -41,6 +41,7 @@
#include "config.h"
const char *interface_name = NULL;
const char *config_methods = NULL;
unsigned int arg_wpa_loglevel = LOG_NOTICE;
bool use_dev = false;
@ -102,6 +103,7 @@ static void manager_add_udev_link(struct manager *m,
return;
link_set_friendly_name(l, m->friendly_name);
link_set_config_methods(l, m->config_methods);
if(use_dev)
link_use_dev(l);
@ -215,6 +217,7 @@ static void manager_free(struct manager *m)
sd_event_unref(m->event);
free(m->friendly_name);
free(m->config_methods);
free(m);
}
@ -227,6 +230,7 @@ static int manager_new(struct manager **out)
unsigned int i;
sigset_t mask;
int r;
char *cm;
m = calloc(1, sizeof(*m));
if (!m)
@ -234,6 +238,16 @@ static int manager_new(struct manager **out)
shl_htable_init_uint(&m->links);
if (config_methods) {
cm = strdup(config_methods);
if (!cm)
return log_ENOMEM();
free(m->config_methods);
m->config_methods = cm;
}
r = sd_event_default(&m->event);
if (r < 0) {
log_vERR(r);
@ -459,6 +473,7 @@ static int help(void)
" --log-time Prefix log-messages with timestamp\n"
"\n"
" -i --interface Choose the interface to use\n"
" --config-methods Define config methods for pairing, default 'pbc'\n"
"\n"
" --wpa-loglevel <lvl wpa_supplicant log-level\n"
" --use-dev enable workaround for 'no ifname' issue\n"
@ -477,10 +492,9 @@ static int parse_argv(int argc, char *argv[])
ARG_VERSION = 0x100,
ARG_LOG_LEVEL,
ARG_LOG_TIME,
ARG_WPA_LOGLEVEL,
ARG_USE_DEV,
ARG_CONFIG_METHODS,
};
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
@ -491,6 +505,7 @@ static int parse_argv(int argc, char *argv[])
{ "wpa-loglevel", required_argument, NULL, ARG_WPA_LOGLEVEL },
{ "interface", required_argument, NULL, 'i' },
{ "use-dev", no_argument, NULL, ARG_USE_DEV },
{ "config-methods", required_argument, NULL, ARG_CONFIG_METHODS },
{}
};
int c;
@ -514,6 +529,9 @@ static int parse_argv(int argc, char *argv[])
case ARG_USE_DEV:
use_dev = true;
break;
case ARG_CONFIG_METHODS:
config_methods = optarg;
break;
case ARG_WPA_LOGLEVEL:
arg_wpa_loglevel = log_parse_arg(optarg);

View file

@ -129,6 +129,7 @@ struct link {
char *ifname;
char *friendly_name;
char *wfd_subelements;
char *config_methods;
size_t peer_cnt;
struct shl_htable peers;
@ -161,6 +162,7 @@ bool link_is_using_dev(struct link *l);
void link_set_managed(struct link *l, bool set);
int link_renamed(struct link *l, const char *ifname);
int link_set_config_methods(struct link *l, char *config_methods);
int link_set_friendly_name(struct link *l, const char *name);
const char *link_get_friendly_name(struct link *l);
int link_set_wfd_subelements(struct link *l, const char *val);
@ -188,6 +190,7 @@ struct manager {
sd_event_source *udev_mon_source;
char *friendly_name;
char *config_methods;
size_t link_cnt;
struct shl_htable links;