src/sync_fsm.h
changeset 613 d59da438b2cb
child 618 32fe7c8bee51
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/sync_fsm.h	Thu May 12 18:26:19 2016 +0200
     1.3 @@ -0,0 +1,56 @@
     1.4 +#pragma once
     1.5 +
     1.6 +// state machine for DeviceState
     1.7 +
     1.8 +#include "pEpEngine.h"
     1.9 +
    1.10 +// types
    1.11 +
    1.12 +typedef pEp_identity * Identity;
    1.13 +typedef union _param { const Identity partner; const stringlist_t *keylist; } param_t;
    1.14 +
    1.15 +// error values
    1.16 +
    1.17 +typedef enum _fsm_error {
    1.18 +    invalid_state = -1,
    1.19 +    invalid_event = -2
    1.20 +} fsm_error;
    1.21 +
    1.22 +// states
    1.23 +
    1.24 +typedef enum _DeviceState_state {
    1.25 +    Sole, 
    1.26 +    HandshakingSole, 
    1.27 +    WaitForGroupKeys, 
    1.28 +    Grouped
    1.29 +} DeviceState_state;
    1.30 +
    1.31 +// events
    1.32 +
    1.33 +typedef enum _DeviceState_event {
    1.34 +    KeyGen, 
    1.35 +    CannotDecrypt, 
    1.36 +    Beacon, 
    1.37 +    HandshakeRequest, 
    1.38 +    Init, 
    1.39 +    HandshakeRejected, 
    1.40 +    HandshakeAccepted, 
    1.41 +    ReceiveGroupKeys, 
    1.42 +    Cancel, 
    1.43 +    Reject
    1.44 +} DeviceState_event;
    1.45 +
    1.46 +// actions
    1.47 +
    1.48 +void sendBeacon(const Identity partner);
    1.49 +void sendHandshakeRequest(const Identity partner);
    1.50 +void showHandshake(const Identity partner);
    1.51 +void reject(const Identity partner);
    1.52 +void storeGroupKeys(const Identity partner);
    1.53 +void sendOwnKeys(const Identity partner);
    1.54 +void transmitGroupKeys(const Identity partner);
    1.55 +
    1.56 +// driver
    1.57 +
    1.58 +void fsm_DeviceState_inject(PEP_SESSION session, DeviceState_event event);
    1.59 +