]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
netfilter: nf_conntrack_sip: Add callid parser
authorSimon Horman <horms@verge.net.au>
Sun, 22 Aug 2010 12:37:51 +0000 (21:37 +0900)
committerSimon Horman <horms@verge.net.au>
Mon, 4 Oct 2010 13:45:23 +0000 (22:45 +0900)
Signed-off-by: Simon Horman <horms@verge.net.au>
Acked-by: Julian Anastasov <ja@ssi.bg>
include/linux/netfilter/nf_conntrack_sip.h
net/netfilter/nf_conntrack_sip.c

index ff8cfbcf3b81148e483831281752572b2faaac1b..0ce91d56a5f264c989ee5b17a027b489eaabc593 100644 (file)
@@ -89,6 +89,7 @@ enum sip_header_types {
        SIP_HDR_VIA_TCP,
        SIP_HDR_EXPIRES,
        SIP_HDR_CONTENT_LENGTH,
+       SIP_HDR_CALL_ID,
 };
 
 enum sdp_header_types {
index 2fd1ea2c1bb3ce33035c2169a6b632d553df9878..715ce54d2fc4d15661f5ea1d41f3899b6224316c 100644 (file)
@@ -130,6 +130,44 @@ static int digits_len(const struct nf_conn *ct, const char *dptr,
        return len;
 }
 
+static int iswordc(const char c)
+{
+       if (isalnum(c) || c == '!' || c == '"' || c == '%' ||
+           (c >= '(' && c <= '/') || c == ':' || c == '<' || c == '>' ||
+           c == '?' || (c >= '[' && c <= ']') || c == '_' || c == '`' ||
+           c == '{' || c == '}' || c == '~')
+               return 1;
+       return 0;
+}
+
+static int word_len(const char *dptr, const char *limit)
+{
+       int len = 0;
+       while (dptr < limit && iswordc(*dptr)) {
+               dptr++;
+               len++;
+       }
+       return len;
+}
+
+static int callid_len(const struct nf_conn *ct, const char *dptr,
+                     const char *limit, int *shift)
+{
+       int len, domain_len;
+
+       len = word_len(dptr, limit);
+       dptr += len;
+       if (!len || dptr == limit || *dptr != '@')
+               return len;
+       dptr++;
+       len++;
+
+       domain_len = word_len(dptr, limit);
+       if (!domain_len)
+               return 0;
+       return len + domain_len;
+}
+
 /* get media type + port length */
 static int media_len(const struct nf_conn *ct, const char *dptr,
                     const char *limit, int *shift)
@@ -299,6 +337,7 @@ static const struct sip_header ct_sip_hdrs[] = {
        [SIP_HDR_VIA_TCP]               = SIP_HDR("Via", "v", "TCP ", epaddr_len),
        [SIP_HDR_EXPIRES]               = SIP_HDR("Expires", NULL, NULL, digits_len),
        [SIP_HDR_CONTENT_LENGTH]        = SIP_HDR("Content-Length", "l", NULL, digits_len),
+       [SIP_HDR_CALL_ID]               = SIP_HDR("Call-Id", "i", NULL, callid_len),
 };
 
 static const char *sip_follow_continuation(const char *dptr, const char *limit)