diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-09-10 15:16:15 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-10 15:16:15 +0900 |
commit | 39b7b6cb4ad4a9765afb4e0b47ca5d9aa004d8c5 (patch) | |
tree | 4173ab863a3281f70624a3b147bd28de3d340ec6 /src | |
parent | 77b1af585a496dd507114c29958940621c192de2 (diff) | |
parent | cdf01b36dbd5ac4ff9c733b71aab3d7cc6487bea (diff) | |
download | systemd-39b7b6cb4ad4a9765afb4e0b47ca5d9aa004d8c5.tar.gz |
Merge pull request #13511 from ssahani/networkctl-dhcp
networkctl Improve display of address . Show it's dhcp
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-network/sd-network.c | 4 | ||||
-rw-r--r-- | src/network/networkctl.c | 12 | ||||
-rw-r--r-- | src/systemd/sd-network.h | 4 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index a3c0542d7a..8ff9382d90 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -229,6 +229,10 @@ _public_ int sd_network_link_get_timezone(int ifindex, char **ret) { return network_link_get_string(ifindex, "TIMEZONE", ret); } +_public_ int sd_network_link_get_dhcp4_address(int ifindex, char **ret) { + return network_link_get_string(ifindex, "DHCP4_ADDRESS", ret); +} + _public_ int sd_network_link_get_dns(int ifindex, char ***ret) { return network_link_get_strv(ifindex, "DNS", ret); } diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 3100a2e04e..a7cccbc690 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -678,6 +678,7 @@ static int dump_addresses( int ifindex) { _cleanup_free_ struct local_address *local = NULL; + _cleanup_free_ char *dhcp4_address = NULL; int r, n, i; assert(rtnl); @@ -687,6 +688,8 @@ static int dump_addresses( if (n < 0) return n; + (void) sd_network_link_get_dhcp4_address(ifindex, &dhcp4_address); + for (i = 0; i < n; i++) { _cleanup_free_ char *pretty = NULL; @@ -700,6 +703,15 @@ static int dump_addresses( if (r < 0) return r; + if (dhcp4_address && streq(pretty, dhcp4_address)) { + _cleanup_free_ char *p = NULL; + + p = pretty; + pretty = strjoin(pretty , " (DHCP4)"); + if (!pretty) + return log_oom(); + } + if (ifindex <= 0) { char name[IF_NAMESIZE+1]; diff --git a/src/systemd/sd-network.h b/src/systemd/sd-network.h index c78f7c86bb..1cf4c2ec9d 100644 --- a/src/systemd/sd-network.h +++ b/src/systemd/sd-network.h @@ -110,6 +110,10 @@ int sd_network_link_get_network_file(int ifindex, char **filename); * IP addresses */ int sd_network_link_get_dns(int ifindex, char ***ret); +/* Get DHCP4 address for a given link. This is string representations of + * IPv4 address */ +int sd_network_link_get_dhcp4_address(int ifindex, char **ret); + /* Get NTP entries for a given link. These are domain names or string * representations of IP addresses */ int sd_network_link_get_ntp(int ifindex, char ***ret); |