src/sync_fsm.h
author Volker Birk <vb@pep-project.org>
Mon, 23 May 2016 02:37:17 +0200
changeset 676 aa02f6473007
parent 627 ef1fdfde8ced
child 690 3ae86b68fdfe
permissions -rw-r--r--
typo in Makefile.conf
     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     InitState, 
    27     Sole, 
    28     HandshakingSole, 
    29     WaitForGroupKeys, 
    30     Grouped
    31 } DeviceState_state;
    32 
    33 // events
    34 
    35 typedef enum _DeviceState_event {
    36     Init, 
    37     KeyGen, 
    38     CannotDecrypt, 
    39     Beacon, 
    40     HandshakeRequest, 
    41     HandshakeRejected, 
    42     HandshakeAccepted, 
    43     ReceiveGroupKeys, 
    44     Cancel, 
    45     Reject
    46 } DeviceState_event;
    47 
    48 // actions
    49 
    50 PEP_STATUS sendBeacon(PEP_SESSION session, const Identity partner);
    51 PEP_STATUS sendHandshakeRequest(PEP_SESSION session, const Identity partner);
    52 PEP_STATUS showHandshake(PEP_SESSION session, const Identity partner);
    53 PEP_STATUS reject(PEP_SESSION session, const Identity partner);
    54 PEP_STATUS storeGroupKeys(PEP_SESSION session, const Identity partner);
    55 PEP_STATUS sendOwnKeys(PEP_SESSION session, const Identity partner);
    56 PEP_STATUS transmitGroupKeys(PEP_SESSION session, const Identity partner);
    57 
    58 // state machine
    59 
    60 DeviceState_state fsm_DeviceState(
    61         PEP_SESSION session,
    62         DeviceState_state state,
    63         DeviceState_event event,
    64         const Identity partner
    65     );
    66 
    67 // driver
    68 
    69 PEP_STATUS fsm_DeviceState_inject(PEP_SESSION session, DeviceState_event event);
    70 
    71 #ifdef __cplusplus
    72 }
    73 #endif
    74