1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #include <stdio.h>
- #include <xtables.h>
- #include <linux/netfilter/xt_IDLETIMER.h>
- enum {
- O_TIMEOUT = 0,
- O_LABEL,
- };
- #define s struct idletimer_tg_info
- static const struct xt_option_entry idletimer_tg_opts[] = {
- {.name = "timeout", .id = O_TIMEOUT, .type = XTTYPE_UINT32,
- .flags = XTOPT_MAND | XTOPT_PUT, XTOPT_POINTER(s, timeout)},
- {.name = "label", .id = O_LABEL, .type = XTTYPE_STRING,
- .flags = XTOPT_MAND | XTOPT_PUT, XTOPT_POINTER(s, label)},
- XTOPT_TABLEEND,
- };
- #undef s
- static void idletimer_tg_help(void)
- {
- printf(
- "IDLETIMER target options:\n"
- " --timeout time Timeout until the notification is sent (in seconds)\n"
- " --label string Unique rule identifier\n"
- "\n");
- }
- static void idletimer_tg_print(const void *ip,
- const struct xt_entry_target *target,
- int numeric)
- {
- struct idletimer_tg_info *info =
- (struct idletimer_tg_info *) target->data;
- printf(" timeout:%u", info->timeout);
- printf(" label:%s", info->label);
- }
- static void idletimer_tg_save(const void *ip,
- const struct xt_entry_target *target)
- {
- struct idletimer_tg_info *info =
- (struct idletimer_tg_info *) target->data;
- printf(" --timeout %u", info->timeout);
- printf(" --label %s", info->label);
- }
- static struct xtables_target idletimer_tg_reg = {
- .family = NFPROTO_UNSPEC,
- .name = "IDLETIMER",
- .version = XTABLES_VERSION,
- .revision = 0,
- .size = XT_ALIGN(sizeof(struct idletimer_tg_info)),
- .userspacesize = offsetof(struct idletimer_tg_info, timer),
- .help = idletimer_tg_help,
- .x6_parse = xtables_option_parse,
- .print = idletimer_tg_print,
- .save = idletimer_tg_save,
- .x6_options = idletimer_tg_opts,
- };
- void _init(void)
- {
- xtables_register_target(&idletimer_tg_reg);
- }
|