Skip to content

Commit f587de0

Browse files
kaberdavem330
authored andcommitted
[NETFILTER]: nf_conntrack/nf_nat: add H.323 helper port
Add IPv4 and IPv6 capable nf_conntrack port of the H.323 conntrack/NAT helper. Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1695890 commit f587de0

File tree

15 files changed

+2600
-14
lines changed

15 files changed

+2600
-14
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#ifndef _NF_CONNTRACK_H323_H
2+
#define _NF_CONNTRACK_H323_H
3+
4+
#ifdef __KERNEL__
5+
6+
#include <linux/netfilter/nf_conntrack_h323_asn1.h>
7+
8+
#define RAS_PORT 1719
9+
#define Q931_PORT 1720
10+
#define H323_RTP_CHANNEL_MAX 4 /* Audio, video, FAX and other */
11+
12+
/* This structure exists only once per master */
13+
struct nf_ct_h323_master {
14+
15+
/* Original and NATed Q.931 or H.245 signal ports */
16+
__be16 sig_port[IP_CT_DIR_MAX];
17+
18+
/* Original and NATed RTP ports */
19+
__be16 rtp_port[H323_RTP_CHANNEL_MAX][IP_CT_DIR_MAX];
20+
21+
union {
22+
/* RAS connection timeout */
23+
u_int32_t timeout;
24+
25+
/* Next TPKT length (for separate TPKT header and data) */
26+
u_int16_t tpkt_len[IP_CT_DIR_MAX];
27+
};
28+
};
29+
30+
struct nf_conn;
31+
32+
extern int get_h225_addr(struct nf_conn *ct, unsigned char *data,
33+
TransportAddress *taddr,
34+
union nf_conntrack_address *addr, __be16 *port);
35+
extern void nf_conntrack_h245_expect(struct nf_conn *new,
36+
struct nf_conntrack_expect *this);
37+
extern void nf_conntrack_q931_expect(struct nf_conn *new,
38+
struct nf_conntrack_expect *this);
39+
extern int (*set_h245_addr_hook) (struct sk_buff **pskb,
40+
unsigned char **data, int dataoff,
41+
H245_TransportAddress *taddr,
42+
union nf_conntrack_address *addr,
43+
__be16 port);
44+
extern int (*set_h225_addr_hook) (struct sk_buff **pskb,
45+
unsigned char **data, int dataoff,
46+
TransportAddress *taddr,
47+
union nf_conntrack_address *addr,
48+
__be16 port);
49+
extern int (*set_sig_addr_hook) (struct sk_buff **pskb,
50+
struct nf_conn *ct,
51+
enum ip_conntrack_info ctinfo,
52+
unsigned char **data,
53+
TransportAddress *taddr, int count);
54+
extern int (*set_ras_addr_hook) (struct sk_buff **pskb,
55+
struct nf_conn *ct,
56+
enum ip_conntrack_info ctinfo,
57+
unsigned char **data,
58+
TransportAddress *taddr, int count);
59+
extern int (*nat_rtp_rtcp_hook) (struct sk_buff **pskb,
60+
struct nf_conn *ct,
61+
enum ip_conntrack_info ctinfo,
62+
unsigned char **data, int dataoff,
63+
H245_TransportAddress *taddr,
64+
__be16 port, __be16 rtp_port,
65+
struct nf_conntrack_expect *rtp_exp,
66+
struct nf_conntrack_expect *rtcp_exp);
67+
extern int (*nat_t120_hook) (struct sk_buff **pskb, struct nf_conn *ct,
68+
enum ip_conntrack_info ctinfo,
69+
unsigned char **data, int dataoff,
70+
H245_TransportAddress *taddr, __be16 port,
71+
struct nf_conntrack_expect *exp);
72+
extern int (*nat_h245_hook) (struct sk_buff **pskb, struct nf_conn *ct,
73+
enum ip_conntrack_info ctinfo,
74+
unsigned char **data, int dataoff,
75+
TransportAddress *taddr, __be16 port,
76+
struct nf_conntrack_expect *exp);
77+
extern int (*nat_callforwarding_hook) (struct sk_buff **pskb,
78+
struct nf_conn *ct,
79+
enum ip_conntrack_info ctinfo,
80+
unsigned char **data, int dataoff,
81+
TransportAddress *taddr,
82+
__be16 port,
83+
struct nf_conntrack_expect *exp);
84+
extern int (*nat_q931_hook) (struct sk_buff **pskb, struct nf_conn *ct,
85+
enum ip_conntrack_info ctinfo,
86+
unsigned char **data, TransportAddress *taddr,
87+
int idx, __be16 port,
88+
struct nf_conntrack_expect *exp);
89+
90+
#endif
91+
92+
#endif

include/linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h renamed to include/linux/netfilter/nf_conntrack_h323_asn1.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/****************************************************************************
2-
* ip_conntrack_helper_h323_asn1.h - BER and PER decoding library for H.323
3-
* conntrack/NAT module.
2+
* ip_conntrack_h323_asn1.h - BER and PER decoding library for H.323
3+
* conntrack/NAT module.
44
*
55
* Copyright (c) 2006 by Jing Min Zhao <[email protected]>
66
*
@@ -34,13 +34,13 @@
3434
*
3535
****************************************************************************/
3636

