blob: 1420d1d776837ea07e94674dc82bc67cada29bd6 [file] [log] [blame]
Bart De Schuymerff587202005-02-08 20:02:28 +00001/* ebt_standard
2 *
3 * Authors:
4 * Bart De Schuymer <bdschuym@pandora.be>
5 *
6 * April, 2002
7 */
8
Bart De Schuymer1abc55d2002-06-01 19:23:47 +00009#include <stdio.h>
Bart De Schuymer41e8a192002-06-23 08:03:12 +000010#include <stdlib.h>
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000011#include <getopt.h>
12#include "../include/ebtables_u.h"
13
14static struct option opts[] =
15{
16 {0}
17};
18
19static void print_help()
20{
Bart De Schuymer9cfd6542002-08-13 16:08:08 +000021 printf("Standard targets: DROP, ACCEPT, RETURN or CONTINUE;\n"
22 "The target can also be a user defined chain.\n");
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000023}
24
25static void init(struct ebt_entry_target *t)
26{
27 ((struct ebt_standard_target *)t)->verdict = EBT_CONTINUE;
28}
29
30static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry,
31 unsigned int *flags, struct ebt_entry_target **target)
32{
33 return 0;
34}
35
36static void final_check(const struct ebt_u_entry *entry,
Bart De Schuymer7b9aaeb2002-06-23 20:38:34 +000037 const struct ebt_entry_target *target, const char *name,
Bart De Schuymerc9b52932002-08-24 13:26:34 +000038 unsigned int hookmask, unsigned int time)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000039{
40}
41
42static void print(const struct ebt_u_entry *entry,
43 const struct ebt_entry_target *target)
44{
Bart De Schuymer41e8a192002-06-23 08:03:12 +000045 int verdict = ((struct ebt_standard_target *)target)->verdict;
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000046
Bart De Schuymer57a40c72002-06-23 17:11:42 +000047 if (verdict >= 0) {
48 struct ebt_u_entries *entries;
49
Bart De Schuymer8339ff12004-01-14 20:05:27 +000050 entries = ebt_nr_to_chain(entry->replace,
51 verdict + NF_BR_NUMHOOKS);
Bart De Schuymer57a40c72002-06-23 17:11:42 +000052 printf("%s", entries->name);
53 return;
54 }
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000055 if (verdict == EBT_CONTINUE)
Bart De Schuymer41e8a192002-06-23 08:03:12 +000056 printf("CONTINUE ");
57 else if (verdict == EBT_ACCEPT)
58 printf("ACCEPT ");
59 else if (verdict == EBT_DROP)
60 printf("DROP ");
61 else if (verdict == EBT_RETURN)
62 printf("RETURN ");
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000063 else
Bart De Schuymer64182a32004-01-21 20:39:54 +000064 ebt_print_bug("Bad standard target");
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000065}
66
67static int compare(const struct ebt_entry_target *t1,
68 const struct ebt_entry_target *t2)
69{
70 return ((struct ebt_standard_target *)t1)->verdict ==
71 ((struct ebt_standard_target *)t2)->verdict;
72}
73
74static struct ebt_u_target standard =
75{
Bart De Schuymer7cf1cca2003-08-30 16:20:19 +000076 .name = EBT_STANDARD_TARGET,
77 .size = sizeof(struct ebt_standard_target) -
78 sizeof(struct ebt_entry_target),
79 .help = print_help,
80 .init = init,
81 .parse = parse,
82 .final_check = final_check,
83 .print = print,
84 .compare = compare,
85 .extra_ops = opts,
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000086};
87
Bart De Schuymer64182a32004-01-21 20:39:54 +000088void _init(void)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000089{
Bart De Schuymer8339ff12004-01-14 20:05:27 +000090 ebt_register_target(&standard);
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000091}