Beispiel #1
0
static int __init nf_conntrack_l7fsm_init(void)
{
	int ret = 0;
	policy.max_expected = 0;
	policy.timeout = 0;

	l7fsm_helper_tcp.tuple.src.l3num = AF_INET;
	l7fsm_helper_tcp.tuple.dst.protonum = IPPROTO_TCP;
	l7fsm_helper_tcp.expect_policy = &policy;
	l7fsm_helper_tcp.me = THIS_MODULE;
	l7fsm_helper_tcp.help = l7fsm_help_tcp;
	l7fsm_helper_tcp.destroy = l7fsm_destroy;
	sprintf(l7fsm_helper_tcp.name, "l7fsm_tcp");

	ret = nf_conntrack_helper_register(&l7fsm_helper_tcp);
	if ( ret != 0 ) {
		pr_err("l7fsm: failed to register tcp helper\n");
		return ret;
	}

	l7fsm_helper_udp.tuple.src.l3num = AF_INET;
	l7fsm_helper_udp.tuple.dst.protonum = IPPROTO_UDP;
	l7fsm_helper_udp.expect_policy = &policy;
	l7fsm_helper_udp.me = THIS_MODULE;
	l7fsm_helper_udp.help = l7fsm_help_udp;
	l7fsm_helper_udp.destroy = l7fsm_destroy;
	sprintf(l7fsm_helper_udp.name, "l7fsm_udp");

	ret = nf_conntrack_helper_register(&l7fsm_helper_udp);
	if ( ret != 0 ) {
		pr_err("l7fsm: failed to register udp helper\n");
		nf_conntrack_helper_unregister(&l7fsm_helper_tcp);
	}
	return ret;
}
Beispiel #2
0
static int __init nf_conntrack_tftp_init(void)
{
	int i, j, ret;

	if (ports_c == 0)
		ports[ports_c++] = TFTP_PORT;

	for (i = 0; i < ports_c; i++) {
		memset(&tftp[i], 0, sizeof(tftp[i]));

		tftp[i][0].tuple.src.l3num = AF_INET;
		tftp[i][1].tuple.src.l3num = AF_INET6;
		for (j = 0; j < 2; j++) {
			tftp[i][j].tuple.dst.protonum = IPPROTO_UDP;
			tftp[i][j].tuple.src.u.udp.port = htons(ports[i]);
			tftp[i][j].expect_policy = &tftp_exp_policy;
			tftp[i][j].me = THIS_MODULE;
			tftp[i][j].help = tftp_help;

			if (ports[i] == TFTP_PORT)
				sprintf(tftp[i][j].name, "tftp");
			else
				sprintf(tftp[i][j].name, "tftp-%u", i);

			ret = nf_conntrack_helper_register(&tftp[i][j]);
			if (ret) {
				pr_err("failed to register helper for pf: %u port: %u\n",
				       tftp[i][j].tuple.src.l3num, ports[i]);
				nf_conntrack_tftp_fini();
				return ret;
			}
		}
	}
	return 0;
}
static int __init
init(void)
{
	int i, ret;
	struct nf_conntrack_helper *hlpr;
	char *tmpname;

	printk("nf_conntrack_rtsp v" IP_NF_RTSP_VERSION " loading\n");

	if (max_outstanding < 1) {
		printk("nf_conntrack_rtsp: max_outstanding must be a positive integer\n");
		return -EBUSY;
	}
	if (setup_timeout < 0) {
		printk("nf_conntrack_rtsp: setup_timeout must be a positive integer\n");
		return -EBUSY;
	}

	rtsp_expect_policy.max_expected = max_outstanding;
	rtsp_expect_policy.timeout = setup_timeout;

	rtsp_buffer = kmalloc(65536, GFP_KERNEL);
	if (!rtsp_buffer)
		return -ENOMEM;

	/* If no port given, default to standard rtsp port */
	if (ports[0] == 0) {
		ports[0] = RTSP_PORT;
	}

	for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
		hlpr = &rtsp_helpers[i];
		memset(hlpr, 0, sizeof(struct nf_conntrack_helper));
		hlpr->tuple.src.u.tcp.port = htons(ports[i]);
		hlpr->tuple.dst.protonum = IPPROTO_TCP;
		hlpr->expect_policy = &rtsp_expect_policy;
		hlpr->me = THIS_MODULE;
		hlpr->help = help;

		tmpname = &rtsp_names[i][0];
		if (ports[i] == RTSP_PORT) {
			sprintf(tmpname, "rtsp");
		} else {
			sprintf(tmpname, "rtsp-%d", i);
		}
		hlpr->name = tmpname;

		DEBUGP("port #%d: %d\n", i, ports[i]);

		ret = nf_conntrack_helper_register(hlpr);

		if (ret) {
			printk("nf_conntrack_rtsp: ERROR registering port %d\n", ports[i]);
			fini();
			return -EBUSY;
		}
		num_ports++;
	}
	return 0;
}
Beispiel #4
0
static int __init nf_nat_snmp_basic_init(void)
{
	BUG_ON(nf_nat_snmp_hook != NULL);
	RCU_INIT_POINTER(nf_nat_snmp_hook, help);

	return nf_conntrack_helper_register(&snmp_trap_helper);
}
Beispiel #5
0
static int __init nf_conntrack_irc_init(void)
{
	int i, ret;
	char *tmpname;

	if (max_dcc_channels < 1) {
		printk("nf_ct_irc: max_dcc_channels must not be zero\n");
		return -EINVAL;
	}

#if !defined(TCSUPPORT_CT) 
#if defined(CONFIG_MIPS_TC3162) || defined(CONFIG_MIPS_TC3262)
    	irc_buffer = kmalloc(NF_CONNTRACK_BUF_SIZE, GFP_KERNEL);
#else
	irc_buffer = kmalloc(65536, GFP_KERNEL);
#endif
#endif
	
	if (!irc_buffer)
		return -ENOMEM;

	/* If no port given, default to standard irc port */
	if (ports_c == 0)
		ports[ports_c++] = IRC_PORT;

	for (i = 0; i < ports_c; i++) {
		irc[i].tuple.src.l3num = AF_INET;
		irc[i].tuple.src.u.tcp.port = htons(ports[i]);
		irc[i].tuple.dst.protonum = IPPROTO_TCP;
		irc[i].mask.src.l3num = 0xFFFF;
		irc[i].mask.src.u.tcp.port = htons(0xFFFF);
		irc[i].mask.dst.protonum = 0xFF;
		irc[i].max_expected = max_dcc_channels;
		irc[i].timeout = dcc_timeout;
		irc[i].me = THIS_MODULE;
		irc[i].help = help;

		tmpname = &irc_names[i][0];
		if (ports[i] == IRC_PORT)
			sprintf(tmpname, "irc");
		else
			sprintf(tmpname, "irc-%u", i);
		irc[i].name = tmpname;

		ret = nf_conntrack_helper_register(&irc[i]);
		if (ret) {
			printk("nf_ct_irc: failed to register helper "
			       "for pf: %u port: %u\n",
			       irc[i].tuple.src.l3num, ports[i]);
			nf_conntrack_irc_fini();
			return ret;
		}
	}
	return 0;
}
static int __init nf_conntrack_tftp_init(void)
{
	int i, j, ret;
	char *tmpname;
	#ifdef CONFIG_CAMEO_ALG_TFTP
	static struct proc_dir_entry *proc_tftp = NULL;
	#endif

	if (ports_c == 0)
		ports[ports_c++] = TFTP_PORT;

	for (i = 0; i < ports_c; i++) {
		memset(&tftp[i], 0, sizeof(tftp[i]));

		tftp[i][0].tuple.src.l3num = AF_INET;
		tftp[i][1].tuple.src.l3num = AF_INET6;
		for (j = 0; j < 2; j++) {
			tftp[i][j].tuple.dst.protonum = IPPROTO_UDP;
			tftp[i][j].tuple.src.u.udp.port = htons(ports[i]);
			tftp[i][j].expect_policy = &tftp_exp_policy;
			tftp[i][j].me = THIS_MODULE;
			tftp[i][j].help = tftp_help;

			tmpname = &tftp_names[i][j][0];
			if (ports[i] == TFTP_PORT)
				sprintf(tmpname, "tftp");
			else
				sprintf(tmpname, "tftp-%u", i);
			tftp[i][j].name = tmpname;

			ret = nf_conntrack_helper_register(&tftp[i][j]);
			if (ret) {
				printk(KERN_ERR "nf_ct_tftp: failed to register"
				       " helper for pf: %u port: %u\n",
					tftp[i][j].tuple.src.l3num, ports[i]);
				nf_conntrack_tftp_fini();
				return ret;
			}
		}
	}

	#ifdef CONFIG_CAMEO_ALG_TFTP
	//Xavier@20130515
	proc_tftp = create_proc_entry("tftp",0,NULL);
	if (proc_tftp)
	{
	    proc_tftp->read_proc		= tftp_read_proc;
	    proc_tftp->write_proc	= tftp_write_proc;
	}
	//End
	#endif

	return 0;
}
static int __init nf_conntrack_pptp_init(void)
{
	int rv;

	rv = nf_conntrack_helper_register(&pptp);
	if (rv < 0)
		return rv;
	rv = register_pernet_subsys(&nf_conntrack_pptp_net_ops);
	if (rv < 0)
		nf_conntrack_helper_unregister(&pptp);
	return rv;
}
Beispiel #8
0
static int __init nf_conntrack_h323_init(void)
{
	int ret;

	h323_buffer = kmalloc(65536, GFP_KERNEL);
	if (!h323_buffer)
		return -ENOMEM;
	ret = nf_conntrack_helper_register(&nf_conntrack_helper_h245);
	if (ret < 0)
		goto err1;
	ret = nf_conntrack_helper_register(&nf_conntrack_helper_q931[0]);
	if (ret < 0)
		goto err2;
	ret = nf_conntrack_helper_register(&nf_conntrack_helper_q931[1]);
	if (ret < 0)
		goto err3;
	ret = nf_conntrack_helper_register(&nf_conntrack_helper_ras[0]);
	if (ret < 0)
		goto err4;
	ret = nf_conntrack_helper_register(&nf_conntrack_helper_ras[1]);
	if (ret < 0)
		goto err5;
	pr_debug("nf_ct_h323: init success\n");
	return 0;

err5:
	nf_conntrack_helper_unregister(&nf_conntrack_helper_ras[0]);
err4:
	nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[1]);
