.TITLE WHOIS NIC data-base query program .NLIST BEX .ENABL LC ; ; NIC data-base query program ; ; This program opens a TCP connection to the Network Information Center ; SRI-NIC.ARPA host WHOIS port (43) and sends the argument string, presumably ; a user name registered with the NIC. The reply text is transmitted as-is to ; the user terminal. ; ; External symbols ; .GLOBL CTRL,SEND,RECV,NETMSG,RTNMSG ;network routines .GLOBL RNAME ;domain-name server .GLOBL TYPE ;determine ascii char type ; ; Entry symbols ; .GLOBL PRBYT ;char i/o routines ; ; System definitions ; .ASECT .MCALL .COM,.CHR,.MSG ;dcnlib macros .MCALL .TTYIN,.TTYOU,.EXIT,.QSET ;rt-11 macroni .MCALL .SPND,.RSUM,.SCCA,.GTLIN .MCALL $DFSIG ;moslib macroni .MCALL CALL,FORMAT ;netlib macros .COM ;define common data .CHR ;define ascii character codes $DFSIG ;define interprocess signals ; ; Module definitions ; QUESIZ = 20. ;max elements on completion queue TCBSIZ = 2048. ;size of tcb P.TCP = 6. ;tcp protocol number S.WHO = 43. ;who-is port number ; ; Procedure segment ; .PSECT $BOSI,RO,I ; ; NIC data-base query program ; START: BIS #40000,@#44 ;disable folding .QSET #QUEUE,#QUESIZ ;allocate space for completion queue .SCCA #ARGBLK,#SCCA ;disable control-c JSR PC,MBOX ;get argument BCS 2$ ;branch if error MOV #S.WHO,CCBADR+4 SWAB CCBADR+4 ;swab decks CLR TCB ;(pass check in open) CALL CTRL,#CM.OPN,#CCB,#TCB ;open connection TST R0 BEQ 1$ ;branch if no error JSR PC,PRIDNT ;error. display message JSR PC,RTNMSG BR 2$ ; 1$: .SPND ;lots happen in there 2$: .EXIT ; ; Net trap routine ; NCA: MOV SD.ADR(R0),R1 ;get signal particulars MOV SD.CHN(R0),R0 BIC #^C17,R0 ;decode signal MOV R0,R2 ASL R2 ADD R2,PC BR SIGOPN ;0 open BR SIGERR ;1 connection error BR SIGERR ;2 host not responding BR SIGCLS ;3 closed BR SIGDAT ;4 data available BR SIGERR ;5 connection reset BR SIGINT ;6 send complete BR SIGERY ;7 remote disconnect BR SIGERR ;10 remote interrupt BR SIGERR ;11 nsp (decnet) ; SIGCLS: .RSUM ;unlock mainline SIGINT: RTS PC ; SIGOPN: BIS #100000,COUNT ;force push CALL SEND,COUNT,#BUFFER,#TCB ;tcp send data TST R0 ;did it take BEQ SIGERY ;branch if yes JSR PC,PRIDNT ;no. display message JSR PC,RTNMSG BR SIGERY ; SIGERR: JSR PC,PRIDNT ;net error. display message JSR PC,NETMSG SIGERY: CALL CTRL,#CM.CLS,#0,#TCB ;ip close RTS PC ; SIGDAT: CALL RECV,#256.,#BUFFER,#TCB ;flush receive data BIC #100000,R0 ;set pointers BEQ SIGINT MOV #BUFFER,R1 MOV R0,R2 1$: MOVB (R1)+,R0 ;copy everything to operator terminal JSR PC,PRBYT SOB R2,1$ BR SIGDAT ; ; Subroutine to write byte ; R0 = byte ; PRBYT: .TTYOU ;put byte RTS PC ; ; Subroutine to display program ident ; PRIDNT: MOV R0,-(SP) ;appear transparent MOV #COM00,R0 ;display program ident JSR PC,FORMAT MOV (SP)+,R0 RTS PC ; ; Subroutine to parse destination @ ; Returns in buffer, in host ; MBOX: MOV #512,R1 ;is argument in chain area TSTB @R1 BNE 10$ ;branch if yes .GTLIN R1,#PROMPT ;no. prompt for it 10$: MOV #BUFFER,R2 1$: MOVB (R1)+,R0 JSR PC,TYPE BEQ 3$ ;branch if none CMPB R0,#'@ BEQ 2$ ;branch if host name follows MOVB R0,(R2)+ BR 1$ ; 3$: MOV #NICNAM,R1 ;no host specified. use nic 2$: MOVB #CR,(R2)+ ;plant backstop MOVB #LF,(R2)+ SUB #BUFFER,R2 MOV R2,COUNT CALL RNAME,R1,#CCBADR,#0 ;fetch Internet address TST R0 BEQ 5$ ;branch if found JSR PC,PRIDNT ;display error message JSR PC,RTNMSG SEC ;error exit RTS PC ; 5$: CLC ;normal exit RTS PC ; ; Data segment ; .PSECT $BOSD,RO,D ;read-only data ; NICNAM: .ASCIZ 'SRI-NIC.ARPA' ;nic data-base host name PROMPT: .ASCII 'User name? '<200> COM00: .ASCIZ '?WHOIS-^+' COM20: .ASCIZ '?WHOIS-F-Reply timeout' .EVEN ; .PSECT $DATA,RW,I ;initialized read/write data ; ; Connection control block ; CCB: .WORD TCBSIZ ;ccb length .WORD NCA ;completion routine .BYTE P.TCP,44 ;protocol, flags .WORD 0,0,0 ;local socket (default) CCBADR: .WORD 0,0,0 ;remote socket .WORD 0,0 ;max datagram size, options (default) ; .PSECT $ERAS,RW,I ;read/write data ; STOBGN = . ;format fence ARGBLK: .BLKW 5 ;rt-11 argument block SCCA: .BLKW 1 ;.scca switch (not used) COUNT: .BLKW 1 ;name string count BUFPTR: .BLKW 1 ;output buffer pointer QUEUE: .BLKW QUESIZ.*7. ;space for completion queue BUFFER: .BLKW 256. ;output buffer TCB: .BLKW TCBSIZ ;transmission control block ; .END START