Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <sys/socket.h> |
| 3 | #include <linux/netfilter_bridge/ebtables.h> |
| 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, |
| 29 | const struct ebt_entry_target *target, const char *name, unsigned int hook) |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | static void print(const struct ebt_u_entry *entry, |
| 34 | const struct ebt_entry_target *target) |
| 35 | { |
| 36 | __u8 verdict = ((struct ebt_standard_target *)target)->verdict; |
| 37 | |
| 38 | if (verdict == EBT_CONTINUE) |
| 39 | printf("Continue "); |
| 40 | else if (verdict == EBT_ACCEPT) |
| 41 | printf("Accept "); |
| 42 | else |
| 43 | printf("Drop "); |
| 44 | } |
| 45 | |
| 46 | static int compare(const struct ebt_entry_target *t1, |
| 47 | const struct ebt_entry_target *t2) |
| 48 | { |
| 49 | return ((struct ebt_standard_target *)t1)->verdict == |
| 50 | ((struct ebt_standard_target *)t2)->verdict; |
| 51 | } |
| 52 | |
| 53 | static struct ebt_u_target standard = |
| 54 | { |
| 55 | EBT_STANDARD_TARGET, |
| 56 | sizeof(struct ebt_standard_target) - sizeof(struct ebt_entry_target), |
| 57 | print_help, |
| 58 | init, |
| 59 | parse, |
| 60 | final_check, |
| 61 | print, |
| 62 | compare, |
| 63 | opts |
| 64 | }; |
| 65 | |
| 66 | static void _init(void) __attribute__ ((constructor)); |
| 67 | static void _init(void) |
| 68 | { |
| 69 | register_target(&standard); |
| 70 | } |