blob: cd34b5611054d60d39b5875c4ec1a3dcc8fe9096 [file] [log] [blame]
Bart De Schuymer1abc55d2002-06-01 19:23:47 +00001#include <stdio.h>
Bart De Schuymer41e8a192002-06-23 08:03:12 +00002#include <stdlib.h>
Bart De Schuymer1abc55d2002-06-01 19:23:47 +00003#include <getopt.h>
4#include "../include/ebtables_u.h"
5
6static struct option opts[] =
7{
8 {0}
9};
10
11static void print_help()
12{
Bart De Schuymer9cfd6542002-08-13 16:08:08 +000013 printf("Standard targets: DROP, ACCEPT, RETURN or CONTINUE;\n"
14 "The target can also be a user defined chain.\n");
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000015}
16
17static void init(struct ebt_entry_target *t)
18{
19 ((struct ebt_standard_target *)t)->verdict = EBT_CONTINUE;
20}
21
22static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry,
23 unsigned int *flags, struct ebt_entry_target **target)
24{
25 return 0;
26}
27
28static void final_check(const struct ebt_u_entry *entry,
Bart De Schuymer7b9aaeb2002-06-23 20:38:34 +000029 const struct ebt_entry_target *target, const char *name,
Bart De Schuymerc9b52932002-08-24 13:26:34 +000030 unsigned int hookmask, unsigned int time)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000031{
32}
33
Bart De Schuymer57a40c72002-06-23 17:11:42 +000034struct ebt_u_entries *nr_to_chain(int nr);
Bart De Schuymer9cfd6542002-08-13 16:08:08 +000035
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000036static void print(const struct ebt_u_entry *entry,
37 const struct ebt_entry_target *target)
38{
Bart De Schuymer41e8a192002-06-23 08:03:12 +000039 int verdict = ((struct ebt_standard_target *)target)->verdict;
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000040
Bart De Schuymer57a40c72002-06-23 17:11:42 +000041 if (verdict >= 0) {
42 struct ebt_u_entries *entries;
43
44 entries = nr_to_chain(verdict + NF_BR_NUMHOOKS);
45 printf("%s", entries->name);
46 return;
47 }
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000048 if (verdict == EBT_CONTINUE)
Bart De Schuymer41e8a192002-06-23 08:03:12 +000049 printf("CONTINUE ");
50 else if (verdict == EBT_ACCEPT)
51 printf("ACCEPT ");
52 else if (verdict == EBT_DROP)
53 printf("DROP ");
54 else if (verdict == EBT_RETURN)
55 printf("RETURN ");
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000056 else
Bart De Schuymer9cfd6542002-08-13 16:08:08 +000057 print_bug("Bad standard target");
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000058}
59
60static int compare(const struct ebt_entry_target *t1,
61 const struct ebt_entry_target *t2)
62{
63 return ((struct ebt_standard_target *)t1)->verdict ==
64 ((struct ebt_standard_target *)t2)->verdict;
65}
66
67static struct ebt_u_target standard =
68{
69 EBT_STANDARD_TARGET,
70 sizeof(struct ebt_standard_target) - sizeof(struct ebt_entry_target),
71 print_help,
72 init,
73 parse,
74 final_check,
75 print,
76 compare,
77 opts
78};
79
80static void _init(void) __attribute__ ((constructor));
81static void _init(void)
82{
83 register_target(&standard);
84}