Merge pull request #13511 from ssahani/networkctl-dhcp

networkctl Improve display of address . Show it's dhcp
This commit is contained in:
Yu Watanabe 2019-09-10 15:16:15 +09:00 committed by GitHub
commit 39b7b6cb4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View file

@ -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);
}

View file

@ -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];

View file

@ -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);