summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2010-02-05 09:51:37 +0100
committerDavid Lamparter <equinox@diac24.net>2010-02-05 09:51:37 +0100
commit1bc5254798593fae60361dfac8b853f6c356895c (patch)
tree43d5d2da847ec3b1b84fe7b6b9787025c8ed75c0
parentea7415e08c20dbcb97e287cd2a6a9bacaedf440f (diff)
parent55d24e7f3dbc69db37781dbff325bda0779778df (diff)
downloadquagga-1bc5254798593fae60361dfac8b853f6c356895c.tar.bz2
quagga-1bc5254798593fae60361dfac8b853f6c356895c.tar.xz
Merge branch 'current' into dn42quagga_1.1.0-dn42.11-rc0
-rw-r--r--lib/vty.c25
-rw-r--r--lib/vty.h7
-rw-r--r--ospfd/ospf_vty.c5
-rw-r--r--zebra/interface.c6
-rw-r--r--zebra/rtadv.c7
5 files changed, 45 insertions, 5 deletions
diff --git a/lib/vty.c b/lib/vty.c
index a76fe2d1..c1bcb328 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -90,6 +90,25 @@ static u_char restricted_mode = 0;
char integrate_default[] = SYSCONFDIR INTEGRATE_DEFAULT_CONFIG;
+void
+vty_prepend (struct vty *vty, const char *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ vsnprintf (vty->prepend + vty->prepend_pos,
+ sizeof(vty->prepend) - vty->prepend_pos,
+ format, args);
+ vty->prepend_pos = strlen (vty->prepend);
+ va_end (args);
+}
+
+void
+vty_unprepend (struct vty *vty)
+{
+ vty->prepend_pos = 0;
+}
+
/* VTY standard output function. */
int
vty_out (struct vty *vty, const char *format, ...)
@@ -100,6 +119,12 @@ vty_out (struct vty *vty, const char *format, ...)
char buf[1024];
char *p = NULL;
+ if (vty->prepend_pos)
+ {
+ vty->prepend_pos = 0;
+ vty_out (vty, "%s", vty->prepend);
+ }
+
if (vty_shell (vty))
{
va_start (args, format);
diff --git a/lib/vty.h b/lib/vty.h
index 7df04b5f..d8f47d86 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -118,6 +118,10 @@ struct vty
/* Timeout seconds and thread. */
unsigned long v_timeout;
struct thread *t_timeout;
+
+ /* Auto-prepending; any vty_out will print this buffer, then clear it: */
+ int prepend_pos;
+ char prepend[1024];
};
/* Integrated configuration file. */
@@ -207,6 +211,9 @@ extern void vty_terminate (void);
extern void vty_reset (void);
extern struct vty *vty_new (void);
extern int vty_out (struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3);
+extern void vty_prepend (struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3);
+extern void vty_unprepend (struct vty *);
+#define vty_prepending(v) ((v)->prepend_pos)
extern void vty_read_config (char *, char *);
extern void vty_time_print (struct vty *, int);
extern void vty_serv_sock (const char *, unsigned short, const char *);
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 01e85c71..434dae2a 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -7612,8 +7612,8 @@ config_write_interface (struct vty *vty)
if (memcmp (ifp->name, "VLINK", 5) == 0)
continue;
- vty_out (vty, "!%s", VTY_NEWLINE);
- vty_out (vty, "interface %s%s", ifp->name,
+ vty_prepend (vty, "!%s", VTY_NEWLINE);
+ vty_prepend (vty, "interface %s%s", ifp->name,
VTY_NEWLINE);
if (ifp->desc)
vty_out (vty, " description %s%s", ifp->desc,
@@ -7802,6 +7802,7 @@ config_write_interface (struct vty *vty)
#ifdef HAVE_OPAQUE_LSA
ospf_opaque_config_write_if (vty, ifp);
#endif /* HAVE_OPAQUE_LSA */
+ vty_unprepend (vty);
}
return write;
diff --git a/zebra/interface.c b/zebra/interface.c
index e19648d7..23554620 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -1753,7 +1753,7 @@ if_config_write (struct vty *vty)
if_data = ifp->info;
- vty_out (vty, "interface %s%s", ifp->name,
+ vty_prepend (vty, "interface %s%s", ifp->name,
VTY_NEWLINE);
if (ifp->desc)
@@ -1821,7 +1821,9 @@ if_config_write (struct vty *vty)
irdp_config_write (vty, ifp);
#endif /* IRDP */
- vty_out (vty, "!%s", VTY_NEWLINE);
+ if (!vty_prepending (vty))
+ vty_out (vty, "!%s", VTY_NEWLINE);
+ vty_unprepend (vty);
}
return 0;
}
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index e8c223f2..9528a31a 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -1585,7 +1585,12 @@ rtadv_config_write (struct vty *vty, struct interface *ifp)
if (zif->rtadv.AdvSendAdvertisements)
vty_out (vty, " no ipv6 nd suppress-ra%s", VTY_NEWLINE);
else
- vty_out (vty, " ipv6 nd suppress-ra%s", VTY_NEWLINE);
+ {
+ if (vty_prepending (vty))
+ vty_prepend (vty, " ipv6 nd suppress-ra%s", VTY_NEWLINE);
+ else
+ vty_out (vty, " ipv6 nd suppress-ra%s", VTY_NEWLINE);
+ }
}