ALGs
Good day,
Some doubts about the conntrack helper module.
1. For the "help" callback, what exactly am I suppose to do with the packets when this function is activated?
2. For the netbios protocol, there are a couple of ports to monitor, such as 137 for name-service, 138 for datagram service, 139 for session service. Does that mean I have to write 3 different tracking modules or do I follow what has been done in the ftp module...i.e register the 3 different ports to track.
3. In the corresponding header files, what do we normally have to define for the various structure? I kinda got confused by what I have read from the source code!
4. How do I get to the payload part where the netbios data-fields are?
Please pardon me if my questions do seems silly to you guys.
Ricky
----Original Message Follows----
From: Harald Welte <[email protected]>
To: Ricky Foo <[email protected]>
CC: [email protected]
Subject: Re: ALGs
Date: Tue, 3 Jun 2003 12:26:51 +0200
Quoted 5 lines · Ricky Foo
Hi guys,
I am new to this list. Currently, I need to develop a ALG for netbios but i can't seems to find the source-code anywhere in the kernel directory. Can anybody lend a helping hand?
for examples see:/usr/src/linux/net/ipv4/netfilter/ip_{conntrack,nat}_{ftp,irc}.c /usr/src/linux/include/linux/netfilter_ipv4/ip_{conntrack,nat}_{ftp,irc}.h
please also note the newnat-summary.txt from CVS and the outdated netfilter hacking howto - as well as lots of other conntrack/NAT helper modules in patch-o-matic.
Quoted 2 lines
Hopefully I can contribute the code back when I am finished since there aren't any ALG for netbios if I am not wrong.
No, there are none. We're always happy about contributions.
Quoted 2 lines
Thanks.
Ricky
--
- Harald Welte <[email protected]> http://www.netfilter.org/
============================================================================
"Fragmentation is like classful addressing -- an interesting early
architectural error that shows how much experimentation was going
on while IP was being designed." -- Paul Vixie
<< attach3 >>
_________________________________________________________________
Send a fun phone greeting to your friend! http://www.msn.com.sg/mobile/fungreetings/
Quoted 3 lines · Ricky Foo
Good day,
Some doubts about the conntrack helper module.
There are quite a few examples, even for complex protocols like h323, so please try to find your answers
Quoted 2 lines
1. For the "help" callback, what exactly am I suppose to do with the packets when this function is activated?
That totally depends on your protocol. The most important thing is to find out which other (slave/sibling) connections are going to be established and call ip_conntrack_expect_related() accordingly.
Quoted 5 lines
2. For the netbios protocol, there are a couple of ports to monitor, such as 137 for name-service, 138 for datagram service, 139 for session service. Does that mean I have to write 3 different tracking modules or do I follow what has been done in the ftp module...i.e register the 3 different ports to track.
That again depends on your protocol. I think the packet formats on all three ports are different, aren't they? So you write one module that registers three helpers (with different help() functions).
Quoted 3 lines
3. In the corresponding header files, what do we normally have to define for the various structure? I kinda got confused by what I have read from the source code!
Again, protocol dependant.
Quoted 1 line
4. How do I get to the payload part where the netbios data-fields are?
just read the packet. Again, there are quite a lot of examples. Just look at ip_conntrack_amanda.c:help()
struct udphdr *udph = (void *)iph + iph->ihl * 4;
u_int32_t udplen = len - iph->ihl * 4;
u_int32_t datalen = udplen - sizeof(struct udphdr);
char *data = (char *)udph + sizeof(struct udphdr);Quoted 1 line
Please pardon me if my questions do seems silly to you guys.
No, they are not. But please try to find out as much as possible by reading the examples.
Good luck!
Quoted 1 line
Ricky
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
Hello Ricky,
Quoted 1 line
Some doubts about the conntrack helper module.
A note: I have not written helper modules myself; the following answers are from what I learned passively.
Quoted 2 lines
1. For the "help" callback, what exactly am I suppose to do with the packets when this function is activated?
Find and update state information according to the packet's content, make neccessary modifications to the packet, or the packet metadata. All according to what your special protocol needs.
Quoted 5 lines
2. For the netbios protocol, there are a couple of ports to monitor, such as 137 for name-service, 138 for datagram service, 139 for session service. Does that mean I have to write 3 different tracking modules or do I follow what has been done in the ftp module...i.e register the 3 different ports to track.
Is it conceivable that people would like to use only a subset of the possible combinations of those three protocols? If the answer is "yes", then it may make good sense to implement three separate modules.
If the answer is "no, never", and you are a believer in such absolutes, then throw it all into one file.
Quoted 3 lines
3. In the corresponding header files, what do we normally have to define for the various structure? I kinda got confused by what I have read from the source code!
If you don't need to keep any state, you shouldn't need to define any structure in your header files.
If you do need to keep per-connection structure, look into the header file include/linux/netfilter_ipv4/ip_conntrack.h. Search for the definition of 'struct ip_conntrack'. Look at the 'union {} help' inside that struct. You are supposed to add another struct, defined by yourself, into this union.
Quoted 1 line
4. How do I get to the payload part where the netbios data-fields are?
Look at how other help() implementations do it. For example, in the ftp protocol helper, the first line of the help() function reads
struct tcphdr *tcph = (void *)iph + iph->ihl * 4;
'iph' is the IP (layer 3) protocol header. This line uses the IP header length field to get a pointer to the first byte of layer 4 data. You need practically the same, but probably casting into a 'struct udphdr', instead of a 'struct tcphdr'.
Quoted 1 line
Please pardon me if my questions do seems silly to you guys.
They do seem unoriented, but that's quite normal for people who meet a significant blob of software for the first time. I hope I could help you along a bit.
best regards
Patrick