Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 8457c46910352e73f0e46d6907b72318 > files > 125

python-pyrad-2.0-3.fc18.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>pyrad.packet – packet encoding and decoding &mdash; pyrad 1.2 documentation</title>
    
    <link rel="stylesheet" href="../_static/repoze.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="pyrad 1.2 documentation" href="../index.html" />
    <link rel="next" title="pyrad.proxy – basic proxy" href="proxy.html" />
    <link rel="prev" title="pyrad.host – RADIUS host definition" href="host.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="proxy.html" title="pyrad.proxy – basic proxy"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="host.html" title="pyrad.host – RADIUS host definition"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">pyrad 1.2 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-pyrad.packet">
<span id="pyrad-packet-packet-encoding-and-decoding"></span><h1><a class="reference internal" href="#module-pyrad.packet" title="pyrad.packet"><tt class="xref py py-mod docutils literal"><span class="pre">pyrad.packet</span></tt></a> &#8211; packet encoding and decoding<a class="headerlink" href="#module-pyrad.packet" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="pyrad.packet.Packet">
<em class="property">class </em><tt class="descclassname">pyrad.packet.</tt><tt class="descname">Packet</tt><big>(</big><em>code=0</em>, <em>id=None</em>, <em>secret=''</em>, <em>authenticator=None</em>, <em>**attributes</em><big>)</big><a class="headerlink" href="#pyrad.packet.Packet" title="Permalink to this definition">¶</a></dt>
<dd><p>Packet acts like a standard python map to provide simple access
to the RADIUS attributes. Since RADIUS allows for repeated
attributes the value will always be a sequence. pyrad makes sure
to preserve the ordering when encoding and decoding packets.</p>
<p>There are two ways to use the map intereface: if attribute
names are used pyrad take care of en-/decoding data. If
the attribute type number (or a vendor ID/attribute type
tuple for vendor attributes) is used you work with the
raw data.</p>
<p>Normally you will not use this class directly, but one of the
<a class="reference internal" href="#pyrad.packet.AuthPacket" title="pyrad.packet.AuthPacket"><tt class="xref py py-obj docutils literal"><span class="pre">AuthPacket</span></tt></a> or <a class="reference internal" href="#pyrad.packet.AcctPacket" title="pyrad.packet.AcctPacket"><tt class="xref py py-obj docutils literal"><span class="pre">AcctPacket</span></tt></a> classes.</p>
<dl class="method">
<dt id="pyrad.packet.Packet.AddAttribute">
<tt class="descname">AddAttribute</tt><big>(</big><em>key</em>, <em>value</em><big>)</big><a class="headerlink" href="#pyrad.packet.Packet.AddAttribute" title="Permalink to this definition">¶</a></dt>
<dd><p>Add an attribute to the packet.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> (<em>string, attribute code or (vendor code, attribute code)
tuple</em>) &#8211; attribute name or identification</li>
<li><strong>value</strong> (<em>depends on type of attribute</em>) &#8211; value</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="staticmethod">
<dt id="pyrad.packet.Packet.CreateAuthenticator">
<em class="property">static </em><tt class="descname">CreateAuthenticator</tt><big>(</big><big>)</big><a class="headerlink" href="#pyrad.packet.Packet.CreateAuthenticator" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a packet autenticator. All RADIUS packets contain a sixteen
byte authenticator which is used to authenticate replies from the
RADIUS server and in the password hiding algorithm. This function
returns a suitable random string that can be used as an authenticator.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">valid packet authenticator</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">binary string</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyrad.packet.Packet.CreateID">
<tt class="descname">CreateID</tt><big>(</big><big>)</big><a class="headerlink" href="#pyrad.packet.Packet.CreateID" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a packet ID.  All RADIUS requests have a ID which is used to
identify a request. This is used to detect retries and replay attacks.
This function returns a suitable random number that can be used as ID.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">ID number</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">integer</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyrad.packet.Packet.CreateReply">
<tt class="descname">CreateReply</tt><big>(</big><em>**attributes</em><big>)</big><a class="headerlink" href="#pyrad.packet.Packet.CreateReply" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new packet as a reply to this one. This method
makes sure the authenticator and secret are copied over
to the new instance.</p>
</dd></dl>

