summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2004-11-04 20:04:19 (UTC)
committer Michael Krelin <hacker@klever.net>2004-11-04 20:04:19 (UTC)
commita494b6d595059d6fb6464935e429176a714d490d (patch) (side-by-side diff)
tree20b82b6d6512ace8abcc7774d0a9c9d7c0bcfbb2
parent5f552506513653f08acc6921b8c158489a7ebbbb (diff)
downloadpumpkin-a494b6d595059d6fb6464935e429176a714d490d.zip
pumpkin-a494b6d595059d6fb6464935e429176a714d490d.tar.gz
pumpkin-a494b6d595059d6fb6464935e429176a714d490d.tar.bz2
invalid opcode during xfer message shows the opcode itself now.
git-svn-id: http://svn.klever.net/kin/pumpkin/trunk@48 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--PumpKINDlg.cpp20
-rw-r--r--pumpkin.rc2
2 files changed, 15 insertions, 7 deletions
diff --git a/PumpKINDlg.cpp b/PumpKINDlg.cpp
index fc24596..b6b8a36 100644
--- a/PumpKINDlg.cpp
+++ b/PumpKINDlg.cpp
@@ -896,179 +896,187 @@ BOOL rv = TRUE;
m_ACK=0;
ASSERT(state!=stateFinish);
{
tftp::tftpOptions o;
if(p->GetOptions(&o)){
CString v;
if(o.Lookup(tftpoBSize,v)){
m_blkSize=atoi(v);
if(!m_blkSize){ // *** More sanity checks
Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE);
rv = TRUE;
break;
}
}
if(o.Lookup(tftpoTOut,v)){
m_timeOut=atoi(v);
if(!m_timeOut){ // *** More sanity checks
Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT);
rv = TRUE;
break;
}
}
if(o.Lookup(tftpoXResume,v)){
m_ACK=atoi(v);
}
}
UpdateList();
DoXfer();
}
break;
case tftp::opACK:
m_ACK=p->data.m_ACK.Block();
if(state!=stateFinish){
UpdateList();
DoXfer();
}
break;
case tftp::opERROR:
{
ASSERT(m_Daddy);
CString tmp;
tmp.Format(IDS_LOG_GOTTFTPERROR,p->data.m_ERROR.Code(),(LPCTSTR)p->errMessage());
m_Daddy->LogLine(tmp);
}
Destroy(FALSE);
rv = FALSE;
break;
default:
- ASSERT(m_Daddy);
- m_Daddy->LogLine(IDS_LOG_XFEROPCODE);
- // *** Self destruct maybe??
+ {
+ ASSERT(m_Daddy);
+ CString tmp;
+ tmp.Format(IDS_LOG_XFEROPCODE,p->Opcode());
+ m_Daddy->LogLine(tmp);
+ // *** Self destruct maybe??
+ }
break;
}
return rv;
}
BOOL CWRQSocket::OnTFTP(tftp* p)
{
switch(p->Opcode()){
case tftp::opOACK:
ASSERT(state!=stateFinish);
{
if(m_bResume)
m_ACK=m_File.GetLength()/m_blkSize;
else
m_ACK=0;
tftp::tftpOptions o;
if(p->GetOptions(&o)){
CString v;
if(o.Lookup(tftpoBSize,v)){
m_blkSize=atoi(v);
if(!m_blkSize){ // *** More sanity checks
Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE);
return TRUE;
}
}
if(o.Lookup(tftpoTOut,v)){
m_timeOut=atoi(v);
if(!m_timeOut){ // *** More sanity checks
Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT);
return TRUE;
}
}
if(o.Lookup(tftpoTSize,v)){
m_xferSize=atoi(v);
}
}
UpdateList();
DoXfer();
}
break;
case tftp::opDATA:
{
UINT block = p->data.m_DATA.Block();
TRY{
m_File.Seek((block-1)*m_blkSize,CFile::begin);
int bytes = p->length-sizeof(p->data.m_DATA.block)-(tftpHdrSize-tftpSlackSize);
if(bytes){
m_File.Write(p->data.m_DATA.data,bytes);
// *** Move to the other place where we can do it not that often
m_File.SetLength(m_File.GetPosition());
}
if(bytes<m_blkSize){
state=stateFinish;
ASSERT(m_Daddy);
CString tmp;
tmp.Format(IDS_LOG_XFERWRQFINISHED,(LPCTSTR)m_FileName);
m_Daddy->LogLine(tmp);
}
m_ACK=block;
m_LastSlack=m_blkSize-bytes;
UpdateList();
DoXfer();
}CATCH(CFileException,e){
Deny(e);
}END_CATCH
}
break;
case tftp::opERROR:
{
ASSERT(m_Daddy);
CString tmp;
tmp.Format(IDS_LOG_GOTTFTPERROR,p->data.m_ERROR.Code(),(LPCTSTR)p->errMessage());
m_Daddy->LogLine(tmp);
}
Destroy(FALSE);
return FALSE;
default:
- ASSERT(m_Daddy);
- m_Daddy->LogLine(IDS_LOG_XFEROPCODE);
- // *** Self destruct maybe??
+ {
+ ASSERT(m_Daddy);
+ CString tmp;
+ tmp.Format(IDS_LOG_XFEROPCODE,p->Opcode());
+ m_Daddy->LogLine(tmp);
+ // *** Self destruct maybe??
+ }
break;
}
return TRUE;
}
void tftp::SetOpcode(WORD op)
{
opcode = REVERSEBYTES(op);
}
void tftp::tftpDATA::SetBlock(WORD b)
{
block=REVERSEBYTES(b);
}
WORD tftp::tftpDATA::Block()
{
return REVERSEBYTES(block);
}
WORD tftp::tftpACK::Block()
{
return REVERSEBYTES(block);
}
void tftp::tftpACK::SetBlock(WORD b)
{
block = REVERSEBYTES(b);
}
WORD tftp::tftpERROR::Code()
{
return REVERSEBYTES(code);
}
void tftp::tftpERROR::SetCode(WORD c)
{
code = REVERSEBYTES(c);
}
CString tftp::errMessage()
{
CString rv;
if(memchr(data.m_ERROR.data,0,length-(tftpHdrSize-tftpSlackSize)-sizeof(data.m_ERROR.code)))
rv = (LPCTSTR)data.m_ERROR.data;
return rv;
}
void CXferSocket::Destroy(BOOL success)
{
if(m_wndResolver){
delete m_wndResolver;
m_wndResolver=NULL;
diff --git a/pumpkin.rc b/pumpkin.rc
index 7f3bbde..1bf0fd3 100644
--- a/pumpkin.rc
+++ b/pumpkin.rc
@@ -450,97 +450,97 @@ BEGIN
POPUP "&Tray"
BEGIN
MENUITEM "&Send File", ID_TRAY_SENDFILE
MENUITEM "F&etch file", ID_TRAY_FETCHFILE
MENUITEM "&Options", ID_TRAY_OPTIONS
MENUITEM "Show &PumpKIN Window", ID_TRAY_SHOWPUMPKINWINDOW
MENUITEM "Open &Files Folder", ID_TRAY_OPENFILESFOLDER
MENUITEM SEPARATOR
MENUITEM "&Help Topics", ID_TRAY_HELP
MENUITEM "&About PumpKIN", ID_TRAY_ABOUTPUMPKIN
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_TRAY_EXIT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_ABOUTBOX "&About PumpKIN..."
IDS_FMT_BYTES "%lu"
IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed."
IDS_TFTP_ERROR_ACCESS "Access violation"
IDS_TFTP_ERROR_NOTFOUND "File not found"
IDS_TFTP_ERROR_DIRFULL "Directory is full"
IDS_TFTP_ERROR_SHARING "Sharing violation"
IDS_TFTP_ERROR_DISKFULL "Disk full"
IDS_TFTP_ERROR_UNDEFINED "Undefined error"
IDS_LOG_START "PumpKIN started"
IDS_LOG_LISTENRECEIVEERROR "Error listening for incoming connections"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_LOG_LISTENACCEPTERROR "Error accepting incoming connection"
IDS_LOG_RRQSERVE "'%s' of type '%s' is requested from %s"
IDS_LOG_LISTENOPCODE "Invalid opcode in initial connection request"
IDS_LOG_XFERUDPSEND "UDP packet send failed"
IDS_LOG_XFERRECEIVE "Error on xfer socket"
IDS_LOG_XFERSEND "Error on xfer socket"
IDS_LOG_XFERUDPRECEIVE "UDP packet receive failed"
IDS_LOG_XFERSOURCETID "Packet from unexpected source"
IDS_LOG_SENTTFTPERROR ":%u: %s"
IDS_LOG_GOTTFTPERROR "TFTP:%u: %s"
- IDS_LOG_XFEROPCODE "Invalid opcode during transfer received"
+ IDS_LOG_XFEROPCODE "Invalid opcode (%u) during transfer received"
IDS_LOG_XFERRRQFINISHED "Transfer of '%s' has successfully completed"
IDS_TITLE_OPTIONS "Options"
IDS_LOG_WRQSERVE "Writing of '%s' of type '%s' is requested by %s"
IDS_TFTP_ERROR_FAILEDTORENAME "Too many clones of the file"
IDS_RENAME_TITLE "Save As"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_LOG_TIMEDOUT "Transmission of '%s' is timed out"
IDS_CONFIRMEXIT_TITLE "Exit"
IDS_CONFIRMEXIT_TEXT "File transmission is currently in progress. Are you sure you want to exit?"
IDS_LOG_XFERWRQFINISHED "Transfer of '%s' has successfully completed"
IDS_LOG_XFERABORTED "Transfer of '%s' was aborted"
IDS_TITLE_PUTREQUEST "Send file"
IDS_TITLE_GETREQUEST "Fetch file"
IDS_WTALKHEADING "Talk with "
IDS_TITLE_BROWSEFILE "Browse"
IDS_LOG_RESOLVEFAILED "Failed to resolve host address for '%s'"
IDS_LOG_FAILEDLOCALFILE "Failed to open local file '%s'"
IDS_LOG_FAILEDTOOPEN "Failed to open '%s'"
IDS_OTALXHEADING "Open Talks: talking to "
IDS_REGISTRYKEY "Klever Group"
IDS_KLEVERNET_URL "http://www.klever.net/"
IDS_LOGTIMEFORMAT "%H:%M:%S %B %d"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_TRAY_HELP "Read the help on PumpKIN"
ID_TRAY_ABOUTPUMPKIN "Learn about PumpKIN and it's creator"
ID_TRAY_EXIT "Close PumpKIN"
ID_TRAY_SENDFILE "Send file over the network to your tete-a-tete"
ID_TRAY_FETCHFILE "Fetch file from remote computer"
ID_TRAY_OPTIONS "Set PumpKIN options"
ID_TRAY_SHOWPUMPKINWINDOW "Show main window"
ID_TRAY_OPENFILESFOLDER "Explore TFTP root folder"
END
STRINGTABLE DISCARDABLE
BEGIN
IDC_CONNECTIONS "Active transfers"
IDC_LOG "PumpKIN Activity Log"
IDC_GET "Fetch file from remote server"
IDC_PUT "Send file over the net"
IDC_ABORT "Abort transfer currently in progress"
IDC_EXIT "Close PumpKIN"
END