⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cradiuspacket_8h-source.html

📁 采用 ACE 开发的 radius 应用
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>ace-radius: RADIUS/CRadiusPacket.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.7-20040704 --><div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a></div><h1>RADIUS/CRadiusPacket.h</h1><pre class="fragment"><div>00001 <span class="comment">/*</span>00002 <span class="comment"> * This source file is part of the ace-radius library.  This code was</span>00003 <span class="comment"> * written by Alex Agranov in 2004, and is covered by the BSD open source</span>00004 <span class="comment"> * license. Refer to the accompanying documentation for details on usage and</span>00005 <span class="comment"> * license.</span>00006 <span class="comment"> */</span>00007 00008 <span class="preprocessor">#ifndef _CRADIUSPACKET_H__</span>00009 <span class="preprocessor"></span><span class="preprocessor">#define _CRADIUSPACKET_H__</span>00010 <span class="preprocessor"></span>00011 <span class="preprocessor">#include "Global.h"</span>00012 <span class="preprocessor">#include "CRadiusAttribute.h"</span>00013 <span class="preprocessor">#include "CTimer.h"</span>00014 00015 00016 <span class="comment">// Radius packet code values (from RFC2865)</span>00017 <span class="preprocessor">#define D_PACKET_ACCESS_REQUEST         1</span>00018 <span class="preprocessor"></span><span class="preprocessor">#define D_PACKET_ACCESS_ACCEPT          2</span>00019 <span class="preprocessor"></span><span class="preprocessor">#define D_PACKET_ACCESS_REJECT          3</span>00020 <span class="preprocessor"></span><span class="preprocessor">#define D_PACKET_ACCOUNTING_REQUEST     4</span>00021 <span class="preprocessor"></span><span class="preprocessor">#define D_PACKET_ACCOUNTING_RESPONSE    5</span>00022 <span class="preprocessor"></span><span class="preprocessor">#define D_PACKET_ACCESS_CHALLENGE       11</span>00023 <span class="preprocessor"></span><span class="preprocessor">#define D_PACKET_STATUS_SERVER          12</span>00024 <span class="preprocessor"></span><span class="preprocessor">#define D_PACKET_STATUS_CLIENT          13</span>00025 <span class="preprocessor"></span>00026 <span class="preprocessor">#define D_PACKET_MAX_KNOWN_CODE         13</span>00027 <span class="preprocessor"></span>00028 00029 00030 <span class="comment">// Some global constants (following RFC definitions)</span>00031 <span class="preprocessor">#define D_RADIUS_PACKET_HEADER_LENGTH 20</span>00032 <span class="preprocessor"></span><span class="preprocessor">#define D_RADIUS_PACKET_MAX_LENGTH    4096</span>00033 <span class="preprocessor"></span><span class="preprocessor">#define D_AUTHENTICATOR_LENGTH        16</span>00034 <span class="preprocessor"></span>00035 <span class="comment">// Raw data buffer is used for storing the whole RADIUS packet _AND_ secret key</span>00036 <span class="comment">// (hence it should be D_RADIUS_PACKET_MAX_LENGTH + D_SECRET_MAX_LENGTH)</span>00037 <span class="preprocessor">#define D_RAW_DATA_LENGTH           4352</span>00038 <span class="preprocessor"></span>00039 00040 <span class="keyword">class </span><a class="code" href="classCRadiusSecret.html">CRadiusSecret</a>;00041 <span class="keyword">class </span><a class="code" href="classCRadiusClientConnection.html">CRadiusClientConnection</a>;00042 <span class="keyword">class </span><a class="code" href="classCRadiusClientStack.html">CRadiusClientStack</a>;00043 <a name="l00058"></a><a class="code" href="classCRadiusPacket.html">00058</a> <span class="keyword">class </span><a class="code" href="classCRadiusPacket.html">CRadiusPacket</a>00059 {00060 <span class="keyword">public</span>:00061 00063 00075     <a class="code" href="classCRadiusPacket.html#a0">CRadiusPacket</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> p_code);00076     00078 00085     <a class="code" href="classCRadiusPacket.html#a0">CRadiusPacket</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> p_code, <a class="code" href="classCRadiusPacket.html">CRadiusPacket</a> * p_request);00086     00088     <a class="code" href="classCRadiusPacket.html#a0">CRadiusPacket</a>(<a class="code" href="classCRadiusPacket.html">CRadiusPacket</a> &amp; p_packet);00089 00091     <a class="code" href="classCRadiusPacket.html#a3">~CRadiusPacket</a>();00092 00094     <span class="keywordtype">void</span> <a class="code" href="classCRadiusPacket.html#a4">copy</a>(<a class="code" href="classCRadiusPacket.html">CRadiusPacket</a> * p_packet);00095 00097 00100     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="classCRadiusPacket.html#a5">getCode</a>(<span class="keywordtype">void</span>);00101 00103     <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="classCRadiusPacket.html#a6">getCodeDescription</a>(<span class="keywordtype">void</span>);00104 00105     00107 00110     ACE_UINT16 <a class="code" href="classCRadiusPacket.html#a7">getLength</a>(<span class="keywordtype">void</span>);00111 00112 00113 00115 00118     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="classCRadiusPacket.html#a8">getID</a>(<span class="keywordtype">void</span>);00119     00121 00124     <span class="keywordtype">void</span> <a class="code" href="classCRadiusPacket.html#a9">setID</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> p_id);00125 00126 00128 00131     <a class="code" href="classCRadiusSecret.html">CRadiusSecret</a> * <a class="code" href="classCRadiusPacket.html#a10">getSecret</a>(<span class="keywordtype">void</span>);00132     00134 00137     <span class="keywordtype">void</span> <a class="code" href="classCRadiusPacket.html#a11">setSecret</a>(<a class="code" href="classCRadiusSecret.html">CRadiusSecret</a> * p_secret);00138 00139 00141     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * <a class="code" href="classCRadiusPacket.html#a12">getAuthenticator</a>(<span class="keywordtype">void</span>);00142     00143 00145     <span class="keywordtype">void</span> <a class="code" href="classCRadiusPacket.html#a13">setAuthenticator</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * p_auth);00146 00147 00148     00149 00151 00155     <span class="keywordtype">void</span> <a class="code" href="classCRadiusPacket.html#a14">dump</a>(<span class="keywordtype">char</span> * p_buf);00156 00157     00158     00160 00181     <span class="keywordtype">int</span> <a class="code" href="classCRadiusPacket.html#a15">getFirstAttribute</a>(<a class="code" href="classCRadiusAttribute.html">CRadiusAttribute</a> &amp; p_attr);00182 00183 00185 00196     <span class="keywordtype">int</span> <a class="code" href="classCRadiusPacket.html#a16">getNextAttribute</a>(<a class="code" href="classCRadiusAttribute.html">CRadiusAttribute</a> &amp; p_attr);00197 00198 00200 00212     <span class="keywordtype">int</span> <a class="code" href="classCRadiusPacket.html#a17">findAttribute</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> p_attrType, <a class="code" href="classCRadiusAttribute.html">CRadiusAttribute</a> &amp; p_attr);00213 00214 00216 00233     <span class="keywordtype">int</span> <a class="code" href="classCRadiusPacket.html#a18">addAttribute</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> p_attrType, <a class="code" href="classCRadiusAttribute.html">CRadiusAttribute</a> &amp; p_attr);00234 00235     00237     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * <a class="code" href="classCRadiusPacket.html#a19">getRawData</a>(<span class="keywordtype">void</span>);00238 00239 00241 00248     <span class="keywordtype">int</span> <a class="code" href="classCRadiusPacket.html#a20">adjustLength</a>(ACE_UINT16 p_length);00249 00250 00252 00261     <span class="keywordtype">void</span> <a class="code" href="classCRadiusPacket.html#a21">responseAuthenticator</a>(<a class="code" href="classCRadiusSecret.html">CRadiusSecret</a> * p_secret = NULL);00262 00263 00264     <span class="comment">// Encode User-Password attribute</span>00265     <span class="comment">/*</span>00266 <span class="comment">     * When packet is retransmitted through new connection, there may be a need to reencode</span>00267 <span class="comment">     * User-Password attribute, since secret key of the new connection may be different.</span>00268 <span class="comment">     * That's exacly what this method does - reencodes User-Password attribute, if the</span>00269 <span class="comment">     * latter exists in this packet.</span>00270 <span class="comment">     *</span>00271 <span class="comment">     * CRadiusClientConnection class uses this method. </span>00272 <span class="comment">     * There seems to be no reason why user application would use this API.</span>00273 <span class="comment">     */</span>00274     <span class="keywordtype">void</span> encodeUserPassword(<span class="keywordtype">void</span>);00275 00276 00278 00287     <span class="keywordtype">void</span> <a class="code" href="classCRadiusPacket.html#a23">accountingRequestAuthenticator</a>(<a class="code" href="classCRadiusSecret.html">CRadiusSecret</a> * p_secret = NULL);00288 00289 <span class="keyword">private</span>:00290 00291     <span class="keyword">friend</span> <a class="code" href="classCRadiusAttribute.html">CRadiusAttribute</a>;00292 00294     <span class="keywordtype">void</span> <a class="code" href="classCRadiusPacket.html#d0">randomAuthenticator</a>(<span class="keywordtype">void</span>);00295 00296     00298 00305     <span class="keywordtype">void</span> <a class="code" href="classCRadiusPacket.html#d1">setCode</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> p_code);00306 00307     00309 00314     <span class="keywordtype">void</span> <a class="code" href="classCRadiusPacket.html#d2">setLength</a>(ACE_UINT16 p_length);00315 00316 00317 <a name="l00319"></a><a class="code" href="classCRadiusPacket.html#r1">00319</a>     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="classCRadiusPacket.html#r1">m_data</a>[D_RAW_DATA_LENGTH];00320 00321 <a name="l00323"></a><a class="code" href="classCRadiusPacket.html#r2">00323</a>     <a class="code" href="classCRadiusSecret.html">CRadiusSecret</a> * <a class="code" href="classCRadiusPacket.html#r2">m_secret</a>;00324 00325 00326     <span class="comment">// User-Password attribute in unencrypted format</span>00327     <span class="comment">/*</span>00328 <span class="comment">     * We need this data in order to re-encode User-Password attribute prior to retransmitting it</span>00329 <span class="comment">     * through another connection (when more than one CRadiusClientConnection is defined);</span>00330 <span class="comment">     */</span>00331     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> m_password[D_USER_PASSWORD_MAX_LENGTH];00332     ACE_UINT16    m_passwordLength;00333     ACE_UINT16    m_passwordOffset;00334 00335 };00336 00337 <span class="preprocessor">#endif // _CRADIUSPACKET_H__</span></div></pre><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 30 11:00:57 2005 for ace-radius by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7-20040704 </small></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -