Browse Source

...

doc_update_sequoia
Volker Birk 6 years ago
parent
commit
c0c1885c4a
7 changed files with 66 additions and 25 deletions
  1. +12
    -8
      src/map_asn1.c
  2. +4
    -4
      src/map_asn1.h
  3. +25
    -6
      src/sync_actions.c
  4. +11
    -1
      sync/gen_actions_skeleton.ysl2
  5. +8
    -0
      sync/gen_statemachine.ysl2
  6. +4
    -4
      test/map_asn1_test.cc
  7. +2
    -2
      test/sequence_test.cc

+ 12
- 8
src/map_asn1.c View File

@ -1,13 +1,14 @@
#include "pEp_internal.h"
#include "map_asn1.h"
Identity_t *Identity_from_Struct(const pEp_identity *ident)
Identity_t *Identity_from_Struct(const pEp_identity *ident, Identity_t *result)
{
assert(ident);
if (!ident)
return NULL;
Identity_t *result = (Identity_t *) calloc(1, sizeof(Identity_t));
if (!result)
result = (Identity_t *) calloc(1, sizeof(Identity_t));
assert(result);
if (!result)
return NULL;
@ -60,13 +61,14 @@ enomem:
return NULL;
}
pEp_identity *Identity_to_Struct(Identity_t *ident)
pEp_identity *Identity_to_Struct(Identity_t *ident, pEp_identity *result)
{
assert(ident);
if (!ident)
return NULL;
pEp_identity *result = new_identity(NULL, NULL, NULL, NULL);
if (!result)
result = new_identity(NULL, NULL, NULL, NULL);
if (!result)
return NULL;
@ -114,13 +116,14 @@ enomem:
return NULL;
}
KeyList_t *KeyList_from_stringlist(const stringlist_t *list)
KeyList_t *KeyList_from_stringlist(const stringlist_t *list, KeyList_t *result)
{
assert(list);
if (!list)
return NULL;
KeyList_t *result = (KeyList_t *) calloc(1, sizeof(KeyList_t));
if (!result)
result = (KeyList_t *) calloc(1, sizeof(KeyList_t));
assert(result);
if (!result)
return NULL;
@ -143,13 +146,14 @@ enomem:
return NULL;
}
stringlist_t *KeyList_to_stringlist(KeyList_t *list)
stringlist_t *KeyList_to_stringlist(KeyList_t *list, stringlist_t *result)
{
assert(list);
if (!list)
return NULL;
stringlist_t *result = new_stringlist(NULL);
if (!result)
result = new_stringlist(NULL);
if (!result)
return NULL;


+ 4
- 4
src/map_asn1.h View File

@ -9,10 +9,10 @@
extern "C" {
#endif
Identity_t *Identity_from_Struct(const pEp_identity *ident);
pEp_identity *Identity_to_Struct(Identity_t *ident);
KeyList_t *KeyList_from_stringlist(const stringlist_t *list);
stringlist_t *KeyList_to_stringlist(KeyList_t *list);
Identity_t *Identity_from_Struct(const pEp_identity *ident, Identity_t *result);
pEp_identity *Identity_to_Struct(Identity_t *ident, pEp_identity *result);
KeyList_t *KeyList_from_stringlist(const stringlist_t *list, KeyList_t *result);
stringlist_t *KeyList_to_stringlist(KeyList_t *list, stringlist_t *result);
#ifdef __cplusplus
}


+ 25
- 6
src/sync_actions.c View File

@ -1,6 +1,7 @@
// Actions for DeviceState state machine
#include <assert.h>
#include "keymanagement.h"
#include "sync_fsm.h"
#include "map_asn1.h"
#include "../asn.1/Beacon.h"
@ -35,9 +36,15 @@ PEP_STATUS sendBeacon(PEP_SESSION session, const Identity partner)
status = sequence_value(session, "DeviceGroup", &seq);
if (status != PEP_STATUS_OK)
goto error;
msg->header.sequence = (long) seq;
msg->header.sequence = seq;
pEp_identity *me = new_identity(NULL, NULL, NULL, NULL);
if (!me)
goto enomem;
status = myself(session, me);
if (status != PEP_STATUS_OK)
goto error;
return status;
enomem:
@ -75,9 +82,15 @@ PEP_STATUS sendHandshakeRequest(PEP_SESSION session, const Identity partner)
status = sequence_value(session, "DeviceGroup", &seq);
if (status != PEP_STATUS_OK)
goto error;
msg->header.sequence = (long) seq;
msg->header.sequence = seq;
pEp_identity *me = new_identity(NULL, NULL, NULL, NULL);
if (!me)
goto enomem;
status = myself(session, me);
if (status != PEP_STATUS_OK)
goto error;
return status;
enomem:
@ -208,9 +221,15 @@ PEP_STATUS sendOwnKeys(PEP_SESSION session, const Identity partner)
status = sequence_value(session, "DeviceGroup", &seq);
if (status != PEP_STATUS_OK)
goto error;
msg->header.sequence = (long) seq;
msg->header.sequence = seq;
pEp_identity *me = new_identity(NULL, NULL, NULL, NULL);
if (!me)
goto enomem;
status = myself(session, me);
if (status != PEP_STATUS_OK)
goto error;
return status;
enomem:


+ 11
- 1
sync/gen_actions_skeleton.ysl2 View File

@ -34,6 +34,7 @@ tstylesheet {
// Actions for «@name» state machine
#include <assert.h>
#include "keymanagement.h"
#include "sync_fsm.h"
#include "map_asn1.h"
`` for "func:distinctName(//action)" if "substring(@name, 1, 4) = 'send'" | #include "../asn.1/«substring(@name, 5, 255)».h"
@ -132,8 +133,17 @@ tstylesheet {
status = sequence_value(session, "DeviceGroup", &seq);
if (status != PEP_STATUS_OK)
goto error;
msg->header.sequence = (long) seq;
pEp_identity *me = new_identity(NULL, NULL, NULL, NULL);
if (!me)
goto enomem;
status = myself(session, me);
if (status != PEP_STATUS_OK)
goto error;
// payload
msg->header.sequence = seq;
return status;


+ 8
- 0
sync/gen_statemachine.ysl2 View File

@ -17,6 +17,10 @@ tstylesheet {
// state machine for «@name»
#include "pEpEngine.h"
#ifdef __cplusplus
extern "C" {
#endif
// types
@ -59,6 +63,10 @@ tstylesheet {
PEP_STATUS fsm_«@name»_inject(PEP_SESSION session, «@name»_event event);
#ifdef __cplusplus
}
#endif
||
||
#include "sync_fsm.h"


+ 4
- 4
test/map_asn1_test.cc View File

@ -20,12 +20,12 @@ int main() {
cout << "converting identity to ASN.1...\n";
Identity_t *ident_asn1 = Identity_from_Struct(ident1);
Identity_t *ident_asn1 = Identity_from_Struct(ident1, NULL);
assert(ident_asn1);
cout << "converting identity from ASN.1...\n";
pEp_identity *ident2 = Identity_to_Struct(ident_asn1);
pEp_identity *ident2 = Identity_to_Struct(ident_asn1, NULL);
assert(ident2);
assert(strcmp(ident1->address, ident2->address) == 0);
@ -50,12 +50,12 @@ int main() {
cout << "converting stringlist to keylist...\n";
KeyList_t *kl = KeyList_from_stringlist(sl);
KeyList_t *kl = KeyList_from_stringlist(sl, NULL);
assert(kl);
cout << "converting keylist to stringlist...\n";
stringlist_t *sl2 = KeyList_to_stringlist(kl);
stringlist_t *sl2 = KeyList_to_stringlist(kl, NULL);
assert(sl2);
stringlist_t *_sl2;


+ 2
- 2
test/sequence_test.cc View File

@ -18,13 +18,13 @@ int main() {
// sequence test code
int64_t value1;
int32_t value1;
PEP_STATUS status2 = sequence_value(session, "test", &value1);
assert(status2 == PEP_STATUS_OK);
cout << "test sequence: " << value1 << "\n";
int64_t value2;
int32_t value2;
PEP_STATUS status3 = sequence_value(session, "test", &value2);
assert(status3 == PEP_STATUS_OK);


Loading…
Cancel
Save