summaryrefslogtreecommitdiffabout
path: root/PumpKINDlg.cpp
Unidiff
Diffstat (limited to 'PumpKINDlg.cpp') (more/less context) (show whitespace changes)
-rw-r--r--PumpKINDlg.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/PumpKINDlg.cpp b/PumpKINDlg.cpp
index 2a01918..bb15211 100644
--- a/PumpKINDlg.cpp
+++ b/PumpKINDlg.cpp
@@ -757,48 +757,53 @@ CFileException e;
757 OnHostKnown(); 757 OnHostKnown();
758 }else{ 758 }else{
759 tftp::tftpOptions o; 759 tftp::tftpOptions o;
760 CString v; 760 CString v;
761 if(m_Options.Lookup(tftpoBSize,v)){ 761 if(m_Options.Lookup(tftpoBSize,v)){
762 m__blkSize=atoi(v); 762 m__blkSize=atoi(v);
763 if(m__blkSize){ 763 if(m__blkSize){
764 m_blkSize=m__blkSize; 764 m_blkSize=m__blkSize;
765 v.Format("%u",m_blkSize); 765 v.Format("%u",m_blkSize);
766 o[tftpoBSize]=v; 766 o[tftpoBSize]=v;
767 } 767 }
768 } 768 }
769 if(m_Options.Lookup(tftpoTSize,v)){ 769 if(m_Options.Lookup(tftpoTSize,v)){
770 v.Format("%lu",m_xferSize); 770 v.Format("%lu",m_xferSize);
771 o[tftpoTSize]=v; 771 o[tftpoTSize]=v;
772 } 772 }
773 if(m_Options.Lookup(tftpoTOut,v)){ 773 if(m_Options.Lookup(tftpoTOut,v)){
774 m__timeOut=atoi(v); 774 m__timeOut=atoi(v);
775 if(m__timeOut){ 775 if(m__timeOut){
776 m_timeOut=m__timeOut; 776 m_timeOut=m__timeOut;
777 v.Format("%u",m_timeOut); 777 v.Format("%u",m_timeOut);
778 o[tftpoTOut]=v; 778 o[tftpoTOut]=v;
779 } 779 }
780 } 780 }
781 // XXX: see if we can enforce our preference regarding block size here.
782 if(m_xferSize >= (m_blkSize<<16)) {
783 Deny(tftp::errUndefined,IDS_TFTP_ERROR_TOOBIG);
784 return TRUE;
785 }
781 state = stateXfer; 786 state = stateXfer;
782 m_ACK=0; 787 m_ACK=0;
783 if(o.GetCount()){ 788 if(o.GetCount()){
784 tftp *p = tftp::Allocate(tftp::tftpOACK::tftpSize(&o)); 789 tftp *p = tftp::Allocate(tftp::tftpOACK::tftpSize(&o));
785 ASSERT(p); 790 ASSERT(p);
786 p->SetOpcode(tftp::opOACK); 791 p->SetOpcode(tftp::opOACK);
787 p->data.m_OACK.Set(&o); 792 p->data.m_OACK.Set(&o);
788 PostTFTP(p,TRUE); 793 PostTFTP(p,TRUE);
789 }else 794 }else
790 DoXfer(); 795 DoXfer();
791 } 796 }
792 return TRUE; 797 return TRUE;
793} 798}
794 799
795CRRQSocket::CRRQSocket(CPumpKINDlg *daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN *sin) 800CRRQSocket::CRRQSocket(CPumpKINDlg *daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN *sin)
796 : CXferSocket(daddy,fileName,type,sin) 801 : CXferSocket(daddy,fileName,type,sin)
797{ 802{
798 m_ACK=0; 803 m_ACK=0;
799 m_LastSlack=0; 804 m_LastSlack=0;
800} 805}
801 806
802UINT tftp::tftpERROR::tftpSize(LPCTSTR msg) 807UINT tftp::tftpERROR::tftpSize(LPCTSTR msg)
803{ 808{
804 return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpERROR::tftpErrorCode)+strlen(msg)+1; 809 return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpERROR::tftpErrorCode)+strlen(msg)+1;
@@ -857,53 +862,51 @@ tftp *p = tftp::Allocate(tftp::tftpDATA::tftpSize(m_blkSize));
857 state=stateClosing; m_ACKtoClose = m_ACK+1; 862 state=stateClosing; m_ACKtoClose = m_ACK+1;
858 } 863 }
859 }CATCH(CFileException,e){ 864 }CATCH(CFileException,e){
860 Deny(e); 865 Deny(e);
861 }END_CATCH 866 }END_CATCH
862} 867}
863 868
864UINT tftp::tftpDATA::tftpSize(UINT blkSize) 869UINT tftp::tftpDATA::tftpSize(UINT blkSize)
865{ 870{
866 return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpDATA) 871 return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpDATA)
867 -sizeof(BYTE)+blkSize; 872 -sizeof(BYTE)+blkSize;
868} 873}
869 874
870void CXferSocket::Deny(CFileException* e) 875void CXferSocket::Deny(CFileException* e)
871{ 876{
872 PostError(e); 877 PostError(e);
873 state=stateDeny; 878 state=stateDeny;
874} 879}
875 880
876void CXferSocket::PostError(UINT errCode,UINT errID) 881void CXferSocket::PostError(UINT errCode,UINT errID)
877{ 882{
878CString msg; 883CString msg;
879 msg.LoadString(errID); 884 msg.LoadString(errID);
880 ASSERT(m_Daddy); 885 ASSERT(m_Daddy);
881 /*// ***
882CString tmp; 886CString tmp;
883 tmp.Format(IDS_LOG_SENTTFTPERROR,errCode,(LPCTSTR)msg); 887 tmp.Format(IDS_LOG_SENTTFTPERROR,errCode,(LPCTSTR)msg);
884 m_Daddy->LogLine(tmp); 888 m_Daddy->LogLine(tmp);
885 */
886tftp* err = tftp::Allocate(tftp::tftpERROR::tftpSize(msg)); 889tftp* err = tftp::Allocate(tftp::tftpERROR::tftpSize(msg));
887err->SetOpcode(tftp::opERROR); 890err->SetOpcode(tftp::opERROR);
888 err->errSet(errCode,msg); 891 err->errSet(errCode,msg);
889 PostTFTP(err); 892 PostTFTP(err);
890} 893}
891 894
892void CXferSocket::PostError(CFileException* e) 895void CXferSocket::PostError(CFileException* e)
893{ 896{
894UINT eCode; 897UINT eCode;
895UINT eMsgID; 898UINT eMsgID;
896 switch(e->m_cause){ 899 switch(e->m_cause){
897 case CFileException::fileNotFound: 900 case CFileException::fileNotFound:
898 eCode=tftp::errNotFound; 901 eCode=tftp::errNotFound;
899 eMsgID=IDS_TFTP_ERROR_NOTFOUND; 902 eMsgID=IDS_TFTP_ERROR_NOTFOUND;
900 break; 903 break;
901 case CFileException::accessDenied: 904 case CFileException::accessDenied:
902 eCode=tftp::errAccessViolation; 905 eCode=tftp::errAccessViolation;
903 eMsgID=IDS_TFTP_ERROR_ACCESS; 906 eMsgID=IDS_TFTP_ERROR_ACCESS;
904 break; 907 break;
905 case CFileException::directoryFull: 908 case CFileException::directoryFull:
906 eCode=tftp::errDiskFull; 909 eCode=tftp::errDiskFull;
907 eMsgID=IDS_TFTP_ERROR_DIRFULL; 910 eMsgID=IDS_TFTP_ERROR_DIRFULL;
908 break; 911 break;
909 case CFileException::sharingViolation: 912 case CFileException::sharingViolation: