1 " ***********************************************************
  2 " *                                                         *
  3 " * Copyright, (C) Honeywell Information Systems Inc., 1983 *
  4 " *                                                         *
  5 " ***********************************************************
  6      proc;
  7           head;
  8           defidx 1, atq, ar, aw, al, bl, cb, cfr, cm, ds, d, dw, dr, ec, eh, fel,
  9           fes, fu, gnr, gs, gt, ia, isi,
 10           i, lrs, ne, qe, r, rh, r1, sbs, sds, sew, sfd, sf, s,
 11           s1, sn, sur, ul, ur, w;
 12 
 13           defidx 1, Active, Listen, Rfc_rcvd, Abort, Rfc_sent, Open, Cls_wait, Reject_wait, Data_wait, Rfnm_wait, Cls_read, Forimp;
 14 
 15           defidx 17, Rts, Str, Cls, All, Gvb, Ret, Int, Buf;
 16 
 17           defidx 0, NOP, RTS, STR, CLS, ALL, GVB, RET, INR, INS, ECO, ERP, ERR, RST, RRP;
 18 
 19           defidx 64, FSOC, LSOC, LINKN, BSPACE, MSPACE, CODEF, ERRTX, ECODT, FSOC1, BYTE;
 20 
 21           defidx 1, netstate, netclose, netfhost, netbgend, netnotup, areasmal, notalloc, undorder, badproci, badindex;
 22 
 23 /* SOCKET STATES - 1 = active, 2 = listening, 3 = rfc-rcvd, 4 = abort, 5 = rfc-sent, 6 = open, 7 = cls-wait,
 24    8 = reject-wait, 9 = data-wait (send) , 10 = rfnm-wait (send) , 11 = cls-read (read) , 12 = active-imp, 13 = croggled */
 25 
 26 com_state_tbl_: tbl inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, abort6_,
 27           inv_state_, inv_state_, inv_state_, abort10_, abort11_, abort6_, inv_state_; /* abort - 1 */
 28           tbl connect1_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_,
 29           inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_; /* connect - 2 */
 30           tbl listen1_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_,
 31           inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_; /* listen - 3 */
 32           tbl inv_state_, inv_state_, reject3_, reject4_, inv_state_, inv_state_,
 33           inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_; /* reject - 4 */
 34           tbl inv_state_, inv_state_, accept3_, reject4_, inv_state_, inv_state_,
 35           inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_; /* accept - 5 */
 36           tbl inv_state_, close2_, close3_, close4_, close5_, close6_,
 37           inv_state_, inv_state_, inv_state_, nop_, abort11_, close12_, close13_; /* close - 6 */
 38           tbl fdeac1_, fdeac1_, fdeac1_, fdeac1_, fdeac1_, deac11_,
 39           deac11_, deac11_, deac11_, deac11_, deac11_, fdeac12_, fdeac13_; /* force-deac - 7 */
 40           tbl inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, sendquit6_,
 41           inv_state_, inv_state_, inv_state_, nop_, nop_, inv_state_, inv_state_; /* sendquit - 8 */
 42           tbl quitenable_, quitenable_, quitenable_, quitenable_, quitenable_, quitenable_,
 43           quitenable_, quitenable_, quitenable_, quitenable_, quitenable_, quitenable_, inv_state_; /* quitenable - 9 */
 44           tbl quitinhib_, quitinhib_, quitinhib_, quitinhib_, quitinhib_, quitinhib_,
 45           quitinhib_, quitinhib_, quitinhib_, quitinhib_, quitinhib_, quitinhib_, inv_state_; /* quitinhibit - 10 */
 46           tbl setbyte1_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_,
 47           inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_; /* setbytesize - 11 */
 48           tbl forimp_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_,
 49           inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, inv_state_; /* forimp - 12 */
 50           tbl inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, read6_,
 51           inv_state_, inv_state_, inv_state_, inv_state_, read11_, inv_state_, inv_state_; /* read - 13 */
 52           tbl nop_, nop_, state3_, state4_, nop_, nop_,
 53           nop_, nop_, nop_, nop_, nop_, nop_, nop_;                   /* state - 14 */
 54           tbl inv_state_, inv_state_, inv_state_, inv_state_, inv_state_, write6_,
 55           inv_state_, inv_state_, inv_state_, write10_, inv_state_, write6_, inv_state_; /* write - 15 */
 56           tbl deac1_, deac1_, deac3_, deac4_, deac5_, deac6_,
 57           deac7_, deac7_, deac7_, deac7_, deac11_, fdeac12_, fdeac13_;          /* deactivate - 16 */
 58           tbl auto_reject_, rts2_, rfc3_, rfc3_, rts5_, auto_reject_,
 59           rfc7_, auto_reject_, auto_reject_, auto_reject_, auto_reject_, auto_reject_, auto_reject_; /* RTS - 17 */
 60           tbl auto_reject_, str2_, rfc3_, rfc3_, str5_, auto_reject_,
 61           rfc7_, auto_reject_, auto_reject_, auto_reject_, auto_reject_, auto_reject_, auto_reject_; /* STR - 18 */
 62           tbl inv_CLS_, inv_CLS_, cls3_, inv_CLS_, cls5_, cls6_,
 63           cls7_, cls8_, cls9_, inv_CLS_, inv_CLS_, inv_CLS_, inv_CLS_; /* CLS - 19 */
 64           tbl inv_com_, inv_com_, inv_com_, inv_com_, inv_com_, all6_,
 65           nop_, inv_com_, all6_, inv_com_, inv_com_, inv_com_, inv_com_;        /* ALL - 20 */
 66           tbl inv_com_, inv_com_, inv_com_, inv_com_, inv_com_, gvb6_,
 67           nop_, inv_com_, gvb6_, inv_com_, inv_com_, inv_com_, inv_com_;        /* GVB - 21 */
 68           tbl inv_com_, inv_com_, inv_com_, inv_com_, inv_com_, nop_,
 69           nop_, inv_com_, nop_, inv_com_, inv_com_, inv_com_, inv_com_;         /* RET - 22 */
 70           tbl inv_com_, inv_com_, inv_com_, inv_com_, inv_com_, int6_,
 71           nop_, inv_com_, nop_, inv_com_, inv_com_, inv_com_, inv_com_;         /* INT - 23 */
 72           tbl error_, error_, error_, error_, error_, nop_,
 73           error_, error_, buf9_, buf10_, error_, error_, nop_;        /*  buf - 24 */
 74 
 75 ctl_tbl_: tbl NOP_, RTS_, STR_, CLS_, ALL_,
 76           GVB_, RET_, INR_, INS_, ECO_, ERP_, ERR_, RST_, RRP_, unk_, buf_;
 77 
 78 inv_state_: error_code netstate;
 79 nop_:     unlock_return;
 80 
 81 /* ABORT user call */
 82 
 83 abort6_:  unlock_return;                                    /* no abort possible because of allocation synch */
 84 
 85 abort10_: imp_abort;
 86           unlock_return;
 87 
 88 abort11_: unassign_link 0;
 89           signal 1;
 90           state_ul_return Active;
 91 
 92 /* CONNECT user call */
 93 
 94 connect1_: insert_socket_id 0 connect1b_ connect1d_;
 95           local_read_socket connect1a_;
 96           ctl_mess STR LSOC FSOC BYTE;
 97           state_ul_return Rfc_sent;
 98 
 99 connect1a_: assign_link 0 connect1c_;