err3:
	nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[0]);
err2:
	nf_conntrack_helper_unregister(&nf_conntrack_helper_h245);
err1:
	kfree(h323_buffer);
	return ret;
}
Beispiel #9
0
static int __init nf_conntrack_sane_init(void)
{
	int i, j = -1, ret = 0;
	char *tmpname;

	sane_buffer = kmalloc(65536, GFP_KERNEL);
	if (!sane_buffer)
		return -ENOMEM;

	if (ports_c == 0)
		ports[ports_c++] = SANE_PORT;

	/* FIXME should be configurable whether IPv4 and IPv6 connections
		 are tracked or not - YK */
	for (i = 0; i < ports_c; i++) {
		sane[i][0].tuple.src.l3num = PF_INET;
		sane[i][1].tuple.src.l3num = PF_INET6;
		for (j = 0; j < 2; j++) {
			sane[i][j].tuple.src.u.tcp.port = htons(ports[i]);
			sane[i][j].tuple.dst.protonum = IPPROTO_TCP;
			sane[i][j].mask.src.u.tcp.port = 0xFFFF;
			sane[i][j].mask.dst.protonum = 0xFF;
			sane[i][j].max_expected = 1;
			sane[i][j].timeout = 5 * 60;	/* 5 Minutes */
			sane[i][j].me = THIS_MODULE;
			sane[i][j].help = help;
			tmpname = &sane_names[i][j][0];
			if (ports[i] == SANE_PORT)
				sprintf(tmpname, "sane");
			else
				sprintf(tmpname, "sane-%d", ports[i]);
			sane[i][j].name = tmpname;

			DEBUGP("nf_ct_sane: registering helper for pf: %d "
			       "port: %d\n",
				sane[i][j].tuple.src.l3num, ports[i]);
			ret = nf_conntrack_helper_register(&sane[i][j]);
			if (ret) {
				printk(KERN_ERR "nf_ct_sane: failed to "
				       "register helper for pf: %d port: %d\n",
					sane[i][j].tuple.src.l3num, ports[i]);
				nf_conntrack_sane_fini();
				return ret;
			}
		}
	}

	return 0;
}
Beispiel #10
0
static int __init nf_conntrack_irc_init(void)
{
	int i, ret;
	char *tmpname;

	if (max_dcc_channels < 1) {
		printk(KERN_ERR "nf_ct_irc: max_dcc_channels must not be zero\n");
		return -EINVAL;
	}

	irc_exp_policy.max_expected = max_dcc_channels;
	irc_exp_policy.timeout = dcc_timeout;

	irc_buffer = kmalloc(65536, GFP_KERNEL);
	if (!irc_buffer)
		return -ENOMEM;

	/* If no port given, default to standard irc port */
	if (ports_c == 0)
		ports[ports_c++] = IRC_PORT;

	for (i = 0; i < ports_c; i++) {
		irc[i].tuple.src.l3num = AF_INET;
		irc[i].tuple.src.u.tcp.port = htons(ports[i]);
		irc[i].tuple.dst.protonum = IPPROTO_TCP;
		irc[i].expect_policy = &irc_exp_policy;
		irc[i].me = THIS_MODULE;
		irc[i].help = help;

		tmpname = &irc_names[i][0];
		if (ports[i] == IRC_PORT)
			sprintf(tmpname, "irc");
		else
			sprintf(tmpname, "irc-%u", i);
		irc[i].name = tmpname;

		ret = nf_conntrack_helper_register(&irc[i]);
		if (ret) {
			printk(KERN_ERR "nf_ct_irc: failed to register helper "
			       "for pf: %u port: %u\n",
			       irc[i].tuple.src.l3num, ports[i]);
			nf_conntrack_irc_fini();
			return ret;
		}
	}
	return 0;
}
Beispiel #11
0
static int __init nf_conntrack_sane_init(void)
{
	int i, j = -1, ret = 0;
	char *tmpname;

	sane_buffer = kmalloc(65536, GFP_KERNEL);
	if (!sane_buffer)
		return -ENOMEM;

	if (ports_c == 0)
		ports[ports_c++] = SANE_PORT;

	
	for (i = 0; i < ports_c; i++) {
		sane[i][0].tuple.src.l3num = PF_INET;
		sane[i][1].tuple.src.l3num = PF_INET6;
		for (j = 0; j < 2; j++) {
			sane[i][j].tuple.src.u.tcp.port = htons(ports[i]);
			sane[i][j].tuple.dst.protonum = IPPROTO_TCP;
			sane[i][j].expect_policy = &sane_exp_policy;
			sane[i][j].me = THIS_MODULE;
			sane[i][j].help = help;
			tmpname = &sane_names[i][j][0];
			if (ports[i] == SANE_PORT)
				sprintf(tmpname, "sane");
			else
				sprintf(tmpname, "sane-%d", ports[i]);
			sane[i][j].name = tmpname;

			pr_debug("nf_ct_sane: registering helper for pf: %d "
				 "port: %d\n",
				 sane[i][j].tuple.src.l3num, ports[i]);
			ret = nf_conntrack_helper_register(&sane[i][j]);
			if (ret) {
				printk(KERN_ERR "nf_ct_sane: failed to "
				       "register helper for pf: %d port: %d\n",
					sane[i][j].tuple.src.l3num, ports[i]);
				nf_conntrack_sane_fini();
				return ret;
			}
		}
	}

	return 0;
}
Beispiel #12
0
static int __init nf_conntrack_sl_init(void)
{
 
        int ret = 0;


#ifdef SL_DEBUG
        printk(KERN_DEBUG "Registering nf_conntrack_sl, port %d\n", SL_PORT);
#endif

        ret = nf_conntrack_helper_register(&sl_helper);
	if (ret < 0) {

	  printk(KERN_ERR "error registering module: %d\n\n", ret);
	  return ret;
	}

	return ret;
}
Beispiel #13
0
static int __init nf_conntrack_tftp_init(void)
{
	int i, j, ret;
	char *tmpname;

	if (ports_c == 0)
		ports[ports_c++] = TFTP_PORT;

	for (i = 0; i < ports_c; i++) {
		memset(&tftp[i], 0, sizeof(tftp[i]));

		tftp[i][0].tuple.src.l3num = AF_INET;
		tftp[i][1].tuple.src.l3num = AF_INET6;
		for (j = 0; j < 2; j++) {
			tftp[i][j].tuple.dst.protonum = IPPROTO_UDP;
			tftp[i][j].tuple.src.u.udp.port = htons(ports[i]);
			tftp[i][j].mask.src.l3num = 0xFFFF;
			tftp[i][j].mask.dst.protonum = 0xFF;
			tftp[i][j].mask.src.u.udp.port = htons(0xFFFF);
			tftp[i][j].max_expected = 1;
			tftp[i][j].timeout = 5 * 60; /* 5 minutes */
			tftp[i][j].me = THIS_MODULE;
			tftp[i][j].help = tftp_help;

			tmpname = &tftp_names[i][j][0];
			if (ports[i] == TFTP_PORT)
				sprintf(tmpname, "tftp");
			else
				sprintf(tmpname, "tftp-%u", i);
			tftp[i][j].name = tmpname;

			ret = nf_conntrack_helper_register(&tftp[i][j]);
			if (ret) {
				printk("nf_ct_tftp: failed to register helper "
				       "for pf: %u port: %u\n",
					tftp[i][j].tuple.src.l3num, ports[i]);
				nf_conntrack_tftp_fini();
				return ret;
			}
		}
	}
	return 0;
}
Beispiel #14
0
static int __init ip_autofw_init(void)
{
	int ret;

	autofw_helper.name = "autofw";
	autofw_helper.tuple.dst.u3.ip = 0xFFFFFFFF;
	autofw_helper.tuple.dst.protonum = 0xFF;
	autofw_helper.mask.dst.u3.ip = 0xFFFFFFFF;
	autofw_helper.mask.dst.protonum = 0xFF;
	autofw_helper.tuple.src.u3.ip = 0xFFFFFFFF;
	autofw_helper.me = THIS_MODULE;
	autofw_helper.timeout = 5 * 60;
	autofw_helper.help = autofw_help;

	ret = nf_conntrack_helper_register(&autofw_helper);
	if (ret)
		nf_conntrack_helper_unregister(&autofw_helper);

	return xt_register_target(&autofw);
}
Beispiel #15
0
static int __init nf_conntrack_dummy_init(void)
{
	int ret, i = 0;
	memset(helpme, 0, sizeof(struct helper_wrapper_t) * MAX_PORTS);
	if (0 == ports_c)
		ports[ports_c++] = DUMMY_PORT;
	for (i = 0; i < ports_c; ++i) {
		if (DUMMY_PORT == ports[i]) {
			snprintf(helpme[i].name, sizeof("dummy-65535"),
				"dummy");
		} else {
			snprintf(helpme[i].name, sizeof("dummy-65535"),
				"dummy-%u", ports[i]);
		}

		helpme[i].helper.name = helpme[i].name;
		helpme[i].helper.me = THIS_MODULE;
		helpme[i].helper.help = dummy_help;
		helpme[i].helper.tuple.src.l3num = AF_INET;
		helpme[i].helper.tuple.src.u.udp.port = htons(ports[i]);
		helpme[i].helper.tuple.dst.protonum = IPPROTO_UDP;

		/* obsoleted in new kernel, use nf_conntrack_expect_policy */
		//helpme[i].helper.max_expected = 0;
		//helpme[i].helper.timeout = EXPECTED_TIMEOUT;

		/* can be multiple policies: expect_policy[expect_class_max] */
		helpme[i].helper.expect_policy = &dummy_exp_policy;
		helpme[i].helper.expect_class_max = NF_CT_EXPECT_CLASS_DEFAULT;


		if ((ret = nf_conntrack_helper_register(&helpme[i].helper))) {
			nf_conntrack_dummy_fini();
			return ret;
		}
		printk(KERN_ALERT "[INFO] nf_conntrack_helper_register %u\n", ports[i]);
	}
	return 0;
}
Beispiel #16
0
static int __init nf_conntrack_pptp_init(void)
{
	return nf_conntrack_helper_register(&pptp);
}
Beispiel #17
0
static int __init nf_conntrack_snmp_init(void)
{
	exp_policy.timeout = timeout;
	return nf_conntrack_helper_register(&helper);
}