init state
authorVolker Birk <vb@pep-project.org>
Sun, 15 May 2016 15:41:44 +0200
changeset 6244892dffa9e70
parent 623 533a7fcc423b
child 625 99e0c66655ad
init state
src/fsm_driver.c
src/sync_fsm.c
src/sync_fsm.h
sync/gen_actions_skeleton.ysl2
sync/sync.fsm
     1.1 --- a/src/fsm_driver.c	Sun May 15 15:18:53 2016 +0200
     1.2 +++ b/src/fsm_driver.c	Sun May 15 15:41:44 2016 +0200
     1.3 @@ -8,5 +8,14 @@
     1.4  {
     1.5      PEP_STATUS status = PEP_STATUS_OK;
     1.6  
     1.7 +    assert(session);
     1.8 +    if (!session)
     1.9 +        return PEP_ILLEGAL_VALUE;
    1.10 +
    1.11 +    static DeviceState_state fsm_state = InitState;
    1.12 +
    1.13 +    // working code
    1.14 +
    1.15 +
    1.16      return status;
    1.17  }
     2.1 --- a/src/sync_fsm.c	Sun May 15 15:18:53 2016 +0200
     2.2 +++ b/src/sync_fsm.c	Sun May 15 15:41:44 2016 +0200
     2.3 @@ -9,6 +9,15 @@
     2.4      )
     2.5  {
     2.6      switch (state) {
     2.7 +    case InitState:
     2.8 +        switch (event) {
     2.9 +            case Init:
    2.10 +                return Sole;
    2.11 +        default:
    2.12 +            return invalid_event;
    2.13 +        }
    2.14 +        break;
    2.15 +    
    2.16      case Sole:
    2.17          switch (event) {
    2.18              case KeyGen:
     3.1 --- a/src/sync_fsm.h	Sun May 15 15:18:53 2016 +0200
     3.2 +++ b/src/sync_fsm.h	Sun May 15 15:41:44 2016 +0200
     3.3 @@ -19,6 +19,7 @@
     3.4  // states
     3.5  
     3.6  typedef enum _DeviceState_state {
     3.7 +    InitState, 
     3.8      Sole, 
     3.9      HandshakingSole, 
    3.10      WaitForGroupKeys, 
    3.11 @@ -28,11 +29,11 @@
    3.12  // events
    3.13  
    3.14  typedef enum _DeviceState_event {
    3.15 +    Init, 
    3.16      KeyGen, 
    3.17      CannotDecrypt, 
    3.18      Beacon, 
    3.19      HandshakeRequest, 
    3.20 -    Init, 
    3.21      HandshakeRejected, 
    3.22      HandshakeAccepted, 
    3.23      ReceiveGroupKeys, 
     4.1 --- a/sync/gen_actions_skeleton.ysl2	Sun May 15 15:18:53 2016 +0200
     4.2 +++ b/sync/gen_actions_skeleton.ysl2	Sun May 15 15:41:44 2016 +0200
     4.3 @@ -22,6 +22,15 @@
     4.4      {
     4.5          PEP_STATUS status = PEP_STATUS_OK;
     4.6  
     4.7 +        assert(session);
     4.8 +        if (!session)
     4.9 +            return PEP_ILLEGAL_VALUE;
    4.10 +
    4.11 +        static DeviceState_state fsm_state = InitState;
    4.12 +
    4.13 +        // working code
    4.14 +
    4.15 +
    4.16          return status;
    4.17      }
    4.18      ||
     5.1 --- a/sync/sync.fsm	Sun May 15 15:18:53 2016 +0200
     5.2 +++ b/sync/sync.fsm	Sun May 15 15:41:44 2016 +0200
     5.3 @@ -10,10 +10,12 @@
     5.4      // all messages have a timestamp, time out and are removed after timeout
     5.5  
     5.6      fsm DeviceState {
     5.7 -        on Init {
     5.8 -            if (storedGroupKeys)
     5.9 -                go Grouped;
    5.10 -            go Sole;
    5.11 +        state InitState {
    5.12 +            on Init {
    5.13 +                if (storedGroupKeys)
    5.14 +                    go Grouped;
    5.15 +                go Sole;
    5.16 +            }
    5.17          }
    5.18  
    5.19          state Sole {