mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
Merge pull request #2717 from keszybz/networkctl-prettification
Networkctl prettification
This commit is contained in:
commit
0ab0c01490
@ -933,7 +933,7 @@
|
||||
<title>Download a Fedora image, set a root password in it, start
|
||||
it as service</title>
|
||||
|
||||
<programlisting># machinectl pull-raw --verify=no http://ftp.halifax.rwth-aachen.de/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-23-20151030.x86_64.raw.xz
|
||||
<programlisting># machinectl pull-raw --verify=no https://dl.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-23-20151030.x86_64.raw.xz
|
||||
# systemd-nspawn -M Fedora-Cloud-Base-23-20151030
|
||||
# passwd
|
||||
# exit
|
||||
|
@ -43,17 +43,6 @@ char* ether_addr_to_string(const struct ether_addr *addr, char buffer[ETHER_ADDR
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool ether_addr_is_null(const struct ether_addr *addr) {
|
||||
assert(addr);
|
||||
|
||||
return addr->ether_addr_octet[0] == 0 &&
|
||||
addr->ether_addr_octet[1] == 0 &&
|
||||
addr->ether_addr_octet[2] == 0 &&
|
||||
addr->ether_addr_octet[3] == 0 &&
|
||||
addr->ether_addr_octet[4] == 0 &&
|
||||
addr->ether_addr_octet[5] == 0;
|
||||
}
|
||||
|
||||
bool ether_addr_equal(const struct ether_addr *a, const struct ether_addr *b) {
|
||||
assert(a);
|
||||
assert(b);
|
||||
|
@ -28,5 +28,10 @@
|
||||
#define ETHER_ADDR_TO_STRING_MAX (3*6)
|
||||
char* ether_addr_to_string(const struct ether_addr *addr, char buffer[ETHER_ADDR_TO_STRING_MAX]);
|
||||
|
||||
bool ether_addr_is_null(const struct ether_addr *addr);
|
||||
bool ether_addr_equal(const struct ether_addr *a, const struct ether_addr *b);
|
||||
|
||||
#define ETHER_ADDR_NULL ((const struct ether_addr){})
|
||||
|
||||
static inline bool ether_addr_is_null(const struct ether_addr *addr) {
|
||||
return ether_addr_equal(addr, ÐER_ADDR_NULL);
|
||||
}
|
||||
|
@ -48,8 +48,9 @@ bool hostname_is_set(void) {
|
||||
char* gethostname_malloc(void) {
|
||||
struct utsname u;
|
||||
|
||||
/* This call tries to return something useful, either the actual hostname or it makes something up. The only
|
||||
* reason it might mail is OOM. It might even return "localhost" if that's set. */
|
||||
/* This call tries to return something useful, either the actual hostname
|
||||
* or it makes something up. The only reason it might fail is OOM.
|
||||
* It might even return "localhost" if that's set. */
|
||||
|
||||
assert_se(uname(&u) >= 0);
|
||||
|
||||
|
@ -1763,7 +1763,7 @@ static int transfer_image_common(sd_bus *bus, sd_bus_message *m) {
|
||||
|
||||
r = sd_bus_call(bus, m, 0, &error, &reply);
|
||||
if (r < 0) {
|
||||
log_error("Failed transfer image: %s", bus_error_message(&error, -r));
|
||||
log_error("Failed to transfer image: %s", bus_error_message(&error, -r));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -901,10 +901,43 @@ static char *lldp_capabilities_to_string(uint16_t x) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void lldp_capabilities_legend(uint16_t x) {
|
||||
unsigned w, i, cols = columns();
|
||||
static const char const* table[] = {
|
||||
"o - Other",
|
||||
"p - Repeater",
|
||||
"b - Bridge",
|
||||
"w - WLAN Access Point",
|
||||
"r - Router",
|
||||
"t - Telephone",
|
||||
"d - DOCSIS cable device",
|
||||
"a - Station",
|
||||
"c - Customer VLAN",
|
||||
"s - Service VLAN",
|
||||
"m - Two-port MAC Relay (TPMR)",
|
||||
};
|
||||
|
||||
if (x == 0)
|
||||
return;
|
||||
|
||||
printf("\nCapability Flags:\n");
|
||||
for (w = 0, i = 0; i < ELEMENTSOF(table); i++)
|
||||
if (x & (1U << i) || arg_all) {
|
||||
bool newline;
|
||||
|
||||
newline = w + strlen(table[i]) + (w == 0 ? 0 : 2) > cols;
|
||||
if (newline)
|
||||
w = 0;
|
||||
w += printf("%s%s%s", newline ? "\n" : "", w == 0 ? "" : "; ", table[i]);
|
||||
}
|
||||
puts("");
|
||||
}
|
||||
|
||||
static int link_lldp_status(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
|
||||
_cleanup_free_ LinkInfo *links = NULL;
|
||||
int i, r, c, m = 0;
|
||||
uint16_t all = 0;
|
||||
|
||||
r = sd_netlink_open(&rtnl);
|
||||
if (r < 0)
|
||||
@ -982,8 +1015,10 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
|
||||
port_description = pdesc;
|
||||
}
|
||||
|
||||
if (sd_lldp_neighbor_get_enabled_capabilities(n, &cc) >= 0)
|
||||
if (sd_lldp_neighbor_get_enabled_capabilities(n, &cc) >= 0) {
|
||||
capabilities = lldp_capabilities_to_string(cc);
|
||||
all |= cc;
|
||||
}
|
||||
|
||||
printf("%-16s %-17s %-16s %-11s %-17s %-16s\n",
|
||||
links[i].name,
|
||||
@ -997,12 +1032,10 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_legend)
|
||||
printf("\nCapability Flags:\n"
|
||||
"o - Other; p - Repeater; b - Bridge; w - WLAN Access Point; r - Router;\n"
|
||||
"t - Telephone; d - DOCSIS cable device; a - Station; c - Customer VLAN;\n"
|
||||
"s - Service VLAN, m - Two-port MAC Relay (TPMR)\n\n"
|
||||
"%i neighbors listed.\n", m);
|
||||
if (arg_legend) {
|
||||
lldp_capabilities_legend(all);
|
||||
printf("\n%i neighbors listed.\n", m);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user