Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nf_conntrack_sip: Add callid parser

Signed-off-by: Simon Horman <horms@verge.net.au>
Acked-by: Julian Anastasov <ja@ssi.bg>

+40
+1
include/linux/netfilter/nf_conntrack_sip.h
··· 89 89 SIP_HDR_VIA_TCP, 90 90 SIP_HDR_EXPIRES, 91 91 SIP_HDR_CONTENT_LENGTH, 92 + SIP_HDR_CALL_ID, 92 93 }; 93 94 94 95 enum sdp_header_types {
+39
net/netfilter/nf_conntrack_sip.c
··· 130 130 return len; 131 131 } 132 132 133 + static int iswordc(const char c) 134 + { 135 + if (isalnum(c) || c == '!' || c == '"' || c == '%' || 136 + (c >= '(' && c <= '/') || c == ':' || c == '<' || c == '>' || 137 + c == '?' || (c >= '[' && c <= ']') || c == '_' || c == '`' || 138 + c == '{' || c == '}' || c == '~') 139 + return 1; 140 + return 0; 141 + } 142 + 143 + static int word_len(const char *dptr, const char *limit) 144 + { 145 + int len = 0; 146 + while (dptr < limit && iswordc(*dptr)) { 147 + dptr++; 148 + len++; 149 + } 150 + return len; 151 + } 152 + 153 + static int callid_len(const struct nf_conn *ct, const char *dptr, 154 + const char *limit, int *shift) 155 + { 156 + int len, domain_len; 157 + 158 + len = word_len(dptr, limit); 159 + dptr += len; 160 + if (!len || dptr == limit || *dptr != '@') 161 + return len; 162 + dptr++; 163 + len++; 164 + 165 + domain_len = word_len(dptr, limit); 166 + if (!domain_len) 167 + return 0; 168 + return len + domain_len; 169 + } 170 + 133 171 /* get media type + port length */ 134 172 static int media_len(const struct nf_conn *ct, const char *dptr, 135 173 const char *limit, int *shift) ··· 337 299 [SIP_HDR_VIA_TCP] = SIP_HDR("Via", "v", "TCP ", epaddr_len), 338 300 [SIP_HDR_EXPIRES] = SIP_HDR("Expires", NULL, NULL, digits_len), 339 301 [SIP_HDR_CONTENT_LENGTH] = SIP_HDR("Content-Length", "l", NULL, digits_len), 302 + [SIP_HDR_CALL_ID] = SIP_HDR("Call-Id", "i", NULL, callid_len), 340 303 }; 341 304 342 305 static const char *sip_follow_continuation(const char *dptr, const char *limit)