1/* ebt_standard
2 *
3 * Authors:
4 * Bart De Schuymer <bdschuym@pandora.be>
5 *
6 * April, 2002
7 */
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <getopt.h>
12#include "../include/ebtables_u.h"
13
14static struct option opts[] =
15{
16	{0}
17};
18
19static void print_help()
20{
21	printf("Standard targets: DROP, ACCEPT, RETURN or CONTINUE;\n"
22	       "The target can also be a user defined chain.\n");
23}
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,
37   const struct ebt_entry_target *target, const char *name,
38   unsigned int hookmask, unsigned int time)
39{
40}
41
42static void print(const struct ebt_u_entry *entry,
43   const struct ebt_entry_target *target)
44{
45	int verdict = ((struct ebt_standard_target *)target)->verdict;
46
47	if (verdict >= 0) {
48		struct ebt_u_entries *entries;
49
50		entries = entry->replace->chains[verdict + NF_BR_NUMHOOKS];
51		printf("%s", entries->name);
52		return;
53	}
54	if (verdict == EBT_CONTINUE)
55		printf("CONTINUE ");
56	else if (verdict == EBT_ACCEPT)
57		printf("ACCEPT ");
58	else if (verdict == EBT_DROP)
59		printf("DROP ");
60	else if (verdict == EBT_RETURN)
61		printf("RETURN ");
62	else
63		ebt_print_bug("Bad standard target");
64}
65
66static int compare(const struct ebt_entry_target *t1,
67   const struct ebt_entry_target *t2)
68{
69	return ((struct ebt_standard_target *)t1)->verdict ==
70	   ((struct ebt_standard_target *)t2)->verdict;
71}
72
73static struct ebt_u_target standard =
74{
75	.name		= "standard",
76	.size		= sizeof(struct ebt_standard_target) -
77			  sizeof(struct ebt_entry_target),
78	.help		= print_help,
79	.init		= init,
80	.parse		= parse,
81	.final_check	= final_check,
82	.print		= print,
83	.compare	= compare,
84	.extra_ops	= opts,
85};
86
87void _init(void)
88{
89	ebt_register_target(&standard);
90}
91