]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_vty.c
Merge branch 'stable/3.0'
[mirror_frr.git] / ospfd / ospf_vty.c
index 776cf21ae3c0f24b84fa5328d7a80c6d1e4d5ba1..99c8368a5ffbaa5639224363a3d648abaa37ad85 100644 (file)
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with GNU Zebra; see the file COPYING.  If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.  
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -67,36 +66,29 @@ static const char *ospf_network_type_str[] =
 
 /* Utility functions. */
 int
-ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
+str2area_id (const char *str, struct in_addr *area_id, int *area_id_fmt)
 {
-  char *endptr = NULL;
-  unsigned long ret;
+  char *ep;
 
-  /* match "A.B.C.D". */
-  if (strchr (str, '.') != NULL)
-    {
-      ret = inet_aton (str, area_id);
-      if (!ret)
-        return -1;
-      *format = OSPF_AREA_ID_FORMAT_ADDRESS;
-    }
-  /* match "<0-4294967295>". */
-  else
-    {
-      if (*str == '-')
-        return -1;
-      errno = 0;
-      ret = strtoul (str, &endptr, 10);
-      if (*endptr != '\0' || errno || ret > UINT32_MAX)
-        return -1;
+  area_id->s_addr = htonl (strtoul (str, &ep, 10));
+  if (*ep && !inet_aton (str, area_id))
+    return -1;
 
-      area_id->s_addr = htonl (ret);
-      *format = OSPF_AREA_ID_FORMAT_DECIMAL;
-    }
+  *area_id_fmt = *ep ? OSPF_AREA_ID_FMT_DOTTEDQUAD : OSPF_AREA_ID_FMT_DECIMAL;
 
   return 0;
 }
 
+void
+area_id2str (char *buf, int length, struct in_addr *area_id, int area_id_fmt)
+{
+  memset (buf, 0, length);
+
+  if (area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD)
+    strncpy (buf, inet_ntoa (*area_id), length);
+  else
+    sprintf (buf, "%lu", (unsigned long) ntohl (area_id->s_addr));
+}
 
 static int
 str2metric (const char *str, int *metric)
@@ -534,7 +526,7 @@ DEFUN (ospf_network_area,
   VTY_GET_IPV4_PREFIX ("network prefix", p, argv[idx_ipv4_prefixlen]->arg);
   VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
 
-  ret = ospf_network_set (ospf, &p, area_id);
+  ret = ospf_network_set (ospf, &p, area_id, format);
   if (ret == 0)
     {
       vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
@@ -641,6 +633,7 @@ DEFUN (ospf_area_range_cost,
   VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg);
 
   ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
+  ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
 
   VTY_GET_INTEGER ("range cost", cost, argv[idx_cost]->arg);
   ospf_area_range_cost_set (ospf, area_id, &p, cost);
@@ -669,6 +662,7 @@ DEFUN (ospf_area_range_not_advertise,
   VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg);
 
   ospf_area_range_set (ospf, area_id, &p, 0);
+  ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
 
   return CMD_SUCCESS;
 }
@@ -728,6 +722,7 @@ DEFUN (ospf_area_range_substitute,
   VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg);
 
   ospf_area_range_substitute_set (ospf, area_id, &p, &s);
+  ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
 
   return CMD_SUCCESS;
 }
@@ -782,7 +777,7 @@ DEFUN (no_ospf_area_range_substitute,
 struct ospf_vl_config_data {
   struct vty *vty;             /* vty stuff */
   struct in_addr area_id;      /* area ID from command line */
-  int format;                  /* command line area ID format */
+  int area_id_fmt;             /* command line area ID format */
   struct in_addr vl_peer;      /* command line vl_peer */
   int auth_type;               /* Authehntication type, if given */
   char *auth_key;              /* simple password if present */
@@ -821,11 +816,12 @@ ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
                VTY_NEWLINE);
       return NULL;
     }
