*********************************************************************
*
* I255603
*
* TCP/IP Password Server
*
* Written by William van den Heuvel, 1998
*
* Update: 1998-11-10
*
*********************************************************************
*
* This program is a TCP/IP server that listens on port x.
*
* It provides Password services submitted by the client program.
* The client is a program that may run on any platform that
* supports TCP/IP.
* The client program submits the request by sending a TCP/IP message
* to port x. The server listens on this port and returns a reply.
*
***********************************************************************
*
* this program uses the EZASMI assembler macro API:
* EZASMI TYPE=SOCKET - open server socket
* EZASMI TYPE=CLOSE - close server socket
*
***********************************************************************
*
* on entry,
* register 1 points to the API parameters.
*
*......................................................................
*
* on completion,
* register 15 will contain a return code (RC):
*
* RC=0 - normal completion (always)
*
***********************************************************************
**********************************************************************
*
I255603 CSECT
I255603 AMODE ANY
I255603 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,'I255603: 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
*
***********************************************************************
***********************************************************************
*
* open server socket
*
* The server socket is the connection between the server program
* and the TCP/IP system. The server socket will remain open
* during the life of this server program.
*
* The server socket is not to be confused with the client
* socket, which will be obtained later by ACCEPT and which lasts
* only during the life of the connection with the client.
*
E100 EQU *
LEMTRACE 0,'I255603: SOCKET'
*
EZASMI TYPE=SOCKET, X
AF='INET', TCP/IP protocol X
SOCTYPE='STREAM', TCP/IP protocol X
TASK=(TIE), TASK storage (TIE) X
RETCODE=DSA_RETCODE, return code (0 or -1) X
ERRNO=DSA_ERRNO, error number (if RETCODE = -1) X
ERROR=E110 if API error occurs
B E120
*
*......................................................................
*
* SOCKET failed (ERROR exit)
E110 EQU *
LEMTRACE 0,'I255603: SOCKET failed - ERROR exit'
B X100
*
*......................................................................
*
* if RETCODE is -1 (error) then ERRNO contains the error code
* else RETCODE contains the socket descriptor
E120 EQU *
*
* error?
L R15,DSA_RETCODE R15 = RETCODE
C R15,=F'-1' RETCODE = -1?
BNE E130 no; successful
*
*......................................................................
*
* unsuccessful
* ERRNO contains the error code
LEMTRACE 0,'I255603: SOCKET failed - ERRNO=',(DSA_ERRNO,4,B)
B X100
*
*......................................................................
*
* successful
E130 EQU *
*
* save socket descriptor
* R15 contains the socket descriptor (bits 16-31)
STCM R15,B'0011',API_SERVER_SOCKET
*
*......................................................................
*
* TRACE
LEMTRACE 0,'I255603: Server SOCKET=',(API_SERVER_SOCKET,2,B)
*
***********************************************************************
***********************************************************************
*
* call I255604 passing API
*
LR R1,API
L R15,=V(I255604)
BASR R14,R15
*
***********************************************************************
***********************************************************************
*
* close server socket
*
F100 EQU *
LEMTRACE 0,'I255603: CLOSE'
*
* The socket number of the server is in API_SERVER_SOCKET
*
EZASMI TYPE=CLOSE, X
TASK=(TIE), TASK storage (TIE) X
S=API_SERVER_SOCKET, server socket X
RETCODE=DSA_RETCODE, return code (0 or -1) X
ERRNO=DSA_ERRNO, error number (if RETCODE = -1) X
ERROR=F110 if API error occurs
B F120
*
*......................................................................
*
* CLOSE failed (ERROR exit)
F110 EQU *
LEMTRACE 0,'I255603: close failed - ERROR exit'
B X100
*
*......................................................................
*
* if RETCODE is -1 (error) then ERRNO contains the error code
* else RETCODE contains the socket descriptor
F120 EQU *
*
* error?
L R15,DSA_RETCODE R15 = RETCODE
C R15,=F'-1' RETCODE = -1?
BNE F130 no; successful
*
*......................................................................
*
* unsuccessful
* ERRNO contains the error code
LEMTRACE 0,'I255603: CLOSE failed - ERRNO=',(DSA_ERRNO,4,B)
B X100
*
*......................................................................
*
* successful
F130 EQU *
*
* CLEAR socket descriptor
XR R15,R15
STCM R15,B'0011',API_SERVER_SOCKET
*
*......................................................................
*
* TRACE
LEMTRACE 0,'I255603: Server SOCKET=',(API_SERVER_SOCKET,2,B)
*
***********************************************************************
**********************************************************************
*
* return to caller
X100 EQU *
LEMTRACE 0,'I255603: exit'
LEMEXIT
*
*********************************************************************
**********************************************************************
*
* 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)
*
*......................................................................
*
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 I25560:
API_BIND_IP DS XL4 IP-address to listen on (0.0.0.0 means "any")
API_BIND_PORT DS H port number to listen on (0 means "any")
API_MAXSOC DS H maximum number of sockets for INITAPI
API_BACKLOG DS F backlog queue incoming connections for LISTEN
*
*......................................................................
*
* following fields are set by I255601:
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 I255602:
API_LOCAL_IP DS XL4 IP-address of server from GETHOSTID
API_LOCAL_NAME DS CL26 local hostname (LL-string) from GETHOSTNAME
*
*......................................................................
*
* following fields are set by I255603:
API_SERVER_SOCKET DS H server socket number from SOCKET
*
***********************************************************************
END