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
Edouard@613
     1
#pragma once
Edouard@613
     2
Edouard@613
     3
// state machine for DeviceState
Edouard@613
     4
Edouard@613
     5
#include "pEpEngine.h"
Edouard@613
     6
Edouard@613
     7
// types
Edouard@613
     8
Edouard@613
     9
typedef pEp_identity * Identity;
Edouard@613
    10
typedef union _param { const Identity partner; const stringlist_t *keylist; } param_t;
Edouard@613
    11
Edouard@613
    12
// error values
Edouard@613
    13
Edouard@613
    14
typedef enum _fsm_error {
Edouard@613
    15
    invalid_state = -1,
Edouard@613
    16
    invalid_event = -2
Edouard@613
    17
} fsm_error;
Edouard@613
    18
Edouard@613
    19
// states
Edouard@613
    20
Edouard@613
    21
typedef enum _DeviceState_state {
Edouard@613
    22
    Sole, 
Edouard@613
    23
    HandshakingSole, 
Edouard@613
    24
    WaitForGroupKeys, 
Edouard@613
    25
    Grouped
Edouard@613
    26
} DeviceState_state;
Edouard@613
    27
Edouard@613
    28
// events
Edouard@613
    29
Edouard@613
    30
typedef enum _DeviceState_event {
Edouard@613
    31
    KeyGen, 
Edouard@613
    32
    CannotDecrypt, 
Edouard@613
    33
    Beacon, 
Edouard@613
    34
    HandshakeRequest, 
Edouard@613
    35
    Init, 
Edouard@613
    36
    HandshakeRejected, 
Edouard@613
    37
    HandshakeAccepted, 
Edouard@613
    38
    ReceiveGroupKeys, 
Edouard@613
    39
    Cancel, 
Edouard@613
    40
    Reject
Edouard@613
    41
} DeviceState_event;
Edouard@613
    42
Edouard@613
    43
// actions
Edouard@613
    44
Edouard@613
    45
void sendBeacon(const Identity partner);
Edouard@613
    46
void sendHandshakeRequest(const Identity partner);
Edouard@613
    47
void showHandshake(const Identity partner);
Edouard@613
    48
void reject(const Identity partner);
Edouard@613
    49
void storeGroupKeys(const Identity partner);
Edouard@613
    50
void sendOwnKeys(const Identity partner);
Edouard@613
    51
void transmitGroupKeys(const Identity partner);
Edouard@613
    52
Edouard@613
    53
// driver
Edouard@613
    54
Edouard@613
    55
void fsm_DeviceState_inject(PEP_SESSION session, DeviceState_event event);
Edouard@613
    56