*DECK QTENDT
USETEXT AIPDEF
USETEXT QTRMBUF
USETEXT QTRMCOM
USETEXT QTRMNIT
PROC QTENDT;
*IF DEF,IMS
#
*1DC QTENDT
*
* 1. PROC NAME AUTHOR DATE
* QTENDT E. GEE 11/01/84
*
* 2. FUNCTIONAL DESCRIPTION.
* TERMINATE OR LOAN A SPECIFIED CONNECTION
*
* 3. METHOD USED.
* ENTRY POINT QTENDT:
* SET LOAN FLAG TO FALSE.
* ENTRY POINT QTLEND:
* SET LOAN FLAG TO TRUE.
* IF QTOPEN HAS NOT BEEN CALLED,
* CALL NP$ERR TO ISSUE DAYFILE MESSAGE AND ABORT APP.
* ELSE (QTOPEN HAS BEEN CALLED),
* INITIALIZE RETURN CODE FIELD IN NIT TO QTRM REJECT CODE
* IF NIT ENTRY NOT IN USE,
* SET SEC-RETURN-CODE FIELD IN NIT TO ERROR CODE.
* ELSE (NIT ENTRY IS IN USE),
* IF CONNECTION HAS BEEN LOANED,
* SET SEC-RETURN-CODE FIELD IN NIT TO ERROR CODE.
* ELSE (CONNECTION DOES EXIST),
* IF NEXT APPLICATION WAS SPECIFIED
* AND DATA IS BEING PASSED TO IT
* AND SIZE OF DATA IS NOT SPECIFIED,
* SET SEC-RETURN-CODE FIELD IN NIT TO ERROR CODE.
* ELSE (OKAY TO END/LOAN CONNECTION),
* IF NEXT APPLICATION WAS SPECIFIED
* AND DATA IS BEING PASSED TO IT
* AND SIZE OF DATA IS TOO LARGE,
* SET SEC-RETURN-CODE FIELD IN NIT TO ERROR CODE.
* ELSE (GOOD SIZE SPECIFIED FOR DATA TO BE PASSED),
* IF LOANING CONNECTION,
* IF NOT DEVICE CONNECTION,
* SET SEC-RETURN-CODE FIELD IN NIT TO ERROR CODE.
* ELSE (DEVICE CONNECTION),
* IF LOANED CONNECTION,
* SET SEC-RETURN-CODE FIELD IN NIT TO ERROR CODE.
* ELSE (DEVICE CONNECTION),
* IF NEXT APPLICATION NOT SPECIFIED,
* SET SEC-RETURN-CODE FIELD IN NIT TO ERROR CD.
* ELSE (NEXT APPLICATION WAS SPECIFIED),
* IF DOWNLINE BLOCKS OUTSTANDING,
* SET SEC-RETURN-CODE FIELD IN NIT TO ERR CD.
* ELSE (OKAY TO LOAN CONNECTION),
* STORE NORMAL COMPLETION RETURN CODE IN NIT.
* ELSE (OKAY TO TERMINATE CONNECTION),
* STORE NORMAL COMPLETION RETURN CODE IN NIT.
* IF NORMAL COMPLETION RETURN CODE IN NIT,
* SEND LST/OFF SM TO TURN OFF MSG TRAFFIC ON CON.
* SEND CON/END/R SM WITH DATA IF ANY.
*
* 4. ENTRY CONDITIONS
* NIT$CON NO OF CONNECTION TO BE TERMINATED OR LOANED
* NIT$CTLC NO OF WDS OF DATA TO PASS TO NEXT APP
* NIT$NEXT$APP NAME OF NEXT APPLICATION TO HAVE DEVICE CON
* NIT$PARMADR ADDR OF DATA TO PASS TO NEXT APPLICATION
*
* 5. NORMAL EXIT CONDITIONS.
* NIT$STATE WCONENDN STATE (IF TERMINATING CONNECTION)
* NET$STATE LEND STATE (IF LOANING CONNECTION)
* NIT$RC 0
*
* 6. ABNORMAL EXIT CONDITIONS.
* NIT$RC QTENDTREJ RETURN CODE (IF QTENDT CALL)
* NIT$RC QTLENDREJ RETURN CODE (IF QTLEND CALL)
* NIT$S$RC REASON CODE FOR REJECTION
*
* 7. COMMON DECKS AND SYMPL TEXT USED.
* AIPDEF NP$CRT QTRMBUF QTRMCOM
* QTRMNIT
*
* 8. ROUTINES CALLED.
* NETPUT OUTPUT BLOCK TO NETWORK
* NETPUTF OUTPUT FRAGMENTED BLOCK TO NETWORK
* NP$ERR DAYFILE ERROR MESSAGE AND ABORT APP
*
* 9. DAYFILE MESSAGES.
* *** NETWORK APPLICATION ABORTED, RC = 70. ***
* *** QTENDT: REQUEST INVALID BEFORE QTOPEN. ***
* *** NETWORK APPLICATION ABORTED, RC = 76. ***
* *** QTLEND: REQUEST INVALID BEFORE QTOPEN. ***
*
*
#
*ENDIF
#
CONTROL DEFINITIONS
#
CONTROL PRESET;
CONTROL PACK;
CONTROL DISJOINT;
CONTROL INERT;
CONTROL FASTLOOP;
*CALL NP$CRT
#
ROUTINES CALLED
#
XREF
BEGIN
PROC NETPUT; # OUTPUT BLOCK TO NETWORK #
PROC NETPUTF; # OUTPUT FRAGMENT SUP MSG #
PROC NP$ERR; # DAYFILE ERR MSG AND ABORT #
END
#
LOCAL VARIABLES
#
ITEM ACN I; # APPLICATION CONNECTION NUMBER#
ITEM LOAN B; # LOAN CONNECTION FLAG #
#**********************************************************************#
CONTROL EJECT;
#
BEGIN QTENDT PROCESSING
#
BEGIN
LOAN = FALSE; # NOT LOANING CONNECTION #
GOTO QTENDT1; # SKIP QTLOAN CODE #
#
BEGIN QTLEND PROCESSING
#
ENTRY PROC QTLEND;
LOAN = TRUE; # LOANING CONNECTION #
#
BEGIN QTLEND/QTENDT COMMON CODE
#
QTENDT1:
IF NOT NETON$STATUS # CHECK IF NETON HAD COMPLETED #
THEN
BEGIN
IF LOAN
THEN # QTLEND CALL #
BEGIN
NP$ERR("76"); # REQUEST INVALID BEFORE QTOPEN#
END
ELSE # QTENDT CALL #
BEGIN
NP$ERR("70"); # REQUEST INVALID BEFORE QTOPEN#
END
END
P<NIT> = NIT$ADDR;
ACN = NIT$CON[0]; # CONNECTION TO BE TERMINATED #
IF LOAN
THEN # QTLEND CALL #
BEGIN
NIT$RC[0] = S"QTLENDREJ"; # INIT RETURN CODE TO REJECT #
END
ELSE # QTENDT CALL #
BEGIN
NIT$RC[0] = S"QTENDTREJ"; # INIT RETURN CODE TO REJECT #
END
IF (NIT$STATE[ACN] EQ S"NULL") OR
(NIT$STATE[ACN] EQ S"WCONENDN") OR
(ACN EQ 0) OR
(ACN GR NIT$NO$TERMS[0])
THEN # BAD CONNECTION NUMBER #
BEGIN
NIT$S$RC[0] = S"BADCN"; # BAD CONNECTION NUMBER #
END
ELSE # NIT ENTRY EXISTS #
BEGIN
IF (NIT$STATE[ACN] EQ S"LEND") OR
(NIT$STATE[ACN] EQ S"LENT")
THEN # CONNECTION DOES NOT EXIST #
BEGIN
NIT$S$RC[0] = S"CONLOANED"; # CONNECTION IN WRONG STATE #
END
ELSE # CONNECTION IN RIGHT STATE #
BEGIN
IF (NIT$PARMADR[0] NQ 0) AND
(NIT$CTLC[0] EQ 0)
THEN # NO DATA LENGTH SPECIFIED #
BEGIN
NIT$S$RC[0] = S"NOSIZE"; # BAD SIZE FOR DATA TO PASS #
END
ELSE # DATA LENGTH WAS SPECIFIED #
BEGIN
IF (NIT$PARMADR[0] NQ 0) AND
(NIT$CTLC[0] GR 52)
THEN # BAD DATA LENGTH SPECIFIED #
BEGIN
NIT$S$RC[0] = S"BADSIZE"; # BAD SIZE FOR DATA TO PASS #
END
ELSE # OKAY TO END CONNECTION #
BEGIN
IF LOAN
THEN # LOANING CONNECTION #
BEGIN
IF (NIT$DEVTYP[ACN] EQ DT$INTA) OR
(NIT$DEVTYP[ACN] EQ DT$INTE)
THEN # APP-TO-APP CONNECTION #
BEGIN
NIT$S$RC[0] = S"NOTDEVC"; # NOT DEVICE CONNECTION #
END
ELSE # DEVICE CONNECTION #
BEGIN
IF NIT$LOAN[ACN] NQ 0
THEN # THIS IS ALREADY A LOANED CON #
BEGIN
NIT$S$RC[0] = S"LOANCON"; # CANNOT LOAN LOANED CON#
END
ELSE # NOT LOANED CONNECTION #
BEGIN
IF NIT$NEXT$APP[0] EQ 0
THEN # NEXT APPLICATION NOT SPEC #
BEGIN
NIT$S$RC[0] = S"NONEXTAP"; # CAN-T LOAN IF NO AP#
END
ELSE # NEXT APPLICATION SPECIFIED #
BEGIN
IF NIT$ABL[ACN] NQ NIT$C$ABL[ACN]
THEN # DOWNLINE BLOCKS OUTSTANDING #
BEGIN
NIT$S$RC[0] = S"DBLKSO"; # DWNLNE BLKS NOT ACK#
END
ELSE # OKAY TO LOAN CONNECTION #
BEGIN
NIT$RC[0] = S"OK"; # INIT RETURN CODE TO SUCCES#
NIT$STATE[ACN] = S"LEND"; # CHANGE STATE #
END
END
END
END
END
ELSE # TERMINATING CONNECTION #
BEGIN
NIT$RC[0] = S"OK"; # INIT RETURN CODE TO SUCCESS#
NIT$STATE[ACN] = S"WCONENDN"; # WAIT FOR CON/END/N STAT#
END
END
IF NIT$RC[0] EQ S"OK"
THEN # OKAY TO END/LOAN CONNECTION #
BEGIN
#
SEND LST/OFF SUPERVISORY MESSAGE FOR CONNECTION
#
ABHWORD[0] = 0;
ABHABT[0] = APPCMD; # ABH FOR LST/OFF ON ACN #
ABHACT[0] = ACLST; # ACT IS C60TRANS #
ABHTLC[0] = LLST; # TLC IS 1 #
SPMSG0[0] = 0;
PFCSFC[0] = LSTOFF; # LST/OFF SUPERVISORY MESSAGE #
LSTACN[0] = ACN;
NETPUT(HEADER, SUP$MES); # SEND LST/OFF TO NAM #
#
SEND CON/END SUPERVISORY MESSAGE
#
ABHWORD[0] = 0;
ABHABT[0] = APPCMD; # ABH FOR CON/END #
ABHACT[0] = ACCON; # ACT IS C60TRANS #
FRAGSZ0[0] = LCONEN; # LENGTH OF SM WITHOUT DATA #
FRAGAD0[0] = LOC(SUP$MES); # ADDR OF 1ST FRAGMENT BUFFER #
SPMSG0[0] = 0;
SPMSG1[0] = 0;
PFCSFC[0] = CONEND; # CON/END SUPERVISORY MESSAGE #
CONACN[0] = ACN;
CONANM[0] = NIT$NEXT$APP[0];# SET NEXT APPLICATION FIELD #
CONLOAN[0] = LOAN; # SET LOAN FLAG IN SUP MSG #
IF ( (NIT$NEXT$APP[0] NQ 0) AND
(NIT$PARMADR[0] NQ 0) ) OR
( (NIT$PARMADR[0] NQ 0) AND
(NIT$LOAN[ACN] NQ 0) )
THEN # SIZE OF DATA TO PASS IS OK #
BEGIN
FRAGSZ0[1] = NIT$CTLC[0]; # LENGTH OF DATA IN 2ND FRAG #
FRAGAD0[1] = NIT$PARMADR[0]; # ADR OF 2ND FRAG BUFFER #
ABHTLC[0] = LCONEN + NIT$CTLC[0]; # SIZE OF CON/END SM #
NOFRAG = 2; # NUMBER OF FRAGMENT BUFFERS #
END
ELSE
BEGIN
ABHTLC[0] = LCONEN; # LENGTH OF SM WITHOUT DATA #
NOFRAG = 1; # NUMBER OF FRAGMENT BUFFERS #
END
NETPUTF(HEADER,NOFRAG,FRAG); # SEND CON/END TO NAM #
END
END
END
END
RETURN;
END
TERM