src/sync_fsm.h
author Volker Birk <vb@pep-project.org>
Sun, 29 May 2016 12:21:50 +0200
changeset 690 3ae86b68fdfe
parent 676 aa02f6473007
child 711 d88dea0f5448
permissions -rw-r--r--
adding sending
     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     Init, 
    39     KeyGen, 
    40     CannotDecrypt, 
    41     Beacon, 
    42     HandshakeRequest, 
    43     HandshakeRejected, 
    44     HandshakeAccepted, 
    45     ReceiveGroupKeys, 
    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 sendOwnKeys(PEP_SESSION session, DeviceState_state state, const Identity partner);
    58 PEP_STATUS transmitGroupKeys(PEP_SESSION session, DeviceState_state state, const Identity partner);
    59 
    60 // state machine
    61 
    62 DeviceState_state fsm_DeviceState(
    63         PEP_SESSION session,
    64         DeviceState_state state,
    65         DeviceState_event event,
    66         const Identity partner,
    67         DeviceState_state state_partner
    68     );
    69 
    70 // driver
    71 
    72 PEP_STATUS fsm_DeviceState_inject(
    73         PEP_SESSION session,
    74         DeviceState_event event,
    75         Identity partner,
    76         DeviceState_state state_partner
    77     );
    78 
    79 #ifdef __cplusplus
    80 }
    81 #endif
    82