.TITLE NETCOM COMMON PACKET INTERFACE .SBTTL SYSTEM AND MODULE DEFINITONS .NLIST BEX .ENABL LC ; ; Pdp11/dcn basic operating system - common packet interface ; ; This module is a common interface for packet protocols using ip-4. ; ; External symbols ; .GLOBL CTRL,NETMSG,RTNMSG .GLOBL HASH,RDDEC,FORMAT,PRD50,PROCB .GLOBL NETDAT,NETSIG,INIT,KWKTBL,COM00 ; ; Entry symbols ; .GLOBL RDLIN,FLAGS,OPNBLK .GLOBL HELP,RDBYT,PRBYT,PRIDNT,ERRLVL .GLOBL TTOBUF,CHAIN,PRTPTR,NETAST ; ; System definitions ; .ASECT .MCALL .COM,.CHR,.CHN ;dcnlib definitions .MCALL .WIND ;dcnlib macros .MCALL $DFIH,$DFSIG ;moslib definitions .MCALL DFCON,CALL,HOST,FORMAT ;netlib macros .MCALL .TTYOU,.EXIT,.PRINT,.TTYIN,.SRESE,.SCCA,.QSET ;rt-11 macros .COM ;define common data .CHR ;define ascii character codes .CHN ;define argument area $DFIH ;define internet header $DFSIG ;define interprocess signals .LIST ME DFCON ;define connection block .NLIST ME ; ; Assembly parameters ; QUESIZ = 20. ;max elements on completion queue . = 500+ENDCHN+200 ;make room for stack .PAGE .SBTTL MAIN SCHEDULING AND DISPATCHING LOOP ; .PSECT $BOSI,RO,I ; ; Subroutine to reflect completion routines ; NETAST: TST (R0)+ ;sd.dst. save parameters MOV (R0)+,OPCODE ;sd.chn MOV (R0)+,CONID ;sd.blk MOV (R0)+,DATA ;sd.adr MOV (R0)+,SSID ;sd.cnt MOV #OPNBLK,R1 ;net signal. search for match 1$: CMP CONPTR(R1),CONID BEQ 2$ MOV CONLNK(R1),R1 BNE 1$ FORMAT #MSG04,#OPCODE ;unrecognized net signal [code] RTS PC ; 2$: MOVB OPCODE,R0 ;get opcode ASL R0 ADD R0,PC BR SIGOPN ;0 open BR SIGERR ;1 connection error (reason) BR SIGERR ;2 host not responding (reason) BR SIGINT ;3 closed BR SIGDAT ;4 data available BR SIGERR ;5 connection error (reason) BR SIGCOM ;6 send complete BR SIGINT ;7 remote disconnect BR SIGINT ;10 remote interrupt BR SIGCOM ;11 nsp (decnet) ; SIGOPN: MOV DATA,UDPSEQ ;open MOV R1,R0 ADD #CONPAR,R0 CALL CTRL,#CM.STA,R0,CONPTR(R1) CMP ERRLVL,#1 ;is detail requested BHIS SIGCOM ;branch if no FORMAT #MSG11 BR SIGCOM ; SIGDAT: MOV DATA,R0 ;data available BEQ 2$ ;branch if tcp CMP SSID,UDPSEQ ;udp. is this in sequence BEQ 10$ ;branch if yes FORMAT #MSG05,#OPCODE ;no. sequence error RTS PC ; 10$: INC UDPSEQ ;okay. bump sequence MOV R1,-(SP) ;does sequence match buffer MOV R0,R1 CLR R0 .WIND CMP SSID,PH.LNK(R1) BEQ 1$ ;branch if yes FORMAT #MSG06,#OPCODE ;no. buffer error MOV (SP)+,R1 RTS PC ; 1$: MOV R1,R0 ;alien pointers MOV (SP)+,R1 2$: JSR PC,NETDAT RTS PC ; SIGINT: CMP ERRLVL,#1 ;is detail requested BHIS SIGCOM ;branch if no SIGERR: CMP ERRLVL,#2 ;is anything requested BHIS SIGCOM ;branch if no MOV R1,-(SP) ;yes. display message FORMAT #MSG00 MOVB OPCODE,R0 MOV DATA,R1 JSR PC,NETMSG MOV (SP)+,R1 SIGCOM: MOV OPCODE,R0 JSR PC,NETSIG RTS PC .PAGE .SBTTL SUBROUTINES FOR COMMAND INTERPRETER ; ; Main interpreter loop ; Reads commands and dispatches execution routines ; START: MOV R0,CHAIN ;save argument pointer .SRESE ;wash and scrub channel table .SCCA #TTOBUF,#SCCA ;disable control-c .QSET #QUEUE,#QUESIZ ;allocate space for completion queue CLR FLAGS ;initialize bits and peices CLR ERRLVL CLR PRTPTR BIS #040100,@#44 BIT #000400,@#44 ;copy chain bit BEQ 1$ BIS #CHNBIT,FLAGS MOV CHAIN,R0 ;read first line from argument ADD #12,R0 JSR PC,RDLIN 1$: JSR PC,INIT ;initialize protocol module 2$: CLR R0 ;get command line from console JSR PC,RDLIN JSR PC,HASH ;get command name BEQ 2$ ;ignore if empty line MOV #KWKTBL,R1 ;search for match 4$: TST (R1)+ ;is this end of table BEQ 3$ ;branch if yes CMP R0,-2(R1) ;no. do entries match BEQ 3$ ;branch if yes TST (R1)+ ;no. step to next BR 4$ ; 3$: ADD @R1,R1 ;entries match. call subroutine JSR PC,@R1 BR 2$ ; ; Rdlin (gtl) ret next command line ; R0 = buffer pointer ; RDLIN: TST R0 ;is this console BNE 1$ ;branch if no MOV #TTIBUF,TTIPTR ;reset pointer 2$: .TTYIN BIC #^C177,R0 BEQ 2$ MOVB R0,@TTIPTR ;save char INC TTIPTR BIT #10000,@#44 ;is char mode set BNE 4$ ;branch if yes CMP R0,#LF ;is it lf BEQ 4$ ;branch if yes CMP R0,#SUB BEQ 4$ CMP R0,#ETX BEQ 4$ CMP TTIPTR,#TTIEND-1 ;is this overflow BLO 2$ ;branch if no 4$: CLRB @TTIPTR ;end of record. park trailer MOV #TTIBUF,R0 1$: MOV R0,RDBPTR ;stash pointer RTS PC ; ; Rdbyt (rdb) get byte from telnet input buffer ; Returns r0 = byte (zero if eol) ; RDBYT: MOVB @RDBPTR,R0 ;is it real BEQ 1$ ;branch if eor INC RDBPTR 1$: RTS PC ; ; Prbyt (prb) put byte in telnet output buffer ; R0 = byte ; PRBYT: TST PRTPTR ;is this direct output BNE 1$ ;branch if no .TTYOU ;yes. straight on RTS PC ; 1$: MOVB R0,@PRTPTR ;stash byte INC PRTPTR MOVB #200,@PRTPTR RTS PC ; ; Help (hel) send help information ; (segment of command language interpreter) ; (no arguments) ; HELP: .PRINT #COM52 ;commands are: MOV #KWKTBL,R1 ;format command table 2$: MOV #8.,R2 MOV #TTOBUF,PRTPTR 3$: MOV (R1)+,R0 ;insert command name JSR PC,PRD50 TST (R1)+ ;skip over entry TST @R1 ;is this end of list BEQ 6$ ;branch if yes DEC R2 ;no. is this end of line BEQ 5$ ;branch if yes MOV #HT,R0 ;no. tab a field JSR PC,PRBYT BR 3$ ; 5$: CLRB @PRTPTR .PRINT #TTOBUF ;print next line BR 2$ ; 6$: CLRB @PRTPTR .PRINT #TTOBUF ;print last line CLR PRTPTR RTS PC ; ; Subroutine to display inet message ; PRIDNT: MOV R0,-(SP) ;appear transparent FORMAT #COM00 ;display program ident MOV (SP)+,R0 ;display inet message JSR PC,RTNMSG RTS PC .PAGE .SBTTL TABLES, TEXT STRINGS AND VARIABLES ; ; Data segment ; .PSECT $BOSD,RO,D ; MSG00: .ASCIZ '?INET-(^R'')-^+' MSG11: .ASCIZ '?INET-(^R'')-I-Open ^C' MSG04: .ASCII '?INET-F-Unrecognized signal ^BI'<0> MSG05: .ASCIZ '?INET-F-Sequence error ^K'<0>' ^K'<2>' ^K'<4>' ^K'<6>' ^K'<10> MSG06: .ASCIZ '?INET-F-Buffer error ^K'<0>' ^K'<2>' ^K'<4>' ^K'<6>' ^K'<10> COM52: .ASCIZ 'Commands are:' .EVEN ; ; Variables ; SCCA: .BLKW 1 ;scca indicator (ignored) OPCODE: .BLKW 1 ;msg opcode CONID: .BLKW 1 ;msg connection id (ccb pointer) DATA: .BLKW 1 ;msg data SSID: .BLKW 1 ;msg sequence id UDPSEQ: .BLKW 1 ;sequence id FLAGS: .BLKW 1 ;flags and other things that wave ERRLVL: .BLKW 1 ;error level CHAIN: .BLKW 1 ;chain area pointer TTIPTR: .BLKW 1 ;cli input text pointer RDBPTR: .BLKW 1 ;rdbyt input text pointer PRTPTR: .BLKW 1 ;prbyt output text pointer QUEUE: .BLKW QUESIZ.*7. ;space for completion queue TTOBUF: .BLKW 2*256. ;output buffer TTIBUF: .BLKB 133. ;input buffer TTIEND = . ;end of input buffer .EVEN ; .END START