37-
#ifndef _IP_CONNTRACK_HELPER_H323_ASN1_H_
38-
#define _IP_CONNTRACK_HELPER_H323_ASN1_H_
37+
#ifndef _NF_CONNTRACK_HELPER_H323_ASN1_H_
38+
#define _NF_CONNTRACK_HELPER_H323_ASN1_H_
3939

4040
/*****************************************************************************
4141
* H.323 Types
4242
****************************************************************************/
43-
#include "ip_conntrack_helper_h323_types.h"
43+
#include "nf_conntrack_h323_types.h"
4444

4545
typedef struct {
4646
enum {

include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h renamed to include/linux/netfilter/nf_conntrack_h323_types.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ typedef struct TransportAddress_ipAddress { /* SEQUENCE */
1010
unsigned ip;
1111
} TransportAddress_ipAddress;
1212

13+
typedef struct TransportAddress_ip6Address { /* SEQUENCE */
14+
int options; /* No use */
15+
unsigned ip6;
16+
} TransportAddress_ip6Address;
17+
1318
typedef struct TransportAddress { /* CHOICE */
1419
enum {
1520
eTransportAddress_ipAddress,
@@ -22,6 +27,7 @@ typedef struct TransportAddress { /* CHOICE */
2227
} choice;
2328
union {
2429
TransportAddress_ipAddress ipAddress;
30+
TransportAddress_ip6Address ip6Address;
2531
};
2632
} TransportAddress;
2733

@@ -93,6 +99,11 @@ typedef struct UnicastAddress_iPAddress { /* SEQUENCE */
9399
unsigned network;
94100
} UnicastAddress_iPAddress;
95101

102+
typedef struct UnicastAddress_iP6Address { /* SEQUENCE */
103+
int options; /* No use */
104+
unsigned network;
105+
} UnicastAddress_iP6Address;
106+
96107
typedef struct UnicastAddress { /* CHOICE */
97108
enum {
98109
eUnicastAddress_iPAddress,
@@ -105,6 +116,7 @@ typedef struct UnicastAddress { /* CHOICE */
105116
} choice;
106117
union {
107118
UnicastAddress_iPAddress iPAddress;
119+
UnicastAddress_iP6Address iP6Address;
108120
};
109121
} UnicastAddress;
110122

include/linux/netfilter_ipv4/Kbuild

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
header-y += ip_conntrack_helper.h
2-
header-y += ip_conntrack_helper_h323_asn1.h
3-
header-y += ip_conntrack_helper_h323_types.h
42
header-y += ip_conntrack_protocol.h
53
header-y += ip_conntrack_sctp.h
64
header-y += ip_conntrack_tcp.h

include/linux/netfilter_ipv4/ip_conntrack_h323.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#ifdef __KERNEL__
55

6-
#include <linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h>
6+
#include <linux/netfilter/nf_conntrack_h323_asn1.h>
77

88
#define RAS_PORT 1719
99
#define Q931_PORT 1720

include/net/netfilter/nf_conntrack.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ union nf_conntrack_expect_proto {
4141

4242
/* Add protocol helper include file here */
4343
#include <linux/netfilter/nf_conntrack_ftp.h>
44+
#include <linux/netfilter/nf_conntrack_h323.h>
4445

4546
/* per conntrack: application helper private data */
4647
union nf_conntrack_help {
4748
/* insert conntrack helper private data (master) here */
4849
struct nf_ct_ftp_master ct_ftp_info;
50+
struct nf_ct_h323_master ct_h323_info;
4951
};
5052

5153
#include <linux/types.h>

include/net/netfilter/nf_conntrack_expect.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct nf_conntrack_expect
4141
unsigned int flags;
4242

4343
#ifdef CONFIG_NF_NAT_NEEDED
44+
__be32 saved_ip;
4445
/* This is the original per-proto part, used to map the
4546
* expected connection the way the recipient expects. */
4647
union nf_conntrack_man_proto saved_proto;

net/ipv4/netfilter/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,11 @@ config IP_NF_NAT_H323
529529
default IP_NF_NAT if IP_NF_H323=y
530530
default m if IP_NF_H323=m
531531

532+
config NF_NAT_H323
533+
tristate
534+
depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT
535+
default NF_NAT && NF_CONNTRACK_H323
536+
532537
config IP_NF_NAT_SIP
533538
tristate
534539
depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n

net/ipv4/netfilter/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ endif
1515
ip_conntrack_pptp-objs := ip_conntrack_helper_pptp.o ip_conntrack_proto_gre.o
1616
ip_nat_pptp-objs := ip_nat_helper_pptp.o ip_nat_proto_gre.o
1717

18-
ip_conntrack_h323-objs := ip_conntrack_helper_h323.o ip_conntrack_helper_h323_asn1.o
18+
ip_conntrack_h323-objs := ip_conntrack_helper_h323.o ../../netfilter/nf_conntrack_h323_asn1.o
1919
ip_nat_h323-objs := ip_nat_helper_h323.o
2020

2121
# connection tracking
@@ -52,6 +52,7 @@ obj-$(CONFIG_IP_NF_NAT_SIP) += ip_nat_sip.o
5252
# NAT helpers (nf_conntrack)
5353
obj-$(CONFIG_NF_NAT_AMANDA) += nf_nat_amanda.o
5454
obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o
55+
obj-$(CONFIG_NF_NAT_H323) += nf_nat_h323.o
5556

5657
# generic IP tables
5758
obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o

0 commit comments

Comments
 (0)