Esempio n. 1
0
File: nf_hook.c Progetto: magg/NAT64
static void __exit nat64_exit(void)
{
	/* Release the hook. */
	nf_unregister_hooks(nfho, ARRAY_SIZE(nfho));

	/* Deinitialize the submodules. */
#ifdef BENCHMARK
	logtime_destroy();
#endif
	sendpkt_destroy();
	translate_packet_destroy();
	filtering_destroy();
	fragdb_destroy();
	sessiondb_destroy();
	bibdb_destroy();
	pktqueue_destroy();
	pool4_destroy();
	pool6_destroy();
	config_destroy();

	log_info(MODULE_NAME " module removed.");
}
static bool init(void)
{
	if (is_error(fragdb_init()))
		goto fragdb_fail;
	if (!init_full())
		goto initfull_fail;

	if (!bib_inject_str(SERVER_ADDR6, SERVER_PORT6, NAT64_POOL4, SERVER_PORT6, L4PROTO_UDP))
		goto inject_fail;
	if (!bib_inject_str(SERVER_ADDR6, SERVER_PORT6, NAT64_POOL4, SERVER_PORT6, L4PROTO_TCP))
		goto inject_fail;
	if (!bib_inject_str(SERVER_ADDR6, SERVER_PORT6, NAT64_POOL4, SERVER_PORT6, L4PROTO_ICMP))
		goto inject_fail;

	return true;

inject_fail:
	end_full();
initfull_fail:
	fragdb_destroy();
fragdb_fail:
	return false;
}
static void deinit(void)
{
	end_full();
	fragdb_destroy();
}
Esempio n. 4
0
File: nf_hook.c Progetto: magg/NAT64
static int __init nat64_init(void)
{
	int error;

	log_debug("%s", banner);
	log_debug("Inserting the module...");

	/* Init Jool's submodules. */
	error = config_init();
	if (error)
		goto config_failure;
	error = pool6_init(pool6, pool6_size);
	if (error)
		goto pool6_failure;
	error = pool4_init(pool4, pool4_size);
	if (error)
		goto pool4_failure;
	error = pktqueue_init();
	if (error)
		goto pktqueue_failure;
	error = bibdb_init();
	if (error)
		goto bib_failure;
	error = sessiondb_init();
	if (error)
		goto session_failure;
	error = fragdb_init();
	if (error)
		goto fragdb_failure;
	error = filtering_init();
	if (error)
		goto filtering_failure;
	error = translate_packet_init();
	if (error)
		goto translate_packet_failure;
	error = sendpkt_init();
	if (error)
		goto sendpkt_failure;
#ifdef BENCHMARK
	error = logtime_init();
	if (error)
		goto log_time_failure;
#endif

	/* Hook Jool to Netfilter. */
	error = nf_register_hooks(nfho, ARRAY_SIZE(nfho));
	if (error)
		goto nf_register_hooks_failure;

	/* Yay */
	log_info(MODULE_NAME " module inserted.");
	return error;

nf_register_hooks_failure:
#ifdef BENCHMARK
	logtime_destroy();

log_time_failure:
#endif
	sendpkt_destroy();

sendpkt_failure:
	translate_packet_destroy();

translate_packet_failure:
	filtering_destroy();

filtering_failure:
	fragdb_destroy();

fragdb_failure:
	sessiondb_destroy();

session_failure:
	bibdb_destroy();

bib_failure:
	pktqueue_destroy();

pktqueue_failure:
	pool4_destroy();

pool4_failure:
	pool6_destroy();

pool6_failure:
	config_destroy();

config_failure:
	return error;
}