<h1>Requirements<aclass="headerlink"href="#requirements"title="Permalink to this headline">¶</a></h1>
<p>Python 2.3+, I think. I haven’t tested in Python 2.3 in a while but it should
still work. Let me know if it doesn’t.</p>
</div>
<divclass="section"id="installation">
<h1>Installation<aclass="headerlink"href="#installation"title="Permalink to this headline">¶</a></h1>
</div>
<divclass="section"id="examples">
<h1>Examples<aclass="headerlink"href="#examples"title="Permalink to this headline">¶</a></h1>
</div>
<divclass="section"id="api-documentation">
<h1>API Documentation<aclass="headerlink"href="#api-documentation"title="Permalink to this headline">¶</a></h1>
<divclass="section"id="front-end-modules">
@ -61,7 +69,7 @@
<p>These modules are the ones that you will need to use directly to implement a
TFTP client or server.</p>
<divclass="section"id="module-tftpy">
<h3>TFTPy Module<aclass="headerlink"href="#module-tftpy"title="Permalink to this headline">¶</a></h3>
<h3>The <ttclass="xref docutils literal"><spanclass="pre">tftpy</span></tt> Module<aclass="headerlink"href="#module-tftpy"title="Permalink to this headline">¶</a></h3>
<p>This library implements the tftp protocol, based on rfc 1350.
At the moment it implements only a client class, but will include a server,
@ -70,14 +78,15 @@ with support for variable block sizes.</p>
directly. The TftpClient and TftpServer classes can be reached through it.</p>
</div>
<divclass="section"id="module-tftpy.TftpClient">
<h3>tftpy.TftpClient<aclass="headerlink"href="#module-tftpy.TftpClient"title="Permalink to this headline">¶</a></h3>
<h3>The <cite>TftpClient</cite> Module<aclass="headerlink"href="#module-tftpy.TftpClient"title="Permalink to this headline">¶</a></h3>
<p>This module implements the TFTP Client functionality. Instantiate an
instance of the client, and then use its upload or download method. Logging is
performed via a standard logging object set in TftpShared.</p>
<dlclass="class">
<dtid="tftpy.TftpClient.TftpClient">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpClient.</tt><ttclass="descname">TftpClient</tt><big>(</big><em>host</em>, <em>port</em>, <em>options={}</em><big>)</big><aclass="headerlink"href="#tftpy.TftpClient.TftpClient"title="Permalink to this definition">¶</a></dt>
<dd><p>This class is an implementation of a tftp client. Once instantiated, a
<p>This class is an implementation of a tftp client. Once instantiated, a
download can be initiated via the download() method, or an upload via the
upload() method.</p>
<dlclass="method">
@ -111,7 +120,7 @@ DAT packet to be ACKd by the server.</p>
</div>
<divclass="section"id="module-tftpy.TftpServer">
<h3>tftpy.TftpServer<aclass="headerlink"href="#module-tftpy.TftpServer"title="Permalink to this headline">¶</a></h3>
<h3>The <cite>TftpServer</cite> Module<aclass="headerlink"href="#module-tftpy.TftpServer"title="Permalink to this headline">¶</a></h3>
<p>This module implements the TFTP Server functionality. Instantiate an
instance of the server, and then run the listen() method to listen for client
requests. Logging is performed via a standard logging object set in
@ -119,7 +128,8 @@ TftpShared.</p>
<dlclass="class">
<dtid="tftpy.TftpServer.TftpServer">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpServer.</tt><ttclass="descname">TftpServer</tt><big>(</big><em>tftproot='/tftpboot'</em>, <em>dyn_file_func=None</em><big>)</big><aclass="headerlink"href="#tftpy.TftpServer.TftpServer"title="Permalink to this definition">¶</a></dt>
<dd><p>This class implements a tftp server object. Run the listen() method to
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpPacketFactory.</tt><ttclass="descname">TftpPacketFactory</tt><aclass="headerlink"href="#tftpy.TftpPacketFactory.TftpPacketFactory"title="Permalink to this definition">¶</a></dt>
<dd><p>This class generates TftpPacket objects. It is responsible for parsing
<h3>tftpy.TftpPacketTypes<aclass="headerlink"href="#module-tftpy.TftpPacketTypes"title="Permalink to this headline">¶</a></h3>
<h3>The <cite>TftpPacketTypes</cite> Module<aclass="headerlink"href="#module-tftpy.TftpPacketTypes"title="Permalink to this headline">¶</a></h3>
<p>This module implements the packet types of TFTP itself, and the
corresponding encode and decode methods for them.</p>
<dlclass="class">
<dtid="tftpy.TftpPacketTypes.TftpPacket">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpPacketTypes.</tt><ttclass="descname">TftpPacket</tt><aclass="headerlink"href="#tftpy.TftpPacketTypes.TftpPacket"title="Permalink to this definition">¶</a></dt>
<dd><p>This class is the parent class of all tftp packet classes. It is an
<p>This class is the parent class of all tftp packet classes. It is an
abstract class, providing an interface, and should not be instantiated
directly.</p>
<dlclass="method">
@ -194,7 +206,8 @@ order suitable for sending over the wire.</p>
<dlclass="class">
<dtid="tftpy.TftpPacketTypes.TftpPacketACK">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpPacketTypes.</tt><ttclass="descname">TftpPacketACK</tt><aclass="headerlink"href="#tftpy.TftpPacketTypes.TftpPacketACK"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpPacketTypes.</tt><ttclass="descname">TftpPacketDAT</tt><aclass="headerlink"href="#tftpy.TftpPacketTypes.TftpPacketDAT"title="Permalink to this definition">¶</a></dt>
<dd><divclass="highlight-python"><pre> 2 bytes 2 bytes n bytes
<divclass="highlight-python"><pre> 2 bytes 2 bytes n bytes
---------------------------------
DATA | 03 | Block # | Data |
---------------------------------</pre>
@ -226,7 +240,8 @@ returns self for easy method chaining.</dd></dl>
<dlclass="class">
<dtid="tftpy.TftpPacketTypes.TftpPacketERR">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpPacketTypes.</tt><ttclass="descname">TftpPacketERR</tt><aclass="headerlink"href="#tftpy.TftpPacketTypes.TftpPacketERR"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpPacketTypes.</tt><ttclass="descname">TftpPacketInitial</tt><aclass="headerlink"href="#tftpy.TftpPacketTypes.TftpPacketInitial"title="Permalink to this definition">¶</a></dt>
<dd><p>This class is a common parent class for the RRQ and WRQ packets, as
@ -273,7 +289,8 @@ they share quite a bit of code.</p>
<dlclass="class">
<dtid="tftpy.TftpPacketTypes.TftpPacketOACK">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpPacketTypes.</tt><ttclass="descname">TftpPacketOACK</tt><aclass="headerlink"href="#tftpy.TftpPacketTypes.TftpPacketOACK"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpPacketTypes.</tt><ttclass="descname">TftpPacketRRQ</tt><aclass="headerlink"href="#tftpy.TftpPacketTypes.TftpPacketRRQ"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpPacketTypes.</tt><ttclass="descname">TftpPacketWRQ</tt><aclass="headerlink"href="#tftpy.TftpPacketTypes.TftpPacketWRQ"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpPacketTypes.</tt><ttclass="descname">TftpPacketWithOptions</tt><aclass="headerlink"href="#tftpy.TftpPacketTypes.TftpPacketWithOptions"title="Permalink to this definition">¶</a></dt>
<dd><p>This class exists to permit some TftpPacket subclasses to share code
<p>This class exists to permit some TftpPacket subclasses to share code
regarding options handling. It does not inherit from TftpPacket, as the
goal is just to share code here, and not cause diamond inheritance.</p>
<dlclass="method">
@ -326,24 +346,30 @@ values.</dd></dl>
<dlclass="class">
<dtid="tftpy.TftpPacketTypes.TftpSession">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpPacketTypes.</tt><ttclass="descname">TftpSession</tt><aclass="headerlink"href="#tftpy.TftpPacketTypes.TftpSession"title="Permalink to this definition">¶</a></dt>
<dd>This class is the base class for the tftp client and server. Any shared
<p>This class is the base class for the tftp client and server. Any shared
code should be in this class.</p>
</dd></dl>
</div>
<divclass="section"id="module-tftpy.TftpShared">
<h3>tftpy.TftpShared<aclass="headerlink"href="#module-tftpy.TftpShared"title="Permalink to this headline">¶</a></h3>
<h3>The <cite>TftpShared</cite> Module<aclass="headerlink"href="#module-tftpy.TftpShared"title="Permalink to this headline">¶</a></h3>
<p>This module holds all objects shared by all other modules in tftpy.</p>
<dlclass="class">
<dtid="tftpy.TftpShared.TftpErrors">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpShared.</tt><ttclass="descname">TftpErrors</tt><aclass="headerlink"href="#tftpy.TftpShared.TftpErrors"title="Permalink to this definition">¶</a></dt>
<dd>This class is a convenience for defining the common tftp error codes,
and making them more readable in the code.</dd></dl>
<p>This class is a convenience for defining the common tftp error codes,
and making them more readable in the code.</p>
</dd></dl>
<dlclass="exception">
<dtid="tftpy.TftpShared.TftpException">
<emclass="property">exception </em><ttclass="descclassname">tftpy.TftpShared.</tt><ttclass="descname">TftpException</tt><aclass="headerlink"href="#tftpy.TftpShared.TftpException"title="Permalink to this definition">¶</a></dt>
<dd>This class is the parent class of all exceptions regarding the handling
<p>This class is the parent class of all exceptions regarding the handling
of the TFTP protocol.</p>
</dd></dl>
<dlclass="function">
<dtid="tftpy.TftpShared.setLogLevel">
@ -362,7 +388,7 @@ by refactoring.</dd></dl>
</div>
<divclass="section"id="module-tftpy.TftpStates">
<h3>tftpy.TftpStates<aclass="headerlink"href="#module-tftpy.TftpStates"title="Permalink to this headline">¶</a></h3>
<h3>The <cite>TftpStates</cite> Module<aclass="headerlink"href="#module-tftpy.TftpStates"title="Permalink to this headline">¶</a></h3>
<p>This module implements all state handling during uploads and downloads, the
main interface to which being the TftpContext base class and the TftpState
base class.</p>
@ -375,7 +401,8 @@ error, in which case a TftpException is returned instead.</p>
<dlclass="class">
<dtid="tftpy.TftpStates.TftpContext">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpStates.</tt><ttclass="descname">TftpContext</tt><big>(</big><em>host</em>, <em>port</em>, <em>timeout</em>, <em>dyn_file_func=None</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpContext"title="Permalink to this definition">¶</a></dt>
<ttclass="descname">checkTimeout</tt><big>(</big><em>now</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpContext.checkTimeout"title="Permalink to this definition">¶</a></dt>
@ -416,7 +443,8 @@ of the host that is set.</dd></dl>
@ -445,7 +474,8 @@ Note: If input is a hyphen, then we will use stdin.</p>
<dlclass="class">
<dtid="tftpy.TftpStates.TftpContextServer">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpStates.</tt><ttclass="descname">TftpContextServer</tt><big>(</big><em>host</em>, <em>port</em>, <em>timeout</em>, <em>root</em>, <em>dyn_file_func=None</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpContextServer"title="Permalink to this definition">¶</a></dt>
<ttclass="descname">end</tt><big>(</big><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpContextServer.end"title="Permalink to this definition">¶</a></dt>
@ -464,7 +494,8 @@ that.</dd></dl>
<dlclass="class">
<dtid="tftpy.TftpStates.TftpMetrics">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpStates.</tt><ttclass="descname">TftpMetrics</tt><aclass="headerlink"href="#tftpy.TftpStates.TftpMetrics"title="Permalink to this definition">¶</a></dt>
<dd><p>A class representing metrics of the transfer.</p>
<p>A class representing metrics of the transfer.</p>
<dlclass="method">
<dtid="tftpy.TftpStates.TftpMetrics.add_dup">
<ttclass="descname">add_dup</tt><big>(</big><em>blocknumber</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpMetrics.add_dup"title="Permalink to this definition">¶</a></dt>
@ -475,7 +506,8 @@ that.</dd></dl>
<dlclass="class">
<dtid="tftpy.TftpStates.TftpState">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpStates.</tt><ttclass="descname">TftpState</tt><big>(</big><em>context</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpState"title="Permalink to this definition">¶</a></dt>
<ttclass="descname">handle</tt><big>(</big><em>pkt</em>, <em>raddress</em>, <em>rport</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpState.handle"title="Permalink to this definition">¶</a></dt>
@ -540,7 +572,8 @@ it is required to send an OACK to the client.</dd></dl>
<dlclass="class">
<dtid="tftpy.TftpStates.TftpStateExpectACK">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpStates.</tt><ttclass="descname">TftpStateExpectACK</tt><big>(</big><em>context</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpStateExpectACK"title="Permalink to this definition">¶</a></dt>
<dd><p>This class represents the state of the transfer when a DAT was just
<p>This class represents the state of the transfer when a DAT was just
sent, and we are waiting for an ACK from the server. This class is the
same one used by the client during the upload, and the server during the
download.</p>
@ -554,7 +587,8 @@ download.</p>
<dlclass="class">
<dtid="tftpy.TftpStates.TftpStateExpectDAT">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpStates.</tt><ttclass="descname">TftpStateExpectDAT</tt><big>(</big><em>context</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpStateExpectDAT"title="Permalink to this definition">¶</a></dt>
<dd><p>Just sent an ACK packet. Waiting for DAT.</p>
<ttclass="descname">handle</tt><big>(</big><em>pkt</em>, <em>raddress</em>, <em>rport</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpStateExpectDAT.handle"title="Permalink to this definition">¶</a></dt>
@ -565,7 +599,8 @@ download.</p>
<dlclass="class">
<dtid="tftpy.TftpStates.TftpStateSentRRQ">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpStates.</tt><ttclass="descname">TftpStateSentRRQ</tt><big>(</big><em>context</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpStateSentRRQ"title="Permalink to this definition">¶</a></dt>
<ttclass="descname">handle</tt><big>(</big><em>pkt</em>, <em>raddress</em>, <em>rport</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpStateSentRRQ.handle"title="Permalink to this definition">¶</a></dt>
@ -576,7 +611,8 @@ download.</p>
<dlclass="class">
<dtid="tftpy.TftpStates.TftpStateSentWRQ">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpStates.</tt><ttclass="descname">TftpStateSentWRQ</tt><big>(</big><em>context</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpStateSentWRQ"title="Permalink to this definition">¶</a></dt>
<ttclass="descname">handle</tt><big>(</big><em>pkt</em>, <em>raddress</em>, <em>rport</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpStateSentWRQ.handle"title="Permalink to this definition">¶</a></dt>
@ -587,7 +623,8 @@ download.</p>
<dlclass="class">
<dtid="tftpy.TftpStates.TftpStateServerRecvRRQ">
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpStates.</tt><ttclass="descname">TftpStateServerRecvRRQ</tt><big>(</big><em>context</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpStateServerRecvRRQ"title="Permalink to this definition">¶</a></dt>
<dd><p>This class represents the state of the TFTP server when it has just
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpStates.</tt><ttclass="descname">TftpStateServerRecvWRQ</tt><big>(</big><em>context</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpStateServerRecvWRQ"title="Permalink to this definition">¶</a></dt>
<dd><p>This class represents the state of the TFTP server when it has just
<emclass="property">class </em><ttclass="descclassname">tftpy.TftpStates.</tt><ttclass="descname">TftpStateServerStart</tt><big>(</big><em>context</em><big>)</big><aclass="headerlink"href="#tftpy.TftpStates.TftpStateServerStart"title="Permalink to this definition">¶</a></dt>
<dd><p>The start state for the server. This is a transitory state since at