Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ospf6: decimal area format in interface command #6700

Merged
merged 2 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions doc/user/ospf6d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ OSPF6 router

Set router's Router-ID.

.. index:: interface IFNAME area AREA
.. clicmd:: interface IFNAME area AREA
.. index:: interface IFNAME area (0-4294967295)
.. clicmd:: interface IFNAME area (0-4294967295)

.. index:: interface IFNAME area A.B.C.D
.. clicmd:: interface IFNAME area A.B.C.D

Bind interface to specified area, and start sending OSPF packets. `area` can
be specified as 0.
Expand Down
16 changes: 0 additions & 16 deletions ospf6d/ospf6_area.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,22 +379,6 @@ void ospf6_area_show(struct vty *vty, struct ospf6_area *oa)
vty_out(vty, "SPF has not been run\n");
}


#define OSPF6_CMD_AREA_GET(str, oa) \
{ \
char *ep; \
uint32_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\n", str); \
return CMD_SUCCESS; \
} \
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,
area_range_cmd,
"area <A.B.C.D|(0-4294967295)> range X:X::X:X/M [<advertise|not-advertise|cost (0-16777215)>]",
Expand Down
15 changes: 15 additions & 0 deletions ospf6d/ospf6_area.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ struct ospf6_area {
#define IS_AREA_TRANSIT(oa) (CHECK_FLAG ((oa)->flag, OSPF6_AREA_TRANSIT))
#define IS_AREA_STUB(oa) (CHECK_FLAG ((oa)->flag, OSPF6_AREA_STUB))

#define OSPF6_CMD_AREA_GET(str, oa) \
{ \
char *ep; \
uint32_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\n", str); \
return CMD_SUCCESS; \
} \
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); \
}

/* prototypes */
extern int ospf6_area_cmp(void *va, void *vb);

Expand Down
23 changes: 7 additions & 16 deletions ospf6d/ospf6_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,12 @@ DEFUN (no_ospf6_distance_source,

DEFUN (ospf6_interface_area,
ospf6_interface_area_cmd,
"interface IFNAME area A.B.C.D",
"interface IFNAME area <A.B.C.D|(0-4294967295)>",
"Enable routing on an IPv6 interface\n"
IFNAME_STR
"Specify the OSPF6 area ID\n"
"OSPF6 area ID in IPv4 address notation\n"
"OSPF6 area ID in decimal notation\n"
)
{
VTY_DECLVAR_CONTEXT(ospf6, o);
Expand All @@ -657,7 +658,6 @@ DEFUN (ospf6_interface_area,
struct ospf6_area *oa;
struct ospf6_interface *oi;
struct interface *ifp;
uint32_t area_id;

/* find/create ospf6 interface */
ifp = if_get_by_name(argv[idx_ifname]->arg, VRF_DEFAULT);
Expand All @@ -671,15 +671,7 @@ DEFUN (ospf6_interface_area,
}

/* parse Area-ID */
if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) {
vty_out(vty, "Invalid Area-ID: %s\n", argv[idx_ipv4]->arg);
return CMD_SUCCESS;
}

/* find/create ospf6 area */
oa = ospf6_area_lookup(area_id, o);
if (oa == NULL)
oa = ospf6_area_create(area_id, o, OSPF6_AREA_FMT_DOTTEDQUAD);
OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, oa);

/* attach interface to area */
listnode_add(oa->if_list, oi); /* sort ?? */
Expand All @@ -703,12 +695,13 @@ DEFUN (ospf6_interface_area,

DEFUN (no_ospf6_interface_area,
no_ospf6_interface_area_cmd,
"no interface IFNAME area A.B.C.D",
"no interface IFNAME area <A.B.C.D|(0-4294967295)>",
NO_STR
"Disable routing on an IPv6 interface\n"
IFNAME_STR
"Specify the OSPF6 area ID\n"
"OSPF6 area ID in IPv4 address notation\n"
"OSPF6 area ID in decimal notation\n"
)
{
int idx_ifname = 2;
Expand All @@ -731,10 +724,8 @@ DEFUN (no_ospf6_interface_area,
}

/* parse Area-ID */
if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) {
vty_out(vty, "Invalid Area-ID: %s\n", argv[idx_ipv4]->arg);
return CMD_SUCCESS;
}
if (inet_pton(AF_INET, argv[idx_ipv4]->arg, &area_id) != 1)
area_id = htonl(strtoul(argv[idx_ipv4]->arg, NULL, 10));

/* Verify Area */
if (oi->area == NULL) {
Expand Down