100           ctl_mess RTS LSOC FSOC LINKN;
101           state_ul_return Rfc_sent;
102 
103 connect1b_: error_code netfhost;
104           unlock_return;
105 
106 connect1c_: error_code notalloc;
107           unlock_return;
108 
109 connect1d_: error_code netbgend;
110           unlock_return;
111 
112 /* LISTEN user call */
113 listen1_: state_ul_return Listen;
114 
115 /* REJECT user call */
116 reject3_: get_nxt_rfc error_;
117           ctl_mess CLS LSOC FSOC 0;
118           state_ul_return Reject_wait;
119 
120 reject4_: get_nxt_rfc error_;
121           set_fsocr;
122           delete_rfc;
123           state_ns Listen;
124           unlock_return;
125 
126 /* ACCEPT user call */
127 accept3_: get_nxt_rfc error_;
128           insert_socket_id 1 error_ error_;
129           local_read_socket accept3a_;
130           assign_link 1 accept3c_;
131           ctl_mess STR LSOC FSOC BYTE;
132           go_to accept3b_;
133 
134 accept3a_: assign_link 0 accept3c_;
135           allocate_read;
136           ctl_mess RTS LSOC FSOC LINKN;
137           ctl_mess ALL LINKN MSPACE BSPACE;
138 accept3b_: delete_rfc;
139           state_ul_return Open;
140 
141 accept3c_: ctl_mess CLS LSOC FSOC 0;
142           delete_rfc;
143           error_code notalloc;
144           state_ul_return Listen;
145 
146 /* CLOSE user call */
147 close2_:  state_ul_return Active;
148 
149 close3_:  get_nxt_rfc error_;
150           ctl_mess CLS LSOC FSOC 0;
151           insert_socket_id 1 error_ error_;
152           delete_rfc;
153           state_ul_return Cls_wait;
154 
155 
156 close4_:  get_nxt_rfc error_;
157           delete_rfc;
158           state_ul_return Active;
159 
160 close5_:  ctl_mess CLS LSOC FSOC 0;
161           state_ul_return Cls_wait;
162 
163 
164 close6_:  local_read_socket close6a_;
165           check_for_rfnm close6a_;
166           set_empty_wakeup;
167           state_ul_return Data_wait;
168 
169 close6a_: ctl_mess CLS LSOC FSOC 0;
170           imp_abort;
171           signal 1;
172           state_ul_return Cls_wait;
173 
174 close12_: unassign_link 1;
175           state_ul_return Active;
176 
177 close13_: unassign_link 0;
178           state_ul_return Active;
179 
180 /* FORCE-DEAC user call */
181 
182 fdeac1_:  get_nxt_rfc fdeac13_;
183           delete_rfc;
184           go_to fdeac1_;
185 fdeac13_: unassign_link 0;
186           signal 1;
187           deactivate;
188           return;
189 
190 
191 fdeac12_: unassign_link 1;
192           deactivate;
193           return;
194 
195 /* SENDQUIT user call */
196 
197 sendquit6_: local_read_socket sendquit6a_;
198           ctl_mess INS LINKN 0 0;
199           unlock_return;
200 
201 sendquit6a_: ctl_mess INR LINKN 0 0;
202           unlock_return;
203 
204 /* QUITENABLE user call */
205 quitenable_: quit_enable 1;
206           signal 0;
207           unlock_return;
208 
209 /* QUITINHIBIT user call */
210 quitinhib_: quit_enable 0;
211           signal 1;
212           unlock_return;
213 
214 /* SETBYTESIZE user call */
215 
216 setbyte1_: set_byte_size;
217           unlock_return;
218 
219 /* FORIMP privileged call */
220 
221 forimp_:  set_forimp_data;
222           state_ul_return Forimp;
223 
224 /* READ user call */
225 
226 read6_: local_read_socket read6a_;
227           error_code netbgend;
228           unlock_return;
229 read6a_:  read read6b_;
230           unlock_return;
231 read6b_:  allocate_read;
232           ctl_mess ALL LINKN MSPACE BSPACE;
233           unlock_return;
234 
235 read11_:  local_read_socket read10a_;
236           error_code netbgend;
237           unlock_return;
238 read10a_: read read10b_;
239 read10b_: check_for_rfnm abort11_;
240           unlock_return;
241 
242 /* STATE user call */
243 state3_:  get_nxt_rfc error_;
244           set_fsocr;
245           unlock_return;
246 
247 state4_:  get_nxt_rfc error_;
248           set_fsocr;
249           delete_rfc;
250           state_ns Listen;
251           unlock_return;
252 
253 /* WRITE user call */
254 
255 write6_:  local_read_socket write6a_;
256           write;
257           unlock_return;
258 write6a_: error_code netbgend;
259           unlock_return;
260 
261 write10_: error_code netclose;
262           unlock_return;
263 
264 /* DEACTIVATE user call */
265 
266 deac1_:   deactivate;
267           return;
268 
269 deac3_:   get_nxt_rfc error_;
270           ctl_mess CLS LSOC FSOC 0;
271 deac3a_:  delete_rfc;
272           deactivate;
273           return;
274 
275 deac4_:   get_nxt_rfc error_;
276           go_to deac3a_;
277 
278 deac5_:   set_deac_sw;
279           go_to close5_;
280 
281 deac6_:   set_deac_sw;
282           go_to close6_;
283 
284 deac7_:   set_deac_sw;
285           unlock_return;
286 
287 deac11_:  unassign_link 0;
288           deactivate;
289           return;
290 
291 
292 /* CONTROL MESSAGE FAN_OUT LIST BLOCKS */
293 
294 NOP_:     bit_length 8;
295           return;
296 
297 RTS_:     bit_length 80;
298           get_sockets 1 polarity_error;
299           find_entry_sock_transfer Rts;
300           ctl_mess CLS LSOC FSOC1 0;
301           return;
302 
303 STR_:     bit_length 80;
304           get_sockets 2 polarity_error;
305           find_entry_sock_transfer Str;
306           ctl_mess CLS LSOC FSOC1 0;
307           return;
308 
309 CLS_:     bit_length 72;
310           get_sockets 3 polarity_error;
311           find_entry_sock_transfer Cls;
312  /* A glitch - we ignore this because it could be a legal CLS for a refused RFC */
313           return;
314 
315 polarity_error: ctl_mess ERR CODEF 3 ERRTX;
316 return;
317 
318 ALL_:     bit_length 64;
319           find_entry_link_transfer 1 All;
320 /* a glitch - we ignore this because it may be legally sent on an aborted connection */
321           return;
322 
323 GVB_:     bit_length 32;
324           find_entry_link_transfer 1 Gvb;
325           ctl_mess ERR CODEF 4 ERRTX;
326           return;
327 
328 RET_:     bit_length 64;
329           find_entry_link_transfer 0 Ret;
330           ctl_mess ERR CODEF 4 ERRTX;
331           return;
332 
333 INR_:     bit_length 16;
334           find_entry_link_transfer 1 Int;
335           ctl_mess ERR CODEF 4 ERRTX;
336           return;
337 
338 INS_:     bit_length 16;
339           find_entry_link_transfer 0 Int;
340           ctl_mess ERR CODEF 4 ERRTX;
341           return;
342 
343 ECO_:     bit_length 16;
344           ctl_mess ERP ECODT 0 0;
345           return;
346 
347 ERP_:     bit_length 16;
348           return;
349 
350 ERR_:     bit_length 96;
351           error_handler;
352           return;
353 
354 RST_:     bit_length 8;
355           reset_host;
356           ctl_mess RRP 0 0 0;
357           return;
358 
359 RRP_:     bit_length 8;
360           return;
361 
362 unk_:     ctl_mess ERR CODEF 1 ERRTX;
363           return;
364 
365 buf_:     find_entry_link_transfer 1 Buf;                   /* this is a write link */
366           ncp_error;
367           return;
368 
369 /* CONTROL MESSAGE PROCESSOR LIST BLOCKS */
370 
371 auto_reject_: ctl_mess CLS LSOC FSOC1 0;
372           unlock_return;
373 
374 inv_com_: ctl_mess ERR CODEF 5 ERRTX;
375           unlock_return;
376 
377 /* RTS or STR control message */
378 
379 rts2_:    add_to_queue rfc3_;
380 rfc2a_:   signal 0;
381           state_ul_return Rfc_rcvd;
382 
383 str2_: check_bytesize auto_reject_;
384           add_to_queue auto_reject_;
385           go_to rfc2a_;
386 
387 rfc3_:    ctl_mess CLS LSOC FSOC1 0;
388           unlock_return;
389 
390 rts5_:    fsoc_unequal auto_reject_;
391           assign_link 1 rfc5a_;
392           signal 0;
393           state_ul_return Open;
394 
395 str5_:    fsoc_unequal auto_reject_;
396           check_bytesize rfc5a_;
397           allocate_read;
398           ctl_mess ALL LINKN MSPACE BSPACE;
399           signal 0;
400           state_ul_return Open;
401 
402 rfc5a_:   ctl_mess CLS LSOC FSOC 0;
403           signal 0;
404           state_ul_return Cls_wait;
405 
406 rfc7_:    fsoc_unequal auto_reject_;
407                                                             /* if sockets are equal, this is from an aborted RFC */
408           unlock_return;
409 
410 /* CLS control message */
411 
412 cls3_:    get_nxt_rfc error_;
413           fsoc_unequal inv_CLS_;
414           ctl_mess CLS LSOC FSOC 0;
415           signal 0;
416           state_ul_return Abort;
417 
418 cls5_:    fsoc_unequal inv_CLS_;
419           signal 0;
420           ctl_mess CLS LSOC FSOC 0;
421           local_read_socket cls5a_;
422           state_ul_return Active;
423 
424 cls5a_: unassign_link 0;
425           state_ul_return Active;
426 
427 cls6_:    fsoc_unequal inv_CLS_;
428           local_read_socket cls6a_;
429           imp_abort;
430           check_for_rfnm buf10_;
431           set_empty_wakeup;
432           state_ul_return Rfnm_wait;
433 
434 cls6a_:   signal 1;
435           ctl_mess CLS LSOC FSOC 0;
436           check_for_rfnm cls7a_;
437           state_ul_return Cls_read;
438 
439 cls7_:    fsoc_unequal inv_CLS_;
440 cls7a_:   unassign_link 0;
441           signal 1;
442           deac_sw deac1_;
443           state_ul_return Active;
444 
445 cls8_:    get_nxt_rfc error_;
446           fsoc_unequal inv_CLS_;
447           delete_rfc;
448           signal 0;
449           state_ul_return Listen;
450 
451 cls9_:    fsoc_unequal inv_CLS_;
452           imp_abort;
453           state_ul_return Rfnm_wait;
454 
455 /* ALL control message */
456 
457 all6_:    allocate_write;
458           signal 0;
459           unlock_return;
460 
461 /* GVB control message */
462 
463 gvb6_:    deallocate_write;
464           ctl_mess RET LINKN MSPACE BSPACE;
465           unlock_return;
466 
467 int6_:    interrupt;
468           unlock_return;
469 
470 /* buffer empty condition */
471 
472 buf9_:    check_for_rfnm buf9a_;
473           unlock_return;
474 
475 buf9a_:   ctl_mess CLS LSOC FSOC 0;
476           state_ul_return Cls_wait;
477 
478 buf10_:   ctl_mess CLS LSOC FSOC 0;
479           go_to cls7a_;
480 
481 error_:   ncp_error;
482 inv_CLS_: unlock_return;
483 
484      end;