parms
authorVolker Birk <vb@pep-project.org>
Tue, 10 May 2016 10:32:47 +0200
changeset 582fa50f202b57c
parent 581 fdfcb223d56b
child 583 2392a33ae121
parms
sync/Makefile
sync/gen_statemachine.ysl2
sync/sync.fsm
     1.1 --- a/sync/Makefile	Tue May 10 10:02:30 2016 +0200
     1.2 +++ b/sync/Makefile	Tue May 10 10:32:47 2016 +0200
     1.3 @@ -1,4 +1,4 @@
     1.4 -sync_fsm.c: sync.fsm gen_statemachine.ysl2
     1.5 +../src/sync_fsm.c: sync.fsm gen_statemachine.ysl2
     1.6  	yml2proc -y gen_statemachine.ysl2 $< -o $@
     1.7  
     1.8  sync.xml: sync.fsm fsm.yml2
     1.9 @@ -7,4 +7,4 @@
    1.10  .PHONY: clean
    1.11  
    1.12  clean:
    1.13 -	rm -f *.xml *.c
    1.14 +	rm -f *.xml ../src/sync_fsm.c
     2.1 --- a/sync/gen_statemachine.ysl2	Tue May 10 10:02:30 2016 +0200
     2.2 +++ b/sync/gen_statemachine.ysl2	Tue May 10 10:32:47 2016 +0200
     2.3 @@ -26,13 +26,21 @@
     2.4      `` for "set:distinct(state/event/@name)" |> «.»`if "position()!=last()" > , `
     2.5      } «@name»_event;
     2.6  
     2.7 -    «@name»_state fsm_«@name»(«@name»_state state, «@name»_event event)
     2.8 +    `` for "set:distinct(state/event//action/@name)" | void «.»(pEp_identity *partner);
     2.9 +
    2.10 +    «@name»_state fsm_«@name»(
    2.11 +            «@name»_state state,
    2.12 +            «@name»_event event,
    2.13 +            pEp_identity *partner
    2.14 +        )
    2.15      {
    2.16          switch (state) {
    2.17              `` apply "state"
    2.18              default:
    2.19                  return invalid_state;
    2.20          }
    2.21 +
    2.22 +        return state;
    2.23      }
    2.24  
    2.25      ||
    2.26 @@ -53,10 +61,19 @@
    2.27      ||
    2.28      case «@name»:
    2.29      `` apply "action|transition";
    2.30 -    `` if "1" |> break;
    2.31 +    `` if "name(*[position()=last()]) != 'transition'" |> break;
    2.32      ||
    2.33  
    2.34 -    template "action" | «@name»();
    2.35 +    template "action" {
    2.36 +        indent(0);
    2.37 +        > «@name»(
    2.38 +        choose {
    2.39 +            when "parm" > «name(parm/*)»
    2.40 +            otherwise > NULL
    2.41 +        }
    2.42 +        > );\n
    2.43 +    }
    2.44 +
    2.45      template "transition" | return «@target»;
    2.46  }
    2.47  
     3.1 --- a/sync/sync.fsm	Tue May 10 10:02:30 2016 +0200
     3.2 +++ b/sync/sync.fsm	Tue May 10 10:32:47 2016 +0200
     3.3 @@ -10,7 +10,7 @@
     3.4      // all messages have a timestamp, time out and are removed after timeout
     3.5  
     3.6      fsm DeviceState {
     3.7 -        on init {
     3.8 +        on Init {
     3.9              if (storedGroupKeys)
    3.10                  go Grouped;
    3.11              go Sole;
    3.12 @@ -23,15 +23,15 @@
    3.13                  do sendBeacon;  // cry, baby
    3.14              on Beacon(identity partner) // this event will not happen for already
    3.15                                          // rejected partners
    3.16 -                do sendHandshakeRequest;
    3.17 +                do sendHandshakeRequest(partner);
    3.18              on HandshakeRequest(identity partner) {
    3.19 -                do sendHandshakeRequest;
    3.20 +                do sendHandshakeRequest(partner);
    3.21                  go HandshakingSole(partner);
    3.22              }
    3.23          }
    3.24  
    3.25          state HandshakingSole(identity partner) {
    3.26 -            on init
    3.27 +            on Init
    3.28                  do showHandshake(partner);
    3.29              on HandshakeRejected(identity partner) {
    3.30                  do reject(partner);             // sends Reject to partner and
    3.31 @@ -65,7 +65,7 @@
    3.32              on KeyGen
    3.33                  do sendOwnKeys; // always send all keys
    3.34              on HandshakeRequest(identity partner) {
    3.35 -                do sendHandshakeRequest;
    3.36 +                do sendHandshakeRequest(partner);
    3.37                  do showHandshake(partner);
    3.38              }
    3.39              on HandshakeRejected(identity partner)