nf_nat_sip.c 17.1 KB
Newer Older
1
/* SIP extension for NAT alteration.
2
3
4
 *
 * (C) 2005 by Christian Hentschel <chentschel@arnet.com.ar>
 * based on RR's ip_nat_ftp.c and other modules.
5
6
 * (C) 2007 United Security Providers
 * (C) 2007, 2008 Patrick McHardy <kaber@trash.net>
7
8
9
10
11
12
13
14
15
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/ip.h>
16
#include <net/ip.h>
17
#include <linux/udp.h>
18
#include <linux/tcp.h>
19
20
21
22
23
24
25
26
27
28
29
30
31
32

#include <net/netfilter/nf_nat.h>
#include <net/netfilter/nf_nat_helper.h>
#include <net/netfilter/nf_nat_rule.h>
#include <net/netfilter/nf_conntrack_helper.h>
#include <net/netfilter/nf_conntrack_expect.h>
#include <linux/netfilter/nf_conntrack_sip.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Christian Hentschel <chentschel@arnet.com.ar>");
MODULE_DESCRIPTION("SIP NAT helper");
MODULE_ALIAS("ip_nat_sip");


33
static unsigned int mangle_packet(struct sk_buff *skb, unsigned int dataoff,
34
35
36
37
38
39
				  const char **dptr, unsigned int *datalen,
				  unsigned int matchoff, unsigned int matchlen,
				  const char *buffer, unsigned int buflen)
{
	enum ip_conntrack_info ctinfo;
	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
	struct tcphdr *th;
	unsigned int baseoff;

	if (nf_ct_protonum(ct) == IPPROTO_TCP) {
		th = (struct tcphdr *)(skb->data + ip_hdrlen(skb));
		baseoff = ip_hdrlen(skb) + th->doff * 4;
		matchoff += dataoff - baseoff;

		if (!__nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
						matchoff, matchlen,
						buffer, buflen, false))
			return 0;
	} else {
		baseoff = ip_hdrlen(skb) + sizeof(struct udphdr);
		matchoff += dataoff - baseoff;

		if (!nf_nat_mangle_udp_packet(skb, ct, ctinfo,
					      matchoff, matchlen,
					      buffer, buflen))
			return 0;
	}
61
62

	/* Reload data pointer and adjust datalen value */
63
	*dptr = skb->data + dataoff;
64
65
66
67
	*datalen += buflen - matchlen;
	return 1;
}

68
static int map_addr(struct sk_buff *skb, unsigned int dataoff,
69
70
		    const char **dptr, unsigned int *datalen,
		    unsigned int matchoff, unsigned int matchlen,
71
		    union nf_inet_addr *addr, __be16 port)
72
{
73
	enum ip_conntrack_info ctinfo;
74
	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
75
	enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
76
77
78
79
80
81
82
83
84
85
86
87
88
	char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
	unsigned int buflen;
	__be32 newaddr;
	__be16 newport;

	if (ct->tuplehash[dir].tuple.src.u3.ip == addr->ip &&
	    ct->tuplehash[dir].tuple.src.u.udp.port == port) {
		newaddr = ct->tuplehash[!dir].tuple.dst.u3.ip;
		newport = ct->tuplehash[!dir].tuple.dst.u.udp.port;
	} else if (ct->tuplehash[dir].tuple.dst.u3.ip == addr->ip &&
		   ct->tuplehash[dir].tuple.dst.u.udp.port == port) {
		newaddr = ct->tuplehash[!dir].tuple.src.u3.ip;
		newport = ct->tuplehash[!dir].tuple.src.u.udp.port;
89
90
91
	} else
		return 1;

92
93
94
	if (newaddr == addr->ip && newport == port)
		return 1;

95
	buflen = sprintf(buffer, "%pI4:%u", &newaddr, ntohs(newport));
96

97
	return mangle_packet(skb, dataoff, dptr, datalen, matchoff, matchlen,
98
			     buffer, buflen);
99
100
}

101
static int map_sip_addr(struct sk_buff *skb, unsigned int dataoff,
102
			const char **dptr, unsigned int *datalen,
103
			enum sip_header_types type)
