Skip to content

Commit

Permalink
local.c: refactor to use similar formatting logic for each parameter …
Browse files Browse the repository at this point in the history
…of interface
  • Loading branch information
christf committed Aug 13, 2018
1 parent 5ef7838 commit 4dfe00e
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions local.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,15 @@ local_notify_interface_1(struct local_socket *s,
{
char buf[512], v4[INET_ADDRSTRLEN];
int rc;
int up;

up = if_up(ifp);
if(up && ifp->ipv4)
inet_ntop(AF_INET, ifp->ipv4, v4, INET_ADDRSTRLEN);
else
v4[0] = '\0';

if(up)
if(if_up(ifp))
rc = snprintf(buf, 512,
"%s interface %s up true%s%s%s%s%s%s\n",
local_kind(kind), ifp->name,
ifp->ll ? " ipv6 " : "",
ifp->ll ? format_address(*ifp->ll) : "",
v4[0] ? " ipv4 " : "", v4,
ifp->ipv4 ? " ipv4 " : "",
ifp->ipv4 ? inet_ntop(AF_INET, ifp->ipv4, v4, INET_ADDRSTRLEN) : "",
ifp->conf->use_prefsrc ? " pref-src ": "",
ifp->conf->use_prefsrc ? format_address(ifp->conf->prefsrc) : "");
else
Expand Down

0 comments on commit 4dfe00e

Please sign in to comment.