blob: 726a1ab6b8da1d58ee59a9e517f2a34e891ab6b7 [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 <sys/socket.h>
Bart De Schuymer1abc55d2002-06-01 19:23:47 +00004#include <getopt.h>
5#include "../include/ebtables_u.h"
6
7static struct option opts[] =
8{
9 {0}
10};
11
12static void print_help()
13{
14 printf("Standard targets: DROP, ACCEPT and CONTINUE\n");
15}
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 Schuymer41e8a192002-06-23 08:03:12 +000029 const struct ebt_entry_target *target, const char *name, unsigned int hook_mask)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000030{
31}
32
Bart De Schuymer57a40c72002-06-23 17:11:42 +000033struct ebt_u_entries *nr_to_chain(int nr);
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000034static void print(const struct ebt_u_entry *entry,
35 const struct ebt_entry_target *target)
36{
Bart De Schuymer41e8a192002-06-23 08:03:12 +000037 int verdict = ((struct ebt_standard_target *)target)->verdict;
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000038
Bart De Schuymer57a40c72002-06-23 17:11:42 +000039 if (verdict >= 0) {
40 struct ebt_u_entries *entries;
41
42 entries = nr_to_chain(verdict + NF_BR_NUMHOOKS);
43 printf("%s", entries->name);
44 return;
45 }
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000046 if (verdict == EBT_CONTINUE)
Bart De Schuymer41e8a192002-06-23 08:03:12 +000047 printf("CONTINUE ");
48 else if (verdict == EBT_ACCEPT)
49 printf("ACCEPT ");
50 else if (verdict == EBT_DROP)
51 printf("DROP ");
52 else if (verdict == EBT_RETURN)
53 printf("RETURN ");
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000054 else
Bart De Schuymer41e8a192002-06-23 08:03:12 +000055 print_error("BUG: Bad standard target"); // this is a bug
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000056}
57
58static int compare(const struct ebt_entry_target *t1,
59 const struct ebt_entry_target *t2)
60{
61 return ((struct ebt_standard_target *)t1)->verdict ==
62 ((struct ebt_standard_target *)t2)->verdict;
63}
64
65static struct ebt_u_target standard =
66{
67 EBT_STANDARD_TARGET,
68 sizeof(struct ebt_standard_target) - sizeof(struct ebt_entry_target),
69 print_help,
70 init,
71 parse,
72 final_check,
73 print,
74 compare,
75 opts
76};
77
78static void _init(void) __attribute__ ((constructor));
79static void _init(void)
80{
81 register_target(&standard);
82}