mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
Merge pull request #8042 from zx2c4-forks/jd/networkctl-type
networkd: fixup networkctl type display
This commit is contained in:
commit
3b8f29fd93
@ -56,49 +56,28 @@ static bool arg_no_pager = false;
|
||||
static bool arg_legend = true;
|
||||
static bool arg_all = false;
|
||||
|
||||
static int link_get_type_string(unsigned short iftype, sd_device *d, char **ret) {
|
||||
static char *link_get_type_string(unsigned short iftype, sd_device *d) {
|
||||
const char *t;
|
||||
char *p;
|
||||
|
||||
assert(ret);
|
||||
|
||||
if (iftype == ARPHRD_ETHER && d) {
|
||||
const char *devtype = NULL, *id = NULL;
|
||||
/* WLANs have iftype ARPHRD_ETHER, but we want
|
||||
* to show a more useful type string for
|
||||
* them */
|
||||
if (d) {
|
||||
const char *devtype = NULL;
|
||||
|
||||
(void) sd_device_get_devtype(d, &devtype);
|
||||
|
||||
if (streq_ptr(devtype, "wlan"))
|
||||
id = "wlan";
|
||||
else if (streq_ptr(devtype, "wwan"))
|
||||
id = "wwan";
|
||||
|
||||
if (id) {
|
||||
p = strdup(id);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = p;
|
||||
return 1;
|
||||
}
|
||||
if (!isempty(devtype))
|
||||
return strdup(devtype);
|
||||
}
|
||||
|
||||
t = arphrd_to_name(iftype);
|
||||
if (!t) {
|
||||
*ret = NULL;
|
||||
return 0;
|
||||
}
|
||||
if (!t)
|
||||
return NULL;
|
||||
|
||||
p = strdup(t);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
return NULL;
|
||||
|
||||
ascii_strlower(p);
|
||||
*ret = p;
|
||||
|
||||
return 0;
|
||||
return p;
|
||||
}
|
||||
|
||||
static void operational_state_to_color(const char *state, const char **on, const char **off) {
|
||||
@ -323,7 +302,7 @@ static int list_links(int argc, char *argv[], void *userdata) {
|
||||
xsprintf(devid, "n%i", links[i].ifindex);
|
||||
(void) sd_device_new_from_device_id(&d, devid);
|
||||
|
||||
(void) link_get_type_string(links[i].iftype, d, &t);
|
||||
t = link_get_type_string(links[i].iftype, d);
|
||||
|
||||
printf("%3i %-16s %-18s %s%-11s%s %s%-10s%s\n",
|
||||
links[i].ifindex, links[i].name, strna(t),
|
||||
@ -816,7 +795,7 @@ static int link_status_one(
|
||||
(void) sd_device_get_property_value(d, "ID_MODEL", &model);
|
||||
}
|
||||
|
||||
(void) link_get_type_string(info->iftype, d, &t);
|
||||
t = link_get_type_string(info->iftype, d);
|
||||
|
||||
(void) sd_network_link_get_network_file(info->ifindex, &network);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user