Repository :
http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master
---------------------------------------------------------------
commit b2deb11b8d4330498c4e4c991e4a258b39ffe6c6
Author: Daniel Kopecek <dkopecek(a)redhat.com>
Date: Wed Aug 20 14:36:00 2014 +0200
Added support for loading ICMP types
---------------------------------------------------------------
firewalld.cpp | 17 +++++++++++++++++
firewalld.hpp | 14 ++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/firewalld.cpp b/firewalld.cpp
index 9ee6257..0f40c2b 100644
--- a/firewalld.cpp
+++ b/firewalld.cpp
@@ -162,6 +162,7 @@ namespace firewalld
for(auto const& path : _definition_dirs) {
loadServiceDefinitions(path + "/services/");
loadZoneDefinitions(path + "/zones/");
+ loadICMPTypeDefinitions(path + "/icmptypes/");
}
}
@@ -210,6 +211,14 @@ namespace firewalld
return;
}
+ void FirewallD::loadICMPTypeDefinitions(const String& directory)
+ {
+ LOG(TRACE) << "Loading ICMP type definitions from " <<
directory;
+ loadFiles(directory,
std::regex(".*\\.xml"/*"[a-zA-Z0-9]+\\.xml"*/),
+ &FirewallD::loadICMPTypeDefinition, this);
+ return;
+ }
+
void FirewallD::loadServiceDefinition(const String& filepath)
{
LOG(TRACE) << "Loading Service definition from " << filepath;
@@ -228,6 +237,14 @@ namespace firewalld
return;
}
+ void FirewallD::loadICMPTypeDefinition(const String& filepath)
+ {
+ LOG(TRACE) << "Loading ICMP type definition from " <<
filepath;
+ UString icmptype = filenameFromPath(filepath);
+ _defined_icmptypes[icmptype] = true;
+ return;
+ }
+
void FirewallD::dbus_method_handle(const ustring& name, const DBusParameters&
parameters, DBusResultBuilder& result)
{
LOG(TRACE) << "DBus method call: method=" << name;
diff --git a/firewalld.hpp b/firewalld.hpp
index ada40cf..b702ae4 100644
--- a/firewalld.hpp
+++ b/firewalld.hpp
@@ -68,6 +68,14 @@ namespace firewalld
void loadZoneDefinitions(const String& directory);
/**
+ * Load ICMP type definitions from a directory.
+ * This functions looks for .xml files with ICMP type definitions
+ * inside the given directory. Only files with .xml extension
+ * are processed. Subdirectories aren't descended into.
+ */
+ void loadICMPTypeDefinitions(const String& directory);
+
+ /**
* Load a Service object from a file.
* This function read the contents of the given file
* and tries to parse it as a service definition.
@@ -82,6 +90,11 @@ namespace firewalld
void loadZoneDefinition(const String& filepath);
/**
+ * Load an ICMP type from a file.
+ */
+ void loadICMPTypeDefinition(const String& filepath);
+
+ /**
* Process a name-value pair from the configuration file.
*/
void processConfigurationNVPair(const String& name, const String& value,
size_t line_num);
@@ -116,6 +129,7 @@ namespace firewalld
// Defined services
UStringKeyMap<Service*> _defined_services;
UStringKeyMap<Zone*> _defined_zones;
+ UStringKeyMap<bool> _defined_icmptypes;
// Config _config;
bool _panic_mode;