András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 1 | /* Code to restore the iptables state, from file by ip6tables-save. |
| 2 | * Author: Andras Kis-Szabo <kisza@sch.bme.hu> |
| 3 | * |
| 4 | * based on iptables-restore |
| 5 | * Authors: |
| 6 | * Harald Welte <laforge@gnumonks.org> |
| 7 | * Rusty Russell <rusty@linuxcare.com.au> |
András Kis-Szabó | 0c4188f | 2002-08-14 11:40:41 +0000 | [diff] [blame] | 8 | * This code is distributed under the terms of GNU GPL v2 |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 9 | * |
Michael Rash | 29cdbd0 | 2004-01-05 09:41:50 +0000 | [diff] [blame] | 10 | * $Id: ip6tables-restore.c,v 1.12 2003/05/02 15:30:11 laforge Exp $ |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <getopt.h> |
| 14 | #include <sys/errno.h> |
| 15 | #include <string.h> |
| 16 | #include <stdio.h> |
| 17 | #include <stdlib.h> |
| 18 | #include "ip6tables.h" |
| 19 | #include "libiptc/libip6tc.h" |
| 20 | |
| 21 | #ifdef DEBUG |
| 22 | #define DEBUGP(x, args...) fprintf(stderr, x, ## args) |
| 23 | #else |
| 24 | #define DEBUGP(x, args...) |
| 25 | #endif |
| 26 | |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 27 | static int binary = 0, counters = 0, verbose = 0, noflush = 0; |
| 28 | |
| 29 | /* Keeping track of external matches and targets. */ |
| 30 | static struct option options[] = { |
| 31 | { "binary", 0, 0, 'b' }, |
| 32 | { "counters", 0, 0, 'c' }, |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 33 | { "verbose", 1, 0, 'v' }, |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 34 | { "help", 0, 0, 'h' }, |
| 35 | { "noflush", 0, 0, 'n'}, |
Harald Welte | 5891865 | 2001-06-16 18:25:25 +0000 | [diff] [blame] | 36 | { "modprobe", 1, 0, 'M'}, |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 37 | { 0 } |
| 38 | }; |
| 39 | |
| 40 | static void print_usage(const char *name, const char *version) __attribute__((noreturn)); |
| 41 | |
| 42 | static void print_usage(const char *name, const char *version) |
| 43 | { |
| 44 | fprintf(stderr, "Usage: %s [-b] [-c] [-v] [-h]\n" |
| 45 | " [ --binary ]\n" |
| 46 | " [ --counters ]\n" |
| 47 | " [ --verbose ]\n" |
| 48 | " [ --help ]\n" |
Harald Welte | 5891865 | 2001-06-16 18:25:25 +0000 | [diff] [blame] | 49 | " [ --noflush ]\n" |
| 50 | " [ --modprobe=<command>]\n", name); |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 51 | |
| 52 | exit(1); |
| 53 | } |
| 54 | |
Harald Welte | 5891865 | 2001-06-16 18:25:25 +0000 | [diff] [blame] | 55 | ip6tc_handle_t create_handle(const char *tablename, const char* modprobe) |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 56 | { |
| 57 | ip6tc_handle_t handle; |
| 58 | |
| 59 | handle = ip6tc_init(tablename); |
Harald Welte | 5891865 | 2001-06-16 18:25:25 +0000 | [diff] [blame] | 60 | |
| 61 | if (!handle) { |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 62 | /* try to insmod the module if iptc_init failed */ |
| 63 | ip6tables_insmod("ip6_tables", modprobe); |
| 64 | handle = ip6tc_init(tablename); |
Harald Welte | 5891865 | 2001-06-16 18:25:25 +0000 | [diff] [blame] | 65 | } |
| 66 | |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 67 | if (!handle) { |
| 68 | exit_error(PARAMETER_PROBLEM, "%s: unable to initialize" |
| 69 | "table '%s'\n", program_name, tablename); |
| 70 | exit(1); |
| 71 | } |
| 72 | return handle; |
| 73 | } |
| 74 | |
| 75 | int parse_counters(char *string, struct ip6t_counters *ctr) |
| 76 | { |
| 77 | return (sscanf(string, "[%llu:%llu]", &ctr->pcnt, &ctr->bcnt) == 2); |
| 78 | } |
| 79 | |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 80 | /* global new argv and argc */ |
| 81 | static char *newargv[255]; |
| 82 | static int newargc; |
| 83 | |
| 84 | /* function adding one argument to newargv, updating newargc |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 85 | * returns true if argument added, false otherwise */ |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 86 | static int add_argv(char *what) { |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 87 | DEBUGP("add_argv: %s\n", what); |
| 88 | if (what && ((newargc + 1) < sizeof(newargv)/sizeof(char *))) { |
| 89 | newargv[newargc] = strdup(what); |
| 90 | newargc++; |
| 91 | return 1; |
| 92 | } else |
| 93 | return 0; |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | static void free_argv(void) { |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 97 | int i; |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 98 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 99 | for (i = 0; i < newargc; i++) |
| 100 | free(newargv[i]); |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 101 | } |
| 102 | |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 103 | int main(int argc, char *argv[]) |
| 104 | { |
Martin Josefsson | 841e4ae | 2003-05-02 15:30:11 +0000 | [diff] [blame] | 105 | ip6tc_handle_t handle = NULL; |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 106 | char buffer[10240]; |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 107 | int c; |
| 108 | char curtable[IP6T_TABLE_MAXNAMELEN + 1]; |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 109 | FILE *in; |
Harald Welte | 5891865 | 2001-06-16 18:25:25 +0000 | [diff] [blame] | 110 | const char *modprobe = 0; |
Harald Welte | a8658ca | 2003-03-05 07:46:15 +0000 | [diff] [blame] | 111 | int in_table = 0; |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 112 | |
| 113 | program_name = "ip6tables-restore"; |
Harald Welte | 80fe35d | 2002-05-29 13:08:15 +0000 | [diff] [blame] | 114 | program_version = IPTABLES_VERSION; |
Harald Welte | a8658ca | 2003-03-05 07:46:15 +0000 | [diff] [blame] | 115 | line = 0; |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 116 | |
Harald Welte | 3efb6ea | 2001-08-06 18:50:21 +0000 | [diff] [blame] | 117 | #ifdef NO_SHARED_LIBS |
| 118 | init_extensions(); |
| 119 | #endif |
| 120 | |
Harald Welte | 5891865 | 2001-06-16 18:25:25 +0000 | [diff] [blame] | 121 | while ((c = getopt_long(argc, argv, "bcvhnM:", options, NULL)) != -1) { |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 122 | switch (c) { |
| 123 | case 'b': |
| 124 | binary = 1; |
| 125 | break; |
| 126 | case 'c': |
| 127 | counters = 1; |
| 128 | break; |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 129 | case 'v': |
| 130 | verbose = 1; |
| 131 | break; |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 132 | case 'h': |
| 133 | print_usage("ip6tables-restore", |
Harald Welte | 80fe35d | 2002-05-29 13:08:15 +0000 | [diff] [blame] | 134 | IPTABLES_VERSION); |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 135 | break; |
| 136 | case 'n': |
| 137 | noflush = 1; |
| 138 | break; |
Harald Welte | 5891865 | 2001-06-16 18:25:25 +0000 | [diff] [blame] | 139 | case 'M': |
| 140 | modprobe = optarg; |
| 141 | break; |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 142 | } |
| 143 | } |
| 144 | |
| 145 | if (optind == argc - 1) { |
| 146 | in = fopen(argv[optind], "r"); |
| 147 | if (!in) { |
| 148 | fprintf(stderr, "Can't open %s: %s", argv[optind], |
| 149 | strerror(errno)); |
| 150 | exit(1); |
| 151 | } |
| 152 | } |
| 153 | else if (optind < argc) { |
| 154 | fprintf(stderr, "Unknown arguments found on commandline"); |
| 155 | exit(1); |
| 156 | } |
| 157 | else in = stdin; |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 158 | |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 159 | /* Grab standard input. */ |
| 160 | while (fgets(buffer, sizeof(buffer), in)) { |
| 161 | int ret; |
| 162 | |
| 163 | line++; |
| 164 | if (buffer[0] == '\n') continue; |
| 165 | else if (buffer[0] == '#') { |
| 166 | if (verbose) fputs(buffer, stdout); |
| 167 | continue; |
Harald Welte | a8658ca | 2003-03-05 07:46:15 +0000 | [diff] [blame] | 168 | } else if ((strcmp(buffer, "COMMIT\n") == 0) && (in_table)) { |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 169 | DEBUGP("Calling commit\n"); |
| 170 | ret = ip6tc_commit(&handle); |
Harald Welte | a8658ca | 2003-03-05 07:46:15 +0000 | [diff] [blame] | 171 | in_table = 0; |
| 172 | } else if ((buffer[0] == '*') && (!in_table)) { |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 173 | /* New table */ |
| 174 | char *table; |
| 175 | |
| 176 | table = strtok(buffer+1, " \t\n"); |
| 177 | DEBUGP("line %u, table '%s'\n", line, table); |
| 178 | if (!table) { |
| 179 | exit_error(PARAMETER_PROBLEM, |
| 180 | "%s: line %u table name invalid\n", |
| 181 | program_name, line); |
| 182 | exit(1); |
| 183 | } |
| 184 | strncpy(curtable, table, IP6T_TABLE_MAXNAMELEN); |
| 185 | |
Martin Josefsson | 841e4ae | 2003-05-02 15:30:11 +0000 | [diff] [blame] | 186 | if (handle) |
| 187 | ip6tc_free(&handle); |
| 188 | |
Harald Welte | 5891865 | 2001-06-16 18:25:25 +0000 | [diff] [blame] | 189 | handle = create_handle(table, modprobe); |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 190 | if (noflush == 0) { |
| 191 | DEBUGP("Cleaning all chains of table '%s'\n", |
| 192 | table); |
| 193 | for_each_chain(flush_entries, verbose, 1, |
| 194 | &handle); |
| 195 | |
| 196 | DEBUGP("Deleting all user-defined chains " |
| 197 | "of table '%s'\n", table); |
| 198 | for_each_chain(delete_chain, verbose, 0, |
| 199 | &handle) ; |
| 200 | } |
| 201 | |
| 202 | ret = 1; |
Harald Welte | a8658ca | 2003-03-05 07:46:15 +0000 | [diff] [blame] | 203 | in_table = 1; |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 204 | |
Harald Welte | a8658ca | 2003-03-05 07:46:15 +0000 | [diff] [blame] | 205 | } else if ((buffer[0] == ':') && (in_table)) { |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 206 | /* New chain. */ |
| 207 | char *policy, *chain; |
| 208 | |
| 209 | chain = strtok(buffer+1, " \t\n"); |
| 210 | DEBUGP("line %u, chain '%s'\n", line, chain); |
| 211 | if (!chain) { |
| 212 | exit_error(PARAMETER_PROBLEM, |
| 213 | "%s: line %u chain name invalid\n", |
| 214 | program_name, line); |
| 215 | exit(1); |
| 216 | } |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 217 | |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 218 | if (!ip6tc_builtin(chain, handle)) { |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 219 | DEBUGP("Creating new chain '%s'\n", chain); |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 220 | if (!ip6tc_create_chain(chain, &handle)) |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 221 | exit_error(PARAMETER_PROBLEM, |
| 222 | "error creating chain " |
| 223 | "'%s':%s\n", chain, |
| 224 | strerror(errno)); |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 225 | } |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 226 | |
| 227 | policy = strtok(NULL, " \t\n"); |
| 228 | DEBUGP("line %u, policy '%s'\n", line, policy); |
| 229 | if (!policy) { |
| 230 | exit_error(PARAMETER_PROBLEM, |
| 231 | "%s: line %u policy invalid\n", |
| 232 | program_name, line); |
| 233 | exit(1); |
| 234 | } |
| 235 | |
| 236 | if (strcmp(policy, "-") != 0) { |
| 237 | struct ip6t_counters count; |
| 238 | |
| 239 | if (counters) { |
| 240 | char *ctrs; |
| 241 | ctrs = strtok(NULL, " \t\n"); |
| 242 | |
| 243 | parse_counters(ctrs, &count); |
| 244 | |
| 245 | } else { |
| 246 | memset(&count, 0, |
| 247 | sizeof(struct ip6t_counters)); |
| 248 | } |
| 249 | |
| 250 | DEBUGP("Setting policy of chain %s to %s\n", |
| 251 | chain, policy); |
| 252 | |
| 253 | if (!ip6tc_set_policy(chain, policy, &count, |
| 254 | &handle)) |
| 255 | exit_error(OTHER_PROBLEM, |
| 256 | "Can't set policy `%s'" |
| 257 | " on `%s' line %u: %s\n", |
| 258 | chain, policy, line, |
| 259 | ip6tc_strerror(errno)); |
| 260 | } |
| 261 | |
| 262 | ret = 1; |
| 263 | |
Harald Welte | a8658ca | 2003-03-05 07:46:15 +0000 | [diff] [blame] | 264 | } else if (in_table) { |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 265 | int a; |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 266 | char *ptr = buffer; |
| 267 | char *pcnt = NULL; |
| 268 | char *bcnt = NULL; |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 269 | char *parsestart; |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 270 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 271 | /* the parser */ |
| 272 | char *param_start, *curchar; |
| 273 | int quote_open; |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 274 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 275 | /* reset the newargv */ |
| 276 | newargc = 0; |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 277 | |
| 278 | if (buffer[0] == '[') { |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 279 | /* we have counters in our input */ |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 280 | ptr = strchr(buffer, ']'); |
| 281 | if (!ptr) |
| 282 | exit_error(PARAMETER_PROBLEM, |
| 283 | "Bad line %u: need ]\n", |
| 284 | line); |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 285 | |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 286 | pcnt = strtok(buffer+1, ":"); |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 287 | if (!pcnt) |
| 288 | exit_error(PARAMETER_PROBLEM, |
| 289 | "Bad line %u: need :\n", |
| 290 | line); |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 291 | |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 292 | bcnt = strtok(NULL, "]"); |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 293 | if (!bcnt) |
| 294 | exit_error(PARAMETER_PROBLEM, |
| 295 | "Bad line %u: need ]\n", |
| 296 | line); |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 297 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 298 | /* start command parsing after counter */ |
| 299 | parsestart = ptr + 1; |
| 300 | } else { |
| 301 | /* start command parsing at start of line */ |
| 302 | parsestart = buffer; |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 303 | } |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 304 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 305 | add_argv(argv[0]); |
| 306 | add_argv("-t"); |
| 307 | add_argv((char *) &curtable); |
| 308 | |
| 309 | if (counters && pcnt && bcnt) { |
| 310 | add_argv("--set-counters"); |
| 311 | add_argv((char *) pcnt); |
| 312 | add_argv((char *) bcnt); |
| 313 | } |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 314 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 315 | /* After fighting with strtok enough, here's now |
| 316 | * a 'real' parser. According to Rusty I'm now no |
| 317 | * longer a real hacker, but I can live with that */ |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 318 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 319 | quote_open = 0; |
| 320 | param_start = parsestart; |
| 321 | |
| 322 | for (curchar = parsestart; *curchar; curchar++) { |
| 323 | if (*curchar == '"') { |
Michael Rash | 29cdbd0 | 2004-01-05 09:41:50 +0000 | [diff] [blame] | 324 | /* quote_open cannot be true if there |
| 325 | * was no previous character. Thus, |
| 326 | * curchar-1 has to be within bounds */ |
| 327 | if (quote_open && |
| 328 | *(curchar-1) != '\\') { |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 329 | quote_open = 0; |
| 330 | *curchar = ' '; |
| 331 | } else { |
| 332 | quote_open = 1; |
| 333 | param_start++; |
| 334 | } |
| 335 | } |
| 336 | if (*curchar == ' ' |
| 337 | || *curchar == '\t' |
| 338 | || * curchar == '\n') { |
| 339 | char param_buffer[1024]; |
| 340 | int param_len = curchar-param_start; |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 341 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 342 | if (quote_open) |
| 343 | continue; |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 344 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 345 | if (!param_len) { |
| 346 | /* two spaces? */ |
| 347 | param_start++; |
| 348 | continue; |
| 349 | } |
| 350 | |
| 351 | /* end of one parameter */ |
| 352 | strncpy(param_buffer, param_start, |
| 353 | param_len); |
| 354 | *(param_buffer+param_len) = '\0'; |
Harald Welte | bb41f88 | 2001-10-21 14:11:54 +0000 | [diff] [blame] | 355 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 356 | /* check if table name specified */ |
Harald Welte | 48a6f90 | 2001-10-22 15:16:21 +0000 | [diff] [blame] | 357 | if (!strncmp(param_buffer, "-t", 3) |
| 358 | || !strncmp(param_buffer, "--table", 8)) { |
Harald Welte | bb41f88 | 2001-10-21 14:11:54 +0000 | [diff] [blame] | 359 | exit_error(PARAMETER_PROBLEM, |
| 360 | "Line %u seems to have a " |
| 361 | "-t table option.\n", line); |
| 362 | exit(1); |
| 363 | } |
| 364 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 365 | add_argv(param_buffer); |
| 366 | param_start += param_len + 1; |
| 367 | } else { |
| 368 | /* regular character, skip */ |
| 369 | } |
| 370 | } |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 371 | |
| 372 | DEBUGP("calling do_command6(%u, argv, &%s, handle):\n", |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 373 | newargc, curtable); |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 374 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 375 | for (a = 0; a < newargc; a++) |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 376 | DEBUGP("argv[%u]: %s\n", a, newargv[a]); |
| 377 | |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 378 | ret = do_command6(newargc, newargv, |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 379 | &newargv[2], &handle); |
Harald Welte | 885c6eb | 2001-10-04 08:30:46 +0000 | [diff] [blame] | 380 | |
András Kis-Szabó | 97fd91a | 2002-03-03 09:44:31 +0000 | [diff] [blame] | 381 | free_argv(); |
András Kis-Szabó | 2f52379 | 2001-02-27 09:59:48 +0000 | [diff] [blame] | 382 | } |
| 383 | if (!ret) { |
| 384 | fprintf(stderr, "%s: line %u failed\n", |
| 385 | program_name, line); |
| 386 | exit(1); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | return 0; |
| 391 | } |