]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospf6d: remember format for ospf6 area id 582/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 18 May 2017 17:27:09 +0000 (17:27 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 19 May 2017 16:51:23 +0000 (16:51 +0000)
If the user enters a decimal, display a decimal.
If the user enters a dotted quad, display a dotted quad.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
ospf6d/ospf6_area.c
ospf6d/ospf6_area.h
ospf6d/ospf6_top.c

index 9f02a414def4d98ce9e34a63cdff8cbfb0f497c4..bf98f704dae2710720d2ac3e2bfd4356eaa21743 100644 (file)
@@ -204,15 +204,32 @@ ospf6_area_no_summary_unset (struct ospf6 *ospf6, struct ospf6_area *area)
     }
 }
 
-/* Make new area structure */
+/**
+ * Make new area structure.
+ *
+ * @param area_id - ospf6 area ID
+ * @param o - ospf6 instance
+ * @param df - display format for area ID
+ */
 struct ospf6_area *
-ospf6_area_create (u_int32_t area_id, struct ospf6 *o)
+ospf6_area_create (u_int32_t area_id, struct ospf6 *o, int df)
 {
   struct ospf6_area *oa;
 
   oa = XCALLOC (MTYPE_OSPF6_AREA, sizeof (struct ospf6_area));
 
-  inet_ntop (AF_INET, &area_id, oa->name, sizeof (oa->name));
+  switch (df)
+    {
+      case OSPF6_AREA_FMT_DECIMAL:
+        snprintf (oa->name, sizeof (oa->name), "%u", ntohl (area_id));
+        break;
+      case OSPF6_AREA_FMT_DOTTEDQUAD:
+        inet_ntop (AF_INET, &area_id, oa->name, sizeof (oa->name));
+        break;
+      default:
+        return NULL;
+    }
+
   oa->area_id = area_id;
   oa->if_list = list_new ();
 
@@ -311,16 +328,6 @@ ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6)
   return (struct ospf6_area *) NULL;
 }
 
-static struct ospf6_area *
-ospf6_area_get (u_int32_t area_id, struct ospf6 *o)
-{
-  struct ospf6_area *oa;
-  oa = ospf6_area_lookup (area_id, o);
-  if (oa == NULL)
-    oa = ospf6_area_create (area_id, o);
-  return oa;
-}
-
 void
 ospf6_area_enable (struct ospf6_area *oa)
 {
@@ -408,13 +415,17 @@ ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
 #define OSPF6_CMD_AREA_GET(str, oa)                        \
 {                                                          \
   char *ep;                                                \
-  u_int32_t area_id = htonl (strtol(str, &ep, 10));        \
+  u_int32_t area_id = htonl (strtoul (str, &ep, 10));      \
   if (*ep && inet_pton (AF_INET, str, &area_id) != 1)      \
     {                                                      \
       vty_out (vty, "Malformed Area-ID: %s%s", str, VNL);  \
       return CMD_SUCCESS;                                  \
     }                                                      \
-  oa = ospf6_area_get (area_id, ospf6);                    \
+  int format = !*ep ? OSPF6_AREA_FMT_DECIMAL :             \
+                      OSPF6_AREA_FMT_DOTTEDQUAD;           \
+  oa = ospf6_area_lookup (area_id, ospf6);                 \
+  if (oa == NULL)                                          \
+    oa = ospf6_area_create (area_id, ospf6, format);       \
 }
 
 DEFUN (area_range,
index 8e2368b1665b8b68522029e598703d3ef5fd1f33..86c68af17b5d74ee1141b9a715ea62fb6eec72af 100644 (file)
@@ -31,6 +31,8 @@ struct ospf6_area
   /* Area-ID */
   u_int32_t area_id;
 
+#define OSPF6_AREA_FMT_DOTTEDQUAD 1
+#define OSPF6_AREA_FMT_DECIMAL    2
   /* Area-ID string */
   char name[16];
 
@@ -115,7 +117,7 @@ struct ospf6_area
 /* prototypes */
 extern int ospf6_area_cmp (void *va, void *vb);
 
-extern struct ospf6_area *ospf6_area_create (u_int32_t, struct ospf6 *);
+extern struct ospf6_area *ospf6_area_create (u_int32_t, struct ospf6 *, int);
 extern void ospf6_area_delete (struct ospf6_area *);
 extern struct ospf6_area *ospf6_area_lookup (u_int32_t, struct ospf6 *);
 
index bafe86bff4c1a34c38522f9ef415c054a21dde79..dfda06678c6f9db51e8d3066544b489cca73ea08 100644 (file)
@@ -603,7 +603,7 @@ DEFUN (ospf6_interface_area,
   /* find/create ospf6 area */
   oa = ospf6_area_lookup (area_id, o);
   if (oa == NULL)
-    oa = ospf6_area_create (area_id, o);
+    oa = ospf6_area_create (area_id, o, OSPF6_AREA_FMT_DOTTEDQUAD);
 
   /* attach interface to area */
   listnode_add (oa->if_list, oi); /* sort ?? */