********************************************************************* * * I255615 * * TCP/IP Password Client * * Written by William van den Heuvel, 1998 * * Update: 1998-11-10 * ********************************************************************* * * this program uses the EZASMI assembler macro API: * EZASMI TYPE=WRITE - send request mesage to server * EZASMI TYPE=READ - receive reply message from server * *********************************************************************** * * on entry, * register 1 points to the API parameters. * *...................................................................... * * on completion, * register 15 will contain a return code (RC): * * RC=0 - normal completion (always) * *********************************************************************** ********************************************************************** * I255615 CSECT I255615 AMODE ANY I255615 RMODE ANY * R0 EQU 0 R1 EQU 1 R2 EQU 2 R3 EQU 3 R4 EQU 4 R5 EQU 5 R6 EQU 6 R7 EQU 7 R8 EQU 8 R9 EQU 9 R10 EQU 10 PARM - address of pointer to PARM-string) R11 EQU 11 BASE - base register of this program R12 EQU 12 CAA - reserved for LE R13 EQU 13 DSA - Dynamic Storage Area R14 EQU 14 return address R15 EQU 15 entry point address * DSA EQU R13 CAA EQU R12 BASE EQU R11 API EQU R10 API parameters GWA EQU R9 GLOBAL storage TIE EQU R8 TASK storage * USING API_DSECT,API USING DSA_DSECT,DSA USING GWA_DSECT,GWA USING TIE_DSECT,TIE * ********************************************************************* ********************************************************************* * LEMENTRY BASE=BASE,LENGTH=DSA_DSECT_LENGTH,PARAM=API,TRACE=0 * * note: * API -> API_DSECT * DSA -> DSA_DSECT * *********************************************************************** LEMTRACE 0,'I255615: entry' *********************************************************************** * * get GLOBAL storage (GWA) L GWA,API_GWA get pointer to GWA * * get TASK storage (TIE) L TIE,API_TIE get pointer to TIE * *********************************************************************** *********************************************************************** * * make request message A100 EQU * * *...................................................................... * * get message MVC DSA_REQUEST_LENGTH,REQUEST_LENGTH MVC DSA_REQUEST_MESSAGE,REQUEST_MESSAGE * *...................................................................... * * trace request message (EBCDIC) L 2,DSA_REQUEST_LENGTH LEMTRACE 4,'I255615: request: ',(DSA_REQUEST_MESSAGE,(2),C) * *...................................................................... * * translate request message from EBCDIC to ISO-8859-1 L R1,DSA_REQUEST_LENGTH LA R2,DSA_REQUEST_MESSAGE EX R1,A110 execute TR instruction at A110 B A120 * * the length of the first operand is supplied in R1 A110 TR 0(0,R2),ISO_8859_1 * *...................................................................... * * trace request message (ISO-8859-1) A120 EQU * L 2,DSA_REQUEST_LENGTH LEMTRACE 0,'I255615: ISO-8859-1: ',(DSA_REQUEST_MESSAGE,(2),X) * *********************************************************************** *********************************************************************** * * WRITE request message to server * B100 EQU * LEMTRACE 0,'I255615: WRITE' * EZASMI TYPE=WRITE, X TASK=(TIE), TASK storage (TIE) X S=API_SOCKET, socket X NBYTE=DSA_REQUEST_LENGTH, request message length X BUF=DSA_REQUEST_MESSAGE, request message X RETCODE=DSA_RETCODE, -1 (error) or 0 (successful) X ERRNO=DSA_ERRNO, error number (if RETCODE = -1) X ERROR=B110 if API error occurs B B120 * *...................................................................... * * WRITE failed (ERROR exit) B110 EQU * LEMTRACE 8,'I255615: WRITE failed - ERROR exit' B X100 * *...................................................................... * * if DSA_RETCODE is -1 then DSA_ERRNO contains the error code B120 EQU * * L R15,DSA_RETCODE R15 = RETCODE C R15,=F'-1' RETCODE = -1? BNE B130 no; successful * *...................................................................... * * unsuccessful * DSA_ERRNO contains the error code LEMTRACE 8,'I255615: WRITE failed - ERRNO=',(DSA_ERRNO,4,B) B X100 * *...................................................................... * * successful B130 EQU * LEMTRACE 0,'I255615: WRITE successful' * *********************************************************************** *********************************************************************** * * READ reply message from server * D100 EQU * LEMTRACE 0,'I255615: READ' * XC DSA_REPLY_MESSAGE,DSA_REPLY_MESSAGE * EZASMI TYPE=READ, X TASK=(TIE), TASK storage (TIE) X S=API_SOCKET, socket X NBYTE=REPLY_BUFFER_LENGTH, reply buffer length X BUF=DSA_REPLY_MESSAGE, reply buffer X RETCODE=DSA_RETCODE, -1 (error) or 0 (successful) X ERRNO=DSA_ERRNO, error number (if RETCODE = -1) X ERROR=D110 if API error occurs B D120 * *...................................................................... * * READ failed (ERROR exit) D110 EQU * LEMTRACE 8,'I255615: READ failed - ERROR exit' B X100 * *...................................................................... * * if DSA_RETCODE is -1 then DSA_ERRNO contains the error code D120 EQU * * L R15,DSA_RETCODE R15 = RETCODE C R15,=F'-1' RETCODE = -1? BNE D130 no; successful * *...................................................................... * * unsuccessful * DSA_ERRNO contains the error code LEMTRACE 8,'I255615: READ failed - ERRNO=',(DSA_ERRNO,4,B) B X100 * *...................................................................... * * successful D130 EQU * LEMTRACE 0,'I255615: READ successful' * * get length of received reply * RETCODE contains the number of bytes received MVC DSA_REPLY_LENGTH,DSA_RETCODE * * if REPLY_LENGTH = 0 then the connection is cosed without data * if REPLY_LENGTH > 0 then we have received data * * check if we have received data L R15,DSA_REPLY_LENGTH LTR R15,R15 any data? BNZ D140 yes * * connection was cosed without any data LEMTRACE 8,'I255615: no reply received (connection closed)' B X100 * *...................................................................... * * reply message received D140 EQU * L 2,DSA_REPLY_LENGTH LEMTRACE 0,'I255615: ISO-8859-1: ',(DSA_REPLY_MESSAGE,(2),X) * * translate reply message from ISO-8859-1 to EBCDIC L R1,DSA_REPLY_LENGTH LA R2,DSA_REPLY_MESSAGE EX R1,D141 execute TR instruction B D142 * * the length of the first operand is supplied in R1 D141 TR 0(0,R2),EBCDIC * *.....................................................................s * * trace reply message (EBCDIC) D142 EQU * L 2,DSA_REPLY_LENGTH LEMTRACE 4,'I255615: reply: ',(DSA_REPLY_MESSAGE,(2),C) * *********************************************************************** ********************************************************************** * * return to caller X100 EQU * LEMTRACE 0,'I255615: exit' LEMEXIT * ********************************************************************* ********************************************************************** * * translation table from ISO-8859-1 to EBCDIC * EBCDIC EQU * * .0.1.2.3.4.5.6.7.8.9.A.B.C.D.E.F DC X'000102030405060708090A0B0C0D0E0F' 0. DC X'101112131415161718191A1B1C1D1E1F' 1. DC X'40217F7B5B6C507D4D5D5C4E6B604B61' 2. DC X'F0F1F2F3F4F5F6F7F8F97A5E4D7E6E6F' 3. DC X'7CC1C2C3C4C5C6C7C8C9D1D2D3D4D5D6' 4. DC X'D7D8D9E2E3E4E5E6E7E8E95BE05D5E6D' 5. DC X'79818283848586878889919293949596' 6. DC X'979899A2A3A4A5A6A7A8A9C07CD07E7F' 7. DC X'808182838485868788898A8B8C8D8E8F' 8. DC X'909192939495969798999A9B9C9D9E9F' 9. DC X'A0A1A2B1A4A56AA7A8B4AA8AACADAEAF' A. DC X'908FB2B3B4B5B6B7B8B9BA8BBCBDBEBF' B. DC X'6465626663679E687471727378757677' C. DC X'D069EDEEEBEFECD7FBFDFEDBFCDDDE59' D. DC X'E0E1E2E343E5E6E754515253ECEDEEEF' E. DC X'8CF1CDCECBCFCCF7F8F9DEDBDCDDFEDF' F. * .0.1.2.3.4.5.6.7.8.9.A.B.C.D.E.F * ********************************************************************* ********************************************************************** * * translation table from EBCDIC to ISO-8859-1 * ISO_8859_1 EQU * * .0.1.2.3.4.5.6.7.8.9.A.B.C.D.E.F DC X'000102030405060708090A0B0C0D0E0F' 0. DC X'101112131415161718191A1B1C1D1E1F' 1. DC X'202122232425262728292A2B2C2D2E2F' 2. DC X'303132333435363738393A3B3C3D3E3F' 3. DC X'204142E44445464748494A2E3C282B4F' 4. DC X'26E9EAEBE855565758DF5A242A293B5F' 5. DC X'2D2FC2C4C0C1C3C5C7D1A62C255F3E3F' 6. DC X'70C9CACBC8CDCECFCC603A2340273D22' 7. DC X'80616263646566676869ABBBF08D8EB1' 8. DC X'B06A6B6C6D6E6F7071729A9B9C9DC69F' 9. DC X'A0A1737475767778797AAAABACADAEAF' A. DC X'B0A3B2B3A9B5B6B7B8B9BABBBCBDBEBF' B. DC X'7B414243444546474849CAF4F6F2F3F5' C. DC X'7D4A4B4C4D4E4F505152DAFBFCFDFAFF' D. DC X'5CE1535455565758595AEAD4D6D2D3D5' E. DC X'30313233343536373839FAD8DCD9DAFF' F. * .0.1.2.3.4.5.6.7.8.9.A.B.C.D.E.F * ********************************************************************* REQUEST_LENGTH DC A(REQUEST_MESSAGE_END-REQUEST_MESSAGE) REQUEST_MESSAGE DC C'VERIFY x010003 cde3vfr4' ***REQUEST_MESSAGE DC CL8'SHUTDOWN' REQUEST_MESSAGE_END EQU * REPLY_BUFFER_LENGTH DC F'80' ********************************************************************** * * GWA Global Work Area * GWA_DSECT EZASMI TYPE=GLOBAL,STORAGE=DSECT * ********************************************************************* ********************************************************************** * * TIE Task Work Area * TIE_DSECT EZASMI TYPE=TASK,STORAGE=DSECT * ********************************************************************* *********************************************************************** * * DSA - Dynamic Storage Area (pointed to by register 13) * DSA_DSECT LEMDSA * *...................................................................... * DSA_RETCODE DS F return code * 0 = successful * -1 = check ERRNO for error code * DSA_ERRNO DS F error code (only if RETCODE=-1) * *...................................................................... * DSA_REQUEST_LENGTH DS F DSA_REQUEST_MESSAGE DS CL100 * *...................................................................... * DSA_REPLY_LENGTH DS F DSA_REPLY_MESSAGE DS CL100 * *...................................................................... * DS 0D D-align what follows DSA_DSECT_LENGTH EQU *-DSA_DSECT * *********************************************************************** * * API - parameters passed between modules * this dsect is address via register API * API_DSECT DSECT * *...................................................................... * * following fields are set by I25561: API_MAXSOC DS H maximum number of sockets for INITAPI API_CONNECT_IP DS XL4 IP-address of server for CONNECT API_CONNECT_PORT DS H port number of server for CONNECT * *...................................................................... * * following fields are set by I255611: API_GWA DS A pointer to GLOBAL storage for EZASMI macro API_TIE DS A pointer to TASK storage for EZASMI macro API_MAXSNO DS H highest socket number from INITAPI DS H unused * *...................................................................... * * following fields are set by I255612: API_LOCAL_IP DS XL4 IP-address of local host from GETHOSTID API_LOCAL_NAME DS CL26 local hostname (LL-string) from GETHOSTNAME * *...................................................................... * * following fields are set by I255613: API_SOCKET DS H socket number from SOCKET * *...................................................................... * * following fields are set by I255614: API_CLIENT_IP DS XL4 client IP adress from GETSOCKETNAME API_CLIENT_PORT DS H client port number from GETSOCKETNAME API_SERVER_IP DS XL4 server IP address from GETPEERNAME API_SERVER_PORT DS H server port number from GETPEERNAME * *********************************************************************** END