<dl class="method">
<dt id="pyrad.packet.Packet.DecodePacket">
<tt class="descname">DecodePacket</tt><big>(</big><em>packet</em><big>)</big><a class="headerlink" href="#pyrad.packet.Packet.DecodePacket" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize the object from raw packet data.  Decode a packet as
received from the network and decode it.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>packet</strong> (<em>string</em>) &#8211; raw packet</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyrad.packet.Packet.ReplyPacket">
<tt class="descname">ReplyPacket</tt><big>(</big><big>)</big><a class="headerlink" href="#pyrad.packet.Packet.ReplyPacket" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a ready-to-transmit authentication reply packet.
Returns a RADIUS packet which can be directly transmitted
to a RADIUS server. This differs with Packet() in how
the authenticator is calculated.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">raw packet</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="pyrad.packet.AuthPacket">
<em class="property">class </em><tt class="descclassname">pyrad.packet.</tt><tt class="descname">AuthPacket</tt><big>(</big><em>code=1</em>, <em>id=None</em>, <em>secret=''</em>, <em>authenticator=None</em>, <em>**attributes</em><big>)</big><a class="headerlink" href="#pyrad.packet.AuthPacket" title="Permalink to this definition">¶</a></dt>
<dd><dl class="method">
<dt id="pyrad.packet.AuthPacket.CreateReply">
<tt class="descname">CreateReply</tt><big>(</big><em>**attributes</em><big>)</big><a class="headerlink" href="#pyrad.packet.AuthPacket.CreateReply" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new packet as a reply to this one. This method
makes sure the authenticator and secret are copied over
to the new instance.</p>
</dd></dl>

<dl class="method">
<dt id="pyrad.packet.AuthPacket.PwCrypt">
<tt class="descname">PwCrypt</tt><big>(</big><em>password</em><big>)</big><a class="headerlink" href="#pyrad.packet.AuthPacket.PwCrypt" title="Permalink to this definition">¶</a></dt>
<dd><p>Obfuscate password.
RADIUS hides passwords in packets by using an algorithm
based on the MD5 hash of the packet authenticator and RADIUS
secret. If no authenticator has been set before calling PwCrypt
one is created automatically. Changing the authenticator after
setting a password that has been encrypted using this function
will not work.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>password</strong> (<em>unicode stringn</em>) &#8211; plaintext password</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">obfuscated version of the password</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">binary string</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyrad.packet.AuthPacket.PwDecrypt">
<tt class="descname">PwDecrypt</tt><big>(</big><em>password</em><big>)</big><a class="headerlink" href="#pyrad.packet.AuthPacket.PwDecrypt" title="Permalink to this definition">¶</a></dt>
<dd><p>Unobfuscate a RADIUS password. RADIUS hides passwords in packets by
using an algorithm based on the MD5 hash of the packet authenticator
and RADIUS secret. This function reverses the obfuscation process.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>password</strong> (<em>binary string</em>) &#8211; obfuscated form of password</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">plaintext password</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">unicode string</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyrad.packet.AuthPacket.RequestPacket">
<tt class="descname">RequestPacket</tt><big>(</big><big>)</big><a class="headerlink" href="#pyrad.packet.AuthPacket.RequestPacket" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a ready-to-transmit authentication request packet.
Return a RADIUS packet which can be directly transmitted
to a RADIUS server.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">raw packet</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="pyrad.packet.AcctPacket">
<em class="property">class </em><tt class="descclassname">pyrad.packet.</tt><tt class="descname">AcctPacket</tt><big>(</big><em>code=4</em>, <em>id=None</em>, <em>secret=''</em>, <em>authenticator=None</em>, <em>**attributes</em><big>)</big><a class="headerlink" href="#pyrad.packet.AcctPacket" title="Permalink to this definition">¶</a></dt>
<dd><p>RADIUS accounting packets. This class is a specialization
of the generic <a class="reference internal" href="#pyrad.packet.Packet" title="pyrad.packet.Packet"><tt class="xref py py-obj docutils literal"><span class="pre">Packet</span></tt></a> class for accounting packets.</p>
<dl class="method">
<dt id="pyrad.packet.AcctPacket.CreateReply">
<tt class="descname">CreateReply</tt><big>(</big><em>**attributes</em><big>)</big><a class="headerlink" href="#pyrad.packet.AcctPacket.CreateReply" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new packet as a reply to this one. This method
makes sure the authenticator and secret are copied over
to the new instance.</p>
</dd></dl>

