-rw-r--r-- | PumpKINDlg.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/PumpKINDlg.cpp b/PumpKINDlg.cpp index fc24596..b6b8a36 100644 --- a/PumpKINDlg.cpp +++ b/PumpKINDlg.cpp | |||
@@ -912,67 +912,71 @@ BOOL rv = TRUE; | |||
912 | if(!m_timeOut){// *** More sanity checks | 912 | if(!m_timeOut){// *** More sanity checks |
913 | Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT); | 913 | Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT); |
914 | rv = TRUE; | 914 | rv = TRUE; |
915 | break; | 915 | break; |
916 | } | 916 | } |
917 | } | 917 | } |
918 | if(o.Lookup(tftpoXResume,v)){ | 918 | if(o.Lookup(tftpoXResume,v)){ |
919 | m_ACK=atoi(v); | 919 | m_ACK=atoi(v); |
920 | } | 920 | } |
921 | } | 921 | } |
922 | UpdateList(); | 922 | UpdateList(); |
923 | DoXfer(); | 923 | DoXfer(); |
924 | } | 924 | } |
925 | break; | 925 | break; |
926 | case tftp::opACK: | 926 | case tftp::opACK: |
927 | m_ACK=p->data.m_ACK.Block(); | 927 | m_ACK=p->data.m_ACK.Block(); |
928 | if(state!=stateFinish){ | 928 | if(state!=stateFinish){ |
929 | UpdateList(); | 929 | UpdateList(); |
930 | DoXfer(); | 930 | DoXfer(); |
931 | } | 931 | } |
932 | break; | 932 | break; |
933 | case tftp::opERROR: | 933 | case tftp::opERROR: |
934 | { | 934 | { |
935 | ASSERT(m_Daddy); | 935 | ASSERT(m_Daddy); |
936 | CString tmp; | 936 | CString tmp; |
937 | tmp.Format(IDS_LOG_GOTTFTPERROR,p->data.m_ERROR.Code(),(LPCTSTR)p->errMessage()); | 937 | tmp.Format(IDS_LOG_GOTTFTPERROR,p->data.m_ERROR.Code(),(LPCTSTR)p->errMessage()); |
938 | m_Daddy->LogLine(tmp); | 938 | m_Daddy->LogLine(tmp); |
939 | } | 939 | } |
940 | Destroy(FALSE); | 940 | Destroy(FALSE); |
941 | rv = FALSE; | 941 | rv = FALSE; |
942 | break; | 942 | break; |
943 | default: | 943 | default: |
944 | ASSERT(m_Daddy); | 944 | { |
945 | m_Daddy->LogLine(IDS_LOG_XFEROPCODE); | 945 | ASSERT(m_Daddy); |
946 | // *** Self destruct maybe?? | 946 | CString tmp; |
947 | tmp.Format(IDS_LOG_XFEROPCODE,p->Opcode()); | ||
948 | m_Daddy->LogLine(tmp); | ||
949 | // *** Self destruct maybe?? | ||
950 | } | ||
947 | break; | 951 | break; |
948 | } | 952 | } |
949 | return rv; | 953 | return rv; |
950 | } | 954 | } |
951 | 955 | ||
952 | BOOL CWRQSocket::OnTFTP(tftp* p) | 956 | BOOL CWRQSocket::OnTFTP(tftp* p) |
953 | { | 957 | { |
954 | switch(p->Opcode()){ | 958 | switch(p->Opcode()){ |
955 | case tftp::opOACK: | 959 | case tftp::opOACK: |
956 | ASSERT(state!=stateFinish); | 960 | ASSERT(state!=stateFinish); |
957 | { | 961 | { |
958 | if(m_bResume) | 962 | if(m_bResume) |
959 | m_ACK=m_File.GetLength()/m_blkSize; | 963 | m_ACK=m_File.GetLength()/m_blkSize; |
960 | else | 964 | else |
961 | m_ACK=0; | 965 | m_ACK=0; |
962 | tftp::tftpOptions o; | 966 | tftp::tftpOptions o; |
963 | if(p->GetOptions(&o)){ | 967 | if(p->GetOptions(&o)){ |
964 | CString v; | 968 | CString v; |
965 | if(o.Lookup(tftpoBSize,v)){ | 969 | if(o.Lookup(tftpoBSize,v)){ |
966 | m_blkSize=atoi(v); | 970 | m_blkSize=atoi(v); |
967 | if(!m_blkSize){// *** More sanity checks | 971 | if(!m_blkSize){// *** More sanity checks |
968 | Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE); | 972 | Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE); |
969 | return TRUE; | 973 | return TRUE; |
970 | } | 974 | } |
971 | } | 975 | } |
972 | if(o.Lookup(tftpoTOut,v)){ | 976 | if(o.Lookup(tftpoTOut,v)){ |
973 | m_timeOut=atoi(v); | 977 | m_timeOut=atoi(v); |
974 | if(!m_timeOut){// *** More sanity checks | 978 | if(!m_timeOut){// *** More sanity checks |
975 | Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT); | 979 | Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT); |
976 | return TRUE; | 980 | return TRUE; |
977 | } | 981 | } |
978 | } | 982 | } |
@@ -992,67 +996,71 @@ BOOL CWRQSocket::OnTFTP(tftp* p) | |||
992 | int bytes = p->length-sizeof(p->data.m_DATA.block)-(tftpHdrSize-tftpSlackSize); | 996 | int bytes = p->length-sizeof(p->data.m_DATA.block)-(tftpHdrSize-tftpSlackSize); |
993 | if(bytes){ | 997 | if(bytes){ |
994 | m_File.Write(p->data.m_DATA.data,bytes); | 998 | m_File.Write(p->data.m_DATA.data,bytes); |
995 | // *** Move to the other place where we can do it not that often | 999 | // *** Move to the other place where we can do it not that often |
996 | m_File.SetLength(m_File.GetPosition()); | 1000 | m_File.SetLength(m_File.GetPosition()); |
997 | } | 1001 | } |
998 | if(bytes<m_blkSize){ | 1002 | if(bytes<m_blkSize){ |
999 | state=stateFinish; | 1003 | state=stateFinish; |
1000 | ASSERT(m_Daddy); | 1004 | ASSERT(m_Daddy); |
1001 | CString tmp; | 1005 | CString tmp; |
1002 | tmp.Format(IDS_LOG_XFERWRQFINISHED,(LPCTSTR)m_FileName); | 1006 | tmp.Format(IDS_LOG_XFERWRQFINISHED,(LPCTSTR)m_FileName); |
1003 | m_Daddy->LogLine(tmp); | 1007 | m_Daddy->LogLine(tmp); |
1004 | } | 1008 | } |
1005 | m_ACK=block; | 1009 | m_ACK=block; |
1006 | m_LastSlack=m_blkSize-bytes; | 1010 | m_LastSlack=m_blkSize-bytes; |
1007 | UpdateList(); | 1011 | UpdateList(); |
1008 | DoXfer(); | 1012 | DoXfer(); |
1009 | }CATCH(CFileException,e){ | 1013 | }CATCH(CFileException,e){ |
1010 | Deny(e); | 1014 | Deny(e); |
1011 | }END_CATCH | 1015 | }END_CATCH |
1012 | } | 1016 | } |
1013 | break; | 1017 | break; |
1014 | case tftp::opERROR: | 1018 | case tftp::opERROR: |
1015 | { | 1019 | { |
1016 | ASSERT(m_Daddy); | 1020 | ASSERT(m_Daddy); |
1017 | CString tmp; | 1021 | CString tmp; |
1018 | tmp.Format(IDS_LOG_GOTTFTPERROR,p->data.m_ERROR.Code(),(LPCTSTR)p->errMessage()); | 1022 | tmp.Format(IDS_LOG_GOTTFTPERROR,p->data.m_ERROR.Code(),(LPCTSTR)p->errMessage()); |
1019 | m_Daddy->LogLine(tmp); | 1023 | m_Daddy->LogLine(tmp); |
1020 | } | 1024 | } |
1021 | Destroy(FALSE); | 1025 | Destroy(FALSE); |
1022 | return FALSE; | 1026 | return FALSE; |
1023 | default: | 1027 | default: |
1024 | ASSERT(m_Daddy); | 1028 | { |
1025 | m_Daddy->LogLine(IDS_LOG_XFEROPCODE); | 1029 | ASSERT(m_Daddy); |
1026 | // *** Self destruct maybe?? | 1030 | CString tmp; |
1031 | tmp.Format(IDS_LOG_XFEROPCODE,p->Opcode()); | ||
1032 | m_Daddy->LogLine(tmp); | ||
1033 | // *** Self destruct maybe?? | ||
1034 | } | ||
1027 | break; | 1035 | break; |
1028 | } | 1036 | } |
1029 | return TRUE; | 1037 | return TRUE; |
1030 | } | 1038 | } |
1031 | 1039 | ||
1032 | void tftp::SetOpcode(WORD op) | 1040 | void tftp::SetOpcode(WORD op) |
1033 | { | 1041 | { |
1034 | opcode = REVERSEBYTES(op); | 1042 | opcode = REVERSEBYTES(op); |
1035 | } | 1043 | } |
1036 | void tftp::tftpDATA::SetBlock(WORD b) | 1044 | void tftp::tftpDATA::SetBlock(WORD b) |
1037 | { | 1045 | { |
1038 | block=REVERSEBYTES(b); | 1046 | block=REVERSEBYTES(b); |
1039 | } | 1047 | } |
1040 | WORD tftp::tftpDATA::Block() | 1048 | WORD tftp::tftpDATA::Block() |
1041 | { | 1049 | { |
1042 | return REVERSEBYTES(block); | 1050 | return REVERSEBYTES(block); |
1043 | } | 1051 | } |
1044 | WORD tftp::tftpACK::Block() | 1052 | WORD tftp::tftpACK::Block() |
1045 | { | 1053 | { |
1046 | return REVERSEBYTES(block); | 1054 | return REVERSEBYTES(block); |
1047 | } | 1055 | } |
1048 | void tftp::tftpACK::SetBlock(WORD b) | 1056 | void tftp::tftpACK::SetBlock(WORD b) |
1049 | { | 1057 | { |
1050 | block = REVERSEBYTES(b); | 1058 | block = REVERSEBYTES(b); |
1051 | } | 1059 | } |
1052 | WORD tftp::tftpERROR::Code() | 1060 | WORD tftp::tftpERROR::Code() |
1053 | { | 1061 | { |
1054 | return REVERSEBYTES(code); | 1062 | return REVERSEBYTES(code); |
1055 | } | 1063 | } |
1056 | void tftp::tftpERROR::SetCode(WORD c) | 1064 | void tftp::tftpERROR::SetCode(WORD c) |
1057 | { | 1065 | { |
1058 | code = REVERSEBYTES(c); | 1066 | code = REVERSEBYTES(c); |