Patrick McHardy | 9fafcd7 | 2006-12-02 22:09:57 -0800 | [diff] [blame] | 1 | #ifndef __NF_CONNTRACK_SIP_H__ |
| 2 | #define __NF_CONNTRACK_SIP_H__ |
| 3 | #ifdef __KERNEL__ |
| 4 | |
| 5 | #define SIP_PORT 5060 |
| 6 | #define SIP_TIMEOUT 3600 |
| 7 | |
Patrick McHardy | 30f33e6 | 2008-03-25 20:22:20 -0700 | [diff] [blame^] | 8 | struct sip_handler { |
| 9 | const char *method; |
| 10 | unsigned int len; |
| 11 | int (*request)(struct sk_buff *skb, |
| 12 | const char **dptr, unsigned int *datalen, |
| 13 | unsigned int cseq); |
| 14 | int (*response)(struct sk_buff *skb, |
| 15 | const char **dptr, unsigned int *datalen, |
| 16 | unsigned int cseq, unsigned int code); |
| 17 | }; |
| 18 | |
| 19 | #define SIP_HANDLER(__method, __request, __response) \ |
| 20 | { \ |
| 21 | .method = (__method), \ |
| 22 | .len = sizeof(__method) - 1, \ |
| 23 | .request = (__request), \ |
| 24 | .response = (__response), \ |
| 25 | } |
| 26 | |
Patrick McHardy | 3e9b4600b | 2008-03-25 20:17:55 -0700 | [diff] [blame] | 27 | struct sip_header { |
| 28 | const char *name; |
| 29 | const char *cname; |
| 30 | const char *search; |
| 31 | unsigned int len; |
| 32 | unsigned int clen; |
| 33 | unsigned int slen; |
| 34 | int (*match_len)(const struct nf_conn *ct, |
| 35 | const char *dptr, const char *limit, |
| 36 | int *shift); |
| 37 | }; |
| 38 | |
| 39 | #define __SIP_HDR(__name, __cname, __search, __match) \ |
| 40 | { \ |
| 41 | .name = (__name), \ |
| 42 | .len = sizeof(__name) - 1, \ |
| 43 | .cname = (__cname), \ |
| 44 | .clen = (__cname) ? sizeof(__cname) - 1 : 0, \ |
| 45 | .search = (__search), \ |
| 46 | .slen = (__search) ? sizeof(__search) - 1 : 0, \ |
| 47 | .match_len = (__match), \ |
| 48 | } |
| 49 | |
Patrick McHardy | ea45f12 | 2008-03-25 20:18:57 -0700 | [diff] [blame] | 50 | #define SIP_HDR(__name, __cname, __search, __match) \ |
| 51 | __SIP_HDR(__name, __cname, __search, __match) |
| 52 | |
Patrick McHardy | 3e9b4600b | 2008-03-25 20:17:55 -0700 | [diff] [blame] | 53 | #define SDP_HDR(__name, __search, __match) \ |
| 54 | __SIP_HDR(__name, NULL, __search, __match) |
| 55 | |
Patrick McHardy | ea45f12 | 2008-03-25 20:18:57 -0700 | [diff] [blame] | 56 | enum sip_header_types { |
Patrick McHardy | 30f33e6 | 2008-03-25 20:22:20 -0700 | [diff] [blame^] | 57 | SIP_HDR_CSEQ, |
Patrick McHardy | ea45f12 | 2008-03-25 20:18:57 -0700 | [diff] [blame] | 58 | SIP_HDR_FROM, |
| 59 | SIP_HDR_TO, |
| 60 | SIP_HDR_CONTACT, |
| 61 | SIP_HDR_VIA, |
| 62 | SIP_HDR_CONTENT_LENGTH, |
| 63 | }; |
| 64 | |
Patrick McHardy | 3e9b4600b | 2008-03-25 20:17:55 -0700 | [diff] [blame] | 65 | enum sdp_header_types { |
| 66 | SDP_HDR_UNSPEC, |
| 67 | SDP_HDR_VERSION, |
| 68 | SDP_HDR_OWNER_IP4, |
| 69 | SDP_HDR_CONNECTION_IP4, |
| 70 | SDP_HDR_OWNER_IP6, |
| 71 | SDP_HDR_CONNECTION_IP6, |
| 72 | SDP_HDR_MEDIA, |
Patrick McHardy | 9fafcd7 | 2006-12-02 22:09:57 -0800 | [diff] [blame] | 73 | }; |
| 74 | |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 75 | extern unsigned int (*nf_nat_sip_hook)(struct sk_buff *skb, |
Patrick McHardy | 2a6cfb2 | 2008-03-25 20:16:54 -0700 | [diff] [blame] | 76 | const char **dptr, |
| 77 | unsigned int *datalen); |
Herbert Xu | 3db05fe | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 78 | extern unsigned int (*nf_nat_sdp_hook)(struct sk_buff *skb, |
Patrick McHardy | 2a6cfb2 | 2008-03-25 20:16:54 -0700 | [diff] [blame] | 79 | const char **dptr, |
Patrick McHardy | 212440a | 2008-03-25 20:17:13 -0700 | [diff] [blame] | 80 | unsigned int *datalen, |
| 81 | struct nf_conntrack_expect *exp); |
Patrick McHardy | 9fafcd7 | 2006-12-02 22:09:57 -0800 | [diff] [blame] | 82 | |
Patrick McHardy | ac36774 | 2008-03-25 20:18:40 -0700 | [diff] [blame] | 83 | extern int ct_sip_parse_request(const struct nf_conn *ct, |
| 84 | const char *dptr, unsigned int datalen, |
Patrick McHardy | 624f8b7 | 2008-03-25 20:19:30 -0700 | [diff] [blame] | 85 | unsigned int *matchoff, unsigned int *matchlen, |
| 86 | union nf_inet_addr *addr, __be16 *port); |
Patrick McHardy | ea45f12 | 2008-03-25 20:18:57 -0700 | [diff] [blame] | 87 | extern int ct_sip_get_header(const struct nf_conn *ct, const char *dptr, |
| 88 | unsigned int dataoff, unsigned int datalen, |
| 89 | enum sip_header_types type, |
| 90 | unsigned int *matchoff, unsigned int *matchlen); |
Patrick McHardy | 05e3ced | 2008-03-25 20:19:13 -0700 | [diff] [blame] | 91 | extern int ct_sip_parse_header_uri(const struct nf_conn *ct, const char *dptr, |
| 92 | unsigned int *dataoff, unsigned int datalen, |
| 93 | enum sip_header_types type, int *in_header, |
| 94 | unsigned int *matchoff, unsigned int *matchlen, |
| 95 | union nf_inet_addr *addr, __be16 *port); |
Patrick McHardy | 3e9b4600b | 2008-03-25 20:17:55 -0700 | [diff] [blame] | 96 | |
| 97 | extern int ct_sip_get_sdp_header(const struct nf_conn *ct, const char *dptr, |
| 98 | unsigned int dataoff, unsigned int datalen, |
| 99 | enum sdp_header_types type, |
| 100 | enum sdp_header_types term, |
| 101 | unsigned int *matchoff, unsigned int *matchlen); |
| 102 | |
Patrick McHardy | 9fafcd7 | 2006-12-02 22:09:57 -0800 | [diff] [blame] | 103 | #endif /* __KERNEL__ */ |
| 104 | #endif /* __NF_CONNTRACK_SIP_H__ */ |