diff options
author | Patrick McHardy <kaber@trash.net> | 2008-03-25 23:24:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-25 23:24:24 -0400 |
commit | 2bbb21168a90c788e12fe722eb66f27e611e7df7 (patch) | |
tree | a36c87d7aa6398cd82d0b73c3fd6dac67f9652d0 /net | |
parent | 9467ee380ae881443bc259fbbac9992baf523e2d (diff) |
[NETFILTER]: nf_conntrack_sip: introduce URI and header parameter parsing helpers
Introduce URI and header parameter parsing helpers. These are needed
by the conntrack helper to parse expiration values in Contact: header
parameters and by the NAT helper to properly update the Via-header
rport=, received= and maddr= parameters.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/nf_conntrack_sip.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c index 8e7e5b465ffb..126f30842d60 100644 --- a/net/netfilter/nf_conntrack_sip.c +++ b/net/netfilter/nf_conntrack_sip.c | |||
@@ -448,6 +448,64 @@ int ct_sip_parse_header_uri(const struct nf_conn *ct, const char *dptr, | |||
448 | } | 448 | } |
449 | EXPORT_SYMBOL_GPL(ct_sip_parse_header_uri); | 449 | EXPORT_SYMBOL_GPL(ct_sip_parse_header_uri); |
450 | 450 | ||
451 | /* Parse address from header parameter and return address, offset and length */ | ||
452 | int ct_sip_parse_address_param(const struct nf_conn *ct, const char *dptr, | ||
453 | unsigned int dataoff, unsigned int datalen, | ||
454 | const char *name, | ||
455 | unsigned int *matchoff, unsigned int *matchlen, | ||
456 | union nf_inet_addr *addr) | ||
457 | { | ||
458 | const char *limit = dptr + datalen; | ||
459 | const char *start, *end; | ||
460 | |||
461 | limit = ct_sip_header_search(dptr + dataoff, limit, ",", strlen(",")); | ||
462 | if (!limit) | ||
463 | limit = dptr + datalen; | ||
464 | |||
465 | start = ct_sip_header_search(dptr + dataoff, limit, name, strlen(name)); | ||
466 | if (!start) | ||
467 | return 0; | ||
468 | |||
469 | start += strlen(name); | ||
470 | if (!parse_addr(ct, start, &end, addr, limit)) | ||
471 | return 0; | ||
472 | *matchoff = start - dptr; | ||
473 | *matchlen = end - start; | ||
474 | return 1; | ||
475 | } | ||
476 | EXPORT_SYMBOL_GPL(ct_sip_parse_address_param); | ||
477 | |||
478 | /* Parse numerical header parameter and return value, offset and length */ | ||
479 | int ct_sip_parse_numerical_param(const struct nf_conn *ct, const char *dptr, | ||
480 | unsigned int dataoff, unsigned int datalen, | ||
481 | const char *name, | ||
482 | unsigned int *matchoff, unsigned int *matchlen, | ||
483 | unsigned int *val) | ||
484 | { | ||
485 | const char *limit = dptr + datalen; | ||
486 | const char *start; | ||
487 | char *end; | ||
488 | |||
489 | limit = ct_sip_header_search(dptr + dataoff, limit, ",", strlen(",")); | ||
490 | if (!limit) | ||
491 | limit = dptr + datalen; | ||
492 | |||
493 | start = ct_sip_header_search(dptr + dataoff, limit, name, strlen(name)); | ||
494 | if (!start) | ||
495 | return 0; | ||
496 | |||
497 | start += strlen(name); | ||
498 | *val = simple_strtoul(start, &end, 0); | ||
499 | if (start == end) | ||
500 | return 0; | ||
501 | if (matchoff && matchlen) { | ||
502 | *matchoff = start - dptr; | ||
503 | *matchlen = end - start; | ||
504 | } | ||
505 | return 1; | ||
506 | } | ||
507 | EXPORT_SYMBOL_GPL(ct_sip_parse_numerical_param); | ||
508 | |||
451 | /* SDP header parsing: a SDP session description contains an ordered set of | 509 | /* SDP header parsing: a SDP session description contains an ordered set of |
452 | * headers, starting with a section containing general session parameters, | 510 | * headers, starting with a section containing general session parameters, |
453 | * optionally followed by multiple media descriptions. | 511 | * optionally followed by multiple media descriptions. |