/* Shared library add-on to iptables to add CRASH support. Author: Intra2net AG Licensed under the GPL v2. */ #include #include #include #include #include #include #include #include #include static struct option opts[] = { { .name = 0 } }; /* Function which prints out usage message. */ static void help(void) { printf( "CRASH v%s options:\n", IPTABLES_VERSION); } /* Initialize the target. */ static void init(struct ipt_entry_target *t, unsigned int *nfcache) { /* Can't cache this */ *nfcache |= NFC_UNKNOWN; } /* Function which parses command options; returns true if it ate an option */ static int parse(int c, char **argv, int invert, unsigned int *flags, const struct ipt_entry *entry, struct ipt_entry_target **target) { return 0; } /* Final check; nothing. */ static void final_check(unsigned int flags) { } static void print_it(const struct ipt_ip *ip, const struct ipt_entry_target *target, char do_prefix) { if (!do_prefix) printf("CRASH "); } /* Prints out the targinfo. */ static void print(const struct ipt_ip *ip, const struct ipt_entry_target *target, int numeric) { print_it (ip, target, 0); } /* Saves the union ipt_targinfo in parsable form to stdout. */ static void save(const struct ipt_ip *ip, const struct ipt_entry_target *target) { print_it(ip, target, 1); } static struct iptables_target crash = { .next = NULL, .name = "CRASH", .version = IPTABLES_VERSION, .size = IPT_ALIGN(sizeof(struct ipt_crash_info)), .userspacesize = IPT_ALIGN(sizeof(struct ipt_crash_info)), .help = &help, .init = &init, .parse = &parse, .final_check = &final_check, .print = &print, .save = &save, .extra_opts = opts }; void _init(void) { register_target(&crash); }