[NETFILTER]: nf_conntrack: introduce expectation classes and policies
[deliverable/linux.git] / net / netfilter / nf_conntrack_sip.c
index 8f8b5a48df386ed65065e3f40ef88893a573c747..0021d5b60cecb886a2f7d4e491b0ce749ea8b363 100644 (file)
@@ -28,7 +28,7 @@ MODULE_ALIAS("ip_conntrack_sip");
 
 #define MAX_PORTS      8
 static unsigned short ports[MAX_PORTS];
-static int ports_c;
+static unsigned int ports_c;
 module_param_array(ports, ushort, &ports_c, 0400);
 MODULE_PARM_DESC(ports, "port numbers of SIP servers");
 
@@ -48,10 +48,10 @@ unsigned int (*nf_nat_sdp_hook)(struct sk_buff *skb,
                                const char *dptr) __read_mostly;
 EXPORT_SYMBOL_GPL(nf_nat_sdp_hook);
 
-static int digits_len(struct nf_conn *, const char *, const char *, int *);
-static int epaddr_len(struct nf_conn *, const char *, const char *, int *);
-static int skp_digits_len(struct nf_conn *, const char *, const char *, int *);
-static int skp_epaddr_len(struct nf_conn *, const char *, const char *, int *);
+static int digits_len(const struct nf_conn *, const char *, const char *, int *);
+static int epaddr_len(const struct nf_conn *, const char *, const char *, int *);
+static int skp_digits_len(const struct nf_conn *, const char *, const char *, int *);
+static int skp_epaddr_len(const struct nf_conn *, const char *, const char *, int *);
 
 struct sip_header_nfo {
        const char      *lname;
@@ -61,7 +61,7 @@ struct sip_header_nfo {
        size_t          snlen;
        size_t          ln_strlen;
        int             case_sensitive;
-       int             (*match_len)(struct nf_conn *, const char *,
+       int             (*match_len)(const struct nf_conn *, const char *,
                                     const char *, int *);
 };
 
@@ -187,7 +187,7 @@ static const struct sip_header_nfo ct_sip_hdrs[] = {
        }
 };
 
-/* get line lenght until first CR or LF seen. */
+/* get line length until first CR or LF seen. */
 int ct_sip_lnlen(const char *line, const char *limit)
 {
        const char *k = line;
@@ -225,7 +225,7 @@ const char *ct_sip_search(const char *needle, const char *haystack,
 }
 EXPORT_SYMBOL_GPL(ct_sip_search);
 
-static int digits_len(struct nf_conn *ct, const char *dptr,
+static int digits_len(const struct nf_conn *ct, const char *dptr,
                      const char *limit, int *shift)
 {
        int len = 0;
@@ -236,8 +236,8 @@ static int digits_len(struct nf_conn *ct, const char *dptr,
        return len;
 }
 
-/* get digits lenght, skiping blank spaces. */
-static int skp_digits_len(struct nf_conn *ct, const char *dptr,
+/* get digits length, skipping blank spaces. */
+static int skp_digits_len(const struct nf_conn *ct, const char *dptr,
                          const char *limit, int *shift)
 {
        for (; dptr <= limit && *dptr == ' '; dptr++)
@@ -246,8 +246,9 @@ static int skp_digits_len(struct nf_conn *ct, const char *dptr,
        return digits_len(ct, dptr, limit, shift);
 }
 
-static int parse_addr(struct nf_conn *ct, const char *cp, const char **endp,
-                     union nf_conntrack_address *addr, const char *limit)
+static int parse_addr(const struct nf_conn *ct, const char *cp,
+                      const char **endp, union nf_inet_addr *addr,
+                      const char *limit)
 {
        const char *end;
        int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
@@ -272,10 +273,10 @@ static int parse_addr(struct nf_conn *ct, const char *cp, const char **endp,
 }
 
 /* skip ip address. returns its length. */
-static int epaddr_len(struct nf_conn *ct, const char *dptr,
+static int epaddr_len(const struct nf_conn *ct, const char *dptr,
                      const char *limit, int *shift)
 {
-       union nf_conntrack_address addr;
+       union nf_inet_addr addr;
        const char *aux = dptr;
 
        if (!parse_addr(ct, dptr, &dptr, &addr, limit)) {
@@ -292,7 +293,7 @@ static int epaddr_len(struct nf_conn *ct, const char *dptr,
 }
 
 /* get address length, skiping user info. */
-static int skp_epaddr_len(struct nf_conn *ct, const char *dptr,
+static int skp_epaddr_len(const struct nf_conn *ct, const char *dptr,
                          const char *limit, int *shift)
 {
        const char *start = dptr;
@@ -319,7 +320,7 @@ static int skp_epaddr_len(struct nf_conn *ct, const char *dptr,
 }
 
 /* Returns 0 if not found, -1 error parsing. */
-int ct_sip_get_info(struct nf_conn *ct,
+int ct_sip_get_info(const struct nf_conn *ct,
                    const char *dptr, size_t dlen,
                    unsigned int *matchoff,
                    unsigned int *matchlen,
@@ -366,7 +367,7 @@ EXPORT_SYMBOL_GPL(ct_sip_get_info);
 static int set_expected_rtp(struct sk_buff *skb,
                            struct nf_conn *ct,
                            enum ip_conntrack_info ctinfo,
-                           union nf_conntrack_address *addr,
+                           union nf_inet_addr *addr,
                            __be16 port,
                            const char *dptr)
 {
@@ -379,7 +380,7 @@ static int set_expected_rtp(struct sk_buff *skb,
        exp = nf_ct_expect_alloc(ct);
        if (exp == NULL)
                return NF_DROP;
-       nf_ct_expect_init(exp, family,
+       nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, family,
                          &ct->tuplehash[!dir].tuple.src.u3, addr,
                          IPPROTO_UDP, NULL, &port);
 
@@ -403,11 +404,11 @@ static int sip_help(struct sk_buff *skb,
                    enum ip_conntrack_info ctinfo)
 {
        int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
-       union nf_conntrack_address addr;
+       union nf_inet_addr addr;
        unsigned int dataoff, datalen;
        const char *dptr;
        int ret = NF_ACCEPT;
-       int matchoff, matchlen;
+       unsigned int matchoff, matchlen;
        u_int16_t port;
        enum sip_header_pos pos;
        typeof(nf_nat_sip_hook) nf_nat_sip;
@@ -475,6 +476,11 @@ out:
 static struct nf_conntrack_helper sip[MAX_PORTS][2] __read_mostly;
 static char sip_names[MAX_PORTS][2][sizeof("sip-65535")] __read_mostly;
 
+static const struct nf_conntrack_expect_policy sip_exp_policy = {
+       .max_expected   = 2,
+       .timeout        = 3 * 60,
+};
+
 static void nf_conntrack_sip_fini(void)
 {
        int i, j;
@@ -504,8 +510,7 @@ static int __init nf_conntrack_sip_init(void)
                for (j = 0; j < 2; j++) {
                        sip[i][j].tuple.dst.protonum = IPPROTO_UDP;
                        sip[i][j].tuple.src.u.udp.port = htons(ports[i]);
-                       sip[i][j].max_expected = 2;
-                       sip[i][j].timeout = 3 * 60; /* 3 minutes */
+                       sip[i][j].expect_policy = &sip_exp_policy;
                        sip[i][j].me = THIS_MODULE;
                        sip[i][j].help = sip_help;
 
This page took 0.031014 seconds and 5 git commands to generate.