]> bbs.cooldavid.org Git - net-next-2.6.git/blame - net/ipv4/netfilter/nf_nat_sip.c
netfilter: nf_conntrack_sip: pass data offset to NAT functions
[net-next-2.6.git] / net / ipv4 / netfilter / nf_nat_sip.c
CommitLineData
9fafcd7b
PM
1/* SIP extension for UDP NAT alteration.
2 *
3 * (C) 2005 by Christian Hentschel <chentschel@arnet.com.ar>
4 * based on RR's ip_nat_ftp.c and other modules.
f49e1aa1
PM
5 * (C) 2007 United Security Providers
6 * (C) 2007, 2008 Patrick McHardy <kaber@trash.net>
9fafcd7b
PM
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/skbuff.h>
15#include <linux/ip.h>
c9bdd4b5 16#include <net/ip.h>
9fafcd7b
PM
17#include <linux/udp.h>
18
19#include <net/netfilter/nf_nat.h>
20#include <net/netfilter/nf_nat_helper.h>
21#include <net/netfilter/nf_nat_rule.h>
22#include <net/netfilter/nf_conntrack_helper.h>
23#include <net/netfilter/nf_conntrack_expect.h>
24#include <linux/netfilter/nf_conntrack_sip.h>
25
26MODULE_LICENSE("GPL");
27MODULE_AUTHOR("Christian Hentschel <chentschel@arnet.com.ar>");
28MODULE_DESCRIPTION("SIP NAT helper");
29MODULE_ALIAS("ip_nat_sip");
30
9fafcd7b 31
3b6b9fab 32static unsigned int mangle_packet(struct sk_buff *skb, unsigned int dataoff,
2a6cfb22
PM
33 const char **dptr, unsigned int *datalen,
34 unsigned int matchoff, unsigned int matchlen,
35 const char *buffer, unsigned int buflen)
36{
37 enum ip_conntrack_info ctinfo;
38 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
39
40 if (!nf_nat_mangle_udp_packet(skb, ct, ctinfo, matchoff, matchlen,
41 buffer, buflen))
42 return 0;
43
44 /* Reload data pointer and adjust datalen value */
3b6b9fab 45 *dptr = skb->data + dataoff;
2a6cfb22
PM
46 *datalen += buflen - matchlen;
47 return 1;
48}
49
3b6b9fab 50static int map_addr(struct sk_buff *skb, unsigned int dataoff,
ac367740
PM
51 const char **dptr, unsigned int *datalen,
52 unsigned int matchoff, unsigned int matchlen,
624f8b7b 53 union nf_inet_addr *addr, __be16 port)
9fafcd7b 54{
212440a7 55 enum ip_conntrack_info ctinfo;
624f8b7b 56 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
9fafcd7b 57 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
624f8b7b
PM
58 char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
59 unsigned int buflen;
60 __be32 newaddr;
61 __be16 newport;
62
63 if (ct->tuplehash[dir].tuple.src.u3.ip == addr->ip &&
64 ct->tuplehash[dir].tuple.src.u.udp.port == port) {
65 newaddr = ct->tuplehash[!dir].tuple.dst.u3.ip;
66 newport = ct->tuplehash[!dir].tuple.dst.u.udp.port;
67 } else if (ct->tuplehash[dir].tuple.dst.u3.ip == addr->ip &&
68 ct->tuplehash[dir].tuple.dst.u.udp.port == port) {
69 newaddr = ct->tuplehash[!dir].tuple.src.u3.ip;
70 newport = ct->tuplehash[!dir].tuple.src.u.udp.port;
9fafcd7b
PM
71 } else
72 return 1;
73
624f8b7b
PM
74 if (newaddr == addr->ip && newport == port)
75 return 1;
76
cffee385 77 buflen = sprintf(buffer, "%pI4:%u", &newaddr, ntohs(newport));
624f8b7b 78
3b6b9fab 79 return mangle_packet(skb, dataoff, dptr, datalen, matchoff, matchlen,
624f8b7b 80 buffer, buflen);
9fafcd7b
PM
81}
82
3b6b9fab 83static int map_sip_addr(struct sk_buff *skb, unsigned int dataoff,
ac367740 84 const char **dptr, unsigned int *datalen,
624f8b7b 85 enum sip_header_types type)
ac367740
PM
86{
87 enum ip_conntrack_info ctinfo;
88 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
89 unsigned int matchlen, matchoff;
624f8b7b
PM
90 union nf_inet_addr addr;
91 __be16 port;
ac367740 92
624f8b7b
PM
93 if (ct_sip_parse_header_uri(ct, *dptr, NULL, *datalen, type, NULL,
94 &matchoff, &matchlen, &addr, &port) <= 0)
ac367740 95 return 1;
3b6b9fab
PM
96 return map_addr(skb, dataoff, dptr, datalen, matchoff, matchlen,
97 &addr, port);
ac367740
PM
98}
99
3b6b9fab 100static unsigned int ip_nat_sip(struct sk_buff *skb, unsigned int dataoff,
2a6cfb22 101 const char **dptr, unsigned int *datalen)
9fafcd7b 102{
212440a7
PM
103 enum ip_conntrack_info ctinfo;
104 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
720ac708 105 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
3b6b9fab 106 unsigned int coff, matchoff, matchlen;
624f8b7b
PM
107 union nf_inet_addr addr;
108 __be16 port;
c978cd3a 109 int request, in_header;
9fafcd7b 110
9fafcd7b 111 /* Basic rules: requests and responses. */
779382eb 112 if (strnicmp(*dptr, "SIP/2.0", strlen("SIP/2.0")) != 0) {
ac367740 113 if (ct_sip_parse_request(ct, *dptr, *datalen,
624f8b7b
PM
114 &matchoff, &matchlen,
115 &addr, &port) > 0 &&
3b6b9fab 116 !map_addr(skb, dataoff, dptr, datalen, matchoff, matchlen,
624f8b7b 117 &addr, port))
9fafcd7b 118 return NF_DROP;
720ac708
PM
119 request = 1;
120 } else
121 request = 0;
122
123 /* Translate topmost Via header and parameters */
124 if (ct_sip_parse_header_uri(ct, *dptr, NULL, *datalen,
125 SIP_HDR_VIA, NULL, &matchoff, &matchlen,
126 &addr, &port) > 0) {
127 unsigned int matchend, poff, plen, buflen, n;
128 char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
129
130 /* We're only interested in headers related to this
131 * connection */
132 if (request) {
133 if (addr.ip != ct->tuplehash[dir].tuple.src.u3.ip ||
134 port != ct->tuplehash[dir].tuple.src.u.udp.port)
135 goto next;
136 } else {
137 if (addr.ip != ct->tuplehash[dir].tuple.dst.u3.ip ||
138 port != ct->tuplehash[dir].tuple.dst.u.udp.port)
139 goto next;
140 }
141
3b6b9fab 142 if (!map_addr(skb, dataoff, dptr, datalen, matchoff, matchlen,
720ac708
PM
143 &addr, port))
144 return NF_DROP;
145
146 matchend = matchoff + matchlen;
147
148 /* The maddr= parameter (RFC 2361) specifies where to send
149 * the reply. */
150 if (ct_sip_parse_address_param(ct, *dptr, matchend, *datalen,
151 "maddr=", &poff, &plen,
152 &addr) > 0 &&
153 addr.ip == ct->tuplehash[dir].tuple.src.u3.ip &&
154 addr.ip != ct->tuplehash[!dir].tuple.dst.u3.ip) {
cffee385
HH
155 buflen = sprintf(buffer, "%pI4",
156 &ct->tuplehash[!dir].tuple.dst.u3.ip);
3b6b9fab
PM
157 if (!mangle_packet(skb, dataoff, dptr, datalen,
158 poff, plen, buffer, buflen))
720ac708
PM
159 return NF_DROP;
160 }
161
162 /* The received= parameter (RFC 2361) contains the address
163 * from which the server received the request. */
164 if (ct_sip_parse_address_param(ct, *dptr, matchend, *datalen,
165 "received=", &poff, &plen,
166 &addr) > 0 &&
167 addr.ip == ct->tuplehash[dir].tuple.dst.u3.ip &&
168 addr.ip != ct->tuplehash[!dir].tuple.src.u3.ip) {
cffee385
HH
169 buflen = sprintf(buffer, "%pI4",
170 &ct->tuplehash[!dir].tuple.src.u3.ip);
3b6b9fab
PM
171 if (!mangle_packet(skb, dataoff, dptr, datalen,
172 poff, plen, buffer, buflen))
720ac708
PM
173 return NF_DROP;
174 }
175
176 /* The rport= parameter (RFC 3581) contains the port number
177 * from which the server received the request. */
178 if (ct_sip_parse_numerical_param(ct, *dptr, matchend, *datalen,
179 "rport=", &poff, &plen,
180 &n) > 0 &&
181 htons(n) == ct->tuplehash[dir].tuple.dst.u.udp.port &&
182 htons(n) != ct->tuplehash[!dir].tuple.src.u.udp.port) {
183 __be16 p = ct->tuplehash[!dir].tuple.src.u.udp.port;
184 buflen = sprintf(buffer, "%u", ntohs(p));
3b6b9fab
PM
185 if (!mangle_packet(skb, dataoff, dptr, datalen,
186 poff, plen, buffer, buflen))
720ac708
PM
187 return NF_DROP;
188 }
9fafcd7b
PM
189 }
190
720ac708 191next:
c978cd3a 192 /* Translate Contact headers */
3b6b9fab 193 coff = 0;
c978cd3a 194 in_header = 0;
3b6b9fab 195 while (ct_sip_parse_header_uri(ct, *dptr, &coff, *datalen,
c978cd3a
PM
196 SIP_HDR_CONTACT, &in_header,
197 &matchoff, &matchlen,
198 &addr, &port) > 0) {
3b6b9fab 199 if (!map_addr(skb, dataoff, dptr, datalen, matchoff, matchlen,
c978cd3a
PM
200 &addr, port))
201 return NF_DROP;
202 }
203
3b6b9fab
PM
204 if (!map_sip_addr(skb, dataoff, dptr, datalen, SIP_HDR_FROM) ||
205 !map_sip_addr(skb, dataoff, dptr, datalen, SIP_HDR_TO))
9fafcd7b
PM
206 return NF_DROP;
207 return NF_ACCEPT;
208}
209
0f32a40f
PM
210/* Handles expected signalling connections and media streams */
211static void ip_nat_sip_expected(struct nf_conn *ct,
212 struct nf_conntrack_expect *exp)
213{
214 struct nf_nat_range range;
215
216 /* This must be a fresh one. */
217 BUG_ON(ct->status & IPS_NAT_DONE_MASK);
218
219 /* For DST manip, map port here to where it's expected. */
220 range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED);
221 range.min = range.max = exp->saved_proto;
222 range.min_ip = range.max_ip = exp->saved_ip;
223 nf_nat_setup_info(ct, &range, IP_NAT_MANIP_DST);
224
225 /* Change src to where master sends to, but only if the connection
226 * actually came from the same source. */
227 if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip ==
228 ct->master->tuplehash[exp->dir].tuple.src.u3.ip) {
229 range.flags = IP_NAT_RANGE_MAP_IPS;
230 range.min_ip = range.max_ip
231 = ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip;
232 nf_nat_setup_info(ct, &range, IP_NAT_MANIP_SRC);
233 }
234}
235
3b6b9fab 236static unsigned int ip_nat_sip_expect(struct sk_buff *skb, unsigned int dataoff,
0f32a40f
PM
237 const char **dptr, unsigned int *datalen,
238 struct nf_conntrack_expect *exp,
239 unsigned int matchoff,
240 unsigned int matchlen)
241{
242 enum ip_conntrack_info ctinfo;
243 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
244 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
245 __be32 newip;
246 u_int16_t port;
247 char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
248 unsigned buflen;
249
250 /* Connection will come from reply */
251 if (ct->tuplehash[dir].tuple.src.u3.ip == ct->tuplehash[!dir].tuple.dst.u3.ip)
252 newip = exp->tuple.dst.u3.ip;
253 else
254 newip = ct->tuplehash[!dir].tuple.dst.u3.ip;
255
256 /* If the signalling port matches the connection's source port in the
257 * original direction, try to use the destination port in the opposite
258 * direction. */
259 if (exp->tuple.dst.u.udp.port ==
260 ct->tuplehash[dir].tuple.src.u.udp.port)
261 port = ntohs(ct->tuplehash[!dir].tuple.dst.u.udp.port);
262 else
263 port = ntohs(exp->tuple.dst.u.udp.port);
264
265 exp->saved_ip = exp->tuple.dst.u3.ip;
266 exp->tuple.dst.u3.ip = newip;
267 exp->saved_proto.udp.port = exp->tuple.dst.u.udp.port;
268 exp->dir = !dir;
269 exp->expectfn = ip_nat_sip_expected;
270
271 for (; port != 0; port++) {
272 exp->tuple.dst.u.udp.port = htons(port);
273 if (nf_ct_expect_related(exp) == 0)
274 break;
275 }
276
277 if (port == 0)
278 return NF_DROP;
279
280 if (exp->tuple.dst.u3.ip != exp->saved_ip ||
281 exp->tuple.dst.u.udp.port != exp->saved_proto.udp.port) {
cffee385 282 buflen = sprintf(buffer, "%pI4:%u", &newip, port);
3b6b9fab
PM
283 if (!mangle_packet(skb, dataoff, dptr, datalen,
284 matchoff, matchlen, buffer, buflen))
0f32a40f
PM
285 goto err;
286 }
287 return NF_ACCEPT;
288
289err:
290 nf_ct_unexpect_related(exp);
291 return NF_DROP;
292}
293
3b6b9fab 294static int mangle_content_len(struct sk_buff *skb, unsigned int dataoff,
3e9b4600 295 const char **dptr, unsigned int *datalen)
9fafcd7b 296{
212440a7
PM
297 enum ip_conntrack_info ctinfo;
298 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
3e9b4600
PM
299 unsigned int matchoff, matchlen;
300 char buffer[sizeof("65536")];
301 int buflen, c_len;
9fafcd7b 302
3e9b4600
PM
303 /* Get actual SDP length */
304 if (ct_sip_get_sdp_header(ct, *dptr, 0, *datalen,
305 SDP_HDR_VERSION, SDP_HDR_UNSPEC,
306 &matchoff, &matchlen) <= 0)
307 return 0;
308 c_len = *datalen - matchoff + strlen("v=");
309
310 /* Now, update SDP length */
ea45f12a
PM
311 if (ct_sip_get_header(ct, *dptr, 0, *datalen, SIP_HDR_CONTENT_LENGTH,
312 &matchoff, &matchlen) <= 0)
9fafcd7b
PM
313 return 0;
314
3e9b4600 315 buflen = sprintf(buffer, "%u", c_len);
3b6b9fab 316 return mangle_packet(skb, dataoff, dptr, datalen, matchoff, matchlen,
3e9b4600 317 buffer, buflen);
9fafcd7b
PM
318}
319
3b6b9fab
PM
320static int mangle_sdp_packet(struct sk_buff *skb, unsigned int dataoff,
321 const char **dptr, unsigned int *datalen,
322 unsigned int sdpoff,
c71529e4
HX
323 enum sdp_header_types type,
324 enum sdp_header_types term,
325 char *buffer, int buflen)
9fafcd7b 326{
212440a7
PM
327 enum ip_conntrack_info ctinfo;
328 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
3e9b4600 329 unsigned int matchlen, matchoff;
9fafcd7b 330
3b6b9fab 331 if (ct_sip_get_sdp_header(ct, *dptr, sdpoff, *datalen, type, term,
3e9b4600 332 &matchoff, &matchlen) <= 0)
c71529e4 333 return -ENOENT;
3b6b9fab 334 return mangle_packet(skb, dataoff, dptr, datalen, matchoff, matchlen,
c71529e4 335 buffer, buflen) ? 0 : -EINVAL;
9fafcd7b
PM
336}
337
3b6b9fab
PM
338static unsigned int ip_nat_sdp_addr(struct sk_buff *skb, unsigned int dataoff,
339 const char **dptr, unsigned int *datalen,
340 unsigned int sdpoff,
4ab9e64e
PM
341 enum sdp_header_types type,
342 enum sdp_header_types term,
343 const union nf_inet_addr *addr)
9fafcd7b
PM
344{
345 char buffer[sizeof("nnn.nnn.nnn.nnn")];
4ab9e64e 346 unsigned int buflen;
9fafcd7b 347
cffee385 348 buflen = sprintf(buffer, "%pI4", &addr->ip);
3b6b9fab 349 if (mangle_sdp_packet(skb, dataoff, dptr, datalen, sdpoff, type, term,
c71529e4 350 buffer, buflen))
9fafcd7b
PM
351 return 0;
352
3b6b9fab 353 return mangle_content_len(skb, dataoff, dptr, datalen);
4ab9e64e
PM
354}
355
3b6b9fab
PM
356static unsigned int ip_nat_sdp_port(struct sk_buff *skb, unsigned int dataoff,
357 const char **dptr, unsigned int *datalen,
4ab9e64e
PM
358 unsigned int matchoff,
359 unsigned int matchlen,
360 u_int16_t port)
361{
362 char buffer[sizeof("nnnnn")];
363 unsigned int buflen;
364
365 buflen = sprintf(buffer, "%u", port);
3b6b9fab 366 if (!mangle_packet(skb, dataoff, dptr, datalen, matchoff, matchlen,
4ab9e64e 367 buffer, buflen))
9fafcd7b
PM
368 return 0;
369
3b6b9fab 370 return mangle_content_len(skb, dataoff, dptr, datalen);
4ab9e64e
PM
371}
372
3b6b9fab
PM
373static unsigned int ip_nat_sdp_session(struct sk_buff *skb, unsigned int dataoff,
374 const char **dptr, unsigned int *datalen,
375 unsigned int sdpoff,
4ab9e64e
PM
376 const union nf_inet_addr *addr)
377{
378 char buffer[sizeof("nnn.nnn.nnn.nnn")];
379 unsigned int buflen;
380
381 /* Mangle session description owner and contact addresses */
cffee385 382 buflen = sprintf(buffer, "%pI4", &addr->ip);
3b6b9fab 383 if (mangle_sdp_packet(skb, dataoff, dptr, datalen, sdpoff,
4ab9e64e
PM
384 SDP_HDR_OWNER_IP4, SDP_HDR_MEDIA,
385 buffer, buflen))
386 return 0;
387
3b6b9fab 388 switch (mangle_sdp_packet(skb, dataoff, dptr, datalen, sdpoff,
c71529e4
HX
389 SDP_HDR_CONNECTION_IP4, SDP_HDR_MEDIA,
390 buffer, buflen)) {
391 case 0:
392 /*
393 * RFC 2327:
394 *
395 * Session description
396 *
397 * c=* (connection information - not required if included in all media)
398 */
399 case -ENOENT:
400 break;
401 default:
9fafcd7b 402 return 0;
c71529e4 403 }
9fafcd7b 404
3b6b9fab 405 return mangle_content_len(skb, dataoff, dptr, datalen);
9fafcd7b
PM
406}
407
408/* So, this packet has hit the connection tracking matching code.
409 Mangle it, and change the expectation to match the new version. */
3b6b9fab
PM
410static unsigned int ip_nat_sdp_media(struct sk_buff *skb, unsigned int dataoff,
411 const char **dptr, unsigned int *datalen,
4ab9e64e
PM
412 struct nf_conntrack_expect *rtp_exp,
413 struct nf_conntrack_expect *rtcp_exp,
414 unsigned int mediaoff,
415 unsigned int medialen,
416 union nf_inet_addr *rtp_addr)
9fafcd7b 417{
212440a7
PM
418 enum ip_conntrack_info ctinfo;
419 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
9fafcd7b 420 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
9fafcd7b
PM
421 u_int16_t port;
422
9fafcd7b 423 /* Connection will come from reply */
f4a607bf
JB
424 if (ct->tuplehash[dir].tuple.src.u3.ip ==
425 ct->tuplehash[!dir].tuple.dst.u3.ip)
4ab9e64e 426 rtp_addr->ip = rtp_exp->tuple.dst.u3.ip;
f4a607bf 427 else
4ab9e64e 428 rtp_addr->ip = ct->tuplehash[!dir].tuple.dst.u3.ip;
9fafcd7b 429
a9c1d359 430 rtp_exp->saved_ip = rtp_exp->tuple.dst.u3.ip;
4ab9e64e 431 rtp_exp->tuple.dst.u3.ip = rtp_addr->ip;
a9c1d359
PM
432 rtp_exp->saved_proto.udp.port = rtp_exp->tuple.dst.u.udp.port;
433 rtp_exp->dir = !dir;
434 rtp_exp->expectfn = ip_nat_sip_expected;
435
436 rtcp_exp->saved_ip = rtcp_exp->tuple.dst.u3.ip;
4ab9e64e 437 rtcp_exp->tuple.dst.u3.ip = rtp_addr->ip;
a9c1d359
PM
438 rtcp_exp->saved_proto.udp.port = rtcp_exp->tuple.dst.u.udp.port;
439 rtcp_exp->dir = !dir;
440 rtcp_exp->expectfn = ip_nat_sip_expected;
441
442 /* Try to get same pair of ports: if not, try to change them. */
443 for (port = ntohs(rtp_exp->tuple.dst.u.udp.port);
444 port != 0; port += 2) {
445 rtp_exp->tuple.dst.u.udp.port = htons(port);
446 if (nf_ct_expect_related(rtp_exp) != 0)
447 continue;
448 rtcp_exp->tuple.dst.u.udp.port = htons(port + 1);
449 if (nf_ct_expect_related(rtcp_exp) == 0)
9fafcd7b 450 break;
a9c1d359 451 nf_ct_unexpect_related(rtp_exp);
9fafcd7b
PM
452 }
453
454 if (port == 0)
4ab9e64e
PM
455 goto err1;
456
457 /* Update media port. */
458 if (rtp_exp->tuple.dst.u.udp.port != rtp_exp->saved_proto.udp.port &&
3b6b9fab
PM
459 !ip_nat_sdp_port(skb, dataoff, dptr, datalen,
460 mediaoff, medialen, port))
4ab9e64e 461 goto err2;
9fafcd7b 462
9fafcd7b 463 return NF_ACCEPT;
4ab9e64e
PM
464
465err2:
466 nf_ct_unexpect_related(rtp_exp);
467 nf_ct_unexpect_related(rtcp_exp);
468err1:
469 return NF_DROP;
9fafcd7b
PM
470}
471
472static void __exit nf_nat_sip_fini(void)
473{
474 rcu_assign_pointer(nf_nat_sip_hook, NULL);
0f32a40f 475 rcu_assign_pointer(nf_nat_sip_expect_hook, NULL);
4ab9e64e 476 rcu_assign_pointer(nf_nat_sdp_addr_hook, NULL);
c7f485ab 477 rcu_assign_pointer(nf_nat_sdp_port_hook, NULL);
4ab9e64e
PM
478 rcu_assign_pointer(nf_nat_sdp_session_hook, NULL);
479 rcu_assign_pointer(nf_nat_sdp_media_hook, NULL);
9fafcd7b
PM
480 synchronize_rcu();
481}
482
483static int __init nf_nat_sip_init(void)
484{
d1332e0a 485 BUG_ON(nf_nat_sip_hook != NULL);
0f32a40f 486 BUG_ON(nf_nat_sip_expect_hook != NULL);
4ab9e64e 487 BUG_ON(nf_nat_sdp_addr_hook != NULL);
c7f485ab 488 BUG_ON(nf_nat_sdp_port_hook != NULL);
4ab9e64e
PM
489 BUG_ON(nf_nat_sdp_session_hook != NULL);
490 BUG_ON(nf_nat_sdp_media_hook != NULL);
9fafcd7b 491 rcu_assign_pointer(nf_nat_sip_hook, ip_nat_sip);
0f32a40f 492 rcu_assign_pointer(nf_nat_sip_expect_hook, ip_nat_sip_expect);
4ab9e64e 493 rcu_assign_pointer(nf_nat_sdp_addr_hook, ip_nat_sdp_addr);
c7f485ab 494 rcu_assign_pointer(nf_nat_sdp_port_hook, ip_nat_sdp_port);
4ab9e64e
PM
495 rcu_assign_pointer(nf_nat_sdp_session_hook, ip_nat_sdp_session);
496 rcu_assign_pointer(nf_nat_sdp_media_hook, ip_nat_sdp_media);
9fafcd7b
PM
497 return 0;
498}
499
500module_init(nf_nat_sip_init);
501module_exit(nf_nat_sip_fini);