Пример #1
0
static void connlabel_mt_parse(struct xt_option_call *cb)
{
	struct xt_connlabel_mtinfo *info = cb->data;
	bool have_labelmap = !connlabel_open();
	int tmp;

	xtables_option_parse(cb);

	switch (cb->entry->id) {
	case O_LABEL:
		if (have_labelmap)
			tmp = nfct_labelmap_get_bit(map, cb->arg);
		else
			tmp = connlabel_value_parse(cb->arg);

		if (tmp < 0)
			xtables_error(PARAMETER_PROBLEM,
				      "label '%s' not found or invalid value",
				      cb->arg);

		info->bit = tmp;
		if (cb->invert)
			info->options |= XT_CONNLABEL_OP_INVERT;
		break;
	case O_SET:
		info->options |= XT_CONNLABEL_OP_SET;
		break;
	}

}
Пример #2
0
static void print_label(struct nfct_labelmap *map)
{
	int b = nfct_labelmap_get_bit(map, "test label 1");
	assert(b == 1);

	b = nfct_labelmap_get_bit(map, "zero");
	assert(b == 0);

	b = nfct_labelmap_get_bit(map, "test label 2");
	assert(b == 2);

	b = nfct_labelmap_get_bit(map, "duplicate");
	assert(b < 0);

	b = nfct_labelmap_get_bit(map, "invalid label");
	assert(b < 0);

	b = nfct_labelmap_get_bit(map, "T");
	assert(b == 42);
}