src/sync_fsm.h
author Edouard Tisserant
Thu, 12 May 2016 18:26:19 +0200
changeset 613 d59da438b2cb
child 618 32fe7c8bee51
permissions -rw-r--r--
Added sync some protocol payload definitions
     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     Sole, 
    23     HandshakingSole, 
    24     WaitForGroupKeys, 
    25     Grouped
    26 } DeviceState_state;
    27 
    28 // events
    29 
    30 typedef enum _DeviceState_event {
    31     KeyGen, 
    32     CannotDecrypt, 
    33     Beacon, 
    34     HandshakeRequest, 
    35     Init, 
    36     HandshakeRejected, 
    37     HandshakeAccepted, 
    38     ReceiveGroupKeys, 
    39     Cancel, 
    40     Reject
    41 } DeviceState_event;
    42 
    43 // actions
    44 
    45 void sendBeacon(const Identity partner);
    46 void sendHandshakeRequest(const Identity partner);
    47 void showHandshake(const Identity partner);
    48 void reject(const Identity partner);
    49 void storeGroupKeys(const Identity partner);
    50 void sendOwnKeys(const Identity partner);
    51 void transmitGroupKeys(const Identity partner);
    52 
    53 // driver
    54 
    55 void fsm_DeviceState_inject(PEP_SESSION session, DeviceState_event event);
    56