1 Copyright (c) 1999 Massachusetts Institute of Technology
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 3 of the License, or (at
6 your option) any later version.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 ------------------------------
18 Warning- don't believe everything in this file!
25 FUNCTION: OPEN channel to Network
28 1. Channel number in AC field of .OPEN instruction
29 2. 4 word block addressed by @ E (X) field of
31 4 word block has this form:
33 _________________________________________________
35 | MODE BITS | SIXBIT /NET/ |
36 |_______________________|_______________________|
39 |_______________________________________________|
42 |_______________________________________________|
45 |_______________________________________________|
50 |--------- don't buffer more
51 | output than allocation
56 ____________________________________________________________________________
57 | | | | | |out|big|by- lis gen|im- |
58 | | SIZE OF BYTE | | |ctl|buf| te ten sok|age blk out|
59 |___________|___________|___________|___|___|___|___|___|___|_#_|___|___|___|
61 BYTE SIZE IF | 0-"NORMAL" | | | |
62 MODE=44 __| 1-8 BIT BYTE SIZE _______| | |
63 (BYTE & IMAGE) IF ASCII | | STANDARD
64 USE BYTE FIELD | | ITS
68 1-LISTEN ON ___________| | | 0XX ASCII |
69 LOCAL SOCKET | | 1XX IMAGE |
71 0-USE LOCAL | | X1X BLOCK |
72 SOCKET FIELD | | XX0 INPUT |
73 1-GENERATE _______________| | XX1 OUTPUT |
74 "UNIQUE" SOCKET |____________|
82 32 bit socket # for local identification
85 32 bit socket # determined by foreign host
89 8 bit socket # specifying computer system
95 SKIPS: No Skip If Fails
98 Indicated in LH of .STATUS value (low order 6 bits
106 (gender of socket wrong for mode)
112 (NCP not up, or IMP not up)
114 13 "FILE ALREADY EXISTS"
115 (socket already open by you on another channel)
117 22 "CONTRADICTORY OPEN"
118 (byte size mismatched)
121 (socket number not part of your allocated
122 "unique" group of 8 allocated to your job)
124 41 "OTHER END OF PIPELINE GONE OR NOT OPEN"
125 (HOST dead or non-existant see NETHST call)
133 ;to listen .OPEN ch, listen
140 0 ;socket determined when
141 matching RFC received
142 0 ;host determined when
143 matching RFC received
146 :to get "unique socket"
151 0 ;determined by system
160 arg 1 mode,,channel number
169 FUNCTION: Read extended STatus of network CHannel
171 ARGUMENT TEMPLATE: AC/ channel,,
175 WORD _________________________________
178 |_______________|_______________|
181 |_______________________________|
184 |_______________________________|
186 3 | I | (reserved)| SIZE | HOST |
187 |___|___________|_______|_______|
189 4 | IMP DOWN | STATE |
190 |_______________|_______________|
192 5 | (reserved) | CLS |
193 |_______________|_______________|
195 6 | (reserved) | #BITS |
196 |_______________|_______________|
201 set by receipt over network of INR/INS
202 control message (see protocol)
204 causes interrupt on channel
208 byte size of connection (bits 2.9 - 2.1)
211 9 bit field (8 used by Network foreign host #)
214 time in 1/30 sec. until IMP going down
218 +n planned to go down in n/30 sec.
219 (see also NETIMP call)
223 %NSCLS 0 connection closed
224 %NSLSN 1 listening for RFC
225 %NSRFC 2 RFC in to listen
226 %NSRCL 3 CLS received after RFC
229 %NSRFN 6 RFNM wait on output
230 %NSCLW 7 CLS sent, waiting for matching CLS
231 %NSCLI 10 CLS received data available to input
232 %NSINP 11 input available
235 REASON FOR CLS (state 0)
236 %NCNTO 0 never opened connection (not .OPEN)
237 %NCUSR 1 CLS by user (.CLOSE)
238 %NCFRN 2 CLS by foreign host
239 %NCRST 3 RST (reset) from foreign host (dead)
240 %NCDED 4 host dead (see also NETHST call)
241 %NCINC 5 incomplete transmission (see NETHST)
242 %NCBYT 6 byte size mismatch
243 %NCNCP 7 local NCP went down, breaking connection
244 %NCRFS 10 connection refused by foreign host
249 FAILURE RETURNS: None
267 arg 1 network channel number
270 val 2 local socket number
271 val 3 foreign socket number
272 val 4 4.9 interrupt received
275 val 5 LH IMP Down time/reason
276 RH Socket state (%NSxxx)
278 val 7 RH Close reason (%NCxxx)
279 val 8 RH Number of bits
\b\b\b\b____ available
280 (input data available or output buffer room)
285 arg 1 network channel number
288 val 2 Socket state (%NSxxx)
289 val 3 Number of bytes
\b\b\b\b\b_____ available
290 (input data available or output buffer room)
291 val 4 Close reason (%NSxxx)
293 This call is usually used to respond to a second-word interrupt
294 from a network channel.
300 FUNCTION: Reads status of Network channel
303 Channel number in AC field of .STATUS instruction
305 RETURNS: Status of word in location addressed by
306 @ E (X) fields of .STATUS instruction
311 FAILURE RETURNS: None
320 FORMAT OF STATUS WORD
322 _________________________________
324 | ERROR CODE | SS0026 |
325 |_______________|_______________|
329 if IOC (I/O channel error) or OPEN failure,
330 codes will be stored here.
333 state (byte 140600), same as that given for
334 .RCHST -- see list of states
337 code for Network device
346 val 1 status word as above
352 FUNCTION: NETwork ACcepts Connection (after LISTEN type
354 (to REJECT, do a .CLOSE)
357 Channel number in AC field of .NETACC instruction
361 SKIPS: Skips on success
364 Not skip --not in state 2 (RFC received to LISTEN)
366 SIDE EFFECTS: Sends matching RFC (and "allocate" if input)
378 FUNCTION: NET Send buffer now
379 (Buffer is normally sent when "full" or after
380 1/2 second of first activity)
383 Channel number in AC field .NETS of instruction
390 IOC (I/O channel error)
391 Code 1, if not SEND (write) channel
393 SIDE EFFECTS: Buffer is queued to be sent immediately
403 Equivalent to .NETS (see above)
410 Does FORCE then waits for all buffered data to be sent
411 and for the final RFNM to come back.
416 FUNCTION: CLOSEs channel and returns immediately
419 Channel number in AC field of .CLOSE instruction
425 FAILURE RETURNS: None
440 FUNCTION: Hang until connection is not in specified
441 state or until time out
444 Standard .CALL arguments
446 2. state -- returns when not in this state
447 3. (optional) time -- number of 30ths of second
448 to wait or -- (time since system up) in 30ths
451 RETURNS: 1. (optional) state -- new state
452 2. (optional) time -- time left after state
455 SKIPS: Skips on success
459 OPEN code 14 -- channel number not <20
460 -- channel not Network device
480 State: <
\b-wait for this state to be left>
\b-
482 Time: <
\b-30ths of second to wait>
\b-
489 The time argument is clobbered in the same way that
490 .SLEEP clobbers its AC; unless it is immediate. In that
491 case, the time out will be restarted if the job is pclsred.
496 FUNCTION: Used to RESET interrupt bit
497 (INR/INS from Network)
500 Channel number in AC field of .RESET instruction
506 FAILURE RETURNS: None
508 SIDE EFFECTS: Clears the Network interrupt bit (see .RCHST,
524 FUNCTION: Sends Network INR/INS control message for
525 link corresponding to channel. (TELNET protocol also
526 demands a "data mark" to be inserted in the stream)
529 Channel number in AC field of .NETINT instruction
533 SKIPS: Skip if success
534 No skip if Network down or not a Network
538 I/O Channel error Interrupt, NET went down
541 SIDE EFFECTS: Sends NET INR/INS control message
555 FUNCTION: Get socket map
560 Name of first of 2 consecutive accumulators in AC
561 field of .GETSYS instruction
563 ac/ -<
\b-length>
\b-,,<
\b-address>
\b- ;CPTR to block to store
565 ac+1/ SIXBIT/<
\b-name>
\b-/ ;sixbit name of area
569 RETURNS: Block of desired information
571 SKIPS: Skips on success
574 No skip -- area name not known in system -- not
577 (ac gets <-lng,,> for number of words needed)
582 ;This can be used to find out how much storage is
583 needed for a .GETSYS block
586 MOVE ac+1, [SIXBIT/NCPSM/]
588 HLRES ac ;here ac contains
590 MOVNS ac ;now ac contains
598 MOVE ac+1 [SIXBIT /NCPSM/]
611 Length -- 400 (8) words (256(10))
613 Format -- one word per host number
614 (word(i) is data for host.number (i))
616 Each word has info packed --
619 ______________________________________________
622 |N|unused|RST| CTL TIME|00| HOST DEAD STATUS |
624 |_|______|___|_________|__|__________________|
627 RFNM 0-control link open
628 1-waiting for RFNM on control link
630 RST 0-host down or not tried
631 1-sent RST to see if up
632 2-got RRP, connections may be opened
635 Last time (1/30 sec module 2 )
636 message sent to this host on control link (0)
639 Last HOST DEAD STATUS from this host's IMP
642 (If data for a single host is desired, use the NETHST call)
644 HOST DEAD STATUS in right half
646 Bits 20-31 (byte pointer [041400,,x])
647 give the time of the Host's coming back up,
648 bit-coded as follows:
651 Bits 20-22 (byte pointer [150300,,x]
652 the day of the week the Host is coming back up
653 Monday is day 0 and Sunday is day 6
655 Bits 23-27 (byte pointer [100500,,x])
656 the hour of the day, from hour 0 to hour 23,
657 that the Host is coming back up
659 Bits 28-31 (byte pointer [040400,,x])
660 the five minute interval, from 0 to 11, in the
661 hour that the Host is coming back up
664 All three of the above are specified in Universal Time
665 (i.e., G.M.T.). The Host may indicate that it will be
666 coming back up more than a week away by setting bits 20-31
667 all to ones (7777). Setting all bits 20-30 to one and bit
668 31 to zero (20-31 = 7776) means it is unknown when the Host
671 \fBits 32-35 have the follwing meanings:
676 0 The destination Host is not communicating with the
677 network -- the destination IMP has no information
678 about the cause. Note that this is the message most
679 likely to occur if the destination IMP has gone down
680 since the destination Host went down.
682 1 The destination Host is not communicating with the
683 network -- it took its ready-line down without saying
686 2 The destination Host is not communicating with the
687 network -- the Host was tardy in taking traffic from
688 the network and the network had to declare the Host
691 3 The destination Host does not exist to the knowledge
696 5 The destination Host is down for scheduled P.M.
698 6 The destination Host is down for scheduled hardware
701 7 The destination Host is down for scheduled software
704 8 The destination Host is down for emergency restart.
706 9 The destination Host is down because of power outage.
708 10 The destination Host is stopped at a software
711 11 The destination Host is down because of a hardware
714 12-15 Currently Unused.
716 When the value of this 4-bit field is 0,1,2, or 3, bits 20-31
717 will have the "unknown" indication.
718 \fNCPPQ area -- pending queue of RFC's
720 Length -- variable 3+4*n where n is currently 40 (8) but
724 word 0 -- relocation word, tells location in system
725 core where first slot begins
727 word 1 -- pointer to first queue entry
729 word 2 thru 4*n+1 -- 4 word slot for queue or -1 if
731 (0) -- pointer to next one (must un-relocate,
733 (1) -- local socket number
734 (2) -- foreign socket number
735 (3) -- sign bit 0 = STR 1 = RTS
736 low order 8 bits (byte pointer [001000,,X])
739 next 8 bits (byte pointer [101000,,x])
743 Example of unrelocating for the NCPPQ area.
744 ;Let ac,ac+1 and b be accumulators
747 MOVE ac+1, [SIXBIT /NCPPQ/]
751 MOVN b,(ac) ;-system address
752 loop: ADD ac,b ;ac now points to
755 ;0(ac) is next pointer word
756 ;1(ac) is local socket word
757 ;2(ac) is foreign socket word
758 ;3(ac) is Host -- lind/byte word
760 MOVE ac,0(ac) ;get next
761 JUMPGE ac,loop ;loop if not last one
765 Length -- 1+13.*20. = 261(10) or 405(8)
766 there are 13 (or more) blocks each of length
767 IMPSTL (an assebly parameter, currintly 20(n))
770 word 0 -- contains IMPSTL, the number of words
772 word 1 -- begins first block -- the blocks are:
774 IMSOC1: REPEAT IMPSTL,0 ; 0 => FREE
775 ; 4.9 = 1 => SOCKET IN USE
776 ; 4.8 = 1 => CHNL TRYING TO BE CLOSED
777 ; 3.1-4.7 MASK FOR INTERRUPT BIT (LSH 1 CHNL#)
779 IMSOC2: BLOCK IMPSTL ; 1.1-4.5 = LOCAL SOCKET NUMBER
780 ; 4.6-4.9 0 (MAKES COMPARISONS EASIER)
781 IMSOC3: BLOCK IMPSTL ; 1.1-4.5 = FOREIGN SOCKET NUMBER
783 IMSOC4: BLOCK IMPSTL ; RH = SOCKET STATE
784 ; 3.1-3.8 = LINK NUMBER
785 ; 3.9-4.7 = FOREIGN HOST NUMBER
786 ; 4.8 = SET BY RCV CLS - MAKES MATCH USING IMSCHD FAIL
787 ; 4.9 = SEND THIS BUFFER NOW
788 IMSOC5: BLOCK IMPSTL ; 1.1-1.8 = CONNECTION BYTE SIZE
789 ; 2.1-2.9 = CLOSE REASON
790 ; 3.1-3.8 = USER BYTE SIZE
791 ; 3.9 => ASCII MODE - 7 BIT
792 ; 4.1 => ASCII MODE - 8 BIT
794 ; 4.3 => NET INTERRUPT (INR/INS) RECEIVED
795 ; 4.4 => HAVE BEGUN CLOSE TIMEOUT
796 ; 4.5 => CLOSED WHILE IN RFNM WAIT, EXPECT ANOTHER RFNM
797 ; 4.9 => TRANSFER IN 32 BIT MODE
798 IMSOC6: BLOCK IMPSTL ; RH => BUFFER ADDRESS
799 ; 4.9 => LOCKED BY CORE JOB
800 ; 4.8 => ACTIVE AT PI LEVEL
801 ; 4.7 => INPUT OCCURRED WHILE BUFFER LOCKED
802 ; 3.1-3.8 => IOBFT INDEX, OR 377 IF BIG BUFFER
803 IMSOC7: BLOCK IMPSTL ; BIT ALLOCATION
804 IMSOC8: BLOCK IMPSTL ; MESSAGE ALLOCATION
805 IMSC7I: BLOCK IMPSTL ; AMOUNT TO INCREASE BIT ALLOCATION BY IN NEXT ALL MSG
806 IMSC8I: BLOCK IMPSTL ; AMOUNT TO INCREASE MESSAGE ALLOCATION BY " " " "
807 IMSOCT: BLOCK IMPSTL ; TIME WHEN FIRST MESS PUT INTO BUF
808 ; (DURING INPUT HAS NUMBER OF DATA BYTES LEFT IN MSG)
809 ; (DURING CLOSE HAS TIME TIMEOUT STARTED)
810 IMSMPP: BLOCK IMPSTL ; MAIN PROGRAM POINTER, ILDB OR IDPB FOR NEXT BYTE
811 IMSMPC: BLOCK IMPSTL ; MAIN PROGRAM COUNTER, FOR OUTPUT HAS ROOM LEFT
812 ; IN BUFFER IN BYTES. FOR INPUT HAS TOTAL NUMBER
813 ; OF DATA BYTES IN THE BUFFER.
814 IMSPIP: BLOCK IMPSTL ; INTERRUPT LEVEL POINTER. FOR OUTPUT ILDB GETS
815 ; FIRST BYTE OF NEXT MESSAGE OUT. FOR INPUT RH
816 ; HAS ADDRESS OF HEADER WORD OF NEXT MESSAGE IN.
817 IMSBFE: BLOCK IMPSTL ; BYTE POINTER TO LAST BYTE IN BUFFER.
821 FUNCTION: Transfer data in or out over Network
824 Channel number in AC field of .IOT in struction
825 <
\b-word>
\b- or pointer to block
827 RETURNS: None (unit output mode)
828 Datum (unit input mode)
829 Updated pointer (block mode)
834 I/O Channel error INTERRUPT
835 Code 1 -- Network went down
836 Code 8 -- Attempted output mode IOT when not in
837 State 5 (open) or State 6 (RFNM wait)
838 Or attempted input IOT when in bad state
839 or when closed other than by foreign host.
840 End of file is sensed when input is done from
841 a socket closed by the foreign host. In unit
842 image mode this gives I/O channel error code 2.
845 Output -- data buffered to be sent
846 Input -- data copied from buffer ALLOCATE sent if
847 buffer empty (enough)
849 EXAMPLE: .IOT ch, foo
852 In image block mode, one byte per word is transferred,
855 In ascii block mode, five bytes per word are transferred,
856 or four bytes per word (8-bit) if mode bit 1.6 was on in