.TITLE NAMSRV Name server .NLIST BEX .ENABL LC ; ; Pdp11/dcn - name server ; ; This program is an internet name caller/server allegedly compatible ; with ien-116. ; ; External symbols ; .GLOBL XNAME,GETPKT,SNDPKT,FREPKT ;utility routines .GLOBL OPNBLK ;connection block ; ; Entry symbols ; .GLOBL NAMREQ ;name server ; ; System definitions ; .ASECT .MCALL .COM,.CHR ;dcnlib definitions .MCALL $DFIH,$DFUH,$DFSIG ;moslib definitions .MCALL DFCON,CALL,FORMAT ;netlib macros .COM ;define common data .CHR ;define ascii character codes $DFIH ;define internet header $DFUH ;define user datagram header $DFSIG ;define interprocess signals DFCON ;define connection block ; ; Module definitions ; ; Name server codes ; NM.NAM = 1 ;host name NM.ADR = 2 ;address NM.ERR = 3 ;error NM.MAX = 3 ;max value ; NE.UNS = 0 ;unspecified error NE.NTF = 1 ;name not found NE.SYN = 2 ;syntax error ; .PSECT $BOSI,RO,I ; ; Name request ; R0 = udp length, r1 = packet pointer, r2 = udp header pointer ; NAMREQ: CMP R0,#UH.LEN+64. ;is format valid BLOS 1$ ;branch if yes JSR PC,FREPKT ;no. free packet buffer RTS PC ; 1$: MOV R2,R3 ;set pointers ADD R0,R3 FORMAT #COM81 ;name request from [host] MOV #QNAME,R0 ;copy host name ADD #UH.LEN+2,R2 2$: CMP R2,R3 BHIS 3$ MOVB (R2)+,(R0)+ BR 2$ ; 3$: CLRB (R0)+ ;stash backstop JSR PC,FREPKT ;free packet buffer JSR PC,GETPKT ;get reply packet BCS 8$ ;branch if cant ADD PH.OFS(R1),R1 ;construct pointers MOV R1,R2 ADD #UH.LEN,R1 MOV #QNAME,R0 ;copy name 4$: MOVB (R0)+,(R1)+ BNE 4$ TSTB -(R1) ;back over stop CALL XNAME,#QNAME,#RDATA,#0 ;get ip address TST R0 BNE 5$ ;branch if not found MOVB #NM.ADR,(R1)+ ;found. copy ip address MOVB #4,(R1)+ MOV #RDATA,R0 MOVB (R0)+,(R1)+ MOVB (R0)+,(R1)+ MOVB (R0)+,(R1)+ MOVB (R0)+,(R1)+ BR 7$ ; 5$: MOV #ERR1,R0 ;copy error message 6$: MOVB (R0)+,(R1)+ BNE 6$ TSTB -(R1) ;back over stop 7$: MOV R1,R0 ;send packet SUB R2,R0 JSR PC,SNDPKT 8$: RTS PC ; ; Data segment ; .PSECT $BOSD,RO,D ; ; Text strings ; COM81: .ASCIZ '?UDP-I-Name request ^C' ERR1: .ASCIZ '?UDP-F-Name not found' ERR1A = .-3 .EVEN ; .PSECT $ERAS,RW,I ; ; Variables ; RDATA: .BLKB 4 ;ip address QNAME: .BLKB 64.+1 ;host name .EVEN ; .END