104
105
106
107
{
	enum ip_conntrack_info ctinfo;
	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
	unsigned int matchlen, matchoff;
108
109
	union nf_inet_addr addr;
	__be16 port;
110

111
112
	if (ct_sip_parse_header_uri(ct, *dptr, NULL, *datalen, type, NULL,
				    &matchoff, &matchlen, &addr, &port) <= 0)
113
		return 1;
114
115
	return map_addr(skb, dataoff, dptr, datalen, matchoff, matchlen,
			&addr, port);
116
117
}

118
static unsigned int ip_nat_sip(struct sk_buff *skb, unsigned int dataoff,
119
			       const char **dptr, unsigned int *datalen)
120
{
121
122
	enum ip_conntrack_info ctinfo;
	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
123
	enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
124
	unsigned int coff, matchoff, matchlen;
125
	enum sip_header_types hdr;
126
127
	union nf_inet_addr addr;
	__be16 port;
128
	int request, in_header;
129
130

	/* Basic rules: requests and responses. */
131
	if (strnicmp(*dptr, "SIP/2.0", strlen("SIP/2.0")) != 0) {
132
		if (ct_sip_parse_request(ct, *dptr, *datalen,
133
134
					 &matchoff, &matchlen,
					 &addr, &port) > 0 &&
135
		    !map_addr(skb, dataoff, dptr, datalen, matchoff, matchlen,
136
			      &addr, port))
137
			return NF_DROP;
138
139
140
141
		request = 1;
	} else
		request = 0;

142
143
144
145
146
	if (nf_ct_protonum(ct) == IPPROTO_TCP)
		hdr = SIP_HDR_VIA_TCP;
	else
		hdr = SIP_HDR_VIA_UDP;

147
148
	/* Translate topmost Via header and parameters */
	if (ct_sip_parse_header_uri(ct, *dptr, NULL, *datalen,
149
				    hdr, NULL, &matchoff, &matchlen,
150
				    &addr, &port) > 0) {
151
		unsigned int olen, matchend, poff, plen, buflen, n;
152
153
154
155
156
157
158
159
160
161
162
163
164
165
		char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")];

		/* We're only interested in headers related to this
		 * connection */
		if (request) {
			if (addr.ip != ct->tuplehash[dir].tuple.src.u3.ip ||
			    port != ct->tuplehash[dir].tuple.src.u.udp.port)
				goto next;
		} else {
			if (addr.ip != ct->tuplehash[dir].tuple.dst.u3.ip ||
			    port != ct->tuplehash[dir].tuple.dst.u.udp.port)
				goto next;
		}

166
		olen = *datalen;
167
		if (!map_addr(skb, dataoff, dptr, datalen, matchoff, matchlen,
168
169
170
			      &addr, port))
			return NF_DROP;

171
		matchend = matchoff + matchlen + *datalen - olen;
172
173
174
175
176

		/* The maddr= parameter (RFC 2361) specifies where to send
		 * the reply. */
		if (ct_sip_parse_address_param(ct, *dptr, matchend, *datalen,
					       "maddr=", &poff, &plen,
177
					       &addr, true) > 0 &&
178
179
		    addr.ip == ct->tuplehash[dir].tuple.src.u3.ip &&
		    addr.ip != ct->tuplehash[!dir].tuple.dst.u3.ip) {
180
181
			buflen = sprintf(buffer, "%pI4",
					&ct->tuplehash[!dir].tuple.dst.u3.ip);
182
183
			if (!mangle_packet(skb, dataoff, dptr, datalen,
					   poff, plen, buffer, buflen))
184
185
186
187
188
189
190
				return NF_DROP;
		}

		/* The received= parameter (RFC 2361) contains the address
		 * from which the server received the request. */
		if (ct_sip_parse_address_param(ct, *dptr, matchend, *datalen,
					       "received=", &poff, &plen,
191
					       &addr, false) > 0 &&
192
193
		    addr.ip == ct->tuplehash[dir].tuple.dst.u3.ip &&
		    addr.ip != ct->tuplehash[!dir].tuple.src.u3.ip) {
194
195
			buflen = sprintf(buffer, "%pI4",
					&ct->tuplehash[!dir].tuple.src.u3.ip);
196
197
			if (!mangle_packet(skb, dataoff, dptr, datalen,
					   poff, plen, buffer, buflen))
198
199
200
201
202
203
204
205
206
207
208
209
				return NF_DROP;
		}

		/* The rport= parameter (RFC 3581) contains the port number
		 * from which the server received the request. */
		if (ct_sip_parse_numerical_param(ct, *dptr, matchend, *datalen,
						 "rport=", &poff, &plen,
						 &n) > 0 &&
		    htons(n) == ct->tuplehash[dir].tuple.dst.u.udp.port &&
		    htons(n) != ct->tuplehash[!dir].tuple.src.u.udp.port) {
			__be16 p = ct->tuplehash[!dir].tuple.src.u.udp.port;
			buflen = sprintf(buffer, "%u", ntohs(p));
210
211
			if (!mangle_packet(skb, dataoff, dptr, datalen,
					   poff, plen, buffer, buflen))
212
213
				return NF_DROP;
		}
214
215
	}

216
next:
217
	/* Translate Contact headers */
218
	coff = 0;
219
	in_header = 0;
220
	while (ct_sip_parse_header_uri(ct, *dptr, &coff, *datalen,
221
222
223
				       SIP_HDR_CONTACT, &in_header,
				       &matchoff, &matchlen,
				       &addr, &port) > 0) {
224
		if (!map_addr(skb, dataoff, dptr, datalen, matchoff, matchlen,
225
226
227
228
			      &addr, port))
			return NF_DROP;
	}

229
230
	if (!map_sip_addr(skb, dataoff, dptr, datalen, SIP_HDR_FROM) ||
	    !map_sip_addr(skb, dataoff, dptr, datalen, SIP_HDR_TO))
231
		return NF_DROP;
232

233
234
235
	return NF_ACCEPT;
}

