All of lore.kernel.org
 help / color / mirror / Atom feed
* RFC: introduce xtables global param struct
@ 2009-02-07 19:28 jamal
  2009-02-11 15:13 ` Jan Engelhardt
  0 siblings, 1 reply; 6+ messages in thread
From: jamal @ 2009-02-07 19:28 UTC (permalink / raw)
  To: kaber, Jan Engelhardt; +Cc: Pablo Neira Ayuso, netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 490 bytes --]


I would like to introduce this new struct so as to pass 
localize the globals used and help in symbol renames. 

xtables_set_params() is intended to free xtables from depending
(as it does right now) on existence of such externally definitions
(from iptables/iptables6 etc).
 
Ive included a sample user - xtables_free_opts() to show
how i plan to use it.

Let me know what you think before i proceed since i am going
to be using this approach as a basis for other changes.

cheers,
jamal

[-- Attachment #2: rfc-p2 --]
[-- Type: text/x-patch, Size: 1668 bytes --]

diff --git a/include/xtables.h.in b/include/xtables.h.in
index 9e45c8b..d91d902 100644
--- a/include/xtables.h.in
+++ b/include/xtables.h.in
@@ -27,6 +27,15 @@
 
 struct in_addr;
 
+struct xtables_globals
+{
+	unsigned int option_offset;
+	char *program_version;
+	char *program_name;
+	struct xtables_afinfo *afinfo;
+	struct option *opts;
+};
+
 /* Include file for additions: new matches and targets. */
 struct xtables_match
 {
@@ -165,6 +174,8 @@ extern void *xtables_malloc(size_t);
 extern int xtables_insmod(const char *, const char *, bool);
 extern int xtables_load_ko(const char *, bool);
 
+extern void xtables_free_opts(int reset_offset,  struct option *original_opts);
+
 extern struct xtables_match *xtables_find_match(const char *name,
 	enum xtables_tryload, struct xtables_rule_match **match);
 extern struct xtables_target *xtables_find_target(const char *name,
diff --git a/xtables.c b/xtables.c
index 849dc7d..b053a48 100644
--- a/xtables.c
+++ b/xtables.c
@@ -53,6 +53,29 @@ const char *xtables_modprobe_program;
 struct xtables_match *xtables_matches;
 struct xtables_target *xtables_targets;
 
+struct xtables_globals *xt_params;
+int xtables_set_params(struct xtables_globals *xtp)
+{
+	if (!xtp) {
+		fprintf(stderr, "%s: Illegal global params\n",__func__);
+		return -1;
+	}
+
+	xt_params = xtp;
+	return 0;
+}
+
+void xtables_free_opts(int reset_offset, struct option *original_opts)
+{
+	if (xt_params->opts != original_opts) {
+		if (original_opts) 
+			free(xt_params->opts);
+		xt_params->opts = original_opts;
+		if (reset_offset)
+			xt_params->option_offset = 0;
+	}
+}
+
 /**
  * xtables_*alloc - wrappers that exit on failure
  */

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: RFC: introduce xtables global param struct
  2009-02-07 19:28 RFC: introduce xtables global param struct jamal
@ 2009-02-11 15:13 ` Jan Engelhardt
  2009-02-11 17:03   ` jamal
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Engelhardt @ 2009-02-11 15:13 UTC (permalink / raw)
  To: jamal; +Cc: kaber, Pablo Neira Ayuso, netfilter-devel


On Saturday 2009-02-07 20:28, jamal wrote:
>
>I would like to introduce this new struct so as to pass 
>localize the globals used and help in symbol renames. 

Please post patch inline. I otherwise need to save them
and reinsert them into alpine..

>xtables_set_params() is intended to free xtables from depending
>(as it does right now) on existence of such externally definitions
>(from iptables/iptables6 etc).
> 
>Ive included a sample user - xtables_free_opts() to show
>how i plan to use it.
>
>Let me know what you think before i proceed since i am going
>to be using this approach as a basis for other changes.
>
>cheers,
>jamal
>

>+struct xtables_globals
>+{
>+	unsigned int option_offset;
>+	char *program_version;
>+	char *program_name;
>+	struct xtables_afinfo *afinfo;
>+	struct option *opts;
>+};

These should be const, esp. program_version and program_name.
I added myself a patch now.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFC: introduce xtables global param struct
  2009-02-11 15:13 ` Jan Engelhardt
