Blame lib/ipset_list_set.c

Packit 99347c
/* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu)
Packit 99347c
 *
Packit 99347c
 * This program is free software; you can redistribute it and/or modify
Packit 99347c
 * it under the terms of the GNU General Public License version 2 as
Packit 99347c
 * published by the Free Software Foundation.
Packit 99347c
 */
Packit 99347c
#include <libipset/data.h>			/* IPSET_OPT_* */
Packit 99347c
#include <libipset/parse.h>			/* parser functions */
Packit 99347c
#include <libipset/print.h>			/* printing functions */
Packit 99347c
#include <libipset/types.h>			/* prototypes */
Packit 99347c
Packit 99347c
/* Initial revision */
Packit 99347c
static struct ipset_type ipset_list_set0 = {
Packit 99347c
	.name = "list:set",
Packit 99347c
	.alias = { "setlist", NULL },
Packit 99347c
	.revision = 0,
Packit 99347c
	.family = NFPROTO_UNSPEC,
Packit 99347c
	.dimension = IPSET_DIM_ONE,
Packit 99347c
	.elem = {
Packit 99347c
		[IPSET_DIM_ONE - 1] = {
Packit 99347c
			.parse = ipset_parse_setname,
Packit 99347c
			.print = ipset_print_name,
Packit 99347c
			.opt = IPSET_OPT_NAME
Packit 99347c
		},
Packit 99347c
	},
Packit 99347c
	.compat_parse_elem = ipset_parse_name_compat,
Packit 99347c
	.cmd = {
Packit 99347c
		[IPSET_CREATE] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_SIZE,
Packit 99347c
				IPSET_ARG_TIMEOUT,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = 0,
Packit 99347c
			.full = 0,
Packit 99347c
			.help = "",
Packit 99347c
		},
Packit 99347c
		[IPSET_ADD] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_TIMEOUT,
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
		[IPSET_DEL] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
		[IPSET_TEST] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
	},
Packit 99347c
	.usage = "where NAME are existing set names.",
Packit 99347c
	.description = "Initial revision",
Packit 99347c
};
Packit 99347c
Packit 99347c
/* counters support */
Packit 99347c
static struct ipset_type ipset_list_set1 = {
Packit 99347c
	.name = "list:set",
Packit 99347c
	.alias = { "setlist", NULL },
Packit 99347c
	.revision = 1,
Packit 99347c
	.family = NFPROTO_UNSPEC,
Packit 99347c
	.dimension = IPSET_DIM_ONE,
Packit 99347c
	.elem = {
Packit 99347c
		[IPSET_DIM_ONE - 1] = {
Packit 99347c
			.parse = ipset_parse_setname,
Packit 99347c
			.print = ipset_print_name,
Packit 99347c
			.opt = IPSET_OPT_NAME
Packit 99347c
		},
Packit 99347c
	},
Packit 99347c
	.compat_parse_elem = ipset_parse_name_compat,
Packit 99347c
	.cmd = {
Packit 99347c
		[IPSET_CREATE] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_SIZE,
Packit 99347c
				IPSET_ARG_TIMEOUT,
Packit 99347c
				IPSET_ARG_COUNTERS,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = 0,
Packit 99347c
			.full = 0,
Packit 99347c
			.help = "",
Packit 99347c
		},
Packit 99347c
		[IPSET_ADD] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_TIMEOUT,
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_PACKETS,
Packit 99347c
				IPSET_ARG_BYTES,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
		[IPSET_DEL] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
		[IPSET_TEST] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
	},
Packit 99347c
	.usage = "where NAME are existing set names.",
Packit 99347c
	.description = "counters support",