236
237
238
239
240
241
242
243
244
245
246
247
248
static void ip_nat_sip_seq_adjust(struct sk_buff *skb, s16 off)
{
	enum ip_conntrack_info ctinfo;
	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
	const struct tcphdr *th;

	if (nf_ct_protonum(ct) != IPPROTO_TCP || off == 0)
		return;

	th = (struct tcphdr *)(skb->data + ip_hdrlen(skb));
	nf_nat_set_seq_adjust(ct, ctinfo, th->seq, off);
}

249
250
251
252
/* Handles expected signalling connections and media streams */
static void ip_nat_sip_expected(struct nf_conn *ct,
				struct nf_conntrack_expect *exp)
{
253
	struct nf_nat_ipv4_range range;
254
255
256
257
258

	/* This must be a fresh one. */
	BUG_ON(ct->status & IPS_NAT_DONE_MASK);

	/* For DST manip, map port here to where it's expected. */
259
	range.flags = (NF_NAT_RANGE_MAP_IPS | NF_NAT_RANGE_PROTO_SPECIFIED);
260
261
	range.min = range.max = exp->saved_proto;
	range.min_ip = range.max_ip = exp->saved_ip;
262
	nf_nat_setup_info(ct, &range, NF_NAT_MANIP_DST);
263
264
265
266
267

	/* Change src to where master sends to, but only if the connection
	 * actually came from the same source. */
	if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip ==
	    ct->master->tuplehash[exp->dir].tuple.src.u3.ip) {
268
		range.flags = NF_NAT_RANGE_MAP_IPS;
269
270
		range.min_ip = range.max_ip
			= ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip;
271
		nf_nat_setup_info(ct, &range, NF_NAT_MANIP_SRC);
272
273
274
	}
}

