iptables: Add extensions options parsing for target
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Thu, 27 Oct 2011 07:26:37 +0000 (10:26 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 28 Oct 2011 19:34:28 +0000 (21:34 +0200)
src/iptables.c

index 417c937..0acc139 100644 (file)
@@ -50,6 +50,8 @@ static const char *hooknames[] = {
 #define LABEL_QUEUE   "QUEUE"
 #define LABEL_RETURN  "RETURN"
 
+#define XT_OPTION_OFFSET_SCALE 256
+
 /* fn returns 0 to continue iteration */
 #define _XT_ENTRY_ITERATE_CONTINUE(type, entries, size, n, fn, args...) \
 ({                                                             \
@@ -1541,14 +1543,13 @@ static int iptables_command(int argc, char *argv[])
                        goto out;
 
                default:
-                       if (xt_t == NULL || xt_t->parse == NULL ||
-                           !xt_t->parse(c - xt_t->option_offset, argv, invert,
-                                       &xt_t->tflags, NULL, &xt_t->t)) {
-                               if (xt_m == NULL || xt_m->parse == NULL)
-                                       break;
-
-                               xt_m->parse(c - xt_m->option_offset, argv,
-                                       invert, &xt_m->mflags, NULL, &xt_m->m);
+                       if (xt_t != NULL && (xt_t->x6_parse != NULL ||
+                                               xt_t->parse != NULL) &&
+                                       (c >= (int) xt_t->option_offset &&
+                                       c < (int) xt_t->option_offset +
+                                       XT_OPTION_OFFSET_SCALE)) {
+                               xtables_option_tpcall(c, argv,
+                                                       invert, xt_t, NULL);
                        }
 
                        break;