<dl class="method">
<dt id="pyrad.packet.AcctPacket.RequestPacket">
<tt class="descname">RequestPacket</tt><big>(</big><big>)</big><a class="headerlink" href="#pyrad.packet.AcctPacket.RequestPacket" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a ready-to-transmit authentication request packet.
Return a RADIUS packet which can be directly transmitted
to a RADIUS server.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">raw packet</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pyrad.packet.AcctPacket.VerifyAcctRequest">
<tt class="descname">VerifyAcctRequest</tt><big>(</big><big>)</big><a class="headerlink" href="#pyrad.packet.AcctPacket.VerifyAcctRequest" title="Permalink to this definition">¶</a></dt>
<dd><p>Verify request authenticator.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True if verification failed else False</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">boolean</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="pyrad.packet.PacketError">
<em class="property">class </em><tt class="descclassname">pyrad.packet.</tt><tt class="descname">PacketError</tt><a class="headerlink" href="#pyrad.packet.PacketError" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="section" id="constants">
<h2>Constants<a class="headerlink" href="#constants" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#module-pyrad.packet" title="pyrad.packet"><tt class="xref py py-mod docutils literal"><span class="pre">pyrad.packet</span></tt></a> module defines several common constants
that are useful when dealing with RADIUS packets.</p>
<p>The following packet codes are defined:</p>
<table border="1" class="docutils">
<colgroup>
<col width="75%" />
<col width="25%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Constant name</th>
<th class="head">Value</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>AccessRequest</td>
<td>1</td>
</tr>
<tr class="row-odd"><td>AccessAccept</td>
<td>2</td>
</tr>
<tr class="row-even"><td>AccessReject</td>
<td>3</td>
</tr>
<tr class="row-odd"><td>AccountingRequest</td>
<td>4</td>
</tr>
<tr class="row-even"><td>AccountingResponse</td>
<td>5</td>
</tr>
<tr class="row-odd"><td>AccessChallenge</td>
<td>11</td>
</tr>
<tr class="row-even"><td>StatusServer</td>
<td>12</td>
</tr>
<tr class="row-odd"><td>StatusClient</td>
<td>13</td>
</tr>
<tr class="row-even"><td>DisconnectRequest</td>
<td>40</td>
</tr>
<tr class="row-odd"><td>DisconnectACK</td>
<td>41</td>
</tr>
<tr class="row-even"><td>DisconnectNAK</td>
<td>42</td>
</tr>
<tr class="row-odd"><td>CoARequest</td>
<td>43</td>
</tr>
<tr class="row-even"><td>CoAACK</td>
<td>44</td>
</tr>
<tr class="row-odd"><td>CoANAK</td>
<td>45</td>
</tr>
</tbody>
</table>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/logo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#"><tt class="docutils literal"><span class="pre">pyrad.packet</span></tt> &#8211; packet encoding and decoding</a><ul>
<li><a class="reference internal" href="#constants">Constants</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="host.html"
                        title="previous chapter"><tt class="docutils literal docutils literal docutils literal"><span class="pre">pyrad.host</span></tt> &#8211; RADIUS host definition</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="proxy.html"
                        title="next chapter"><tt class="docutils literal"><span class="pre">pyrad.proxy</span></tt> &#8211; basic proxy</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/api/packet.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="proxy.html" title="pyrad.proxy – basic proxy"
             >next</a> |</li>
        <li class="right" >
          <a href="host.html" title="pyrad.host – RADIUS host definition"
             >previous</a> |</li>
        <li><a href="../index.html">pyrad 1.2 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2002-2009 Wichert Akkerman, 2009 Kristoffer Gronlund.
      Last updated on Sep 05, 2013.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>