275
static unsigned int ip_nat_sip_expect(struct sk_buff *skb, unsigned int dataoff,
276
277
278
279
280
281
282
283
284
285
286
				      const char **dptr, unsigned int *datalen,
				      struct nf_conntrack_expect *exp,
				      unsigned int matchoff,
				      unsigned int matchlen)
{
	enum ip_conntrack_info ctinfo;
	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
	enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
	__be32 newip;
	u_int16_t port;
	char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
287
	unsigned int buflen;
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310

	/* Connection will come from reply */
	if (ct->tuplehash[dir].tuple.src.u3.ip == ct->tuplehash[!dir].tuple.dst.u3.ip)
		newip = exp->tuple.dst.u3.ip;
	else
		newip = ct->tuplehash[!dir].tuple.dst.u3.ip;

	/* If the signalling port matches the connection's source port in the
	 * original direction, try to use the destination port in the opposite
	 * direction. */
	if (exp->tuple.dst.u.udp.port ==
	    ct->tuplehash[dir].tuple.src.u.udp.port)
		port = ntohs(ct->tuplehash[!dir].tuple.dst.u.udp.port);
	else
		port = ntohs(exp->tuple.dst.u.udp.port);

	exp->saved_ip = exp->tuple.dst.u3.ip;
	exp->tuple.dst.u3.ip = newip;
	exp->saved_proto.udp.port = exp->tuple.dst.u.udp.port;
	exp->dir = !dir;
	exp->expectfn = ip_nat_sip_expected;

	for (; port != 0; port++) {
311
312
		int ret;

313
		exp->tuple.dst.u.udp.port = htons(port);
314
315
316
317
318
		ret = nf_ct_expect_related(exp);
		if (ret == 0)
			break;
		else if (ret != -EBUSY) {
			port = 0;
319
			break;
320
		}
321
322
323
324
325
326
327
	}

	if (port == 0)
		return NF_DROP;

	if (exp->tuple.dst.u3.ip != exp->saved_ip ||
	    exp->tuple.dst.u.udp.port != exp->saved_proto.udp.port) {
328
		buflen = sprintf(buffer, "%pI4:%u", &newip, port);
329
330
		if (!mangle_packet(skb, dataoff, dptr, datalen,
				   matchoff, matchlen, buffer, buflen))
331
332
333
334
335
336
337
338
339
			goto err;
	}
	return NF_ACCEPT;

err:
	nf_ct_unexpect_related(exp);
	return NF_DROP;
}

340
static int mangle_content_len(struct sk_buff *skb, unsigned int dataoff,
341
			      const char **dptr, unsigned int *datalen)
342
{
343
344
	enum ip_conntrack_info ctinfo;
	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
345
346
347
	unsigned int matchoff, matchlen;
	char buffer[sizeof("65536")];
	int buflen, c_len;
348

349
350
351
352
353
354
355
356
	/* Get actual SDP length */
	if (ct_sip_get_sdp_header(ct, *dptr, 0, *datalen,
				  SDP_HDR_VERSION, SDP_HDR_UNSPEC,
				  &matchoff, &matchlen) <= 0)
		return 0;
	c_len = *datalen - matchoff + strlen("v=");

	/* Now, update SDP length */
357
358
	if (ct_sip_get_header(ct, *dptr, 0, *datalen, SIP_HDR_CONTENT_LENGTH,
			      &matchoff, &matchlen) <= 0)
359
360
		return 0;

361
	buflen = sprintf(buffer, "%u", c_len);
362
	return mangle_packet(skb, dataoff, dptr, datalen, matchoff, matchlen,
363
			     buffer, buflen);
364
365
}

366
367
368
static int mangle_sdp_packet(struct sk_buff *skb, unsigned int dataoff,
			     const char **dptr, unsigned int *datalen,
			     unsigned int sdpoff,
369
370
371
			     enum sdp_header_types type,
			     enum sdp_header_types term,
			     char *buffer, int buflen)
372
{
373
374
	enum ip_conntrack_info ctinfo;
	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
375
	unsigned int matchlen, matchoff;
376

377
	if (ct_sip_get_sdp_header(ct, *dptr, sdpoff, *datalen, type, term,
378
				  &matchoff, &matchlen) <= 0)
379
		return -ENOENT;
380
	return mangle_packet(skb, dataoff, dptr, datalen, matchoff, matchlen,
381
			     buffer, buflen) ? 0 : -EINVAL;
382
383
}

384
385
386
static unsigned int ip_nat_sdp_addr(struct sk_buff *skb, unsigned int dataoff,
				    const char **dptr, unsigned int *datalen,
				    unsigned int sdpoff,
387
388
389
				    enum sdp_header_types type,
				    enum sdp_header_types term,
				    const union nf_inet_addr *addr)
