230 L3AddressResolver addressResolver;
231 cXMLElementList filterElements = config->getChildrenByTagName(
"filter");
232 for (
auto & filterElements_i : filterElements) {
233 cXMLElement *filterElement = filterElements_i;
236 const char *srcAddrAttr = filterElement->getAttribute(
"srcAddress");
237 const char *srcPrefixLengthAttr = filterElement->getAttribute(
"srcPrefixLength");
238 const char *destAddrAttr = filterElement->getAttribute(
"destAddress");
239 const char *destPrefixLengthAttr = filterElement->getAttribute(
"destPrefixLength");
240 const char *protocolAttr = filterElement->getAttribute(
"protocol");
241 const char *tosAttr = filterElement->getAttribute(
"tos");
242 const char *tosMaskAttr = filterElement->getAttribute(
"tosMask");
243 const char *srcPortAttr = filterElement->getAttribute(
"srcPort");
244 const char *srcPortMinAttr = filterElement->getAttribute(
"srcPortMin");
245 const char *srcPortMaxAttr = filterElement->getAttribute(
"srcPortMax");
246 const char *destPortAttr = filterElement->getAttribute(
"destPort");
247 const char *destPortMinAttr = filterElement->getAttribute(
"destPortMin");
248 const char *destPortMaxAttr = filterElement->getAttribute(
"destPortMax");
253 filter.srcAddr = addressResolver.resolve(srcAddrAttr);
254 if (srcPrefixLengthAttr)
255 filter.srcPrefixLength =
parseIntAttribute(srcPrefixLengthAttr,
"srcPrefixLength");
256 else if (srcAddrAttr)
257 filter.srcPrefixLength = filter.srcAddr.getType() ==
L3Address::IPv6 ? 128 : 32;
259 filter.destAddr = addressResolver.resolve(destAddrAttr);
260 if (destPrefixLengthAttr)
261 filter.destPrefixLength =
parseIntAttribute(destPrefixLengthAttr,
"destPrefixLength");
262 else if (destAddrAttr)
263 filter.destPrefixLength = filter.destAddr.getType() ==
L3Address::IPv6 ? 128 : 32;
271 filter.srcPortMin = filter.srcPortMax =
parseIntAttribute(srcPortAttr,
"srcPort");
277 filter.destPortMin = filter.destPortMax =
parseIntAttribute(destPortAttr,
"destPort");
285 catch (std::exception&
e) {
286 throw cRuntimeError(
"Error in XML <filter> element at %s: %s", filterElement->getSourceLocation(), e.what());
Definition: L3Address.h:47
void addFilter(const Filter &filter)
Definition: MultiFieldClassifier.cc:196
const char * getRequiredAttribute(const cXMLElement &node, const char *attr)
Definition: XMLUtils.cc:150
const value< double, units::C > e(1.602176487e-19)
int parseProtocol(const char *attrValue, const char *attrName)
Parses an IP protocol number.
Definition: DiffservUtil.cc:103
int parseIntAttribute(const char *attrValue, const char *attrName, bool isOptional)
Parses an integer attribute.
Definition: DiffservUtil.cc:78