summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2017-05-22 17:45:29 +0200
committerGitHub <noreply@github.com>2017-05-22 17:45:29 +0200
commitdb64fac494eb51ae481293b6edc9cae1dec88a10 (patch)
tree80237878b231372118562f8068b2d7269bc201c3
parent1aba7c0944eb798384a27d0a5211c27bd94ffe70 (diff)
parent79c3f4f491bae3b4bbd4ef63edc8125e24175f3e (diff)
Merge pull request #582 from qlyoung/ospf6-df-areaid
ospf6d: remember format for ospf6 area id
-rw-r--r--ospf6d/ospf6_area.c41
-rw-r--r--ospf6d/ospf6_area.h4
-rw-r--r--ospf6d/ospf6_top.c2
3 files changed, 30 insertions, 17 deletions
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c
index 9f02a414de..bf98f704da 100644
--- a/ospf6d/ospf6_area.c
+++ b/ospf6d/ospf6_area.c
@@ -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,
diff --git a/ospf6d/ospf6_area.h b/ospf6d/ospf6_area.h
index 8e2368b166..86c68af17b 100644
--- a/ospf6d/ospf6_area.h
+++ b/ospf6d/ospf6_area.h
@@ -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 *);
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index bafe86bff4..dfda06678c 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -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 ?? */