iptables-test: Add insert support
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Tue, 19 Mar 2013 12:46:27 +0000 (13:46 +0100)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 25 Mar 2013 11:17:57 +0000 (13:17 +0200)
tools/iptables-test.c

index f20404b..1d964b9 100644 (file)
@@ -30,6 +30,7 @@
 
 enum iptables_command {
        IPTABLES_COMMAND_APPEND,
+       IPTABLES_COMMAND_INSERT,
        IPTABLES_COMMAND_DELETE,
        IPTABLES_COMMAND_POLICY,
        IPTABLES_COMMAND_CHAIN_INSERT,
@@ -48,12 +49,16 @@ int main(int argc, char *argv[])
        opterr = 0;
 
        while ((c = getopt_long(argc, argv,
-                               "-A:D:P:N:X:F:Lt:", NULL, NULL)) != -1) {
+                               "-A:I:D:P:N:X:F:Lt:", NULL, NULL)) != -1) {
                switch (c) {
                case 'A':
                        chain = optarg;
                        cmd = IPTABLES_COMMAND_APPEND;
                        break;
+               case 'I':
+                       chain = optarg;
+                       cmd = IPTABLES_COMMAND_INSERT;
+                       break;
                case 'D':
                        chain = optarg;
                        cmd = IPTABLES_COMMAND_DELETE;
@@ -105,6 +110,9 @@ out:
        case IPTABLES_COMMAND_APPEND:
                err = __connman_iptables_append(table, chain, rule);
                break;
+       case IPTABLES_COMMAND_INSERT:
+               err = __connman_iptables_insert(table, chain, rule);
+               break;
        case IPTABLES_COMMAND_DELETE:
                err = __connman_iptables_delete(table, chain, rule);
                break;
@@ -127,7 +135,7 @@ out:
                break;
        case IPTABLES_COMMAND_UNKNOWN:
                printf("Missing command\n");
-               printf("usage: iptables-test [-t table] {-A|-D} chain rule\n");
+               printf("usage: iptables-test [-t table] {-A|-I|-D} chain rule\n");
                printf("       iptables-test [-t table] {-N|-X|-F} chain\n");
                printf("       iptables-test [-t table] -L\n");
                printf("       iptables-test [-t table] -P chain target\n");