cfgfile_gen: improve printing of routing tables
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 30 Apr 2015 09:29:26 +0000 (11:29 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Fri, 1 May 2015 07:38:57 +0000 (09:38 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
src/cfgparser/cfgfile_gen.c

index ea820fb..05bfb7f 100644 (file)
@@ -469,25 +469,55 @@ void olsrd_write_cnf_autobuf(struct autobuf *out, struct olsrd_config *cnf) {
     DEF_SGW_RT_TABLE_NR, DEF_SGW_RT_TABLE_DEFAULT_NR, DEF_SGW_RT_TABLE_TUNNEL_NR,
     DEF_RT_TABLE_NR, DEF_RT_TABLE_DEFAULT_NR, DEF_RT_TABLE_TUNNEL_NR);
   if (!cnf->smart_gw_active) {
-    abuf_appendf(out, "%sRtTable        %u\n",
-        cnf->rt_table == DEF_RT_TABLE_NR ? "# " : "",
-        cnf->rt_table);
-    abuf_appendf(out, "%sRtTableDefault %u\n",
-        cnf->rt_table_default == DEF_RT_TABLE_DEFAULT_NR ? "# " : "",
-        cnf->rt_table_default);
-    abuf_appendf(out, "%sRtTableTunnel  %u\n",
-        cnf->rt_table_tunnel == DEF_RT_TABLE_TUNNEL_NR ? "# " : "",
-        cnf->rt_table_tunnel);
+    if (cnf->rt_table == DEF_RT_TABLE_NR)
+      abuf_appendf(out, "%sRtTable        %s\n",
+          "# ",
+          "auto");
+    else
+      abuf_appendf(out, "%sRtTable        %u\n",
+          "",
+          cnf->rt_table);
+    if (cnf->rt_table_default == DEF_RT_TABLE_DEFAULT_NR)
+      abuf_appendf(out, "%sRtTableDefault %s\n",
+          "# ",
+          "auto");
+    else
+      abuf_appendf(out, "%sRtTableDefault %u\n",
+          "",
+          cnf->rt_table_default);
+    if (cnf->rt_table_tunnel == DEF_RT_TABLE_TUNNEL_NR)
+      abuf_appendf(out, "%sRtTableTunnel  %s\n",
+          "# ",
+          "auto");
+    else
+      abuf_appendf(out, "%sRtTableTunnel  %u\n",
+          "",
+          cnf->rt_table_tunnel);
   } else {
-    abuf_appendf(out, "%sRtTable        %u\n",
-        cnf->rt_table == DEF_SGW_RT_TABLE_NR ? "# " : "",
-        cnf->rt_table);
-    abuf_appendf(out, "%sRtTableDefault %u\n",
-        cnf->rt_table_default == DEF_SGW_RT_TABLE_DEFAULT_NR ? "# " : "",
-        cnf->rt_table_default);
-    abuf_appendf(out, "%sRtTableTunnel  %u\n",
-        cnf->rt_table_tunnel == DEF_SGW_RT_TABLE_TUNNEL_NR ? "# " : "",
-        cnf->rt_table_tunnel);
+    if (cnf->rt_table == DEF_SGW_RT_TABLE_NR)
+      abuf_appendf(out, "%sRtTable        %s\n",
+          "# ",
+          "auto");
+    else
+      abuf_appendf(out, "%sRtTable        %u\n",
+          "",
+          cnf->rt_table);
+    if (cnf->rt_table_default == DEF_SGW_RT_TABLE_DEFAULT_NR)
+      abuf_appendf(out, "%sRtTableDefault %s\n",
+          "# ",
+          "auto");
+    else
+      abuf_appendf(out, "%sRtTableDefault %u\n",
+          "",
+          cnf->rt_table_default);
+    if (cnf->rt_table_tunnel == DEF_SGW_RT_TABLE_TUNNEL_NR)
+      abuf_appendf(out, "%sRtTableTunnel  %s\n",
+          "# ",
+          "auto");
+    else
+      abuf_appendf(out, "%sRtTableTunnel  %u\n",
+          "",
+          cnf->rt_table_tunnel);
   }
   abuf_appendf(out,
     "\n"