verinec.adaptation.snmp.tftpserver
Class TFTPServer

java.lang.Object
  extended by verinec.adaptation.snmp.tftpserver.TFTPServer

public class TFTPServer
extends Object

TFTP server main class The server can be run from the command line, with command java -classpath ./verinec-adaptation.jar:./verinec.jar verinec.adaptation.snmp.tftpserver.TFTPServer 'port' 'server root directory'
The server root directory must be the same as in the system property adaptation.distribution.tftp.localpath

BEWARE: This server is very insecure: it does not check the specified path in any way. This means, files from outside the server root directory can be retrieved or overwritten.

Most of the source was taken from http://www.it.rit.edu/~netsyslb/vksf522/class_examples/Day09_TFTPServer/TFTPPacket.pdf
I removed the gui part.

verinec.adaptation.snmp.tftpserver

Version:
1.0
Author:
christoph.ehret at unifr.ch

Nested Class Summary
private  class TFTPServer.Listener
          a thread to listen for incoming packets
 
Field Summary
private  Logger logger
           
private  TFTPServer.Listener mainListener
           
private  DatagramSocket mainSocket
           
private  File rootDir
           
 
Constructor Summary
TFTPServer(int port, File rootDir)
          Creates a TFTPServer instance that starts the server process in a new thread.
 
Method Summary
 String getServerFolder()
          Get's the TFTP Server folder absoluth path
static void main(String[] argv)
          Start the server stand alone.
 void stopServer()
          Stops the TFTP server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private Logger logger

mainSocket

private DatagramSocket mainSocket

mainListener

private TFTPServer.Listener mainListener

rootDir

private File rootDir
Constructor Detail

TFTPServer

public TFTPServer(int port,
                  File rootDir)
           throws VerinecException
Creates a TFTPServer instance that starts the server process in a new thread.

Parameters:
port - The port the server should listen on
rootDir - Folder where files are downloaded and uploaded
Throws:
VerinecException - If the server can not be created
Method Detail

main

public static void main(String[] argv)
Start the server stand alone. Paremeters are:

Parameters:
argv - Command line

stopServer

public void stopServer()
Stops the TFTP server


getServerFolder

public String getServerFolder()
Get's the TFTP Server folder absoluth path

Returns:
Absolute path of the TFTP server folder

Copyright © 2005 Verinec, DIUF