This file is indexed.

/usr/share/gtk-doc/html/libnice/libnice-Timer.html is in libnice-doc 0.1.1-2ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Timer</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="libnice Reference Manual">
<link rel="up" href="ch04.html" title="STUN usages">
<link rel="prev" href="libnice-TURN.html" title="TURN">
<link rel="next" href="pt03.html" title="Part III. Pseudo TCP Socket implementation">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="libnice-TURN.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch04.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">libnice Reference Manual</th>
<td><a accesskey="n" href="pt03.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#libnice-Timer.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#libnice-Timer.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="libnice-Timer"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="libnice-Timer.top_of_page"></a>Timer</span></h2>
<p>Timer — STUN timer Usage</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="libnice-Timer.stability-level"></a><h2>Stability Level</h2>
Stable, unless otherwise indicated
</div>
<div class="refsynopsisdiv">
<a name="libnice-Timer.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;stun/usages/timer.h&gt;

typedef             <a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer">StunTimer</a>;
enum                <a class="link" href="libnice-Timer.html#StunUsageTimerReturn" title="enum StunUsageTimerReturn">StunUsageTimerReturn</a>;
#define             <a class="link" href="libnice-Timer.html#STUN-TIMER-DEFAULT-MAX-RETRANSMISSIONS:CAPS" title="STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS">STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS</a>
#define             <a class="link" href="libnice-Timer.html#STUN-TIMER-DEFAULT-RELIABLE-TIMEOUT:CAPS" title="STUN_TIMER_DEFAULT_RELIABLE_TIMEOUT">STUN_TIMER_DEFAULT_RELIABLE_TIMEOUT</a>
#define             <a class="link" href="libnice-Timer.html#STUN-TIMER-DEFAULT-TIMEOUT:CAPS" title="STUN_TIMER_DEFAULT_TIMEOUT">STUN_TIMER_DEFAULT_TIMEOUT</a>
<span class="returnvalue">void</span>                <a class="link" href="libnice-Timer.html#stun-timer-start" title="stun_timer_start ()">stun_timer_start</a>                    (<em class="parameter"><code><a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> *timer</code></em>,
                                                         <em class="parameter"><code>unsigned <span class="type">int</span> initial_timeout</code></em>,
                                                         <em class="parameter"><code>unsigned <span class="type">int</span> max_retransmissions</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="libnice-Timer.html#stun-timer-start-reliable" title="stun_timer_start_reliable ()">stun_timer_start_reliable</a>           (<em class="parameter"><code><a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> *timer</code></em>,
                                                         <em class="parameter"><code>unsigned <span class="type">int</span> initial_timeout</code></em>);
<a class="link" href="libnice-Timer.html#StunUsageTimerReturn" title="enum StunUsageTimerReturn"><span class="returnvalue">StunUsageTimerReturn</span></a>  <a class="link" href="libnice-Timer.html#stun-timer-refresh" title="stun_timer_refresh ()">stun_timer_refresh</a>                (<em class="parameter"><code><a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> *timer</code></em>);
<span class="returnvalue">unsigned</span>            <a class="link" href="libnice-Timer.html#stun-timer-remainder" title="stun_timer_remainder ()">stun_timer_remainder</a>                (<em class="parameter"><code>const <a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> *timer</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="libnice-Timer.description"></a><h2>Description</h2>
<p>
The STUN timer usage is a set of helpful utility functions that allows you
to easily track when a STUN message should be retransmitted or considered
as timed out.
</p>
<p>
 </p>
<div class="example">
<a name="id2712328"></a><p class="title"><b>Example 3. Simple example on how to use the timer usage</b></p>
<div class="example-contents">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="usertype">StunTimer</span><span class="normal"> timer</span><span class="symbol">;</span>
<span class="type">unsigned</span><span class="normal"> remainder</span><span class="symbol">;</span>
<span class="usertype">StunUsageTimerReturn</span><span class="normal"> ret</span><span class="symbol">;</span>

<span class="comment">// Build the message, etc..</span>
<span class="symbol">...</span>

<span class="comment">// Send the message and start the timer</span>
<span class="function">send</span><span class="symbol">(</span><span class="normal">socket</span><span class="symbol">,</span><span class="normal"> request</span><span class="symbol">,</span><span class="normal"> </span><span class="keyword">sizeof</span><span class="symbol">(</span><span class="normal">request</span><span class="symbol">));</span>
<span class="function"><a href="libnice-Timer.html#stun-timer-start">stun_timer_start</a></span><span class="symbol">(&amp;</span><span class="normal">timer</span><span class="symbol">,</span><span class="normal"> <a href="libnice-Timer.html#STUN-TIMER-DEFAULT-TIMEOUT:CAPS">STUN_TIMER_DEFAULT_TIMEOUT</a></span><span class="symbol">,</span>
<span class="normal">                 <a href="libnice-Timer.html#STUN-TIMER-DEFAULT-MAX-RETRANSMISSIONS:CAPS">STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS</a></span><span class="symbol">);</span>

<span class="comment">// Loop until we get the response</span>
<span class="keyword">for</span><span class="normal"> </span><span class="symbol">(;;)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">  remainder </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="libnice-Timer.html#stun-timer-remainder">stun_timer_remainder</a></span><span class="symbol">(&amp;</span><span class="normal">timer</span><span class="symbol">);</span>

<span class="normal">  </span><span class="comment">// Poll the socket until data is received or the timer expires</span>
<span class="normal">  </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function">poll</span><span class="normal"> </span><span class="symbol">(&amp;</span><span class="normal">pollfd</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1</span><span class="symbol">,</span><span class="normal"> delay</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">&lt;=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">    </span><span class="comment">// Time out and no response was received</span>
<span class="normal">    ret </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="libnice-Timer.html#stun-timer-refresh">stun_timer_refresh</a></span><span class="normal"> </span><span class="symbol">(&amp;</span><span class="normal">timer</span><span class="symbol">);</span>
<span class="normal">    </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">ret </span><span class="symbol">==</span><span class="normal"> <a href="libnice-Timer.html#STUN-USAGE-TIMER-RETURN-TIMEOUT:CAPS">STUN_USAGE_TIMER_RETURN_TIMEOUT</a></span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">      </span><span class="comment">// Transaction timed out</span>
<span class="normal">      </span><span class="keyword">break</span><span class="symbol">;</span>
<span class="normal">    </span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">ret </span><span class="symbol">==</span><span class="normal"> <a href="libnice-Timer.html#STUN-USAGE-TIMER-RETURN-RETRANSMIT:CAPS">STUN_USAGE_TIMER_RETURN_RETRANSMIT</a></span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">      </span><span class="comment">// A retransmission is necessary</span>
<span class="normal">      </span><span class="function">send</span><span class="symbol">(</span><span class="normal">socket</span><span class="symbol">,</span><span class="normal"> request</span><span class="symbol">,</span><span class="normal"> </span><span class="keyword">sizeof</span><span class="symbol">(</span><span class="normal">request</span><span class="symbol">));</span>
<span class="normal">      </span><span class="keyword">continue</span><span class="symbol">;</span>
<span class="normal">    </span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">ret </span><span class="symbol">==</span><span class="normal"> <a href="libnice-Timer.html#STUN-USAGE-TIMER-RETURN-SUCCESS:CAPS">STUN_USAGE_TIMER_RETURN_SUCCESS</a></span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">      </span><span class="comment">// The refresh succeeded and nothing has to be done, continue polling</span>
<span class="normal">      </span><span class="keyword">continue</span><span class="symbol">;</span>
<span class="normal">    </span><span class="cbracket">}</span>
<span class="normal">  </span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">    </span><span class="comment">// We received a response, read it</span>
<span class="normal">    </span><span class="function">recv</span><span class="symbol">(</span><span class="normal">socket</span><span class="symbol">,</span><span class="normal"> response</span><span class="symbol">,</span><span class="normal"> </span><span class="keyword">sizeof</span><span class="symbol">(</span><span class="normal">response</span><span class="symbol">));</span>
<span class="normal">    </span><span class="keyword">break</span><span class="symbol">;</span>
<span class="normal">  </span><span class="cbracket">}</span>
<span class="cbracket">}</span>

