PageRenderTime 143ms CodeModel.GetById 48ms RepoModel.GetById 4ms app.codeStats 1ms

/OverSim-20101103/doc/doxy/stun_8cc_source.html

https://bitbucket.org/indigopony/omnetproject
HTML | 2544 lines | 2543 code | 0 blank | 1 comment | 0 complexity | 8fed1a93e64c11b01c0e744ec6daf511 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, GPL-2.0, Apache-2.0, JSON

Large files files are truncated, but you can click here to view the full file

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <title>OverSim: stun.cc Source File</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  8. </head>
  9. <body>
  10. <!-- Generated by Doxygen 1.7.1 -->
  11. <div class="navigation" id="top">
  12. <div class="tabs">
  13. <ul class="tablist">
  14. <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
  15. <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  16. <li><a href="namespaces.html"><span>Namespaces</span></a></li>
  17. <li><a href="annotated.html"><span>Classes</span></a></li>
  18. <li class="current"><a href="files.html"><span>Files</span></a></li>
  19. <li><a href="dirs.html"><span>Directories</span></a></li>
  20. </ul>
  21. </div>
  22. <div class="tabs2">
  23. <ul class="tablist">
  24. <li><a href="files.html"><span>File&nbsp;List</span></a></li>
  25. <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
  26. </ul>
  27. </div>
  28. <div class="navpath">
  29. <ul>
  30. <li><a class="el" href="dir_668dee661430860db5868c2621a9c372.html">src</a> </li>
  31. <li><a class="el" href="dir_12590045ec6dcd64f3c4ad499444ef83.html">underlay</a> </li>
  32. <li><a class="el" href="dir_e7abd501ef2699b72177966ee598d65b.html">singlehostunderlay</a> </li>
  33. <li><a class="el" href="dir_e172c4d23ca9cdab66e1c382ceb2ddaa.html">stun</a> </li>
  34. </ul>
  35. </div>
  36. </div>
  37. <div class="header">
  38. <div class="headertitle">
  39. <h1>stun.cc</h1> </div>
  40. </div>
  41. <div class="contents">
  42. <a href="stun_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &lt;cassert&gt;</span>
  43. <a name="l00002"></a>00002 <span class="preprocessor">#include &lt;cstring&gt;</span>
  44. <a name="l00003"></a>00003 <span class="preprocessor">#include &lt;iostream&gt;</span>
  45. <a name="l00004"></a>00004 <span class="preprocessor">#include &lt;cstdlib&gt;</span>
  46. <a name="l00005"></a>00005 <span class="preprocessor">#include &lt;errno.h&gt;</span>
  47. <a name="l00006"></a>00006
  48. <a name="l00007"></a>00007 <span class="preprocessor">#ifdef WIN32</span>
  49. <a name="l00008"></a>00008 <span class="preprocessor"></span><span class="preprocessor">#include &lt;winsock2.h&gt;</span>
  50. <a name="l00009"></a>00009 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
  51. <a name="l00010"></a>00010 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
  52. <a name="l00011"></a>00011 <span class="preprocessor">#include &lt;io.h&gt;</span>
  53. <a name="l00012"></a>00012 <span class="preprocessor">#include &lt;time.h&gt;</span>
  54. <a name="l00013"></a>00013 <span class="preprocessor">#else</span>
  55. <a name="l00014"></a>00014 <span class="preprocessor"></span>
  56. <a name="l00015"></a>00015 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
  57. <a name="l00016"></a>00016 <span class="preprocessor">#include &lt;unistd.h&gt;</span>
  58. <a name="l00017"></a>00017 <span class="preprocessor">#include &lt;string.h&gt;</span>
  59. <a name="l00018"></a>00018 <span class="preprocessor">#include &lt;sys/ioctl.h&gt;</span>
  60. <a name="l00019"></a>00019 <span class="preprocessor">#include &lt;sys/socket.h&gt;</span>
  61. <a name="l00020"></a>00020 <span class="preprocessor">#include &lt;sys/time.h&gt;</span>
  62. <a name="l00021"></a>00021 <span class="preprocessor">#include &lt;sys/types.h&gt;</span>
  63. <a name="l00022"></a>00022 <span class="preprocessor">#include &lt;arpa/inet.h&gt;</span>
  64. <a name="l00023"></a>00023 <span class="preprocessor">#include &lt;fcntl.h&gt;</span>
  65. <a name="l00024"></a>00024 <span class="preprocessor">#include &lt;netdb.h&gt;</span>
  66. <a name="l00025"></a>00025 <span class="preprocessor">#include &lt;netinet/in.h&gt;</span>
  67. <a name="l00026"></a>00026 <span class="preprocessor">#include &lt;arpa/nameser.h&gt;</span>
  68. <a name="l00027"></a>00027 <span class="preprocessor">#include &lt;resolv.h&gt;</span>
  69. <a name="l00028"></a>00028 <span class="preprocessor">#include &lt;net/if.h&gt;</span>
  70. <a name="l00029"></a>00029
  71. <a name="l00030"></a>00030 <span class="preprocessor">#endif</span>
  72. <a name="l00031"></a>00031 <span class="preprocessor"></span>
  73. <a name="l00032"></a>00032
  74. <a name="l00033"></a>00033 <span class="preprocessor">#if defined(__sparc__) || defined(WIN32)</span>
  75. <a name="l00034"></a>00034 <span class="preprocessor"></span><span class="preprocessor">#define NOSSL</span>
  76. <a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  77. <a name="l00036"></a><a class="code" href="stun_8cc.html#a6072c634968940fb89f70b65cf072c6a">00036</a> <span class="preprocessor"></span><span class="preprocessor">#define NOSSL</span>
  78. <a name="l00037"></a>00037 <span class="preprocessor"></span>
  79. <a name="l00038"></a>00038 <span class="preprocessor">#include &quot;<a class="code" href="stun__udp_8h.html">stun_udp.h</a>&quot;</span>
  80. <a name="l00039"></a>00039 <span class="preprocessor">#include &quot;<a class="code" href="stun_8h.html">stun.h</a>&quot;</span>
  81. <a name="l00040"></a>00040
  82. <a name="l00041"></a>00041
  83. <a name="l00042"></a>00042 <span class="keyword">using namespace </span>std;
  84. <a name="l00043"></a>00043
  85. <a name="l00044"></a>00044
  86. <a name="l00045"></a>00045 <span class="keyword">static</span> <span class="keywordtype">void</span>
  87. <a name="l00046"></a>00046 <a class="code" href="stun_8cc.html#afdae90956a999518a90595e783525734">computeHmac</a>(<span class="keywordtype">char</span>* hmac, <span class="keyword">const</span> <span class="keywordtype">char</span>* input, <span class="keywordtype">int</span> length, <span class="keyword">const</span> <span class="keywordtype">char</span>* key, <span class="keywordtype">int</span> keySize);
  88. <a name="l00047"></a>00047
  89. <a name="l00048"></a>00048 <span class="keyword">static</span> <span class="keywordtype">bool</span>
  90. <a name="l00049"></a><a class="code" href="stun_8cc.html#a16624b9ba3d6b2f1c821571fa467c544">00049</a> <a class="code" href="stun_8cc.html#a16624b9ba3d6b2f1c821571fa467c544">stunParseAtrAddress</a>( <span class="keywordtype">char</span>* body, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hdrLen, <a class="code" href="structStunAtrAddress4.html">StunAtrAddress4</a>&amp; result )
  91. <a name="l00050"></a>00050 {
  92. <a name="l00051"></a>00051 <span class="keywordflow">if</span> ( hdrLen != 8 )
  93. <a name="l00052"></a>00052 {
  94. <a name="l00053"></a>00053 clog &lt;&lt; <span class="stringliteral">&quot;hdrLen wrong for Address&quot;</span> &lt;&lt;endl;
  95. <a name="l00054"></a>00054 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  96. <a name="l00055"></a>00055 }
  97. <a name="l00056"></a>00056 result.<a class="code" href="structStunAtrAddress4.html#afe6ed0534166b0fd194b23b01ddad7b4">pad</a> = *body++;
  98. <a name="l00057"></a>00057 result.<a class="code" href="structStunAtrAddress4.html#ab31f05e3cba900d7613bc9f226f171d0">family</a> = *body++;
  99. <a name="l00058"></a>00058 <span class="keywordflow">if</span> (result.<a class="code" href="structStunAtrAddress4.html#ab31f05e3cba900d7613bc9f226f171d0">family</a> == <a class="code" href="stun_8h.html#ac2c7bc41e1b918c98583006fd7025bc5" title="define a structure to hold a stun address">IPv4Family</a>)
  100. <a name="l00059"></a>00059 {
  101. <a name="l00060"></a>00060 <a class="code" href="stun_8h.html#accc14a7c843716dfed734f3a03e8d2b6">UInt16</a> nport;
  102. <a name="l00061"></a>00061 memcpy(&amp;nport, body, 2); body+=2;
  103. <a name="l00062"></a>00062 result.<a class="code" href="structStunAtrAddress4.html#a80b81fdc81e96531c1fecd5b9b5125c4">ipv4</a>.<a class="code" href="structStunAddress4.html#a182b25091f39b6f1d9904a02bcbeb43b">port</a> = ntohs(nport);
  104. <a name="l00063"></a>00063
  105. <a name="l00064"></a>00064 <a class="code" href="stun_8h.html#a4cd0dc7d33ac7a69204e8429ecea0f86">UInt32</a> naddr;
  106. <a name="l00065"></a>00065 memcpy(&amp;naddr, body, 4); body+=4;
  107. <a name="l00066"></a>00066 result.<a class="code" href="structStunAtrAddress4.html#a80b81fdc81e96531c1fecd5b9b5125c4">ipv4</a>.<a class="code" href="structStunAddress4.html#a870846bf1b2de80c031948f0795e24c6">addr</a> = ntohl(naddr);
  108. <a name="l00067"></a>00067 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  109. <a name="l00068"></a>00068 }
  110. <a name="l00069"></a>00069 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (result.<a class="code" href="structStunAtrAddress4.html#ab31f05e3cba900d7613bc9f226f171d0">family</a> == <a class="code" href="stun_8h.html#a5da56f5efebd69e84bf5fdb74a02bf8a">IPv6Family</a>)
  111. <a name="l00070"></a>00070 {
  112. <a name="l00071"></a>00071 clog &lt;&lt; <span class="stringliteral">&quot;ipv6 not supported&quot;</span> &lt;&lt; endl;
  113. <a name="l00072"></a>00072 }
  114. <a name="l00073"></a>00073 <span class="keywordflow">else</span>
  115. <a name="l00074"></a>00074 {
  116. <a name="l00075"></a>00075 clog &lt;&lt; <span class="stringliteral">&quot;bad address family: &quot;</span> &lt;&lt; result.<a class="code" href="structStunAtrAddress4.html#ab31f05e3cba900d7613bc9f226f171d0">family</a> &lt;&lt; endl;
  117. <a name="l00076"></a>00076 }
  118. <a name="l00077"></a>00077
  119. <a name="l00078"></a>00078 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  120. <a name="l00079"></a>00079 }
  121. <a name="l00080"></a>00080
  122. <a name="l00081"></a>00081 <span class="keyword">static</span> <span class="keywordtype">bool</span>
  123. <a name="l00082"></a><a class="code" href="stun_8cc.html#af2f9f10bd394cb42037f1997266b978a">00082</a> <a class="code" href="stun_8cc.html#af2f9f10bd394cb42037f1997266b978a">stunParseAtrChangeRequest</a>( <span class="keywordtype">char</span>* body, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hdrLen, <a class="code" href="structStunAtrChangeRequest.html">StunAtrChangeRequest</a>&amp; result )
  124. <a name="l00083"></a>00083 {
  125. <a name="l00084"></a>00084 <span class="keywordflow">if</span> ( hdrLen != 4 )
  126. <a name="l00085"></a>00085 {
  127. <a name="l00086"></a>00086 clog &lt;&lt; <span class="stringliteral">&quot;hdr length = &quot;</span> &lt;&lt; hdrLen &lt;&lt; <span class="stringliteral">&quot; expecting &quot;</span> &lt;&lt; <span class="keyword">sizeof</span>(result) &lt;&lt; endl;
  128. <a name="l00087"></a>00087
  129. <a name="l00088"></a>00088 clog &lt;&lt; <span class="stringliteral">&quot;Incorrect size for ChangeRequest&quot;</span> &lt;&lt; endl;
  130. <a name="l00089"></a>00089 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  131. <a name="l00090"></a>00090 }
  132. <a name="l00091"></a>00091 <span class="keywordflow">else</span>
  133. <a name="l00092"></a>00092 {
  134. <a name="l00093"></a>00093 memcpy(&amp;result.<a class="code" href="structStunAtrChangeRequest.html#adbb006a8e7cc0637d01959c8ba985c0c">value</a>, body, 4);
  135. <a name="l00094"></a>00094 result.<a class="code" href="structStunAtrChangeRequest.html#adbb006a8e7cc0637d01959c8ba985c0c">value</a> = ntohl(result.<a class="code" href="structStunAtrChangeRequest.html#adbb006a8e7cc0637d01959c8ba985c0c">value</a>);
  136. <a name="l00095"></a>00095 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  137. <a name="l00096"></a>00096 }
  138. <a name="l00097"></a>00097 }
  139. <a name="l00098"></a>00098
  140. <a name="l00099"></a>00099 <span class="keyword">static</span> <span class="keywordtype">bool</span>
  141. <a name="l00100"></a><a class="code" href="stun_8cc.html#afdf35a5dc5c3d6b7109c290308e32887">00100</a> <a class="code" href="stun_8cc.html#afdf35a5dc5c3d6b7109c290308e32887">stunParseAtrError</a>( <span class="keywordtype">char</span>* body, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hdrLen, <a class="code" href="structStunAtrError.html">StunAtrError</a>&amp; result )
  142. <a name="l00101"></a>00101 {
  143. <a name="l00102"></a>00102 <span class="keywordflow">if</span> ( hdrLen &gt;= <span class="keyword">sizeof</span>(result) )
  144. <a name="l00103"></a>00103 {
  145. <a name="l00104"></a>00104 clog &lt;&lt; <span class="stringliteral">&quot;head on Error too large&quot;</span> &lt;&lt; endl;
  146. <a name="l00105"></a>00105 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  147. <a name="l00106"></a>00106 }
  148. <a name="l00107"></a>00107 <span class="keywordflow">else</span>
  149. <a name="l00108"></a>00108 {
  150. <a name="l00109"></a>00109 memcpy(&amp;result.<a class="code" href="structStunAtrError.html#ae2d32994bcf7387452902e139f2b652f">pad</a>, body, 2); body+=2;
  151. <a name="l00110"></a>00110 result.<a class="code" href="structStunAtrError.html#ae2d32994bcf7387452902e139f2b652f">pad</a> = ntohs(result.<a class="code" href="structStunAtrError.html#ae2d32994bcf7387452902e139f2b652f">pad</a>);
  152. <a name="l00111"></a>00111 result.<a class="code" href="structStunAtrError.html#aef65890aa74d342d326ea74000064be5">errorClass</a> = *body++;
  153. <a name="l00112"></a>00112 result.<a class="code" href="structStunAtrError.html#abdee224c138f23ad06aeb97ed9d6e0fe">number</a> = *body++;
  154. <a name="l00113"></a>00113
  155. <a name="l00114"></a>00114 result.<a class="code" href="structStunAtrError.html#adcac61cdac715d64ebaa78e6847e1108">sizeReason</a> = hdrLen - 4;
  156. <a name="l00115"></a>00115 memcpy(&amp;result.<a class="code" href="structStunAtrError.html#a3bb11d3802d0bfe65a153d8a6bccd472">reason</a>, body, result.<a class="code" href="structStunAtrError.html#adcac61cdac715d64ebaa78e6847e1108">sizeReason</a>);
  157. <a name="l00116"></a>00116 result.<a class="code" href="structStunAtrError.html#a3bb11d3802d0bfe65a153d8a6bccd472">reason</a>[result.<a class="code" href="structStunAtrError.html#adcac61cdac715d64ebaa78e6847e1108">sizeReason</a>] = 0;
  158. <a name="l00117"></a>00117 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  159. <a name="l00118"></a>00118 }
  160. <a name="l00119"></a>00119 }
  161. <a name="l00120"></a>00120
  162. <a name="l00121"></a>00121 <span class="keyword">static</span> <span class="keywordtype">bool</span>
  163. <a name="l00122"></a><a class="code" href="stun_8cc.html#a739d3cc61a2a1609b96d535ae74a6221">00122</a> <a class="code" href="stun_8cc.html#a739d3cc61a2a1609b96d535ae74a6221">stunParseAtrUnknown</a>( <span class="keywordtype">char</span>* body, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hdrLen, <a class="code" href="structStunAtrUnknown.html">StunAtrUnknown</a>&amp; result )
  164. <a name="l00123"></a>00123 {
  165. <a name="l00124"></a>00124 <span class="keywordflow">if</span> ( hdrLen &gt;= <span class="keyword">sizeof</span>(result) )
  166. <a name="l00125"></a>00125 {
  167. <a name="l00126"></a>00126 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  168. <a name="l00127"></a>00127 }
  169. <a name="l00128"></a>00128 <span class="keywordflow">else</span>
  170. <a name="l00129"></a>00129 {
  171. <a name="l00130"></a>00130 <span class="keywordflow">if</span> (hdrLen % 4 != 0) <span class="keywordflow">return</span> <span class="keyword">false</span>;
  172. <a name="l00131"></a>00131 result.<a class="code" href="structStunAtrUnknown.html#a39f2cca60b76d9476cd2a61a349e72d6">numAttributes</a> = hdrLen / 4;
  173. <a name="l00132"></a>00132 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;result.<a class="code" href="structStunAtrUnknown.html#a39f2cca60b76d9476cd2a61a349e72d6">numAttributes</a>; i++)
  174. <a name="l00133"></a>00133 {
  175. <a name="l00134"></a>00134 memcpy(&amp;result.<a class="code" href="structStunAtrUnknown.html#a2a9ac6afb38e1f951bc7cb8ec0b2a888">attrType</a>[i], body, 2); body+=2;
  176. <a name="l00135"></a>00135 result.<a class="code" href="structStunAtrUnknown.html#a2a9ac6afb38e1f951bc7cb8ec0b2a888">attrType</a>[i] = ntohs(result.<a class="code" href="structStunAtrUnknown.html#a2a9ac6afb38e1f951bc7cb8ec0b2a888">attrType</a>[i]);
  177. <a name="l00136"></a>00136 }
  178. <a name="l00137"></a>00137 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  179. <a name="l00138"></a>00138 }
  180. <a name="l00139"></a>00139 }
  181. <a name="l00140"></a>00140
  182. <a name="l00141"></a>00141
  183. <a name="l00142"></a>00142 <span class="keyword">static</span> <span class="keywordtype">bool</span>
  184. <a name="l00143"></a><a class="code" href="stun_8cc.html#a2c161a60854ecb6fe959dff3fe422310">00143</a> <a class="code" href="stun_8cc.html#a2c161a60854ecb6fe959dff3fe422310">stunParseAtrString</a>( <span class="keywordtype">char</span>* body, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hdrLen, <a class="code" href="structStunAtrString.html">StunAtrString</a>&amp; result )
  185. <a name="l00144"></a>00144 {
  186. <a name="l00145"></a>00145 <span class="keywordflow">if</span> ( hdrLen &gt;= <a class="code" href="stun_8h.html#ac4d86797b42c1696b7acbd715481c0b1">STUN_MAX_STRING</a> )
  187. <a name="l00146"></a>00146 {
  188. <a name="l00147"></a>00147 clog &lt;&lt; <span class="stringliteral">&quot;String is too large&quot;</span> &lt;&lt; endl;
  189. <a name="l00148"></a>00148 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  190. <a name="l00149"></a>00149 }
  191. <a name="l00150"></a>00150 <span class="keywordflow">else</span>
  192. <a name="l00151"></a>00151 {
  193. <a name="l00152"></a>00152 <span class="keywordflow">if</span> (hdrLen % 4 != 0)
  194. <a name="l00153"></a>00153 {
  195. <a name="l00154"></a>00154 clog &lt;&lt; <span class="stringliteral">&quot;Bad length string &quot;</span> &lt;&lt; hdrLen &lt;&lt; endl;
  196. <a name="l00155"></a>00155 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  197. <a name="l00156"></a>00156 }
  198. <a name="l00157"></a>00157
  199. <a name="l00158"></a>00158 result.<a class="code" href="structStunAtrString.html#aa1e288247a4ae07b170ecf956bdd48c9">sizeValue</a> = hdrLen;
  200. <a name="l00159"></a>00159 memcpy(&amp;result.<a class="code" href="structStunAtrString.html#a609965b0f07f831423bda6aaa1b852dc">value</a>, body, hdrLen);
  201. <a name="l00160"></a>00160 result.<a class="code" href="structStunAtrString.html#a609965b0f07f831423bda6aaa1b852dc">value</a>[hdrLen] = 0;
  202. <a name="l00161"></a>00161 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  203. <a name="l00162"></a>00162 }
  204. <a name="l00163"></a>00163 }
  205. <a name="l00164"></a>00164
  206. <a name="l00165"></a>00165
  207. <a name="l00166"></a>00166 <span class="keyword">static</span> <span class="keywordtype">bool</span>
  208. <a name="l00167"></a><a class="code" href="stun_8cc.html#a4e7e4c29e1424831e001c9ffa9b74b53">00167</a> <a class="code" href="stun_8cc.html#a4e7e4c29e1424831e001c9ffa9b74b53">stunParseAtrIntegrity</a>( <span class="keywordtype">char</span>* body, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hdrLen, <a class="code" href="structStunAtrIntegrity.html">StunAtrIntegrity</a>&amp; result )
  209. <a name="l00168"></a>00168 {
  210. <a name="l00169"></a>00169 <span class="keywordflow">if</span> ( hdrLen != 20)
  211. <a name="l00170"></a>00170 {
  212. <a name="l00171"></a>00171 clog &lt;&lt; <span class="stringliteral">&quot;MessageIntegrity must be 20 bytes&quot;</span> &lt;&lt; endl;
  213. <a name="l00172"></a>00172 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  214. <a name="l00173"></a>00173 }
  215. <a name="l00174"></a>00174 <span class="keywordflow">else</span>
  216. <a name="l00175"></a>00175 {
  217. <a name="l00176"></a>00176 memcpy(&amp;result.<a class="code" href="structStunAtrIntegrity.html#a584fa6b758583be87dfad5c10da9fd44">hash</a>, body, hdrLen);
  218. <a name="l00177"></a>00177 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  219. <a name="l00178"></a>00178 }
  220. <a name="l00179"></a>00179 }
  221. <a name="l00180"></a>00180
  222. <a name="l00181"></a>00181
  223. <a name="l00182"></a>00182 <span class="keywordtype">bool</span>
  224. <a name="l00183"></a><a class="code" href="stun_8h.html#a44a8d7b644cb0faa4107db47b2e06471">00183</a> <a class="code" href="stun_8cc.html#af81c30137f26a4cb158b48aa21f4f681">stunParseMessage</a>( <span class="keywordtype">char</span>* buf, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bufLen, <a class="code" href="structStunMessage.html">StunMessage</a>&amp; msg, <span class="keywordtype">bool</span> verbose)
  225. <a name="l00184"></a>00184 {
  226. <a name="l00185"></a>00185 <span class="keywordflow">if</span> (verbose) clog &lt;&lt; <span class="stringliteral">&quot;Received stun message: &quot;</span> &lt;&lt; bufLen &lt;&lt; <span class="stringliteral">&quot; bytes&quot;</span> &lt;&lt; endl;
  227. <a name="l00186"></a>00186 memset(&amp;msg, 0, <span class="keyword">sizeof</span>(msg));
  228. <a name="l00187"></a>00187
  229. <a name="l00188"></a>00188 <span class="keywordflow">if</span> (<span class="keyword">sizeof</span>(<a class="code" href="structStunMsgHdr.html">StunMsgHdr</a>) &gt; bufLen)
  230. <a name="l00189"></a>00189 {
  231. <a name="l00190"></a>00190 clog &lt;&lt; <span class="stringliteral">&quot;Bad message&quot;</span> &lt;&lt; endl;
  232. <a name="l00191"></a>00191 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  233. <a name="l00192"></a>00192 }
  234. <a name="l00193"></a>00193
  235. <a name="l00194"></a>00194 memcpy(&amp;msg.<a class="code" href="structStunMessage.html#a4928bac8dd595927e7ebab4610f316f6">msgHdr</a>, buf, <span class="keyword">sizeof</span>(<a class="code" href="structStunMsgHdr.html">StunMsgHdr</a>));
  236. <a name="l00195"></a>00195 msg.<a class="code" href="structStunMessage.html#a4928bac8dd595927e7ebab4610f316f6">msgHdr</a>.<a class="code" href="structStunMsgHdr.html#a7cc96e6cbb87582e56f298eb891c43e2">msgType</a> = ntohs(msg.<a class="code" href="structStunMessage.html#a4928bac8dd595927e7ebab4610f316f6">msgHdr</a>.<a class="code" href="structStunMsgHdr.html#a7cc96e6cbb87582e56f298eb891c43e2">msgType</a>);
  237. <a name="l00196"></a>00196 msg.<a class="code" href="structStunMessage.html#a4928bac8dd595927e7ebab4610f316f6">msgHdr</a>.<a class="code" href="structStunMsgHdr.html#a619e2158af7fd1b3de12b88899a7c5dd">msgLength</a> = ntohs(msg.<a class="code" href="structStunMessage.html#a4928bac8dd595927e7ebab4610f316f6">msgHdr</a>.<a class="code" href="structStunMsgHdr.html#a619e2158af7fd1b3de12b88899a7c5dd">msgLength</a>);
  238. <a name="l00197"></a>00197
  239. <a name="l00198"></a>00198 <span class="keywordflow">if</span> (msg.<a class="code" href="structStunMessage.html#a4928bac8dd595927e7ebab4610f316f6">msgHdr</a>.<a class="code" href="structStunMsgHdr.html#a619e2158af7fd1b3de12b88899a7c5dd">msgLength</a> + <span class="keyword">sizeof</span>(<a class="code" href="structStunMsgHdr.html">StunMsgHdr</a>) != bufLen)
  240. <a name="l00199"></a>00199 {
  241. <a name="l00200"></a>00200 clog &lt;&lt; <span class="stringliteral">&quot;Message header length doesn&#39;t match message size: &quot;</span>
  242. <a name="l00201"></a>00201 &lt;&lt; msg.<a class="code" href="structStunMessage.html#a4928bac8dd595927e7ebab4610f316f6">msgHdr</a>.<a class="code" href="structStunMsgHdr.html#a619e2158af7fd1b3de12b88899a7c5dd">msgLength</a> &lt;&lt; <span class="stringliteral">&quot; - &quot;</span> &lt;&lt; bufLen &lt;&lt; endl;
  243. <a name="l00202"></a>00202 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  244. <a name="l00203"></a>00203 }
  245. <a name="l00204"></a>00204
  246. <a name="l00205"></a>00205 <span class="keywordtype">char</span>* body = buf + <span class="keyword">sizeof</span>(<a class="code" href="structStunMsgHdr.html">StunMsgHdr</a>);
  247. <a name="l00206"></a>00206 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size = msg.<a class="code" href="structStunMessage.html#a4928bac8dd595927e7ebab4610f316f6">msgHdr</a>.<a class="code" href="structStunMsgHdr.html#a619e2158af7fd1b3de12b88899a7c5dd">msgLength</a>;
  248. <a name="l00207"></a>00207
  249. <a name="l00208"></a>00208 <span class="comment">//clog &lt;&lt; &quot;bytes after header = &quot; &lt;&lt; size &lt;&lt; endl;</span>
  250. <a name="l00209"></a>00209
  251. <a name="l00210"></a>00210 <span class="keywordflow">while</span> ( size &gt; 0 )
  252. <a name="l00211"></a>00211 {
  253. <a name="l00212"></a>00212 <span class="comment">// !jf! should check that there are enough bytes left in the buffer</span>
  254. <a name="l00213"></a>00213
  255. <a name="l00214"></a>00214 <a class="code" href="structStunAtrHdr.html">StunAtrHdr</a>* attr = <span class="keyword">reinterpret_cast&lt;</span><a class="code" href="structStunAtrHdr.html">StunAtrHdr</a>*<span class="keyword">&gt;</span>(body);
  256. <a name="l00215"></a>00215
  257. <a name="l00216"></a>00216 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> attrLen = ntohs(attr-&gt;<a class="code" href="structStunAtrHdr.html#a979c6bd5a4c93128cc316bef605191f5">length</a>);
  258. <a name="l00217"></a>00217 <span class="keywordtype">int</span> atrType = ntohs(attr-&gt;<a class="code" href="structStunAtrHdr.html#a303835ac7916984e097587ad499b568e">type</a>);
  259. <a name="l00218"></a>00218
  260. <a name="l00219"></a>00219 <span class="comment">//if (verbose) clog &lt;&lt; &quot;Found attribute type=&quot; &lt;&lt; AttrNames[atrType] &lt;&lt; &quot; length=&quot; &lt;&lt; attrLen &lt;&lt; endl;</span>
  261. <a name="l00220"></a>00220 <span class="keywordflow">if</span> ( attrLen+4 &gt; size )
  262. <a name="l00221"></a>00221 {
  263. <a name="l00222"></a>00222 clog &lt;&lt; <span class="stringliteral">&quot;claims attribute is larger than size of message &quot;</span>
  264. <a name="l00223"></a>00223 &lt;&lt;<span class="stringliteral">&quot;(attribute type=&quot;</span>&lt;&lt;atrType&lt;&lt;<span class="stringliteral">&quot;)&quot;</span>&lt;&lt; endl;
  265. <a name="l00224"></a>00224 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  266. <a name="l00225"></a>00225 }
  267. <a name="l00226"></a>00226
  268. <a name="l00227"></a>00227 body += 4; <span class="comment">// skip the length and type in attribute header</span>
  269. <a name="l00228"></a>00228 size -= 4;
  270. <a name="l00229"></a>00229
  271. <a name="l00230"></a>00230 <span class="keywordflow">switch</span> ( atrType )
  272. <a name="l00231"></a>00231 {
  273. <a name="l00232"></a>00232 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a2479ede510923cc5e8a0c2da5558acc3">MappedAddress</a>:
  274. <a name="l00233"></a>00233 msg.<a class="code" href="structStunMessage.html#a605889708c9696c60f1284b3c486ca18">hasMappedAddress</a> = <span class="keyword">true</span>;
  275. <a name="l00234"></a>00234 <span class="keywordflow">if</span> ( <a class="code" href="stun_8cc.html#a16624b9ba3d6b2f1c821571fa467c544">stunParseAtrAddress</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#a7c354e1ca2aae9d180c98e6b12ba879c">mappedAddress</a> )== <span class="keyword">false</span> )
  276. <a name="l00235"></a>00235 {
  277. <a name="l00236"></a>00236 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing MappedAddress&quot;</span> &lt;&lt; endl;
  278. <a name="l00237"></a>00237 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  279. <a name="l00238"></a>00238 }
  280. <a name="l00239"></a>00239 <span class="keywordflow">else</span>
  281. <a name="l00240"></a>00240 {
  282. <a name="l00241"></a>00241 <span class="keywordflow">if</span> (verbose) clog &lt;&lt; <span class="stringliteral">&quot;MappedAddress = &quot;</span> &lt;&lt; msg.<a class="code" href="structStunMessage.html#a7c354e1ca2aae9d180c98e6b12ba879c">mappedAddress</a>.<a class="code" href="structStunAtrAddress4.html#a80b81fdc81e96531c1fecd5b9b5125c4">ipv4</a> &lt;&lt; endl;
  283. <a name="l00242"></a>00242 }
  284. <a name="l00243"></a>00243
  285. <a name="l00244"></a>00244 <span class="keywordflow">break</span>;
  286. <a name="l00245"></a>00245
  287. <a name="l00246"></a>00246 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a91ab7c5c3d71a86a77679d0d2786fae8">ResponseAddress</a>:
  288. <a name="l00247"></a>00247 msg.<a class="code" href="structStunMessage.html#ab7926e7d5ceb2d9c3337439ec89ec87d">hasResponseAddress</a> = <span class="keyword">true</span>;
  289. <a name="l00248"></a>00248 <span class="keywordflow">if</span> ( <a class="code" href="stun_8cc.html#a16624b9ba3d6b2f1c821571fa467c544">stunParseAtrAddress</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#adb06537683f153438687995e8d1783c6">responseAddress</a> )== <span class="keyword">false</span> )
  290. <a name="l00249"></a>00249 {
  291. <a name="l00250"></a>00250 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing ResponseAddress&quot;</span> &lt;&lt; endl;
  292. <a name="l00251"></a>00251 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  293. <a name="l00252"></a>00252 }
  294. <a name="l00253"></a>00253 <span class="keywordflow">else</span>
  295. <a name="l00254"></a>00254 {
  296. <a name="l00255"></a>00255 <span class="keywordflow">if</span> (verbose) clog &lt;&lt; <span class="stringliteral">&quot;ResponseAddress = &quot;</span> &lt;&lt; msg.<a class="code" href="structStunMessage.html#adb06537683f153438687995e8d1783c6">responseAddress</a>.<a class="code" href="structStunAtrAddress4.html#a80b81fdc81e96531c1fecd5b9b5125c4">ipv4</a> &lt;&lt; endl;
  297. <a name="l00256"></a>00256 }
  298. <a name="l00257"></a>00257 <span class="keywordflow">break</span>;
  299. <a name="l00258"></a>00258
  300. <a name="l00259"></a>00259 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a6183c3f6e20ddc5bf9acd531d37c4b08">ChangeRequest</a>:
  301. <a name="l00260"></a>00260 msg.<a class="code" href="structStunMessage.html#a0fe2488f060fe65507c9a58bbb66899f">hasChangeRequest</a> = <span class="keyword">true</span>;
  302. <a name="l00261"></a>00261 <span class="keywordflow">if</span> (<a class="code" href="stun_8cc.html#af2f9f10bd394cb42037f1997266b978a">stunParseAtrChangeRequest</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#a65e5de40376764ea12d96f5b5ebe2c29">changeRequest</a>) == <span class="keyword">false</span>)
  303. <a name="l00262"></a>00262 {
  304. <a name="l00263"></a>00263 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing ChangeRequest&quot;</span> &lt;&lt; endl;
  305. <a name="l00264"></a>00264 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  306. <a name="l00265"></a>00265 }
  307. <a name="l00266"></a>00266 <span class="keywordflow">else</span>
  308. <a name="l00267"></a>00267 {
  309. <a name="l00268"></a>00268 <span class="keywordflow">if</span> (verbose) clog &lt;&lt; <span class="stringliteral">&quot;ChangeRequest = &quot;</span> &lt;&lt; msg.<a class="code" href="structStunMessage.html#a65e5de40376764ea12d96f5b5ebe2c29">changeRequest</a>.<a class="code" href="structStunAtrChangeRequest.html#adbb006a8e7cc0637d01959c8ba985c0c">value</a> &lt;&lt; endl;
  310. <a name="l00269"></a>00269 }
  311. <a name="l00270"></a>00270 <span class="keywordflow">break</span>;
  312. <a name="l00271"></a>00271
  313. <a name="l00272"></a>00272 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#ab2b81c4c09625b39c5a1d57ee2b460a4">SourceAddress</a>:
  314. <a name="l00273"></a>00273 msg.<a class="code" href="structStunMessage.html#a5feb7431931118218d78642c4a7c83db">hasSourceAddress</a> = <span class="keyword">true</span>;
  315. <a name="l00274"></a>00274 <span class="keywordflow">if</span> ( <a class="code" href="stun_8cc.html#a16624b9ba3d6b2f1c821571fa467c544">stunParseAtrAddress</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#ab7203fc2e5a8b1248c9e14ce6e6ec313">sourceAddress</a> )== <span class="keyword">false</span> )
  316. <a name="l00275"></a>00275 {
  317. <a name="l00276"></a>00276 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing SourceAddress&quot;</span> &lt;&lt; endl;
  318. <a name="l00277"></a>00277 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  319. <a name="l00278"></a>00278 }
  320. <a name="l00279"></a>00279 <span class="keywordflow">else</span>
  321. <a name="l00280"></a>00280 {
  322. <a name="l00281"></a>00281 <span class="keywordflow">if</span> (verbose) clog &lt;&lt; <span class="stringliteral">&quot;SourceAddress = &quot;</span> &lt;&lt; msg.<a class="code" href="structStunMessage.html#ab7203fc2e5a8b1248c9e14ce6e6ec313">sourceAddress</a>.<a class="code" href="structStunAtrAddress4.html#a80b81fdc81e96531c1fecd5b9b5125c4">ipv4</a> &lt;&lt; endl;
  323. <a name="l00282"></a>00282 }
  324. <a name="l00283"></a>00283 <span class="keywordflow">break</span>;
  325. <a name="l00284"></a>00284
  326. <a name="l00285"></a>00285 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a930a1eeda1f0620132bfdea315e711f7">ChangedAddress</a>:
  327. <a name="l00286"></a>00286 msg.<a class="code" href="structStunMessage.html#a4d3036e012cce04e6be670898f4e24eb">hasChangedAddress</a> = <span class="keyword">true</span>;
  328. <a name="l00287"></a>00287 <span class="keywordflow">if</span> ( <a class="code" href="stun_8cc.html#a16624b9ba3d6b2f1c821571fa467c544">stunParseAtrAddress</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#ac240bd9424c010b74411679f1813a705">changedAddress</a> )== <span class="keyword">false</span> )
  329. <a name="l00288"></a>00288 {
  330. <a name="l00289"></a>00289 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing ChangedAddress&quot;</span> &lt;&lt; endl;
  331. <a name="l00290"></a>00290 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  332. <a name="l00291"></a>00291 }
  333. <a name="l00292"></a>00292 <span class="keywordflow">else</span>
  334. <a name="l00293"></a>00293 {
  335. <a name="l00294"></a>00294 <span class="keywordflow">if</span> (verbose) clog &lt;&lt; <span class="stringliteral">&quot;ChangedAddress = &quot;</span> &lt;&lt; msg.<a class="code" href="structStunMessage.html#ac240bd9424c010b74411679f1813a705">changedAddress</a>.<a class="code" href="structStunAtrAddress4.html#a80b81fdc81e96531c1fecd5b9b5125c4">ipv4</a> &lt;&lt; endl;
  336. <a name="l00295"></a>00295 }
  337. <a name="l00296"></a>00296 <span class="keywordflow">break</span>;
  338. <a name="l00297"></a>00297
  339. <a name="l00298"></a>00298 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a0845232ed07b469d1262348e1618b962">Username</a>:
  340. <a name="l00299"></a>00299 msg.<a class="code" href="structStunMessage.html#a2a22a4f1560b25fcf5247647885bab3c">hasUsername</a> = <span class="keyword">true</span>;
  341. <a name="l00300"></a>00300 <span class="keywordflow">if</span> (<a class="code" href="stun_8cc.html#a2c161a60854ecb6fe959dff3fe422310">stunParseAtrString</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#ab5c364c8f9339a6d4f314ce3819ed1fd">username</a>) == <span class="keyword">false</span>)
  342. <a name="l00301"></a>00301 {
  343. <a name="l00302"></a>00302 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing Username&quot;</span> &lt;&lt; endl;
  344. <a name="l00303"></a>00303 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  345. <a name="l00304"></a>00304 }
  346. <a name="l00305"></a>00305 <span class="keywordflow">else</span>
  347. <a name="l00306"></a>00306 {
  348. <a name="l00307"></a>00307 <span class="keywordflow">if</span> (verbose) clog &lt;&lt; <span class="stringliteral">&quot;Username = &quot;</span> &lt;&lt; msg.<a class="code" href="structStunMessage.html#ab5c364c8f9339a6d4f314ce3819ed1fd">username</a>.<a class="code" href="structStunAtrString.html#a609965b0f07f831423bda6aaa1b852dc">value</a> &lt;&lt; endl;
  349. <a name="l00308"></a>00308 }
  350. <a name="l00309"></a>00309
  351. <a name="l00310"></a>00310 <span class="keywordflow">break</span>;
  352. <a name="l00311"></a>00311
  353. <a name="l00312"></a>00312 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a1741d36983135a1f2eefa1b1473956a2">Password</a>:
  354. <a name="l00313"></a>00313 msg.<a class="code" href="structStunMessage.html#ac09b6e5f081db9f5ec2c1a4532676366">hasPassword</a> = <span class="keyword">true</span>;
  355. <a name="l00314"></a>00314 <span class="keywordflow">if</span> (<a class="code" href="stun_8cc.html#a2c161a60854ecb6fe959dff3fe422310">stunParseAtrString</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#aa15cab0d5b2a9a044895e81d527c1b68">password</a>) == <span class="keyword">false</span>)
  356. <a name="l00315"></a>00315 {
  357. <a name="l00316"></a>00316 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing Password&quot;</span> &lt;&lt; endl;
  358. <a name="l00317"></a>00317 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  359. <a name="l00318"></a>00318 }
  360. <a name="l00319"></a>00319 <span class="keywordflow">else</span>
  361. <a name="l00320"></a>00320 {
  362. <a name="l00321"></a>00321 <span class="keywordflow">if</span> (verbose) clog &lt;&lt; <span class="stringliteral">&quot;Password = &quot;</span> &lt;&lt; msg.<a class="code" href="structStunMessage.html#aa15cab0d5b2a9a044895e81d527c1b68">password</a>.<a class="code" href="structStunAtrString.html#a609965b0f07f831423bda6aaa1b852dc">value</a> &lt;&lt; endl;
  363. <a name="l00322"></a>00322 }
  364. <a name="l00323"></a>00323 <span class="keywordflow">break</span>;
  365. <a name="l00324"></a>00324
  366. <a name="l00325"></a>00325 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a0371caac677f72f19ea073dd152197f0">MessageIntegrity</a>:
  367. <a name="l00326"></a>00326 msg.<a class="code" href="structStunMessage.html#a2a47413181e29d0de7063d4bfa6609ff">hasMessageIntegrity</a> = <span class="keyword">true</span>;
  368. <a name="l00327"></a>00327 <span class="keywordflow">if</span> (<a class="code" href="stun_8cc.html#a4e7e4c29e1424831e001c9ffa9b74b53">stunParseAtrIntegrity</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#a1b2c965443dc78688973c049713072d0">messageIntegrity</a>) == <span class="keyword">false</span>)
  369. <a name="l00328"></a>00328 {
  370. <a name="l00329"></a>00329 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing MessageIntegrity&quot;</span> &lt;&lt; endl;
  371. <a name="l00330"></a>00330 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  372. <a name="l00331"></a>00331 }
  373. <a name="l00332"></a>00332 <span class="keywordflow">else</span>
  374. <a name="l00333"></a>00333 {
  375. <a name="l00334"></a>00334 <span class="comment">//if (verbose) clog &lt;&lt; &quot;MessageIntegrity = &quot; &lt;&lt; msg.messageIntegrity.hash &lt;&lt; endl;</span>
  376. <a name="l00335"></a>00335 }
  377. <a name="l00336"></a>00336
  378. <a name="l00337"></a>00337 <span class="comment">// read the current HMAC</span>
  379. <a name="l00338"></a>00338 <span class="comment">// look up the password given the user of given the transaction id</span>
  380. <a name="l00339"></a>00339 <span class="comment">// compute the HMAC on the buffer</span>
  381. <a name="l00340"></a>00340 <span class="comment">// decide if they match or not</span>
  382. <a name="l00341"></a>00341 <span class="keywordflow">break</span>;
  383. <a name="l00342"></a>00342
  384. <a name="l00343"></a>00343 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a750ec1534b2aebc05c90b9e6fe9532c7">ErrorCode</a>:
  385. <a name="l00344"></a>00344 msg.<a class="code" href="structStunMessage.html#afe66349979726d392fa4f0c9c84ebedf">hasErrorCode</a> = <span class="keyword">true</span>;
  386. <a name="l00345"></a>00345 <span class="keywordflow">if</span> (<a class="code" href="stun_8cc.html#afdf35a5dc5c3d6b7109c290308e32887">stunParseAtrError</a>(body, attrLen, msg.<a class="code" href="structStunMessage.html#a8e6a7183381efea4e4a92e2b4e8bba6a">errorCode</a>) == <span class="keyword">false</span>)
  387. <a name="l00346"></a>00346 {
  388. <a name="l00347"></a>00347 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing ErrorCode&quot;</span> &lt;&lt; endl;
  389. <a name="l00348"></a>00348 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  390. <a name="l00349"></a>00349 }
  391. <a name="l00350"></a>00350 <span class="keywordflow">else</span>
  392. <a name="l00351"></a>00351 {
  393. <a name="l00352"></a>00352 <span class="keywordflow">if</span> (verbose) clog &lt;&lt; <span class="stringliteral">&quot;ErrorCode = &quot;</span> &lt;&lt; int(msg.<a class="code" href="structStunMessage.html#a8e6a7183381efea4e4a92e2b4e8bba6a">errorCode</a>.<a class="code" href="structStunAtrError.html#aef65890aa74d342d326ea74000064be5">errorClass</a>)
  394. <a name="l00353"></a>00353 &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; int(msg.<a class="code" href="structStunMessage.html#a8e6a7183381efea4e4a92e2b4e8bba6a">errorCode</a>.<a class="code" href="structStunAtrError.html#abdee224c138f23ad06aeb97ed9d6e0fe">number</a>)
  395. <a name="l00354"></a>00354 &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; msg.<a class="code" href="structStunMessage.html#a8e6a7183381efea4e4a92e2b4e8bba6a">errorCode</a>.<a class="code" href="structStunAtrError.html#a3bb11d3802d0bfe65a153d8a6bccd472">reason</a> &lt;&lt; endl;
  396. <a name="l00355"></a>00355 }
  397. <a name="l00356"></a>00356
  398. <a name="l00357"></a>00357 <span class="keywordflow">break</span>;
  399. <a name="l00358"></a>00358
  400. <a name="l00359"></a>00359 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#ac5d0f4ecd6bc741747a3ff79b6e5a96c">UnknownAttribute</a>:
  401. <a name="l00360"></a>00360 msg.<a class="code" href="structStunMessage.html#a29507d464e9900ced2ce92c75bb158a4">hasUnknownAttributes</a> = <span class="keyword">true</span>;
  402. <a name="l00361"></a>00361 <span class="keywordflow">if</span> (<a class="code" href="stun_8cc.html#a739d3cc61a2a1609b96d535ae74a6221">stunParseAtrUnknown</a>(body, attrLen, msg.<a class="code" href="structStunMessage.html#a40311e31449afb24c3e40db8c8fc6911">unknownAttributes</a>) == <span class="keyword">false</span>)
  403. <a name="l00362"></a>00362 {
  404. <a name="l00363"></a>00363 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing UnknownAttribute&quot;</span> &lt;&lt; endl;
  405. <a name="l00364"></a>00364 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  406. <a name="l00365"></a>00365 }
  407. <a name="l00366"></a>00366 <span class="keywordflow">break</span>;
  408. <a name="l00367"></a>00367
  409. <a name="l00368"></a>00368 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a11d1c4b717d340b20582ac7dead1cd49">ReflectedFrom</a>:
  410. <a name="l00369"></a>00369 msg.<a class="code" href="structStunMessage.html#ab88124a21ca8562a44a696ed4b39fa4f">hasReflectedFrom</a> = <span class="keyword">true</span>;
  411. <a name="l00370"></a>00370 <span class="keywordflow">if</span> ( <a class="code" href="stun_8cc.html#a16624b9ba3d6b2f1c821571fa467c544">stunParseAtrAddress</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#ab80a59189b1b938698339f788417f32b">reflectedFrom</a> ) == <span class="keyword">false</span> )
  412. <a name="l00371"></a>00371 {
  413. <a name="l00372"></a>00372 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing ReflectedFrom&quot;</span> &lt;&lt; endl;
  414. <a name="l00373"></a>00373 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  415. <a name="l00374"></a>00374 }
  416. <a name="l00375"></a>00375 <span class="keywordflow">break</span>;
  417. <a name="l00376"></a>00376
  418. <a name="l00377"></a>00377 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#afd742381f8d8131e21dac399b8a26c3a">XorMappedAddress</a>:
  419. <a name="l00378"></a>00378 msg.<a class="code" href="structStunMessage.html#a8e149870681eebee0a55b0f630c89471">hasXorMappedAddress</a> = <span class="keyword">true</span>;
  420. <a name="l00379"></a>00379 <span class="keywordflow">if</span> ( <a class="code" href="stun_8cc.html#a16624b9ba3d6b2f1c821571fa467c544">stunParseAtrAddress</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#a2ef5db0ff5bd395800262b8b9d49b6bb">xorMappedAddress</a> ) == <span class="keyword">false</span> )
  421. <a name="l00380"></a>00380 {
  422. <a name="l00381"></a>00381 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing XorMappedAddress&quot;</span> &lt;&lt; endl;
  423. <a name="l00382"></a>00382 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  424. <a name="l00383"></a>00383 }
  425. <a name="l00384"></a>00384 <span class="keywordflow">else</span>
  426. <a name="l00385"></a>00385 {
  427. <a name="l00386"></a>00386 <span class="keywordflow">if</span> (verbose) clog &lt;&lt; <span class="stringliteral">&quot;XorMappedAddress = &quot;</span> &lt;&lt; msg.<a class="code" href="structStunMessage.html#a7c354e1ca2aae9d180c98e6b12ba879c">mappedAddress</a>.<a class="code" href="structStunAtrAddress4.html#a80b81fdc81e96531c1fecd5b9b5125c4">ipv4</a> &lt;&lt; endl;
  428. <a name="l00387"></a>00387 }
  429. <a name="l00388"></a>00388 <span class="keywordflow">break</span>;
  430. <a name="l00389"></a>00389
  431. <a name="l00390"></a>00390 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a615f23f67cf9c716c91fa445e272da3c">XorOnly</a>:
  432. <a name="l00391"></a>00391 msg.<a class="code" href="structStunMessage.html#ad2d3b64955956272841f656fe354aa18">xorOnly</a> = <span class="keyword">true</span>;
  433. <a name="l00392"></a>00392 <span class="keywordflow">if</span> (verbose)
  434. <a name="l00393"></a>00393 {
  435. <a name="l00394"></a>00394 clog &lt;&lt; <span class="stringliteral">&quot;xorOnly = true&quot;</span> &lt;&lt; endl;
  436. <a name="l00395"></a>00395 }
  437. <a name="l00396"></a>00396 <span class="keywordflow">break</span>;
  438. <a name="l00397"></a>00397
  439. <a name="l00398"></a>00398 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a53f47b517798fa3e1b64313d04168ea2">ServerName</a>:
  440. <a name="l00399"></a>00399 msg.<a class="code" href="structStunMessage.html#afcf544b5b0663edad215525b8bcd67df">hasServerName</a> = <span class="keyword">true</span>;
  441. <a name="l00400"></a>00400 <span class="keywordflow">if</span> (<a class="code" href="stun_8cc.html#a2c161a60854ecb6fe959dff3fe422310">stunParseAtrString</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#a1998c160a79020e146957c14ae1add11">serverName</a>) == <span class="keyword">false</span>)
  442. <a name="l00401"></a>00401 {
  443. <a name="l00402"></a>00402 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing ServerName&quot;</span> &lt;&lt; endl;
  444. <a name="l00403"></a>00403 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  445. <a name="l00404"></a>00404 }
  446. <a name="l00405"></a>00405 <span class="keywordflow">else</span>
  447. <a name="l00406"></a>00406 {
  448. <a name="l00407"></a>00407 <span class="keywordflow">if</span> (verbose) clog &lt;&lt; <span class="stringliteral">&quot;ServerName = &quot;</span> &lt;&lt; msg.<a class="code" href="structStunMessage.html#a1998c160a79020e146957c14ae1add11">serverName</a>.<a class="code" href="structStunAtrString.html#a609965b0f07f831423bda6aaa1b852dc">value</a> &lt;&lt; endl;
  449. <a name="l00408"></a>00408 }
  450. <a name="l00409"></a>00409 <span class="keywordflow">break</span>;
  451. <a name="l00410"></a>00410
  452. <a name="l00411"></a>00411 <span class="keywordflow">case</span> <a class="code" href="stun_8h.html#a4d77a59e0dc2c3c06deb3730baa78f80">SecondaryAddress</a>:
  453. <a name="l00412"></a>00412 msg.<a class="code" href="structStunMessage.html#ace894f36510487ec8151609513974eba">hasSecondaryAddress</a> = <span class="keyword">true</span>;
  454. <a name="l00413"></a>00413 <span class="keywordflow">if</span> ( <a class="code" href="stun_8cc.html#a16624b9ba3d6b2f1c821571fa467c544">stunParseAtrAddress</a>( body, attrLen, msg.<a class="code" href="structStunMessage.html#a8fc16bd394228aa6fa6e1f5f98c356c1">secondaryAddress</a> ) == <span class="keyword">false</span> )
  455. <a name="l00414"></a>00414 {
  456. <a name="l00415"></a>00415 clog &lt;&lt; <span class="stringliteral">&quot;problem parsing secondaryAddress&quot;</span> &lt;&lt; endl;
  457. <a name="l00416"></a>00416 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  458. <a name="l00417"></a>00417 }
  459. <a name="l00418"></a>00418 <span class="keywordflow">else</span>
  460. <a name="l00419"></a>00419 {
  461. <a name="l00420"></a>00

Large files files are truncated, but you can click here to view the full file