Source code of HPW routine I255612

Client program that runs on Host

 

*********************************************************************
*
*                                I255612
*
*                        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=GETHOSTID   - get IP-address of local host
* EZASMI TYPE=GETHOSTNAME - get hostname  of local host
*
***********************************************************************
*
* on entry,
* register 1 points to the API parameters.
*
*......................................................................
*
* on completion,
* register 15 will contain a return code (RC):
*
* RC=0 - normal completion (always)
*
***********************************************************************




**********************************************************************
*
I255612  CSECT
I255612  AMODE ANY
I255612  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,'I255612: 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
*
***********************************************************************






***********************************************************************
*
*        get IP-address of our own local host
*
C100     EQU   *
         LEMTRACE 0,'I255612: GETHOSTID'
*
*......................................................................
*
*        get input parameters for GETHOSTID
*        (none)
*
*......................................................................
*
         EZASMI TYPE=GETHOSTID,                                        X
               TASK=(TIE),            TASK storage (TIE)               X
               RETCODE=DSA_RETCODE,   -1 (error) or IP-address         X
               ERROR=C110             if API error occurs
         B     C120
*
*......................................................................
*
*        GETHOSTID failed (ERROR exit)
C110     EQU   *
         LEMTRACE 8,'I255612: GETHOSTID failed - ERROR exit'
         B     X100
*
*......................................................................
*
*        if RETCODE is -1 (error) then there is no IP-address
*        else RETCODE contains the IP-address of our own local host
*
*        error?
C120     EQU   *
         L    R15,DSA_RETCODE    R15 = RETCODE
         C    R15,=F'-1'         RETCODE = -1?
         BNE  C130               no; successful
*
*......................................................................
*
*        unsuccessful
         LEMTRACE 8,'I255612: GETHOSTID failed - RETCODE=-1'
         B     X100
*
*......................................................................
*
*        successful - get output from GETHOSTID
C130     EQU   *
         LEMTRACE 0,'I255612: GETHOSTID succesful'
*
*        save IP-address of server (local host)
*        RETCODE contains the IP-address
         MVC  API_LOCAL_IP,DSA_RETCODE
*
*......................................................................
*
*        TRACE:
         XR   2,2
         IC   2,API_LOCAL_IP+0
         XR   3,3
         IC   3,API_LOCAL_IP+1
         XR   4,4
         IC   4,API_LOCAL_IP+2
         XR   5,5
         IC   5,API_LOCAL_IP+3
*
         LEMTRACE 4,'I255612: LOCAL_IP=',                              X
               (2,B),'.',(3,B),'.',(4,B),'.',(5,B)
*
***********************************************************************






***********************************************************************
*
*        get hostname of our own local host
*
D100     EQU   *
         LEMTRACE 0,'I255612: GETHOSTNAME'
*
*        get input parameters for GETHOSTNAME
         MVC   DSA_HOST_NAMELEN,=F'24'     maximum length of hostname
         MVC   DSA_HOST_NAME(24),=CL24' '  blank hostname
*
         EZASMI TYPE=GETHOSTNAME,                                      X
               TASK=(TIE),                 TASK storage (TIE)          X
               NAME=DSA_HOST_NAME,         own local hostname          X
               NAMELEN=DSA_HOST_NAMELEN,   length of hostname          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
*
*......................................................................
*
*        GETHOSTNAME failed (ERROR exit)
D110     EQU   *
         LEMTRACE 8,'I255612: GETHOSTNAME 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,'I255612: GETHOSTNAME failed - ERRNO=',            X
               (DSA_ERRNO,4,B)
         B     X100
*
*......................................................................
*
*        successful - get output parameters from GETHOSTNAME
D130     EQU   *
*
*        DSA_HOST_NAME    contains the hostname
*        DSA_HOST_NAMELEN contains the length of the hostname
*
*        TRACE:
         LEMTRACE 0,'I255612: HOST_NAMELEN=',(DSA_HOST_NAMELEN,4,X)
         LEMTRACE 0,'I255612: HOST_NAME=',(DSA_HOST_NAME,24,X)
*
*        Note:
*        DSA_HOST_NAMELEN still contains the maximum length (24)
*        and not the actual length of the hostname in DSA_HOST_NAME
*        The name in DSA_HOST_NAME is padded with nulls (not blanks)
*
*        compute actual length of hostname
         LA     R1,DSA_HOST_NAME
         L      R15,DSA_HOST_NAMELEN
D131     CLI    0(R1),X'00'
         BE     D132
         LA     R1,1(R1)
         BCT    R15,D131
D132     EQU    *
         LA     R15,DSA_HOST_NAME
         SR     R1,R15                   R15 = length of hostname
         ST     R1,DSA_HOST_NAMELEN
*
*        copy hostname to API_LOCAL_NAME
*        API_LOCAL_NAME is an LL-string
         L      R1,DSA_HOST_NAMELEN
         STCM   R1,B'0011',API_LOCAL_NAME
         MVC    API_LOCAL_NAME+2(24),DSA_HOST_NAME
*
*......................................................................
*
*        TRACE:
         LEMTRACE 4,'I255612: LOCAL_NAME=',(API_LOCAL_NAME,LL)
*
***********************************************************************




***********************************************************************
*
*        call I255613 passing API
*
         LR    R1,API
         L     R15,=V(I255613)
         BASR  R14,R15
*
***********************************************************************






**********************************************************************
*
*        return to caller
X100     EQU *
         LEMTRACE 0,'I255612: 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)
*
DSA_HOST_NAMELEN    DS  F    length of following hostname
DSA_HOST_NAME       DS  CL24 hostname
*
*......................................................................
*
              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
*
***********************************************************************
        END