Repository :
http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master
---------------------------------------------------------------
commit 99b9fe166d48506fe07d7887ba7a8c6f81efa124
Author: Thomas Woerner <twoerner(a)redhat.com>
Date: Mon Jan 12 14:12:05 2015 +0100
Add missing files for 3bfa285000b4bf0c571e815cb3f619aeb99acd65
---------------------------------------------------------------
libfirewall/src/fw_args.c | 108 +++++++++++++++
libfirewall/src/{fw_port.h => fw_args.h} | 33 ++---
libfirewall/src/fw_passthrough.c | 125 +++++++++++++++++
libfirewall/src/fw_passthrough.h | 51 +++++++
libfirewall/src/fw_port.o | Bin 0 -> 18320 bytes
libfirewall/src/fw_rule.c | 221 ++++++++++++++++++++++++++++++
libfirewall/src/fw_rule.h | 57 ++++++++
libfirewall/src/fw_simplerule.c | 125 +++++++++++++++++
libfirewall/src/fw_simplerule.h | 51 +++++++
9 files changed, 753 insertions(+), 18 deletions(-)
diff --git a/libfirewall/src/fw_args.c b/libfirewall/src/fw_args.c
new file mode 100644
index 0000000..21096c2
--- /dev/null
+++ b/libfirewall/src/fw_args.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * Authors:
+ * Thomas Woerner <twoerner(a)redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <
http://www.gnu.org/licenses/>.
+ */
+
+#include "fw_args.h"
+
+G_DEFINE_TYPE(FWArgs, fw_args, G_TYPE_OBJECT);
+
+#define FW_ARGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), FW_ARGS_TYPE,
FWArgsPrivate))
+
+typedef struct {
+ GList *args; /* list of strings */
+} FWArgsPrivate;
+
+FWArgs *
+fw_args_new()
+{
+ return g_object_new(FW_ARGS_TYPE, NULL);
+}
+
+static void
+fw_args_init(FWArgs *obj)
+{
+ FWArgsPrivate *priv = FW_ARGS_GET_PRIVATE(obj);
+
+ /* init vars */
+ priv->args = NULL;
+}
+
+static void
+fw_args_finalize(GObject *obj)
+{
+ FWArgsPrivate *priv = FW_ARGS_GET_PRIVATE(obj);
+
+ if (priv->args != NULL) {
+ g_free(priv->args);
+ }
+
+ G_OBJECT_CLASS(fw_args_parent_class)->finalize(obj);
+}
+
+static void
+fw_args_class_init(FWArgsClass *fw_args_class)
+{
+ GObjectClass *obj_class = G_OBJECT_CLASS(fw_args_class);
+
+ obj_class->finalize = fw_args_finalize;
+
+ g_type_class_add_private(obj_class, sizeof(FWArgsPrivate));
+}
+
+/* methods */
+
+/**
+ * fw_args_getArgs:
+ * @obj: (type FWArgs*): a FWArgs instance
+ *
+ * Returns: (transfer none) (allow-none) (element-type gchar*)
+ */
+GList *
+fw_args_getArgs(FWArgs *obj)
+{
+ FWArgsPrivate *priv = FW_ARGS_GET_PRIVATE(obj);
+
+ return priv->args;
+}
+
+/**
+ * fw_args_setArgs:
+ * @obj: (type FWArgs*): a FWArgs instance
+ * @args: (type GList*) (element-type gchar*): list of strings
+ */
+void
+fw_args_setArgs(FWArgs *obj, GList *args)
+{
+ FWArgsPrivate *priv = FW_ARGS_GET_PRIVATE(obj);
+
+ priv->args = args;
+}
+
+/**
+ * fw_args_addArg:
+ * @obj: (type FWArgs*): a FWArgs instance
+ * @arg: (gchar*): strings arg
+ */
+void
+fw_args_addArg(FWArgs *obj, gchar *arg)
+{
+ FWArgsPrivate *priv = FW_ARGS_GET_PRIVATE(obj);
+
+ priv->args = g_list_append(priv->args, arg);
+}
diff --git a/libfirewall/src/fw_port.h b/libfirewall/src/fw_args.h
similarity index 52%
copy from libfirewall/src/fw_port.h
copy to libfirewall/src/fw_args.h
index 21ef804..4dc8df5 100644
--- a/libfirewall/src/fw_port.h
+++ b/libfirewall/src/fw_args.h
@@ -18,35 +18,32 @@
* along with this program. If not, see <
http://www.gnu.org/licenses/>.
*/
-#ifndef __FW_PORT_H__
-#define __FW_PORT_H__
+#ifndef __FW_ARGS_H__
+#define __FW_ARGS_H__
#include <glib.h>
#include <glib-object.h>
#include "firewall.h"
-#define FW_PORT_TYPE (fw_port_get_type())
-#define FW_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), FW_PORT_TYPE,
FWPort))
-#define FW_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), FW_PORT_TYPE,
FWPortClass))
-#define FW_IS_PORT(klass) (G_TYPE_CHECK_INSTANCE_CLASS((klass), FW_PORT_TYPE,
FWPortClass))
-#define FW_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FW_PORT_TYPE,
FWPortClass))
+#define FW_ARGS_TYPE (fw_args_get_type())
+#define FW_ARGS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), FW_ARGS_TYPE,
FWArgs))
+#define FW_ARGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), FW_ARGS_TYPE,
FWArgsClass))
+#define FW_IS_ARGS(klass) (G_TYPE_CHECK_INSTANCE_CLASS((klass), FW_ARGS_TYPE,
FWArgsClass))
+#define FW_ARGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FW_ARGS_TYPE,
FWArgsClass))
typedef struct {
GObject parent;
-} FWPort;
+} FWArgs;
typedef struct {
GObjectClass parent;
-} FWPortClass;
+} FWArgsClass;
-GType fw_port_get_type(void);
-FWPort *fw_port_new(void);
+GType fw_args_get_type(void);
+FWArgs *fw_args_new(void);
-gchar *fw_port_getPort(FWPort *obj);
-gchar *fw_port_getProtocol(FWPort *obj);
-gchar *fw_port_getStr(FWPort *obj);
+GList *fw_args_getArgs(FWArgs *obj);
+void fw_args_setArgs(FWArgs *obj, GList *args);
+void fw_args_addArg(FWArgs *obj, gchar *arg);
-void fw_port_setPort(FWPort *obj, gchar *port);
-void fw_port_setProtocol(FWPort *obj, gchar *protocol);
-
-#endif /* __FW_PORT_H__ */
+#endif /* __FW_ARGS_H__ */
diff --git a/libfirewall/src/fw_passthrough.c b/libfirewall/src/fw_passthrough.c
new file mode 100644
index 0000000..c4a3139
--- /dev/null
+++ b/libfirewall/src/fw_passthrough.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * Authors:
+ * Thomas Woerner <twoerner(a)redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <
http://www.gnu.org/licenses/>.
+ */
+
+#include "fw_passthrough.h"
+
+G_DEFINE_TYPE(FWPassthrough, fw_passthrough, G_TYPE_OBJECT);
+
+#define FW_PASSTHROUGH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o),
FW_PASSTHROUGH_TYPE, FWPassthroughPrivate))
+
+typedef struct {
+ gchar *ipv; /* string */
+ GList *args; /* list of strings */
+} FWPassthroughPrivate;
+
+FWPassthrough *
+fw_passthrough_new()
+{
+ return g_object_new(FW_PASSTHROUGH_TYPE, NULL);
+}
+
+static void
+fw_passthrough_init(FWPassthrough *obj)
+{
+ FWPassthroughPrivate *passthrough = FW_PASSTHROUGH_GET_PRIVATE(obj);
+
+ /* init vars */
+ passthrough->ipv = NULL;
+ passthrough->args = NULL;
+}
+
+static void
+fw_passthrough_finalize(GObject *obj)
+{
+ FWPassthroughPrivate *passthrough = FW_PASSTHROUGH_GET_PRIVATE(obj);
+
+ if (passthrough->args != NULL) {
+ g_list_foreach(passthrough->args, (GFunc) g_free, NULL);
+ g_free(passthrough->args);
+ }
+
+ G_OBJECT_CLASS(fw_passthrough_parent_class)->finalize(obj);
+}
+
+static void
+fw_passthrough_class_init(FWPassthroughClass *fw_passthrough_class)
+{
+ GObjectClass *obj_class = G_OBJECT_CLASS(fw_passthrough_class);
+
+ obj_class->finalize = fw_passthrough_finalize;
+
+ g_type_class_add_private(obj_class, sizeof(FWPassthroughPrivate));
+}
+
+/* methods */
+
+/**
+ * fw_passthrough_getIpv:
+ * @obj: (type FWPassthrough*): a FWPassthrough instance
+ *
+ * Returns: (type gchar*)
+ */
+gchar *
+fw_passthrough_getIpv(FWPassthrough *obj)
+{
+ FWPassthroughPrivate *passthrough = FW_PASSTHROUGH_GET_PRIVATE(obj);
+
+ return passthrough->ipv;
+}
+
+/**
+ * fw_passthrough_getArgs:
+ * @obj: (type FWPassthrough*): a FWPassthrough instance
+ *
+ * Returns: (transfer none) (allow-none) (type GList*) (element-type gchar*)
+ */
+GList *
+fw_passthrough_getArgs(FWPassthrough *obj)
+{
+ FWPassthroughPrivate *passthrough = FW_PASSTHROUGH_GET_PRIVATE(obj);
+
+ return passthrough->args;
+}
+
+/**
+ * fw_passthrough_setIpv:
+ * @obj: (type FWPassthrough*): a FWPassthrough instance
+ * @ipv: (type gchar*)
+ */
+void
+fw_passthrough_setIpv(FWPassthrough *obj, gchar *ipv)
+{
+ FWPassthroughPrivate *passthrough = FW_PASSTHROUGH_GET_PRIVATE(obj);
+
+ passthrough->ipv = ipv;
+}
+
+/**
+ * fw_passthrough_setArgs:
+ * @obj: (type FWPassthrough*): a FWPassthrough instance
+ * @args: (type GList*) (element-type gchar*)
+ */
+void
+fw_passthrough_setArgs(FWPassthrough *obj, GList *args)
+{
+ FWPassthroughPrivate *passthrough = FW_PASSTHROUGH_GET_PRIVATE(obj);
+
+ passthrough->args = args;
+}
diff --git a/libfirewall/src/fw_passthrough.h b/libfirewall/src/fw_passthrough.h
new file mode 100644
index 0000000..9827924
--- /dev/null
+++ b/libfirewall/src/fw_passthrough.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * Authors:
+ * Thomas Woerner <twoerner(a)redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <
http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __FW_PASSTHROUGH_H__
+#define __FW_PASSTHROUGH_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "firewall.h"
+
+#define FW_PASSTHROUGH_TYPE (fw_passthrough_get_type())
+#define FW_PASSTHROUGH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),
FW_PASSTHROUGH_TYPE, FWPassthrough))
+#define FW_PASSTHROUGH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),
FW_PASSTHROUGH_TYPE, FWPassthroughClass))
+#define FW_IS_PASSTHROUGH(klass) (G_TYPE_CHECK_INSTANCE_CLASS((klass),
FW_PASSTHROUGH_TYPE, FWPassthroughClass))
+#define FW_PASSTHROUGH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),
FW_PASSTHROUGH_TYPE, FWPassthroughClass))
+
+typedef struct {
+ GObject parent;
+} FWPassthrough;
+
+typedef struct {
+ GObjectClass parent;
+} FWPassthroughClass;
+
+GType fw_passthrough_get_type(void);
+FWPassthrough *fw_passthrough_new(void);
+
+gchar *fw_passthrough_getIpv(FWPassthrough *obj);
+GList *fw_passthrough_getArgs(FWPassthrough *obj);
+
+void fw_passthrough_setIpv(FWPassthrough *obj, char *ipv);
+void fw_passthrough_setArgs(FWPassthrough *obj, GList *args);
+
+#endif /* __FW_PASSTHROUGH_H__ */
diff --git a/libfirewall/src/fw_port.o b/libfirewall/src/fw_port.o
new file mode 100644
index 0000000..b708654
Binary files /dev/null and b/libfirewall/src/fw_port.o differ
diff --git a/libfirewall/src/fw_rule.c b/libfirewall/src/fw_rule.c
new file mode 100644
index 0000000..a5b6ce4
--- /dev/null
+++ b/libfirewall/src/fw_rule.c
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * Authors:
+ * Thomas Woerner <twoerner(a)redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <
http://www.gnu.org/licenses/>.
+ */
+
+#include "fw_rule.h"
+
+G_DEFINE_TYPE(FWRule, fw_rule, G_TYPE_OBJECT);
+
+#define FW_RULE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), FW_RULE_TYPE,
FWRulePrivate))
+
+typedef struct {
+ gchar *ipv; /* string */
+ gchar *table; /* string */
+ gchar *chain; /* string */
+ gint32 priority; /* int32 */
+ GList *args; /* list of strings */
+} FWRulePrivate;
+
+FWRule *
+fw_rule_new()
+{
+ return g_object_new(FW_RULE_TYPE, NULL);
+}
+
+static void
+fw_rule_init(FWRule *obj)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ /* init vars */
+ rule->ipv = NULL;
+ rule->table = NULL;
+ rule->chain = NULL;
+ rule->priority = 0;
+ rule->args = NULL;
+}
+
+static void
+fw_rule_finalize(GObject *obj)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ if (rule->ipv != NULL) {
+ g_free(rule->ipv);
+ }
+ if (rule->table != NULL) {
+ g_free(rule->table);
+ }
+ if (rule->chain != NULL) {
+ g_free(rule->chain);
+ }
+ if (rule->args != NULL) {
+ g_list_foreach(rule->args, (GFunc) g_free, NULL);
+ g_free(rule->args);
+ }
+
+ G_OBJECT_CLASS(fw_rule_parent_class)->finalize(obj);
+}
+
+static void
+fw_rule_class_init(FWRuleClass *fw_rule_class)
+{
+ GObjectClass *obj_class = G_OBJECT_CLASS(fw_rule_class);
+
+ obj_class->finalize = fw_rule_finalize;
+
+ g_type_class_add_private(obj_class, sizeof(FWRulePrivate));
+}
+
+/* methods */
+
+/**
+ * fw_rule_getIpv:
+ * @obj: (type FWRule*): a FWRule instance
+ *
+ * Returns: (type gchar*)
+ */
+gchar *
+fw_rule_getIpv(FWRule *obj)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ return rule->ipv;
+}
+
+/**
+ * fw_rule_getTable:
+ * @obj: (type FWRule*): a FWRule instance
+ *
+ * Returns: (type gchar*)
+ */
+gchar *
+fw_rule_getTable(FWRule *obj)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ return rule->table;
+}
+
+/**
+ * fw_rule_getChain:
+ * @obj: (type FWRule*): a FWRule instance
+ *
+ * Returns: (type gchar*)
+ */
+gchar *
+fw_rule_getChain(FWRule *obj)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ return rule->chain;
+}
+
+/**
+ * fw_rule_getPriority:
+ * @obj: (type FWRule*): a FWRule instance
+ *
+ * Returns: (type gint32)
+ */
+gint32
+fw_rule_getPriority(FWRule *obj)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ return rule->priority;
+}
+
+/**
+ * fw_rule_getArgs:
+ * @obj: (type FWRule*): a FWRule instance
+ *
+ * Returns: (transfer none) (allow-none) (type GList*) (element-type gchar*)
+ */
+GList *
+fw_rule_getArgs(FWRule *obj)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ return rule->args;
+}
+
+/**
+ * fw_rule_setIpv:
+ * @obj: (type FWRule*): a FWRule instance
+ * @ipv: (type gchar*)
+ */
+void
+fw_rule_setIpv(FWRule *obj, gchar *ipv)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ rule->ipv = ipv;
+}
+
+/**
+ * fw_rule_setTable:
+ * @obj: (type FWRule*): a FWRule instance
+ * @table: (type gchar*)
+ */
+void
+fw_rule_setTable(FWRule *obj, gchar *table)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ rule->table = table;
+}
+
+/**
+ * fw_rule_setChain:
+ * @obj: (type FWRule*): a FWRule instance
+ * @chain: (type gchar*)
+ */
+void
+fw_rule_setChain(FWRule *obj, gchar *chain)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ rule->chain = chain;
+}
+
+/**
+ * fw_rule_setPriority:
+ * @obj: (type FWRule*): a FWRule instance
+ * @priority: (type gint32)
+ */
+void
+fw_rule_setPriority(FWRule *obj, gint32 priority)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ rule->priority = priority;
+}
+
+/**
+ * fw_rule_setArgs:
+ * @obj: (type FWRule*): a FWRule instance
+ * @args: (type GList*) (element-type gchar*)
+ */
+void
+fw_rule_setArgs(FWRule *obj, GList *args)
+{
+ FWRulePrivate *rule = FW_RULE_GET_PRIVATE(obj);
+
+ rule->args = args;
+}
diff --git a/libfirewall/src/fw_rule.h b/libfirewall/src/fw_rule.h
new file mode 100644
index 0000000..0f3b72f
--- /dev/null
+++ b/libfirewall/src/fw_rule.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * Authors:
+ * Thomas Woerner <twoerner(a)redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <
http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __FW_RULE_H__
+#define __FW_RULE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "firewall.h"
+
+#define FW_RULE_TYPE (fw_rule_get_type())
+#define FW_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), FW_RULE_TYPE,
FWRule))
+#define FW_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), FW_RULE_TYPE,
FWRuleClass))
+#define FW_IS_RULE(klass) (G_TYPE_CHECK_INSTANCE_CLASS((klass), FW_RULE_TYPE,
FWRuleClass))
+#define FW_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FW_RULE_TYPE,
FWRuleClass))
+
+typedef struct {
+ GObject parent;
+} FWRule;
+
+typedef struct {
+ GObjectClass parent;
+} FWRuleClass;
+
+GType fw_rule_get_type(void);
+FWRule *fw_rule_new(void);
+
+gchar *fw_rule_getIpv(FWRule *obj);
+gchar *fw_rule_getTable(FWRule *obj);
+gchar *fw_rule_getChain(FWRule *obj);
+gint32 fw_rule_getPriority(FWRule *obj);
+GList *fw_rule_getArgs(FWRule *obj);
+
+void fw_rule_setIpv(FWRule *obj, char *ipv);
+void fw_rule_setTable(FWRule *obj, char *table);
+void fw_rule_setChain(FWRule *obj, char *chain);
+void fw_rule_setPriority(FWRule *obj, gint32 priority);
+void fw_rule_setArgs(FWRule *obj, GList *args);
+
+#endif /* __FW_RULE_H__ */
diff --git a/libfirewall/src/fw_simplerule.c b/libfirewall/src/fw_simplerule.c
new file mode 100644
index 0000000..35369b4
--- /dev/null
+++ b/libfirewall/src/fw_simplerule.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * Authors:
+ * Thomas Woerner <twoerner(a)redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <
http://www.gnu.org/licenses/>.
+ */
+
+#include "fw_simplerule.h"
+
+G_DEFINE_TYPE(FWSimplerule, fw_simplerule, G_TYPE_OBJECT);
+
+#define FW_SIMPLERULE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o),
FW_SIMPLERULE_TYPE, FWSimplerulePrivate))
+
+typedef struct {
+ gint32 priority; /* int32 */
+ GList *args; /* list of strings */
+} FWSimplerulePrivate;
+
+FWSimplerule *
+fw_simplerule_new()
+{
+ return g_object_new(FW_SIMPLERULE_TYPE, NULL);
+}
+
+static void
+fw_simplerule_init(FWSimplerule *obj)
+{
+ FWSimplerulePrivate *rule = FW_SIMPLERULE_GET_PRIVATE(obj);
+
+ /* init vars */
+ rule->priority = 0;
+ rule->args = NULL;
+}
+
+static void
+fw_simplerule_finalize(GObject *obj)
+{
+ FWSimplerulePrivate *rule = FW_SIMPLERULE_GET_PRIVATE(obj);
+
+ if (rule->args != NULL) {
+ g_list_foreach(rule->args, (GFunc) g_free, NULL);
+ g_free(rule->args);
+ }
+
+ G_OBJECT_CLASS(fw_simplerule_parent_class)->finalize(obj);
+}
+
+static void
+fw_simplerule_class_init(FWSimpleruleClass *fw_simplerule_class)
+{
+ GObjectClass *obj_class = G_OBJECT_CLASS(fw_simplerule_class);
+
+ obj_class->finalize = fw_simplerule_finalize;
+
+ g_type_class_add_private(obj_class, sizeof(FWSimplerulePrivate));
+}
+
+/* methods */
+
+/**
+ * fw_simplerule_getPriority:
+ * @obj: (type FWSimplerule*): a FWSimplerule instance
+ *
+ * Returns: (type gint32)
+ */
+gint32
+fw_simplerule_getPriority(FWSimplerule *obj)
+{
+ FWSimplerulePrivate *rule = FW_SIMPLERULE_GET_PRIVATE(obj);
+
+ return rule->priority;
+}
+
+/**
+ * fw_simplerule_getArgs:
+ * @obj: (type FWSimplerule*): a FWSimplerule instance
+ *
+ * Returns: (transfer none) (allow-none) (type GList*) (element-type gchar*)
+ */
+GList *
+fw_simplerule_getArgs(FWSimplerule *obj)
+{
+ FWSimplerulePrivate *rule = FW_SIMPLERULE_GET_PRIVATE(obj);
+
+ return rule->args;
+}
+
+/**
+ * fw_simplerule_setPriority:
+ * @obj: (type FWSimplerule*): a FWSimplerule instance
+ * @priority: (type gint32)
+ */
+void
+fw_simplerule_setPriority(FWSimplerule *obj, gint32 priority)
+{
+ FWSimplerulePrivate *rule = FW_SIMPLERULE_GET_PRIVATE(obj);
+
+ rule->priority = priority;
+}
+
+/**
+ * fw_simplerule_setArgs:
+ * @obj: (type FWSimplerule*): a FWSimplerule instance
+ * @args: (type GList*) (element-type gchar*)
+ */
+void
+fw_simplerule_setArgs(FWSimplerule *obj, GList *args)
+{
+ FWSimplerulePrivate *rule = FW_SIMPLERULE_GET_PRIVATE(obj);
+
+ rule->args = args;
+}
diff --git a/libfirewall/src/fw_simplerule.h b/libfirewall/src/fw_simplerule.h
new file mode 100644
index 0000000..d77718a
--- /dev/null
+++ b/libfirewall/src/fw_simplerule.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * Authors:
+ * Thomas Woerner <twoerner(a)redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <
http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __FW_SIMPLERULE_H__
+#define __FW_SIMPLERULE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "firewall.h"
+
+#define FW_SIMPLERULE_TYPE (fw_simplerule_get_type())
+#define FW_SIMPLERULE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),
FW_SIMPLERULE_TYPE, FWSimplerule))
+#define FW_SIMPLERULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),
FW_SIMPLERULE_TYPE, FWSimpleruleClass))
+#define FW_IS_SIMPLERULE(klass) (G_TYPE_CHECK_INSTANCE_CLASS((klass),
FW_SIMPLERULE_TYPE, FWSimpleruleClass))
+#define FW_SIMPLERULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),
FW_SIMPLERULE_TYPE, FWSimpleruleClass))
+
+typedef struct {
+ GObject parent;
+} FWSimplerule;
+
+typedef struct {
+ GObjectClass parent;
+} FWSimpleruleClass;
+
+GType fw_simplerule_get_type(void);
+FWSimplerule *fw_simplerule_new(void);
+
+gint32 fw_simplerule_getPriority(FWSimplerule *obj);
+GList *fw_simplerule_getArgs(FWSimplerule *obj);
+
+void fw_simplerule_setPriority(FWSimplerule *obj, gint32 priority);
+void fw_simplerule_setArgs(FWSimplerule *obj, GList *args);
+
+#endif /* __FW_SIMPLERULE_H__ */