aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-03-25 23:24:57 -0400
committerDavid S. Miller <davem@davemloft.net>2008-03-25 23:24:57 -0400
commitc978cd3a937141deaf7995b849824af6dacdeae7 (patch)
treee5e86e630a5e103072a34cc0d9d6f8a1bcf53395 /net/ipv4
parent720ac7085ce815ea4caec24396575fed7bd711aa (diff)
[NETFILTER]: nf_nat_sip: translate all Contact headers
The SIP message may contain multiple Contact: addresses referring to the NATed endpoint, translate all of them. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/netfilter/nf_nat_sip.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c
index 71a4adcfd576..b443618a857f 100644
--- a/net/ipv4/netfilter/nf_nat_sip.c
+++ b/net/ipv4/netfilter/nf_nat_sip.c
@@ -101,10 +101,10 @@ static unsigned int ip_nat_sip(struct sk_buff *skb,
101 enum ip_conntrack_info ctinfo; 101 enum ip_conntrack_info ctinfo;
102 struct nf_conn *ct = nf_ct_get(skb, &ctinfo); 102 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
103 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); 103 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
104 unsigned int matchoff, matchlen; 104 unsigned int dataoff, matchoff, matchlen;
105 union nf_inet_addr addr; 105 union nf_inet_addr addr;
106 __be16 port; 106 __be16 port;
107 int request; 107 int request, in_header;
108 108
109 /* Basic rules: requests and responses. */ 109 /* Basic rules: requests and responses. */
110 if (strnicmp(*dptr, "SIP/2.0", strlen("SIP/2.0")) != 0) { 110 if (strnicmp(*dptr, "SIP/2.0", strlen("SIP/2.0")) != 0) {
@@ -187,9 +187,20 @@ static unsigned int ip_nat_sip(struct sk_buff *skb,
187 } 187 }
188 188
189next: 189next:
190 /* Translate Contact headers */
191 dataoff = 0;
192 in_header = 0;
193 while (ct_sip_parse_header_uri(ct, *dptr, &dataoff, *datalen,
194 SIP_HDR_CONTACT, &in_header,
195 &matchoff, &matchlen,
196 &addr, &port) > 0) {
197 if (!map_addr(skb, dptr, datalen, matchoff, matchlen,
198 &addr, port))
199 return NF_DROP;
200 }
201
190 if (!map_sip_addr(skb, dptr, datalen, SIP_HDR_FROM) || 202 if (!map_sip_addr(skb, dptr, datalen, SIP_HDR_FROM) ||
191 !map_sip_addr(skb, dptr, datalen, SIP_HDR_TO) || 203 !map_sip_addr(skb, dptr, datalen, SIP_HDR_TO))
192 !map_sip_addr(skb, dptr, datalen, SIP_HDR_CONTACT))
193 return NF_DROP; 204 return NF_DROP;
194 return NF_ACCEPT; 205 return NF_ACCEPT;
195} 206}