|
Packit |
7b22a4 |
/*
|
|
Packit |
7b22a4 |
* Shared library add-on for iptables to add IDLETIMER support.
|
|
Packit |
7b22a4 |
*
|
|
Packit |
7b22a4 |
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
|
|
Packit |
7b22a4 |
*
|
|
Packit |
7b22a4 |
* Contact: Luciano Coelho <luciano.coelho@nokia.com>
|
|
Packit |
7b22a4 |
*
|
|
Packit |
7b22a4 |
* This program is free software; you can redistribute it and/or
|
|
Packit |
7b22a4 |
* modify it under the terms of the GNU General Public License
|
|
Packit |
7b22a4 |
* version 2 as published by the Free Software Foundation.
|
|
Packit |
7b22a4 |
*
|
|
Packit |
7b22a4 |
* This program is distributed in the hope that it will be useful, but
|
|
Packit |
7b22a4 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
7b22a4 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
7b22a4 |
* General Public License for more details.
|
|
Packit |
7b22a4 |
*
|
|
Packit |
7b22a4 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
7b22a4 |
* along with this program; if not, write to the Free Software
|
|
Packit |
7b22a4 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
Packit |
7b22a4 |
* 02110-1301 USA
|
|
Packit |
7b22a4 |
*
|
|
Packit |
7b22a4 |
*/
|
|
Packit |
7b22a4 |
#include <stdio.h>
|
|
Packit |
7b22a4 |
#include <xtables.h>
|
|
Packit |
7b22a4 |
#include <linux/netfilter/xt_IDLETIMER.h>
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
enum {
|
|
Packit |
7b22a4 |
O_TIMEOUT = 0,
|
|
Packit |
7b22a4 |
O_LABEL,
|
|
Packit |
7b22a4 |
};
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
#define s struct idletimer_tg_info
|
|
Packit |
7b22a4 |
static const struct xt_option_entry idletimer_tg_opts[] = {
|
|
Packit |
7b22a4 |
{.name = "timeout", .id = O_TIMEOUT, .type = XTTYPE_UINT32,
|
|
Packit |
7b22a4 |
.flags = XTOPT_MAND | XTOPT_PUT, XTOPT_POINTER(s, timeout)},
|
|
Packit |
7b22a4 |
{.name = "label", .id = O_LABEL, .type = XTTYPE_STRING,
|
|
Packit |
7b22a4 |
.flags = XTOPT_MAND | XTOPT_PUT, XTOPT_POINTER(s, label)},
|
|
Packit |
7b22a4 |
XTOPT_TABLEEND,
|
|
Packit |
7b22a4 |
};
|
|
Packit |
7b22a4 |
#undef s
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static void idletimer_tg_help(void)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
printf(
|
|
Packit |
7b22a4 |
"IDLETIMER target options:\n"
|
|
Packit |
7b22a4 |
" --timeout time Timeout until the notification is sent (in seconds)\n"
|
|
Packit |
7b22a4 |
" --label string Unique rule identifier\n"
|
|
Packit |
7b22a4 |
"\n");
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static void idletimer_tg_print(const void *ip,
|
|
Packit |
7b22a4 |
const struct xt_entry_target *target,
|
|
Packit |
7b22a4 |
int numeric)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
struct idletimer_tg_info *info =
|
|
Packit |
7b22a4 |
(struct idletimer_tg_info *) target->data;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
printf(" timeout:%u", info->timeout);
|
|
Packit |
7b22a4 |
printf(" label:%s", info->label);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static void idletimer_tg_save(const void *ip,
|
|
Packit |
7b22a4 |
const struct xt_entry_target *target)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
struct idletimer_tg_info *info =
|
|
Packit |
7b22a4 |
(struct idletimer_tg_info *) target->data;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
printf(" --timeout %u", info->timeout);
|
|
Packit |
7b22a4 |
printf(" --label %s", info->label);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static struct xtables_target idletimer_tg_reg = {
|
|
Packit |
7b22a4 |
.family = NFPROTO_UNSPEC,
|
|
Packit |
7b22a4 |
.name = "IDLETIMER",
|
|
Packit |
7b22a4 |
.version = XTABLES_VERSION,
|
|
Packit |
7b22a4 |
.revision = 0,
|
|
Packit |
7b22a4 |
.size = XT_ALIGN(sizeof(struct idletimer_tg_info)),
|
|
Packit |
7b22a4 |
.userspacesize = offsetof(struct idletimer_tg_info, timer),
|
|
Packit |
7b22a4 |
.help = idletimer_tg_help,
|
|
Packit |
7b22a4 |
.x6_parse = xtables_option_parse,
|
|
Packit |
7b22a4 |
.print = idletimer_tg_print,
|
|
Packit |
7b22a4 |
.save = idletimer_tg_save,
|
|
Packit |
7b22a4 |
.x6_options = idletimer_tg_opts,
|
|
Packit |
7b22a4 |
};
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
void _init(void)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
xtables_register_target(&idletimer_tg_reg);
|
|
Packit |
7b22a4 |
}
|