390
391
{
	char buffer[sizeof("nnn.nnn.nnn.nnn")];
392
	unsigned int buflen;
393

394
	buflen = sprintf(buffer, "%pI4", &addr->ip);
395
	if (mangle_sdp_packet(skb, dataoff, dptr, datalen, sdpoff, type, term,
396
			      buffer, buflen))
397
398
		return 0;

399
	return mangle_content_len(skb, dataoff, dptr, datalen);
400
401
}

402
403
static unsigned int ip_nat_sdp_port(struct sk_buff *skb, unsigned int dataoff,
				    const char **dptr, unsigned int *datalen,
404
405
406
407
408
409
410
411
				    unsigned int matchoff,
				    unsigned int matchlen,
				    u_int16_t port)
{
	char buffer[sizeof("nnnnn")];
	unsigned int buflen;

	buflen = sprintf(buffer, "%u", port);
412
	if (!mangle_packet(skb, dataoff, dptr, datalen, matchoff, matchlen,
413
			   buffer, buflen))
414
415
		return 0;

416
	return mangle_content_len(skb, dataoff, dptr, datalen);
417
418
}

419
420
421
static unsigned int ip_nat_sdp_session(struct sk_buff *skb, unsigned int dataoff,
				       const char **dptr, unsigned int *datalen,
				       unsigned int sdpoff,
422
423
424
425
426
427
				       const union nf_inet_addr *addr)
{
	char buffer[sizeof("nnn.nnn.nnn.nnn")];
	unsigned int buflen;

	/* Mangle session description owner and contact addresses */
428
	buflen = sprintf(buffer, "%pI4", &addr->ip);
429
	if (mangle_sdp_packet(skb, dataoff, dptr, datalen, sdpoff,
430
431
432
433
			       SDP_HDR_OWNER_IP4, SDP_HDR_MEDIA,
			       buffer, buflen))
		return 0;

434
	switch (mangle_sdp_packet(skb, dataoff, dptr, datalen, sdpoff,
435
436
437
438
439
440
441
442
443
444
445
446
447
				  SDP_HDR_CONNECTION_IP4, SDP_HDR_MEDIA,
				  buffer, buflen)) {
	case 0:
	/*
	 * RFC 2327:
	 *
	 * Session description
	 *
	 * c=* (connection information - not required if included in all media)
	 */
	case -ENOENT:
		break;
	default:
448
		return 0;
449
	}
450

451
	return mangle_content_len(skb, dataoff, dptr, datalen);
452
453
454
455
}

/* So, this packet has hit the connection tracking matching code.
   Mangle it, and change the expectation to match the new version. */
456
457
static unsigned int ip_nat_sdp_media(struct sk_buff *skb, unsigned int dataoff,
				     const char **dptr, unsigned int *datalen,
458
459
460
461
462
				     struct nf_conntrack_expect *rtp_exp,
				     struct nf_conntrack_expect *rtcp_exp,
				     unsigned int mediaoff,
				     unsigned int medialen,
				     union nf_inet_addr *rtp_addr)
