Commit 1763348d authored by bernd's avatar bernd

Use special flag for stateless commands - these use the address as IV then (the address is ignored)

parent 261eddda
......@@ -185,7 +185,9 @@ Variable show-offset show-offset on
dup show-offset @ = IF ." <<< " THEN
buf-state 2! p@ 64>n net2o-see buf-state 2@ ;
: n2o:see ( addr u -- ) ." net2o-code " t-stack $off
: n2o:see ( addr u -- )
." net2o-code" dest-flags 1+ c@ stateless# and IF '0' emit THEN
space t-stack $off
o IF token-table @ >r THEN
[: BEGIN cmd-see dup 0= UNTIL ;] catch
o IF r> token-table ! THEN throw 2drop ;
......@@ -284,32 +286,47 @@ gen-table $@ inherit-table reply-table
\ net2o assembler
: .dest-addr ( flag -- )
1+ c@ stateless# and 0= IF dest-addr 64@ $64. THEN ;
: n2o:see-me ( -- )
buf-state 2@ 2>r
." see-me: " dest-addr 64@ $64.
." see-me: "
inbuf flags .dest-addr
\ tag-addr dup hex. 2@ swap hex. hex. F cr
inbuf packet-data n2o:see
2r> buf-state 2! ;
: cmdreset cmdbuf# off ;
: net2o-code cmd0source off cmdlock lock
: cmdreset ( -- )
cmdbuf# off ;
: cmd0! ( -- )
\g initialize a stateless command
cmd0buf cmd0source ! stateless# outflag ! ;
: cmd! ( -- )
\g initialize a statefull command
cmd0source off outflag off ;
: net2o-code ( -- )
\g start a statefull command
cmd! cmdlock lock
cmdreset 1 code+ also net2o-base ;
comp: :, also net2o-base ;
: net2o-code0 cmd0buf cmd0source ! cmdlock lock
: net2o-code0
\g start a stateless command
cmd0! cmdlock lock
cmdreset also net2o-base ;
comp: :, also net2o-base ;
: send-cmd ( addr u dest -- ) n64-swap { buf# }
+send-cmd dest-addr 64@ 64>r set-dest
cmd( ." send: " dest-addr 64@ $64. dup buf# n2o:see cr )
cmd( ." send: " dest-flags .dest-addr dup buf# n2o:see cr )
max-size^2 1+ 0 DO
buf# min-size I lshift u<= IF
I send-cX cmdreset UNLOOP
64r> dest-addr 64! EXIT THEN
LOOP 64r> dest-addr 64! true !!commands!! ;
: cmddest ( -- dest ) cmd0source @ IF 64#0 ELSE code-vdest
: cmddest ( -- dest ) cmd0source @ IF rng@ ELSE code-vdest
64dup 64-0= !!no-dest!! THEN ;
: cmd ( -- ) cmdbuf# @ 2 u< ?EXIT \ don't send if cmdbuf is empty
......@@ -357,7 +374,7 @@ previous
Variable throwcount
: do-cmd-loop ( addr u -- )
cmd( dest-addr 64@ $64. 2dup n2o:see )
cmd( dest-flags .dest-addr 2dup n2o:see )
sp@ >r throwcount off
[: BEGIN cmd-dispatch dup 0<= UNTIL ;] catch
dup IF 1 throwcount +!
......@@ -378,7 +395,7 @@ Variable throwcount
tag-addr? IF
2drop >flyburst 1 packetr2 +! EXIT THEN
ELSE
cmd0buf cmd0source !
cmd0!
THEN
[: cmdreset do-cmd-loop cmd-send? ;] cmdlock c-section ;
......
......@@ -348,7 +348,7 @@ cell 8 = [IF] 6 [ELSE] 5 [THEN] Constant cell>>
end-code ;
:noname ( addr u -- )
cmd0buf cmd0source ! cmdreset also net2o-base
cmd0! cmdreset also net2o-base
[ also net2o-base ]
['] end-cmd IS expect-reply?
$, nest end-code
......@@ -357,7 +357,7 @@ cell 8 = [IF] 6 [ELSE] 5 [THEN] Constant cell>>
: 0-resend? ( -- )
resend0 @ IF
\ ." Resend to 0" cr
cmd0buf cmd0source !
cmd0!
[: resend0 $@ >r cmdbuf r@ move
r0-address return-addr $10 move
cmdbuf r> 64#0 send-cmd 1 packets2 +! ;]
......
......@@ -111,7 +111,8 @@ User last-ivskey
ivs-assembly state# move
key( ." key: " ivs-assembly state# + 64@ $64. ivs-assembly state# 2* xtype cr )
ivs-assembly >c:key regen-ivs EXIT THEN 64drop
dest-addr 64@ 64-0= IF default-key ELSE true !!inv-dest!! THEN ;
dest-flags 1+ c@ stateless# and
IF default-key ELSE true !!inv-dest!! THEN ;
: crypt-buf-init ( map -- ) >r
o IF r@ .ivs>source? ELSE default-key THEN
......
......@@ -764,6 +764,7 @@ $40 Constant multicasting#
\ $30 Constant net2o-reserved# - should be 0
$08 Constant stateless# \ stateless message
$07 Constant acks#
$01 Constant ack-toggle#
$02 Constant b2b-toggle#
......@@ -1740,7 +1741,7 @@ require net2o-crypt.fs
User outflag outflag off
: set-flags ( -- )
outflag @ outbuf 1+ c! outflag off
0 outflag !@ outbuf 1+ c!
outbuf w@ dest-flags w! ;
#90 Constant EMSGSIZE
......@@ -1758,7 +1759,7 @@ User outflag outflag off
: send-code-packet ( -- ) +sendX
\ ." send " outbuf .header
o IF code-map @ ELSE 0 THEN outbuf-encrypt
outbuf addr 64@ 64-0= IF
outbuf flags 1+ c@ stateless# and IF
return-addr
cmd0( .time ." cmd0 to: " dup $10 xtype cr )
ELSE
......@@ -2265,7 +2266,8 @@ $20 Constant knock-val
: handle-packet ( -- ) \ handle local packet
>ret-addr >dest-addr +desta
dest-addr 64@ 64-0= IF handle-cmd0
dest-flags 1+ c@ stateless# and IF
handle-cmd0
ELSE
check-dest dup 0= IF
msg( ." unhandled packet to: " dest-addr 64@ $64. cr )
......
......@@ -94,4 +94,3 @@ rngbuf# rng-pos !
rng-pos @ 4 + rng-step?
rng-pos @ rng-buffer @ + l@
4 rng-pos +! ;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment