Skip to content

Commit

Permalink
Make NetmaskFilterKind optional in allowlist XML parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Lopez Fernandez <[email protected]>
  • Loading branch information
juanlofer-eprosima committed Mar 14, 2024
1 parent ea8d638 commit eb9943c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
4 changes: 2 additions & 2 deletions resources/xsd/fastRTPS_profiles.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -984,13 +984,13 @@
<!--allowlist:
├ interface [0~*]
| ╠ att. name [string] REQ,
| ╠ att. netmask_filter [string] REQ ("OFF", "AUTO", "ON") -->
| ╠ att. netmask_filter [string] ("OFF", "AUTO", "ON") -->
<xs:complexType name="allowlistType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="interface" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="string" use="required"/>
<xs:attribute name="netmask_filter" use="required">
<xs:attribute name="netmask_filter" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="OFF"/>
Expand Down
13 changes: 3 additions & 10 deletions src/cpp/rtps/xmlparser/XMLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ XMLP_ret XMLParser::parseXMLAllowlist(
<xs:element name="interface" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="string" use="required"/>
<xs:attribute name="netmask_filter" type="netmaskFilterType" use="required"/>
<xs:attribute name="netmask_filter" type="netmaskFilterType" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
Expand All @@ -720,10 +720,8 @@ XMLP_ret XMLParser::parseXMLAllowlist(
name = p_aux0->Name();
if (strcmp(name, INTERFACE_NAME) == 0)
{
std::string iface_name;
fastdds::rtps::NetmaskFilterKind netmask_filter;

// Parse interface name (device/ip)
std::string iface_name;
auto iface_name_attr = p_aux0->FindAttribute(NAME_ATTR_NAME);
if (nullptr != iface_name_attr)
{
Expand All @@ -743,6 +741,7 @@ XMLP_ret XMLParser::parseXMLAllowlist(
}

// Parse netmask filter
fastdds::rtps::NetmaskFilterKind netmask_filter{fastdds::rtps::NetmaskFilterKind::AUTO};
auto netmask_filter_attr = p_aux0->FindAttribute(NETMASK_FILTER_ATTR_NAME);
if (nullptr != netmask_filter_attr)
{
Expand All @@ -759,12 +758,6 @@ XMLP_ret XMLParser::parseXMLAllowlist(
return XMLP_ret::XML_ERROR;
}
}
else
{
EPROSIMA_LOG_ERROR(XMLPARSER,
"Failed to parse 'allowlist' element. Required attribute 'netmask_filter' not found.");
return XMLP_ret::XML_ERROR;
}
// Add valid item to allowlist
p_transport->interface_allowlist.emplace_back(iface_name, netmask_filter);
}
Expand Down

0 comments on commit eb9943c

Please sign in to comment.