Page 1 of 1
MCH1210 in do_iconv_real procedure FTPAPI
Posted: Fri Dec 06, 2024 2:28 pm
by Cinzia
Good morning,
I recently downloaded ftpapi 2.8 and started using it.
I debugged it and got this error:
MCH1210 in the function
dcl-proc do_iconv_real export; present in the FTPTCP member of the QRPGLESRC file.
In particular, I found the error when running:
Code: Select all
rc = iconv( ictbl
: p_inputBuf
: inputLeft
: p_outputBuf
: outputLeft );
I can't understand why I get the error, can you help me?
Re: MCH1210 in do_iconv_real procedure FTPAPI
Posted: Mon Dec 09, 2024 9:23 am
by Cinzia
Hi,
I solved MCH by changing the definition of RC from int(10) to uns(10)
However I have a problem during ftps, the commands are taken correctly, but as soon as "TYPE I" is written the system does not recognize the command.
Checking in debug I see that the RC of the iconv in the do_real_iconv procedure is 4294967295, could this be the problem? Why does it happen?
Code: Select all
0: > USER DCM_ADMIN
0: 331 Enter password.
0: > PASS **********
0: 230 DCM_ADMIN logged on.
0: > PBSZ 0
0: 200 PBSZ accepted.
0: > PROT P
0: 200 PROT accepted.
0: > RCMD CRTSAVF DSCOBJDCMW/WO00050475
0: 250 Command CRTSAVF DSCOBJDCMW/WO00050475 successful.
0: > TYPE I
0: 500 Subcommand not valid.
0: > QUIT
0: 500 Subcommand not valid.
Re: MCH1210 in do_iconv_real procedure FTPAPI
Posted: Mon Dec 09, 2024 3:59 pm
by Scott Klement
Cinzia wrote: Mon Dec 09, 2024 9:23 am
Checking in debug I see that the RC of the iconv in the do_real_iconv procedure is 4294967295, could this be the problem? Why does it happen?
iconv() was designed strangely. It returns uns(10) normally, but for errors return -1. uns(10) means "unsigned", whiuch means it cannot have a negative value. So it is a strange design.
In the C prgoramming language a signed value of -1 is the same as an unsigned value of 4294967295. so if the variable contains 4294967295, you could check it against -1 in C and it would work. In RPG you have to check it against 4294967295, however.
I can fix that, but a bigger question is, why is iconv() failing to begin with?
Re: MCH1210 in do_iconv_real procedure FTPAPI
Posted: Mon Dec 09, 2024 4:07 pm
by Scott Klement
Is is trying to convert the string "TYPE I" from EBCDIC to ASCII to send it to the FTP server. When converting, iconv() is returning ICONV_FAIL, so it is return an empty string '', that's why you see the message "Subcommand <blank> not valid" because TYPE I is now translating to blank.
I can't imagine how that would happen, as TYPE I is entirely made of invariant characters.
Please tell me how I can reproduce this on my own system.
Re: MCH1210 in do_iconv_real procedure FTPAPI
Posted: Tue Dec 10, 2024 8:07 am
by Cinzia
Hi,
this is the debug value:
Code: Select all
EVAL ictbl
ICTBL.RETURN_VALUE = 0
ICTBL.CD(1) = 280
ICTBL.CD(2) = 1208
ICTBL.CD(3) = 0
ICTBL.CD(4) = 0
ICTBL.CD(5) = 0
ICTBL.CD(6) = 0
ICTBL.CD(7) = 0
ICTBL.CD(8) = 33056
ICTBL.CD(9) = -1396812187
ICTBL.CD(10) = -455061503
ICTBL.CD(11) = 0
ICTBL.CD(12) = 0
INP =
....5...10...15...20...25...30...35...40...45...50...55...60
1 'TYPE I '
61 ' '
121 ' '
181 ' '
241 ' '
301 ' '
361 ' '
421 ' '
481 ' '
541 ' '
601 ' '
inputLeft = %len(inp);
p_inputBuf = %addr(inp: *data);
outputLeft = %len(outp: *MAX);
%len(outp) = outputLeft;
p_outputBuf = %addr(outp: *data);
P_INPUTBUF = SPP:C3770B08A6061462
INPUTLEFT = 6
P_OUTPUTBUF = SPP:C3770B08A6062A92
OUTPUTLEFT = 32766
rc = iconv( ictbl
: p_inputBuf
: inputLeft
: p_outputBuf
: outputLeft );
RC = 4294967295
I tried using the SendLine2 procedure instead of the SendLine procedure (so using ToASCII instead of iconv) and in this way the connection occurs correctly.
Re: MCH1210 in do_iconv_real procedure FTPAPI
Posted: Tue Dec 10, 2024 4:51 pm
by Scott Klement
I can't do anything with the debug values of the variables -- I need to be able to reproduce the problem.
Re: MCH1210 in do_iconv_real procedure FTPAPI
Posted: Wed Dec 11, 2024 7:54 am
by Cinzia
Hi,
I enabled only the FTPS connection between two systems in both directions (CHGFTPA ALWSSL(*ONLY)) and set the certificates correctly.
I tested the FTPS in iterative and it works correctly.
These are the steps that the procedure takes:
Code: Select all
WRK_SOCKET = FTP_open(P655.P655RCVSYS : FTP_PORT : 10); //P655.P655RCVSYS -> Name of system target
FTP_login(WRK_SOCKET : LDC_DDMUSR : P091.P091OUTDTA) // -> LDC_DDMUSR and P091OUTDTA are user and password
CALLP FTP_binaryMode(WRK_SOCKET:*ON);
CALLP FTP_passiveMode(WRK_SOCKET:*ON);
FTP_RmtCmd(WRK_SOCKET : WRK_CMCRTF) //WRK_CMCRTF = CRTSAVF DSCOBJDCMW/WO00050521
FTP_put(WRK_SOCKET : WRK_CMPUT1 : WRK_CMPUT2) // WRK_CMPUT1 and WRK_CMPUT2 = /qsys.lib/DSCOBJDCMW.lib/WO00050521.file
FTP_open happens with peTlsMode = FTPS_IMPLICIT and wwPort = 990
Everything up to the FTP_RmtCmd works correctly, the FTP_put fails when it goes to write the "TYPE I" with the iconv
Re: MCH1210 in do_iconv_real procedure FTPAPI
Posted: Wed Dec 11, 2024 3:42 pm
by Scott Klement
I tried your code, and it all worked without problems for me.
Code: Select all
0: FTPAPI version 2.8 released on 2024-09-09
1: 220-QTCP at LOOPBACK.
1: 220 Connection will close if idle more than 5 minutes.
1: > USER SKLEMENT
1: 331 Enter password.
1: > PASS **********
1: 230 SKLEMENT logged on.
1: > RCMD CRTSAVF DSCOBJDCMW/WO00050521
1: 250 Command CRTSAVF DSCOBJDCMW/WO00050521 successful.
1: > TYPE I
1: 200 Representation type is binary IMAGE.
1: > EPSV
1: 229 Entering Extended Passive Mode (|||45685|).
1: > STOR /qsys.lib/DSCOBJDCMW.lib/WO00050521.file