checking in generated file
authorVolker Birk <vb@pep-project.org>
Thu, 12 May 2016 19:51:53 +0200
changeset 6166d4ea9ea1016
parent 615 52c1a857e73e
child 617 0caa732cf9a4
checking in generated file
src/sync_fsm.c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/sync_fsm.c	Thu May 12 19:51:53 2016 +0200
     1.3 @@ -0,0 +1,89 @@
     1.4 +#include "sync_fsm.h"
     1.5 +
     1.6 +// state machine for DeviceState
     1.7 +
     1.8 +DeviceState_state fsm_DeviceState(
     1.9 +        DeviceState_state state,
    1.10 +        DeviceState_event event,
    1.11 +        const Identity partner
    1.12 +    )
    1.13 +{
    1.14 +    switch (state) {
    1.15 +    case Sole:
    1.16 +        switch (event) {
    1.17 +            case KeyGen:
    1.18 +                sendBeacon(NULL);
    1.19 +                break;
    1.20 +            case CannotDecrypt:
    1.21 +                sendBeacon(NULL);
    1.22 +                break;
    1.23 +            case Beacon:
    1.24 +                sendHandshakeRequest(partner);
    1.25 +                break;
    1.26 +            case HandshakeRequest:
    1.27 +                sendHandshakeRequest(partner);
    1.28 +                return HandshakingSole;
    1.29 +        default:
    1.30 +            return invalid_event;
    1.31 +        }
    1.32 +        break;
    1.33 +    
    1.34 +    case HandshakingSole:
    1.35 +        switch (event) {
    1.36 +            case Init:
    1.37 +                showHandshake(partner);
    1.38 +                break;
    1.39 +            case HandshakeRejected:
    1.40 +                reject(partner);
    1.41 +                return Sole;
    1.42 +            case HandshakeAccepted:
    1.43 +                return WaitForGroupKeys;
    1.44 +        default:
    1.45 +            return invalid_event;
    1.46 +        }
    1.47 +        break;
    1.48 +    
    1.49 +    case WaitForGroupKeys:
    1.50 +        switch (event) {
    1.51 +            case ReceiveGroupKeys:
    1.52 +                storeGroupKeys(partner);
    1.53 +                return Grouped;
    1.54 +            case Cancel:
    1.55 +                return Sole;
    1.56 +            case Reject:
    1.57 +                reject(partner);
    1.58 +                return Sole;
    1.59 +        default:
    1.60 +            return invalid_event;
    1.61 +        }
    1.62 +        break;
    1.63 +    
    1.64 +    case Grouped:
    1.65 +        switch (event) {
    1.66 +            case KeyGen:
    1.67 +                sendOwnKeys(NULL);
    1.68 +                break;
    1.69 +            case HandshakeRequest:
    1.70 +                sendHandshakeRequest(partner);
    1.71 +                showHandshake(partner);
    1.72 +                break;
    1.73 +            case HandshakeRejected:
    1.74 +                reject(partner);
    1.75 +                break;
    1.76 +            case HandshakeAccepted:
    1.77 +                transmitGroupKeys(partner);
    1.78 +                break;
    1.79 +            case Reject:
    1.80 +                reject(NULL);
    1.81 +                break;
    1.82 +        default:
    1.83 +            return invalid_event;
    1.84 +        }
    1.85 +        break;
    1.86 +    
    1.87 +        default:
    1.88 +            return invalid_state;
    1.89 +    }
    1.90 +
    1.91 +    return state;
    1.92 +}