! file 'pollpads' !********************** !* pollpads/lmeoty * !* * !********************* %conststring (13) vsn = "PollPad...1a " ! Prep options:- m - more monitoring #datestring !! stack = 300, streams = 1 %externalstring (255) %fnspec cli param %control 1 %recordformat xf(%byteinteger unit,fsys,%byteintegerarray fname(0:5)) %include "b_deimosspecs" %begin %owninteger mon = 0 %ownstring (1) snil = "" %recordformat lev3f(%bytearray reserved(0:6), (%bytearray data(0:127) %or %c %string (127) s)) ! itp_data(0) is actually inside the reserved space, as it is ! only used for the length, this should not matter %recordformat mef(%record(mef)%name link,%byteinteger len,type, %c (%record(lev3f) lev3 %or %bytearray params(0:241))) %recordformat pf(%byteinteger service,reply,(%byte fn,s1, %c %record(mef)%name mes,%byteinteger gate port, task port %or %c %byte a1, a2, b1, b2, c1, c2)) %record (pf) p %recordformat qf(%record (mef) %name e) %recordformat tcpf(%integer state, con state ind, %c %byteinteger port, ostate, tcpn, term, %c size, max, %integer packets) %constinteger max conns = 48 %ownrecord (tcpf) tcp ! %constinteger not allocated = 0 %constinteger conn asked = 1 %constinteger connected = 2 %constinteger tcp disconnecting = 3 !****** tcp_ostate states (permission to send) ***** %constinteger idle = 0 %constinteger busy = 1 !*********************************************************** %recordformat consf(%integer cnsl, state) %ownrecord (consf) con %constinteger tt ser=1, gate ser=24, buffer manager=17 %constinteger rd=0, echo off=10 %constinteger request buffer=0, release buffer=1 %constintegername no of small == k'100114' %include "b_ygatecalls" %integer i, node, term, k, flag, tick, conns %owninteger initf %owninteger users, sta, cpu, pkts, sbr, byt, rjei, tim, rjeo %owninteger conn ok, g port, power, kill it, maxc %constbyteintegername change out zero == k'160310' %constinteger t3 ser = 21 %ownstring (23) address = "" %ownstring (15) adr %ownstring (9) name = "OPER**" %ownstring (11) pass = "dolphins**" %ownstring (23) show = "status line 16**" %ownstring (127) t, v, cli %routine readstring(%string (*) %name s) %integer i s = "" %cycle readsymbol(i); %exit %if i = nl s = s.tostring(i) %repeat %end %routine get buffer(%integer reason, r2) p_service=buffer manager; p_reply=id p_a1=request buffer; p_c1=1; p_c2=reason; ! small buff p_a2 = r2 pon(p) %end %routine free buffer(%record(mef)%name mes) p_service=buffer manager; p_reply=id p_a1=release buffer; p_mes==mes pon(p) %end %routine add crlf(%string(*)%name s) charno(s, length(s)) = 10 charno(s, length(s)-1) = 13 %end %routine mon mes(%record (mef) %name mes) %integer i, j, k, n k = mes_len write(k, 1); space; space j = 0 %cycle i = 0, 1, k write(mes_lev3_data(i), 1) j = j+1; %if j = 25 %then j = 0 %and newline %repeat newline; select output(0) %end %routine mon p(%record (pf)%name p) %integer i printstring(" fn ="); write(p_fn, 1) printstring(" gate port"); write(p_gate port, 1) printstring(" task port"); write(p_task port, 1) printstring(" a2"); write(p_a2, 1) newline %end %routine to gate(%integer fn, %record (mef) %name mes, %c %integer flag) %if fn = put output %start; ! queue these as necessary %if tcp_state # connected %start; ! throw away free buffer(mes); %return %finish #if m %if mon < 0 %start select output(2) printstring("io "); mon mes(mes) %finish #fi %finish p_service = gate ser; p_reply = id p_fn = fn; p_mes == mes; p_s1 = flag p_task port = tcp_tcpn; p_gate port = tcp_port #if x!t %if mon < 0 %start select output(2); spaces(5) printstring("xxx: to gate:"); {t} mon p(p) select output(0) %finish #fi pon(p) %end %routine pack(%record(mef) %name mes, %string (*) %name s) string(addr(mes_params(mes_len))) = s mes_len = mes_len+length(s)+1 %end %routine do connect(%integer type, %record (mef) %name mes) !============================================================ %string (23) facn p_service = gate ser; p_reply = own id p_fn = connect p_gate port = 0; p_task port = tcp_tcpn p_s1 = 1; ! 1 for xxx call p_mes == mes mes_len = 0 pack(mes, address) pack(mes,snil); ! calling address facn = "P=128/128" pack(mes, facn) pack(mes, snil) %if mon # 0 %start select output(2); spaces(5) printstring("xxx: to gate:"); mon p(p) select output(0) %finish pon(p) conns = conns+1 tcp_state = conn asked %end %routine block(%record (mef) %name mes, %integer cnsl) %integer i, j, k %record (lev3f) %name lev3 %switch sw(0:6) lev3 == mes_lev3 lev3_s = "" -> sw(con_state) sw(0): ! 1st wakeup message sw(3): ! Newline after pass sent con_state = con_state+1 -> wait sw(1): ! send name lev3_s = name -> comm sw(2): ! send pass lev3_s = pass -> comm sw(4): ! Send 'show counts' lev3_s = show -> comm sw(5): ! wait wait: free buffer(mes) %return comm: mes_len = length(lev3_s) %if mon # 0 %start select output(2) %if length(lev3_s) # 0 %then spaces(3) %and printstring(lev3_s) newline select output(0) %finish to gate(put output, mes, 0) con_state = con_state+1 %end %routine analyse itp input(%record (mef) %name mes) %record (lev3f) %name lev3 %integer i, j, k, q lev3 == mes_lev3 k = tcp_tcpn length(lev3_s) = mes_len v = lev3_s %if mon # 0 %start select output(2) printstring("In:state:"); write(k, 1); write(con_state, 1) write(lev3_data(0), 1); space %if length(v) > 0 %then printstring(v) newline select output(0) %finish select output(1) %if con_state > 4 %or con_state = 0 %start printstring(v) %unless v = "REM>" %finish select output(0) %if v -> t.("REM>").v %and con_state = 5 %start; ! overwrites v to gate(Disconnect, null, 0) tcp_state = tcp disconnecting %finish %else %start get buffer(k, 0) %finish free buffer(mes) %end i = map virt(buffer manager, 5, 4) i = map virt(buffer manager, 6, 5) printstring(vsn) printstring(datestring) printstring(" Input from Stream 1, Output to Stream 1 ") cli = cli param; ! get params %if cli -> t.(":").v %start; ! new instruction show = v."**" %finish select input(1) maxc = 1 sta = maxc i = 0 tcp_tcpn = i+1 alarm(10) add crlf(name) add crlf(pass) add crlf(show) %cycle prompt("Address (or END)?"); readstring(address) adr = address; length(adr) = 12 %if length(adr) = 14 %exit %if address = "END" get buffer(0, 255); ! connect up tcp_state = 0 %cycle p_service = 0; poff(p) %if p_reply = 0 %start; ! clock %if int = 'A' %start kill it = -1 printstring("killing it ") to gate(Disconnect, null, 0) %if tcp_state = connected tcp_state = tcp disconnecting int = 0 %finish alarm(50); ! 1 secs %if 'M' <= int <= 'P' %start mon = int-'O'; int = 0 %finish %if int = 'Z' %start %if kill it >= 0 %then printstring("Do int:A first ") %else %stop int = 0 %finish %continue %finish %if mon < 0 %and p_reply = gate ser %start select output(2) printstring("From Gate:") mon p(p) newline select output(0) %finish %if p_reply = buffer manager %start %if kill it < 0 %then free buffer(p_mes) %and %continue %if p_a2 = 255 %then do connect(p_c2, p_mes) %else %c block(p_mes, p_c2) %continue %finish %if p_reply = gate ser %start node = p_task port-1 %if p_fn = accept call %start; ! reply %if %not p_mes == null %then free buffer(p_mes) %if kill it < 0 %then to gate(Disconnect, null, 0) %c %and tcp_state = tcp disconnecting flag = p_s1 %if mon # 0 %start printstring("call accepted"); write(node, 1); newline %finish tcp_state = connected tcp_port = p_gate port %continue %finish %if p_fn = disconnect %start; ! my end i hope conns = conns-1 %unless p_mes == null %then free buffer(p_mes) %if tcp_state = tcp disconnecting %start; ! expected in xxx repeat: %if kill it < 0 %then -> go away tcp_state = 0 con_state = 0 %exit %else select output(1) printstring("Pad:"); printstring(adr); printstring(" Rejects call ") select output(0) %exit %if tcp_state = 0 tcp_state = 0 %if tcp_state = connected %or p_s1 = 141 %c %then to gate(disconnect, null, 0) %and -> repeat %finish %if conns = 0 %and kill it < 0 %start go away: p_service = 0; poff(p); ! wait for timer tick %stop %finish %exit %finish %if p_fn = enable output %start %continue %finish %if p_fn = input here %start analyse itp input(p_mes) to gate(enable input, null, 1) %continue %finish %if p_fn = control data %start free buffer(p_mes) to gate(enable input, null, 1) %continue %finish printstring("funny fn"); write(p_fn, 1) printstring(" from"); write(p_reply, 1); newline %continue %finish %repeat %repeat p_service = 0; poff(p); ! catch timer tick %endofprogram