[NETFILTER]: constify nf_afinfo
[safe/jmp/linux-2.6] / net / netfilter / nf_conntrack_h323_main.c
1 /*
2  * H.323 connection tracking helper
3  *
4  * Copyright (c) 2006 Jing Min Zhao <zhaojingmin@users.sourceforge.net>
5  *
6  * This source code is licensed under General Public License version 2.
7  *
8  * Based on the 'brute force' H.323 connection tracking module by
9  * Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10  *
11  * For more information, please see http://nath323.sourceforge.net/
12  */
13
14 #include <linux/module.h>
15 #include <linux/moduleparam.h>
16 #include <linux/ctype.h>
17 #include <linux/inet.h>
18 #include <linux/in.h>
19 #include <linux/ip.h>
20 #include <linux/udp.h>
21 #include <linux/tcp.h>
22 #include <linux/skbuff.h>
23 #include <net/route.h>
24 #include <net/ip6_route.h>
25
26 #include <net/netfilter/nf_conntrack.h>
27 #include <net/netfilter/nf_conntrack_core.h>
28 #include <net/netfilter/nf_conntrack_tuple.h>
29 #include <net/netfilter/nf_conntrack_expect.h>
30 #include <net/netfilter/nf_conntrack_ecache.h>
31 #include <net/netfilter/nf_conntrack_helper.h>
32 #include <linux/netfilter/nf_conntrack_h323.h>
33
34 /* Parameters */
35 static unsigned int default_rrq_ttl __read_mostly = 300;
36 module_param(default_rrq_ttl, uint, 0600);
37 MODULE_PARM_DESC(default_rrq_ttl, "use this TTL if it's missing in RRQ");
38
39 static int gkrouted_only __read_mostly = 1;
40 module_param(gkrouted_only, int, 0600);
41 MODULE_PARM_DESC(gkrouted_only, "only accept calls from gatekeeper");
42
43 static int callforward_filter __read_mostly = 1;
44 module_param(callforward_filter, bool, 0600);
45 MODULE_PARM_DESC(callforward_filter, "only create call forwarding expectations "
46                                      "if both endpoints are on different sides "
47                                      "(determined by routing information)");
48
49 /* Hooks for NAT */
50 int (*set_h245_addr_hook) (struct sk_buff *skb,
51                            unsigned char **data, int dataoff,
52                            H245_TransportAddress *taddr,
53                            union nf_conntrack_address *addr, __be16 port)
54                            __read_mostly;
55 int (*set_h225_addr_hook) (struct sk_buff *skb,
56                            unsigned char **data, int dataoff,
57                            TransportAddress *taddr,
58                            union nf_conntrack_address *addr, __be16 port)
59                            __read_mostly;
60 int (*set_sig_addr_hook) (struct sk_buff *skb,
61                           struct nf_conn *ct,
62                           enum ip_conntrack_info ctinfo,
63                           unsigned char **data,
64                           TransportAddress *taddr, int count) __read_mostly;
65 int (*set_ras_addr_hook) (struct sk_buff *skb,
66                           struct nf_conn *ct,
67                           enum ip_conntrack_info ctinfo,
68                           unsigned char **data,
69                           TransportAddress *taddr, int count) __read_mostly;
70 int (*nat_rtp_rtcp_hook) (struct sk_buff *skb,
71                           struct nf_conn *ct,
72                           enum ip_conntrack_info ctinfo,
73                           unsigned char **data, int dataoff,
74                           H245_TransportAddress *taddr,
75                           __be16 port, __be16 rtp_port,
76                           struct nf_conntrack_expect *rtp_exp,
77                           struct nf_conntrack_expect *rtcp_exp) __read_mostly;
78 int (*nat_t120_hook) (struct sk_buff *skb,
79                       struct nf_conn *ct,
80                       enum ip_conntrack_info ctinfo,
81                       unsigned char **data, int dataoff,
82                       H245_TransportAddress *taddr, __be16 port,
83                       struct nf_conntrack_expect *exp) __read_mostly;
84 int (*nat_h245_hook) (struct sk_buff *skb,
85                       struct nf_conn *ct,
86                       enum ip_conntrack_info ctinfo,
87                       unsigned char **data, int dataoff,
88                       TransportAddress *taddr, __be16 port,
89                       struct nf_conntrack_expect *exp) __read_mostly;
90 int (*nat_callforwarding_hook) (struct sk_buff *skb,
91                                 struct nf_conn *ct,
92                                 enum ip_conntrack_info ctinfo,
93                                 unsigned char **data, int dataoff,
94                                 TransportAddress *taddr, __be16 port,
95                                 struct nf_conntrack_expect *exp) __read_mostly;
96 int (*nat_q931_hook) (struct sk_buff *skb,
97                       struct nf_conn *ct,
98                       enum ip_conntrack_info ctinfo,
99                       unsigned char **data, TransportAddress *taddr, int idx,
100                       __be16 port, struct nf_conntrack_expect *exp)
101                       __read_mostly;
102
103 static DEFINE_SPINLOCK(nf_h323_lock);
104 static char *h323_buffer;
105
106 static struct nf_conntrack_helper nf_conntrack_helper_h245;
107 static struct nf_conntrack_helper nf_conntrack_helper_q931[];
108 static struct nf_conntrack_helper nf_conntrack_helper_ras[];
109
110 /****************************************************************************/
111 static int get_tpkt_data(struct sk_buff *skb, unsigned int protoff,
112                          struct nf_conn *ct, enum ip_conntrack_info ctinfo,
113                          unsigned char **data, int *datalen, int *dataoff)
114 {
115         struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
116         int dir = CTINFO2DIR(ctinfo);
117         struct tcphdr _tcph, *th;
118         int tcpdatalen;
119         int tcpdataoff;
120         unsigned char *tpkt;
121         int tpktlen;
122         int tpktoff;
123
124         /* Get TCP header */
125         th = skb_header_pointer(skb, protoff, sizeof(_tcph), &_tcph);
126         if (th == NULL)
127                 return 0;
128
129         /* Get TCP data offset */
130         tcpdataoff = protoff + th->doff * 4;
131
132         /* Get TCP data length */
133         tcpdatalen = skb->len - tcpdataoff;
134         if (tcpdatalen <= 0)    /* No TCP data */
135                 goto clear_out;
136
137         if (*data == NULL) {    /* first TPKT */
138                 /* Get first TPKT pointer */
139                 tpkt = skb_header_pointer(skb, tcpdataoff, tcpdatalen,
140                                           h323_buffer);
141                 BUG_ON(tpkt == NULL);
142
143                 /* Validate TPKT identifier */
144                 if (tcpdatalen < 4 || tpkt[0] != 0x03 || tpkt[1] != 0) {
145                         /* Netmeeting sends TPKT header and data separately */
146                         if (info->tpkt_len[dir] > 0) {
147                                 pr_debug("nf_ct_h323: previous packet "
148                                          "indicated separate TPKT data of %hu "
149                                          "bytes\n", info->tpkt_len[dir]);
150                                 if (info->tpkt_len[dir] <= tcpdatalen) {
151                                         /* Yes, there was a TPKT header
152                                          * received */
153                                         *data = tpkt;
154                                         *datalen = info->tpkt_len[dir];
155                                         *dataoff = 0;
156                                         goto out;
157                                 }
158
159                                 /* Fragmented TPKT */
160                                 pr_debug("nf_ct_h323: fragmented TPKT\n");
161                                 goto clear_out;
162                         }
163
164                         /* It is not even a TPKT */
165                         return 0;
166                 }
167                 tpktoff = 0;
168         } else {                /* Next TPKT */
169                 tpktoff = *dataoff + *datalen;
170                 tcpdatalen -= tpktoff;
171                 if (tcpdatalen <= 4)    /* No more TPKT */
172                         goto clear_out;
173                 tpkt = *data + *datalen;
174
175                 /* Validate TPKT identifier */
176                 if (tpkt[0] != 0x03 || tpkt[1] != 0)
177                         goto clear_out;
178         }
179
180         /* Validate TPKT length */
181         tpktlen = tpkt[2] * 256 + tpkt[3];
182         if (tpktlen < 4)
183                 goto clear_out;
184         if (tpktlen > tcpdatalen) {
185                 if (tcpdatalen == 4) {  /* Separate TPKT header */
186                         /* Netmeeting sends TPKT header and data separately */
187                         pr_debug("nf_ct_h323: separate TPKT header indicates "
188                                  "there will be TPKT data of %hu bytes\n",
189                                  tpktlen - 4);
190                         info->tpkt_len[dir] = tpktlen - 4;
191                         return 0;
192                 }
193
194                 if (net_ratelimit())
195                         printk("nf_ct_h323: incomplete TPKT (fragmented?)\n");
196                 goto clear_out;
197         }
198
199         /* This is the encapsulated data */
200         *data = tpkt + 4;
201         *datalen = tpktlen - 4;
202         *dataoff = tpktoff + 4;
203
204       out:
205         /* Clear TPKT length */
206         info->tpkt_len[dir] = 0;
207         return 1;
208
209       clear_out:
210         info->tpkt_len[dir] = 0;
211         return 0;
212 }
213
214 /****************************************************************************/
215 static int get_h245_addr(struct nf_conn *ct, unsigned char *data,
216                          H245_TransportAddress *taddr,
217                          union nf_conntrack_address *addr, __be16 *port)
218 {
219         unsigned char *p;
220         int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
221         int len;
222
223         if (taddr->choice != eH245_TransportAddress_unicastAddress)
224                 return 0;
225
226         switch (taddr->unicastAddress.choice) {
227         case eUnicastAddress_iPAddress:
228                 if (family != AF_INET)
229                         return 0;
230                 p = data + taddr->unicastAddress.iPAddress.network;
231                 len = 4;
232                 break;
233         case eUnicastAddress_iP6Address:
234                 if (family != AF_INET6)
235                         return 0;
236                 p = data + taddr->unicastAddress.iP6Address.network;
237                 len = 16;
238                 break;
239         default:
240                 return 0;
241         }
242
243         memcpy(addr, p, len);
244         memset((void *)addr + len, 0, sizeof(*addr) - len);
245         memcpy(port, p + len, sizeof(__be16));
246
247         return 1;
248 }
249
250 /****************************************************************************/
251 static int expect_rtp_rtcp(struct sk_buff *skb, struct nf_conn *ct,
252                            enum ip_conntrack_info ctinfo,
253                            unsigned char **data, int dataoff,
254                            H245_TransportAddress *taddr)
255 {
256         int dir = CTINFO2DIR(ctinfo);
257         int ret = 0;
258         __be16 port;
259         __be16 rtp_port, rtcp_port;
260         union nf_conntrack_address addr;
261         struct nf_conntrack_expect *rtp_exp;
262         struct nf_conntrack_expect *rtcp_exp;
263         typeof(nat_rtp_rtcp_hook) nat_rtp_rtcp;
264
265         /* Read RTP or RTCP address */
266         if (!get_h245_addr(ct, *data, taddr, &addr, &port) ||
267             memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) ||
268             port == 0)
269                 return 0;
270
271         /* RTP port is even */
272         port &= htons(~1);
273         rtp_port = port;
274         rtcp_port = htons(ntohs(port) + 1);
275
276         /* Create expect for RTP */
277         if ((rtp_exp = nf_ct_expect_alloc(ct)) == NULL)
278                 return -1;
279         nf_ct_expect_init(rtp_exp, ct->tuplehash[!dir].tuple.src.l3num,
280                           &ct->tuplehash[!dir].tuple.src.u3,
281                           &ct->tuplehash[!dir].tuple.dst.u3,
282                           IPPROTO_UDP, NULL, &rtp_port);
283
284         /* Create expect for RTCP */
285         if ((rtcp_exp = nf_ct_expect_alloc(ct)) == NULL) {
286                 nf_ct_expect_put(rtp_exp);
287                 return -1;
288         }
289         nf_ct_expect_init(rtcp_exp, ct->tuplehash[!dir].tuple.src.l3num,
290                           &ct->tuplehash[!dir].tuple.src.u3,
291                           &ct->tuplehash[!dir].tuple.dst.u3,
292                           IPPROTO_UDP, NULL, &rtcp_port);
293
294         if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
295                    &ct->tuplehash[!dir].tuple.dst.u3,
296                    sizeof(ct->tuplehash[dir].tuple.src.u3)) &&
297                    (nat_rtp_rtcp = rcu_dereference(nat_rtp_rtcp_hook)) &&
298                    ct->status & IPS_NAT_MASK) {
299                 /* NAT needed */
300                 ret = nat_rtp_rtcp(skb, ct, ctinfo, data, dataoff,
301                                    taddr, port, rtp_port, rtp_exp, rtcp_exp);
302         } else {                /* Conntrack only */
303                 if (nf_ct_expect_related(rtp_exp) == 0) {
304                         if (nf_ct_expect_related(rtcp_exp) == 0) {
305                                 pr_debug("nf_ct_h323: expect RTP ");
306                                 NF_CT_DUMP_TUPLE(&rtp_exp->tuple);
307                                 pr_debug("nf_ct_h323: expect RTCP ");
308                                 NF_CT_DUMP_TUPLE(&rtcp_exp->tuple);
309                         } else {
310                                 nf_ct_unexpect_related(rtp_exp);
311                                 ret = -1;
312                         }
313                 } else
314                         ret = -1;
315         }
316
317         nf_ct_expect_put(rtp_exp);
318         nf_ct_expect_put(rtcp_exp);
319
320         return ret;
321 }
322
323 /****************************************************************************/
324 static int expect_t120(struct sk_buff *skb,
325                        struct nf_conn *ct,
326                        enum ip_conntrack_info ctinfo,
327                        unsigned char **data, int dataoff,
328                        H245_TransportAddress *taddr)
329 {
330         int dir = CTINFO2DIR(ctinfo);
331         int ret = 0;
332         __be16 port;
333         union nf_conntrack_address addr;
334         struct nf_conntrack_expect *exp;
335         typeof(nat_t120_hook) nat_t120;
336
337         /* Read T.120 address */
338         if (!get_h245_addr(ct, *data, taddr, &addr, &port) ||
339             memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) ||
340             port == 0)
341                 return 0;
342
343         /* Create expect for T.120 connections */
344         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
345                 return -1;
346         nf_ct_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
347                           &ct->tuplehash[!dir].tuple.src.u3,
348                           &ct->tuplehash[!dir].tuple.dst.u3,
349                           IPPROTO_TCP, NULL, &port);
350         exp->flags = NF_CT_EXPECT_PERMANENT;    /* Accept multiple channels */
351
352         if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
353                    &ct->tuplehash[!dir].tuple.dst.u3,
354                    sizeof(ct->tuplehash[dir].tuple.src.u3)) &&
355             (nat_t120 = rcu_dereference(nat_t120_hook)) &&
356             ct->status & IPS_NAT_MASK) {
357                 /* NAT needed */
358                 ret = nat_t120(skb, ct, ctinfo, data, dataoff, taddr,
359                                port, exp);
360         } else {                /* Conntrack only */
361                 if (nf_ct_expect_related(exp) == 0) {
362                         pr_debug("nf_ct_h323: expect T.120 ");
363                         NF_CT_DUMP_TUPLE(&exp->tuple);
364                 } else
365                         ret = -1;
366         }
367
368         nf_ct_expect_put(exp);
369
370         return ret;
371 }
372
373 /****************************************************************************/
374 static int process_h245_channel(struct sk_buff *skb,
375                                 struct nf_conn *ct,
376                                 enum ip_conntrack_info ctinfo,
377                                 unsigned char **data, int dataoff,
378                                 H2250LogicalChannelParameters *channel)
379 {
380         int ret;
381
382         if (channel->options & eH2250LogicalChannelParameters_mediaChannel) {
383                 /* RTP */
384                 ret = expect_rtp_rtcp(skb, ct, ctinfo, data, dataoff,
385                                       &channel->mediaChannel);
386                 if (ret < 0)
387                         return -1;
388         }
389
390         if (channel->
391             options & eH2250LogicalChannelParameters_mediaControlChannel) {
392                 /* RTCP */
393                 ret = expect_rtp_rtcp(skb, ct, ctinfo, data, dataoff,
394                                       &channel->mediaControlChannel);
395                 if (ret < 0)
396                         return -1;
397         }
398
399         return 0;
400 }
401
402 /****************************************************************************/
403 static int process_olc(struct sk_buff *skb, struct nf_conn *ct,
404                        enum ip_conntrack_info ctinfo,
405                        unsigned char **data, int dataoff,
406                        OpenLogicalChannel *olc)
407 {
408         int ret;
409
410         pr_debug("nf_ct_h323: OpenLogicalChannel\n");
411
412         if (olc->forwardLogicalChannelParameters.multiplexParameters.choice ==
413             eOpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters)
414         {
415                 ret = process_h245_channel(skb, ct, ctinfo, data, dataoff,
416                                            &olc->
417                                            forwardLogicalChannelParameters.
418                                            multiplexParameters.
419                                            h2250LogicalChannelParameters);
420                 if (ret < 0)
421                         return -1;
422         }
423
424         if ((olc->options &
425              eOpenLogicalChannel_reverseLogicalChannelParameters) &&
426             (olc->reverseLogicalChannelParameters.options &
427              eOpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters)
428             && (olc->reverseLogicalChannelParameters.multiplexParameters.
429                 choice ==
430                 eOpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters))
431         {
432                 ret =
433                     process_h245_channel(skb, ct, ctinfo, data, dataoff,
434                                          &olc->
435                                          reverseLogicalChannelParameters.
436                                          multiplexParameters.
437                                          h2250LogicalChannelParameters);
438                 if (ret < 0)
439                         return -1;
440         }
441
442         if ((olc->options & eOpenLogicalChannel_separateStack) &&
443             olc->forwardLogicalChannelParameters.dataType.choice ==
444             eDataType_data &&
445             olc->forwardLogicalChannelParameters.dataType.data.application.
446             choice == eDataApplicationCapability_application_t120 &&
447             olc->forwardLogicalChannelParameters.dataType.data.application.
448             t120.choice == eDataProtocolCapability_separateLANStack &&
449             olc->separateStack.networkAddress.choice ==
450             eNetworkAccessParameters_networkAddress_localAreaAddress) {
451                 ret = expect_t120(skb, ct, ctinfo, data, dataoff,
452                                   &olc->separateStack.networkAddress.
453                                   localAreaAddress);
454                 if (ret < 0)
455                         return -1;
456         }
457
458         return 0;
459 }
460
461 /****************************************************************************/
462 static int process_olca(struct sk_buff *skb, struct nf_conn *ct,
463                         enum ip_conntrack_info ctinfo,
464                         unsigned char **data, int dataoff,
465                         OpenLogicalChannelAck *olca)
466 {
467         H2250LogicalChannelAckParameters *ack;
468         int ret;
469
470         pr_debug("nf_ct_h323: OpenLogicalChannelAck\n");
471
472         if ((olca->options &
473              eOpenLogicalChannelAck_reverseLogicalChannelParameters) &&
474             (olca->reverseLogicalChannelParameters.options &
475              eOpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters)
476             && (olca->reverseLogicalChannelParameters.multiplexParameters.
477                 choice ==
478                 eOpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters))
479         {
480                 ret = process_h245_channel(skb, ct, ctinfo, data, dataoff,
481                                            &olca->
482                                            reverseLogicalChannelParameters.
483                                            multiplexParameters.
484                                            h2250LogicalChannelParameters);
485                 if (ret < 0)
486                         return -1;
487         }
488
489         if ((olca->options &
490              eOpenLogicalChannelAck_forwardMultiplexAckParameters) &&
491             (olca->forwardMultiplexAckParameters.choice ==
492              eOpenLogicalChannelAck_forwardMultiplexAckParameters_h2250LogicalChannelAckParameters))
493         {
494                 ack = &olca->forwardMultiplexAckParameters.
495                     h2250LogicalChannelAckParameters;
496                 if (ack->options &
497                     eH2250LogicalChannelAckParameters_mediaChannel) {
498                         /* RTP */
499                         ret = expect_rtp_rtcp(skb, ct, ctinfo, data, dataoff,
500                                               &ack->mediaChannel);
501                         if (ret < 0)
502                                 return -1;
503                 }
504
505                 if (ack->options &
506                     eH2250LogicalChannelAckParameters_mediaControlChannel) {
507                         /* RTCP */
508                         ret = expect_rtp_rtcp(skb, ct, ctinfo, data, dataoff,
509                                               &ack->mediaControlChannel);
510                         if (ret < 0)
511                                 return -1;
512                 }
513         }
514
515         if ((olca->options & eOpenLogicalChannelAck_separateStack) &&
516                 olca->separateStack.networkAddress.choice ==
517                 eNetworkAccessParameters_networkAddress_localAreaAddress) {
518                 ret = expect_t120(skb, ct, ctinfo, data, dataoff,
519                                   &olca->separateStack.networkAddress.
520                                   localAreaAddress);
521                 if (ret < 0)
522                         return -1;
523         }
524
525         return 0;
526 }
527
528 /****************************************************************************/
529 static int process_h245(struct sk_buff *skb, struct nf_conn *ct,
530                         enum ip_conntrack_info ctinfo,
531                         unsigned char **data, int dataoff,
532                         MultimediaSystemControlMessage *mscm)
533 {
534         switch (mscm->choice) {
535         case eMultimediaSystemControlMessage_request:
536                 if (mscm->request.choice ==
537                     eRequestMessage_openLogicalChannel) {
538                         return process_olc(skb, ct, ctinfo, data, dataoff,
539                                            &mscm->request.openLogicalChannel);
540                 }
541                 pr_debug("nf_ct_h323: H.245 Request %d\n",
542                          mscm->request.choice);
543                 break;
544         case eMultimediaSystemControlMessage_response:
545                 if (mscm->response.choice ==
546                     eResponseMessage_openLogicalChannelAck) {
547                         return process_olca(skb, ct, ctinfo, data, dataoff,
548                                             &mscm->response.
549                                             openLogicalChannelAck);
550                 }
551                 pr_debug("nf_ct_h323: H.245 Response %d\n",
552                          mscm->response.choice);
553                 break;
554         default:
555                 pr_debug("nf_ct_h323: H.245 signal %d\n", mscm->choice);
556                 break;
557         }
558
559         return 0;
560 }
561
562 /****************************************************************************/
563 static int h245_help(struct sk_buff *skb, unsigned int protoff,
564                      struct nf_conn *ct, enum ip_conntrack_info ctinfo)
565 {
566         static MultimediaSystemControlMessage mscm;
567         unsigned char *data = NULL;
568         int datalen;
569         int dataoff;
570         int ret;
571
572         /* Until there's been traffic both ways, don't look in packets. */
573         if (ctinfo != IP_CT_ESTABLISHED &&
574             ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) {
575                 return NF_ACCEPT;
576         }
577         pr_debug("nf_ct_h245: skblen = %u\n", skb->len);
578
579         spin_lock_bh(&nf_h323_lock);
580
581         /* Process each TPKT */
582         while (get_tpkt_data(skb, protoff, ct, ctinfo,
583                              &data, &datalen, &dataoff)) {
584                 pr_debug("nf_ct_h245: TPKT len=%d ", datalen);
585                 NF_CT_DUMP_TUPLE(&ct->tuplehash[CTINFO2DIR(ctinfo)].tuple);
586
587                 /* Decode H.245 signal */
588                 ret = DecodeMultimediaSystemControlMessage(data, datalen,
589                                                            &mscm);
590                 if (ret < 0) {
591                         pr_debug("nf_ct_h245: decoding error: %s\n",
592                                  ret == H323_ERROR_BOUND ?
593                                  "out of bound" : "out of range");
594                         /* We don't drop when decoding error */
595                         break;
596                 }
597
598                 /* Process H.245 signal */
599                 if (process_h245(skb, ct, ctinfo, &data, dataoff, &mscm) < 0)
600                         goto drop;
601         }
602
603         spin_unlock_bh(&nf_h323_lock);
604         return NF_ACCEPT;
605
606       drop:
607         spin_unlock_bh(&nf_h323_lock);
608         if (net_ratelimit())
609                 printk("nf_ct_h245: packet dropped\n");
610         return NF_DROP;
611 }
612
613 /****************************************************************************/
614 static struct nf_conntrack_helper nf_conntrack_helper_h245 __read_mostly = {
615         .name                   = "H.245",
616         .me                     = THIS_MODULE,
617         .max_expected           = H323_RTP_CHANNEL_MAX * 4 + 2 /* T.120 */,
618         .timeout                = 240,
619         .tuple.dst.protonum     = IPPROTO_UDP,
620         .help                   = h245_help
621 };
622
623 /****************************************************************************/
624 int get_h225_addr(struct nf_conn *ct, unsigned char *data,
625                   TransportAddress *taddr,
626                   union nf_conntrack_address *addr, __be16 *port)
627 {
628         unsigned char *p;
629         int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
630         int len;
631
632         switch (taddr->choice) {
633         case eTransportAddress_ipAddress:
634                 if (family != AF_INET)
635                         return 0;
636                 p = data + taddr->ipAddress.ip;
637                 len = 4;
638                 break;
639         case eTransportAddress_ip6Address:
640                 if (family != AF_INET6)
641                         return 0;
642                 p = data + taddr->ip6Address.ip;
643                 len = 16;
644                 break;
645         default:
646                 return 0;
647         }
648
649         memcpy(addr, p, len);
650         memset((void *)addr + len, 0, sizeof(*addr) - len);
651         memcpy(port, p + len, sizeof(__be16));
652
653         return 1;
654 }
655
656 /****************************************************************************/
657 static int expect_h245(struct sk_buff *skb, struct nf_conn *ct,
658                        enum ip_conntrack_info ctinfo,
659                        unsigned char **data, int dataoff,
660                        TransportAddress *taddr)
661 {
662         int dir = CTINFO2DIR(ctinfo);
663         int ret = 0;
664         __be16 port;
665         union nf_conntrack_address addr;
666         struct nf_conntrack_expect *exp;
667         typeof(nat_h245_hook) nat_h245;
668
669         /* Read h245Address */
670         if (!get_h225_addr(ct, *data, taddr, &addr, &port) ||
671             memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) ||
672             port == 0)
673                 return 0;
674
675         /* Create expect for h245 connection */
676         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
677                 return -1;
678         nf_ct_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
679                           &ct->tuplehash[!dir].tuple.src.u3,
680                           &ct->tuplehash[!dir].tuple.dst.u3,
681                           IPPROTO_TCP, NULL, &port);
682         exp->helper = &nf_conntrack_helper_h245;
683
684         if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
685                    &ct->tuplehash[!dir].tuple.dst.u3,
686                    sizeof(ct->tuplehash[dir].tuple.src.u3)) &&
687             (nat_h245 = rcu_dereference(nat_h245_hook)) &&
688             ct->status & IPS_NAT_MASK) {
689                 /* NAT needed */
690                 ret = nat_h245(skb, ct, ctinfo, data, dataoff, taddr,
691                                port, exp);
692         } else {                /* Conntrack only */
693                 if (nf_ct_expect_related(exp) == 0) {
694                         pr_debug("nf_ct_q931: expect H.245 ");
695                         NF_CT_DUMP_TUPLE(&exp->tuple);
696                 } else
697                         ret = -1;
698         }
699
700         nf_ct_expect_put(exp);
701
702         return ret;
703 }
704
705 /* If the calling party is on the same side of the forward-to party,
706  * we don't need to track the second call */
707 static int callforward_do_filter(union nf_conntrack_address *src,
708                                  union nf_conntrack_address *dst,
709                                  int family)
710 {
711         const struct nf_afinfo *afinfo;
712         struct flowi fl1, fl2;
713         int ret = 0;
714
715         /* rcu_read_lock()ed by nf_hook_slow() */
716         afinfo = nf_get_afinfo(family);
717         if (!afinfo)
718                 return 0;
719
720         memset(&fl1, 0, sizeof(fl1));
721         memset(&fl2, 0, sizeof(fl2));
722
723         switch (family) {
724         case AF_INET: {
725                 struct rtable *rt1, *rt2;
726
727                 fl1.fl4_dst = src->ip;
728                 fl2.fl4_dst = dst->ip;
729                 if (!afinfo->route((struct dst_entry **)&rt1, &fl1)) {
730                         if (!afinfo->route((struct dst_entry **)&rt2, &fl2)) {
731                                 if (rt1->rt_gateway == rt2->rt_gateway &&
732                                     rt1->u.dst.dev  == rt2->u.dst.dev)
733                                         ret = 1;
734                                 dst_release(&rt2->u.dst);
735                         }
736                         dst_release(&rt1->u.dst);
737                 }
738                 break;
739         }
740 #if defined(CONFIG_NF_CONNTRACK_IPV6) || \
741     defined(CONFIG_NF_CONNTRACK_IPV6_MODULE)
742         case AF_INET6: {
743                 struct rt6_info *rt1, *rt2;
744
745                 memcpy(&fl1.fl6_dst, src, sizeof(fl1.fl6_dst));
746                 memcpy(&fl2.fl6_dst, dst, sizeof(fl2.fl6_dst));
747                 if (!afinfo->route((struct dst_entry **)&rt1, &fl1)) {
748                         if (!afinfo->route((struct dst_entry **)&rt2, &fl2)) {
749                                 if (!memcmp(&rt1->rt6i_gateway, &rt2->rt6i_gateway,
750                                             sizeof(rt1->rt6i_gateway)) &&
751                                     rt1->u.dst.dev == rt2->u.dst.dev)
752                                         ret = 1;
753                                 dst_release(&rt2->u.dst);
754                         }
755                         dst_release(&rt1->u.dst);
756                 }
757                 break;
758         }
759 #endif
760         }
761         return ret;
762
763 }
764
765 /****************************************************************************/
766 static int expect_callforwarding(struct sk_buff *skb,
767                                  struct nf_conn *ct,
768                                  enum ip_conntrack_info ctinfo,
769                                  unsigned char **data, int dataoff,
770                                  TransportAddress *taddr)
771 {
772         int dir = CTINFO2DIR(ctinfo);
773         int ret = 0;
774         __be16 port;
775         union nf_conntrack_address addr;
776         struct nf_conntrack_expect *exp;
777         typeof(nat_callforwarding_hook) nat_callforwarding;
778
779         /* Read alternativeAddress */
780         if (!get_h225_addr(ct, *data, taddr, &addr, &port) || port == 0)
781                 return 0;
782
783         /* If the calling party is on the same side of the forward-to party,
784          * we don't need to track the second call */
785         if (callforward_filter &&
786             callforward_do_filter(&addr, &ct->tuplehash[!dir].tuple.src.u3,
787                                   ct->tuplehash[!dir].tuple.src.l3num)) {
788                 pr_debug("nf_ct_q931: Call Forwarding not tracked\n");
789                 return 0;
790         }
791
792         /* Create expect for the second call leg */
793         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
794                 return -1;
795         nf_ct_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
796                           &ct->tuplehash[!dir].tuple.src.u3, &addr,
797                           IPPROTO_TCP, NULL, &port);
798         exp->helper = nf_conntrack_helper_q931;
799
800         if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
801                    &ct->tuplehash[!dir].tuple.dst.u3,
802                    sizeof(ct->tuplehash[dir].tuple.src.u3)) &&
803             (nat_callforwarding = rcu_dereference(nat_callforwarding_hook)) &&
804             ct->status & IPS_NAT_MASK) {
805                 /* Need NAT */
806                 ret = nat_callforwarding(skb, ct, ctinfo, data, dataoff,
807                                          taddr, port, exp);
808         } else {                /* Conntrack only */
809                 if (nf_ct_expect_related(exp) == 0) {
810                         pr_debug("nf_ct_q931: expect Call Forwarding ");
811                         NF_CT_DUMP_TUPLE(&exp->tuple);
812                 } else
813                         ret = -1;
814         }
815
816         nf_ct_expect_put(exp);
817
818         return ret;
819 }
820
821 /****************************************************************************/
822 static int process_setup(struct sk_buff *skb, struct nf_conn *ct,
823                          enum ip_conntrack_info ctinfo,
824                          unsigned char **data, int dataoff,
825                          Setup_UUIE *setup)
826 {
827         int dir = CTINFO2DIR(ctinfo);
828         int ret;
829         int i;
830         __be16 port;
831         union nf_conntrack_address addr;
832         typeof(set_h225_addr_hook) set_h225_addr;
833
834         pr_debug("nf_ct_q931: Setup\n");
835
836         if (setup->options & eSetup_UUIE_h245Address) {
837                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
838                                   &setup->h245Address);
839                 if (ret < 0)
840                         return -1;
841         }
842
843         set_h225_addr = rcu_dereference(set_h225_addr_hook);
844         if ((setup->options & eSetup_UUIE_destCallSignalAddress) &&
845             (set_h225_addr) && ct->status && IPS_NAT_MASK &&
846             get_h225_addr(ct, *data, &setup->destCallSignalAddress,
847                           &addr, &port) &&
848             memcmp(&addr, &ct->tuplehash[!dir].tuple.src.u3, sizeof(addr))) {
849                 pr_debug("nf_ct_q931: set destCallSignalAddress "
850                          NIP6_FMT ":%hu->" NIP6_FMT ":%hu\n",
851                          NIP6(*(struct in6_addr *)&addr), ntohs(port),
852                          NIP6(*(struct in6_addr *)&ct->tuplehash[!dir].tuple.src.u3),
853                          ntohs(ct->tuplehash[!dir].tuple.src.u.tcp.port));
854                 ret = set_h225_addr(skb, data, dataoff,
855                                     &setup->destCallSignalAddress,
856                                     &ct->tuplehash[!dir].tuple.src.u3,
857                                     ct->tuplehash[!dir].tuple.src.u.tcp.port);
858                 if (ret < 0)
859                         return -1;
860         }
861
862         if ((setup->options & eSetup_UUIE_sourceCallSignalAddress) &&
863             (set_h225_addr) && ct->status & IPS_NAT_MASK &&
864             get_h225_addr(ct, *data, &setup->sourceCallSignalAddress,
865                           &addr, &port) &&
866             memcmp(&addr, &ct->tuplehash[!dir].tuple.dst.u3, sizeof(addr))) {
867                 pr_debug("nf_ct_q931: set sourceCallSignalAddress "
868                          NIP6_FMT ":%hu->" NIP6_FMT ":%hu\n",
869                          NIP6(*(struct in6_addr *)&addr), ntohs(port),
870                          NIP6(*(struct in6_addr *)&ct->tuplehash[!dir].tuple.dst.u3),
871                          ntohs(ct->tuplehash[!dir].tuple.dst.u.tcp.port));
872                 ret = set_h225_addr(skb, data, dataoff,
873                                     &setup->sourceCallSignalAddress,
874                                     &ct->tuplehash[!dir].tuple.dst.u3,
875                                     ct->tuplehash[!dir].tuple.dst.u.tcp.port);
876                 if (ret < 0)
877                         return -1;
878         }
879
880         if (setup->options & eSetup_UUIE_fastStart) {
881                 for (i = 0; i < setup->fastStart.count; i++) {
882                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
883                                           &setup->fastStart.item[i]);
884                         if (ret < 0)
885                                 return -1;
886                 }
887         }
888
889         return 0;
890 }
891
892 /****************************************************************************/
893 static int process_callproceeding(struct sk_buff *skb,
894                                   struct nf_conn *ct,
895                                   enum ip_conntrack_info ctinfo,
896                                   unsigned char **data, int dataoff,
897                                   CallProceeding_UUIE *callproc)
898 {
899         int ret;
900         int i;
901
902         pr_debug("nf_ct_q931: CallProceeding\n");
903
904         if (callproc->options & eCallProceeding_UUIE_h245Address) {
905                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
906                                   &callproc->h245Address);
907                 if (ret < 0)
908                         return -1;
909         }
910
911         if (callproc->options & eCallProceeding_UUIE_fastStart) {
912                 for (i = 0; i < callproc->fastStart.count; i++) {
913                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
914                                           &callproc->fastStart.item[i]);
915                         if (ret < 0)
916                                 return -1;
917                 }
918         }
919
920         return 0;
921 }
922
923 /****************************************************************************/
924 static int process_connect(struct sk_buff *skb, struct nf_conn *ct,
925                            enum ip_conntrack_info ctinfo,
926                            unsigned char **data, int dataoff,
927                            Connect_UUIE *connect)
928 {
929         int ret;
930         int i;
931
932         pr_debug("nf_ct_q931: Connect\n");
933
934         if (connect->options & eConnect_UUIE_h245Address) {
935                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
936                                   &connect->h245Address);
937                 if (ret < 0)
938                         return -1;
939         }
940
941         if (connect->options & eConnect_UUIE_fastStart) {
942                 for (i = 0; i < connect->fastStart.count; i++) {
943                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
944                                           &connect->fastStart.item[i]);
945                         if (ret < 0)
946                                 return -1;
947                 }
948         }
949
950         return 0;
951 }
952
953 /****************************************************************************/
954 static int process_alerting(struct sk_buff *skb, struct nf_conn *ct,
955                             enum ip_conntrack_info ctinfo,
956                             unsigned char **data, int dataoff,
957                             Alerting_UUIE *alert)
958 {
959         int ret;
960         int i;
961
962         pr_debug("nf_ct_q931: Alerting\n");
963
964         if (alert->options & eAlerting_UUIE_h245Address) {
965                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
966                                   &alert->h245Address);
967                 if (ret < 0)
968                         return -1;
969         }
970
971         if (alert->options & eAlerting_UUIE_fastStart) {
972                 for (i = 0; i < alert->fastStart.count; i++) {
973                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
974                                           &alert->fastStart.item[i]);
975                         if (ret < 0)
976                                 return -1;
977                 }
978         }
979
980         return 0;
981 }
982
983 /****************************************************************************/
984 static int process_facility(struct sk_buff *skb, struct nf_conn *ct,
985                             enum ip_conntrack_info ctinfo,
986                             unsigned char **data, int dataoff,
987                             Facility_UUIE *facility)
988 {
989         int ret;
990         int i;
991
992         pr_debug("nf_ct_q931: Facility\n");
993
994         if (facility->reason.choice == eFacilityReason_callForwarded) {
995                 if (facility->options & eFacility_UUIE_alternativeAddress)
996                         return expect_callforwarding(skb, ct, ctinfo, data,
997                                                      dataoff,
998                                                      &facility->
999                                                      alternativeAddress);
1000                 return 0;
1001         }
1002
1003         if (facility->options & eFacility_UUIE_h245Address) {
1004                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
1005                                   &facility->h245Address);
1006                 if (ret < 0)
1007                         return -1;
1008         }
1009
1010         if (facility->options & eFacility_UUIE_fastStart) {
1011                 for (i = 0; i < facility->fastStart.count; i++) {
1012                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
1013                                           &facility->fastStart.item[i]);
1014                         if (ret < 0)
1015                                 return -1;
1016                 }
1017         }
1018
1019         return 0;
1020 }
1021
1022 /****************************************************************************/
1023 static int process_progress(struct sk_buff *skb, struct nf_conn *ct,
1024                             enum ip_conntrack_info ctinfo,
1025                             unsigned char **data, int dataoff,
1026                             Progress_UUIE *progress)
1027 {
1028         int ret;
1029         int i;
1030
1031         pr_debug("nf_ct_q931: Progress\n");
1032
1033         if (progress->options & eProgress_UUIE_h245Address) {
1034                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
1035                                   &progress->h245Address);
1036                 if (ret < 0)
1037                         return -1;
1038         }
1039
1040         if (progress->options & eProgress_UUIE_fastStart) {
1041                 for (i = 0; i < progress->fastStart.count; i++) {
1042                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
1043                                           &progress->fastStart.item[i]);
1044                         if (ret < 0)
1045                                 return -1;
1046                 }
1047         }
1048
1049         return 0;
1050 }
1051
1052 /****************************************************************************/
1053 static int process_q931(struct sk_buff *skb, struct nf_conn *ct,
1054                         enum ip_conntrack_info ctinfo,
1055                         unsigned char **data, int dataoff, Q931 *q931)
1056 {
1057         H323_UU_PDU *pdu = &q931->UUIE.h323_uu_pdu;
1058         int i;
1059         int ret = 0;
1060
1061         switch (pdu->h323_message_body.choice) {
1062         case eH323_UU_PDU_h323_message_body_setup:
1063                 ret = process_setup(skb, ct, ctinfo, data, dataoff,
1064                                     &pdu->h323_message_body.setup);
1065                 break;
1066         case eH323_UU_PDU_h323_message_body_callProceeding:
1067                 ret = process_callproceeding(skb, ct, ctinfo, data, dataoff,
1068                                              &pdu->h323_message_body.
1069                                              callProceeding);
1070                 break;
1071         case eH323_UU_PDU_h323_message_body_connect:
1072                 ret = process_connect(skb, ct, ctinfo, data, dataoff,
1073                                       &pdu->h323_message_body.connect);
1074                 break;
1075         case eH323_UU_PDU_h323_message_body_alerting:
1076                 ret = process_alerting(skb, ct, ctinfo, data, dataoff,
1077                                        &pdu->h323_message_body.alerting);
1078                 break;
1079         case eH323_UU_PDU_h323_message_body_facility:
1080                 ret = process_facility(skb, ct, ctinfo, data, dataoff,
1081                                        &pdu->h323_message_body.facility);
1082                 break;
1083         case eH323_UU_PDU_h323_message_body_progress:
1084                 ret = process_progress(skb, ct, ctinfo, data, dataoff,
1085                                        &pdu->h323_message_body.progress);
1086                 break;
1087         default:
1088                 pr_debug("nf_ct_q931: Q.931 signal %d\n",
1089                          pdu->h323_message_body.choice);
1090                 break;
1091         }
1092
1093         if (ret < 0)
1094                 return -1;
1095
1096         if (pdu->options & eH323_UU_PDU_h245Control) {
1097                 for (i = 0; i < pdu->h245Control.count; i++) {
1098                         ret = process_h245(skb, ct, ctinfo, data, dataoff,
1099                                            &pdu->h245Control.item[i]);
1100                         if (ret < 0)
1101                                 return -1;
1102                 }
1103         }
1104
1105         return 0;
1106 }
1107
1108 /****************************************************************************/
1109 static int q931_help(struct sk_buff *skb, unsigned int protoff,
1110                      struct nf_conn *ct, enum ip_conntrack_info ctinfo)
1111 {
1112         static Q931 q931;
1113         unsigned char *data = NULL;
1114         int datalen;
1115         int dataoff;
1116         int ret;
1117
1118         /* Until there's been traffic both ways, don't look in packets. */
1119         if (ctinfo != IP_CT_ESTABLISHED &&
1120             ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) {
1121                 return NF_ACCEPT;
1122         }
1123         pr_debug("nf_ct_q931: skblen = %u\n", skb->len);
1124
1125         spin_lock_bh(&nf_h323_lock);
1126
1127         /* Process each TPKT */
1128         while (get_tpkt_data(skb, protoff, ct, ctinfo,
1129                              &data, &datalen, &dataoff)) {
1130                 pr_debug("nf_ct_q931: TPKT len=%d ", datalen);
1131                 NF_CT_DUMP_TUPLE(&ct->tuplehash[CTINFO2DIR(ctinfo)].tuple);
1132
1133                 /* Decode Q.931 signal */
1134                 ret = DecodeQ931(data, datalen, &q931);
1135                 if (ret < 0) {
1136                         pr_debug("nf_ct_q931: decoding error: %s\n",
1137                                  ret == H323_ERROR_BOUND ?
1138                                  "out of bound" : "out of range");
1139                         /* We don't drop when decoding error */
1140                         break;
1141                 }
1142
1143                 /* Process Q.931 signal */
1144                 if (process_q931(skb, ct, ctinfo, &data, dataoff, &q931) < 0)
1145                         goto drop;
1146         }
1147
1148         spin_unlock_bh(&nf_h323_lock);
1149         return NF_ACCEPT;
1150
1151       drop:
1152         spin_unlock_bh(&nf_h323_lock);
1153         if (net_ratelimit())
1154                 printk("nf_ct_q931: packet dropped\n");
1155         return NF_DROP;
1156 }
1157
1158 /****************************************************************************/
1159 static struct nf_conntrack_helper nf_conntrack_helper_q931[] __read_mostly = {
1160         {
1161                 .name                   = "Q.931",
1162                 .me                     = THIS_MODULE,
1163                                           /* T.120 and H.245 */
1164                 .max_expected           = H323_RTP_CHANNEL_MAX * 4 + 4,
1165                 .timeout                = 240,
1166                 .tuple.src.l3num        = AF_INET,
1167                 .tuple.src.u.tcp.port   = __constant_htons(Q931_PORT),
1168                 .tuple.dst.protonum     = IPPROTO_TCP,
1169                 .help                   = q931_help
1170         },
1171         {
1172                 .name                   = "Q.931",
1173                 .me                     = THIS_MODULE,
1174                                           /* T.120 and H.245 */
1175                 .max_expected           = H323_RTP_CHANNEL_MAX * 4 + 4,
1176                 .timeout                = 240,
1177                 .tuple.src.l3num        = AF_INET6,
1178                 .tuple.src.u.tcp.port   = __constant_htons(Q931_PORT),
1179                 .tuple.dst.protonum     = IPPROTO_TCP,
1180                 .help                   = q931_help
1181         },
1182 };
1183
1184 /****************************************************************************/
1185 static unsigned char *get_udp_data(struct sk_buff *skb, unsigned int protoff,
1186                                    int *datalen)
1187 {
1188         struct udphdr _uh, *uh;
1189         int dataoff;
1190
1191         uh = skb_header_pointer(skb, protoff, sizeof(_uh), &_uh);
1192         if (uh == NULL)
1193                 return NULL;
1194         dataoff = protoff + sizeof(_uh);
1195         if (dataoff >= skb->len)
1196                 return NULL;
1197         *datalen = skb->len - dataoff;
1198         return skb_header_pointer(skb, dataoff, *datalen, h323_buffer);
1199 }
1200
1201 /****************************************************************************/
1202 static struct nf_conntrack_expect *find_expect(struct nf_conn *ct,
1203                                                union nf_conntrack_address *addr,
1204                                                __be16 port)
1205 {
1206         struct nf_conntrack_expect *exp;
1207         struct nf_conntrack_tuple tuple;
1208
1209         memset(&tuple.src.u3, 0, sizeof(tuple.src.u3));
1210         tuple.src.u.tcp.port = 0;
1211         memcpy(&tuple.dst.u3, addr, sizeof(tuple.dst.u3));
1212         tuple.dst.u.tcp.port = port;
1213         tuple.dst.protonum = IPPROTO_TCP;
1214
1215         exp = __nf_ct_expect_find(&tuple);
1216         if (exp && exp->master == ct)
1217                 return exp;
1218         return NULL;
1219 }
1220
1221 /****************************************************************************/
1222 static int set_expect_timeout(struct nf_conntrack_expect *exp,
1223                               unsigned timeout)
1224 {
1225         if (!exp || !del_timer(&exp->timeout))
1226                 return 0;
1227
1228         exp->timeout.expires = jiffies + timeout * HZ;
1229         add_timer(&exp->timeout);
1230
1231         return 1;
1232 }
1233
1234 /****************************************************************************/
1235 static int expect_q931(struct sk_buff *skb, struct nf_conn *ct,
1236                        enum ip_conntrack_info ctinfo,
1237                        unsigned char **data,
1238                        TransportAddress *taddr, int count)
1239 {
1240         struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1241         int dir = CTINFO2DIR(ctinfo);
1242         int ret = 0;
1243         int i;
1244         __be16 port;
1245         union nf_conntrack_address addr;
1246         struct nf_conntrack_expect *exp;
1247         typeof(nat_q931_hook) nat_q931;
1248
1249         /* Look for the first related address */
1250         for (i = 0; i < count; i++) {
1251                 if (get_h225_addr(ct, *data, &taddr[i], &addr, &port) &&
1252                     memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3,
1253                            sizeof(addr)) == 0 && port != 0)
1254                         break;
1255         }
1256
1257         if (i >= count)         /* Not found */
1258                 return 0;
1259
1260         /* Create expect for Q.931 */
1261         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
1262                 return -1;
1263         nf_ct_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
1264                           gkrouted_only ? /* only accept calls from GK? */
1265                                 &ct->tuplehash[!dir].tuple.src.u3 : NULL,
1266                           &ct->tuplehash[!dir].tuple.dst.u3,
1267                           IPPROTO_TCP, NULL, &port);
1268         exp->helper = nf_conntrack_helper_q931;
1269         exp->flags = NF_CT_EXPECT_PERMANENT;    /* Accept multiple calls */
1270
1271         nat_q931 = rcu_dereference(nat_q931_hook);
1272         if (nat_q931 && ct->status & IPS_NAT_MASK) {    /* Need NAT */
1273                 ret = nat_q931(skb, ct, ctinfo, data, taddr, i, port, exp);
1274         } else {                /* Conntrack only */
1275                 if (nf_ct_expect_related(exp) == 0) {
1276                         pr_debug("nf_ct_ras: expect Q.931 ");
1277                         NF_CT_DUMP_TUPLE(&exp->tuple);
1278
1279                         /* Save port for looking up expect in processing RCF */
1280                         info->sig_port[dir] = port;
1281                 } else
1282                         ret = -1;
1283         }
1284
1285         nf_ct_expect_put(exp);
1286
1287         return ret;
1288 }
1289
1290 /****************************************************************************/
1291 static int process_grq(struct sk_buff *skb, struct nf_conn *ct,
1292                        enum ip_conntrack_info ctinfo,
1293                        unsigned char **data, GatekeeperRequest *grq)
1294 {
1295         typeof(set_ras_addr_hook) set_ras_addr;
1296
1297         pr_debug("nf_ct_ras: GRQ\n");
1298
1299         set_ras_addr = rcu_dereference(set_ras_addr_hook);
1300         if (set_ras_addr && ct->status & IPS_NAT_MASK)  /* NATed */
1301                 return set_ras_addr(skb, ct, ctinfo, data,
1302                                     &grq->rasAddress, 1);
1303         return 0;
1304 }
1305
1306 /****************************************************************************/
1307 static int process_gcf(struct sk_buff *skb, struct nf_conn *ct,
1308                        enum ip_conntrack_info ctinfo,
1309                        unsigned char **data, GatekeeperConfirm *gcf)
1310 {
1311         int dir = CTINFO2DIR(ctinfo);
1312         int ret = 0;
1313         __be16 port;
1314         union nf_conntrack_address addr;
1315         struct nf_conntrack_expect *exp;
1316
1317         pr_debug("nf_ct_ras: GCF\n");
1318
1319         if (!get_h225_addr(ct, *data, &gcf->rasAddress, &addr, &port))
1320                 return 0;
1321
1322         /* Registration port is the same as discovery port */
1323         if (!memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) &&
1324             port == ct->tuplehash[dir].tuple.src.u.udp.port)
1325                 return 0;
1326
1327         /* Avoid RAS expectation loops. A GCF is never expected. */
1328         if (test_bit(IPS_EXPECTED_BIT, &ct->status))
1329                 return 0;
1330
1331         /* Need new expect */
1332         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
1333                 return -1;
1334         nf_ct_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
1335                           &ct->tuplehash[!dir].tuple.src.u3, &addr,
1336                           IPPROTO_UDP, NULL, &port);
1337         exp->helper = nf_conntrack_helper_ras;
1338
1339         if (nf_ct_expect_related(exp) == 0) {
1340                 pr_debug("nf_ct_ras: expect RAS ");
1341                 NF_CT_DUMP_TUPLE(&exp->tuple);
1342         } else
1343                 ret = -1;
1344
1345         nf_ct_expect_put(exp);
1346
1347         return ret;
1348 }
1349
1350 /****************************************************************************/
1351 static int process_rrq(struct sk_buff *skb, struct nf_conn *ct,
1352                        enum ip_conntrack_info ctinfo,
1353                        unsigned char **data, RegistrationRequest *rrq)
1354 {
1355         struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1356         int ret;
1357         typeof(set_ras_addr_hook) set_ras_addr;
1358
1359         pr_debug("nf_ct_ras: RRQ\n");
1360
1361         ret = expect_q931(skb, ct, ctinfo, data,
1362                           rrq->callSignalAddress.item,
1363                           rrq->callSignalAddress.count);
1364         if (ret < 0)
1365                 return -1;
1366
1367         set_ras_addr = rcu_dereference(set_ras_addr_hook);
1368         if (set_ras_addr && ct->status & IPS_NAT_MASK) {
1369                 ret = set_ras_addr(skb, ct, ctinfo, data,
1370                                    rrq->rasAddress.item,
1371                                    rrq->rasAddress.count);
1372                 if (ret < 0)
1373                         return -1;
1374         }
1375
1376         if (rrq->options & eRegistrationRequest_timeToLive) {
1377                 pr_debug("nf_ct_ras: RRQ TTL = %u seconds\n", rrq->timeToLive);
1378                 info->timeout = rrq->timeToLive;
1379         } else
1380                 info->timeout = default_rrq_ttl;
1381
1382         return 0;
1383 }
1384
1385 /****************************************************************************/
1386 static int process_rcf(struct sk_buff *skb, struct nf_conn *ct,
1387                        enum ip_conntrack_info ctinfo,
1388                        unsigned char **data, RegistrationConfirm *rcf)
1389 {
1390         struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1391         int dir = CTINFO2DIR(ctinfo);
1392         int ret;
1393         struct nf_conntrack_expect *exp;
1394         typeof(set_sig_addr_hook) set_sig_addr;
1395
1396         pr_debug("nf_ct_ras: RCF\n");
1397
1398         set_sig_addr = rcu_dereference(set_sig_addr_hook);
1399         if (set_sig_addr && ct->status & IPS_NAT_MASK) {
1400                 ret = set_sig_addr(skb, ct, ctinfo, data,
1401                                         rcf->callSignalAddress.item,
1402                                         rcf->callSignalAddress.count);
1403                 if (ret < 0)
1404                         return -1;
1405         }
1406
1407         if (rcf->options & eRegistrationConfirm_timeToLive) {
1408                 pr_debug("nf_ct_ras: RCF TTL = %u seconds\n", rcf->timeToLive);
1409                 info->timeout = rcf->timeToLive;
1410         }
1411
1412         if (info->timeout > 0) {
1413                 pr_debug("nf_ct_ras: set RAS connection timeout to "
1414                          "%u seconds\n", info->timeout);
1415                 nf_ct_refresh(ct, skb, info->timeout * HZ);
1416
1417                 /* Set expect timeout */
1418                 read_lock_bh(&nf_conntrack_lock);
1419                 exp = find_expect(ct, &ct->tuplehash[dir].tuple.dst.u3,
1420                                   info->sig_port[!dir]);
1421                 if (exp) {
1422                         pr_debug("nf_ct_ras: set Q.931 expect "
1423                                  "timeout to %u seconds for",
1424                                  info->timeout);
1425                         NF_CT_DUMP_TUPLE(&exp->tuple);
1426                         set_expect_timeout(exp, info->timeout);
1427                 }
1428                 read_unlock_bh(&nf_conntrack_lock);
1429         }
1430
1431         return 0;
1432 }
1433
1434 /****************************************************************************/
1435 static int process_urq(struct sk_buff *skb, struct nf_conn *ct,
1436                        enum ip_conntrack_info ctinfo,
1437                        unsigned char **data, UnregistrationRequest *urq)
1438 {
1439         struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1440         int dir = CTINFO2DIR(ctinfo);
1441         int ret;
1442         typeof(set_sig_addr_hook) set_sig_addr;
1443
1444         pr_debug("nf_ct_ras: URQ\n");
1445
1446         set_sig_addr = rcu_dereference(set_sig_addr_hook);
1447         if (set_sig_addr && ct->status & IPS_NAT_MASK) {
1448                 ret = set_sig_addr(skb, ct, ctinfo, data,
1449                                    urq->callSignalAddress.item,
1450                                    urq->callSignalAddress.count);
1451                 if (ret < 0)
1452                         return -1;
1453         }
1454
1455         /* Clear old expect */
1456         nf_ct_remove_expectations(ct);
1457         info->sig_port[dir] = 0;
1458         info->sig_port[!dir] = 0;
1459
1460         /* Give it 30 seconds for UCF or URJ */
1461         nf_ct_refresh(ct, skb, 30 * HZ);
1462
1463         return 0;
1464 }
1465
1466 /****************************************************************************/
1467 static int process_arq(struct sk_buff *skb, struct nf_conn *ct,
1468                        enum ip_conntrack_info ctinfo,
1469                        unsigned char **data, AdmissionRequest *arq)
1470 {
1471         struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1472         int dir = CTINFO2DIR(ctinfo);
1473         __be16 port;
1474         union nf_conntrack_address addr;
1475         typeof(set_h225_addr_hook) set_h225_addr;
1476
1477         pr_debug("nf_ct_ras: ARQ\n");
1478
1479         set_h225_addr = rcu_dereference(set_h225_addr_hook);
1480         if ((arq->options & eAdmissionRequest_destCallSignalAddress) &&
1481             get_h225_addr(ct, *data, &arq->destCallSignalAddress,
1482                           &addr, &port) &&
1483             !memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) &&
1484             port == info->sig_port[dir] &&
1485             set_h225_addr && ct->status & IPS_NAT_MASK) {
1486                 /* Answering ARQ */
1487                 return set_h225_addr(skb, data, 0,
1488                                      &arq->destCallSignalAddress,
1489                                      &ct->tuplehash[!dir].tuple.dst.u3,
1490                                      info->sig_port[!dir]);
1491         }
1492
1493         if ((arq->options & eAdmissionRequest_srcCallSignalAddress) &&
1494             get_h225_addr(ct, *data, &arq->srcCallSignalAddress,
1495                           &addr, &port) &&
1496             !memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) &&
1497             set_h225_addr && ct->status & IPS_NAT_MASK) {
1498                 /* Calling ARQ */
1499                 return set_h225_addr(skb, data, 0,
1500                                      &arq->srcCallSignalAddress,
1501                                      &ct->tuplehash[!dir].tuple.dst.u3,
1502                                      port);
1503         }
1504
1505         return 0;
1506 }
1507
1508 /****************************************************************************/
1509 static int process_acf(struct sk_buff *skb, struct nf_conn *ct,
1510                        enum ip_conntrack_info ctinfo,
1511                        unsigned char **data, AdmissionConfirm *acf)
1512 {
1513         int dir = CTINFO2DIR(ctinfo);
1514         int ret = 0;
1515         __be16 port;
1516         union nf_conntrack_address addr;
1517         struct nf_conntrack_expect *exp;
1518         typeof(set_sig_addr_hook) set_sig_addr;
1519
1520         pr_debug("nf_ct_ras: ACF\n");
1521
1522         if (!get_h225_addr(ct, *data, &acf->destCallSignalAddress,
1523                            &addr, &port))
1524                 return 0;
1525
1526         if (!memcmp(&addr, &ct->tuplehash[dir].tuple.dst.u3, sizeof(addr))) {
1527                 /* Answering ACF */
1528                 set_sig_addr = rcu_dereference(set_sig_addr_hook);
1529                 if (set_sig_addr && ct->status & IPS_NAT_MASK)
1530                         return set_sig_addr(skb, ct, ctinfo, data,
1531                                             &acf->destCallSignalAddress, 1);
1532                 return 0;
1533         }
1534
1535         /* Need new expect */
1536         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
1537                 return -1;
1538         nf_ct_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
1539                           &ct->tuplehash[!dir].tuple.src.u3, &addr,
1540                           IPPROTO_TCP, NULL, &port);
1541         exp->flags = NF_CT_EXPECT_PERMANENT;
1542         exp->helper = nf_conntrack_helper_q931;
1543
1544         if (nf_ct_expect_related(exp) == 0) {
1545                 pr_debug("nf_ct_ras: expect Q.931 ");
1546                 NF_CT_DUMP_TUPLE(&exp->tuple);
1547         } else
1548                 ret = -1;
1549
1550         nf_ct_expect_put(exp);
1551
1552         return ret;
1553 }
1554
1555 /****************************************************************************/
1556 static int process_lrq(struct sk_buff *skb, struct nf_conn *ct,
1557                        enum ip_conntrack_info ctinfo,
1558                        unsigned char **data, LocationRequest *lrq)
1559 {
1560         typeof(set_ras_addr_hook) set_ras_addr;
1561
1562         pr_debug("nf_ct_ras: LRQ\n");
1563
1564         set_ras_addr = rcu_dereference(set_ras_addr_hook);
1565         if (set_ras_addr && ct->status & IPS_NAT_MASK)
1566                 return set_ras_addr(skb, ct, ctinfo, data,
1567                                     &lrq->replyAddress, 1);
1568         return 0;
1569 }
1570
1571 /****************************************************************************/
1572 static int process_lcf(struct sk_buff *skb, struct nf_conn *ct,
1573                        enum ip_conntrack_info ctinfo,
1574                        unsigned char **data, LocationConfirm *lcf)
1575 {
1576         int dir = CTINFO2DIR(ctinfo);
1577         int ret = 0;
1578         __be16 port;
1579         union nf_conntrack_address addr;
1580         struct nf_conntrack_expect *exp;
1581
1582         pr_debug("nf_ct_ras: LCF\n");
1583
1584         if (!get_h225_addr(ct, *data, &lcf->callSignalAddress,
1585                            &addr, &port))
1586                 return 0;
1587
1588         /* Need new expect for call signal */
1589         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
1590                 return -1;
1591         nf_ct_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
1592                           &ct->tuplehash[!dir].tuple.src.u3, &addr,
1593                           IPPROTO_TCP, NULL, &port);
1594         exp->flags = NF_CT_EXPECT_PERMANENT;
1595         exp->helper = nf_conntrack_helper_q931;
1596
1597         if (nf_ct_expect_related(exp) == 0) {
1598                 pr_debug("nf_ct_ras: expect Q.931 ");
1599                 NF_CT_DUMP_TUPLE(&exp->tuple);
1600         } else
1601                 ret = -1;
1602
1603         nf_ct_expect_put(exp);
1604
1605         /* Ignore rasAddress */
1606
1607         return ret;
1608 }
1609
1610 /****************************************************************************/
1611 static int process_irr(struct sk_buff *skb, struct nf_conn *ct,
1612                        enum ip_conntrack_info ctinfo,
1613                        unsigned char **data, InfoRequestResponse *irr)
1614 {
1615         int ret;
1616         typeof(set_ras_addr_hook) set_ras_addr;
1617         typeof(set_sig_addr_hook) set_sig_addr;
1618
1619         pr_debug("nf_ct_ras: IRR\n");
1620
1621         set_ras_addr = rcu_dereference(set_ras_addr_hook);
1622         if (set_ras_addr && ct->status & IPS_NAT_MASK) {
1623                 ret = set_ras_addr(skb, ct, ctinfo, data,
1624                                    &irr->rasAddress, 1);
1625                 if (ret < 0)
1626                         return -1;
1627         }
1628
1629         set_sig_addr = rcu_dereference(set_sig_addr_hook);
1630         if (set_sig_addr && ct->status & IPS_NAT_MASK) {
1631                 ret = set_sig_addr(skb, ct, ctinfo, data,
1632                                         irr->callSignalAddress.item,
1633                                         irr->callSignalAddress.count);
1634                 if (ret < 0)
1635                         return -1;
1636         }
1637
1638         return 0;
1639 }
1640
1641 /****************************************************************************/
1642 static int process_ras(struct sk_buff *skb, struct nf_conn *ct,
1643                        enum ip_conntrack_info ctinfo,
1644                        unsigned char **data, RasMessage *ras)
1645 {
1646         switch (ras->choice) {
1647         case eRasMessage_gatekeeperRequest:
1648                 return process_grq(skb, ct, ctinfo, data,
1649                                    &ras->gatekeeperRequest);
1650         case eRasMessage_gatekeeperConfirm:
1651                 return process_gcf(skb, ct, ctinfo, data,
1652                                    &ras->gatekeeperConfirm);
1653         case eRasMessage_registrationRequest:
1654                 return process_rrq(skb, ct, ctinfo, data,
1655                                    &ras->registrationRequest);
1656         case eRasMessage_registrationConfirm:
1657                 return process_rcf(skb, ct, ctinfo, data,
1658                                    &ras->registrationConfirm);
1659         case eRasMessage_unregistrationRequest:
1660                 return process_urq(skb, ct, ctinfo, data,
1661                                    &ras->unregistrationRequest);
1662         case eRasMessage_admissionRequest:
1663                 return process_arq(skb, ct, ctinfo, data,
1664                                    &ras->admissionRequest);
1665         case eRasMessage_admissionConfirm:
1666                 return process_acf(skb, ct, ctinfo, data,
1667                                    &ras->admissionConfirm);
1668         case eRasMessage_locationRequest:
1669                 return process_lrq(skb, ct, ctinfo, data,
1670                                    &ras->locationRequest);
1671         case eRasMessage_locationConfirm:
1672                 return process_lcf(skb, ct, ctinfo, data,
1673                                    &ras->locationConfirm);
1674         case eRasMessage_infoRequestResponse:
1675                 return process_irr(skb, ct, ctinfo, data,
1676                                    &ras->infoRequestResponse);
1677         default:
1678                 pr_debug("nf_ct_ras: RAS message %d\n", ras->choice);
1679                 break;
1680         }
1681
1682         return 0;
1683 }
1684
1685 /****************************************************************************/
1686 static int ras_help(struct sk_buff *skb, unsigned int protoff,
1687                     struct nf_conn *ct, enum ip_conntrack_info ctinfo)
1688 {
1689         static RasMessage ras;
1690         unsigned char *data;
1691         int datalen = 0;
1692         int ret;
1693
1694         pr_debug("nf_ct_ras: skblen = %u\n", skb->len);
1695
1696         spin_lock_bh(&nf_h323_lock);
1697
1698         /* Get UDP data */
1699         data = get_udp_data(skb, protoff, &datalen);
1700         if (data == NULL)
1701                 goto accept;
1702         pr_debug("nf_ct_ras: RAS message len=%d ", datalen);
1703         NF_CT_DUMP_TUPLE(&ct->tuplehash[CTINFO2DIR(ctinfo)].tuple);
1704
1705         /* Decode RAS message */
1706         ret = DecodeRasMessage(data, datalen, &ras);
1707         if (ret < 0) {
1708                 pr_debug("nf_ct_ras: decoding error: %s\n",
1709                          ret == H323_ERROR_BOUND ?
1710                          "out of bound" : "out of range");
1711                 goto accept;
1712         }
1713
1714         /* Process RAS message */
1715         if (process_ras(skb, ct, ctinfo, &data, &ras) < 0)
1716                 goto drop;
1717
1718       accept:
1719         spin_unlock_bh(&nf_h323_lock);
1720         return NF_ACCEPT;
1721
1722       drop:
1723         spin_unlock_bh(&nf_h323_lock);
1724         if (net_ratelimit())
1725                 printk("nf_ct_ras: packet dropped\n");
1726         return NF_DROP;
1727 }
1728
1729 /****************************************************************************/
1730 static struct nf_conntrack_helper nf_conntrack_helper_ras[] __read_mostly = {
1731         {
1732                 .name                   = "RAS",
1733                 .me                     = THIS_MODULE,
1734                 .max_expected           = 32,
1735                 .timeout                = 240,
1736                 .tuple.src.l3num        = AF_INET,
1737                 .tuple.src.u.udp.port   = __constant_htons(RAS_PORT),
1738                 .tuple.dst.protonum     = IPPROTO_UDP,
1739                 .help                   = ras_help,
1740         },
1741         {
1742                 .name                   = "RAS",
1743                 .me                     = THIS_MODULE,
1744                 .max_expected           = 32,
1745                 .timeout                = 240,
1746                 .tuple.src.l3num        = AF_INET6,
1747                 .tuple.src.u.udp.port   = __constant_htons(RAS_PORT),
1748                 .tuple.dst.protonum     = IPPROTO_UDP,
1749                 .help                   = ras_help,
1750         },
1751 };
1752
1753 /****************************************************************************/
1754 static void __exit nf_conntrack_h323_fini(void)
1755 {
1756         nf_conntrack_helper_unregister(&nf_conntrack_helper_ras[1]);
1757         nf_conntrack_helper_unregister(&nf_conntrack_helper_ras[0]);
1758         nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[1]);
1759         nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[0]);
1760         kfree(h323_buffer);
1761         pr_debug("nf_ct_h323: fini\n");
1762 }
1763
1764 /****************************************************************************/
1765 static int __init nf_conntrack_h323_init(void)
1766 {
1767         int ret;
1768
1769         h323_buffer = kmalloc(65536, GFP_KERNEL);
1770         if (!h323_buffer)
1771                 return -ENOMEM;
1772         ret = nf_conntrack_helper_register(&nf_conntrack_helper_q931[0]);
1773         if (ret < 0)
1774                 goto err1;
1775         ret = nf_conntrack_helper_register(&nf_conntrack_helper_q931[1]);
1776         if (ret < 0)
1777                 goto err2;
1778         ret = nf_conntrack_helper_register(&nf_conntrack_helper_ras[0]);
1779         if (ret < 0)
1780                 goto err3;
1781         ret = nf_conntrack_helper_register(&nf_conntrack_helper_ras[1]);
1782         if (ret < 0)
1783                 goto err4;
1784         pr_debug("nf_ct_h323: init success\n");
1785         return 0;
1786
1787 err4:
1788         nf_conntrack_helper_unregister(&nf_conntrack_helper_ras[0]);
1789 err3:
1790         nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[1]);
1791 err2:
1792         nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[0]);
1793 err1:
1794         return ret;
1795 }
1796
1797 /****************************************************************************/
1798 module_init(nf_conntrack_h323_init);
1799 module_exit(nf_conntrack_h323_fini);
1800
1801 EXPORT_SYMBOL_GPL(get_h225_addr);
1802 EXPORT_SYMBOL_GPL(set_h245_addr_hook);
1803 EXPORT_SYMBOL_GPL(set_h225_addr_hook);
1804 EXPORT_SYMBOL_GPL(set_sig_addr_hook);
1805 EXPORT_SYMBOL_GPL(set_ras_addr_hook);
1806 EXPORT_SYMBOL_GPL(nat_rtp_rtcp_hook);
1807 EXPORT_SYMBOL_GPL(nat_t120_hook);
1808 EXPORT_SYMBOL_GPL(nat_h245_hook);
1809 EXPORT_SYMBOL_GPL(nat_callforwarding_hook);
1810 EXPORT_SYMBOL_GPL(nat_q931_hook);
1811
1812 MODULE_AUTHOR("Jing Min Zhao <zhaojingmin@users.sourceforge.net>");
1813 MODULE_DESCRIPTION("H.323 connection tracking helper");
1814 MODULE_LICENSE("GPL");
1815 MODULE_ALIAS("ip_conntrack_h323");