home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / b / krtail.mac < prev    next >
Text File  |  2020-01-01  |  13KB  |  335 lines

  1.     .title    Watch LCDTIM and stop tailgating
  2.     .ident    "09B"
  3.  
  4. ; /63/    27-Sep-97  Billy Youdelman
  5. ; /62/    27-Jul-93  Billy Youdelman
  6. ;
  7. ;            * * *   N O T I C E   * * *
  8. ;
  9. ;    This program is intended for use with TSX-Plus V6.31 or LOWER
  10. ;    releases, at least to V6.0.  It is NOT NECESSARY with V6.4 or
  11. ;    above, and it may run on some of the later V5.x releases too.
  12.  
  13. ;    This file is named KRTAIL.MAC to be included with the Kermit-11
  14. ;    for RT-11 (KRT) distribution.  It is actually NOTAIL.MAC, DECUS
  15. ;    #110916, and is supplied here for your convenience.  Before use
  16. ;    copy this file to NOTAIL.MAC, then edit that for your system.
  17.  
  18.  
  19. ;            NOTAIL - Edit History
  20. ;
  21. ;   9-Feb-96  V9B - Included in KRT general clean-up, local labels reordered.
  22. ;
  23. ;   4-Jul-93  V9A - Add automatic 50Hz clock rate detection and support for
  24. ;  watching more than 34. lines, just in case anyone ever achieves this..
  25. ;
  26. ;   9-Sep-91  V8A - modified to work with pre-V6.3 versions of TSX per Chester
  27. ;  Wilson's KILL.MAC in his TSCLIB.
  28. ;
  29. ;  21-Oct-88  V7E - Initial release of detached job version as DECUS #11-916.
  30. ;  Created from Howard Helman's TIMCK/USRCOP.
  31.  
  32.  
  33. ;            NOTAIL - Documentation
  34. ;
  35. ;  Tailgating is the name commonly given to what happens when a modem data
  36. ;  path is broken before the job using it has logged off, and the next call
  37. ;  is connected to that still active session of the prior user.  Additional
  38. ;  info may be found in Data Communications, March, 1988, page 55.
  39. ;
  40. ;  Beginning with V6.4 TSX-Plus was given improved modem control, with which
  41. ;  tailgating incidents are easily prevented.  The following values are
  42. ;  suggested for MNP/V.42 auto-answer operation (modem time out = 40 secs):
  43. ;
  44. ;  .show modem
  45. ;  PHONE=1    Other modem control parameters (in 0.5 sec):
  46. ;   ONTIM=80 OFFTIM=1 TIMIN=80 TIMLOC=1 TIMOUT=1
  47. ;
  48. ;  When no error correction is in use, ONTIM and TIMIN may be halved, and the
  49. ;  modem's wait time for carrier (S7 register in Hayes-style units) set to 20
  50. ;  seconds.  If the modem's wait time is not settable such that it's restored
  51. ;  when reset (ala ATZ), then ONTIM and TIMIN must be set to match the modem.
  52. ;  OFFTIM, TIMLOC and TIMOUT must = 1 (the minimum, don't use zero) to ensure
  53. ;  the job is logged off immediately.  The $PHONE flag must be defined in the
  54. ;  LINDEF (in TSGEN.MAC) for any line connected to an auto-answer modem.  And
  55. ;  above all, the modem MUST be configured to hang up when DTR is dropped for
  56. ;  any of this to be effective.
  57. ;
  58. ;    IF YOU ARE RUNNING TSX-PLUS V6.40 OR HIGHER DOING THE ABOVE MAKES USING
  59. ;    THIS PROGRAM UNNECESSARY!  However, the info concerning use of a logoff
  60. ;    command file (following) remains worthwhile reading.
  61. ;
  62. ;  If you're using TSX-Plus V6.31 or below, the TIMOUT value which governs
  63. ;  how long a job will be held active after the data carrier has been lost
  64. ;  also determines the time allowed for a caller to first connect, type two
  65. ;  returns and initialize the line.  Thus, setting TIMOUT small enough to
  66. ;  prevent tailgating means it's not likely anyone will be able to log on a
  67. ;  phone line either.
  68. ;
  69. ;  This little program, running as a detached job, checks designated lines
  70. ;  every 0.5 second and kills any that may still be logged on without DCD
  71. ;  held true.  Phone lines on which DCD is true keep LCDTIM refreshed with
  72. ;  TIMOUT, otherwise LCDTIM is decremented every 0.5 second.  Status of
  73. ;  monitored jobs is kept here in an internal table, maintained by their
  74. ;  broadcast status reports.  When LCDTIM no longer equals TIMOUT for a
  75. ;  watched line that's still active, that job is killed by this program.
  76. ;
  77. ;  Most modems provide some immunity to brief hits in the carrier by including
  78. ;  a small delay before dropping DCD, and the test done here is not sync'd
  79. ;  with the LCDTIM refresh, so it may take as long as two seconds from actual
  80. ;  loss of carrier until a logoff command file has run, however this is less
  81. ;  time than it takes for a following call to be connected.  Modems which can
  82. ;  retrain should be configured to keep DCD asserted true during that process.
  83. ;  TSX-Plus has no provision for use of DCD to ignore the retrain string, but
  84. ;  loss of DCD will result in the line being killed.
  85. ;
  86. ;    To use this program the appropriate values for the four user settable
  87. ;    parameters, below, MUST BE PATCHED AS INDICATED.  Lines to be watched
  88. ;    must be numerically contiguous, or the init routine suitably modified.
  89. ;    Monitoring a non-phone line will definitely render it useless.  This
  90. ;    program must be rebuilt any time any of these four parameters change,
  91. ;    such as when a new system generation changes the LCDTIM table address.
  92. ;
  93. ;  Then assemble and link to create NOTAIL.SAV:
  94. ;
  95. ;    .MACRO NOTAIL
  96. ;    .LINK NOTAIL
  97. ;
  98. ;  and copy that to SY.  Then add this command line to the end of an existing
  99. ;  system start-up detached job command file (so that detached job slot ends
  100. ;  up running NOTAIL forever) or create NOTAIL.DET containing the same command
  101. ;  line and edit TSGEN.MAC to run it as a detached job when TSX is started:
  102. ;
  103. ;    R NOTAIL
  104. ;
  105. ;  The TSGEN parameter MAXMON must accommodate the number of lines monitored
  106. ;  as well as any other use of it, and PHONE must be set true (PHONE=1), both
  107. ;  of which may be done via TSXMOD, after which TSX+ must be restarted to read
  108. ;  the new values, if there's an existing detached job running at start-up to
  109. ;  which the above may be appended.  If not started by the system NOTAIL needs
  110. ;  MEMMAP, PSWAPM, SEND and WORLD privileges to run.
  111. ;
  112. ;  As the modem itself is reset by dropping DTR, actually dumping a modem
  113. ;  connection is most efficiently done by the use of a logoff command file,
  114. ;  which is assigned in each phone line's start-up command file.  Example:
  115. ;
  116. ;    SET ERROR FATAL
  117. ;    !ACCESS SY:CLEAR.COM/READ    ..if access restrictions are used
  118. ;    SET LOGOFF FILE=SY:CLEAR.COM
  119. ;    SET TT PAGE            !see note for CLEAR.COM, below
  120. ;    R LOGON
  121. ;
  122. ;  Then SY:CLEAR.COM would contain:
  123. ;
  124. ;    SET ERROR NONE
  125. ;    SET PRIO 70            ! be sure this runs before next call
  126. ;    SET TT NOPAGE,NODTR,PHONE,AUTO,XON
  127. ;    !Insert whatever else's needed here..
  128. ;
  129. ;  The reasons for the various SET TT options used above are:
  130. ;
  131. ;        NOPAGE ensures possible noise induced XOFF on DTR drop is harmless
  132. ;        NODTR  resets the modem
  133. ;        PHONE  ensures port is not in local mode, just in case..
  134. ;        AUTO   ensures port not stuck at any particular speed
  135. ;        XON    resets any XOFF which may have snuck thru..
  136. ;
  137. ;  This may seem a bit extreme on the SET TT end of things, but it definitely
  138. ;  gets the job done, even after in and out buffers are overflowed, XOFF'd in
  139. ;  both directions (deadlocked) and the caller has to hang up.
  140. ;
  141. ;  Note that TERMINAL privilege is required for the above to drop DTR.  As of
  142. ;  TSX V6.5 installing a .COM file with TERM privilege doesn't work, the user
  143. ;  must be given it.  If the user does not have TERM privilege, DTR won't get
  144. ;  dropped until after the XON is done, which has been a problem in V6.20 and
  145. ;  earlier releases.
  146. ;
  147. ;  It's also a good idea when using a Hayes-style modem to disable its escape
  148. ;  character means of invoking the modem's command mode.  If one phones in to
  149. ;  a TSX system and then uses another line on it to call out or talks to some
  150. ;  one such that the other person's data are going into the modem (the one at
  151. ;  the TSX system, to which your local system is connected) via its DCE port,
  152. ;  there's no other way to prevent someone from using the escape sequence and
  153. ;  taking control of that modem, after which they've got your phone line..
  154. ;
  155. ;    Billy Youdelman                billy@MIX.COM
  156. ;    PO Box 1207            
  157. ;    Culver City, California  90232-1207
  158. ;    USA
  159.  
  160.  
  161.     .sbttl    User settable parameters
  162.  
  163. FLINE    =        6.        ; first primary line number to check
  164. NLINES    =        4.        ; # contiguous lines to check from fline up..
  165. LCDTIM    =    20062        ; TSX time out table addr, get from TSX.MAP
  166. TIMOUT    =       20.        ; time out value, must match TIMOUT in TSGEN
  167.  
  168.     ; end of user settable parameters
  169.  
  170.  
  171.     .mcall    .EXIT    ,.GVAL    ,.SERR    ,.TWAIT
  172.     .enabl    lc
  173.  
  174.  
  175.     $INKMN    =    10000        ; set in LSW4 to pretend pgm is TSKMON
  176.     CONFIG    =      300        ; RT-11 primary configuration word
  177.         HERTZ50    =  40        ; 50Hz clock if set
  178.     ERRBYT    =       52        ; emt error byte location
  179.     TS.VER    =      -32.        ; offset to TSX version number
  180.  
  181.     .ASECT
  182.     . = 56
  183.     .if le    <NLINES-34.>        ; if watching 34. or less lines
  184.     .word    1            ; setsiz notail.sav/t:1
  185.     .iff                ; if more than 34. (ya never know..)
  186.     .word    2            ; setsiz notail.sav/t:2
  187.     .endc                ; le NLINES-34.
  188.  
  189.  
  190.     .psect
  191.     .sbttl    Initialization
  192.  
  193. notail:    .serr                ; don't crash on an error
  194.     mov    #lock    ,r0        ; lock into memory
  195.     emt    375            ; so timing stuff won't ever be late
  196.     mov    #priority,r0        ; bump up the priority
  197.     emt    375
  198.     mov    #newname,r0        ; set the user name
  199.     emt    375            ; to something informative
  200.  
  201.     mov    #fline    ,linno        ; start at this TSX line number
  202.     mov    #nlines    ,r4        ; do this many contiguous lines
  203.  
  204. 10$:    mov    linno    ,monlin        ; give line number to monitor emt
  205.     mov    #monjob    ,r0        ; point to monitor emt arg block
  206.     emt    375            ; begin monitoring for this line
  207.     bcc    20$            ; it worked
  208.     jmp    errext            ; it failed, go say why
  209. 20$:    inc    linno            ; prep for next line
  210.     sob    r4    ,10$        ; another to check?
  211.  
  212.     .gval    #area    ,#config    ; get RMON configuration word into r0
  213.     bit    #hertz50,r0        ; is clock 50Hz?
  214.     beq    10$            ; nope..
  215.     mov    #25.    ,time+2        ; ya, overwrite 60Hz default
  216.     .gval    #area    ,#ts.ver    ; get TSX version number
  217.     bcs    loop            ; this doesn't work before V6.0
  218.     mov    r0    ,tsxver        ; save it
  219.  
  220.  
  221.     .sbttl    Main loop        ; search + destroy every 0.5 sec
  222.  
  223. loop:    mov    #fline    ,linno        ; start at this line
  224.     mov    #nlines    ,r4        ; how many to do
  225.  
  226. 10$:    mov    linno    ,r0        ; get a line number
  227.     asl    r0            ; word indexing for data table
  228.     tst    flags(r0)        ; is this line active?
  229.     beq    40$            ; nope, on to the next one
  230.     mov    r0    ,lindex        ; save shifted TSX line number
  231.     add    #lcdtim    ,r0        ; convert to physical address for line
  232.     mov    r0    ,addr        ; save for peek
  233.     mov    #pkemt    ,r0        ; set up peek
  234.     emt    375            ; get lcdtim register value
  235.     cmp    r0    ,#timout    ; if lcdtim<>timout DCD has gone away
  236.     beq    40$            ; if lcdtim=timout skip to next..
  237.  
  238.     cmp    tsxver    ,#630.        ; will documented kill emt work?
  239.     bge    20$            ; ya
  240.  
  241.     mov    #kmnon    ,r0        ; no, set the "in KMON" bit in LSW4
  242.     emt    375            ; so the following will work
  243.     mov    lindex    ,job        ; pass job_# * 2 (word indexing)
  244.     mov    #kmnkill,r0        ; load args for KMON's kill emt
  245.     emt    375            ; do it
  246.     mov    #kmnoff    ,r0        ; now clear the "in KMON" bit..
  247.     emt    375
  248.     br    30$
  249.  
  250. 20$:    mov    linno    ,knum        ; give job number to kill emt
  251.     mov    #kill    ,r0        ; point to args
  252.     emt    375            ; kill the line
  253.  
  254. 30$:    mov    lindex    ,r0        ; recover pointer
  255.     clr    flags(r0)        ; clear flag for this line
  256. 40$:    inc    linno            ; prep for next line
  257.     sob    r4    ,10$        ; another to check?
  258.     .twait    #area    ,#time        ; wait for lcdtim regs to be updated
  259.     br    loop
  260.  
  261.  
  262.     .sbttl    Monitoring completion routine
  263.  
  264. moncpl:    asl    r0            ; word index and dump sys message bit
  265.     bcc    20$            ; not a system message..
  266.     cmp    r1    ,#1        ; is this job init message?
  267.     bne    10$            ; no
  268.     mov    sp    ,flags(r0)    ; set the line's entry as logged on
  269.     br    20$            ; and return
  270. 10$:    cmp    r1    ,#5        ; has job logged off?
  271.     bne    20$            ; no so return
  272.     clr    flags(r0)        ; clear flag for this line
  273. 20$:    return                ; that's it..
  274.  
  275.  
  276.     .sbttl    Job monitor scheduling error
  277.  
  278. errext:    movb    @#errbyt,r1        ; get emt error code
  279.     add    #'0    ,r1        ; convert to ascii numeral
  280.     movb    r1    ,errcod        ; stuff into error message
  281.     mov    linno    ,r1        ; recover line number
  282.     mov    #<which+2>,r2        ; get pointer to end of buffer
  283.     mov    #2    ,r3        ; setup for two loops
  284. 10$:    clr    r0            ; prepare for divide
  285.     div    #10.    ,r0        ; get value of digit
  286.     add    #'0    ,r1        ; convert it to ascii
  287.     movb    r1    ,-(r2)        ; put ascii number in buffer
  288.     mov    r0    ,r1        ; get tens digit for second pass
  289.     sob    r3    ,10$        ; two digits only
  290.     mov    #yell    ,r0        ; load emt arg block
  291.     emt    375            ; display error on system console
  292.     .exit                ; then stop this program
  293.  
  294.  
  295.     .sbttl    Data..
  296.  
  297. area:    .blkw    2            ; 2 word arg area for .twait
  298. flags:    .blkw    fline+nlines        ; lines data table
  299. kill:    .byte    2 ,132            ; kill emt
  300. knum:    .word    0            ; job number
  301. kmnkill:.byte    0 ,126            ; TSKMON kill a job emt
  302.     .word    5
  303. job:    .word    0            ; "job" = tsx_line_number * 2
  304. kmnoff:    .byte    3 ,130            ; clear $INKMN bit in TSX's LSW4
  305.     .word    4
  306.     .word    $inkmn
  307. kmnon:    .byte    2 ,130            ; set $INKMN bit in TSX's LSW4
  308.     .word    4
  309.     .word    $inkmn
  310. lindex:    .word    0            ; asl'd linno for word indexing
  311. linno:    .word    0            ; current loop line number
  312. lock:    .byte    7 ,140            ; lock into low memory emt
  313. name:    .ascii    "DCD_time_out"        ; must = 12. bytes
  314. newname:.byte    1 ,147            ; change the user name emt args
  315.     .word    name
  316. monjob:    .byte    0 ,157            ; emt arg block to monitor a line
  317. monlin:    .word    0            ; monitor this line
  318.     .word    moncpl            ; completion routine address
  319. pkemt:    .byte    1 ,34            ; .peek emt arg block
  320. addr:    .word    0            ; where to peek
  321. priority:.byte    0 ,150            ; set priority emt
  322.     .word    55.            ; bump it up to here
  323. time:    .word    0            ; time high word
  324.     .word    30.            ; time low word - sleep for 0.5 sec
  325. tsxver:    .word    0            ; TSX version number
  326. yell:    .byte    1 ,127            ; display text on
  327.     .word    1            ; operator's console
  328.     .word    monerr            ; what to send starts here
  329. monerr:    .ascii    <15><12><7>"?NOTAIL-F-Monitor EMT error #"
  330. errcod:    .ascii    "0 for Line #"        ; error # goes here
  331. which:    .asciz    "00"<15><12>        ; line # goes here
  332.     .even
  333.  
  334.     .end    notail
  335.