1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-03-09 23:38:56 +00:00

miracled: friendly-name support for local links

The friendly-name is used as name for local links. Default to a random
string and try to read the local hostname during startup.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
David Herrmann 2014-02-10 12:17:19 +01:00
parent 062c73ecf3
commit 2e50d006ad
6 changed files with 119 additions and 2 deletions

View file

@ -152,6 +152,10 @@ static int link_wifi_init(struct link *l)
r = wifi_open(l->w, path);
free(path);
if (r < 0)
return r;
r = wifi_set_name(l->w, l->friendly_name);
if (r < 0)
return r;
@ -212,7 +216,7 @@ int link_new(struct manager *m,
goto error;
}
l->friendly_name = strdup("");
l->friendly_name = strdup(m->friendly_name);
if (!l->friendly_name) {
r = log_ENOMEM();
goto error;
@ -270,3 +274,33 @@ void link_free(struct link *l)
free(l->interface);
free(l);
}
int link_set_friendly_name(struct link *l, const char *name)
{
char *dup;
int r;
if (!l || !name)
return log_EINVAL();
dup = strdup(name);
if (!dup)
return log_ENOMEM();
r = 0;
switch (l->type) {
case LINK_WIFI:
r = wifi_set_name(l->w, name);
break;
}
if (r < 0) {
free(dup);
return r;
}
free(l->friendly_name);
l->friendly_name = dup;
return 0;
}