<span id="result_box" class="" lang="en"><span title="Clique para mostrar traduções alternativas" class="hps">Actually</span> <span title="Clique para mostrar traduções alternativas" class="hps">I&#39;m</span> <span title="Clique para mostrar traduções alternativas" class="hps">migrating</span> <span title="Clique para mostrar traduções alternativas" class="hps">my</span> <span title="Clique para mostrar traduções alternativas" class="hps">call routing</span> <span title="Clique para mostrar traduções alternativas" class="hps">module</span> <span title="Clique para mostrar traduções alternativas" class="hps">of</span> <span title="Clique para mostrar traduções alternativas" class="hps">version</span> <span title="Clique para mostrar traduções alternativas" class="hps">1.5.0</span> <span title="Clique para mostrar traduções alternativas" class="hps">of</span> <span title="Clique para mostrar traduções alternativas" class="hps">kamailio</span> <span title="Clique para mostrar traduções alternativas" class="hps">to</span> <span title="Clique para mostrar traduções alternativas" class="hps">version 3.1.2</span><span title="Clique para mostrar traduções alternativas">.</span> <span title="Clique para mostrar traduções alternativas" class="hps">I</span> <span title="Clique para mostrar traduções alternativas" class="hps">want to</span> <span title="Clique para mostrar traduções alternativas" class="hps">understand why</span> <span title="Clique para mostrar traduções alternativas" class="hps">the</span> <span title="Clique para mostrar traduções alternativas" class="hps">tm</span> <span title="Clique para mostrar traduções alternativas" class="hps">module</span> <span title="Clique para mostrar traduções alternativas" class="hps">registers</span> <span title="Clique para mostrar traduções alternativas" class="hps">an</span> <span title="Clique para mostrar traduções alternativas" class="hps">event</span> <span title="Clique para mostrar traduções alternativas" class="hps">callback</span> <span title="Clique para mostrar traduções alternativas" class="hps">after</span> <span title="Clique para mostrar traduções alternativas" class="hps">the</span> <span title="Clique para mostrar traduções alternativas" class="hps">INVITE message</span> <span title="Clique para mostrar traduções alternativas" class="hps">is</span> <span title="Clique para mostrar traduções alternativas" class="hps">processed</span> <span title="Clique para mostrar traduções alternativas" class="hps">by</span> <span title="Clique para mostrar traduções alternativas" class="hps">my</span> <span title="Clique para mostrar traduções alternativas" class="hps">routing</span> <span title="Clique para mostrar traduções alternativas" class="hps">module</span><span title="Clique para mostrar traduções alternativas">.</span><br>
 <span title="Clique para mostrar traduções alternativas" class="hps">When I</span> <span title="Clique para mostrar traduções alternativas" class="hps">use the</span> <span title="Clique para mostrar traduções alternativas" class="hps">dispatcher</span> <span title="Clique para mostrar traduções alternativas" class="hps">module</span> <span title="Clique para mostrar traduções alternativas" class="hps">for</span> <span title="Clique para mostrar traduções alternativas" class="hps">routing</span><span title="Clique para mostrar traduções alternativas">,</span> <span title="Clique para mostrar traduções alternativas" class="hps">no</span> <span title="Clique para mostrar traduções alternativas" class="hps">event</span> <span title="Clique para mostrar traduções alternativas" class="hps">callback</span> <span title="Clique para mostrar traduções alternativas" class="hps">is registered</span> <span title="Clique para mostrar traduções alternativas" class="hps">by the</span> <span title="Clique para mostrar traduções alternativas" class="hps">tm</span> <span title="Clique para mostrar traduções alternativas" class="hps">module</span><span title="Clique para mostrar traduções alternativas">.</span><br>
