Ejemplo n.º 1
0
static bool remove_entry(char *addr4, __u8 len4, char *addr6, __u8 len6,
		int expected_error)
{
	struct ipv4_prefix prefix4;
	struct ipv6_prefix prefix6;
	bool success;
	int error;

	log_debug("----------------");
	log_debug("Removing entry %s/%u %s/%u", addr6, len6, addr4, len4);

	if (!addr4 && !addr6) {
		log_err("Both addr4 and addr6 are NULL.");
		return false;
	}

	if (addr4) {
		if (is_error(str_to_addr4(addr4, &prefix4.address)))
			return false;
		prefix4.len = len4;
	}

	if (addr6) {
		if (is_error(str_to_addr6(addr6, &prefix6.address)))
			return false;
		prefix6.len = len6;
	}

	error = eamt_rm(addr6 ? &prefix6 : NULL, addr4 ? &prefix4 : NULL);
	success = ASSERT_INT(expected_error, error, "removing EAM entry");

	/* rtrie_print(eamt.tree6); */

	return success;
}
Ejemplo n.º 2
0
Archivo: eam.c Proyecto: NICMx/Jool
static int handle_eamt_rm(struct eam_table *eamt, union request_eamt *request)
{
	struct ipv6_prefix *prefix6;
	struct ipv4_prefix *prefix4;

	log_debug("Removing EAMT entry.");

	prefix6 = request->rm.prefix6_set ? &request->rm.prefix6 : NULL;
	prefix4 = request->rm.prefix4_set ? &request->rm.prefix4 : NULL;
	return eamt_rm(eamt, prefix6, prefix4);
}
Ejemplo n.º 3
0
static int handle_eamt_config(struct nlmsghdr *nl_hdr, struct request_hdr *jool_hdr,
		union request_eamt *request)
{
	__u64 count;
	int error;

	if (xlat_is_nat64()) {
		log_err("Stateful NAT64 doesn't have an EAMT.");
		return -EINVAL;
	}

	switch (jool_hdr->operation) {
	case OP_DISPLAY:
		return handle_eamt_display(nl_hdr, request);

	case OP_COUNT:
		log_debug("Returning EAMT count.");
		error = eamt_count(&count);
		if (error)
			return respond_error(nl_hdr, error);
		return respond_setcfg(nl_hdr, &count, sizeof(count));

	case OP_TEST:
		return handle_eamt_test(nl_hdr, request);

	case OP_ADD:
		if (verify_superpriv())
			return respond_error(nl_hdr, -EPERM);

		log_debug("Adding EAMT entry.");
		return respond_error(nl_hdr, eamt_add(&request->add.prefix6,
				&request->add.prefix4, request->add.force));

	case OP_REMOVE:
		if (verify_superpriv())
			return respond_error(nl_hdr, -EPERM);

		log_debug("Removing EAMT entry.");
		return respond_error(nl_hdr, eamt_rm(
				request->rm.prefix6_set ? &request->rm.prefix6 : NULL,
				request->rm.prefix4_set ? &request->rm.prefix4 : NULL));

	case OP_FLUSH:
		if (verify_superpriv())
			return respond_error(nl_hdr, -EPERM);

		eamt_flush();
		return respond_error(nl_hdr, 0);

	default:
		log_err("Unknown operation: %d", jool_hdr->operation);
		return respond_error(nl_hdr, -EINVAL);
	}
}