]> git.puffer.fish Git - mirror/frr.git/commitdiff
2005-05-23 Paul Jakma <paul@dishone.st>
authorpaul <paul>
Mon, 23 May 2005 12:43:34 +0000 (12:43 +0000)
committerpaul <paul>
Mon, 23 May 2005 12:43:34 +0000 (12:43 +0000)
* routemap.c: (rmap_onmatch_goto) fix crash if 'continue' command
  is used, which does not supply an argv[0].
  this is a backport candidate /iff/ the trailing ; is removed
  from VTY_GET_INTEGER_RANGE
* vty.h: fix the VTY_GET macros, do {..} while(0) so they have
  correct function like syntax in usage.

lib/ChangeLog
lib/routemap.c
lib/vty.h

index 1e34474fa3bfce87f9a4aea5bbd9a597c84319f0..3268ab9941d3ddf3fe69ae3a6232cc2c11ae95e3 100644 (file)
@@ -3,6 +3,12 @@
        * memtypes.awk: use character classes, which work correctly in
          all LC_COLLATE environments, unlike A-Z, which doesnt work in
          eg estonian collate order. Reported by Hasso.
+       * routemap.c: (rmap_onmatch_goto) fix crash if 'continue' command
+         is used, which does not supply an argv[0].
+         this is a backport candidate /iff/ the trailing ; is removed
+         from VTY_GET_INTEGER_RANGE
+       * vty.h: fix the VTY_GET macros, do {..} while(0) so they have
+         correct function like syntax in usage.
 
 2005-05-19 Paul Jakma <paul@dishone.st>
 
index c52b050a9fde878857d1692c105482af3e764a8f..0a4eeb994e6e18eee5bf01f1f71a77ff19a9bec0 100644 (file)
@@ -26,6 +26,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include "prefix.h"
 #include "routemap.h"
 #include "command.h"
+#include "vty.h"
 #include "log.h"
 \f
 /* Vector for route match rules. */
@@ -1063,15 +1064,16 @@ DEFUN (rmap_onmatch_goto,
        "Goto Clause number\n"
        "Number\n")
 {
-  struct route_map_index *index;
+  struct route_map_index *index = vty->index;
   int d = 0;
 
-  if (argv[0])
-    d = atoi(argv[0]);
-
-  index = vty->index;
   if (index)
     {
+      if (argc == 1 && argv[0])
+        VTY_GET_INTEGER_RANGE("route-map index", d, argv[0], 1, 65536);
+      else
+        d = index->pref + 1;
+      
       if (d <= index->pref)
        {
          /* Can't allow you to do that, Dave */
index 7289b7e6bf903564339f8dc0e3ff5db50799c0df..5a02e65f5172cfa9d6c2475b755cba7cc0e9ff59 100644 (file)
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -149,7 +149,7 @@ struct vty
 
 /* Utility macros to convert VTY argument to unsigned long or integer. */
 #define VTY_GET_LONG(NAME,V,STR) \
-{ \
+do { \
   char *endptr = NULL; \
   (V) = strtoul ((STR), &endptr, 10); \
   if (*endptr != '\0' || (V) == ULONG_MAX) \
@@ -157,25 +157,25 @@ struct vty
       vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
       return CMD_WARNING; \
     } \
-}
+} while (0)
 
 #define VTY_GET_INTEGER_RANGE(NAME,V,STR,MIN,MAX) \
-{ \
+do { \
   unsigned long tmpl; \
-  VTY_GET_LONG(NAME, tmpl, STR) \
-  if ( tmpl < (MIN) || tmpl > (MAX)) \
+  VTY_GET_LONG(NAME, tmpl, STR); \
+  if ( (tmpl < (MIN)) || (tmpl > (MAX))) \
     { \
       vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
       return CMD_WARNING; \
     } \
   (V) = tmpl; \
-}
+} while (0)
 
 #define VTY_GET_INTEGER(NAME,V,STR) \
   VTY_GET_INTEGER_RANGE(NAME,V,STR,0U,UINT32_MAX)
 
 #define VTY_GET_IPV4_ADDRESS(NAME,V,STR)                                      \
-{                                                                             \
+do {                                                                             \
   int retv;                                                                   \
   retv = inet_aton ((STR), &(V));                                             \
   if (!retv)                                                                  \
@@ -183,10 +183,10 @@ struct vty
       vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE);              \
       return CMD_WARNING;                                                     \
     }                                                                         \
-}
+} while (0)
 
 #define VTY_GET_IPV4_PREFIX(NAME,V,STR)                                       \
-{                                                                             \
+do {                                                                             \
   int retv;                                                                   \
   retv = str2prefix_ipv4 ((STR), &(V));                                       \
   if (retv <= 0)                                                              \
@@ -194,7 +194,7 @@ struct vty
       vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE);              \
       return CMD_WARNING;                                                     \
     }                                                                         \
-}
+} while (0)
 
 /* Exported variables */
 extern char integrate_default[];