/* REXX */
/* CLS2REXXed by FSOX001 on 10 Oct 2018 at 16:00:40  */
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
Address ISREDIT
 
"MACRO"               /* CACM0012 EDIT TCPPARMS(TCPDATA) */
/*********************************************************************/
/* This EDIT MACRO provides the finding details for ITCP0020 and     */
/* ITCP0025.                                                         */
/*********************************************************************/
/* 08/05/2004 JL.NELSON Added EXIT CODE                              */
/* 08/09/2004 JL.NELSON ADDED comments for PDI checks                */
/* 10/13/2004 JL.NELSON ADDED Manual Review per Charles on           */
/*            NSINTERADDR.                                           */
/* 02/11/2005 JL.NELSON Changed constants to variables before        */
/*            rename.                                                */
/* 03/09/2005 JL.NELSON Changed LMMREP to LMMADD/LMMREP to avoid     */
/*            errors.                                                */
/* 03/29/2005 JL.NELSON Correct syntax error &STIGTXT                */
/* 04/28/2005 JL.NELSON Modified ITCP0020 and ITCP0025(new) per      */
/*            Charles                                                */
/* 06/09/2005 JL.NELSON Pass MAXCC in ZISPFRC variable.              */
/* 07/08/2005 JL.NELSON Changed ITCP0020 numbering.                  */
/* 07/08/2005 JL.NELSON Changed ITCP0025 single and plural           */
/*            noun/verb.                                             */
/* 07/13/2005 JL.NELSON Changed NSINTERADDR statement not used.      */
/* 10/24/2005 JL.NELSON Modified for V511 PDI name changes.          */
/* 03/13/2006 JL.NELSON Set/test RCode for critical ISREDIT          */
/*            commands.                                              */
/* 03/20/2006 JL.NELSON Use NRSTR avoid abend 900 if ampersand in    */
/*            data.                                                  */
/* 03/29/2006 JL.NELSON Test for empty member LINENUM Rcode = 4.     */
/* 04/06/2006 JL.NELSON Pass PARMLIB dataset name for INCLUDE stmts. */
/* 04/17/2006 JL.NELSON Added TRUNC_DATA routine to drop blanks      */
/*            RC=864                                                 */
/* 05/09/2006 JL.NELSON Avoid RC 20 on ISREDIT LINE when " or ' in   */
/*            data.                                                  */
/* 06/28/2007 CL.FENTON Removed Manual Review from ITCP0025, PDI is  */
/*            documentable in VMS.                                   */
/* 03/19/2012 CL.FENTON Removed NSINTERADDR as a required statement  */
/*            for ITCP0020 and N/A if not specified for ITCP0025,    */
/*            CSD-AR003162899.                                       */
/* 05/18/2018 CL.Fenton Added "Not Reviewed" to ITCP0025 for vuls    */
/*            that require additional analysis, STS-019713.          */
/* 10/10/2018 CL.FENTON Converted script from CLIST to REXX.         */
/* 06/11/2021 CL.Fenton Removed automation for ITCP0025, STS-026844. */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CACM0012 06/11/21"
sysprompt = "OFF"                /* CONTROL NOPROMPT          */
sysflush = "OFF"                /* CONTROL NOFLUSH           */
sysasis = "ON"                 /* CONTROL ASIS - caps off   */
return_code = 0
maxcc = 0
max_rc = 0
Address ISPEXEC "CONTROL NONDISPL ENTER"
Address ISPEXEC "CONTROL ERRORS RETURN"
/*******************************************/
/* VARIABLES ARE PASSED TO THIS MACRO      */
/* CONSLIST                                */
/* COMLIST                                 */
/* SYMLIST                                 */
/* TERMMSGS                                */
/*******************************************/
return_code = 0
zerrsm = ""
Address ISPEXEC "VGET (CONSLIST COMLIST SYMLIST TERMMSGS PDIDD ACP",
  "PARMDSN) ASIS"
cm12vget = return_code
If return_code <> 0 then do
  Say pgmname "VGET RC =" return_code zerrsm
  Say pgmname "CONSLIST/"conslist "COMLIST/"comlist,
    "SYMLIST/"symlist "TERMMSGS/"termmsgs
  Say pgmname "PDIDD/"pdidd "ACP/"acp "PARMDSN/"parmdsn
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
If CONSLIST = "ON" | COMLIST = "ON" | SYMLIST = "ON" ,
  then Trace r
 
