<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/3362/">https://reviewboard.asterisk.org/r/3362/</a>
</td>
</tr>
</table>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/3362/diff/8/?file=56955#file56955line306" style="color: black; font-weight: bold; text-decoration: underline;">/trunk/funcs/func_periodic_hook.c</a>
<span style="font-weight: normal;">
(Diff revision 8)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">306</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="n">args</span><span class="p">.</span><span class="n">context</span> <span class="o">=</span> <span class="n">S_OR</span><span class="p">(</span><span class="n">args</span><span class="p">.</span><span class="n">context</span><span class="p">,</span> <span class="s">"default"</span><span class="p">);</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">307</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="n">args</span><span class="p">.</span><span class="n">exten</span> <span class="o">=</span> <span class="n">S_OR</span><span class="p">(</span><span class="n">args</span><span class="p">.</span><span class="n">exten</span><span class="p">,</span> <span class="s">"s"</span><span class="p">);</span></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The xmldoc states that these parameters are required so I think it would be better to report failure if either are ast_strlen_zero.
I have tagged this issue here instead of the documentation since I don't agree with them having defaults. I would not object strongly if args.exten were optional / default "s", but only if the parameters were reordered to PERIODIC_INTERVAL(interval,context,exten). My preference is to require the caller to be explicit with all parameters.</pre>
</div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/3362/diff/8/?file=56955#file56955line445" style="color: black; font-weight: bold; text-decoration: underline;">/trunk/funcs/func_periodic_hook.c</a>
<span style="font-weight: normal;">
(Diff revision 8)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">445</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="n">res</span> <span class="o">=</span> <span class="n">ast_custom_function_register</span><span class="p">(</span><span class="o">&</span><span class="n">hook_function</span><span class="p">);</span></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I just had a thought about AMI (and ARI?) security. This function should be unavailable to users without originate permissions. I'm not aware of a way to require Originate permissions from someone who is using AMI to write to this function, so I think this might need to use ast_custom_function_register_escalating.
I am very sure with AMI access to read this function and channel events I could perform a DoS attack against the local system while harassing 1 or more individuals with a continuous stream of silent calls (they hangup one call, another call comes within 1 second). Normally a lack of permission to originate channels should prevent me from doing this.</pre>
</div>
<br />
<p>- Corey Farrell</p>
<br />
<p>On April 1st, 2014, 12:43 p.m. EDT, Russell Bryant wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By Russell Bryant.</div>
<p style="color: grey;"><i>Updated April 1, 2014, 12:43 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"> This commit introduces a new dialplan function, PERIODIC_HOOK().
It allows you run to a dialplan hook on a channel periodically. The
original use case that inspired this was the ability to play a beep
periodically into a call being recorded. The implementation is much
more generic though and could be used for many other things.
The implementation makes heavy use of existing Asterisk components.
It uses a combination of Local channels and ChanSpy() to run some
custom dialplan and inject any audio it generates into an active call.
The other important bit of the implementation is how it figures out
when to trigger the beep playback. This implementation uses the
audiohook API, even though it's not actually touching the audio in any
way. It's a convenient way to get a callback and check if it's time
to kick off another beep. It would be nice if this was timer event
based instead of polling based, but unfortunately I don't see a way to
do it that won't interfere with other things.
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Called the following extension (100@test), both letting it run all the way through, as well as hanging up at various points in the middle.
[hooks]
exten => beep,1,Answer()
same => n,Verbose(1,Channel name: ${HOOK_CHANNEL})
same => n,Verbose(1,Hook ID: ${HOOK_ID})
same => n,Playback(beep)
[test]
exten => 100,1,Answer()
same => n,Set(BEEP_ID=${PERIODIC_HOOK(hooks,beep,5)})
same => n,Wait(20)
same => n,Set(PERIODIC_HOOK(${BEEP_ID})=off)
same => n,Wait(20)
same => n,Set(PERIODIC_HOOK(${BEEP_ID})=on)
same => n,Wait(20)
same => n,Hangup()
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/trunk/funcs/func_periodic_hook.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/CHANGES <span style="color: grey">(411583)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/3362/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>