aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2010-02-11 06:30:21 -0500
committerPatrick McHardy <kaber@trash.net>2010-02-11 06:30:21 -0500
commit9d288dffe3a276e1f06ba556845c456d696c5a4f (patch)
tree770d2f3aa755fa6c834e8ce3f21ebb3f19a051f4
parent48f8ac26537c1b7b1a2422f5232f45d06c945348 (diff)
netfilter: nf_conntrack_sip: add T.38 FAX support
Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r--include/linux/netfilter/nf_conntrack_sip.h1
-rw-r--r--include/net/netfilter/nf_conntrack.h2
-rw-r--r--net/netfilter/nf_conntrack_sip.c28
3 files changed, 25 insertions, 6 deletions
diff --git a/include/linux/netfilter/nf_conntrack_sip.h b/include/linux/netfilter/nf_conntrack_sip.h
index cd84d6f44d11..ff8cfbcf3b81 100644
--- a/include/linux/netfilter/nf_conntrack_sip.h
+++ b/include/linux/netfilter/nf_conntrack_sip.h
@@ -14,6 +14,7 @@ enum sip_expectation_classes {
14 SIP_EXPECT_SIGNALLING, 14 SIP_EXPECT_SIGNALLING,
15 SIP_EXPECT_AUDIO, 15 SIP_EXPECT_AUDIO,
16 SIP_EXPECT_VIDEO, 16 SIP_EXPECT_VIDEO,
17 SIP_EXPECT_IMAGE,
17 __SIP_EXPECT_MAX 18 __SIP_EXPECT_MAX
18}; 19};
19#define SIP_EXPECT_MAX (__SIP_EXPECT_MAX - 1) 20#define SIP_EXPECT_MAX (__SIP_EXPECT_MAX - 1)
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 5043d61c99a7..5b7d8835523f 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -70,7 +70,7 @@ union nf_conntrack_help {
70struct nf_conntrack_helper; 70struct nf_conntrack_helper;
71 71
72/* Must be kept in sync with the classes defined by helpers */ 72/* Must be kept in sync with the classes defined by helpers */
73#define NF_CT_MAX_EXPECT_CLASSES 3 73#define NF_CT_MAX_EXPECT_CLASSES 4
74 74
75/* nf_conn feature for connections that have a helper */ 75/* nf_conn feature for connections that have a helper */
76struct nf_conn_help { 76struct nf_conn_help {
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 3bb3aaff76e9..fbe8ff5a420a 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -907,6 +907,7 @@ err1:
907static const struct sdp_media_type sdp_media_types[] = { 907static const struct sdp_media_type sdp_media_types[] = {
908 SDP_MEDIA_TYPE("audio ", SIP_EXPECT_AUDIO), 908 SDP_MEDIA_TYPE("audio ", SIP_EXPECT_AUDIO),
909 SDP_MEDIA_TYPE("video ", SIP_EXPECT_VIDEO), 909 SDP_MEDIA_TYPE("video ", SIP_EXPECT_VIDEO),
910 SDP_MEDIA_TYPE("image ", SIP_EXPECT_IMAGE),
910}; 911};
911 912
912static const struct sdp_media_type *sdp_media_type(const char *dptr, 913static const struct sdp_media_type *sdp_media_type(const char *dptr,
@@ -932,7 +933,6 @@ static int process_sdp(struct sk_buff *skb, unsigned int dataoff,
932{ 933{
933 enum ip_conntrack_info ctinfo; 934 enum ip_conntrack_info ctinfo;
934 struct nf_conn *ct = nf_ct_get(skb, &ctinfo); 935 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
935 struct nf_conn_help *help = nfct_help(ct);
936 unsigned int matchoff, matchlen; 936 unsigned int matchoff, matchlen;
937 unsigned int mediaoff, medialen; 937 unsigned int mediaoff, medialen;
938 unsigned int sdpoff; 938 unsigned int sdpoff;
@@ -1024,9 +1024,6 @@ static int process_sdp(struct sk_buff *skb, unsigned int dataoff,
1024 ret = nf_nat_sdp_session(skb, dataoff, dptr, datalen, sdpoff, 1024 ret = nf_nat_sdp_session(skb, dataoff, dptr, datalen, sdpoff,
1025 &rtp_addr); 1025 &rtp_addr);
1026 1026
1027 if (ret == NF_ACCEPT && i > 0)
1028 help->help.ct_sip_info.invite_cseq = cseq;
1029
1030 return ret; 1027 return ret;
1031} 1028}
1032static int process_invite_response(struct sk_buff *skb, unsigned int dataoff, 1029static int process_invite_response(struct sk_buff *skb, unsigned int dataoff,
@@ -1077,6 +1074,22 @@ static int process_prack_response(struct sk_buff *skb, unsigned int dataoff,
1077 return NF_ACCEPT; 1074 return NF_ACCEPT;
1078} 1075}
1079 1076
1077static int process_invite_request(struct sk_buff *skb, unsigned int dataoff,
1078 const char **dptr, unsigned int *datalen,
1079 unsigned int cseq)
1080{
1081 enum ip_conntrack_info ctinfo;
1082 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
1083 struct nf_conn_help *help = nfct_help(ct);
1084 unsigned int ret;
1085
1086 flush_expectations(ct, true);
1087 ret = process_sdp(skb, dataoff, dptr, datalen, cseq);
1088 if (ret == NF_ACCEPT)
1089 help->help.ct_sip_info.invite_cseq = cseq;
1090 return ret;
1091}
1092
1080static int process_bye_request(struct sk_buff *skb, unsigned int dataoff, 1093static int process_bye_request(struct sk_buff *skb, unsigned int dataoff,
1081 const char **dptr, unsigned int *datalen, 1094 const char **dptr, unsigned int *datalen,
1082 unsigned int cseq) 1095 unsigned int cseq)
@@ -1257,7 +1270,7 @@ flush:
1257} 1270}
1258 1271
1259static const struct sip_handler sip_handlers[] = { 1272static const struct sip_handler sip_handlers[] = {
1260 SIP_HANDLER("INVITE", process_sdp, process_invite_response), 1273 SIP_HANDLER("INVITE", process_invite_request, process_invite_response),
1261 SIP_HANDLER("UPDATE", process_sdp, process_update_response), 1274 SIP_HANDLER("UPDATE", process_sdp, process_update_response),
1262 SIP_HANDLER("ACK", process_sdp, NULL), 1275 SIP_HANDLER("ACK", process_sdp, NULL),
1263 SIP_HANDLER("PRACK", process_sdp, process_prack_response), 1276 SIP_HANDLER("PRACK", process_sdp, process_prack_response),
@@ -1473,6 +1486,11 @@ static const struct nf_conntrack_expect_policy sip_exp_policy[SIP_EXPECT_MAX + 1
1473 .max_expected = 2 * IP_CT_DIR_MAX, 1486 .max_expected = 2 * IP_CT_DIR_MAX,
1474 .timeout = 3 * 60, 1487 .timeout = 3 * 60,
1475 }, 1488 },
1489 [SIP_EXPECT_IMAGE] = {
1490 .name = "image",
1491 .max_expected = IP_CT_DIR_MAX,
1492 .timeout = 3 * 60,
1493 },
1476}; 1494};
1477 1495
1478static void nf_conntrack_sip_fini(void) 1496static void nf_conntrack_sip_fini(void)