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
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
vb@676
     7
#ifdef __cplusplus
vb@676
     8
extern "C" {
vb@676
     9
#endif
vb@676
    10
Edouard@613
    11
// types
Edouard@613
    12
Edouard@613
    13
typedef pEp_identity * Identity;
Edouard@613
    14
typedef union _param { const Identity partner; const stringlist_t *keylist; } param_t;
Edouard@613
    15
Edouard@613
    16
// error values
Edouard@613
    17
Edouard@613
    18
typedef enum _fsm_error {
Edouard@613
    19
    invalid_state = -1,
Edouard@613
    20
    invalid_event = -2
Edouard@613
    21
} fsm_error;
Edouard@613
    22
Edouard@613
    23
// states
Edouard@613
    24
Edouard@613
    25
typedef enum _DeviceState_state {
vb@624
    26
    InitState, 
Edouard@613
    27
    Sole, 
Edouard@613
    28
    HandshakingSole, 
Edouard@613
    29
    WaitForGroupKeys, 
Edouard@613
    30
    Grouped
Edouard@613
    31
} DeviceState_state;
Edouard@613
    32
Edouard@613
    33
// events
Edouard@613
    34
Edouard@613
    35
typedef enum _DeviceState_event {
vb@624
    36
    Init, 
Edouard@613
    37
    KeyGen, 
Edouard@613
    38
    CannotDecrypt, 
Edouard@613
    39
    Beacon, 
Edouard@613
    40
    HandshakeRequest, 
Edouard@613
    41
    HandshakeRejected, 
Edouard@613
    42
    HandshakeAccepted, 
Edouard@613
    43
    ReceiveGroupKeys, 
Edouard@613
    44
    Cancel, 
Edouard@613
    45
    Reject
Edouard@613
    46
} DeviceState_event;
Edouard@613
    47
Edouard@613
    48
// actions
Edouard@613
    49
vb@627
    50
PEP_STATUS sendBeacon(PEP_SESSION session, const Identity partner);
vb@627
    51
PEP_STATUS sendHandshakeRequest(PEP_SESSION session, const Identity partner);
vb@627
    52
PEP_STATUS showHandshake(PEP_SESSION session, const Identity partner);
vb@627
    53
PEP_STATUS reject(PEP_SESSION session, const Identity partner);
vb@627
    54
PEP_STATUS storeGroupKeys(PEP_SESSION session, const Identity partner);
vb@627
    55
PEP_STATUS sendOwnKeys(PEP_SESSION session, const Identity partner);
vb@627
    56
PEP_STATUS transmitGroupKeys(PEP_SESSION session, const Identity partner);
Edouard@613
    57
vb@626
    58
// state machine
vb@626
    59
vb@626
    60
DeviceState_state fsm_DeviceState(
vb@627
    61
        PEP_SESSION session,
vb@626
    62
        DeviceState_state state,
vb@626
    63
        DeviceState_event event,
vb@626
    64
        const Identity partner
vb@626
    65
    );
vb@626
    66
Edouard@613
    67
// driver
Edouard@613
    68
vb@623
    69
PEP_STATUS fsm_DeviceState_inject(PEP_SESSION session, DeviceState_event event);
Edouard@613
    70
vb@676
    71
#ifdef __cplusplus
vb@676
    72
}
vb@676
    73
#endif
vb@676
    74