<br> <span title="Clique para mostrar traduções alternativas" class="hps">I do</span> <span title="Clique para mostrar traduções alternativas" class="hps">not</span> <span title="Clique para mostrar traduções alternativas" class="hps">quite understand</span> <span title="Clique para mostrar traduções alternativas" class="hps">this</span> <span title="Clique para mostrar traduções alternativas" class="hps">process</span> <span title="Clique para mostrar traduções alternativas" class="hps">callback</span><span title="Clique para mostrar traduções alternativas">, I</span> <span title="Clique para mostrar traduções alternativas" class="hps">study</span> <span title="Clique para mostrar traduções alternativas" class="hps">a</span> <span title="Clique para mostrar traduções alternativas" class="hps">little more</span> <span title="Clique para mostrar traduções alternativas" class="hps">...<br>
<br></span></span><br>Regards,<br><br><br><br><div class="gmail_quote">2011/6/3 Timo Reimann <span dir="ltr">&lt;<a href="mailto:timo.reimann@1und1.de">timo.reimann@1und1.de</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hey Bruno,<br>
<div class="im"><br>
<br>
On 03.06.2011 16:21, Bruno Bresciani wrote:<br>
&gt; In file t_hook.c line 386 &quot;*cbp-&gt;callback( trans, cbp-&gt;types, params )*&quot;<br>
&gt; calls the function to record register_tmcb when I received a INVITE. I&#39;d<br>
&gt; like to now how register_tmcb function is call by the function callback.<br>
<br>
</div>register_tmcb() isn&#39;t called by a callback function, it rather works the<br>
other way around. For clarity, here&#39;s the call flow:<br>
<br>
(1) A user is interested in being called back on a particular tm event,<br>
e.g., TMCB_DESTROY. To be notified of such events, he calls<br>
tmcb_register() and passes the set of events (callback types) he is<br>
interested in (e.g., TMCB_DESTROY and possibly others) together with the<br>
desired callback function and a few other parameters.<br>
(2) In tmcb_register(), a few sanity checks are done first (e.g.,<br>
callback type is valid, callback function is not NULL, transaction<br>
exists, etc.). If they pass, the callback function and the parameters<br>
are stored in a list of callbacks (called cb_list in register_tmcb()).<br>
(3) When a particular tm event occurs, the tm module checks if any<br>
callbacks were registered for that specific event. If so, it executes<br>
each registered callback function in sequence, with each function being<br>
passed the callback type and callback-specific parameter. The call of<br>
the callback is exactly what<br>
<br>
  cbp-&gt;callback( trans, type, params )<br>
<br>
does, at least for call types other than TMCB_REQUEST_IN.<br>
<br>
For TMCB_REQUEST_IN, the handling is slightly different because<br>
callbacks for new SIP requests cannot be associated with an already<br>
existing transaction (after all, they are new). With regards to how<br>
TMCB_REQUEST_IN-typed callback functions are called, the only difference<br>
is that the callback function is being passed the set of all callback<br>
types the registering user was interested in, and not just TMCB_REQUEST_IN:<br>
<div class="im"><br>
  cbp-&gt;callback( trans, cbp-&gt;types, params )<br>
<br>
</div>(This is line 386.) Actually, I am not quite sure why the extent of<br>
returned callback types differs here. I&#39;m using tm callbacks myself but<br>
never had to take advantage of that.<br>
<br>
<br>
Anyways, if all you want to do is use tm callbacks from a module of<br>
yours, just call register_tmcb() passing<br>
<br>
- a callback function,<br>
- a transaction cell (unless you&#39;re registering for TMCB_REQUEST_IN),<br>
- a void pointer to something you want to be passed back on callback<br>
execution, and<br>
- an optional release function for cleanup purposes.<br>
<br>
Implement your callback-specific logic in the callback function, and<br>
that&#39;s it. Naturally, your callback function must fit the callback<br>
signature defined in t_hooks.h.<br>
<br>
<br>
I hope this answers your question. If not, let us know what you<br>
specifically have in mind, i.e., whether you would like to use tm<br>
callbacks, change the framework, or whatever.<br>
<br>
<br>
Cheers,<br>
<br>
--Timo<br>
<br>
<br>
<br>
&gt; 2011/6/3 Timo Reimann &lt;<a href="mailto:timo.reimann@1und1.de">timo.reimann@1und1.de</a> &lt;mailto:<a href="mailto:timo.reimann@1und1.de">timo.reimann@1und1.de</a>&gt;&gt;<br>
<div><div></div><div class="h5">&gt;<br>
&gt;     Hi Bruno,<br>
&gt;<br>
&gt;<br>
&gt;     On 03.06.2011 00:07, Bruno Bresciani wrote:<br>
&gt;     &gt; I&#39;m having doubts in the implementation of the callback function<br>
&gt;     module<br>
&gt;     &gt; tm. As she calls the function to record register_tmcb ()?<br>
&gt;     &gt; Can someome help me?<br>
&gt;<br>
&gt;     Could you be more specific on which part of the tm module you are having<br>
&gt;     trouble with?<br>
&gt;<br>
&gt;     If you need an example on how to use tm&#39;s callbacks you may take a look<br>
&gt;     at the dialog module, specifically the files dialog.c and<br>
&gt;     dlg_handlers.c.<br>
&gt;<br>
&gt;<br>
&gt;     Cheers,<br>
&gt;<br>
&gt;     --Timo<br>
</div></div></blockquote></div><br>