Skip to content

Commit

Permalink
networkctl: Display address is a DHCP4 address
Browse files Browse the repository at this point in the history
  • Loading branch information
ssahani committed Sep 9, 2019
1 parent 611224d commit cdf01b3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/network/networkctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

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

Expand Down

0 comments on commit cdf01b3

Please sign in to comment.