blob: 9bc0da96cda4c6606fc336ae00045ef7dd7305ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "format-util.h"
#include "network-common.h"
#include "string-util.h"
const char *get_ifname(int ifindex, char **ifname) {
char buf[IF_NAMESIZE + 1];
assert(ifname);
/* This sets ifname only when it is not set yet. */
if (*ifname)
return *ifname;
if (ifindex <= 0)
return NULL;
if (!format_ifname(ifindex, buf))
return NULL;
return *ifname = strdup(buf);
}
|