src/sync_fsm.h
author Volker Birk <vb@pep-project.org>
Sun, 15 May 2016 21:23:36 +0200
changeset 627 ef1fdfde8ced
parent 626 64a89bd12469
child 676 aa02f6473007
permissions -rw-r--r--
adding session handles
     1 #pragma once
     2 
     3 // state machine for DeviceState
     4 
     5 #include "pEpEngine.h"
     6 
     7 // types
     8 
     9 typedef pEp_identity * Identity;
    10 typedef union _param { const Identity partner; const stringlist_t *keylist; } param_t;
    11 
    12 // error values
    13 
    14 typedef enum _fsm_error {
    15     invalid_state = -1,
    16     invalid_event = -2
    17 } fsm_error;
    18 
    19 // states
    20 
    21 typedef enum _DeviceState_state {
    22     InitState, 
    23     Sole, 
    24     HandshakingSole, 
    25     WaitForGroupKeys, 
    26     Grouped
    27 } DeviceState_state;
    28 
    29 // events
    30 
    31 typedef enum _DeviceState_event {
    32     Init, 
    33     KeyGen, 
    34     CannotDecrypt, 
    35     Beacon, 
    36     HandshakeRequest, 
    37     HandshakeRejected, 
    38     HandshakeAccepted, 
    39     ReceiveGroupKeys, 
    40     Cancel, 
    41     Reject
    42 } DeviceState_event;
    43 
    44 // actions
    45 
    46 PEP_STATUS sendBeacon(PEP_SESSION session, const Identity partner);
    47 PEP_STATUS sendHandshakeRequest(PEP_SESSION session, const Identity partner);
    48 PEP_STATUS showHandshake(PEP_SESSION session, const Identity partner);
    49 PEP_STATUS reject(PEP_SESSION session, const Identity partner);
    50 PEP_STATUS storeGroupKeys(PEP_SESSION session, const Identity partner);
    51 PEP_STATUS sendOwnKeys(PEP_SESSION session, const Identity partner);
    52 PEP_STATUS transmitGroupKeys(PEP_SESSION session, const Identity partner);
    53 
    54 // state machine
    55 
    56 DeviceState_state fsm_DeviceState(
    57         PEP_SESSION session,
    58         DeviceState_state state,
    59         DeviceState_event event,
    60         const Identity partner
    61     );
    62 
    63 // driver
    64 
    65 PEP_STATUS fsm_DeviceState_inject(PEP_SESSION session, DeviceState_event event);
    66