Module: sip-router Branch: janakj/kcore Commit: 49e8baef3465862976999224eeb58123edfa240b URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=49e8baef...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Jan Janak jan@iptel.org Date: Sun Mar 29 20:07:28 2009 +0200
Function to retrieve the first URI from Path headers.
Signed-off-by: Jan Janak jan@iptel.org
---
lib/kcore/parser_helpers.c | 26 ++++++++++++++++++++++++++ lib/kcore/parser_helpers.h | 1 + 2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/lib/kcore/parser_helpers.c b/lib/kcore/parser_helpers.c index e769160..37aa4fa 100644 --- a/lib/kcore/parser_helpers.c +++ b/lib/kcore/parser_helpers.c @@ -174,3 +174,29 @@ int print_rr_body(struct hdr_field *iroute, str *oroute, int order, error: return -1; } + + +/*! + * Path must be available. Function returns the first uri + * from Path without any duplication. + */ +int get_path_dst_uri(str *_p, str *_dst) +{ + rr_t *route = 0; + + LM_DBG("path for branch: '%.*s'\n", _p->len, _p->s); + if(parse_rr_body(_p->s, _p->len, &route) < 0) { + LM_ERR("failed to parse Path body\n"); + return -1; + } + + if(!route) { + LM_ERR("failed to parse Path body no head found\n"); + return -1; + } + *_dst = route->nameaddr.uri; + + free_rr(&route); + + return 0; +} diff --git a/lib/kcore/parser_helpers.h b/lib/kcore/parser_helpers.h index 76f7e98..e078ab6 100644 --- a/lib/kcore/parser_helpers.h +++ b/lib/kcore/parser_helpers.h @@ -17,5 +17,6 @@ struct sip_uri* parse_from_uri(struct sip_msg* msg); int print_rr_body(struct hdr_field *iroute, str *oroute, int order, unsigned int * nb_recs);
+int get_path_dst_uri(str *_p, str *_dst);
#endif /* _PARSER_HELPERS_H */