void (*delete_hook)(struct access_list *);
};
-/* Static structure for IPv4 access_list's master. */
+/* Static structure for mac access_list's master. */
static struct access_master access_master_mac = {
{NULL, NULL},
{NULL, NULL},
}
}
-/*
- * mac filter match
- * n is of type struct prefix_eth
- * p can be of type struct ethaddr
- */
-static int mac_filter_match(struct prefix *n, struct ethaddr *p)
-{
- if (!n && !p)
- return 1;
-
- if (!n || !p)
- return 0;
-
- /* check if we are matching on any mac */
- if (is_zero_mac(&(n->u.prefix_eth)))
- return 1;
-
- if (memcmp(&(n->u.prefix), p, sizeof(struct ethaddr)) == 0)
- return 1;
-
- return 0;
-}
-
/* If filter match to the prefix then return 1. */
-static int filter_match_cisco(struct filter *mfilter, struct prefix *p)
+static int filter_match_cisco(struct filter *mfilter, const struct prefix *p)
{
struct filter_cisco *filter;
struct in_addr mask;
- u_int32_t check_addr;
- u_int32_t check_mask;
+ uint32_t check_addr;
+ uint32_t check_mask;
filter = &mfilter->u.cfilter;
check_addr = p->u.prefix4.s_addr & ~filter->addr_mask.s_addr;
}
/* If filter match to the prefix then return 1. */
-static int filter_match_zebra(struct filter *mfilter, void *obj)
+static int filter_match_zebra(struct filter *mfilter, const struct prefix *p)
{
struct filter_zebra *filter = NULL;
filter = &mfilter->u.zfilter;
- if (filter->prefix.family == AF_ETHERNET) {
- struct ethaddr *p = NULL;
-
- p = (struct ethaddr *)obj;
- return mac_filter_match(&filter->prefix, p);
- }
-
- if (filter->prefix.family == AF_INET
- || filter->prefix.family == AF_INET6) {
- struct prefix *p = NULL;
-
- p = (struct prefix *)obj;
- if (filter->prefix.family == p->family) {
- if (filter->exact) {
- if (filter->prefix.prefixlen == p->prefixlen)
- return prefix_match(&filter->prefix, p);
- else
- return 0;
- } else
+ if (filter->prefix.family == p->family) {
+ if (filter->exact) {
+ if (filter->prefix.prefixlen == p->prefixlen)
return prefix_match(&filter->prefix, p);
+ else
+ return 0;
} else
- return 0;
- }
-
- return 0;
+ return prefix_match(&filter->prefix, p);
+ } else
+ return 0;
}
/* Allocate new access list structure. */
}
/* Apply access list to object (which should be struct prefix *). */
-enum filter_type access_list_apply(struct access_list *access, void *object)
+enum filter_type access_list_apply(struct access_list *access,
+ const void *object)
{
struct filter *filter;
- struct prefix *p;
-
- p = (struct prefix *)object;
+ const struct prefix *p = (const struct prefix *)object;
if (access == NULL)
return FILTER_DENY;
if (filter_match_cisco(filter, p))
return filter->type;
} else {
- if (filter_match_zebra(filter, object))
+ if (filter_match_zebra(filter, p))
return filter->type;
}
}
if (filter->exact == new->exact
&& mfilter->type == mnew->type) {
- if (new->prefix.family == AF_ETHERNET) {
- if (prefix_eth_same(
- (struct prefix_eth *)&filter
- ->prefix,
- (struct prefix_eth *)&new->prefix))
- return mfilter;
- } else {
- if (prefix_same(&filter->prefix, &new->prefix))
- return mfilter;
- }
+ if (prefix_same(&filter->prefix, &new->prefix))
+ return mfilter;
}
}
return NULL;
access->remark = NULL;
}
- if (access->head == NULL && access->tail == NULL
- && access->remark == NULL)
+ if (access->head == NULL && access->tail == NULL)
access_list_delete(access);
return CMD_SUCCESS;
DEFUN (mac_access_list,
mac_access_list_cmd,
- "mac access-list WORD <deny|permit> MAC",
+ "mac access-list WORD <deny|permit> X:X:X:X:X:X",
"Add a mac access-list\n"
"Add an access list entry\n"
"MAC zebra access-list name\n"
DEFUN (no_mac_access_list,
no_mac_access_list_cmd,
- "no mac access-list WORD <deny|permit> MAC",
+ "no mac access-list WORD <deny|permit> X:X:X:X:X:X",
NO_STR
"Remove a mac access-list\n"
"Remove an access list entry\n"
"Prefix to match. e.g. 10.0.0.0/8\n"
"Exact match of the prefixes\n")
{
- int idx;
+ int idx = 0;
int exact = 0;
int idx_word = 1;
int idx_permit_deny = 2;
"Prefix to match. e.g. 10.0.0.0/8\n"
"Exact match of the prefixes\n")
{
- int idx;
+ int idx = 0;
int exact = 0;
int idx_word = 2;
int idx_permit_deny = 3;
"IPv6 prefix\n"
"Exact match of the prefixes\n")
{
- int idx;
+ int idx = 0;
int exact = 0;
int idx_word = 2;
int idx_allow = 3;
"Prefix to match. e.g. 3ffe:506::/32\n"
"Exact match of the prefixes\n")
{
- int idx;
+ int idx = 0;
int exact = 0;
int idx_word = 3;
int idx_permit_deny = 4;
: "Standard")
: "Zebra",
(afi == AFI_IP)
- ? ("")
- : ((afi == AFI_IP6) ? ("ipv6 ")
- : ("mac ")),
+ ? ("IP")
+ : ((afi == AFI_IP6) ? ("IPv6 ")
+ : ("MAC ")),
access->name);
write = 0;
}
: "Standard")
: "Zebra",
(afi == AFI_IP)
- ? ("")
- : ((afi == AFI_IP6) ? ("ipv6 ")
- : ("mac ")),
+ ? ("IP")
+ : ((afi == AFI_IP6) ? ("IPv6 ")
+ : ("MAC ")),
access->name);
write = 0;
}
show_mac_access_list_name_cmd,
"show mac access-list WORD",
SHOW_STR
- "mac\n"
+ "mac access lists\n"
"List mac access lists\n"
- "mac zebra access-list\n"
- "mac address")
+ "mac address\n")
{
return filter_show(vty, argv[3]->arg, AFI_L2VPN);
}
inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
p->prefixlen, filter->exact ? " exact-match" : "");
else if (p->family == AF_ETHERNET) {
- if (is_zero_mac(&(p->u.prefix_eth)))
+ if (p->prefixlen == 0)
vty_out(vty, " any");
else
vty_out(vty, " %s", prefix_mac2str(&(p->u.prefix_eth),