blob: 95e00a5cdaf991f11f891a92e74aa40c4dd9f32a [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 Schuymer7b9aaeb2002-06-23 20:38:34 +000029 const struct ebt_entry_target *target, const char *name,
30 unsigned int hook_mask, 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 Schuymer1abc55d2002-06-01 19:23:47 +000035static void print(const struct ebt_u_entry *entry,
36 const struct ebt_entry_target *target)
37{
Bart De Schuymer41e8a192002-06-23 08:03:12 +000038 int verdict = ((struct ebt_standard_target *)target)->verdict;
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000039
Bart De Schuymer57a40c72002-06-23 17:11:42 +000040 if (verdict >= 0) {
41 struct ebt_u_entries *entries;
42
43 entries = nr_to_chain(verdict + NF_BR_NUMHOOKS);
44 printf("%s", entries->name);
45 return;
46 }
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000047 if (verdict == EBT_CONTINUE)
Bart De Schuymer41e8a192002-06-23 08:03:12 +000048 printf("CONTINUE ");
49 else if (verdict == EBT_ACCEPT)
50 printf("ACCEPT ");
51 else if (verdict == EBT_DROP)
52 printf("DROP ");
53 else if (verdict == EBT_RETURN)
54 printf("RETURN ");
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000055 else
Bart De Schuymer41e8a192002-06-23 08:03:12 +000056 print_error("BUG: Bad standard target"); // this is a bug
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000057}
58
59static int compare(const struct ebt_entry_target *t1,
60 const struct ebt_entry_target *t2)
61{
62 return ((struct ebt_standard_target *)t1)->verdict ==
63 ((struct ebt_standard_target *)t2)->verdict;
64}
65
66static struct ebt_u_target standard =
67{
68 EBT_STANDARD_TARGET,
69 sizeof(struct ebt_standard_target) - sizeof(struct ebt_entry_target),
70 print_help,
71 init,
72 parse,
73 final_check,
74 print,
75 compare,
76 opts
77};
78
79static void _init(void) __attribute__ ((constructor));
80static void _init(void)
81{
82 register_target(&standard);
83}