@ 2009-02-11 17:03   ` jamal
  2009-02-11 17:17     ` Jan Engelhardt
  0 siblings, 1 reply; 6+ messages in thread
From: jamal @ 2009-02-11 17:03 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: kaber, Pablo Neira Ayuso, netfilter-devel

On Wed, 2009-02-11 at 16:13 +0100, Jan Engelhardt wrote:
> On Saturday 2009-02-07 20:28, jamal wrote:

> Please post patch inline. I otherwise need to save them
> and reinsert them into alpine..

I have problems with my client  with insertion of whitespaces if 
i do that. I will send the next one inlined and see if Patrick 
complains when applying.

> >+struct xtables_globals
> >+{
> >+	unsigned int option_offset;
> >+	char *program_version;
> >+	char *program_name;
> >+	struct xtables_afinfo *afinfo;
> >+	struct option *opts;
> >+};
> 
> These should be const, esp. program_version and program_name.
> I added myself a patch now.

Ok, so you took care of this?

cheers,
jamal


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFC: introduce xtables global param struct
  2009-02-11 17:03   ` jamal
@ 2009-02-11 17:17     ` Jan Engelhardt
  2009-02-12 14:52       ` jamal
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Engelhardt @ 2009-02-11 17:17 UTC (permalink / raw)
  To: jamal; +Cc: kaber, Pablo Neira Ayuso, netfilter-devel


On Wednesday 2009-02-11 18:03, jamal wrote:
>
>> >+struct xtables_globals
>> >+{
>> >+	unsigned int option_offset;
>> >+	char *program_version;
>> >+	char *program_name;
>> >+	struct xtables_afinfo *afinfo;
>> >+	struct option *opts;
>> >+};
>> 
>> These should be const, esp. program_version and program_name.
>> I added myself a patch now.
>
>Ok, so you took care of this?
>
About the const - yes. (Since the patch itself was already applied.)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFC: introduce xtables global param struct
  2009-02-11 17:17     ` Jan Engelhardt
@ 2009-02-12 14:52       ` jamal
  2009-02-12 15:04         ` Jan Engelhardt
  0 siblings, 1 reply; 6+ messages in thread
From: jamal @ 2009-02-12 14:52 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: kaber, Pablo Neira Ayuso, netfilter-devel

On Wed, 2009-02-11 at 18:17 +0100, Jan Engelhardt wrote:

> About the const - yes. (Since the patch itself was already applied.)

Ok, This hasnt propagated yet. My two other patches depend on this.
So once Patrick syncs with you, I will submit on top later today.

cheers,
jamal


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFC: introduce xtables global param struct
  2009-02-12 14:52       ` jamal
@ 2009-02-12 15:04         ` Jan Engelhardt
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Engelhardt @ 2009-02-12 15:04 UTC (permalink / raw)
  To: jamal; +Cc: kaber, Pablo Neira Ayuso, netfilter-devel


On Thursday 2009-02-12 15:52, jamal wrote:
>On Wed, 2009-02-11 at 18:17 +0100, Jan Engelhardt wrote:
>
>> About the const - yes. (Since the patch itself was already applied.)
>
>Ok, This hasnt propagated yet. My two other patches depend on this.
>So once Patrick syncs with you, I will submit on top later today.

This has already - 41f03ba382dfd26e7db939fd02447058b1c56f7b.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-02-12 15:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-07 19:28 RFC: introduce xtables global param struct jamal
2009-02-11 15:13 ` Jan Engelhardt
2009-02-11 17:03   ` jamal
2009-02-11 17:17     ` Jan Engelhardt
2009-02-12 14:52       ` jamal
2009-02-12 15:04         ` Jan Engelhardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.