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
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 {
vb@624
    22
    InitState, 
Edouard@613
    23
    Sole, 
Edouard@613
    24
    HandshakingSole, 
Edouard@613
    25
    WaitForGroupKeys, 
Edouard@613
    26
    Grouped
Edouard@613
    27
} DeviceState_state;
Edouard@613
    28
Edouard@613
    29
// events
Edouard@613
    30
Edouard@613
    31
typedef enum _DeviceState_event {
vb@624
    32
    Init, 
Edouard@613
    33
    KeyGen, 
Edouard@613
    34
    CannotDecrypt, 
Edouard@613
    35
    Beacon, 
Edouard@613
    36
    HandshakeRequest, 
Edouard@613
    37
    HandshakeRejected, 
Edouard@613
    38
    HandshakeAccepted, 
Edouard@613
    39
    ReceiveGroupKeys, 
Edouard@613
    40
    Cancel, 
Edouard@613
    41
    Reject
Edouard@613
    42
} DeviceState_event;
Edouard@613
    43
Edouard@613
    44
// actions
Edouard@613
    45
vb@627
    46
PEP_STATUS sendBeacon(PEP_SESSION session, const Identity partner);
vb@627
    47
PEP_STATUS sendHandshakeRequest(PEP_SESSION session, const Identity partner);
vb@627
    48
PEP_STATUS showHandshake(PEP_SESSION session, const Identity partner);
vb@627
    49
PEP_STATUS reject(PEP_SESSION session, const Identity partner);
vb@627
    50
PEP_STATUS storeGroupKeys(PEP_SESSION session, const Identity partner);
vb@627
    51
PEP_STATUS sendOwnKeys(PEP_SESSION session, const Identity partner);
vb@627
    52
PEP_STATUS transmitGroupKeys(PEP_SESSION session, const Identity partner);
Edouard@613
    53
vb@626
    54
// state machine
vb@626
    55
vb@626
    56
DeviceState_state fsm_DeviceState(
vb@627
    57
        PEP_SESSION session,
vb@626
    58
        DeviceState_state state,
vb@626
    59
        DeviceState_event event,
vb@626
    60
        const Identity partner
vb@626
    61
    );
vb@626
    62
Edouard@613
    63
// driver
Edouard@613
    64
vb@623
    65
PEP_STATUS fsm_DeviceState_inject(PEP_SESSION session, DeviceState_event event);
Edouard@613
    66