99e385d5b707eab5690ce436afacef46a4e5c747
[linux-2.6.git] / 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_inet_addr *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_inet_addr *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         const struct tcphdr *th;
118         struct tcphdr _tcph;
119         int tcpdatalen;
120         int tcpdataoff;
121         unsigned char *tpkt;
122         int tpktlen;
123         int tpktoff;
124
125         /* Get TCP header */
126         th = skb_header_pointer(skb, protoff, sizeof(_tcph), &_tcph);
127         if (th == NULL)
128                 return 0;
129
130         /* Get TCP data offset */
131         tcpdataoff = protoff + th->doff * 4;
132
133         /* Get TCP data length */
134         tcpdatalen = skb->len - tcpdataoff;
135         if (tcpdatalen <= 0)    /* No TCP data */
136                 goto clear_out;
137
138         if (*data == NULL) {    /* first TPKT */
139                 /* Get first TPKT pointer */
140                 tpkt = skb_header_pointer(skb, tcpdataoff, tcpdatalen,
141                                           h323_buffer);
142                 BUG_ON(tpkt == NULL);
143
144                 /* Validate TPKT identifier */
145                 if (tcpdatalen < 4 || tpkt[0] != 0x03 || tpkt[1] != 0) {
146                         /* Netmeeting sends TPKT header and data separately */
147                         if (info->tpkt_len[dir] > 0) {
148                                 pr_debug("nf_ct_h323: previous packet "
149                                          "indicated separate TPKT data of %hu "
150                                          "bytes\n", info->tpkt_len[dir]);
151                                 if (info->tpkt_len[dir] <= tcpdatalen) {
152                                         /* Yes, there was a TPKT header
153                                          * received */
154                                         *data = tpkt;
155                                         *datalen = info->tpkt_len[dir];
156                                         *dataoff = 0;
157                                         goto out;
158                                 }
159
160                                 /* Fragmented TPKT */
161                                 pr_debug("nf_ct_h323: fragmented TPKT\n");
162                                 goto clear_out;
163                         }
164
165                         /* It is not even a TPKT */
166                         return 0;
167                 }
168                 tpktoff = 0;
169         } else {                /* Next TPKT */
170                 tpktoff = *dataoff + *datalen;
171                 tcpdatalen -= tpktoff;
172                 if (tcpdatalen <= 4)    /* No more TPKT */
173                         goto clear_out;
174                 tpkt = *data + *datalen;
175
176                 /* Validate TPKT identifier */
177                 if (tpkt[0] != 0x03 || tpkt[1] != 0)
178                         goto clear_out;
179         }
180
181         /* Validate TPKT length */
182         tpktlen = tpkt[2] * 256 + tpkt[3];
183         if (tpktlen < 4)
184                 goto clear_out;
185         if (tpktlen > tcpdatalen) {
186                 if (tcpdatalen == 4) {  /* Separate TPKT header */
187                         /* Netmeeting sends TPKT header and data separately */
188                         pr_debug("nf_ct_h323: separate TPKT header indicates "
189                                  "there will be TPKT data of %hu bytes\n",
190                                  tpktlen - 4);
191                         info->tpkt_len[dir] = tpktlen - 4;
192                         return 0;
193                 }
194
195                 if (net_ratelimit())
196                         printk("nf_ct_h323: incomplete TPKT (fragmented?)\n");
197                 goto clear_out;
198         }
199
200         /* This is the encapsulated data */
201         *data = tpkt + 4;
202         *datalen = tpktlen - 4;
203         *dataoff = tpktoff + 4;
204
205       out:
206         /* Clear TPKT length */
207         info->tpkt_len[dir] = 0;
208         return 1;
209
210       clear_out:
211         info->tpkt_len[dir] = 0;
212         return 0;
213 }
214
215 /****************************************************************************/
216 static int get_h245_addr(struct nf_conn *ct, const unsigned char *data,
217                          H245_TransportAddress *taddr,
218                          union nf_inet_addr *addr, __be16 *port)
219 {
220         const unsigned char *p;
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 (nf_ct_l3num(ct) != AF_INET)
229                         return 0;
230                 p = data + taddr->unicastAddress.iPAddress.network;
231                 len = 4;
232                 break;
233         case eUnicastAddress_iP6Address:
234                 if (nf_ct_l3num(ct) != 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_inet_addr 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, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
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, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
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_inet_addr 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, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
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 const struct nf_conntrack_expect_policy h245_exp_policy = {
615         .max_expected   = H323_RTP_CHANNEL_MAX * 4 + 2 /* T.120 */,
616         .timeout        = 240,
617 };
618
619 static struct nf_conntrack_helper nf_conntrack_helper_h245 __read_mostly = {
620         .name                   = "H.245",
621         .me                     = THIS_MODULE,
622         .tuple.dst.protonum     = IPPROTO_UDP,
623         .help                   = h245_help,
624         .expect_policy          = &h245_exp_policy,
625 };
626
627 /****************************************************************************/
628 int get_h225_addr(struct nf_conn *ct, unsigned char *data,
629                   TransportAddress *taddr,
630                   union nf_inet_addr *addr, __be16 *port)
631 {
632         const unsigned char *p;
633         int len;
634
635         switch (taddr->choice) {
636         case eTransportAddress_ipAddress:
637                 if (nf_ct_l3num(ct) != AF_INET)
638                         return 0;
639                 p = data + taddr->ipAddress.ip;
640                 len = 4;
641                 break;
642         case eTransportAddress_ip6Address:
643                 if (nf_ct_l3num(ct) != AF_INET6)
644                         return 0;
645                 p = data + taddr->ip6Address.ip;
646                 len = 16;
647                 break;
648         default:
649                 return 0;
650         }
651
652         memcpy(addr, p, len);
653         memset((void *)addr + len, 0, sizeof(*addr) - len);
654         memcpy(port, p + len, sizeof(__be16));
655
656         return 1;
657 }
658
659 /****************************************************************************/
660 static int expect_h245(struct sk_buff *skb, struct nf_conn *ct,
661                        enum ip_conntrack_info ctinfo,
662                        unsigned char **data, int dataoff,
663                        TransportAddress *taddr)
664 {
665         int dir = CTINFO2DIR(ctinfo);
666         int ret = 0;
667         __be16 port;
668         union nf_inet_addr addr;
669         struct nf_conntrack_expect *exp;
670         typeof(nat_h245_hook) nat_h245;
671
672         /* Read h245Address */
673         if (!get_h225_addr(ct, *data, taddr, &addr, &port) ||
674             memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) ||
675             port == 0)
676                 return 0;
677
678         /* Create expect for h245 connection */
679         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
680                 return -1;
681         nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
682                           &ct->tuplehash[!dir].tuple.src.u3,
683                           &ct->tuplehash[!dir].tuple.dst.u3,
684                           IPPROTO_TCP, NULL, &port);
685         exp->helper = &nf_conntrack_helper_h245;
686
687         if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
688                    &ct->tuplehash[!dir].tuple.dst.u3,
689                    sizeof(ct->tuplehash[dir].tuple.src.u3)) &&
690             (nat_h245 = rcu_dereference(nat_h245_hook)) &&
691             ct->status & IPS_NAT_MASK) {
692                 /* NAT needed */
693                 ret = nat_h245(skb, ct, ctinfo, data, dataoff, taddr,
694                                port, exp);
695         } else {                /* Conntrack only */
696                 if (nf_ct_expect_related(exp) == 0) {
697                         pr_debug("nf_ct_q931: expect H.245 ");
698                         nf_ct_dump_tuple(&exp->tuple);
699                 } else
700                         ret = -1;
701         }
702
703         nf_ct_expect_put(exp);
704
705         return ret;
706 }
707
708 /* If the calling party is on the same side of the forward-to party,
709  * we don't need to track the second call */
710 static int callforward_do_filter(const union nf_inet_addr *src,
711                                  const union nf_inet_addr *dst, int family)
712 {
713         const struct nf_afinfo *afinfo;
714         struct flowi fl1, fl2;
715         int ret = 0;
716
717         /* rcu_read_lock()ed by nf_hook_slow() */
718         afinfo = nf_get_afinfo(family);
719         if (!afinfo)
720                 return 0;
721
722         memset(&fl1, 0, sizeof(fl1));
723         memset(&fl2, 0, sizeof(fl2));
724
725         switch (family) {
726         case AF_INET: {
727                 struct rtable *rt1, *rt2;
728
729                 fl1.fl4_dst = src->ip;
730                 fl2.fl4_dst = dst->ip;
731                 if (!afinfo->route((struct dst_entry **)&rt1, &fl1)) {
732                         if (!afinfo->route((struct dst_entry **)&rt2, &fl2)) {
733                                 if (rt1->rt_gateway == rt2->rt_gateway &&
734                                     rt1->u.dst.dev  == rt2->u.dst.dev)
735                                         ret = 1;
736                                 dst_release(&rt2->u.dst);
737                         }
738                         dst_release(&rt1->u.dst);
739                 }
740                 break;
741         }
742 #if defined(CONFIG_NF_CONNTRACK_IPV6) || \
743     defined(CONFIG_NF_CONNTRACK_IPV6_MODULE)
744         case AF_INET6: {
745                 struct rt6_info *rt1, *rt2;
746
747                 memcpy(&fl1.fl6_dst, src, sizeof(fl1.fl6_dst));
748                 memcpy(&fl2.fl6_dst, dst, sizeof(fl2.fl6_dst));
749                 if (!afinfo->route((struct dst_entry **)&rt1, &fl1)) {
750                         if (!afinfo->route((struct dst_entry **)&rt2, &fl2)) {
751                                 if (!memcmp(&rt1->rt6i_gateway, &rt2->rt6i_gateway,
752                                             sizeof(rt1->rt6i_gateway)) &&
753                                     rt1->u.dst.dev == rt2->u.dst.dev)
754                                         ret = 1;
755                                 dst_release(&rt2->u.dst);
756                         }
757                         dst_release(&rt1->u.dst);
758                 }
759                 break;
760         }
761 #endif
762         }
763         return ret;
764
765 }
766
767 /****************************************************************************/
768 static int expect_callforwarding(struct sk_buff *skb,
769                                  struct nf_conn *ct,
770                                  enum ip_conntrack_info ctinfo,
771                                  unsigned char **data, int dataoff,
772                                  TransportAddress *taddr)
773 {
774         int dir = CTINFO2DIR(ctinfo);
775         int ret = 0;
776         __be16 port;
777         union nf_inet_addr addr;
778         struct nf_conntrack_expect *exp;
779         typeof(nat_callforwarding_hook) nat_callforwarding;
780
781         /* Read alternativeAddress */
782         if (!get_h225_addr(ct, *data, taddr, &addr, &port) || port == 0)
783                 return 0;
784
785         /* If the calling party is on the same side of the forward-to party,
786          * we don't need to track the second call */
787         if (callforward_filter &&
788             callforward_do_filter(&addr, &ct->tuplehash[!dir].tuple.src.u3,
789                                   nf_ct_l3num(ct))) {
790                 pr_debug("nf_ct_q931: Call Forwarding not tracked\n");
791                 return 0;
792         }
793
794         /* Create expect for the second call leg */
795         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
796                 return -1;
797         nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
798                           &ct->tuplehash[!dir].tuple.src.u3, &addr,
799                           IPPROTO_TCP, NULL, &port);
800         exp->helper = nf_conntrack_helper_q931;
801
802         if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
803                    &ct->tuplehash[!dir].tuple.dst.u3,
804                    sizeof(ct->tuplehash[dir].tuple.src.u3)) &&
805             (nat_callforwarding = rcu_dereference(nat_callforwarding_hook)) &&
806             ct->status & IPS_NAT_MASK) {
807                 /* Need NAT */
808                 ret = nat_callforwarding(skb, ct, ctinfo, data, dataoff,
809                                          taddr, port, exp);
810         } else {                /* Conntrack only */
811                 if (nf_ct_expect_related(exp) == 0) {
812                         pr_debug("nf_ct_q931: expect Call Forwarding ");
813                         nf_ct_dump_tuple(&exp->tuple);
814                 } else
815                         ret = -1;
816         }
817
818         nf_ct_expect_put(exp);
819
820         return ret;
821 }
822
823 /****************************************************************************/
824 static int process_setup(struct sk_buff *skb, struct nf_conn *ct,
825                          enum ip_conntrack_info ctinfo,
826                          unsigned char **data, int dataoff,
827                          Setup_UUIE *setup)
828 {
829         int dir = CTINFO2DIR(ctinfo);
830         int ret;
831         int i;
832         __be16 port;
833         union nf_inet_addr addr;
834         typeof(set_h225_addr_hook) set_h225_addr;
835
836         pr_debug("nf_ct_q931: Setup\n");
837
838         if (setup->options & eSetup_UUIE_h245Address) {
839                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
840                                   &setup->h245Address);
841                 if (ret < 0)
842                         return -1;
843         }
844
845         set_h225_addr = rcu_dereference(set_h225_addr_hook);
846         if ((setup->options & eSetup_UUIE_destCallSignalAddress) &&
847             (set_h225_addr) && ct->status & IPS_NAT_MASK &&
848             get_h225_addr(ct, *data, &setup->destCallSignalAddress,
849                           &addr, &port) &&
850             memcmp(&addr, &ct->tuplehash[!dir].tuple.src.u3, sizeof(addr))) {
851                 pr_debug("nf_ct_q931: set destCallSignalAddress "
852                          NIP6_FMT ":%hu->" NIP6_FMT ":%hu\n",
853                          NIP6(*(struct in6_addr *)&addr), ntohs(port),
854                          NIP6(*(struct in6_addr *)&ct->tuplehash[!dir].tuple.src.u3),
855                          ntohs(ct->tuplehash[!dir].tuple.src.u.tcp.port));
856                 ret = set_h225_addr(skb, data, dataoff,
857                                     &setup->destCallSignalAddress,
858                                     &ct->tuplehash[!dir].tuple.src.u3,
859                                     ct->tuplehash[!dir].tuple.src.u.tcp.port);
860                 if (ret < 0)
861                         return -1;
862         }
863
864         if ((setup->options & eSetup_UUIE_sourceCallSignalAddress) &&
865             (set_h225_addr) && ct->status & IPS_NAT_MASK &&
866             get_h225_addr(ct, *data, &setup->sourceCallSignalAddress,
867                           &addr, &port) &&
868             memcmp(&addr, &ct->tuplehash[!dir].tuple.dst.u3, sizeof(addr))) {
869                 pr_debug("nf_ct_q931: set sourceCallSignalAddress "
870                          NIP6_FMT ":%hu->" NIP6_FMT ":%hu\n",
871                          NIP6(*(struct in6_addr *)&addr), ntohs(port),
872                          NIP6(*(struct in6_addr *)&ct->tuplehash[!dir].tuple.dst.u3),
873                          ntohs(ct->tuplehash[!dir].tuple.dst.u.tcp.port));
874                 ret = set_h225_addr(skb, data, dataoff,
875                                     &setup->sourceCallSignalAddress,
876                                     &ct->tuplehash[!dir].tuple.dst.u3,
877                                     ct->tuplehash[!dir].tuple.dst.u.tcp.port);
878                 if (ret < 0)
879                         return -1;
880         }
881
882         if (setup->options & eSetup_UUIE_fastStart) {
883                 for (i = 0; i < setup->fastStart.count; i++) {
884                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
885                                           &setup->fastStart.item[i]);
886                         if (ret < 0)
887                                 return -1;
888                 }
889         }
890
891         return 0;
892 }
893
894 /****************************************************************************/
895 static int process_callproceeding(struct sk_buff *skb,
896                                   struct nf_conn *ct,
897                                   enum ip_conntrack_info ctinfo,
898                                   unsigned char **data, int dataoff,
899                                   CallProceeding_UUIE *callproc)
900 {
901         int ret;
902         int i;
903
904         pr_debug("nf_ct_q931: CallProceeding\n");
905
906         if (callproc->options & eCallProceeding_UUIE_h245Address) {
907                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
908                                   &callproc->h245Address);
909                 if (ret < 0)
910                         return -1;
911         }
912
913         if (callproc->options & eCallProceeding_UUIE_fastStart) {
914                 for (i = 0; i < callproc->fastStart.count; i++) {
915                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
916                                           &callproc->fastStart.item[i]);
917                         if (ret < 0)
918                                 return -1;
919                 }
920         }
921
922         return 0;
923 }
924
925 /****************************************************************************/
926 static int process_connect(struct sk_buff *skb, struct nf_conn *ct,
927                            enum ip_conntrack_info ctinfo,
928                            unsigned char **data, int dataoff,
929                            Connect_UUIE *connect)
930 {
931         int ret;
932         int i;
933
934         pr_debug("nf_ct_q931: Connect\n");
935
936         if (connect->options & eConnect_UUIE_h245Address) {
937                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
938                                   &connect->h245Address);
939                 if (ret < 0)
940                         return -1;
941         }
942
943         if (connect->options & eConnect_UUIE_fastStart) {
944                 for (i = 0; i < connect->fastStart.count; i++) {
945                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
946                                           &connect->fastStart.item[i]);
947                         if (ret < 0)
948                                 return -1;
949                 }
950         }
951
952         return 0;
953 }
954
955 /****************************************************************************/
956 static int process_alerting(struct sk_buff *skb, struct nf_conn *ct,
957                             enum ip_conntrack_info ctinfo,
958                             unsigned char **data, int dataoff,
959                             Alerting_UUIE *alert)
960 {
961         int ret;
962         int i;
963
964         pr_debug("nf_ct_q931: Alerting\n");
965
966         if (alert->options & eAlerting_UUIE_h245Address) {
967                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
968                                   &alert->h245Address);
969                 if (ret < 0)
970                         return -1;
971         }
972
973         if (alert->options & eAlerting_UUIE_fastStart) {
974                 for (i = 0; i < alert->fastStart.count; i++) {
975                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
976                                           &alert->fastStart.item[i]);
977                         if (ret < 0)
978                                 return -1;
979                 }
980         }
981
982         return 0;
983 }
984
985 /****************************************************************************/
986 static int process_facility(struct sk_buff *skb, struct nf_conn *ct,
987                             enum ip_conntrack_info ctinfo,
988                             unsigned char **data, int dataoff,
989                             Facility_UUIE *facility)
990 {
991         int ret;
992         int i;
993
994         pr_debug("nf_ct_q931: Facility\n");
995
996         if (facility->reason.choice == eFacilityReason_callForwarded) {
997                 if (facility->options & eFacility_UUIE_alternativeAddress)
998                         return expect_callforwarding(skb, ct, ctinfo, data,
999                                                      dataoff,
1000                                                      &facility->
1001                                                      alternativeAddress);
1002                 return 0;
1003         }
1004
1005         if (facility->options & eFacility_UUIE_h245Address) {
1006                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
1007                                   &facility->h245Address);
1008                 if (ret < 0)
1009                         return -1;
1010         }
1011
1012         if (facility->options & eFacility_UUIE_fastStart) {
1013                 for (i = 0; i < facility->fastStart.count; i++) {
1014                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
1015                                           &facility->fastStart.item[i]);
1016                         if (ret < 0)
1017                                 return -1;
1018                 }
1019         }
1020
1021         return 0;
1022 }
1023
1024 /****************************************************************************/
1025 static int process_progress(struct sk_buff *skb, struct nf_conn *ct,
1026                             enum ip_conntrack_info ctinfo,
1027                             unsigned char **data, int dataoff,
1028                             Progress_UUIE *progress)
1029 {
1030         int ret;
1031         int i;
1032
1033         pr_debug("nf_ct_q931: Progress\n");
1034
1035         if (progress->options & eProgress_UUIE_h245Address) {
1036                 ret = expect_h245(skb, ct, ctinfo, data, dataoff,
1037                                   &progress->h245Address);
1038                 if (ret < 0)
1039                         return -1;
1040         }
1041
1042         if (progress->options & eProgress_UUIE_fastStart) {
1043                 for (i = 0; i < progress->fastStart.count; i++) {
1044                         ret = process_olc(skb, ct, ctinfo, data, dataoff,
1045                                           &progress->fastStart.item[i]);
1046                         if (ret < 0)
1047                                 return -1;
1048                 }
1049         }
1050
1051         return 0;
1052 }
1053
1054 /****************************************************************************/
1055 static int process_q931(struct sk_buff *skb, struct nf_conn *ct,
1056                         enum ip_conntrack_info ctinfo,
1057                         unsigned char **data, int dataoff, Q931 *q931)
1058 {
1059         H323_UU_PDU *pdu = &q931->UUIE.h323_uu_pdu;
1060         int i;
1061         int ret = 0;
1062
1063         switch (pdu->h323_message_body.choice) {
1064         case eH323_UU_PDU_h323_message_body_setup:
1065                 ret = process_setup(skb, ct, ctinfo, data, dataoff,
1066                                     &pdu->h323_message_body.setup);
1067                 break;
1068         case eH323_UU_PDU_h323_message_body_callProceeding:
1069                 ret = process_callproceeding(skb, ct, ctinfo, data, dataoff,
1070                                              &pdu->h323_message_body.
1071                                              callProceeding);
1072                 break;
1073         case eH323_UU_PDU_h323_message_body_connect:
1074                 ret = process_connect(skb, ct, ctinfo, data, dataoff,
1075                                       &pdu->h323_message_body.connect);
1076                 break;
1077         case eH323_UU_PDU_h323_message_body_alerting:
1078                 ret = process_alerting(skb, ct, ctinfo, data, dataoff,
1079                                        &pdu->h323_message_body.alerting);
1080                 break;
1081         case eH323_UU_PDU_h323_message_body_facility:
1082                 ret = process_facility(skb, ct, ctinfo, data, dataoff,
1083                                        &pdu->h323_message_body.facility);
1084                 break;
1085         case eH323_UU_PDU_h323_message_body_progress:
1086                 ret = process_progress(skb, ct, ctinfo, data, dataoff,
1087                                        &pdu->h323_message_body.progress);
1088                 break;
1089         default:
1090                 pr_debug("nf_ct_q931: Q.931 signal %d\n",
1091                          pdu->h323_message_body.choice);
1092                 break;
1093         }
1094
1095         if (ret < 0)
1096                 return -1;
1097
1098         if (pdu->options & eH323_UU_PDU_h245Control) {
1099                 for (i = 0; i < pdu->h245Control.count; i++) {
1100                         ret = process_h245(skb, ct, ctinfo, data, dataoff,
1101                                            &pdu->h245Control.item[i]);
1102                         if (ret < 0)
1103                                 return -1;
1104                 }
1105         }
1106
1107         return 0;
1108 }
1109
1110 /****************************************************************************/
1111 static int q931_help(struct sk_buff *skb, unsigned int protoff,
1112                      struct nf_conn *ct, enum ip_conntrack_info ctinfo)
1113 {
1114         static Q931 q931;
1115         unsigned char *data = NULL;
1116         int datalen;
1117         int dataoff;
1118         int ret;
1119
1120         /* Until there's been traffic both ways, don't look in packets. */
1121         if (ctinfo != IP_CT_ESTABLISHED &&
1122             ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) {
1123                 return NF_ACCEPT;
1124         }
1125         pr_debug("nf_ct_q931: skblen = %u\n", skb->len);
1126
1127         spin_lock_bh(&nf_h323_lock);
1128
1129         /* Process each TPKT */
1130         while (get_tpkt_data(skb, protoff, ct, ctinfo,
1131                              &data, &datalen, &dataoff)) {
1132                 pr_debug("nf_ct_q931: TPKT len=%d ", datalen);
1133                 nf_ct_dump_tuple(&ct->tuplehash[CTINFO2DIR(ctinfo)].tuple);
1134
1135                 /* Decode Q.931 signal */
1136                 ret = DecodeQ931(data, datalen, &q931);
1137                 if (ret < 0) {
1138                         pr_debug("nf_ct_q931: decoding error: %s\n",
1139                                  ret == H323_ERROR_BOUND ?
1140                                  "out of bound" : "out of range");
1141                         /* We don't drop when decoding error */
1142                         break;
1143                 }
1144
1145                 /* Process Q.931 signal */
1146                 if (process_q931(skb, ct, ctinfo, &data, dataoff, &q931) < 0)
1147                         goto drop;
1148         }
1149
1150         spin_unlock_bh(&nf_h323_lock);
1151         return NF_ACCEPT;
1152
1153       drop:
1154         spin_unlock_bh(&nf_h323_lock);
1155         if (net_ratelimit())
1156                 printk("nf_ct_q931: packet dropped\n");
1157         return NF_DROP;
1158 }
1159
1160 /****************************************************************************/
1161 static const struct nf_conntrack_expect_policy q931_exp_policy = {
1162         /* T.120 and H.245 */
1163         .max_expected           = H323_RTP_CHANNEL_MAX * 4 + 4,
1164         .timeout                = 240,
1165 };
1166
1167 static struct nf_conntrack_helper nf_conntrack_helper_q931[] __read_mostly = {
1168         {
1169                 .name                   = "Q.931",
1170                 .me                     = THIS_MODULE,
1171                 .tuple.src.l3num        = AF_INET,
1172                 .tuple.src.u.tcp.port   = __constant_htons(Q931_PORT),
1173                 .tuple.dst.protonum     = IPPROTO_TCP,
1174                 .help                   = q931_help,
1175                 .expect_policy          = &q931_exp_policy,
1176         },
1177         {
1178                 .name                   = "Q.931",
1179                 .me                     = THIS_MODULE,
1180                 .tuple.src.l3num        = AF_INET6,
1181                 .tuple.src.u.tcp.port   = __constant_htons(Q931_PORT),
1182                 .tuple.dst.protonum     = IPPROTO_TCP,
1183                 .help                   = q931_help,
1184                 .expect_policy          = &q931_exp_policy,
1185         },
1186 };
1187
1188 /****************************************************************************/
1189 static unsigned char *get_udp_data(struct sk_buff *skb, unsigned int protoff,
1190                                    int *datalen)
1191 {
1192         const struct udphdr *uh;
1193         struct udphdr _uh;
1194         int dataoff;
1195
1196         uh = skb_header_pointer(skb, protoff, sizeof(_uh), &_uh);
1197         if (uh == NULL)
1198                 return NULL;
1199         dataoff = protoff + sizeof(_uh);
1200         if (dataoff >= skb->len)
1201                 return NULL;
1202         *datalen = skb->len - dataoff;
1203         return skb_header_pointer(skb, dataoff, *datalen, h323_buffer);
1204 }
1205
1206 /****************************************************************************/
1207 static struct nf_conntrack_expect *find_expect(struct nf_conn *ct,
1208                                                union nf_inet_addr *addr,
1209                                                __be16 port)
1210 {
1211         struct nf_conntrack_expect *exp;
1212         struct nf_conntrack_tuple tuple;
1213
1214         memset(&tuple.src.u3, 0, sizeof(tuple.src.u3));
1215         tuple.src.u.tcp.port = 0;
1216         memcpy(&tuple.dst.u3, addr, sizeof(tuple.dst.u3));
1217         tuple.dst.u.tcp.port = port;
1218         tuple.dst.protonum = IPPROTO_TCP;
1219
1220         exp = __nf_ct_expect_find(&tuple);
1221         if (exp && exp->master == ct)
1222                 return exp;
1223         return NULL;
1224 }
1225
1226 /****************************************************************************/
1227 static int set_expect_timeout(struct nf_conntrack_expect *exp,
1228                               unsigned timeout)
1229 {
1230         if (!exp || !del_timer(&exp->timeout))
1231                 return 0;
1232
1233         exp->timeout.expires = jiffies + timeout * HZ;
1234         add_timer(&exp->timeout);
1235
1236         return 1;
1237 }
1238
1239 /****************************************************************************/
1240 static int expect_q931(struct sk_buff *skb, struct nf_conn *ct,
1241                        enum ip_conntrack_info ctinfo,
1242                        unsigned char **data,
1243                        TransportAddress *taddr, int count)
1244 {
1245         struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1246         int dir = CTINFO2DIR(ctinfo);
1247         int ret = 0;
1248         int i;
1249         __be16 port;
1250         union nf_inet_addr addr;
1251         struct nf_conntrack_expect *exp;
1252         typeof(nat_q931_hook) nat_q931;
1253
1254         /* Look for the first related address */
1255         for (i = 0; i < count; i++) {
1256                 if (get_h225_addr(ct, *data, &taddr[i], &addr, &port) &&
1257                     memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3,
1258                            sizeof(addr)) == 0 && port != 0)
1259                         break;
1260         }
1261
1262         if (i >= count)         /* Not found */
1263                 return 0;
1264
1265         /* Create expect for Q.931 */
1266         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
1267                 return -1;
1268         nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
1269                           gkrouted_only ? /* only accept calls from GK? */
1270                                 &ct->tuplehash[!dir].tuple.src.u3 : NULL,
1271                           &ct->tuplehash[!dir].tuple.dst.u3,
1272                           IPPROTO_TCP, NULL, &port);
1273         exp->helper = nf_conntrack_helper_q931;
1274         exp->flags = NF_CT_EXPECT_PERMANENT;    /* Accept multiple calls */
1275
1276         nat_q931 = rcu_dereference(nat_q931_hook);
1277         if (nat_q931 && ct->status & IPS_NAT_MASK) {    /* Need NAT */
1278                 ret = nat_q931(skb, ct, ctinfo, data, taddr, i, port, exp);
1279         } else {                /* Conntrack only */
1280                 if (nf_ct_expect_related(exp) == 0) {
1281                         pr_debug("nf_ct_ras: expect Q.931 ");
1282                         nf_ct_dump_tuple(&exp->tuple);
1283
1284                         /* Save port for looking up expect in processing RCF */
1285                         info->sig_port[dir] = port;
1286                 } else
1287                         ret = -1;
1288         }
1289
1290         nf_ct_expect_put(exp);
1291
1292         return ret;
1293 }
1294
1295 /****************************************************************************/
1296 static int process_grq(struct sk_buff *skb, struct nf_conn *ct,
1297                        enum ip_conntrack_info ctinfo,
1298                        unsigned char **data, GatekeeperRequest *grq)
1299 {
1300         typeof(set_ras_addr_hook) set_ras_addr;
1301
1302         pr_debug("nf_ct_ras: GRQ\n");
1303
1304         set_ras_addr = rcu_dereference(set_ras_addr_hook);
1305         if (set_ras_addr && ct->status & IPS_NAT_MASK)  /* NATed */
1306                 return set_ras_addr(skb, ct, ctinfo, data,
1307                                     &grq->rasAddress, 1);
1308         return 0;
1309 }
1310
1311 /****************************************************************************/
1312 static int process_gcf(struct sk_buff *skb, struct nf_conn *ct,
1313                        enum ip_conntrack_info ctinfo,
1314                        unsigned char **data, GatekeeperConfirm *gcf)
1315 {
1316         int dir = CTINFO2DIR(ctinfo);
1317         int ret = 0;
1318         __be16 port;
1319         union nf_inet_addr addr;
1320         struct nf_conntrack_expect *exp;
1321
1322         pr_debug("nf_ct_ras: GCF\n");
1323
1324         if (!get_h225_addr(ct, *data, &gcf->rasAddress, &addr, &port))
1325                 return 0;
1326
1327         /* Registration port is the same as discovery port */
1328         if (!memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) &&
1329             port == ct->tuplehash[dir].tuple.src.u.udp.port)
1330                 return 0;
1331
1332         /* Avoid RAS expectation loops. A GCF is never expected. */
1333         if (test_bit(IPS_EXPECTED_BIT, &ct->status))
1334                 return 0;
1335
1336         /* Need new expect */
1337         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
1338                 return -1;
1339         nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
1340                           &ct->tuplehash[!dir].tuple.src.u3, &addr,
1341                           IPPROTO_UDP, NULL, &port);
1342         exp->helper = nf_conntrack_helper_ras;
1343
1344         if (nf_ct_expect_related(exp) == 0) {
1345                 pr_debug("nf_ct_ras: expect RAS ");
1346                 nf_ct_dump_tuple(&exp->tuple);
1347         } else
1348                 ret = -1;
1349
1350         nf_ct_expect_put(exp);
1351
1352         return ret;
1353 }
1354
1355 /****************************************************************************/
1356 static int process_rrq(struct sk_buff *skb, struct nf_conn *ct,
1357                        enum ip_conntrack_info ctinfo,
1358                        unsigned char **data, RegistrationRequest *rrq)
1359 {
1360         struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1361         int ret;
1362         typeof(set_ras_addr_hook) set_ras_addr;
1363
1364         pr_debug("nf_ct_ras: RRQ\n");
1365
1366         ret = expect_q931(skb, ct, ctinfo, data,
1367                           rrq->callSignalAddress.item,
1368                           rrq->callSignalAddress.count);
1369         if (ret < 0)
1370                 return -1;
1371
1372         set_ras_addr = rcu_dereference(set_ras_addr_hook);
1373         if (set_ras_addr && ct->status & IPS_NAT_MASK) {
1374                 ret = set_ras_addr(skb, ct, ctinfo, data,
1375                                    rrq->rasAddress.item,
1376                                    rrq->rasAddress.count);
1377                 if (ret < 0)
1378                         return -1;
1379         }
1380
1381         if (rrq->options & eRegistrationRequest_timeToLive) {
1382                 pr_debug("nf_ct_ras: RRQ TTL = %u seconds\n", rrq->timeToLive);
1383                 info->timeout = rrq->timeToLive;
1384         } else
1385                 info->timeout = default_rrq_ttl;
1386
1387         return 0;
1388 }
1389
1390 /****************************************************************************/
1391 static int process_rcf(struct sk_buff *skb, struct nf_conn *ct,
1392                        enum ip_conntrack_info ctinfo,
1393                        unsigned char **data, RegistrationConfirm *rcf)
1394 {
1395         struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1396         int dir = CTINFO2DIR(ctinfo);
1397         int ret;
1398         struct nf_conntrack_expect *exp;
1399         typeof(set_sig_addr_hook) set_sig_addr;
1400
1401         pr_debug("nf_ct_ras: RCF\n");
1402
1403         set_sig_addr = rcu_dereference(set_sig_addr_hook);
1404         if (set_sig_addr && ct->status & IPS_NAT_MASK) {
1405                 ret = set_sig_addr(skb, ct, ctinfo, data,
1406                                         rcf->callSignalAddress.item,
1407                                         rcf->callSignalAddress.count);
1408                 if (ret < 0)
1409                         return -1;
1410         }
1411
1412         if (rcf->options & eRegistrationConfirm_timeToLive) {
1413                 pr_debug("nf_ct_ras: RCF TTL = %u seconds\n", rcf->timeToLive);
1414                 info->timeout = rcf->timeToLive;
1415         }
1416
1417         if (info->timeout > 0) {
1418                 pr_debug("nf_ct_ras: set RAS connection timeout to "
1419                          "%u seconds\n", info->timeout);
1420                 nf_ct_refresh(ct, skb, info->timeout * HZ);
1421
1422                 /* Set expect timeout */
1423                 spin_lock_bh(&nf_conntrack_lock);
1424                 exp = find_expect(ct, &ct->tuplehash[dir].tuple.dst.u3,
1425                                   info->sig_port[!dir]);
1426                 if (exp) {
1427                         pr_debug("nf_ct_ras: set Q.931 expect "
1428                                  "timeout to %u seconds for",
1429                                  info->timeout);
1430                         nf_ct_dump_tuple(&exp->tuple);
1431                         set_expect_timeout(exp, info->timeout);
1432                 }
1433                 spin_unlock_bh(&nf_conntrack_lock);
1434         }
1435
1436         return 0;
1437 }
1438
1439 /****************************************************************************/
1440 static int process_urq(struct sk_buff *skb, struct nf_conn *ct,
1441                        enum ip_conntrack_info ctinfo,
1442                        unsigned char **data, UnregistrationRequest *urq)
1443 {
1444         struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1445         int dir = CTINFO2DIR(ctinfo);
1446         int ret;
1447         typeof(set_sig_addr_hook) set_sig_addr;
1448
1449         pr_debug("nf_ct_ras: URQ\n");
1450
1451         set_sig_addr = rcu_dereference(set_sig_addr_hook);
1452         if (set_sig_addr && ct->status & IPS_NAT_MASK) {
1453                 ret = set_sig_addr(skb, ct, ctinfo, data,
1454                                    urq->callSignalAddress.item,
1455                                    urq->callSignalAddress.count);
1456                 if (ret < 0)
1457                         return -1;
1458         }
1459
1460         /* Clear old expect */
1461         nf_ct_remove_expectations(ct);
1462         info->sig_port[dir] = 0;
1463         info->sig_port[!dir] = 0;
1464
1465         /* Give it 30 seconds for UCF or URJ */
1466         nf_ct_refresh(ct, skb, 30 * HZ);
1467
1468         return 0;
1469 }
1470
1471 /****************************************************************************/
1472 static int process_arq(struct sk_buff *skb, struct nf_conn *ct,
1473                        enum ip_conntrack_info ctinfo,
1474                        unsigned char **data, AdmissionRequest *arq)
1475 {
1476         const struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1477         int dir = CTINFO2DIR(ctinfo);
1478         __be16 port;
1479         union nf_inet_addr addr;
1480         typeof(set_h225_addr_hook) set_h225_addr;
1481
1482         pr_debug("nf_ct_ras: ARQ\n");
1483
1484         set_h225_addr = rcu_dereference(set_h225_addr_hook);
1485         if ((arq->options & eAdmissionRequest_destCallSignalAddress) &&
1486             get_h225_addr(ct, *data, &arq->destCallSignalAddress,
1487                           &addr, &port) &&
1488             !memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) &&
1489             port == info->sig_port[dir] &&
1490             set_h225_addr && ct->status & IPS_NAT_MASK) {
1491                 /* Answering ARQ */
1492                 return set_h225_addr(skb, data, 0,
1493                                      &arq->destCallSignalAddress,
1494                                      &ct->tuplehash[!dir].tuple.dst.u3,
1495                                      info->sig_port[!dir]);
1496         }
1497
1498         if ((arq->options & eAdmissionRequest_srcCallSignalAddress) &&
1499             get_h225_addr(ct, *data, &arq->srcCallSignalAddress,
1500                           &addr, &port) &&
1501             !memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) &&
1502             set_h225_addr && ct->status & IPS_NAT_MASK) {
1503                 /* Calling ARQ */
1504                 return set_h225_addr(skb, data, 0,
1505                                      &arq->srcCallSignalAddress,
1506                                      &ct->tuplehash[!dir].tuple.dst.u3,
1507                                      port);
1508         }
1509
1510         return 0;
1511 }
1512
1513 /****************************************************************************/
1514 static int process_acf(struct sk_buff *skb, struct nf_conn *ct,
1515                        enum ip_conntrack_info ctinfo,
1516                        unsigned char **data, AdmissionConfirm *acf)
1517 {
1518         int dir = CTINFO2DIR(ctinfo);
1519         int ret = 0;
1520         __be16 port;
1521         union nf_inet_addr addr;
1522         struct nf_conntrack_expect *exp;
1523         typeof(set_sig_addr_hook) set_sig_addr;
1524
1525         pr_debug("nf_ct_ras: ACF\n");
1526
1527         if (!get_h225_addr(ct, *data, &acf->destCallSignalAddress,
1528                            &addr, &port))
1529                 return 0;
1530
1531         if (!memcmp(&addr, &ct->tuplehash[dir].tuple.dst.u3, sizeof(addr))) {
1532                 /* Answering ACF */
1533                 set_sig_addr = rcu_dereference(set_sig_addr_hook);
1534                 if (set_sig_addr && ct->status & IPS_NAT_MASK)
1535                         return set_sig_addr(skb, ct, ctinfo, data,
1536                                             &acf->destCallSignalAddress, 1);
1537                 return 0;
1538         }
1539
1540         /* Need new expect */
1541         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
1542                 return -1;
1543         nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
1544                           &ct->tuplehash[!dir].tuple.src.u3, &addr,
1545                           IPPROTO_TCP, NULL, &port);
1546         exp->flags = NF_CT_EXPECT_PERMANENT;
1547         exp->helper = nf_conntrack_helper_q931;
1548
1549         if (nf_ct_expect_related(exp) == 0) {
1550                 pr_debug("nf_ct_ras: expect Q.931 ");
1551                 nf_ct_dump_tuple(&exp->tuple);
1552         } else
1553                 ret = -1;
1554
1555         nf_ct_expect_put(exp);
1556
1557         return ret;
1558 }
1559
1560 /****************************************************************************/
1561 static int process_lrq(struct sk_buff *skb, struct nf_conn *ct,
1562                        enum ip_conntrack_info ctinfo,
1563                        unsigned char **data, LocationRequest *lrq)
1564 {
1565         typeof(set_ras_addr_hook) set_ras_addr;
1566
1567         pr_debug("nf_ct_ras: LRQ\n");
1568
1569         set_ras_addr = rcu_dereference(set_ras_addr_hook);
1570         if (set_ras_addr && ct->status & IPS_NAT_MASK)
1571                 return set_ras_addr(skb, ct, ctinfo, data,
1572                                     &lrq->replyAddress, 1);
1573         return 0;
1574 }
1575
1576 /****************************************************************************/
1577 static int process_lcf(struct sk_buff *skb, struct nf_conn *ct,
1578                        enum ip_conntrack_info ctinfo,
1579                        unsigned char **data, LocationConfirm *lcf)
1580 {
1581         int dir = CTINFO2DIR(ctinfo);
1582         int ret = 0;
1583         __be16 port;
1584         union nf_inet_addr addr;
1585         struct nf_conntrack_expect *exp;
1586
1587         pr_debug("nf_ct_ras: LCF\n");
1588
1589         if (!get_h225_addr(ct, *data, &lcf->callSignalAddress,
1590                            &addr, &port))
1591                 return 0;
1592
1593         /* Need new expect for call signal */
1594         if ((exp = nf_ct_expect_alloc(ct)) == NULL)
1595                 return -1;
1596         nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
1597                           &ct->tuplehash[!dir].tuple.src.u3, &addr,
1598                           IPPROTO_TCP, NULL, &port);
1599         exp->flags = NF_CT_EXPECT_PERMANENT;
1600         exp->helper = nf_conntrack_helper_q931;
1601
1602         if (nf_ct_expect_related(exp) == 0) {
1603                 pr_debug("nf_ct_ras: expect Q.931 ");
1604                 nf_ct_dump_tuple(&exp->tuple);
1605         } else
1606                 ret = -1;
1607
1608         nf_ct_expect_put(exp);
1609
1610         /* Ignore rasAddress */
1611
1612         return ret;
1613 }
1614
1615 /****************************************************************************/
1616 static int process_irr(struct sk_buff *skb, struct nf_conn *ct,
1617                        enum ip_conntrack_info ctinfo,
1618                        unsigned char **data, InfoRequestResponse *irr)
1619 {
1620         int ret;
1621         typeof(set_ras_addr_hook) set_ras_addr;
1622         typeof(set_sig_addr_hook) set_sig_addr;
1623
1624         pr_debug("nf_ct_ras: IRR\n");
1625
1626         set_ras_addr = rcu_dereference(set_ras_addr_hook);
1627         if (set_ras_addr && ct->status & IPS_NAT_MASK) {
1628                 ret = set_ras_addr(skb, ct, ctinfo, data,
1629                                    &irr->rasAddress, 1);
1630                 if (ret < 0)
1631                         return -1;
1632         }
1633
1634         set_sig_addr = rcu_dereference(set_sig_addr_hook);
1635         if (set_sig_addr && ct->status & IPS_NAT_MASK) {
1636                 ret = set_sig_addr(skb, ct, ctinfo, data,
1637                                         irr->callSignalAddress.item,
1638                                         irr->callSignalAddress.count);
1639                 if (ret < 0)
1640                         return -1;
1641         }
1642
1643         return 0;
1644 }
1645
1646 /****************************************************************************/
1647 static int process_ras(struct sk_buff *skb, struct nf_conn *ct,
1648                        enum ip_conntrack_info ctinfo,
1649                        unsigned char **data, RasMessage *ras)
1650 {
1651         switch (ras->choice) {
1652         case eRasMessage_gatekeeperRequest:
1653                 return process_grq(skb, ct, ctinfo, data,
1654                                    &ras->gatekeeperRequest);
1655         case eRasMessage_gatekeeperConfirm:
1656                 return process_gcf(skb, ct, ctinfo, data,
1657                                    &ras->gatekeeperConfirm);
1658         case eRasMessage_registrationRequest:
1659                 return process_rrq(skb, ct, ctinfo, data,
1660                                    &ras->registrationRequest);
1661         case eRasMessage_registrationConfirm:
1662                 return process_rcf(skb, ct, ctinfo, data,
1663                                    &ras->registrationConfirm);
1664         case eRasMessage_unregistrationRequest:
1665                 return process_urq(skb, ct, ctinfo, data,
1666                                    &ras->unregistrationRequest);
1667         case eRasMessage_admissionRequest:
1668                 return process_arq(skb, ct, ctinfo, data,
1669                                    &ras->admissionRequest);
1670         case eRasMessage_admissionConfirm:
1671                 return process_acf(skb, ct, ctinfo, data,
1672                                    &ras->admissionConfirm);
1673         case eRasMessage_locationRequest:
1674                 return process_lrq(skb, ct, ctinfo, data,
1675                                    &ras->locationRequest);
1676         case eRasMessage_locationConfirm:
1677                 return process_lcf(skb, ct, ctinfo, data,
1678                                    &ras->locationConfirm);
1679         case eRasMessage_infoRequestResponse:
1680                 return process_irr(skb, ct, ctinfo, data,
1681                                    &ras->infoRequestResponse);
1682         default:
1683                 pr_debug("nf_ct_ras: RAS message %d\n", ras->choice);
1684                 break;
1685         }
1686
1687         return 0;
1688 }
1689
1690 /****************************************************************************/
1691 static int ras_help(struct sk_buff *skb, unsigned int protoff,
1692                     struct nf_conn *ct, enum ip_conntrack_info ctinfo)
1693 {
1694         static RasMessage ras;
1695         unsigned char *data;
1696         int datalen = 0;
1697         int ret;
1698
1699         pr_debug("nf_ct_ras: skblen = %u\n", skb->len);
1700
1701         spin_lock_bh(&nf_h323_lock);
1702
1703         /* Get UDP data */
1704         data = get_udp_data(skb, protoff, &datalen);
1705         if (data == NULL)
1706                 goto accept;
1707         pr_debug("nf_ct_ras: RAS message len=%d ", datalen);
1708         nf_ct_dump_tuple(&ct->tuplehash[CTINFO2DIR(ctinfo)].tuple);
1709
1710         /* Decode RAS message */
1711         ret = DecodeRasMessage(data, datalen, &ras);
1712         if (ret < 0) {
1713                 pr_debug("nf_ct_ras: decoding error: %s\n",
1714                          ret == H323_ERROR_BOUND ?
1715                          "out of bound" : "out of range");
1716                 goto accept;
1717         }
1718
1719         /* Process RAS message */
1720         if (process_ras(skb, ct, ctinfo, &data, &ras) < 0)
1721                 goto drop;
1722
1723       accept:
1724         spin_unlock_bh(&nf_h323_lock);
1725         return NF_ACCEPT;
1726
1727       drop:
1728         spin_unlock_bh(&nf_h323_lock);
1729         if (net_ratelimit())
1730                 printk("nf_ct_ras: packet dropped\n");
1731         return NF_DROP;
1732 }
1733
1734 /****************************************************************************/
1735 static const struct nf_conntrack_expect_policy ras_exp_policy = {
1736         .max_expected           = 32,
1737         .timeout                = 240,
1738 };
1739
1740 static struct nf_conntrack_helper nf_conntrack_helper_ras[] __read_mostly = {
1741         {
1742                 .name                   = "RAS",
1743                 .me                     = THIS_MODULE,
1744                 .tuple.src.l3num        = AF_INET,
1745                 .tuple.src.u.udp.port   = __constant_htons(RAS_PORT),
1746                 .tuple.dst.protonum     = IPPROTO_UDP,
1747                 .help                   = ras_help,
1748                 .expect_policy          = &ras_exp_policy,
1749         },
1750         {
1751                 .name                   = "RAS",
1752                 .me                     = THIS_MODULE,
1753                 .tuple.src.l3num        = AF_INET6,
1754                 .tuple.src.u.udp.port   = __constant_htons(RAS_PORT),
1755                 .tuple.dst.protonum     = IPPROTO_UDP,
1756                 .help                   = ras_help,
1757                 .expect_policy          = &ras_exp_policy,
1758         },
1759 };
1760
1761 /****************************************************************************/
1762 static void __exit nf_conntrack_h323_fini(void)
1763 {
1764         nf_conntrack_helper_unregister(&nf_conntrack_helper_ras[1]);
1765         nf_conntrack_helper_unregister(&nf_conntrack_helper_ras[0]);
1766         nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[1]);
1767         nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[0]);
1768         kfree(h323_buffer);
1769         pr_debug("nf_ct_h323: fini\n");
1770 }
1771
1772 /****************************************************************************/
1773 static int __init nf_conntrack_h323_init(void)
1774 {
1775         int ret;
1776
1777         h323_buffer = kmalloc(65536, GFP_KERNEL);
1778         if (!h323_buffer)
1779                 return -ENOMEM;
1780         ret = nf_conntrack_helper_register(&nf_conntrack_helper_q931[0]);
1781         if (ret < 0)
1782                 goto err1;
1783         ret = nf_conntrack_helper_register(&nf_conntrack_helper_q931[1]);
1784         if (ret < 0)
1785                 goto err2;
1786         ret = nf_conntrack_helper_register(&nf_conntrack_helper_ras[0]);
1787         if (ret < 0)
1788                 goto err3;
1789         ret = nf_conntrack_helper_register(&nf_conntrack_helper_ras[1]);
1790         if (ret < 0)
1791                 goto err4;
1792         pr_debug("nf_ct_h323: init success\n");
1793         return 0;
1794
1795 err4:
1796         nf_conntrack_helper_unregister(&nf_conntrack_helper_ras[0]);
1797 err3:
1798         nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[1]);
1799 err2:
1800         nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[0]);
1801 err1:
1802         kfree(h323_buffer);
1803         return ret;
1804 }
1805
1806 /****************************************************************************/
1807 module_init(nf_conntrack_h323_init);
1808 module_exit(nf_conntrack_h323_fini);
1809
1810 EXPORT_SYMBOL_GPL(get_h225_addr);
1811 EXPORT_SYMBOL_GPL(set_h245_addr_hook);
1812 EXPORT_SYMBOL_GPL(set_h225_addr_hook);
1813 EXPORT_SYMBOL_GPL(set_sig_addr_hook);
1814 EXPORT_SYMBOL_GPL(set_ras_addr_hook);
1815 EXPORT_SYMBOL_GPL(nat_rtp_rtcp_hook);
1816 EXPORT_SYMBOL_GPL(nat_t120_hook);
1817 EXPORT_SYMBOL_GPL(nat_h245_hook);
1818 EXPORT_SYMBOL_GPL(nat_callforwarding_hook);
1819 EXPORT_SYMBOL_GPL(nat_q931_hook);
1820
1821 MODULE_AUTHOR("Jing Min Zhao <zhaojingmin@users.sourceforge.net>");
1822 MODULE_DESCRIPTION("H.323 connection tracking helper");
1823 MODULE_LICENSE("GPL");
1824 MODULE_ALIAS("ip_conntrack_h323");