<span class="comment">// Check if the transaction timed out or not</span>
<span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">ret </span><span class="symbol">==</span><span class="normal"> <a href="libnice-Timer.html#STUN-USAGE-TIMER-RETURN-TIMEOUT:CAPS">STUN_USAGE_TIMER_RETURN_TIMEOUT</a></span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">  </span><span class="comment">// do whatever needs to be done in that case</span>
<span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">  </span><span class="comment">// Parse the response</span>
<span class="cbracket">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

</div>
<p><br class="example-break">
</p>
</div>
<div class="refsect1">
<a name="libnice-Timer.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="StunTimer"></a><h3>StunTimer</h3>
<pre class="programlisting">typedef struct stun_timer_s StunTimer;
</pre>
<p>
An opaque structure representing a STUN transaction retransmission timer
</p>
</div>
<hr>
<div class="refsect2">
<a name="StunUsageTimerReturn"></a><h3>enum StunUsageTimerReturn</h3>
<pre class="programlisting">typedef enum {
  STUN_USAGE_TIMER_RETURN_SUCCESS,
  STUN_USAGE_TIMER_RETURN_RETRANSMIT,
  STUN_USAGE_TIMER_RETURN_TIMEOUT
} StunUsageTimerReturn;
</pre>
<p>
Return value of <code class="function">stun_usage_timer_refresh()</code> which provides you with status
information on the timer.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><a name="STUN-USAGE-TIMER-RETURN-SUCCESS:CAPS"></a><span class="term"><code class="literal">STUN_USAGE_TIMER_RETURN_SUCCESS</code></span></p></td>
<td>The timer was refreshed successfully
and there is nothing to be done
</td>
</tr>
<tr>
<td><p><a name="STUN-USAGE-TIMER-RETURN-RETRANSMIT:CAPS"></a><span class="term"><code class="literal">STUN_USAGE_TIMER_RETURN_RETRANSMIT</code></span></p></td>
<td>The timer expired and the message
should be retransmitted now.
</td>
</tr>
<tr>
<td><p><a name="STUN-USAGE-TIMER-RETURN-TIMEOUT:CAPS"></a><span class="term"><code class="literal">STUN_USAGE_TIMER_RETURN_TIMEOUT</code></span></p></td>
<td>The timer expired as well as all the
retransmissions, the transaction timed out
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="STUN-TIMER-DEFAULT-MAX-RETRANSMISSIONS:CAPS"></a><h3>STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS</h3>
<pre class="programlisting">#define STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS 3
</pre>
<p>
The default maximum retransmissions allowed before a timer decides to timeout
</p>
</div>
<hr>
<div class="refsect2">
<a name="STUN-TIMER-DEFAULT-RELIABLE-TIMEOUT:CAPS"></a><h3>STUN_TIMER_DEFAULT_RELIABLE_TIMEOUT</h3>
<pre class="programlisting">#define STUN_TIMER_DEFAULT_RELIABLE_TIMEOUT 7900
</pre>
<p>
The default intial timeout to use for a reliable timer
</p>
</div>
<hr>
<div class="refsect2">
<a name="STUN-TIMER-DEFAULT-TIMEOUT:CAPS"></a><h3>STUN_TIMER_DEFAULT_TIMEOUT</h3>
<pre class="programlisting">#define STUN_TIMER_DEFAULT_TIMEOUT 600
</pre>
<p>
The default intial timeout to use for the timer
</p>
</div>
<hr>
<div class="refsect2">
<a name="stun-timer-start"></a><h3>stun_timer_start ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                stun_timer_start                    (<em class="parameter"><code><a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> *timer</code></em>,
                                                         <em class="parameter"><code>unsigned <span class="type">int</span> initial_timeout</code></em>,
                                                         <em class="parameter"><code>unsigned <span class="type">int</span> max_retransmissions</code></em>);</pre>
