From cc0c9cbc95df872c2b53ae8eb502127bf34031d1 Mon Sep 17 00:00:00 2001 From: Ferry Huberts Date: Thu, 30 Apr 2015 11:24:26 +0200 Subject: [PATCH] cfgfile_gen: improve printing of MainIp Signed-off-by: Ferry Huberts --- src/cfgparser/cfgfile_gen.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cfgparser/cfgfile_gen.c b/src/cfgparser/cfgfile_gen.c index 546ac430..d4546833 100644 --- a/src/cfgparser/cfgfile_gen.c +++ b/src/cfgparser/cfgfile_gen.c @@ -834,8 +834,14 @@ void olsrd_write_cnf_autobuf(struct autobuf *out, struct olsrd_config *cnf) { "# change during the uptime of olsrd.\n" "# (default is 0.0.0.0, which triggers usage of the IP of the first interface)\n" "\n"); - abuf_appendf(out, "MainIp %s\n", - olsr_ip_to_string(&ipbuf, &cnf->main_addr)); + { + union olsr_ip_addr main_addr; + memset(&main_addr, 0, sizeof(main_addr)); + + abuf_appendf(out, "%sMainIp %s\n", + !memcmp(&main_addr, &cnf->main_addr, (cnf->ip_version == AF_INET) ? sizeof(main_addr.v4) : sizeof(main_addr.v6)) ? "# " : "", + olsr_ip_to_string(&ipbuf, &cnf->main_addr)); + } abuf_appendf(out, "\n" "# The fixed willingness to use (0-7)\n" -- 2.20.1