src/sync_fsm.h
author Volker Birk <vb@pep-project.org>
Fri, 29 Jul 2016 10:45:13 +0200
branchkeysync
changeset 939 ed7dfdae3031
parent 783 f0a7c5183450
child 951 dec407deb10e
permissions -rw-r--r--
changing message_api: adding flags to encrypt_message()
     1 #pragma once
     2 
     3 // state machine for DeviceState
     4 
     5 #include "pEpEngine.h"
     6 
     7 #ifdef __cplusplus
     8 extern "C" {
     9 #endif
    10 
    11 // types
    12 
    13 typedef pEp_identity * Identity;
    14 typedef stringlist_t * Stringlist;
    15 typedef union _param { Identity partner; stringlist_t *keylist; } param_t;
    16 
    17 // error values
    18 
    19 typedef enum _fsm_error {
    20     invalid_state = -2,
    21     invalid_event = -3
    22 } fsm_error;
    23 
    24 // states
    25 
    26 typedef enum _DeviceState_state {
    27     DeviceState_state_NONE = -1,
    28     InitState, 
    29     Sole, 
    30     HandshakingSole, 
    31     WaitForGroupKeys, 
    32     Grouped
    33 } DeviceState_state;
    34 
    35 // events
    36 
    37 typedef enum _DeviceState_event {
    38     DeviceState_event_NONE = -1,
    39     Beacon = 1,
    40     HandshakeRequest = 2,
    41     GroupKeys = 3,
    42     Init, 
    43     KeyGen, 
    44     CannotDecrypt, 
    45     HandshakeRejected, 
    46     HandshakeAccepted, 
    47     Cancel, 
    48     Reject, 
    49     Hand
    50 } DeviceState_event;
    51 
    52 // actions
    53 
    54 PEP_STATUS sendBeacon(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    55 PEP_STATUS sendHandshakeRequest(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    56 PEP_STATUS showHandshake(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    57 PEP_STATUS reject(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    58 PEP_STATUS storeGroupKeys(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    59 PEP_STATUS sendGroupKeys(PEP_SESSION session, DeviceState_state state, Identity partner, void *extra);
    60 
    61 // state machine
    62 
    63 DeviceState_state fsm_DeviceState(
    64         PEP_SESSION session,
    65         DeviceState_state state,
    66         DeviceState_event event,
    67         Identity partner,
    68         DeviceState_state state_partner
    69     );
    70 
    71 // driver
    72 
    73 DYNAMIC_API PEP_STATUS fsm_DeviceState_inject(
    74         PEP_SESSION session,
    75         DeviceState_event event,
    76         Identity partner,
    77         DeviceState_state state_partner
    78     );
    79 
    80 #ifdef __cplusplus
    81 }
    82 #endif
    83