If it's just printing I/O SIP messages, you can also export TPORT_LOG=1
before running your app, or include the following code:
     setenv("TPORT_LOG", "1", 1);

I also have a sofia-sip log redirection to my own function:
     su_log_redirect(NULL, __sofiasip_logger_func, NULL);

And this is my logger function which uses glib for printing.

static void
__sofiasip_logger_func(void *stream, char const *fmt, va_list ap)
{
    if((fmt != NULL) && \
       (strcmp(fmt,"\n") != 0))
    {
        /* Skip sofia-sip msg separators as they have a nasty \n */
        if(strstr(fmt,"-------------------------") != NULL)
            g_debug("----------<SIP message delimiter>---------------");
        else
            g_logv("sofia-sip", G_LOG_LEVEL_DEBUG, fmt, ap);
    }
}

My 2 cents,
-Aleksander


Andrew Rechenberg Lists wrote:
> Working on my test app for the iPhone I just wanted to get the payload
> from a SIP message and display it.  Is this what you want to do?
> 
> I did it by doing the following (which may not be the RightThing, but it
> works for me).  I my event_callback I output the following to my logs:
> 
> sip->sip_payload->pl_data
> 
> Again, it's probably not the correct way to do what you want but I can
> pop a dialog window on the iPhone simulator with the text of the message
> I sent to my UA.
> 
> Hope this helps.
> 
>> -----Original Message-----
>> From: Stefano Sabatini [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, November 20, 2008 7:38 AM
>> To: sofia-sip-devel@lists.sourceforge.net
>> Subject: Re: [Sofia-sip-devel] [NEWBIE] How to print a SIP message
>>
>> 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
> 
> Confidentiality Notice: This e-mail message including attachments, if any, is 
> intended only for the person or entity to which it is addressed and may 
> contain confidential and/or privileged material. Any unauthorized review, 
> use, disclosure or distribution is prohibited. If you are not the intended 
> recipient, please contact the sender by reply e-mail and destroy all copies 
> of the original message. If you are the intended recipient, but do not wish 
> to receive communications through this medium, please so advise the sender 
> immediately.
> 
> -------------------------------------------------------------------------
> 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

-------------------------------------------------------------------------
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