diff options
author | Patrick McHardy <kaber@trash.net> | 2008-03-25 23:18:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-25 23:18:40 -0400 |
commit | ac3677406d4e36e86b1eb5a453997a3b3e0c089a (patch) | |
tree | f67f28c542cf7adfde72af692892b2156f30e922 /net/ipv4 | |
parent | 3e9b4600b4e71beaa9d943251bfe9c25f6a97b8c (diff) |
[NETFILTER]: nf_conntrack_sip: kill request URI "header" definitions
The request URI is not a header and needs to be treated differently than
real SIP headers. Add a seperate function for parsing it and get rid of
the POS_REQ_URI/POS_REG_REQ_URI definitions.
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.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c index aa8a4f492baf..60151b5901a5 100644 --- a/net/ipv4/netfilter/nf_nat_sip.c +++ b/net/ipv4/netfilter/nf_nat_sip.c | |||
@@ -78,20 +78,17 @@ static unsigned int mangle_packet(struct sk_buff *skb, | |||
78 | return 1; | 78 | return 1; |
79 | } | 79 | } |
80 | 80 | ||
81 | static int map_sip_addr(struct sk_buff *skb, | 81 | static int map_addr(struct sk_buff *skb, |
82 | const char **dptr, unsigned int *datalen, | 82 | const char **dptr, unsigned int *datalen, |
83 | enum sip_header_pos pos, struct addr_map *map) | 83 | unsigned int matchoff, unsigned int matchlen, |
84 | struct addr_map *map) | ||
84 | { | 85 | { |
85 | enum ip_conntrack_info ctinfo; | 86 | enum ip_conntrack_info ctinfo; |
86 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | 87 | struct nf_conn *ct __maybe_unused = nf_ct_get(skb, &ctinfo); |
87 | enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); | 88 | enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); |
88 | unsigned int matchlen, matchoff, addrlen; | 89 | unsigned int addrlen; |
89 | char *addr; | 90 | char *addr; |
90 | 91 | ||
91 | if (ct_sip_get_info(ct, *dptr, *datalen, &matchoff, &matchlen, | ||
92 | pos) <= 0) | ||
93 | return 1; | ||
94 | |||
95 | if ((matchlen == map->addr[dir].srciplen || | 92 | if ((matchlen == map->addr[dir].srciplen || |
96 | matchlen == map->addr[dir].srclen) && | 93 | matchlen == map->addr[dir].srclen) && |
97 | strncmp(*dptr + matchoff, map->addr[dir].src, matchlen) == 0) { | 94 | strncmp(*dptr + matchoff, map->addr[dir].src, matchlen) == 0) { |
@@ -109,13 +106,27 @@ static int map_sip_addr(struct sk_buff *skb, | |||
109 | addr, addrlen); | 106 | addr, addrlen); |
110 | } | 107 | } |
111 | 108 | ||
109 | static int map_sip_addr(struct sk_buff *skb, | ||
110 | const char **dptr, unsigned int *datalen, | ||
111 | enum sip_header_pos pos, struct addr_map *map) | ||
112 | { | ||
113 | enum ip_conntrack_info ctinfo; | ||
114 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | ||
115 | unsigned int matchlen, matchoff; | ||
116 | |||
117 | if (ct_sip_get_info(ct, *dptr, *datalen, &matchoff, &matchlen, | ||
118 | pos) <= 0) | ||
119 | return 1; | ||
120 | return map_addr(skb, dptr, datalen, matchoff, matchlen, map); | ||
121 | } | ||
122 | |||
112 | static unsigned int ip_nat_sip(struct sk_buff *skb, | 123 | static unsigned int ip_nat_sip(struct sk_buff *skb, |
113 | const char **dptr, unsigned int *datalen) | 124 | const char **dptr, unsigned int *datalen) |
114 | { | 125 | { |
115 | enum ip_conntrack_info ctinfo; | 126 | enum ip_conntrack_info ctinfo; |
116 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | 127 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
117 | enum sip_header_pos pos; | ||
118 | struct addr_map map; | 128 | struct addr_map map; |
129 | unsigned int matchoff, matchlen; | ||
119 | 130 | ||
120 | if (*datalen < strlen("SIP/2.0")) | 131 | if (*datalen < strlen("SIP/2.0")) |
121 | return NF_ACCEPT; | 132 | return NF_ACCEPT; |
@@ -124,18 +135,9 @@ static unsigned int ip_nat_sip(struct sk_buff *skb, | |||
124 | 135 | ||
125 | /* Basic rules: requests and responses. */ | 136 | /* Basic rules: requests and responses. */ |
126 | if (strnicmp(*dptr, "SIP/2.0", strlen("SIP/2.0")) != 0) { | 137 | if (strnicmp(*dptr, "SIP/2.0", strlen("SIP/2.0")) != 0) { |
127 | /* 10.2: Constructing the REGISTER Request: | 138 | if (ct_sip_parse_request(ct, *dptr, *datalen, |
128 | * | 139 | &matchoff, &matchlen) > 0 && |
129 | * The "userinfo" and "@" components of the SIP URI MUST NOT | 140 | !map_addr(skb, dptr, datalen, matchoff, matchlen, &map)) |
130 | * be present. | ||
131 | */ | ||
132 | if (*datalen >= strlen("REGISTER") && | ||
133 | strnicmp(*dptr, "REGISTER", strlen("REGISTER")) == 0) | ||
134 | pos = POS_REG_REQ_URI; | ||
135 | else | ||
136 | pos = POS_REQ_URI; | ||
137 | |||
138 | if (!map_sip_addr(skb, dptr, datalen, pos, &map)) | ||
139 | return NF_DROP; | 141 | return NF_DROP; |
140 | } | 142 | } |
141 | 143 | ||