... sync
authorVolker Birk <vb@pep.foundation>
Tue, 21 Aug 2018 17:35:00 +0200
branchsync
changeset 2864dcbed0d35466
parent 2857 dc81cb891159
child 2865 96aaa55b2a54
...
src/message_api.h
src/sync_impl.h
sync/gen_message_func.ysl2
sync/gen_messages.ysl2
test/src/engine_tests/SyncTests.cc
     1.1 --- a/src/message_api.h	Fri Aug 17 21:28:43 2018 +0200
     1.2 +++ b/src/message_api.h	Tue Aug 21 17:35:00 2018 +0200
     1.3 @@ -68,7 +68,7 @@
     1.4  //                                      attached to it
     1.5  //
     1.6  //  caveat:
     1.7 -//      the ownershop of src remains with the caller
     1.8 +//      the ownership of src remains with the caller
     1.9  //      the ownership of dst goes to the caller
    1.10  DYNAMIC_API PEP_STATUS encrypt_message(
    1.11          PEP_SESSION session,
     2.1 --- a/src/sync_impl.h	Fri Aug 17 21:28:43 2018 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,79 +0,0 @@
     2.4 -// This file is under GNU General Public License 3.0
     2.5 -// see LICENSE.txt
     2.6 -
     2.7 -#pragma once
     2.8 -
     2.9 -#include "fsm_common.h"
    2.10 -#include "message_api.h"
    2.11 -#include "Sync_event.h"
    2.12 -
    2.13 -#ifdef __cplusplus
    2.14 -extern "C" {
    2.15 -#endif
    2.16 -
    2.17 -// conditions
    2.18 -
    2.19 -PEP_STATUS deviceGrouped(PEP_SESSION session, bool *result);
    2.20 -PEP_STATUS challengeAccepted(PEP_SESSION session, bool *result);
    2.21 -PEP_STATUS partnerIsGrouped(PEP_SESSION session, bool *result);
    2.22 -PEP_STATUS keyElectionWon(PEP_SESSION session, bool *result);
    2.23 -
    2.24 -// actions
    2.25 -
    2.26 -PEP_STATUS closeHandshakeDialog(PEP_SESSION session);
    2.27 -PEP_STATUS clearState(PEP_SESSION session);
    2.28 -PEP_STATUS openChallenge(PEP_SESSION session);
    2.29 -PEP_STATUS storeChallenge(PEP_SESSION session);
    2.30 -PEP_STATUS openTransaction(PEP_SESSION session);
    2.31 -PEP_STATUS storeTransaction(PEP_SESSION session);
    2.32 -PEP_STATUS showSoleHandshake(PEP_SESSION session);
    2.33 -PEP_STATUS disable(PEP_SESSION session);
    2.34 -PEP_STATUS saveGroupKeys(PEP_SESSION session);
    2.35 -PEP_STATUS ownKeysAreGroupKeys(PEP_SESSION session);
    2.36 -PEP_STATUS showJoinGroupHandshake(PEP_SESSION session);
    2.37 -PEP_STATUS showGroupedHandshake(PEP_SESSION session);
    2.38 -
    2.39 -// notify state machine from event
    2.40 -// use state to generate Sync message if necessary
    2.41 -
    2.42 -PEP_STATUS Sync_notify(
    2.43 -        PEP_SESSION session, 
    2.44 -        Sync_PR fsm,
    2.45 -        int message_type
    2.46 -    );
    2.47 -
    2.48 -// send message about an event to communication partners using state
    2.49 -
    2.50 -PEP_STATUS send_Sync_message(
    2.51 -        PEP_SESSION session, 
    2.52 -        Sync_PR fsm,
    2.53 -        int message_type
    2.54 -    );
    2.55 -
    2.56 -// receive message and store it in state
    2.57 -
    2.58 -PEP_STATUS recv_Sync_event(
    2.59 -        PEP_SESSION session,
    2.60 -        Sync_event_t *ev
    2.61 -    );
    2.62 -
    2.63 -// state machine driver
    2.64 -// if fsm or event set to 0 use fields in src if present
    2.65 -
    2.66 -PEP_STATUS Sync_driver(
    2.67 -        PEP_SESSION session,
    2.68 -        Sync_PR fsm,
    2.69 -        int event
    2.70 -    );
    2.71 -
    2.72 -PEP_STATUS inject_Sync_event(
    2.73 -        PEP_SESSION session, 
    2.74 -        Sync_PR fsm,
    2.75 -        int event
    2.76 -    );
    2.77 -
    2.78 -
    2.79 -#ifdef __cplusplus
    2.80 -}
    2.81 -#endif
    2.82 -
     3.1 --- a/sync/gen_message_func.ysl2	Fri Aug 17 21:28:43 2018 +0200
     3.2 +++ b/sync/gen_message_func.ysl2	Tue Aug 21 17:35:00 2018 +0200
     3.3 @@ -3,7 +3,7 @@
     3.4  
     3.5  // generate message functions
     3.6  
     3.7 -// Copyleft (c) 2017, p≡p foundation
     3.8 +// Copyleft (c) 2017, 2018, p≡p foundation
     3.9  
    3.10  // Written by Volker Birk
    3.11  
     4.1 --- a/sync/gen_messages.ysl2	Fri Aug 17 21:28:43 2018 +0200
     4.2 +++ b/sync/gen_messages.ysl2	Tue Aug 21 17:35:00 2018 +0200
     4.3 @@ -17,78 +17,81 @@
     4.4      function "pEp_imports"
     4.5          | IMPORTS Identity, IdentityList, TID, Hash FROM PEP;
     4.6  
     4.7 +    function "header"
     4.8 +    ||
     4.9 +    -- This file is under BSD License 2.0
    4.10 +
    4.11 +    -- «@name» protocol for p≡p
    4.12 +    -- Copyright (c) 2016-2018 p≡p foundation
    4.13 +
    4.14 +    -- Written by Volker Birk
    4.15 +
    4.16 +    ||
    4.17 +
    4.18      template "/" {
    4.19          apply "protocol", 0, mode=overview;
    4.20          apply "protocol/fsm", 0, mode=individual;
    4.21      }
    4.22  
    4.23      template "protocol", mode=overview
    4.24 -        document "generated/{yml:lcase(@name)}.asn1", "text"
    4.25 -    ||
    4.26 -    -- This file is under BSD License 2.0
    4.27 +        document "generated/{yml:lcase(@name)}.asn1", "text" {
    4.28  
    4.29 -    -- «@name» protocol stack for p≡p
    4.30 -    -- Copyright (c) 2016, 2017 p≡p foundation
    4.31 +        call "header";
    4.32 +        ||
    4.33 +        «yml:ucase(@name)»
    4.34 +            { iso(1) org(3) dod(6) internet(1) private(4) enterprise(1) pEp(47878) «yml:lcase(@name)»(«@id») }
    4.35  
    4.36 -    -- Written by Volker Birk
    4.37 +        DEFINITIONS AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::=
    4.38  
    4.39 -    «yml:ucase(@name)»
    4.40 -        { iso(1) org(3) dod(6) internet(1) private(4) enterprise(1) pEp(47878) «yml:lcase(@name)»(«@id») }
    4.41 +        BEGIN
    4.42  
    4.43 -    DEFINITIONS AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::=
    4.44 +        `` for "fsm" | IMPORTS «@name» FROM «yml:ucase(@name)»;
    4.45  
    4.46 -    BEGIN
    4.47 +        «@name» ::= CHOICE {
    4.48 +            `` for "fsm" |> «yml:lcase(@name)» [APPLICATION «@id»] «@name»`if "position()!=last()" > , `
    4.49 +        }
    4.50  
    4.51 -    `` for "fsm" | IMPORTS «@name» FROM «yml:ucase(@name)»;
    4.52 +        END
    4.53  
    4.54 -    «@name» ::= CHOICE {
    4.55 -        `` for "fsm" |> «yml:lcase(@name)» [APPLICATION «@id»] «@name»`if "position()!=last()" > , `
    4.56 +        ||
    4.57      }
    4.58  
    4.59 -    END
    4.60 +    template "fsm", mode=individual
    4.61 +        document "generated/{yml:lcase(@name)}.asn1", "text" {
    4.62  
    4.63 -    ||
    4.64 +        call "header";
    4.65 +        ||
    4.66 +        «yml:ucase(@name)»
    4.67 +            { iso(1) org(3) dod(6) internet(1) private(4) enterprise(1) pEp(47878) «yml:lcase(../@name)»(«../@id») «yml:lcase(@name)»(«@id») }
    4.68  
    4.69 -    template "fsm", mode=individual
    4.70 -        document "generated/{yml:lcase(@name)}.asn1", "text"
    4.71 -    ||
    4.72 -    -- This file is under BSD License 2.0
    4.73 +        DEFINITIONS AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::=
    4.74  
    4.75 -    -- «@name» protocol for p≡p version «version/@major».«version/@minor»
    4.76 -    -- Copyright (c) 2016, 2017 p≡p foundation
    4.77 +        BEGIN
    4.78  
    4.79 -    -- Written by Volker Birk
    4.80 +        EXPORTS «@name»;
    4.81 +        `` call "pEp_imports"
    4.82  
    4.83 -    «yml:ucase(@name)»
    4.84 -        { iso(1) org(3) dod(6) internet(1) private(4) enterprise(1) pEp(47878) «yml:lcase(../@name)»(«../@id») «yml:lcase(@name)»(«@id») }
    4.85 +        Version ::= SEQUENCE {
    4.86 +            major INTEGER (0..255) DEFAULT «version/@major»,
    4.87 +            minor INTEGER (0..255) DEFAULT «version/@minor»
    4.88 +        }
    4.89  
    4.90 -    DEFINITIONS AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::=
    4.91 +        `` apply "message", 0, mode=impl;
    4.92 +        «@name» ::= SEQUENCE {
    4.93 +            header SEQUENCE {
    4.94 +                sequence INTEGER  -- always increases
    4.95 +            },
    4.96  
    4.97 -    BEGIN
    4.98 +            payload CHOICE {
    4.99 +            `` for "message" |>> «yml:mixedCase(@name)» [APPLICATION «@id»] «@name»`if "position()!=last()" > ,`
   4.100 +            }
   4.101 +        }
   4.102  
   4.103 -    EXPORTS «@name»;
   4.104 -    `` call "pEp_imports"
   4.105 +        END
   4.106  
   4.107 -    Version ::= SEQUENCE {
   4.108 -        major INTEGER (0..255) DEFAULT «version/@major»,
   4.109 -        minor INTEGER (0..255) DEFAULT «version/@minor»
   4.110 +        ||
   4.111      }
   4.112  
   4.113 -    `` apply "message", 0, mode=impl;
   4.114 -    «@name» ::= SEQUENCE {
   4.115 -        header SEQUENCE {
   4.116 -            sequence INTEGER  -- always increases
   4.117 -        },
   4.118 -
   4.119 -        payload CHOICE {
   4.120 -        `` for "message" |>> «yml:mixedCase(@name)» [APPLICATION «@id»] «@name»`if "position()!=last()" > ,`
   4.121 -        }
   4.122 -    }
   4.123 -
   4.124 -    END
   4.125 -
   4.126 -    ||
   4.127 -
   4.128      template "message", mode=impl
   4.129      ||
   4.130      «@name» ::= SEQUENCE {
     5.1 --- a/test/src/engine_tests/SyncTests.cc	Fri Aug 17 21:28:43 2018 +0200
     5.2 +++ b/test/src/engine_tests/SyncTests.cc	Tue Aug 21 17:35:00 2018 +0200
     5.3 @@ -35,6 +35,7 @@
     5.4          adapter->q.push_front(ev);
     5.5          return 0;
     5.6      }
     5.7 +
     5.8      static Sync_event_t *retrieve_next_sync_event(void *management)
     5.9      {
    5.10          auto adapter = static_cast< Sync_Adapter *>(management);