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