.TITLE INPRTP RTP protocol module .NLIST BEX .ENABL LC ; ; Pdp11/dcn rtp protocol module ; ; This module provides a raw internet datagram interface for real-time ; Applications. appropriate emulator calls can be used to construct ; Internet header and options for outgoing packets. incoming packets ; Are validated by the internet layer and passed directly to the user. ; A rudimentary connection open/close protocol is provided for compatibility ; With tcp. ; ; External symbols ; .GLOBL $SGUSE ;routine to signal user process .GLOBL NETIN,NETOT ;network interface routines ; ; Entry symbols ; .GLOBL $RTP ;rtp protocol module ; ; System definitions ; .ASECT .MCALL .COM,.PSA,.IPD,.TRDEF,.TRAP ;dcnlib definitions .MCALL $DFTCB,$DFIH,$DFSIG,$SGNLI ;moslib definitions .MCALL $PUSH,$POP,$SGUSE ;moslib macros .COM ;define common data .PSA ;define process storage areas .IPD ;define internet process storage areas .TRDEF ;define trap codes $DFTCB ;define tcb (control block) $DFIH ;define internet header $DFSIG ;define interprocess signals ; ; Module definitions ; MAXINP = 10. ;max packets (fragments) ; ; Procedure segment ; ; Process-state procedure ; Dsects: r5 = tcb ; .PSECT $SUPI,RO,I ;supervisor i space ; ; Rtp subroutine (entry point from internet process) ; R0 = code, r1 = data, r2 = tcb pointer, returns r0 = state ; $RTP: $PUSH R1,R2,R3,R4,R5 ;save registers MOV R5,R3 MOV R2,R5 ;establish tcb pointer MOV STATE(R5),R4 ;get flags and pennants BIC #^C7,R0 ;extract signal ASL R0 JSR PC,@OPCTBL(R0) ;call routine BIT #ST.DEL,R4 ;is close imminent BEQ 1$ ;branch if no TSTB SNDCNT(R5) ;yes. are all resources returned BNE 1$ ;branch if no $SGUSE #SG.CC ;close complete CLR R4 ;indicate that 1$: MOV R4,STATE(R5) ;return state word MOV R4,R0 $POP R5,R4,R3,R2,R1 ;restore registers RTS PC ; ; Signal 0 - packet received ; PKTIN: BIT #ST.SS,R4 ;is connection open BEQ 1$ ;branch if no CMPB SNDCNT(R5),#MAXINP ;yes. is quota exceeded BLOS 2$ ;branch if no 1$: JSR PC,NETIN ;yes. drop packet(s) RTS PC ; 2$: MOV PH.LNK(R1),R2 ;are there mice MOV -2(R1),R0 ;*** mousetrap BIC #^C17,R0 CMP R0,#7 BNE 3$ ;branch if yes CMP MSGIDM(R3),IH.ID(R1) ;no. does sequence check BEQ 4$ ;branch if yes 3$: .TRAP #TR.LDR,R3,R1,-2(R1),MSGIDM(R3),IH.ID(R1) RTS PC ; 4$: MOV UDPSEQ(R5),PH.LNK(R1) ;save sequence id in two places $SGNLI USEPID(R5),#SG.DAT,INPPID(R5),USECID(R5),R1,UDPSEQ(R5),CCBAST(R5) INC UDPSEQ(R5) ;increment sequence id TST R2 ;is there another fragment BEQ 5$ ;branch if no .TRAP #TR.LDR,R3,R1,-2(R1),#0,IH.FRG(R1) MOV R2,R1 BR 2$ ; 5$: RTS PC ; ; Signal 1 - output packet acknowledgment ; PKTFVS: DEC RTXTMO(R5) ;update user flow control RTS PC ; ; Signal 2 - catenet source quench ; QUENCH: RTS PC ;ignore these silly things ; ; Signal 3 - catenet destination unreachable ; R1 = reason ; UNREAC: BIT #ST.SS,R4 ;is connection open BEQ 1$ ;branch if no $SGUSE #SG.ERR,R1 ;connection error (reason) 1$: RTS PC ; ; Signal 5 - open rtp connection ; OPNCON: MOV PROTCL(R5),R4 ;get initial flags BIC #^C,R4 BIS #ST.SS,R4 ;mark as open CLR RTXTMO(R5) ;initialize user flow control $SGUSE #SG.EST,UDPSEQ(R5) ;connection established RTS PC ; ; Signal 6 - close rtp connection ; CLSCON: BIS #ST.DEL,R4 ;mark for delete RTS PC ; ; Signal 7 - send packet ; SNDPKT: JSR PC,NETOT ;give to net output driver MOV R0,R1 ;is status okay BNE 1$ ;branch if no INC RTXTMO(R5) ;yes. update user flow control RTS PC ; 1$: $SGUSE #SG.ERR,R1 ;connection error (reason) IGNORE: RTS PC ; .PSECT $SUPD,RO,D ;supervisor d space ; ; Operation code branch table ; OPCTBL: .WORD PKTIN ;0 packet received .WORD PKTFVS ;1 output packet completion .WORD QUENCH ;2 catenet source quench .WORD UNREAC ;3 catenet destination unreachable .WORD IGNORE ;4 rtx timer signal .WORD OPNCON ;5 open rtp connection .WORD CLSCON ;6 close rtp connection .WORD SNDPKT ;7 send packet ; .END