10 static void print_help()
12 printf("ebtablesu v"PROGVERSION
" ("PROGDATE
")\n");
15 "ebtablesu open table : copy the kernel table\n"
16 "ebtablesu fopen table file : copy the table from the specified file\n"
17 "ebtablesu free table : remove the table from memory\n"
18 "ebtablesu commit table : commit the table to the kernel\n"
19 "ebtablesu fcommit table file : commit the table to the specified file\n\n"
20 "ebtablesu <ebtables options> : the ebtables specifications\n"
21 " use spaces only to separate options and commands\n"
22 "For the ebtables options, see\n# ebtables -h\nor\n# man ebtables\n"
25 int main(int argc
, char *argv
[])
27 char *arguments
, *pos
;
28 int i
, writefd
, len
= 0;
30 if (argc
> EBTD_ARGC_MAX
) {
31 fprintf(stderr
, "ebtablesd accepts at most %d arguments, %d "
32 "arguments were specified. If you need this many "
33 "arguments, recompile this tool with a higher value for"
34 " EBTD_ARGC_MAX.\n", EBTD_ARGC_MAX
- 1, argc
- 1);
36 } else if (argc
== 1) {
37 fprintf(stderr
, "At least one argument is needed.\n");
42 for (i
= 0; i
< argc
; i
++)
43 len
+= strlen(argv
[i
]);
44 /* Don't forget '\0' */
46 if (len
> EBTD_CMDLINE_MAXLN
) {
47 fprintf(stderr
, "ebtablesd has a maximum command line argument "
48 "length of %d, an argument length of %d was received. "
49 "If a smaller length is unfeasible, recompile this tool "
50 "with a higher value for EBTD_CMDLINE_MAXLN.\n",
51 EBTD_CMDLINE_MAXLN
, len
);
55 if (!strcmp(argv
[1], "-h") || !strcmp(argv
[1], "--help")) {
57 fprintf(stderr
, "%s does not accept options.\n", argv
[1]);
64 if (!(arguments
= (char *)malloc(len
))) {
65 fprintf(stderr
, "ebtablesu: out of memory.\n");
69 if ((writefd
= open(EBTD_PIPE
, O_WRONLY
, 0)) == -1) {
70 fprintf(stderr
, "Could not open the pipe, perhaps ebtablesd is "
71 "not running or you don't have write permission (try "
72 "running as root).\n");
77 for (i
= 0; i
< argc
; i
++) {
79 pos
+= strlen(argv
[i
]);
84 if (write(writefd
, arguments
, len
) == -1) {