.TITLE INPUSE TCP interface routines .SBTTL System and module definitions .NLIST BEX,CND .ENABL LC ; ; Pdp11/dcn user interface routines ; ; This module contains a number of interface subroutines called both ; by the internet process and its protocol modules and by user programs ; (by means of the rt-11 emulator). ; ; External symbols ; ; Entry symbols ; .GLOBL $RECV ;tcp receive data .GLOBL $SEND ;tcp send data .GLOBL $INT ;tcp send urgent (interrupt) ; ; System definitions ; .ASECT .MCALL .COM ;dcnlib definitions .MCALL $DFTCB,$DFSIG ;moslib definitions .MCALL $SGNLI ;moslib macros .COM ;define common data $DFTCB ;define connection control block $DFSIG ;define interprocess signals ; ; Module definitions ; .MACRO $SGINP CODE,DATA ;send signal to internet process .IF DIF,,R0 MOV CODE,R0 .ENDC .IF NB, .IF DIF,,R1 MOV DATA,R1 .ENDC .ENDC JSR PC,$SGINP .ENDM $SGINP .PAGE .SBTTL TCP interface routines ; ; Procedure segment ; ; Process-state procedure ; .PSECT $USEI,RO,I ; ; The following routines are used only with tcp. they provide an interface ; To the tcp buffering facilities. ; ; $int (int) tcp send urgent (interrupt) ; r2 = ccb pointer ; (must be followed by $send/$close) ; $INT: MOV R5,-(SP) ;initialize MOV R1,-(SP) MOV RTXCNT(R2),SNDUP(R2) ;initialize urgent offset $SGINP #SG.WRK,#FL.URG ;signal internet process CTL3: CLR R0 ;return inoccuous status CTL1: MOV (SP)+,R1 MOV (SP)+,R5 RTS PC ; CTL6: MOV #PK.OPN,R0 ;connection open error BR CTL1 ; CTL7: MOV #PK.PAR,R0 ;invalid parameter BR CTL1 ; ; $send (snd) tcp send data ; R0 = byte count, r1 = buffer pointer, r2 = ccb pointer ; Set sign bit of r0 for push ; Returns r0 = status ; $SEND: MOV R5,-(SP) ;initialize MOV R1,-(SP) TST INPCID(R2) ;is connection usable BEQ CTL6 ;if not, exit BIT #FL.TXT,FLAGS(R2) ;send still outstanding? BNE CTL7 ;if so, exit TST R0 ;is push bit set BGT 10$ ;branch if no BIC #100000,R0 ;yes. remove it BEQ CTL7 ;zero byte count not allowed CLR SNDPP(R2) ;initialize push offset SUB R0,SNDPP(R2) SUB QUECNT(R2),SNDPP(R2) SUB RTXCNT(R2),SNDPP(R2) 10$: MOV R0,SNDBR(R2) ;save byte count and buffer address MOV R1,SNDUVA(R2) $SGINP #SG.WRK,#FL.TXT ;signal internet process BR CTL3 ; ; $recv (rcv) tcp receive data ; R0 = max byte count, r1 = buffer pointer, r2 = ccb pointer ; Returns r0 = byte count, set sign bit of r0 for eol ; $RECV: MOV R5,-(SP) ;initialize MOV R1,-(SP) MOV R3,-(SP) CLR -(SP) ;save switch CLR R3 ;initialize eol flag TST INPCID(R2) ;is connection usable BEQ 5$ ;if not, exit MOV RSMHD(R2),R5 ;get pointer to head of reassembly buf SUB CCBRLF(R2),R5 1$: MOV @R5,R3 ;get next byte/code SWAB R3 BIT #RF.TXT*400,R3 ;is it text BEQ 3$ ;branch if no INC @SP ;yes. account for it MOVB R3,(R1)+ CLR (R5)+ MOV R5,-(SP) ADD CCBRLF(R2),@SP CMP (SP)+,RSMEND(R2) ;reached end of buffer? BNE 2$ ;if not, skip SUB RSMLEN(R2),R5 ;else, reset buffer pointer to front 2$: BIT #RF.EOL*400,R3 ;is it eol BNE 3$ ;branch if yes SOB R0,1$ 3$: ADD CCBRLF(R2),R5 ;update buffer pointer MOV R5,RSMHD(R2) ADD @SP,RCVWS(R2) ;update counters ADD @SP,ACKTIK(R2) BIT #RF.EOL*400,R3 ;is push bit set BEQ 4$ ;branch if no BIS #100000,@SP ;yes. reveal to client 4$: $SGINP #SG.WRK,#FL.CHK ;signal internet process 5$: MOV (SP)+,R0 ;restore registers MOV (SP)+,R3 BR CTL1 ; ; $sginp (sig) send signal to internet process ; R0 = code, r1 = data, r2 = ccb pointer ; $SGINP: $SGNLI INPPID(R2),R0,USEPID(R2),INPCID(R2),R1 RTS PC ; .END