; GATE.MAC - 1/17/87 - GateWay code. .z80 .xlist maclib TNC.LIB tncdefs timdef asciictl .list entry gcon1,gcon2,gcon4,gunp,gmon entry gaton,gatoff,gate,gbye,gater entry gm1,gm2,gm3,gm4,gm5,gm6,gm7,gm9,gm10,gm11,gm12 entry gm13,gm14 entry gmenus,gmenul,gateok,moncnt,montim,monok external cmd,cmdlen,cmdtyp,getdat,getwt,const external conmod,gotcon,gotlnk,ertime,ercant,erwhat external mode,logout,event,log,logtxt,llogtxt,dis external prtcmd,@prtx,@fill,@wait,@mcmd,movcal external twotnc,cmdtnc,@docmd,wtcmd,itime,ynbq external fcb2,f2st,f2l,scon,mtnc,stnc,mcall,scall external @srcl,@srcn,@srcw,@srcc,@srct,@src external prtcon,rdusr,uslst,uscnt,usport,uspath dseg ; Addresses of the GateWay messages. gateok: ds 1 gmenus: ds 2 ; short menu text gmenul: ds 2 ; long menu text gm1: ds 2 ; "not available" message gm2: ds 2 gm3: ds 2 gm4: ds 2 gm5: ds 2 gm6: ds 2 gm7: ds 2 gm8: ds 2 gm9: ds 2 gm10: ds 2 gm11: ds 2 gm12: ds 2 gm13: ds 2 gm14: ds 2 monok: ds 1 moncnt: ds 2 montim: ds 2 mtyp: ds 1 count: ds 2 tcall: ds 6 linkit: ds 1 con: dw $+2 db 'CONOK ON',cr,0 coff: dw $+2 db 'CONOK OFF',cr,0 monon: dw $+2 db 'mon on',cr,0 monoff: dw $+2 db 'mon off',cr,0 clink: db 'G',cr,'C ' ccall: ds 6 db cr,0 ; Linking code. cseg link: movw timer,itime ; Start timeout timer mvim count,10 ; Count lines transfered linka: master call const call nz,linkm ; Deal with line from master slave call const call nz,links ; Deal with line from slave dtz timer ; Timed out yet? jr nz,linka ; No call ertime ; Yes, tell slave user master call ertime ; and master user jp linknd ; Drop the link ; Deal with data from master linkm: mvim getwt,false ; Dont wait after con req call getdat ; Get line of data from master movb mtyp,cmdtyp ; Save command status ld a,(cmdtyp) ckcmd linkma,linknd,linknd cmpm cmd,linkcmd ; Wants to drop the link? jp z,linknd ; Yes, do it slave call prtcmd ; Send the line to the slave movw timer,itime ; Restart timeout timer ld hl,count ; Count lines dec (hl) ret nz ; Not enough yet ld (hl),10 ; Restart count console prtx gm11 ; Tell system owner who using gateway linkma: ret ; Deal with data from slave links: mvim getwt,false ; Dont wait after con req call getdat ; Get line of data from slave ckcmd linkse,linksa,linksb call gotcon ; Did someone connect? jr nz,linksc ; No mvim scon,true ; Change status to connected ld de,scall ld hl,cmd ld a,(cmdlen) call movcal ; Save call of station that connected prtx gm9 ; Tell them who they talking to master prtx gm10 ; Tell user on master who connected ret linksc: master call prtcmd ; Send the line of data to master call gotlnk ; Slave linked us somewhere? jr nz,linksd ; No ld de,scall ld hl,cmd ld a,(cmdlen) call movcal ; Save call of station we linked to linksd: movw timer,itime ; Restart timeout timer ld hl,count ; Point to line count dec (hl) ; Time to tell owner? ret nz ; No ld (hl),10 ; Restart the count console prtx gm11 ; Tell owner who using his system linkse: ret ; Slave disconnected linksa: mvim scon,false jr linknd ; Slave timed out linksb: master call ertime ; Exit from linked state linknd: slave call cmdtnc ; Get TNC into command mode docmd coff ; CONOK OFF cmpm scon,true ; Slave is connected? call z,dis ; Then disconnect... master movb cmdtyp,mtyp ; Restore command status pop hl ; Return to link caller, not link ret ; Log end of event. logend: ld hl,logtxt ld (hl),'E' inc hl ld (hl),cr call log ret ; Enable / disable GateWay. gaton: mvim gateok,true ret gatoff: mvim gateok,false ret ; Entry to GateWay from MailBox gate: ld a, (gateok) ; See if gw is on now call ynbq ; .. ld hl,(gm1) ; Err msg if GW not avail jp z,@prtx ; No cmpm twotnc,false ; We have two tnc's? jp z,@prtx ; No mvim event,'G' ld hl,logtxt ld (hl),'S' inc hl ld (hl),cr call log ; Log GateWay start mvim mode,gmode ; Set GateWay mode ret ; Exit from GateWay - disconnect. gbye: call logend jp logout ; Exit from GateWay back to MailBox gater: call logend ; Log end of gate mvim mode,umode ; Set user mode ret ; Let the sucker monitor. gmon: ld a, (monok) ; Monitor allowed now? call ynbq ; .. ld hl,(gm14) ; Msg if not jp z,@prtx ; Sorry Charlie ld hl,logtxt ; Set up text for log file ld (hl),'M' inc hl ld (hl),cr call log ; Log the event prtx gm13 ; Tell user he listening to other TNC slave docmd monon ; Turn on monitor movw count,moncnt ; Init count of lines monitored movw timer,montim ; Init # seconds to monitor gmonb: slave call const ; Anything from slave? jr z,gmonc ; No dcxm count ; Count this line mvim getwt,false ; No wait if con req call getdat ; Get line from slave ckcmd gmonc,gmonc,gmonc master call prtcmd ; Send line to master gmonc: master dtz count ; Monitored max lines allowed? jr z,gmond ; Yes dtz timer ; Monitored long enough? jr z,gmond ; Yes call const ; Line from master? jr z,gmonb ; No mvim getwt,false ; No wait if con req call getdat ; Get line from master ckcmd gmonb,gmone,gmone jr gmone ; Quit monitoring gmond: call ertime ; Tell user he timed out gmone: slave docmd monoff ; Turn off monitor master jp logend ; Log end of event and return ; Link the TNC's in unprotocol mode gunp: ld hl,logtxt ; Set up text for log file ld (hl),'U' inc hl ld (hl),cr call log ; Log the event prtx gm2 ; Tell user he talking to other TNC slave docmd con ; Turn CONOK on call conmod ; Go to unproto mode mvim scon,false ; Slave is not connected fill scall,6,' ' ; Nobody connected on slave call link ; Go play gateway jp logend ; Log end of event and return ; Attempt a connected link ckp: cmpm usport,'A' ; User on COMM TNC? ld a,(iobyte) jr z,ckpa ; Yes cp rbiob ; Path for same port? ret ckpa: cp raiob ; Path for same port? ret gcon1: ld hl,(gm3) jp @prtx ; No call given gcon2: mvim linkit,false ld a,(f2l) ; Length of call cp 7 ; More than six chars? jr nc,gcon4 ; Yes, use what we got srclst fcb2+1,uslst,uscnt,6,6 jr z,gconc ; We know this user gcon4: mvim linkit,false call prtcmd ; Show what we do slave call prtcmd ; Send the connect as we got it call wtcmd ; Wait for tnc response push af mvim linkit,false jp gconf ; Connect to user. gconc: zmov tcall,mcall,6 ; Save users call ld de,mcall ld hl,(f2st) ld a,(f2l) call movcal ; Get call of station to link to zmov ccall,mcall,6 ; and save that too call rdusr ; Read user record of station to link to cmpm usport,'L' ; That staion linked here? jr nz,x1 ; No cmpm uspath,cr ; Have call of GateWay? jr z,x1 ; No mvim linkit,true ; We going to link thru another GateWay fill mcall,6,' ' ld hl,uspath ld de,mcall ld b,6 x2: ld a,(hl) inc hl cp cr jr z,x3 ld (de),a inc de dec b jr nz,x2 x3: call rdusr ; Get user record of GateWay x1: call ckp ; User last seen on same port? jr nz,gcond ; No call prtcmd ; Show what we do slave call prtcmd ; Send the connect as we got it jr gcone ; Ok, we really DO know how to get to this one! gcond: call prtcon ; Show what we do slave call prtcon ; Send connect to slave tnc gcone: call wtcmd ; Wait for tnc response push af ; Save status from command zmov mcall,tcall,6 ; Restore loged in user call call rdusr ; Get logged user record back gconf: master pop af ; Get status back jr z,gcong ; TNC liked the command dec a jp z,ercant ; TNC not respond jp erwhat ; TNC did an EH? ; Wait for response from slave gcong: prtx gm4 ; Tell user we try the connect movcmd logtxt,0,llogtxt-2 ld (hl),cr movb mtyp,cmdtyp gconh: mvim getwt,false ; Not to wait after con req slave call const jr nz,gcons ; Input from slave master call const jr nz,gconm ; Input from master jr gconh ; Input from master gconm: call getdat ; Get the line from master movb mtyp,cmdtyp ; Save type of input ld a,(cmdtyp) ckcmd gconh,gconma,gconma cmpm cmd,linkcmd ; User wants to give up? jr nz,gconh ; Nope ; Abort the connect attempt. prtx gm7 ; Tell user we giving up gconma: slave call dis ; Disconnect on slave master jp gconng ; and quit ; Input from slave gcons: call getdat ; Get line from slave ckcmd gconh,gconsb,gconsc call gotcon ; Is it a connect? jr z,gconsa ; Yes master call prtcmd ; Show user the busy jr gconh ; Keep trying ; Connect worked gconsa: mvim scon,true ; Mark slave as connected ld de,scall ld hl,cmd ld a,(cmdlen) call movcal ; Save call of station connect to wait linktim ; Wait a bit, remote bbs needs it prtx gm9 ; Tell slave user who they linked to ; If we connected to another GateWay, send it the ; commands to connect to the station we really want. ld hl,clink cmpm linkit,true call z,@prtx master prtx gm6 ; Tell master user connect worked prtx gm10 ; and who they linked to call log ; Log the connect call link ; Go play gateway call logend ; Log end of connect movb cmdtyp,mtyp ; Restore command status ret ; Back to menu ; Connect failed gconsb: call wtcmd ; Wait for TNC master prtx gm5 ; Tell user no connect jr gconng ; and exit ; Timed out waiting for connect gconsc: call dis ; Disconnect slave TNC master call ertime ; Tell user he timed out gconng: mvim logtxt,'A' ; Log as attempt, not connect call log ; Log the connect attempt movb cmdtyp,mtyp ; Restore command status ret ; Back to menu end