... sync
authorVolker Birk <vb@pep.foundation>
Wed, 22 Aug 2018 18:34:52 +0200
branchsync
changeset 28714593a7b8b6a8
parent 2870 9c0567977ed2
child 2872 ea6d9edc7001
...
Makefile
asn.1/Makefile
src/Makefile
sync/cond_act_sync.yml2
sync/gen_statemachine.ysl2
sync/sync.fsm
test/src/engine_tests/SyncTests.cc
     1.1 --- a/Makefile	Wed Aug 22 17:04:03 2018 +0200
     1.2 +++ b/Makefile	Wed Aug 22 18:34:52 2018 +0200
     1.3 @@ -48,7 +48,6 @@
     1.4  test: all
     1.5  	$(MAKE) -C test test
     1.6  
     1.7 -
     1.8  .PHONY: package
     1.9  package: clean
    1.10  	cd .. ; COPYFILE_DISABLE=true tar cjf pEpEngine.tar.bz2 "$(HERE_REL)"
     2.1 --- a/asn.1/Makefile	Wed Aug 22 17:04:03 2018 +0200
     2.2 +++ b/asn.1/Makefile	Wed Aug 22 18:34:52 2018 +0200
     2.3 @@ -24,7 +24,7 @@
     2.4  sync.asn1 keysync.asn1 pEp.asn1:
     2.5  	cp -f ../sync/generated/*.asn1 ../asn.1
     2.6  
     2.7 -.PHONY: clean install uninstall
     2.8 +.PHONY: clean install uninstall tags
     2.9  
    2.10  clean:
    2.11  	rm -f *.a *.o *.c *.h *.sample sync.asn1 keysync.asn1
    2.12 @@ -33,3 +33,5 @@
    2.13  
    2.14  uninstall:
    2.15  
    2.16 +tags:
    2.17 +	ctags *.c *.h
     3.1 --- a/src/Makefile	Wed Aug 22 17:04:03 2018 +0200
     3.2 +++ b/src/Makefile	Wed Aug 22 18:34:52 2018 +0200
     3.3 @@ -96,3 +96,8 @@
     3.4  uninstall:
     3.5  	rm -f $(PREFIX)/lib/$(TARGET)
     3.6  	rm -rf $(PREFIX)/include/pEp
     3.7 +
     3.8 +.PHONY: tags
     3.9 +tags:
    3.10 +	ctags *.c *.h
    3.11 +
     4.1 --- a/sync/cond_act_sync.yml2	Wed Aug 22 17:04:03 2018 +0200
     4.2 +++ b/sync/cond_act_sync.yml2	Wed Aug 22 18:34:52 2018 +0200
     4.3 @@ -56,18 +56,6 @@
     4.4  
     4.5  // action: PEP_STATUS «@name»(PEP_SESSION session)
     4.6  
     4.7 -action closeHandshakeDialog
     4.8 -||
     4.9 -    assert(session->notifyHandshake);
    4.10 -    if (!session->notifyHandshake)
    4.11 -        return PEP_SYNC_NO_NOTIFY_CALLBACK;
    4.12 -
    4.13 -    PEP_STATUS status = session->notifyHandshake(
    4.14 -            session->sync_management, NULL, NULL, SYNC_NOTIFY_OVERTAKEN);
    4.15 -    if (status)
    4.16 -        return status;
    4.17 -||
    4.18 -
    4.19  function "new_UUID" {
    4.20      param "dst";
    4.21      ||
    4.22 @@ -92,9 +80,6 @@
    4.23      ||
    4.24  }
    4.25  
    4.26 -action clearState
    4.27 -    |> free_Sync_state(session);
    4.28 -
    4.29  action openChallenge
    4.30      call "new_UUID" with "dst" > &session->own_sync_state.challenge
    4.31  
     5.1 --- a/sync/gen_statemachine.ysl2	Wed Aug 22 17:04:03 2018 +0200
     5.2 +++ b/sync/gen_statemachine.ysl2	Wed Aug 22 18:34:52 2018 +0200
     5.3 @@ -347,21 +347,26 @@
     5.4                      goto the_end;
     5.5  
     5.6                  switch (message_type) {
     5.7 -                    // these messages are broadcasted
     5.8 -                    `` for "fsm/message[@type='broadcast']" |>> case «@name»:
     5.9 -                        status = _own_identities_retrieve(session, &channels, PEP_idf_not_for_sync);
    5.10 +                    // these messages are being broadcasted
    5.11 +                    `` for "fsm/message[@type='broadcast']" |>> case «../@name»__payload_PR_«yml:lcase(@name)»:
    5.12 +                        status = _own_identities_retrieve(session, &channels, PEP_idf_not_for_«yml:lcase(@name)»);
    5.13                          if (!status)
    5.14                              goto the_end;
    5.15 +
    5.16 +                        if (!(channels && channels->ident)) {
    5.17 +                            status = PEP_«yml:ucase(@name)»_NO_CHANNEL;
    5.18 +                            goto the_end;
    5.19 +                        }
    5.20                          break;
    5.21  
    5.22                      // all other go anycast; previously used address is sticky (unicast)
    5.23                      default: {
    5.24                          if (!session->«yml:lcase(@name)»_state.common.from `> |`|
    5.25                              (session->«yml:lcase(@name)»_state.common.from->flags &
    5.26 -                            PEP_idf_not_for_sync)) {
    5.27 +                            PEP_idf_not_for_«yml:lcase(@name)»)) {
    5.28  
    5.29                              // no address available yet, try to find one
    5.30 -                            status = _own_identities_retrieve(session, &channels, PEP_idf_not_for_sync);
    5.31 +                            status = _own_identities_retrieve(session, &channels, PEP_idf_not_for_«yml:lcase(@name)»);
    5.32                              if (!status)
    5.33                                  goto the_end;
    5.34                              break;
    5.35 @@ -372,7 +377,7 @@
    5.36                                  channels->next = NULL;
    5.37                              }
    5.38                              else {
    5.39 -                                status = PEP_SYNC_NO_CHANNEL;
    5.40 +                                status = PEP_«yml:ucase(@name)»_NO_CHANNEL;
    5.41                                  goto the_end;
    5.42                              }
    5.43                          }
     6.1 --- a/sync/sync.fsm	Wed Aug 22 17:04:03 2018 +0200
     6.2 +++ b/sync/sync.fsm	Wed Aug 22 18:34:52 2018 +0200
     6.3 @@ -29,8 +29,6 @@
     6.4  
     6.5          state Sole {
     6.6              on Init {
     6.7 -                do closeHandshakeDialog;
     6.8 -                do clearState;
     6.9                  do openChallenge; // own challenge
    6.10                  send Beacon;
    6.11              }
    6.12 @@ -216,11 +214,6 @@
    6.13          }
    6.14  
    6.15          state Grouped {
    6.16 -            on Init {
    6.17 -                do closeHandshakeDialog;
    6.18 -                do clearState;
    6.19 -            }
    6.20 -
    6.21              on GroupKeys
    6.22                  do saveGroupKeys;
    6.23  
     7.1 --- a/test/src/engine_tests/SyncTests.cc	Wed Aug 22 17:04:03 2018 +0200
     7.2 +++ b/test/src/engine_tests/SyncTests.cc	Wed Aug 22 18:34:52 2018 +0200
     7.3 @@ -6,7 +6,9 @@
     7.4  
     7.5  #include "pEpEngine.h"
     7.6  #include "sync_api.h"
     7.7 -#include "Sync_event.h"
     7.8 +
     7.9 +#include "pEp_internal.h"
    7.10 +#include "KeySync_fsm.h"
    7.11  
    7.12  #include "EngineTestSessionSuite.h"
    7.13  #include "SyncTests.h"
    7.14 @@ -20,11 +22,11 @@
    7.15      utility::locked_queue< Sync_event_t * > q;
    7.16  
    7.17      static PEP_STATUS notifyHandshake(
    7.18 -        void *obj,
    7.19 -        pEp_identity *me,
    7.20 -        pEp_identity *partner,
    7.21 -        sync_handshake_signal signal
    7.22 -    )
    7.23 +            void *obj,
    7.24 +            pEp_identity *me,
    7.25 +            pEp_identity *partner,
    7.26 +            sync_handshake_signal signal
    7.27 +        )
    7.28      {
    7.29          return PEP_STATUS_OK;
    7.30      }
    7.31 @@ -41,6 +43,12 @@
    7.32          auto adapter = static_cast< Sync_Adapter *>(management);
    7.33          return adapter->q.pop_front();
    7.34      }
    7.35 +
    7.36 +    static PEP_STATUS messageToSend(void *obj, struct _message *msg)
    7.37 +    {
    7.38 +        assert(msg);
    7.39 +        return PEP_STATUS_OK;
    7.40 +    }
    7.41  };
    7.42  
    7.43  SyncTests::SyncTests(string suitename, string test_home_dir) :
    7.44 @@ -49,18 +57,26 @@
    7.45                                                                        static_cast<Func>(&SyncTests::check_sync)));
    7.46  }
    7.47  
    7.48 -void SyncTests::check_sync() {
    7.49 +void SyncTests::check_sync()
    7.50 +{
    7.51      Sync_Adapter adapter;
    7.52 +    PEP_SESSION sync = NULL;
    7.53  
    7.54 -    PEP_STATUS status = register_sync_callbacks(
    7.55 -            session,
    7.56 +    PEP_STATUS status = init(&sync, Sync_Adapter::messageToSend);
    7.57 +    TEST_ASSERT(status == PEP_STATUS_OK);
    7.58 +
    7.59 +    status = register_sync_callbacks(
    7.60 +            sync,
    7.61              &adapter.q,
    7.62              Sync_Adapter::notifyHandshake,
    7.63              Sync_Adapter::inject_sync_event,
    7.64              Sync_Adapter::retrieve_next_sync_event
    7.65          );
    7.66 +    TEST_ASSERT(status == PEP_STATUS_OK);
    7.67  
    7.68 -    TEST_ASSERT(status == PEP_STATUS_OK);
    7.69 -    unregister_sync_callbacks(session);
    7.70 +    TEST_ASSERT(sync->sync_state.keysync.state == Sole);
    7.71 +
    7.72 +    unregister_sync_callbacks(sync);
    7.73 +    release(sync);
    7.74  }
    7.75