SIP conntrack-nat update.
PATCH 1/1 SIP conntrack-nat update.
Hi,
This adds some minor stylistic changes to my conntrack-nat SIP module.
Changed some return types and vars.
Next in my todo list is to provide some nfsim testsuite.
I'd be nice some help/feedback with testing. I tested with cisco (ATA
188) and linphone at the moment.
Please apply,
Signature · 1 line
Christian Hentschel <[email protected]>
linux-2.6.11/include/linux/netfilter_ipv4/ip_conntrack_sip.h +78 -0
@@ -0,0 +1,78 @@ +#ifndef __IP_CONNTRACK_SIP_H__ +#define __IP_CONNTRACK_SIP_H__ +/* SIP tracking. */ + +#ifdef __KERNEL__ + +#define SIP_PORT 5060 +#define SIP_TIMEOUT 3600 + +#define POS_VIA 0 +#define POS_CONTACT 1 +#define POS_CONTENT 2 +#define POS_MEDIA 3 +#define POS_OWNER 4 +#define POS_CONECTION 5 +#define POS_REQ_HEADER 6 +#define POS_SDP_HEADER 7 + +struct sip_header_nfo { +const char *lname; +size_t lnlen; +const char *sname; +size_t snlen; +const char *ln_str; +size_t ln_strlen; +int (*match_len)(const char *,const char *,int *); + +}; + +extern unsigned int (*ip_nat_sip_hook)(struct sk_buff **pskb, +enum ip_conntrack_info ctinfo, +struct ip_conntrack *ct, +const char **dptr); + +/* For NAT to hook in when on expect. */ +extern unsigned int (*ip_nat_sdp_hook)(struct sk_buff **pskb, +enum ip_conntrack_info ctinfo, +struct ip_conntrack_expect *exp, +const char *dptr); + +extern int ct_sip_get_info (const char *dptr,size_t dlen, +unsigned int *matchoff, +unsigned int *matchlen, +struct sip_header_nfo *hnfo); + +/* get line lenght until first CR or LF seen. */ +static __inline__int ct_sip_lnlen (const char *line,const char *limit) +{ +const char *k = line; + +while ((line <= limit) && (*line =='\r' || *line =='\n' )) + line++; + +while (line <= limit) { +if (*line =='\r' || *line =='\n' ) +break ; + line++; + } +return line - k; +} + +/* Linear string search, case sensitive. */ +static __inline__ +const char *ct_sip_search (const char *needle,const char *haystack, +size_t needle_len,size_t haystack_len) +{ +const char *limit = haystack + (haystack_len - needle_len); + +while (haystack <= limit) { +if (memcmp (haystack, needle, needle_len) ==0 ) +return haystack; + haystack++; + } +return NULL ; +} +#endif /* __KERNEL__ */ + +#endif /* __IP_CONNTRACK_SIP_H__ */
linux-2.6.11/net/ipv4/netfilter/Makefile.ladd +6 -0
@@ -0,0 +1,6 @@ +obj-$(CONFIG_IP_NF_CONNTRACK) += ip_conntrack.o + +# SIP support +obj-$(CONFIG_IP_NF_SIP) += ip_conntrack_sip.o +obj-$(CONFIG_IP_NF_NAT_SIP) += ip_nat_sip.o +
linux-2.6.11/net/ipv4/netfilter/Kconfig.ladd +18 -0
@@ -0,0 +1,18 @@ +config IP_NF_NAT_SIP + tristate + depends on IP_NF_CONNTRACK!=n && IP_NF_NAT!=n + default IP_NF_NAT if IP_NF_SIP=y + default m if IP_NF_SIP=m + +config IP_NF_SIP + tristate 'SIP support' + depends on IP_NF_CONNTRACK + help + SIP is an application-layer control protocol that can establish, + modify, and terminate multimedia sessions (conferences) such as + Internet telephony calls. With the ip_conntrack_sip and + the ip_nat_sip modules you can support the protocol on a connection + tracking/NATing firewall. + + If you want to compile it as a module, say 'M' here and read + Documentation/modules.txt. If unsure, say 'N'.
linux-2.6.11/net/ipv4/netfilter/ip_conntrack_sip.c +408 -0
408 lines not on this page · raw message
linux-2.6.11/net/ipv4/netfilter/ip_nat_sip.c +253 -0
253 lines not on this page · raw message
help +7 -0
@@ -0,0 +1,7 @@ +This adds CONFIG_IP_NF_SIP: SIP support module for netfilter +connection tracking and NAT. + +The SIP conntrack/NAT modules support the connection tracking/NATing of +the data streams requested on the dynamic RTP/RTCP ports, as well as mangling +of SIP requests/responses. +
info +5 -0
@@ -0,0 +1,5 @@ +Title: SIP connection tracking and NAT helper +Author: Christian Hentschel <[email protected]> +Status: Alpha +Repository: extra +Requires: linux-2.6 >= 2.6.11
Quoted 3 lines · Christian Hentschel
Hi,
This adds some minor stylistic changes to my conntrack-nat SIP module.
Changed some return types and vars.
grat news. I've now committed it to patch-o-matic-ng, although I didn't have that much time for review yet...
Quoted 1 line
Christian Hentschel <[email protected]>
Signature · 5 lines
- Harald Welte <[email protected]> http://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