return_code = 0
/*******************************************/
/* TURN ON MESSAGES                        */
/*******************************************/
syssymlist = symlist          /* CONTROL SYMLIST/NOSYMLIST */
sysconlist = conslist         /* CONTROL CONLIST/NOCONLIST */
syslist    = comlist          /* CONTROL LIST/NOLIST       */
sysmsg     = termmsgs         /* CONTROL MSG/NOMSG         */
/*******************************************/
/* MAIN PROCESS                            */
/*******************************************/
"(MEMBER) = MEMBER"
"(DSNAME) = DATASET"
return_code = 0
"(LASTLINE) = LINENUM .ZLAST"
 
If return_code > 0 then do
  If lastline = 0 then,
    Say pgmname "Empty file RCode =" return_code "DSN="dsname,
      "MEMBER="member zerrsm
  Else,
    Say pgmname "LINENUM Error RCode =" return_code "DSN="dsname,
      "MEMBER="member zerrsm
  SIGNAL ERR_EXIT
  end
call REMOVE_5E_FIRST
 
 
FIND_INCL:
do forever
  "CURSOR = 1 0"
  return_code = 0
  "FIND 'INCLUDE' WORD"
  If return_code <> 0 then leave
  "(ROW,COL) = CURSOR"
  "(DATA) = LINE" row
  parse var data . "INCLUDE" data
  If data <> " " then do
    incdsn = strip(translate(data))
    Say pgmname member "<INCLUDE>" incdsn
    locate = sysdsn("'"incdsn"'")
    If locate <> "OK" &  length(incdsn) < 9 &,
      pos("(",incdsn) = 0 then do
      dsnmbr = parmdsn"("incdsn")"
      locate2 = sysdsn("'"dsnmbr"'")
      If locate2 = "OK" then do
        incdsn = dsnmbr
        locate = locate2
        end
      end
    If locate = "OK" then do
      return_code = 0
      "COPY '"incdsn"' AFTER" row
      If return_code <> 0 then,
        Say pgmname "COPY" incdsn "Failed" retrun_code zerrsm
      end
    Else,
      Say pgmname "LOCATE" incdsn "Failed" locate
    end
  "DELETE" row
  call REMOVE_5E_FIRST
  end
 
"EXCLUDE ALL '"left(" ",80)"' 1 80"
"DELETE ALL X"
 
 
NEXT_1:
return_code = 0
"(LASTLINE) = LINENUM .ZLAST"
If return_code > 0 then do
  If lastline = 0 then,
    Say pgmname "Empty file RCode =" return_code "DSN="dsname,
      "MEMBER="member zerrsm
  Else
    Say pgmname "LINENUM Error RCode =" return_code "DSN="dsname,
      "MEMBER="member zerrsm
  SIGNAL ERR_EXIT
  end
 
return_code = 0
"FIND FIRST 'TCPIPJOBNAME '"
f_jobname = return_code
If return_code = 0 then do
  "(ROW,COL) = CURSOR"
  "(DATA) = LINE" row
  stigtxt1 = "The TCPIPJOBNAME statement is configured.     ",
    substr(data,col)
  end
 
return_code = 0
"FIND FIRST 'HOSTNAME '"
f_hostname = return_code
If return_code = 0 then do
  "(ROW,COL) = CURSOR"
  "(DATA) = LINE" row
  stigtxt2 = "The HOSTNAME statement is configured.         ",
    substr(data,col)
  end
 
return_code = 0
"FIND FIRST 'DOMAINORIGIN '"
f_origin = return_code
If return_code = 0 then do
  "(ROW,COL) = CURSOR"
  "(DATA) = LINE" row
  stigtxt3 = "The DOMAINORIGIN statement is configured.     ",
    substr(data,col)
  end
 
return_code = 0
"FIND FIRST 'DATASETPREFIX '"
f_prefix = return_code
If return_code = 0 then do
  "(ROW,COL) = CURSOR"
  "(DATA) = LINE" row
  stigtxt4 = "The DATASETPREFIX statement is configured.    ",
    substr(data,col)
  end
 
return_code = 0
"FIND FIRST 'NSINTERADDR '"
f_addr = return_code
 
 
END_EDIT:
return_code = 0
ztcp020_cnt = 0
If f_jobname  > 0 then,
  ztcp020_cnt = ztcp020_cnt +1
If f_hostname > 0 then,
  ztcp020_cnt = ztcp020_cnt +1
If f_origin   > 0 then,
  ztcp020_cnt = ztcp020_cnt +1
