[sr-dev] How to parse msg stored in the tm correctly?

Min Wang wang at basis-audionet.com
Sat Dec 19 17:48:58 CET 2009


HI Andrei 

    thanks a lot!

>> Hi Ser Gurus:
>> 
>>      How to parse msg stored in the tm correctly? 
>> 
>> e.g in the reply msg, we can get the corresponding request from tm:
>> 
>>     msg  = t->uas.request;
>> 
>> The sip_msg_cloner seems copy only via/from/to/cseq/auth headers and
>> parsed headers to the shm, right?
>> 
>> what if we want to parse the other headers, 
>> 
>> e.g:  parse_headers(msg, HDR_ROUTE_F, 0)<0)
>
>By default all headers are parsed before creating the transaction, so
>you'll have all the headers in the shm copy.
>What you don't always have parsed is the content of a header (but that
>depends on the header type).
   
    Oh I see,  what we need is a parsed content of route header. 

>> 
>> The parse_headers uses pkg_alloc, thus the parsed result is
>> pkg_alloced and stored the tm structure,  then it never get freed until
>> tm is destoried ( but even in this case tm may call shm_free instead of
>> pkg_free???? )
>
>In general one calls parse_headers only on a copy of the message stored
>in tm (see fake_req()).

     I see. 

>> 
>> So how can we parsed the tm-stored msg and how to do it correctly?
>
>If you could be more specific (what headers do you need and from where,
>e.g. failure route or a tm hook) it would help.

    Here is the detailed case:

    U1 --> p-cscf --> U2

    U1 call U2, U2 reply with 183 and 200 OK.
    
    The p-cscf  handles the 183/200 reply in two different processes, 
we need to get original request's route header and its parsed content.

the  old psudocode is like which cause memory leak/crash the sytem:

    msg  = t->uas.request;
    parse_headers(msg, HDR_ROUTE_F, 0)
    parse_rr(h);

   
according to your email, it seems should be something like :

    msg  = fake_req(t->uas.request);
    parse_headers(msg, HDR_ROUTE_F, 0)
    parse_rr(h);
    free_faked_req(msg);

    
    since 183/200 are in different process and need the same parsed route header
 content, is there a way to copied the parsed content to shm to avoid duplicate parsing? 
Or is there a way to copy the parsed-header's content to shm before creating the transaction?




Kind regards

Min Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20091219/877437b0/attachment.htm>


More information about the sr-dev mailing list