463
{
464
465
	enum ip_conntrack_info ctinfo;
	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
466
467
468
469
	enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
	u_int16_t port;

	/* Connection will come from reply */
470
471
	if (ct->tuplehash[dir].tuple.src.u3.ip ==
	    ct->tuplehash[!dir].tuple.dst.u3.ip)
472
		rtp_addr->ip = rtp_exp->tuple.dst.u3.ip;
473
	else
474
		rtp_addr->ip = ct->tuplehash[!dir].tuple.dst.u3.ip;
475

476
	rtp_exp->saved_ip = rtp_exp->tuple.dst.u3.ip;
477
	rtp_exp->tuple.dst.u3.ip = rtp_addr->ip;
478
479
480
481
482
	rtp_exp->saved_proto.udp.port = rtp_exp->tuple.dst.u.udp.port;
	rtp_exp->dir = !dir;
	rtp_exp->expectfn = ip_nat_sip_expected;

	rtcp_exp->saved_ip = rtcp_exp->tuple.dst.u3.ip;
483
	rtcp_exp->tuple.dst.u3.ip = rtp_addr->ip;
484
485
486
487
488
489
490
	rtcp_exp->saved_proto.udp.port = rtcp_exp->tuple.dst.u.udp.port;
	rtcp_exp->dir = !dir;
	rtcp_exp->expectfn = ip_nat_sip_expected;

	/* Try to get same pair of ports: if not, try to change them. */
	for (port = ntohs(rtp_exp->tuple.dst.u.udp.port);
	     port != 0; port += 2) {
491
492
		int ret;

493
		rtp_exp->tuple.dst.u.udp.port = htons(port);
494
495
		ret = nf_ct_expect_related(rtp_exp);
		if (ret == -EBUSY)
496
			continue;
497
498
499
500
		else if (ret < 0) {
			port = 0;
			break;
		}
501
		rtcp_exp->tuple.dst.u.udp.port = htons(port + 1);
502
503
		ret = nf_ct_expect_related(rtcp_exp);
		if (ret == 0)
504
			break;
505
506
507
508
		else if (ret == -EBUSY) {
			nf_ct_unexpect_related(rtp_exp);
			continue;
		} else if (ret < 0) {
509
510
511
512
			nf_ct_unexpect_related(rtp_exp);
			port = 0;
			break;
		}
513
514
515
	}

	if (port == 0)
516
517
518
519
		goto err1;

	/* Update media port. */
	if (rtp_exp->tuple.dst.u.udp.port != rtp_exp->saved_proto.udp.port &&
520
521
	    !ip_nat_sdp_port(skb, dataoff, dptr, datalen,
			     mediaoff, medialen, port))
522
		goto err2;
523
524

	return NF_ACCEPT;
525
526
527
528
529
530

err2:
	nf_ct_unexpect_related(rtp_exp);
	nf_ct_unexpect_related(rtcp_exp);
err1:
	return NF_DROP;
531
532
}

533
534
535
536
537
static struct nf_ct_helper_expectfn sip_nat = {
        .name           = "sip",
        .expectfn       = ip_nat_sip_expected,
};

538
539
static void __exit nf_nat_sip_fini(void)
{
540
541
542
543
544
545
546
	RCU_INIT_POINTER(nf_nat_sip_hook, NULL);
	RCU_INIT_POINTER(nf_nat_sip_seq_adjust_hook, NULL);
	RCU_INIT_POINTER(nf_nat_sip_expect_hook, NULL);
	RCU_INIT_POINTER(nf_nat_sdp_addr_hook, NULL);
	RCU_INIT_POINTER(nf_nat_sdp_port_hook, NULL);
	RCU_INIT_POINTER(nf_nat_sdp_session_hook, NULL);
	RCU_INIT_POINTER(nf_nat_sdp_media_hook, NULL);
547
	nf_ct_helper_expectfn_unregister(&sip_nat);
548
549
550
551
552
	synchronize_rcu();
}

static int __init nf_nat_sip_init(void)
{
553
	BUG_ON(nf_nat_sip_hook != NULL);
554
	BUG_ON(nf_nat_sip_seq_adjust_hook != NULL);
555
	BUG_ON(nf_nat_sip_expect_hook != NULL);
556
	BUG_ON(nf_nat_sdp_addr_hook != NULL);
557
	BUG_ON(nf_nat_sdp_port_hook != NULL);
558
559
	BUG_ON(nf_nat_sdp_session_hook != NULL);
	BUG_ON(nf_nat_sdp_media_hook != NULL);
560
561
562
563
564
565
566
	RCU_INIT_POINTER(nf_nat_sip_hook, ip_nat_sip);
	RCU_INIT_POINTER(nf_nat_sip_seq_adjust_hook, ip_nat_sip_seq_adjust);
	RCU_INIT_POINTER(nf_nat_sip_expect_hook, ip_nat_sip_expect);
	RCU_INIT_POINTER(nf_nat_sdp_addr_hook, ip_nat_sdp_addr);
	RCU_INIT_POINTER(nf_nat_sdp_port_hook, ip_nat_sdp_port);
	RCU_INIT_POINTER(nf_nat_sdp_session_hook, ip_nat_sdp_session);
	RCU_INIT_POINTER(nf_nat_sdp_media_hook, ip_nat_sdp_media);
567
	nf_ct_helper_expectfn_register(&sip_nat);
568
569
570
571
572
	return 0;
}

module_init(nf_nat_sip_init);
module_exit(nf_nat_sip_fini);