Example #1
0
static int init(void)
{
	struct config_prefix6 pool6;
	struct pool4_entry_usr entry;
	int error;

	pool6.set = true;
	pool6.prefix.len = 96;
	error = str_to_addr6("3::", &pool6.prefix.addr);
	if (error)
		return error;

	error = xlator_add(FW_NETFILTER, INAME_DEFAULT, &pool6, &jool);
	if (error)
		return error;

	entry.mark = 0;
	entry.iterations = 0;
	entry.flags = ITERATIONS_SET | ITERATIONS_INFINITE;
	error = str_to_addr4("192.0.2.128", &entry.range.prefix.addr);
	if (error)
		goto fail;
	entry.range.prefix.len = 32;
	entry.range.ports.min = 1024;
	entry.range.ports.max = 1024;

	entry.proto = L4PROTO_TCP;
	error = pool4db_add(jool.nat64.pool4, &entry);
	if (error)
		goto fail;
	entry.proto = L4PROTO_UDP;
	error = pool4db_add(jool.nat64.pool4, &entry);
	if (error)
		goto fail;
	entry.proto = L4PROTO_ICMP;
	error = pool4db_add(jool.nat64.pool4, &entry);
	if (error)
		goto fail;

	return 0;

fail:
	xlator_put(&jool);
	xlator_rm(INAME_DEFAULT);
	return error;
}
Example #2
0
static int handle_pool4_add(struct nlmsghdr *nl_hdr, union request_pool4 *request)
{
	if (verify_superpriv())
		return respond_error(nl_hdr, -EPERM);

	log_debug("Adding elements to the IPv4 pool.");

	return respond_error(nl_hdr, pool4db_add(request->add.mark,
			request->add.proto, &request->add.addrs,
			&request->add.ports));
}
Example #3
0
/**
 * add - Boilerplate code to add an entry to the pool during the tests.
 */
static bool add(__u32 addr, __u8 prefix_len, __u16 min, __u16 max)
{
	struct ipv4_range range;

	range.prefix.address.s_addr = cpu_to_be32(addr);
	range.prefix.len = prefix_len;
	range.ports.min = min;
	range.ports.max = max;

	return ASSERT_INT(0, pool4db_add(pool, 1, L4PROTO_TCP, &range),
			"add of %pI4/%u (%u-%u)",
			&range.prefix.address, prefix_len, min, max);
}
Example #4
0
File: pool4.c Project: NICMx/Jool
static int handle_pool4_add(struct pool4 *pool, struct genl_info *info,
		union request_pool4 *request)
{
	log_debug("Adding elements to pool4.");
	return nlcore_respond(info, pool4db_add(pool, &request->add));
}