<p>
Starts a STUN transaction retransmission timer.
This should be called as soon as you send the message for the first time on
a UDP socket.
The timeout before the next retransmission is set to <em class="parameter"><code>initial_timeout</code></em>, then
each time a packet is retransmited, that timeout will be doubled, until the
<em class="parameter"><code>max_retransmissions</code></em> retransmissions limit is reached.
</p>
<p>
To determine the total timeout value, one can use the following equation :
 </p>
<pre class="programlisting">
 total_timeout =  initial_timeout * (2^(max_retransmissions + 1) - 1);
 </pre>
<p>
</p>
<p>
</p>
<p>
See also: <a class="link" href="libnice-Timer.html#STUN-TIMER-DEFAULT-TIMEOUT:CAPS" title="STUN_TIMER_DEFAULT_TIMEOUT"><span class="type">STUN_TIMER_DEFAULT_TIMEOUT</span></a>
</p>
<p>
See also: <a class="link" href="libnice-Timer.html#STUN-TIMER-DEFAULT-MAX-RETRANSMISSIONS:CAPS" title="STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS"><span class="type">STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS</span></a>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>timer</code></em> :</span></p></td>
<td>The <a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> to start</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>initial_timeout</code></em> :</span></p></td>
<td>The initial timeout to use before the first retransmission</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>max_retransmissions</code></em> :</span></p></td>
<td>The maximum number of transmissions before the
<a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> times out</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="stun-timer-start-reliable"></a><h3>stun_timer_start_reliable ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                stun_timer_start_reliable           (<em class="parameter"><code><a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> *timer</code></em>,
                                                         <em class="parameter"><code>unsigned <span class="type">int</span> initial_timeout</code></em>);</pre>
<p>
Starts a STUN transaction retransmission timer for a reliable transport.
This should be called as soon as you send the message for the first time on
a TCP socket
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>timer</code></em> :</span></p></td>
<td>The <a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> to start</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="stun-timer-refresh"></a><h3>stun_timer_refresh ()</h3>
<pre class="programlisting"><a class="link" href="libnice-Timer.html#StunUsageTimerReturn" title="enum StunUsageTimerReturn"><span class="returnvalue">StunUsageTimerReturn</span></a>  stun_timer_refresh                (<em class="parameter"><code><a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> *timer</code></em>);</pre>
<p>
Updates a STUN transaction retransmission timer.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>timer</code></em> :</span></p></td>
<td>The <a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> to refresh</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A <a class="link" href="libnice-Timer.html#StunUsageTimerReturn" title="enum StunUsageTimerReturn"><span class="type">StunUsageTimerReturn</span></a> telling you what to do next</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="stun-timer-remainder"></a><h3>stun_timer_remainder ()</h3>
<pre class="programlisting"><span class="returnvalue">unsigned</span>            stun_timer_remainder                (<em class="parameter"><code>const <a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> *timer</code></em>);</pre>
<p>
Query the timer on the time left before the next refresh should be done
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>timer</code></em> :</span></p></td>
<td>The <a class="link" href="libnice-Timer.html#StunTimer" title="StunTimer"><span class="type">StunTimer</span></a> to query</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>The time remaining for the timer to expire in milliseconds</td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>