src/sync_fsm.h
branchkeysync
changeset 951 dec407deb10e
parent 939 ed7dfdae3031
child 952 986fd7b2eb8f
     1.1 --- a/src/sync_fsm.h	Sun Jul 31 09:04:42 2016 +0200
     1.2 +++ b/src/sync_fsm.h	Sun Jul 31 19:38:23 2016 +0200
     1.3 @@ -3,6 +3,7 @@
     1.4  // state machine for DeviceState
     1.5  
     1.6  #include "pEpEngine.h"
     1.7 +#include "../asn.1/DeviceGroup-Protocol.h"
     1.8  
     1.9  #ifdef __cplusplus
    1.10  extern "C" {
    1.11 @@ -21,10 +22,15 @@
    1.12      invalid_event = -3
    1.13  } fsm_error;
    1.14  
    1.15 +// conditions
    1.16 +
    1.17 +bool storedGroupKeys(PEP_SESSION session);
    1.18 +bool keyElectionWon(PEP_SESSION session, Identity partner);
    1.19 +
    1.20  // states
    1.21  
    1.22  typedef enum _DeviceState_state {
    1.23 -    DeviceState_state_NONE = -1,
    1.24 +    DeviceState_state_NONE = 0,
    1.25      InitState, 
    1.26      Sole, 
    1.27      HandshakingSole, 
    1.28 @@ -35,11 +41,11 @@
    1.29  // events
    1.30  
    1.31  typedef enum _DeviceState_event {
    1.32 -    DeviceState_event_NONE = -1,
    1.33 -    Beacon = 1,
    1.34 -    HandshakeRequest = 2,
    1.35 -    GroupKeys = 3,
    1.36 -    Init, 
    1.37 +    DeviceState_event_NONE = 0,
    1.38 +    Init = 1,
    1.39 +    Beacon = 2,
    1.40 +    HandshakeRequest = 3,
    1.41 +    GroupKeys = 4,
    1.42      KeyGen, 
    1.43      CannotDecrypt, 
    1.44      HandshakeRejected, 
    1.45 @@ -58,6 +64,10 @@
    1.46  PEP_STATUS storeGroupKeys(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    1.47  PEP_STATUS sendGroupKeys(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    1.48  
    1.49 +// message receiver
    1.50 +
    1.51 +PEP_STATUS receive_DeviceState_msg(PEP_SESSION session, DeviceGroup_Protocol_t *msg);
    1.52 +
    1.53  // state machine
    1.54  
    1.55  DeviceState_state fsm_DeviceState(
    1.56 @@ -65,7 +75,7 @@
    1.57          DeviceState_state state,
    1.58          DeviceState_event event,
    1.59          Identity partner,
    1.60 -        DeviceState_state state_partner
    1.61 +        void *extra
    1.62      );
    1.63  
    1.64  // driver
    1.65 @@ -74,7 +84,7 @@
    1.66          PEP_SESSION session,
    1.67          DeviceState_event event,
    1.68          Identity partner,
    1.69 -        DeviceState_state state_partner
    1.70 +        void *extra
    1.71      );
    1.72  
    1.73  #ifdef __cplusplus