-  area = ospf_area_get (ospf, area_id, vl_config->format);
+  area = ospf_area_get (ospf, area_id);
+  ospf_area_display_format_set (ospf, area, vl_config->area_id_fmt);
 
   if (area->external_routing != OSPF_AREA_DEFAULT)
     {
-      if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
+      if (vl_config->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD)
        vty_out (vty, "Area %s is %s%s",
                 inet_ntoa (area_id),
                 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
@@ -992,15 +988,15 @@ ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
        "Use null authentication\n" \
        "Use message-digest authentication\n"
 
-#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
+#define VLINK_HELPSTR_TIME_PARAM \
        "Time between HELLO packets\n" \
+       "Seconds\n" \
        "Time between retransmitting lost link state advertisements\n" \
+       "Seconds\n" \
        "Link state transmit delay\n" \
-       "Interval time after which a neighbor is declared down\n"
-
-#define VLINK_HELPSTR_TIME_PARAM \
-       VLINK_HELPSTR_TIME_PARAM_NOSECS \
-       "Seconds\n"
+       "Seconds\n" \
+       "Interval time after which a neighbor is declared down\n" \
+       "Seconds\n" \
 
 #define VLINK_HELPSTR_AUTH_SIMPLE \
        "Authentication password (key)\n" \
@@ -1037,7 +1033,8 @@ DEFUN (ospf_area_vlink,
   ospf_vl_config_data_init(&vl_config, vty);
 
   /* Read off first 2 parameters and check them */
-  ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &vl_config.format);
+  ret = str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id,
+                          &vl_config.area_id_fmt);
   if (ret < 0)
     {
       vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
@@ -1132,59 +1129,6 @@ DEFUN (ospf_area_vlink,
 
 }
 
-DEFUN (ospf_area_vlink_intervals,
-       ospf_area_vlink_intervals_cmd,
-       "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
-       "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "]]]",
-       VLINK_HELPSTR_IPADDR
-       VLINK_HELPSTR_TIME_PARAM
-       VLINK_HELPSTR_TIME_PARAM
-       VLINK_HELPSTR_TIME_PARAM
-       VLINK_HELPSTR_TIME_PARAM)
-{
-  VTY_DECLVAR_CONTEXT(ospf, ospf);
-  struct ospf_vl_config_data vl_config;
-  int ret = 0;
-
-  ospf_vl_config_data_init(&vl_config, vty);
-
-  char *area_id   = argv[1]->arg;
-  char *router_id = argv[3]->arg;
-
-  ret = ospf_str2area_id (area_id, &vl_config.area_id, &vl_config.format);
-  if (ret < 0)
-    {
-      vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-
-  ret = inet_aton (router_id, &vl_config.vl_peer);
-  if (! ret)
-    {
-      vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-  for (unsigned int i = 0; i < 4; i++)
-    {
-      int idx = 0;
-      if (argv_find (argv, argc, "hello-interval", &idx))
-        vl_config.hello_interval = strtol(argv[idx+1]->arg, NULL, 10);
-      else if (argv_find (argv, argc, "retransmit-interval", &idx))
-        vl_config.retransmit_interval = strtol(argv[idx+1]->arg, NULL, 10);
-      else if (argv_find (argv, argc, "transmit-delay", &idx))
-        vl_config.transmit_delay = strtol(argv[idx+1]->arg, NULL, 10);
-      else if (argv_find (argv, argc, "dead-interval", &idx))
-        vl_config.dead_interval = strtol(argv[idx+1]->arg, NULL, 10);
-    }
-
-  /* Action configuration */
-  return ospf_vl_set (ospf, &vl_config);
-}
-
 DEFUN (no_ospf_area_vlink,
        no_ospf_area_vlink_cmd,
        "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]",
@@ -1210,7 +1154,7 @@ DEFUN (no_ospf_area_vlink,
 
   ospf_vl_config_data_init(&vl_config, vty);
 
-  ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format);
+  ret = str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format);
   if (ret < 0)
     {
       vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
@@ -1295,19 +1239,56 @@ DEFUN (no_ospf_area_vlink,
   return ospf_vl_set (ospf, &vl_config);
 }
 
+DEFUN (ospf_area_vlink_intervals,
+       ospf_area_vlink_intervals_cmd,
+       "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}",
+       VLINK_HELPSTR_IPADDR
+       VLINK_HELPSTR_TIME_PARAM)
+{
+  VTY_DECLVAR_CONTEXT(ospf, ospf);
+  struct ospf_vl_config_data vl_config;
+  int ret = 0;
+
+  ospf_vl_config_data_init(&vl_config, vty);
+
+  char *area_id   = argv[1]->arg;
+  char *router_id = argv[3]->arg;
+
+  ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt);
+  if (ret < 0)
+    {
+      vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  ret = inet_aton (router_id, &vl_config.vl_peer);
+  if (! ret)
+    {
+      vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  for (int idx = 4; idx < argc; idx++)
+    {
+      if (strmatch (argv[idx]->text, "hello-interval"))
+        vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10);
+      else if (strmatch (argv[idx]->text, "retransmit-interval"))
+        vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10);
+      else if (strmatch (argv[idx]->text, "transmit-delay"))
+        vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10);
+      else if (strmatch (argv[idx]->text, "dead-interval"))
+        vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10);
+    }
+
+  /* Action configuration */
+  return ospf_vl_set (ospf, &vl_config);
+}
+
 DEFUN (no_ospf_area_vlink_intervals,
        no_ospf_area_vlink_intervals_cmd,
-       "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
-       "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "]]]",
+       "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}",
        NO_STR
        VLINK_HELPSTR_IPADDR
