]>
Commit | Line | Data |
---|---|---|
9fafcd7b PM |
1 | #ifndef __NF_CONNTRACK_SIP_H__ |
2 | #define __NF_CONNTRACK_SIP_H__ | |
3 | #ifdef __KERNEL__ | |
4 | ||
1afc5679 PNA |
5 | #include <net/netfilter/nf_conntrack_expect.h> |
6 | ||
7266507d KC |
7 | #include <linux/types.h> |
8 | ||
9fafcd7b PM |
9 | #define SIP_PORT 5060 |
10 | #define SIP_TIMEOUT 3600 | |
11 | ||
0f32a40f PM |
12 | struct nf_ct_sip_master { |
13 | unsigned int register_cseq; | |
ef75d49f | 14 | unsigned int invite_cseq; |
7266507d | 15 | __be16 forced_dport; |
0f32a40f PM |
16 | }; |
17 | ||
18 | enum sip_expectation_classes { | |
19 | SIP_EXPECT_SIGNALLING, | |
20 | SIP_EXPECT_AUDIO, | |
0d0ab037 | 21 | SIP_EXPECT_VIDEO, |
9d288dff | 22 | SIP_EXPECT_IMAGE, |
0f32a40f PM |
23 | __SIP_EXPECT_MAX |
24 | }; | |
25 | #define SIP_EXPECT_MAX (__SIP_EXPECT_MAX - 1) | |
26 | ||
0d0ab037 PM |
27 | struct sdp_media_type { |
28 | const char *name; | |
29 | unsigned int len; | |
30 | enum sip_expectation_classes class; | |
31 | }; | |
32 | ||
33 | #define SDP_MEDIA_TYPE(__name, __class) \ | |
34 | { \ | |
35 | .name = (__name), \ | |
36 | .len = sizeof(__name) - 1, \ | |
37 | .class = (__class), \ | |
38 | } | |
39 | ||
30f33e6d PM |
40 | struct sip_handler { |
41 | const char *method; | |
42 | unsigned int len; | |
051966c0 PM |
43 | int (*request)(struct sk_buff *skb, unsigned int protoff, |
44 | unsigned int dataoff, | |
30f33e6d PM |
45 | const char **dptr, unsigned int *datalen, |
46 | unsigned int cseq); | |
051966c0 PM |
47 | int (*response)(struct sk_buff *skb, unsigned int protoff, |
48 | unsigned int dataoff, | |
30f33e6d PM |
49 | const char **dptr, unsigned int *datalen, |
50 | unsigned int cseq, unsigned int code); | |
51 | }; | |
52 | ||
53 | #define SIP_HANDLER(__method, __request, __response) \ | |
54 | { \ | |
55 | .method = (__method), \ | |
56 | .len = sizeof(__method) - 1, \ | |
57 | .request = (__request), \ | |
58 | .response = (__response), \ | |
59 | } | |
60 | ||
3e9b4600 PM |
61 | struct sip_header { |
62 | const char *name; | |
63 | const char *cname; | |
64 | const char *search; | |
65 | unsigned int len; | |
66 | unsigned int clen; | |
67 | unsigned int slen; | |
68 | int (*match_len)(const struct nf_conn *ct, | |
69 | const char *dptr, const char *limit, | |
70 | int *shift); | |
71 | }; | |
72 | ||
73 | #define __SIP_HDR(__name, __cname, __search, __match) \ | |
74 | { \ | |
75 | .name = (__name), \ | |
76 | .len = sizeof(__name) - 1, \ | |
77 | .cname = (__cname), \ | |
78 | .clen = (__cname) ? sizeof(__cname) - 1 : 0, \ | |
79 | .search = (__search), \ | |
80 | .slen = (__search) ? sizeof(__search) - 1 : 0, \ | |
81 | .match_len = (__match), \ | |
82 | } | |
83 | ||
ea45f12a PM |
84 | #define SIP_HDR(__name, __cname, __search, __match) \ |
85 | __SIP_HDR(__name, __cname, __search, __match) | |
86 | ||
3e9b4600 PM |
87 | #define SDP_HDR(__name, __search, __match) \ |
88 | __SIP_HDR(__name, NULL, __search, __match) | |
89 | ||
ea45f12a | 90 | enum sip_header_types { |
30f33e6d | 91 | SIP_HDR_CSEQ, |
ea45f12a PM |
92 | SIP_HDR_FROM, |
93 | SIP_HDR_TO, | |
94 | SIP_HDR_CONTACT, | |
f5b321bd PM |
95 | SIP_HDR_VIA_UDP, |
96 | SIP_HDR_VIA_TCP, | |
0f32a40f | 97 | SIP_HDR_EXPIRES, |
ea45f12a | 98 | SIP_HDR_CONTENT_LENGTH, |
001985b2 | 99 | SIP_HDR_CALL_ID, |
ea45f12a PM |
100 | }; |
101 | ||
3e9b4600 PM |
102 | enum sdp_header_types { |
103 | SDP_HDR_UNSPEC, | |
104 | SDP_HDR_VERSION, | |
9a664821 PM |
105 | SDP_HDR_OWNER, |
106 | SDP_HDR_CONNECTION, | |
3e9b4600 | 107 | SDP_HDR_MEDIA, |
9fafcd7b PM |
108 | }; |
109 | ||
3db05fea | 110 | extern unsigned int (*nf_nat_sip_hook)(struct sk_buff *skb, |
051966c0 | 111 | unsigned int protoff, |
3b6b9fab | 112 | unsigned int dataoff, |
2a6cfb22 PM |
113 | const char **dptr, |
114 | unsigned int *datalen); | |
9a664821 PM |
115 | extern void (*nf_nat_sip_seq_adjust_hook)(struct sk_buff *skb, |
116 | unsigned int protoff, s16 off); | |
0f32a40f | 117 | extern unsigned int (*nf_nat_sip_expect_hook)(struct sk_buff *skb, |
051966c0 | 118 | unsigned int protoff, |
3b6b9fab | 119 | unsigned int dataoff, |
0f32a40f PM |
120 | const char **dptr, |
121 | unsigned int *datalen, | |
122 | struct nf_conntrack_expect *exp, | |
123 | unsigned int matchoff, | |
124 | unsigned int matchlen); | |
4ab9e64e | 125 | extern unsigned int (*nf_nat_sdp_addr_hook)(struct sk_buff *skb, |
051966c0 | 126 | unsigned int protoff, |
4ab9e64e | 127 | unsigned int dataoff, |
3b6b9fab | 128 | const char **dptr, |
4ab9e64e | 129 | unsigned int *datalen, |
3b6b9fab | 130 | unsigned int sdpoff, |
4ab9e64e PM |
131 | enum sdp_header_types type, |
132 | enum sdp_header_types term, | |
133 | const union nf_inet_addr *addr); | |
c7f485ab | 134 | extern unsigned int (*nf_nat_sdp_port_hook)(struct sk_buff *skb, |
051966c0 | 135 | unsigned int protoff, |
3b6b9fab | 136 | unsigned int dataoff, |
c7f485ab PM |
137 | const char **dptr, |
138 | unsigned int *datalen, | |
139 | unsigned int matchoff, | |
140 | unsigned int matchlen, | |
141 | u_int16_t port); | |
4ab9e64e | 142 | extern unsigned int (*nf_nat_sdp_session_hook)(struct sk_buff *skb, |
051966c0 | 143 | unsigned int protoff, |
4ab9e64e | 144 | unsigned int dataoff, |
3b6b9fab | 145 | const char **dptr, |
4ab9e64e | 146 | unsigned int *datalen, |
3b6b9fab | 147 | unsigned int sdpoff, |
4ab9e64e PM |
148 | const union nf_inet_addr *addr); |
149 | extern unsigned int (*nf_nat_sdp_media_hook)(struct sk_buff *skb, | |
051966c0 | 150 | unsigned int protoff, |
3b6b9fab | 151 | unsigned int dataoff, |
4ab9e64e PM |
152 | const char **dptr, |
153 | unsigned int *datalen, | |
154 | struct nf_conntrack_expect *rtp_exp, | |
155 | struct nf_conntrack_expect *rtcp_exp, | |
156 | unsigned int mediaoff, | |
157 | unsigned int medialen, | |
158 | union nf_inet_addr *rtp_addr); | |
9fafcd7b | 159 | |
ac367740 PM |
160 | extern int ct_sip_parse_request(const struct nf_conn *ct, |
161 | const char *dptr, unsigned int datalen, | |
624f8b7b PM |
162 | unsigned int *matchoff, unsigned int *matchlen, |
163 | union nf_inet_addr *addr, __be16 *port); | |
ea45f12a PM |
164 | extern int ct_sip_get_header(const struct nf_conn *ct, const char *dptr, |
165 | unsigned int dataoff, unsigned int datalen, | |
166 | enum sip_header_types type, | |
167 | unsigned int *matchoff, unsigned int *matchlen); | |
05e3ced2 PM |
168 | extern int ct_sip_parse_header_uri(const struct nf_conn *ct, const char *dptr, |
169 | unsigned int *dataoff, unsigned int datalen, | |
170 | enum sip_header_types type, int *in_header, | |
171 | unsigned int *matchoff, unsigned int *matchlen, | |
172 | union nf_inet_addr *addr, __be16 *port); | |
2bbb2116 PM |
173 | extern int ct_sip_parse_address_param(const struct nf_conn *ct, const char *dptr, |
174 | unsigned int dataoff, unsigned int datalen, | |
175 | const char *name, | |
176 | unsigned int *matchoff, unsigned int *matchlen, | |
02b69cbd | 177 | union nf_inet_addr *addr, bool delim); |
2bbb2116 PM |
178 | extern int ct_sip_parse_numerical_param(const struct nf_conn *ct, const char *dptr, |
179 | unsigned int off, unsigned int datalen, | |
180 | const char *name, | |
181 | unsigned int *matchoff, unsigned int *matchen, | |
182 | unsigned int *val); | |
3e9b4600 PM |
183 | |
184 | extern int ct_sip_get_sdp_header(const struct nf_conn *ct, const char *dptr, | |
185 | unsigned int dataoff, unsigned int datalen, | |
186 | enum sdp_header_types type, | |
187 | enum sdp_header_types term, | |
188 | unsigned int *matchoff, unsigned int *matchlen); | |
189 | ||
9fafcd7b PM |
190 | #endif /* __KERNEL__ */ |
191 | #endif /* __NF_CONNTRACK_SIP_H__ */ |