Merge pull request #763 from dslicenc/ospfd-network-statement

lib/ospf/eigrp: enable ospf and eigrp to use more specific network st…
This commit is contained in:
Jafar Al-Gharaibeh 2017-06-29 09:35:36 -05:00 committed by GitHub
commit 9e810aba4e
4 changed files with 28 additions and 2 deletions

View File

@ -262,7 +262,7 @@ static int
eigrp_network_match_iface(const struct connected *co, const struct prefix *net)
{
/* new approach: more elegant and conceptually clean */
return prefix_match(net, CONNECTED_PREFIX (co));
return prefix_match_network_statement(net, CONNECTED_PREFIX (co));
}
static void

View File

@ -292,6 +292,31 @@ prefix_match (const struct prefix *n, const struct prefix *p)
return 1;
}
/* If n includes p then return 1 else return 0. Prefix mask is not considered */
int
prefix_match_network_statement (const struct prefix *n, const struct prefix *p)
{
int offset;
int shift;
const u_char *np, *pp;
/* Set both prefix's head pointer. */
np = (const u_char *)&n->u.prefix;
pp = (const u_char *)&p->u.prefix;
offset = n->prefixlen / PNBBY;
shift = n->prefixlen % PNBBY;
if (shift)
if (maskbit[shift] & (np[offset] ^ pp[offset]))
return 0;
while (offset--)
if (np[offset] != pp[offset])
return 0;
return 1;
}
/* Copy prefix from src to dest. */
void
prefix_copy (struct prefix *dest, const struct prefix *src)

View File

@ -279,6 +279,7 @@ extern int str2prefix (const char *, struct prefix *);
extern const char *prefix2str (union prefixconstptr, char *, int);
extern int prefix_match (const struct prefix *, const struct prefix *);
extern int prefix_match_network_statement (const struct prefix *, const struct prefix *);
extern int prefix_same (const struct prefix *, const struct prefix *);
extern int prefix_cmp (const struct prefix *, const struct prefix *);
extern int prefix_common_bits (const struct prefix *, const struct prefix *);

View File

@ -1081,7 +1081,7 @@ static int
ospf_network_match_iface(const struct connected *co, const struct prefix *net)
{
/* new approach: more elegant and conceptually clean */
return prefix_match(net, CONNECTED_PREFIX(co));
return prefix_match_network_statement(net, CONNECTED_PREFIX(co));
}
static void