-       VLINK_HELPSTR_TIME_PARAM
-       VLINK_HELPSTR_TIME_PARAM
-       VLINK_HELPSTR_TIME_PARAM
        VLINK_HELPSTR_TIME_PARAM)
 {
   VTY_DECLVAR_CONTEXT(ospf, ospf);
@@ -1319,7 +1300,7 @@ DEFUN (no_ospf_area_vlink_intervals,
   char *area_id   = argv[2]->arg;
   char *router_id = argv[4]->arg;
 
-  ret = ospf_str2area_id (area_id, &vl_config.area_id, &vl_config.format);
+  ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt);
   if (ret < 0)
     {
       vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
@@ -1333,16 +1314,15 @@ DEFUN (no_ospf_area_vlink_intervals,
       return CMD_WARNING;
     }
 
-  for (unsigned int i = 0; i < 4; i++)
+  for (int idx = 5; idx < argc; idx++)
     {
-      int idx = 0;
-      if (argv_find (argv, argc, "hello-interval", &idx))
+      if (strmatch (argv[idx]->text, "hello-interval"))
         vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
-      else if (argv_find (argv, argc, "retransmit-interval", &idx))
+      else if (strmatch (argv[idx]->text, "retransmit-interval"))
         vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
-      else if (argv_find (argv, argc, "transmit-delay", &idx))
+      else if (strmatch (argv[idx]->text, "transmit-delay"))
         vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
-      else if (argv_find (argv, argc, "dead-interval", &idx))
+      else if (strmatch (argv[idx]->text, "dead-interval"))
         vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
     }
 
@@ -1371,7 +1351,8 @@ DEFUN (ospf_area_shortcut,
 
   VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg);
 
-  area = ospf_area_get (ospf, area_id, format);
+  area = ospf_area_get (ospf, area_id);
+  ospf_area_display_format_set (ospf, area, format);
 
   if (strncmp (argv[idx_enable_disable]->arg, "de", 2) == 0)
     mode = OSPF_SHORTCUT_DEFAULT;
@@ -1437,6 +1418,7 @@ DEFUN (ospf_area_stub,
   VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg);
 
   ret = ospf_area_stub_set (ospf, area_id);
+  ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
   if (ret == 0)
     {
       vty_out (vty, "First deconfigure all virtual link through this area%s",
@@ -1466,6 +1448,7 @@ DEFUN (ospf_area_stub_no_summary,
   VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg);
 
   ret = ospf_area_stub_set (ospf, area_id);
+  ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
   if (ret == 0)
     {
       vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
@@ -1532,6 +1515,7 @@ ospf_area_nssa_cmd_handler (struct vty *vty, int argc, struct cmd_token **argv,
   VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[1]->arg);
 
   ret = ospf_area_nssa_set (ospf, area_id);
+  ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
   if (ret == 0)
     {
       vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
@@ -1539,7 +1523,7 @@ ospf_area_nssa_cmd_handler (struct vty *vty, int argc, struct cmd_token **argv,
       return CMD_WARNING;
     }
 
-  if (argc > 1)
+  if (argc > 3)
     {
       if (strncmp (argv[3]->text, "translate-c", 11) == 0)
         ospf_area_nssa_translator_role_set (ospf, area_id,
@@ -1669,7 +1653,8 @@ DEFUN (ospf_area_default_cost,
   VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg);
   VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[idx_number]->arg, 0, 16777215);
 
-  area = ospf_area_get (ospf, area_id, format);
+  area = ospf_area_get (ospf, area_id);
+  ospf_area_display_format_set (ospf, area, format);
 
   if (area->external_routing == OSPF_AREA_DEFAULT)
     {
@@ -1756,7 +1741,8 @@ DEFUN (ospf_area_export_list,
 
   VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
 
-  area = ospf_area_get (ospf, area_id, format);
+  area = ospf_area_get (ospf, area_id);
+  ospf_area_display_format_set (ospf, area, format);
   ospf_area_export_list_set (ospf, area, argv[3]->arg);
 
   return CMD_SUCCESS;
@@ -1807,7 +1793,8 @@ DEFUN (ospf_area_import_list,
 
   VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
 
-  area = ospf_area_get (ospf, area_id, format);
+  area = ospf_area_get (ospf, area_id);
+  ospf_area_display_format_set (ospf, area, format);
   ospf_area_import_list_set (ospf, area, argv[3]->arg);
 
   return CMD_SUCCESS;
@@ -1863,7 +1850,8 @@ DEFUN (ospf_area_filter_list,
 
   VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
 
-  area = ospf_area_get (ospf, area_id, format);
+  area = ospf_area_get (ospf, area_id);
+  ospf_area_display_format_set (ospf, area, format);
   plist = prefix_list_lookup (AFI_IP, argv[idx_word]->arg);
   if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0)
     {
@@ -1963,7 +1951,8 @@ DEFUN (ospf_area_authentication_message_digest,
 
   VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
 
-  area = ospf_area_get (ospf, area_id, format);
+  area = ospf_area_get (ospf, area_id);
+  ospf_area_display_format_set (ospf, area, format);
   area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
 
   return CMD_SUCCESS;
@@ -1985,7 +1974,8 @@ DEFUN (ospf_area_authentication,
 
   VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
 
-  area = ospf_area_get (ospf, area_id, format);
+  area = ospf_area_get (ospf, area_id);
+  ospf_area_display_format_set (ospf, area, format);
   area->auth_type = OSPF_AUTH_SIMPLE;
 
   return CMD_SUCCESS;
@@ -2215,7 +2205,7 @@ DEFUN (ospf_timers_min_ls_interval,
   int idx_number = 4;
   unsigned int interval;
 
-  if (argc != 1)
+  if (argc < 5)
     {
       vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
       return CMD_WARNING;
@@ -2257,7 +2247,7 @@ DEFUN (ospf_timers_min_ls_arrival,
   int idx_number = 3;
   unsigned int arrival;
 
-  if (argc != 1)
+  if (argc < 4)
     {
       vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
       return CMD_WARNING;
@@ -2302,7 +2292,7 @@ DEFUN (ospf_timers_throttle_spf,
   int idx_number_3 = 5;
   unsigned int delay, hold, max;
   
-  if (argc != 3)
+  if (argc < 6)
     {
       vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
       return CMD_WARNING;
@@ -2345,7 +2335,7 @@ DEFUN (ospf_timers_lsa,
   int idx_number = 3;
   unsigned int minarrival;
 
-  if (argc != 1)
+  if (argc < 4)
     {
       vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
       return CMD_WARNING;
@@ -3545,7 +3535,6 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc,
   if (use_json)
     {
       json = json_object_new_object();
-      json_interface_sub = json_object_new_object();
     }
 
   if (ospf->instance)
@@ -3564,7 +3553,11 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc,
         {
           if (ospf_oi_count(ifp))
             {
+              if (use_json)
+                json_interface_sub = json_object_new_object();
+
               show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json);
+
              if (use_json)
                json_object_object_add (json, ifp->name, json_interface_sub);
             }
@@ -3582,7 +3575,11 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc,
         }
       else
         {
+          if (use_json)
+            json_interface_sub = json_object_new_object();
+
           show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json);
+
           if (use_json)
             json_object_object_add(json, ifp->name, json_interface_sub);
         }
@@ -6333,7 +6330,7 @@ DEFUN (no_ip_ospf_dead_interval,
 {
   VTY_DECLVAR_CONTEXT(interface, ifp);
   int idx_ipv4 = argc - 1;
-  struct in_addr addr;
+  struct in_addr addr = { .s_addr = 0L};
   int ret;
   struct ospf_if_params *params;
   struct ospf_interface *oi;
@@ -6465,6 +6462,7 @@ DEFUN (no_ip_ospf_hello_interval,
   int idx = 0;
   struct in_addr addr;
   struct ospf_if_params *params;
+
   params = IF_DEF_PARAMS (ifp);
 
   if (argv_find (argv, argc, "A.B.C.D", &idx))
@@ -7003,7 +7001,7 @@ DEFUN (ip_ospf_area,
       return CMD_SUCCESS;
     }
 
-  ret = ospf_str2area_id (areaid, &area_id, &format);
+  ret = str2area_id (areaid, &area_id, &format);
   if (ret < 0)
     {
       vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s",
@@ -7160,7 +7158,7 @@ DEFUN (no_ospf_redistribute_source,
 
 DEFUN (ospf_redistribute_instance_source,
        ospf_redistribute_instance_source_cmd,
-       "redistribute <ospf|table> (1-65535) {<metric (0-16777214)|metric-type (1-2)|route-map WORD>}",
+       "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
        REDIST_STR
        "Open Shortest Path First\n"
        "Non-main Kernel Routing Table\n"
@@ -7231,7 +7229,7 @@ DEFUN (ospf_redistribute_instance_source,
 
 DEFUN (no_ospf_redistribute_instance_source,
        no_ospf_redistribute_instance_source_cmd,
-       "no redistribute <ospf|table> (1-65535) {<metric (0-16777214)|metric-type (1-2)|route-map WORD>}",
+       "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
        NO_STR
        REDIST_STR
        "Open Shortest Path First\n"
@@ -8165,19 +8163,6 @@ const char *ospf_shortcut_mode_str[] =
   "disable"
 };
 
-
-static void
-area_id2str (char *buf, int length, struct ospf_area *area)
-{
-  memset (buf, 0, length);
-
-  if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
-    strncpy (buf, inet_ntoa (area->area_id), length);
-  else
-    sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
-}
-
-
 const char *ospf_int_type_str[] = 
 {
   "unknown",           /* should never be used. */
@@ -8424,7 +8409,7 @@ config_write_network_area (struct vty *vty, struct ospf *ospf)
        memset (buf, 0, INET_ADDRSTRLEN);
 
        /* Create Area ID string by specified Area ID format. */
-       if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
+       if (n->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD)
          strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
        else
          sprintf ((char *) buf, "%lu", 
@@ -8451,7 +8436,8 @@ config_write_ospf_area (struct vty *vty, struct ospf *ospf)
     {
       struct route_node *rn1;
 
-      area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
+      area_id2str ((char *) buf, INET_ADDRSTRLEN, &area->area_id,
+                   area->area_id_fmt);
 
       if (area->auth_type != OSPF_AUTH_NULL)
        {
@@ -8570,7 +8556,7 @@ config_write_virtual_link (struct vty *vty, struct ospf *ospf)
 {
   struct listnode *node;
   struct ospf_vl_data *vl_data;
-  u_char buf[INET_ADDRSTRLEN];
+  char buf[INET_ADDRSTRLEN];
 
   /* Virtual-Link print */
   for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
@@ -8582,12 +8568,8 @@ config_write_virtual_link (struct vty *vty, struct ospf *ospf)
       if (vl_data != NULL)
        {
          memset (buf, 0, INET_ADDRSTRLEN);
-         
-         if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
-           strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
-         else
-           sprintf ((char *) buf, "%lu", 
-                    (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
+
+          area_id2str (buf, sizeof(buf), &vl_data->vl_area_id, vl_data->vl_area_id_fmt);
          oi = vl_data->vl_oi;
 
          /* timers */
@@ -9107,7 +9089,7 @@ DEFUN (clear_ip_ospf_interface,
     }
   else /* Interface name is specified. */
     {
-      if ((ifp = if_lookup_by_name (argv[idx_ifname]->text, VRF_DEFAULT)) == NULL)
+      if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg, VRF_DEFAULT)) == NULL)
         vty_out (vty, "No such interface name%s", VTY_NEWLINE);
       else
         ospf_interface_clear(ifp);