Packit 99347c
};
Packit 99347c
Packit 99347c
/* comment support */
Packit 99347c
static struct ipset_type ipset_list_set2 = {
Packit 99347c
	.name = "list:set",
Packit 99347c
	.alias = { "setlist", NULL },
Packit 99347c
	.revision = 2,
Packit 99347c
	.family = NFPROTO_UNSPEC,
Packit 99347c
	.dimension = IPSET_DIM_ONE,
Packit 99347c
	.elem = {
Packit 99347c
		[IPSET_DIM_ONE - 1] = {
Packit 99347c
			.parse = ipset_parse_setname,
Packit 99347c
			.print = ipset_print_name,
Packit 99347c
			.opt = IPSET_OPT_NAME
Packit 99347c
		},
Packit 99347c
	},
Packit 99347c
	.compat_parse_elem = ipset_parse_name_compat,
Packit 99347c
	.cmd = {
Packit 99347c
		[IPSET_CREATE] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_SIZE,
Packit 99347c
				IPSET_ARG_TIMEOUT,
Packit 99347c
				IPSET_ARG_COUNTERS,
Packit 99347c
				IPSET_ARG_COMMENT,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = 0,
Packit 99347c
			.full = 0,
Packit 99347c
			.help = "",
Packit 99347c
		},
Packit 99347c
		[IPSET_ADD] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_TIMEOUT,
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_PACKETS,
Packit 99347c
				IPSET_ARG_BYTES,
Packit 99347c
				IPSET_ARG_ADT_COMMENT,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
		[IPSET_DEL] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
		[IPSET_TEST] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
	},
Packit 99347c
	.usage = "where NAME are existing set names.",
Packit 99347c
	.description = "comment support",
Packit 99347c
};
Packit 99347c
Packit 99347c
/* skbinfo support */
Packit 99347c
static struct ipset_type ipset_list_set3 = {
Packit 99347c
	.name = "list:set",
Packit 99347c
	.alias = { "setlist", NULL },
Packit 99347c
	.revision = 3,
Packit 99347c
	.family = NFPROTO_UNSPEC,
Packit 99347c
	.dimension = IPSET_DIM_ONE,
Packit 99347c
	.elem = {
Packit 99347c
		[IPSET_DIM_ONE - 1] = {
Packit 99347c
			.parse = ipset_parse_setname,
Packit 99347c
			.print = ipset_print_name,
Packit 99347c
			.opt = IPSET_OPT_NAME
Packit 99347c
		},
Packit 99347c
	},
Packit 99347c
	.compat_parse_elem = ipset_parse_name_compat,
Packit 99347c
	.cmd = {
Packit 99347c
		[IPSET_CREATE] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_SIZE,
Packit 99347c
				IPSET_ARG_TIMEOUT,
Packit 99347c
				IPSET_ARG_COUNTERS,
Packit 99347c
				IPSET_ARG_COMMENT,
Packit 99347c
				IPSET_ARG_SKBINFO,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = 0,
Packit 99347c
			.full = 0,
Packit 99347c
			.help = "",
Packit 99347c
		},
Packit 99347c
		[IPSET_ADD] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_TIMEOUT,
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_PACKETS,
Packit 99347c
				IPSET_ARG_BYTES,
Packit 99347c
				IPSET_ARG_ADT_COMMENT,
Packit 99347c
				IPSET_ARG_SKBMARK,
Packit 99347c
				IPSET_ARG_SKBPRIO,
Packit 99347c
				IPSET_ARG_SKBQUEUE,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
		[IPSET_DEL] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
		[IPSET_TEST] = {
Packit 99347c
			.args = {
Packit 99347c
				IPSET_ARG_BEFORE,
Packit 99347c
				IPSET_ARG_AFTER,
Packit 99347c
				IPSET_ARG_NONE,
Packit 99347c
			},
Packit 99347c
			.need = IPSET_FLAG(IPSET_OPT_NAME),
Packit 99347c
			.full = IPSET_FLAG(IPSET_OPT_NAME)
Packit 99347c
				| IPSET_FLAG(IPSET_OPT_BEFORE),
Packit 99347c
			.help = "NAME [before|after NAME]",
Packit 99347c
		},
Packit 99347c
	},
Packit 99347c
	.usage = "where NAME are existing set names.",
Packit 99347c
	.description = "skbinfo support",
Packit 99347c
};
Packit 99347c
Packit 99347c
void _init(void);
Packit 99347c
void _init(void)
Packit 99347c
{
Packit 99347c
	ipset_type_add(&ipset_list_set0);
Packit 99347c
	ipset_type_add(&ipset_list_set1);
Packit 99347c
	ipset_type_add(&ipset_list_set2);
Packit 99347c
	ipset_type_add(&ipset_list_set3);
Packit 99347c
}