Hi,
Context: I am currently writing a module that allows me to connect to a policy server -- not unlike CPL. It essentially routes the message out to the server and then receives a response. I get the message out ok, and will receive a complete sip message back. The module main function is called in the ser.cfg.
Here are my questions: 1) how do I get a message that I have received -- say in char *msg_buf -- to be the message that is used for further routing? The policy server might have changed any header fields or even created a (or several) completely new message(s).
2) can the module send back intermediate messages, such as 1xx info, while it is still continuing its work? This is to provide the user with feedback should things take while ...
3) I also want the module to react to SIP response messages (4xx and so). I assumed providing a response_function would do this, but apparently not (I had a simple one which was just LOGging some text to the system log, but it never did create any entries). So how can I do this?
thanks,
Stephan
-- Dr Stephan Reiff-Marganiec Research Fellow Department of Computing Science; University of Stirling email: srm@cs.stir.ac.uk tel: 01786 46 7448
First, I recommend to developers to use CVS code -- it has not been tested sufficiently yet but we carried out so many clean ups that using 0_8_10 would just cost lot of porting effort later.
At 07:13 PM 2/25/2003, Stephan Reiff-Marganiec wrote:
- how do I get a message that I have received -- say in char *msg_buf -- to
be the message that is used for further routing?
The mechanism we use now is reply_route. We mark transactions to be revisited when a final negative reply comes back with t_on_negative. then, reply_route is entered and the original request is processed again. One could achieve similar functionality which would be less script-programmable but more powerful using TM callbacks.
The policy server might have changed any header fields or even created a (or several) completely new message(s).
As for changing header fields, the following memo may be usefult for you. http://cvs.berlios.de/cgi-bin/viewcvs.cgi/*checkout*/ser/sip_router/doc/tmem...
- can the module send back intermediate messages, such as 1xx info, while
it is still continuing its work? This is to provide the user with feedback should things take while ...
As long as they are 1xx, I think so.
- I also want the module to react to SIP response messages (4xx and so). I
assumed providing a response_function would do this, but apparently not (I had a simple one which was just LOGging some text to the system log, but it never did create any entries). So how can I do this?
We will probably have new route blocks designed for reply processing -- Maxim has already pioneered that and I'm looking now how to integrate with other ideas we want to put in the running code.
-Jiri
Jiri,
I don't think I completely understand your earlier answer -- or maybe it wasn't clear what I wanted to achieve.
| At 07:13 PM 2/25/2003, Stephan Reiff-Marganiec wrote: | >1) how do I get a message that I have received -- say in | char *msg_buf -- to | >be the message that is used for further routing? | | The mechanism we use now is reply_route. We mark transactions | to be revisited | when a final negative reply comes back with t_on_negative. | then, reply_route | is entered and the original request is processed again. One | could achieve | similar functionality which would be less script-programmable | but more powerful | using TM callbacks. |
Here is a little scenario (the module talks to My Server via a TCP Socket):
---- ------------------------ UAC ---------------> SER --------------------->remote end ---- INVITE(a) ------------------------ | /\ | | | INVITE(a) | ****INVITE(c), NOTIFY(d)***** / | ------------------------ MODULE ------------------------ | /\ | | | INVITE(a) | INVITE(c), NOTIFY(d) | | / | ------------------------ MY SERVER ------------------------
The user agent sends an invite (but this could be any other message) which is passed via a ser module to "My Server". My server now adopts the message dependent on some internal rules and will generate new sip messages, which are transferred back to the module. This exchange happens via a TCP connection and works. Module receives the message back and logs it. The whole process is triggered by start_exec() in the route block of ser.cfg. Within module I now have something like:
int start_exec(struct sipmsg *msg) { //... send msg to myserver and receive response // ... receive len of response // buf is: char *buf; n = recv(socket, buf, len, MSG_WAITALL); exit (1); }
at this point buf contains the reposnse(s) that I wish to replace the original message. They are plain sip messages (that is they are text). These message(s) should now be used in the routing instead of the original one. I do not need stateful routing ... hance the tm module seems to be an overkill.
Using Reply_route seems too restricted, as far as I understand it: Depending on the int return value the ser.cfg script knows what should happen. However, an int return is not rich enough for me (well, there simply would be too many cases), as the above example should show.
I appreciate your advice.
Stephan
-- Dr Stephan Reiff-Marganiec Research Fellow Department of Computing Science; University of Stirling email: srm@cs.stir.ac.uk tel: 01786 46 7448
I see -- I misunderstood your message previously. Comments inline.
-jiri
At 07:13 PM 2/25/2003, Stephan Reiff-Marganiec wrote:
Hi,
Context: I am currently writing a module that allows me to connect to a policy server -- not unlike CPL. It essentially routes the message out to the server and then receives a response. I get the message out ok, and will receive a complete sip message back. The module main function is called in the ser.cfg.
Here are my questions:
- how do I get a message that I have received -- say in char *msg_buf -- to
be the message that is used for further routing? The policy server might have changed any header fields or even created a (or several) completely new message(s).
If your server gave you a complete SIP message then you just need to send it out using a socket function.
- can the module send back intermediate messages, such as 1xx info, while
it is still continuing its work? This is to provide the user with feedback should things take while ...
It can -- you must go for stateful processing then. Which is in this case desirable since any TCP questions slow down and block and possible retransmissions would quickly block all your processes.
- I also want the module to react to SIP response messages (4xx and so). I
assumed providing a response_function would do this, but apparently not (I had a simple one which was just LOGging some text to the system log, but it never did create any entries). So how can I do this?
I don't know why your reply logging function did not work, but if you register a response_function, all processed replies will visit it (unless absorbed by stateful processing).
-Jiri
At 01:22 PM 2/28/2003, Jiri Kuthan wrote:
Here are my questions:
- how do I get a message that I have received -- say in char *msg_buf -- to
be the message that is used for further routing? The policy server might have changed any header fields or even created a (or several) completely new message(s).
If your server gave you a complete SIP message then you just need to send it out using a socket function.
I realized another way how you can think of your policy server (if it makes sense in you scenario) -- rather than giving a full resulting message, it can give just diffs to the original message. Actually, sip cgi-bin (rfc-3050) is doing something similar -- it tells add_header, delete_header, etc. You can decide whether you would like to have them high-level (append_header, replace_header) or low-level (insert this string at offset 13).
Just came in my mind and I aired it in case you are seeking kibitzing.
-Jiri