Hello,
I've been working whit SER for a while, and I need to have some way of redirecting Invites dynamicly. The idea is similar to the definition of groups (local,ld,...), only I want to be able to define the redirection address without having to rewrite ser.cfg (and therefor reinitialize SER). The part of defining these new groups and addresses was straightforward, after that I tried to build a module that would have a function to do the writing of the "To" URI. The only function I found to alter the destination URI was append_branch. The module compiles without error and SER works normally, except it does not do the redirections that I was hoping. Are there any other ways of adding/rewriting something to the body of "To" in the SIP message? Or one can only do that in ser.cfg?
Thanks in advance,
José Nunes
Hi Jose!
Routing decisions are never made based on the To: header field. Only the Request-URI and the topmost Route: haeder field are basis for routing decisions (see also RFC 3261). I guess this is why your implementation doesn't work as planned.
AFAIK a proxy changing the To: header field is not allowed, except adding a tag. Furthermore I would expect interoperability problems, if a proxy in the middle changes the To: header field. (Certainly such problems occur with legacy RFC 2543 UAs.)
What you are trying to implement looks like a Back-2-Back-User-Agent (B2BUA).
T: Bernie
On Tue, 25 Nov 2003, José Nunes wrote:
Hello,
I've been working whit SER for a while, and I need to have some way of redirecting Invites dynamicly. The idea is similar to the definition of groups (local,ld,...), only I want to be able to define the redirection address without having to rewrite ser.cfg (and therefor reinitialize SER). The part of defining these new groups and addresses was straightforward, after that I tried to build a module that would have a function to do the writing of the "To" URI. The only function I found to alter the destination URI was append_branch. The module compiles without error and SER works normally, except it does not do the redirections that I was hoping. Are there any other ways of adding/rewriting something to the body of "To" in the SIP message? Or one can only do that in ser.cfg?
Thanks in advance,
José Nunes
Hello Bernie,
Indeed I was taking the wrong way to solve my problem (I should do a more thorough reading of the docs :-)). I do not intend to go so far as to implementing a B2BUA, in the moment I only want redirection, not keeping the dialog state. Now I can achieve my goal using the do_action function to change the request URI.
Thanks for your help,
José Nunes ----- Original Message ----- From: "Bernie Hoeneisen" bhoeneis@switch.ch To: "José Nunes" jnunes@av.it.pt Cc: serusers@lists.iptel.org Sent: Tuesday, November 25, 2003 5:11 PM Subject: Re: [Serusers] Help rewriting "To" URI
Hi Jose!
Routing decisions are never made based on the To: header field. Only the Request-URI and the topmost Route: haeder field are basis for routing decisions (see also RFC 3261). I guess this is why your implementation doesn't work as planned.
AFAIK a proxy changing the To: header field is not allowed, except adding a tag. Furthermore I would expect interoperability problems, if a proxy in the middle changes the To: header field. (Certainly such problems occur with legacy RFC 2543 UAs.)
What you are trying to implement looks like a Back-2-Back-User-Agent (B2BUA).
T: Bernie
On Tue, 25 Nov 2003, José Nunes wrote:
Hello,
I've been working whit SER for a while, and I need to have some way of redirecting Invites dynamicly. The idea is similar to the definition of groups (local,ld,...), only I want to be able to define the redirection address without having to rewrite ser.cfg (and therefor reinitialize SER). The part of defining these new groups and addresses was straightforward, after that I tried to build a module that would have a function to do the writing of the "To" URI. The only function I found to alter the destination URI was append_branch. The module compiles without error and SER works normally, except it does not do the redirections that I was hoping. Are there any other ways of adding/rewriting something to the body of "To" in the SIP message? Or one can only do that in ser.cfg?
Thanks in advance,
José Nunes
If you need to rewrite request URI in a module then you can use the following function (you will have to include "sip_router/mem/mem.h, sip_router/dprint.h, sip_router/parser/msg_parser.h and sip_router/str.h).
Jan.
/* * Rewrite Request-URI */ static inline int rewrite(struct sip_msg* _m, str* _s) { char* buf;
buf = (char*)pkg_malloc(_s->len + 1); if (!buf) { LOG(L_ERR, "rewrite(): No memory left\n"); return -1; } memcpy(buf, _s->s, _s->len); buf[_s->len] = '\0'; _m->parsed_uri_ok = 0; if (_m->new_uri.s) { pkg_free(_m->new_uri.s); }
_m->new_uri.s = buf; _m->new_uri.len = _s->len; DBG("rewrite(): Rewriting Request-URI with '%.*s'\n", _s->len, buf); return 0; }
On 26-11 13:00, José Nunes wrote:
Hello Bernie,
Indeed I was taking the wrong way to solve my problem (I should do a more thorough reading of the docs :-)). I do not intend to go so far as to implementing a B2BUA, in the moment I only want redirection, not keeping the dialog state. Now I can achieve my goal using the do_action function to change the request URI.
Thanks for your help,
José Nunes ----- Original Message ----- From: "Bernie Hoeneisen" bhoeneis@switch.ch To: "José Nunes" jnunes@av.it.pt Cc: serusers@lists.iptel.org Sent: Tuesday, November 25, 2003 5:11 PM Subject: Re: [Serusers] Help rewriting "To" URI
Hi Jose!
Routing decisions are never made based on the To: header field. Only the Request-URI and the topmost Route: haeder field are basis for routing decisions (see also RFC 3261). I guess this is why your implementation doesn't work as planned.
AFAIK a proxy changing the To: header field is not allowed, except adding a tag. Furthermore I would expect interoperability problems, if a proxy in the middle changes the To: header field. (Certainly such problems occur with legacy RFC 2543 UAs.)
What you are trying to implement looks like a Back-2-Back-User-Agent (B2BUA).
T: Bernie
On Tue, 25 Nov 2003, José Nunes wrote:
Hello,
I've been working whit SER for a while, and I need to have some way of redirecting Invites dynamicly. The idea is similar to the definition of groups (local,ld,...), only I want to be able to define the redirection address without having to rewrite ser.cfg (and therefor reinitialize SER). The part of defining these new groups and addresses was straightforward, after that I tried to build a module that would have a function to do the writing of the "To" URI. The only function I found to alter the destination URI was append_branch. The module compiles without error and SER works normally, except it does not do the redirections that I was hoping. Are there any other ways of adding/rewriting something to the body of "To" in the SIP message? Or one can only do that in ser.cfg?
Thanks in advance,
José Nunes
Serusers mailing list serusers@lists.iptel.org http://lists.iptel.org/mailman/listinfo/serusers