src/sync_fsm.h
author Volker Birk <vb@pep-project.org>
Thu, 02 Jun 2016 13:46:38 +0200
changeset 711 d88dea0f5448
parent 690 3ae86b68fdfe
child 743 e4b613ebac2f
permissions -rw-r--r--
slightly redesigning things
     1 #pragma once
     2 
     3 // state machine for DeviceState
     4 
     5 #include "pEpEngine.h"
     6 
     7 #ifdef __cplusplus
     8 extern "C" {
     9 #endif
    10 
    11 // types
    12 
    13 typedef pEp_identity * Identity;
    14 typedef union _param { const Identity partner; const stringlist_t *keylist; } param_t;
    15 
    16 // error values
    17 
    18 typedef enum _fsm_error {
    19     invalid_state = -1,
    20     invalid_event = -2
    21 } fsm_error;
    22 
    23 // states
    24 
    25 typedef enum _DeviceState_state {
    26     DeviceState_state_NONE = 0,
    27     InitState, 
    28     Sole, 
    29     HandshakingSole, 
    30     WaitForGroupKeys, 
    31     Grouped
    32 } DeviceState_state;
    33 
    34 // events
    35 
    36 typedef enum _DeviceState_event {
    37     DeviceState_event_NONE = 0,
    38     Beacon = 1,
    39     HandshakeRequest = 2,
    40     GroupKeys = 3,
    41     Init, 
    42     KeyGen, 
    43     CannotDecrypt, 
    44     HandshakeRejected, 
    45     HandshakeAccepted, 
    46     Cancel, 
    47     Reject
    48 } DeviceState_event;
    49 
    50 // actions
    51 
    52 PEP_STATUS sendBeacon(PEP_SESSION session, DeviceState_state state, const Identity partner);
    53 PEP_STATUS sendHandshakeRequest(PEP_SESSION session, DeviceState_state state, const Identity partner);
    54 PEP_STATUS showHandshake(PEP_SESSION session, DeviceState_state state, const Identity partner);
    55 PEP_STATUS reject(PEP_SESSION session, DeviceState_state state, const Identity partner);
    56 PEP_STATUS storeGroupKeys(PEP_SESSION session, DeviceState_state state, const Identity partner);
    57 PEP_STATUS sendGroupKeys(PEP_SESSION session, DeviceState_state state, const Identity partner);
    58 
    59 // state machine
    60 
    61 DeviceState_state fsm_DeviceState(
    62         PEP_SESSION session,
    63         DeviceState_state state,
    64         DeviceState_event event,
    65         const Identity partner,
    66         DeviceState_state state_partner
    67     );
    68 
    69 // driver
    70 
    71 PEP_STATUS fsm_DeviceState_inject(
    72         PEP_SESSION session,
    73         DeviceState_event event,
    74         Identity partner,
    75         DeviceState_state state_partner
    76     );
    77 
    78 #ifdef __cplusplus
    79 }
    80 #endif
    81