#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
#include <linux/netfilter_ipv4/ip_conntrack_tftp.h>
+#include <linux/moduleparam.h>
MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
MODULE_DESCRIPTION("tftp connection tracking helper");
#define MAX_PORTS 8
static int ports[MAX_PORTS];
static int ports_c;
-MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
+module_param_array(ports, int, ports_c, 0400);
MODULE_PARM_DESC(ports, "port numbers of tftp servers");
#if 0
struct ip_conntrack *ct,
enum ip_conntrack_info ctinfo)
{
- struct tftphdr tftph;
+ struct tftphdr _tftph, *tfh;
struct ip_conntrack_expect *exp;
- if (skb_copy_bits(skb, skb->nh.iph->ihl * 4 + sizeof(struct udphdr),
- &tftph, sizeof(tftph)) != 0)
+ tfh = skb_header_pointer(skb,
+ skb->nh.iph->ihl * 4 + sizeof(struct udphdr),
+ sizeof(_tftph), &_tftph);
+ if (tfh == NULL)
return NF_ACCEPT;
- switch (ntohs(tftph.opcode)) {
+ switch (ntohs(tfh->opcode)) {
/* RRQ and WRQ works the same way */
case TFTP_OPCODE_READ:
case TFTP_OPCODE_WRITE:
int i, ret;
char *tmpname;
- if (!ports[0])
- ports[0]=TFTP_PORT;
+ if (ports_c == 0)
+ ports[ports_c++] = TFTP_PORT;
- for (i = 0 ; (i < MAX_PORTS) && ports[i] ; i++) {
+ for (i = 0; i < ports_c; i++) {
/* Create helper structure */
memset(&tftp[i], 0, sizeof(struct ip_conntrack_helper));
fini();
return(ret);
}
- ports_c++;
}
return(0);
}