Jump to content











Photo
- - - - -

Filename Remapping


  • Please log in to reply
No replies to this topic

#1 kellerza

kellerza
  • Members
  • 1 posts
  •  
    South Africa

Posted 07 March 2011 - 08:32 PM

Hi,

I've modified TFTPD32 slightly to give Linux TFTPD like file remapping based on the source IP address of the request.

Currently it only maps "*.cfg" to "*.$IP$.cfg". So if you request 'config.cfg' TFTPD32 will serve you a file specific to your IP address,- 'config.$IP$.cfg'

It still needs proper testing and PCRE to get the full Linux TFTPD functionality.

--Johann


Add the following to tftpd_thread.c, and call it from TftpExtendFileName: TftpFileNameRemapping(pTftp, szExtName, nSize);
or somewhere in DecodConnectData

/////////////////////

// TftpFileNameRemapping

//       Work in progress to do "filename remapping"

//       http://linux.die.net/man/8/tftpd -m option

//       current maps .cfg to $IP$.cfg

/////////////////////

static char *TftpFileNameRemapping (struct LL_TftpInfo *pTftp,

                                 char               *szExtName,

                                 int                 nSize)

{

  char* p=strstr(szExtName, ".cfg");

  if (p!=NULL) {

    int nLength;

    char* srcIP = inet_ntoa (pTftp->b.from.sin_addr);

    lstrcpy (p+1, srcIP);

    nLength = lstrlen(szExtName);

    lstrcpy (szExtName + nLength, ".cfg");

    LOG(1, "REMAPPED: '%s'", szExtName);

  } 

  return szExtName;

}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users