;; DLW 1/26/77 -*-Fundamental-*- TITLE CHAOS NET TIME SERVER A=1 B=2 C=3 P=17 GMTDIF==5 ; Difference between EST and GMT zones. NETI==1 NETO==2 .INSRT SYSTEM;CHSDEF > ; The offical contact name is "TIME". The server sends an ANS of 4 bytes. ; The first word of data is the LOW order 16 bits, and the second word ; the HIGH order 16 bits of the number of seconds since Jan 1,1900, midnight GMT. ; Each 16-bit word is made up of two 8-bit bytes in pdp11 order, which is ; wrong for pdp10's. Beware. PKTBUF: BLOCK %CPMXW ; Packet buffer. DEBUG: 0 ; -1 => debugging. PDL: -10,,. BLOCK 10 GO: MOVE P,PDL MOVE A,[JSR TSINT] ; Must handle IOC errors MOVEM A,42 SKIPN DEBUG .SUSET [.SMASK,,[%PIIOC]] .CALL [ SETZ SIXBIT /CHAOSO/ MOVEI NETI MOVEI NETO SETZI 5 ] ;WINDOW SIZE = 5 (ha ha) JSR LOGOUT ;; Construct and send the LSN packet. MOVEI A,%COLSN DPB A,[$CPKOP+PKTBUF] ; OPCODE = LSN MOVE A,[.BYTE 8 ? "T ? "I ? "M ? "E] MOVEM A,PKTBUF+%CPKDT MOVEI A,4 DPB A,[$CPKNB+PKTBUF] .CALL [SETZ ? 'PKTIOT ? MOVEI NETO ? SETZI PKTBUF] JSR LOGOUT ;; Wait for the RFC to come. MOVEI A,%CSLSN ; Listening state. MOVEI B,30.*30. ; 30. second timeout. SKIPE DEBUG MOVSI B,177777 ; or infinite if in debug mode. .CALL [ SETZ SIXBIT /NETBLK/ MOVEI NETO A B SETZM C] JSR LOGOUT CAIE C,%CSRFC ; RFC received state JSR LOGOUT ;; Construct and send the ANS. MOVEI A,%COANS DPB A,[$CPKOP+PKTBUF] MOVEI A,4 DPB A,[$CPKNB+PKTBUF] PUSHJ P,GETTIM ; Get time in A. MOVE C,[440800,,B] IDPB A,C LSH A,-10 IDPB A,C LSH A,-10 IDPB A,C LSH A,-10 IDPB A,C MOVEM B,%CPKDT+PKTBUF ; Data. .CALL [ SETZ ? 'PKTIOT ? MOVEI NETO ? SETZI PKTBUF] JSR LOGOUT ;; Wait for the ANS to get sent, and die. .CALL [ SETZ SIXBIT /FINISH/ SETZI NETO] JSR LOGOUT JSR LOGOUT LOGOUT: 0 SKIPL DEBUG .LOGOUT .VALUE GETTIM: .RLPDTM A, ; Get in A, # secs since beg of year. CAME A,[-1] CAMN B,[-1] JSR LOGOUT ; If either is -1, time not known. CAIGE B, ; If 4.9 on, SUBI A,24.*3600. ; subtract 1 day - .RLPDTM misfeature! TLNE B,100000 ; Bit 4.7 = Daylight Savings time? SUBI A,3600. ; If on, subtract one hour to get Standard. MOVEI B,-1900.(B) ; Get year, relative to 1900. MOVEI C,-1(B) ; Adjust and LSH C,-2 ; Get # leap years since 1900 not including this year. IMULI B,365. ; Find # days in years thus far ADDI B,(C) ; Plus # LY's, to get total days in years past. IMULI B,86400. ; Now get # seconds in all them days. ADD A,B ; and produce total seconds since 1/1/00 ! ADD A,[GMTDIF*3600.] ; Adjust to GMT. POPJ P, TSINT: 0 ? 0 JSR LOGOUT ; IOC error END GO