If f_prefix   > 0 then,
  ztcp020_cnt = ztcp020_cnt +1
If ztcp020_cnt > 0 then do
  ac = "The TCP/IP Data configuration file is coded improperly."
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  ac = " "
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  a = 1
  If ztcp020_cnt > 1 then,
    pd = a") "
  Else
    pd = ""
  end
Else do
  ac = "Not a Finding"
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  ac = " "
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  ac = "1)" stigtxt1
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  ac = "2)" stigtxt2
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  ac = "3)" stigtxt3
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  ac = "4)" stigtxt4
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  end
 
If f_jobname > 0 then do
  ac = pd"The TCPIPJOBNAME statement is not configured."
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  a = a + 1
  If ztcp020_cnt > 1 then,
    pd = a") "
  end
If f_hostname > 0 then do
  ac = pd"The HOSTNAME statement is not configured."
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  a = a + 1
  If ztcp020_cnt > 1 then,
    pd = a") "
  end
If f_origin > 0 then do
  ac = pd"The DOMAINORIGIN statement is not configured."
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  a = a + 1
  If ztcp020_cnt > 1 then,
    pd = a") "
  end
If f_prefix > 0 then do
  ac = pd"The DATASETPREFIX statement is not configured."
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(ITCP0020)"
  a = a + 1
  If ztcp020_cnt > 1 then,
    pd = a") "
  end
 
 
ZTCP020_ADD:
return_code = 0
pdimbr = "ITCP0020"
Call add_member
 
return_code = 0
 
 
ERR_EXIT:
If maxcc >= 16 | return_code > 0 then do
  Address ISPEXEC "VGET (ZISPFRC) SHARED"
  If maxcc > zispfrc then,
    zispfrc = maxcc
  Else,
    zispfrc = return_code
  Address ISPEXEC "VPUT (ZISPFRC) SHARED"
  Say pgmname "ZISPFRC =" zispfrc
  end
cm012rc = return_code
Address ISPEXEC "VPUT (CM12VGET CM012RC) ASIS"
"END"
Exit (0)
 
 
/*******************************************/
/*  SYSCALL SUBROUTINES                    */
/*******************************************/
TRUNC_DATA:
return_code = 0
dl = length(data)
Do SI = 1 to dl while substrc(si,data) = " "
  end
Do EI = dl to 1 by -1 while substrc(ei,data) = " "
  end
If si < ei then do
  data = substrc(si,ei,data)
  end
Return (rc)
 
 
ADD_MEMBER:
return_code = 0
Address ISPEXEC "LMMADD DATAID("pdidd") MEMBER("pdimbr")"
If return_code = 4 then do
  return_code = 0
  Address ISPEXEC "LMMREP DATAID("pdidd") MEMBER("pdimbr")"
  If return_code <> 0 then do
    Say pgmname "LMMREP PDI RCODE =" return_code datamem zerrsm
    end
  end
Else do
  If return_code <> 0 then,
    Say pgmname "LMMADD PDI RCODE =" return_code datamem zerrsm
  end
Return
 
 
/* remove all ; lines*/
/* remove all ; comments*/
REMOVE_5E_FIRST:
"EXCLUDE ALL X'5E' 1 1"
"DELETE ALL X"
"CURSOR = 1 0"
 
 
REMOVE_5E:
do until return_code > 0
  return_code = 0
  "FIND X'5E' 2 80"
  If return_code > 0 then leave
  "(ROW,COL) = CURSOR"
  "(DATA) = LINE" row
/*data = substrc(1,col-1,data)*/
  parse var data data ";" .
  "LINE" row "= (DATA)"
  end
return
 
 
substrc: Procedure
If arg(3) = '' then do
  s = Arg(1)
  l = 1
  v = arg(2)
  end
Else do
  s = arg(1)
  l = arg(2)-arg(1)+1
  v = arg(3)
  end
Return substr(v,s,l)
 
 
NoValue:
Failure:
Syntax:
say pgmname "REXX error" rc "in line" sigl":" strip(ERRORTEXT(rc))
say SOURCELINE(sigl)
SIGNAL ERR_EXIT
 
 
Error:
return_code = RC
if RC >= 16 then do
  say pgmname "LASTCC =" RC strip(zerrlm)
  say pgmname "REXX error" rc "in line" sigl":" ERRORTEXT(rc)
  say SOURCELINE(sigl)
  end
if return_code > maxcc then
  maxcc = return_code
return
 
 
