src/sync_fsm.h
author Krista Grothoff <krista@pep-project.org>
Sat, 24 Sep 2016 18:09:18 +0200
branchENGINE-27
changeset 1185 4b01328f3cf2
parent 783 f0a7c5183450
child 939 ed7dfdae3031
permissions -rw-r--r--
ENGINE-27: update_identity no longer pays attention to the input identity's fpr, but pulls one from elect_pubkey.
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 {
vb@743
    19
    invalid_state = -2,
vb@743
    20
    invalid_event = -3
Edouard@613
    21
} fsm_error;
Edouard@613
    22
Edouard@613
    23
// states
Edouard@613
    24
Edouard@613
    25
typedef enum _DeviceState_state {
vb@743
    26
    DeviceState_state_NONE = -1,
vb@624
    27
    InitState, 
Edouard@613
    28
    Sole, 
Edouard@613
    29
    HandshakingSole, 
Edouard@613
    30
    WaitForGroupKeys, 
Edouard@613
    31
    Grouped
Edouard@613
    32
} DeviceState_state;
Edouard@613
    33
Edouard@613
    34
// events
Edouard@613
    35
Edouard@613
    36
typedef enum _DeviceState_event {
vb@743
    37
    DeviceState_event_NONE = -1,
vb@711
    38
    Beacon = 1,
vb@711
    39
    HandshakeRequest = 2,
vb@711
    40
    GroupKeys = 3,
vb@624
    41
    Init, 
Edouard@613
    42
    KeyGen, 
Edouard@613
    43
    CannotDecrypt, 
Edouard@613
    44
    HandshakeRejected, 
Edouard@613
    45
    HandshakeAccepted, 
Edouard@613
    46
    Cancel, 
Edouard@613
    47
    Reject
Edouard@613
    48
} DeviceState_event;
Edouard@613
    49
Edouard@613
    50
// actions
Edouard@613
    51
vb@690
    52
PEP_STATUS sendBeacon(PEP_SESSION session, DeviceState_state state, const Identity partner);
vb@690
    53
PEP_STATUS sendHandshakeRequest(PEP_SESSION session, DeviceState_state state, const Identity partner);
vb@690
    54
PEP_STATUS showHandshake(PEP_SESSION session, DeviceState_state state, const Identity partner);
vb@690
    55
PEP_STATUS reject(PEP_SESSION session, DeviceState_state state, const Identity partner);
vb@690
    56
PEP_STATUS storeGroupKeys(PEP_SESSION session, DeviceState_state state, const Identity partner);
vb@711
    57
PEP_STATUS sendGroupKeys(PEP_SESSION session, DeviceState_state state, const Identity partner);
Edouard@613
    58
vb@626
    59
// state machine
vb@626
    60
vb@626
    61
DeviceState_state fsm_DeviceState(
vb@627
    62
        PEP_SESSION session,
vb@626
    63
        DeviceState_state state,
vb@626
    64
        DeviceState_event event,
vb@690
    65
        const Identity partner,
vb@690
    66
        DeviceState_state state_partner
vb@626
    67
    );
vb@626
    68
Edouard@613
    69
// driver
Edouard@613
    70
vb@783
    71
DYNAMIC_API PEP_STATUS fsm_DeviceState_inject(
vb@690
    72
        PEP_SESSION session,
vb@690
    73
        DeviceState_event event,
vb@690
    74
        Identity partner,
vb@690
    75
        DeviceState_state state_partner
vb@690
    76
    );
Edouard@613
    77
vb@676
    78
#ifdef __cplusplus
vb@676
    79
}
vb@676
    80
#endif
vb@676
    81