diff options
author | paul <paul> | 2003-01-17 13:20:40 +0000 |
---|---|---|
committer | paul <paul> | 2003-01-17 13:20:40 +0000 |
commit | 47e64cb1fb3ba81f535654fc3bfc9d10c6726d62 (patch) | |
tree | a23914917215395ba4ef5f562146bb16f9380eca /bgpd/bgp_ecommunity.c | |
parent | 01f6e536df19cf94358db09612ba945dbf8833cc (diff) | |
download | quagga-zebra.org.20030117.tar.bz2 quagga-zebra.org.20030117.tar.xz |
Import of Zebra CVS 20020117-13:15zebra.org.20030117
Diffstat (limited to 'bgpd/bgp_ecommunity.c')
-rw-r--r-- | bgpd/bgp_ecommunity.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 2f9cc945..aa0f1176 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -158,6 +158,15 @@ ecommunity_dup (struct ecommunity *ecom) return new; } +/* Retrun string representation of communities attribute. */ +char * +ecommunity_str (struct ecommunity *ecom) +{ + if (! ecom->str) + ecom->str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_DISPLAY); + return ecom->str; +} + /* Merge two Extended Communities Attribute structure. */ struct ecommunity * ecommunity_merge (struct ecommunity *ecom1, struct ecommunity *ecom2) @@ -639,3 +648,33 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format) } return str_buf; } + +int +ecommunity_match (struct ecommunity *ecom1, struct ecommunity *ecom2) +{ + int i = 0; + int j = 0; + + if (ecom1 == NULL && ecom2 == NULL) + return 1; + + if (ecom1 == NULL || ecom2 == NULL) + return 0; + + if (ecom1->size < ecom2->size) + return 0; + + /* Every community on com2 needs to be on com1 for this to match */ + while (i < ecom1->size && j < ecom2->size) + { + if (memcmp (ecom1->val + i, ecom2->val + j, ECOMMUNITY_SIZE) == 0) + j++; + i++; + } + + if (j == ecom2->size) + return 1; + else + return 0; +} + |