11 #include <arpa/inet.h> 17 BgpFilterRule::~BgpFilterRule() {}
28 this->match_type = type;
29 this->prefix = prefix;
41 this->match_type = type;
42 this->prefix = prefix;
54 this->match_type = type;
59 for (
const std::shared_ptr<BgpPathAttrib> &attr : attribs) {
60 if (attr->type_code != AS_PATH)
continue;
64 if (as_seg.
type != AS_SEQUENCE)
continue;
69 for (uint32_t asn : as_seg.
value) {
70 if (asn == this->asn && match_type ==
M_HAS_ASN)
return op;
91 this->match_type = type;
92 uint8_t *community_ptr = (uint8_t *) &community;
93 putValue<uint16_t>(&community_ptr, htons(asn));
94 putValue<uint16_t>(&community_ptr, htons(keyword));
106 this->match_type = type;
107 this->community = htonl(community);
111 for (
const std::shared_ptr<BgpPathAttrib> &attr : attribs) {
112 if (attr->type_code != COMMUNITY)
continue;
115 for (uint32_t community_val : community.
communites) {
116 if (match_type ==
M_HAS_COMMUNITY && community_val == this->community)
return op;
141 this->default_op = default_op;
152 if (rules.size() == 0)
return default_op;
154 auto rule = rules.end();
158 BgpFilterOP this_op = (*rule)->apply(prefix, attribs);
159 if (this_op !=
NOP)
return this_op;
160 }
while (rule != rules.begin());
IPv6 Route/Prefix related utilities.
std::vector< uint32_t > value
The segment value.
BgpFilterOP
The filter operation.
BgpFilterRuleRouteMatchType
Matching type of IP prefix rule.
BgpFilterOP apply(const Prefix &prefix, const std::vector< std::shared_ptr< BgpPathAttrib >> &attribs)
Apply the rules set on a route.
BgpFilterRules()
Construct a new BgpFilterRules rules set.
BgpFilterRuleCommunityMatchType
Matching type of COMMUNITY rule.
std::vector< BgpAsPathSegment > as_paths
The AS Path segments.
BgpFilterRuleRoute6(BgpFilterOP op, BgpFilterRuleRouteMatchType type, const Prefix6 &prefix)
Construct a new IPv6 route filtering object.
uint8_t type
Segment type.
BgpFilterRuleRoute4(BgpFilterOP op, BgpFilterRuleRouteMatchType type, const Prefix4 &prefix)
Construct a new IPv4 route filtering object.
IPv4 Route/Prefix related utilities.
Buffer operation helpers.
Route/Prefix related utilities.
An AS_PATH or AS4_PATH segment.
BgpFilterRuleAsPathMatchType
Matching type of AS_PATH rule.
BgpFilterOP apply(const Prefix &prefix, const std::vector< std::shared_ptr< BgpPathAttrib >> &attribs)
Apply the rule on a route.
BgpFilterRuleAsPath(BgpFilterOP op, BgpFilterRuleAsPathMatchType type, uint32_t asn)
Construct a new AS_PATH filtering object.