On date Thursday 2008-11-20 10:49:21 +0100, Stefano Sabatini phoned this:
[...]
> How can I get a msg_t from a sip_t?
> 
> I can convert a msg_t -> sip_t using sip_object, but how can I perform
> the inverse conversion?

Again auto-replying to myself...

Contemplating the sip module doc picture I finally got for the first
time a complete understanding of the msg_t struct.

I don't know if there is function for such a conversion, anyway it
shouldn't too hard to define a function to create a msg_t struct and
fill the fields in order to create (maybe even refactorizing some code
from msg_as_string()).

As suggested by Pessa in a previous mail, for example it should be
possible to iterate through the headers contained in sip_t, print a
representation of them (e.g. using sip_header_as_string()) and fill a
buffer which will be equivalent to the original buffer.

> All I want to do is to simply print out the sip_t message received by
> the event callback, so the solution looks either convert sip_t ->
> msg_t and use msg_as_string() either to print sip_t using some to text
> conversion function, which I can't find.

Even without to access the sip_t struct there is a solution using the
nua_current_request() function. Sofia-sip somehow stores the current
message processed (the name is misleading, since it also stores
response messages), the following snippet may be executed for example
at the beginning of the event callback:

        /* print the incoming message */
        int msg_size = 0;
        msg_t* msg = nua_current_request(nua);
        if (msg) {
            char * msg_str = msg_as_string(home, msg, NULL, 0, &msg_size);
            printf ("SIP message:\n"
                    "%s\n", msg_str);
        }

Regards.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to