diff options
| author | Daniel Walton <dwalton@cumulusnetworks.com> | 2017-06-30 17:52:56 +0000 |
|---|---|---|
| committer | Daniel Walton <dwalton@cumulusnetworks.com> | 2017-06-30 17:52:56 +0000 |
| commit | 1161690b93b48fbd07f4ee25c1261574db8d71c5 (patch) | |
| tree | 7ffbe5c3b333b1fe0b8a3f042d8b1af602d48019 /lib/prefix.c | |
| parent | ab782c96f881b1fdd59f52ba972cd82b5eeadc66 (diff) | |
| parent | 5fca4e3635c2778e8349bce0eaf944c26913d321 (diff) | |
Merge branch 'master' of https://github.com/dwalton76/frr into bgpd-ipv4-plus-label-misc3
Conflicts:
bgpd/bgp_route.c
Diffstat (limited to 'lib/prefix.c')
| -rw-r--r-- | lib/prefix.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/prefix.c b/lib/prefix.c index 9c228cf954..4131f37fbd 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -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) |
