Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 1 | #include <stdio.h> |
Bart De Schuymer | 41e8a19 | 2002-06-23 08:03:12 +0000 | [diff] [blame] | 2 | #include <stdlib.h> |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 3 | #include <sys/socket.h> |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 4 | #include <getopt.h> |
| 5 | #include "../include/ebtables_u.h" |
| 6 | |
| 7 | static struct option opts[] = |
| 8 | { |
| 9 | {0} |
| 10 | }; |
| 11 | |
| 12 | static void print_help() |
| 13 | { |
| 14 | printf("Standard targets: DROP, ACCEPT and CONTINUE\n"); |
| 15 | } |
| 16 | |
| 17 | static void init(struct ebt_entry_target *t) |
| 18 | { |
| 19 | ((struct ebt_standard_target *)t)->verdict = EBT_CONTINUE; |
| 20 | } |
| 21 | |
| 22 | static 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 | |
| 28 | static void final_check(const struct ebt_u_entry *entry, |
Bart De Schuymer | 41e8a19 | 2002-06-23 08:03:12 +0000 | [diff] [blame] | 29 | const struct ebt_entry_target *target, const char *name, unsigned int hook_mask) |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 30 | { |
| 31 | } |
| 32 | |
| 33 | static void print(const struct ebt_u_entry *entry, |
| 34 | const struct ebt_entry_target *target) |
| 35 | { |
Bart De Schuymer | 41e8a19 | 2002-06-23 08:03:12 +0000 | [diff] [blame] | 36 | int verdict = ((struct ebt_standard_target *)target)->verdict; |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 37 | |
| 38 | if (verdict == EBT_CONTINUE) |
Bart De Schuymer | 41e8a19 | 2002-06-23 08:03:12 +0000 | [diff] [blame] | 39 | printf("CONTINUE "); |
| 40 | else if (verdict == EBT_ACCEPT) |
| 41 | printf("ACCEPT "); |
| 42 | else if (verdict == EBT_DROP) |
| 43 | printf("DROP "); |
| 44 | else if (verdict == EBT_RETURN) |
| 45 | printf("RETURN "); |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 46 | else |
Bart De Schuymer | 41e8a19 | 2002-06-23 08:03:12 +0000 | [diff] [blame] | 47 | print_error("BUG: Bad standard target"); // this is a bug |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | static int compare(const struct ebt_entry_target *t1, |
| 51 | const struct ebt_entry_target *t2) |
| 52 | { |
| 53 | return ((struct ebt_standard_target *)t1)->verdict == |
| 54 | ((struct ebt_standard_target *)t2)->verdict; |
| 55 | } |
| 56 | |
| 57 | static struct ebt_u_target standard = |
| 58 | { |
| 59 | EBT_STANDARD_TARGET, |
| 60 | sizeof(struct ebt_standard_target) - sizeof(struct ebt_entry_target), |
| 61 | print_help, |
| 62 | init, |
| 63 | parse, |
| 64 | final_check, |
| 65 | print, |
| 66 | compare, |
| 67 | opts |
| 68 | }; |
| 69 | |
| 70 | static void _init(void) __attribute__ ((constructor)); |
| 71 | static void _init(void) |
| 72 | { |
| 73 | register_target(&standard); |
| 74 | } |