Browse Source

abstract multiprotocol implementation

master
Volker Birk 7 months ago
parent
commit
288f0013e6
7 changed files with 42 additions and 51 deletions
  1. +4
    -12
      .gitignore
  2. +18
    -18
      codegen/Makefile
  3. +1
    -1
      codegen/gen_actions.ysl2
  4. +1
    -1
      codegen/gen_dot.ysl2
  5. +2
    -2
      codegen/gen_message_func.ysl2
  6. +16
    -17
      codegen/gen_statemachine.ysl2
  7. +0
    -0
      codegen/sync.act

+ 4
- 12
.gitignore View File

@ -41,7 +41,7 @@ Makefile.protocols
test/msg_encrypt_for_self.asc
tags
asn.1/pEpEngineASN1/pEpEngineASN1.vcxproj.user
sync/generated
codegen/generated
*.xml
*.dot
*.svg
@ -82,12 +82,6 @@ asn.1/exploration.asn1
asn.1/managedgroup.asn1
asn.1/storage.asn1
asn.1/messagestorage.asn1
sync/.codecs
sync/.messages
sync/.actions
sync/.codegen
sync/.statemachines
sync/.copy
test/msg_2.0.asc
test/*.txt
lldb-history
@ -135,9 +129,7 @@ test/test_mails/ENGINE-654_bob_mail.eml
# ignore generated data
codegen/.actions
codegen/.codecs
codegen/.copy
codegen/.messages
codegen/.statemachines
codegen/generated/
codegen/*.gen
.copy

+ 18
- 18
codegen/Makefile View File

@ -10,37 +10,37 @@ all: .copy
generated:
mkdir -p $@
.actions: sync.fsm gen_actions.ysl2 fsm.yml2 functions.ysl2 $(wildcard cond_act_*.yml2) | generated
$(YML2_PROC) -y gen_actions.ysl2 $< -o $@
statemachines := $(patsubst %.fsm,%.fsm.gen,$(wildcard *.fsm))
.statemachines: sync.fsm gen_statemachine.ysl2 fsm.yml2 functions.ysl2 | generated
$(YML2_PROC) -y gen_statemachine.ysl2 $< -o $@
actions := $(patsubst %.act,%.act.gen,$(wildcard *.act))
.codecs: sync.fsm distribution.fsm storage.fsm gen_codec.ysl2 fsm.yml2 functions.ysl2 | generated
$(YML2_PROC) -y gen_codec.ysl2 $< -o $@
$(YML2_PROC) -y gen_codec.ysl2 distribution.fsm -o $@
$(YML2_PROC) -y gen_codec.ysl2 storage.fsm -o $@
dot := $(patsubst %.fsm,%.dot,$(wildcard *.fsm))
.messages: sync.fsm distribution.fsm storage.fsm gen_messages.ysl2 gen_message_func.ysl2 fsm.yml2 functions.ysl2 | generated
$(YML2_PROC) -y gen_messages.ysl2 $< -o $@
%.fsm.gen: %.fsm gen_statemachine.ysl2 fsm.yml2 functions.ysl2 | generated
$(YML2_PROC) -y gen_statemachine.ysl2 $< > /dev/null
$(YML2_PROC) -y gen_codec.ysl2 $< > /dev/null
$(YML2_PROC) -y gen_messages.ysl2 $< > /dev/null
$(YML2_PROC) -y gen_message_func.ysl2 $< -o $@
$(YML2_PROC) -y gen_messages.ysl2 distribution.fsm -o $@
$(YML2_PROC) -y gen_messages.ysl2 storage.fsm -o $@
%.act.gen: %.act %.fsm gen_actions.ysl2 fsm.yml2 functions.ysl2 | generated
echo 'define actfile = "./$<";' | $(YML2_PROC) - gen_actions.ysl2 | $(YML2_PROC) -X - sync.fsm -o $@
clean:
rm -rf generated
rm -f *.xml *.xsl .statemachines .actions .codecs .messages .copy *.dot *.svg
rm -rf generated *.gen
rm -f *.xml *.xsl .copy *.dot *.svg
.copy: .actions .statemachines .codecs .messages
.copy: $(actions) $(statemachines) $(dot)
cp -f generated/*.c generated/*.h ../src
cp -f generated/*.asn1 ../asn.1
touch .copy
%.xml: %.fsm
yml2c $< -o $@
$(YML2_PROC) $< -o $@
svg: $(patsubst %.dot,%.svg,$(wildcard *.dot))
%.dot: sync.fsm gen_dot.ysl2
$(YML2_PROC) -y gen_dot.ysl2 $<
%.dot: %.fsm gen_dot.ysl2
$(YML2_PROC) -y gen_dot.ysl2 $< -o $@
%.svg: %.dot
dot -Tsvg -o $@ $<


+ 1
- 1
codegen/gen_actions.ysl2 View File

@ -23,7 +23,7 @@ tstylesheet {
include standardlib.ysl2
include ./functions.ysl2
include ./cond_act_*.yml2
include from *actfile
template "/protocol" {
document "generated/{@name}_actions.c", "text" {


+ 1
- 1
codegen/gen_dot.ysl2 View File

@ -4,7 +4,7 @@
include yslt.yml2
tstylesheet {
template "protocol/fsm" document "{@name}.dot", "text"
template "protocol/fsm[count(state)>0]" document "{@name}.dot", "text"
||
digraph finite_state_machine {
rankdir=LR;


+ 2
- 2
codegen/gen_message_func.ysl2 View File

@ -20,7 +20,7 @@ template "/" {
}
template "protocol", mode=header
document "generated/{@name}_func.h", "text"
if "fsm[count(state)]" document "generated/{@name}_func.h", "text"
||
/**
* @file «@name»_func.h
@ -195,7 +195,7 @@ struct _«@name»_state_s {
||
template "protocol", mode=impl
document "generated/{@name}_func.c", "text" {
if "fsm[count(state)]" document "generated/{@name}_func.c", "text" {
||
/**
* @file «@name»_func.c


+ 16
- 17
codegen/gen_statemachine.ysl2 View File

@ -14,7 +14,7 @@ tstylesheet {
include ./functions.ysl2
template "/protocol" {
document "generated/{@name}_event.h", "text"
if "count(fsm/state)" document "generated/{@name}_event.h", "text"
||
/**
* @file «@name»_event.h
@ -93,7 +93,7 @@ tstylesheet {
||
document "generated/{@name}_event.c", "text"
if "count(fsm/state)" document "generated/{@name}_event.c", "text"
||
/**
@ -148,7 +148,7 @@ tstylesheet {
||
document "generated/{@name}_impl.h", "text" {
if "count(fsm/state)" document "generated/{@name}_impl.h", "text" {
||
/**
* @file «@name»_impl.h
@ -167,7 +167,7 @@ tstylesheet {
#include "../asn.1/«@name».h"
#define «yml:ucase(@name)»_THRESHOLD «@threshold»
`` for "fsm" | #define «yml:ucase(@name)»_THRESHOLD «@threshold»
`` for "fsm[count(state)]" | #define «yml:ucase(@name)»_THRESHOLD «@threshold»
#ifdef __cplusplus
extern "C" {
@ -338,7 +338,7 @@ tstylesheet {
||
}
document "generated/{@name}_impl.c", "text" {
if "count(fsm/state)" document "generated/{@name}_impl.c", "text" {
||
/**
* @file «@name»_impl.c
@ -354,9 +354,9 @@ tstylesheet {
#include "«yml:lcase(@name)»_codec.h"
#include "baseprotocol.h"
#include "security_checks.h"
`` for "fsm" | #include "«@name»_fsm.h"
`` for "fsm[count(state)]" | #include "«@name»_fsm.h"
`` apply "fsm", 0, mode=timeout
`` apply "fsm[count(state)]", 0, mode=timeout
PEP_STATUS «@name»_driver(
PEP_SESSION session,
«@name»_PR fsm,
@ -371,12 +371,12 @@ tstylesheet {
case None:
if (!event) {
// timeout occured
`` for "fsm" |>>>> «../@name»_driver(session, «../@name»_PR_«yml:lcase(@name)», None);
`` for "fsm[count(state)]" |>>>> «../@name»_driver(session, «../@name»_PR_«yml:lcase(@name)», None);
return PEP_STATUS_OK;
}
return PEP_ILLEGAL_VALUE;
`` apply "fsm", mode=reset_state_machine;
`` apply "fsm[count(state)]", mode=reset_state_machine;
default:
return PEP_ILLEGAL_VALUE;
}
@ -384,7 +384,7 @@ tstylesheet {
int next_state = None;
do {
switch (fsm) {
`` apply "fsm", 3, mode=driver
`` apply "fsm[count(state)]", 3, mode=driver
default:
return PEP_ILLEGAL_VALUE;
}
@ -480,7 +480,7 @@ tstylesheet {
bool is_own_key = false;
switch (fsm) {
`` apply "fsm", 2, mode=signal_message
`` apply "fsm[count(state)]", 2, mode=signal_message
default:
status = PEP_«yml:ucase(@name)»_ILLEGAL_MESSAGE;
goto the_end;
@ -540,7 +540,7 @@ tstylesheet {
time_t now = time(NULL);
switch (fsm) {
||
apply "fsm", 2, mode=send;
apply "fsm[count(state)]", 2, mode=send;
||
}
@ -586,7 +586,7 @@ tstylesheet {
switch (fsm) {
||
apply "fsm", 2, mode=send2;
apply "fsm[count(state)]", 2, mode=send2;
||
default:
break;
@ -628,8 +628,7 @@ tstylesheet {
m = _m;
break;
`` for "fsm/message[@security='untrusted' and ../@name!='KeySync']" | #error untrusted only allowed with KeySync
`` for "fsm/message[@security='untrusted' and ../@name='KeySync']" |>>> case «../@name»_PR_«yml:mixedCase(@name)»:
`` for "fsm/message[@security='untrusted']" |>>> case «../@name»_PR_«yml:mixedCase(@name)»:
// add fpr of key of comm partner
if (!session->«yml:lcase(@name)»_state.transport.sender_fpr) {
@ -1434,7 +1433,7 @@ tstylesheet {
||
template "fsm", mode=gen {
document "generated/{@name}_fsm.h", "text" {
if "count(state)" document "generated/{@name}_fsm.h", "text" {
||
/**
* @file «@name»_fsm.h
@ -1548,7 +1547,7 @@ tstylesheet {
||
}
document "generated/{@name}_fsm.c", "text" {
if "count(state)" document "generated/{@name}_fsm.c", "text" {
||
/**
* @file «@name»_fsm.c


codegen/cond_act_sync.yml2 → codegen/sync.act View File


Loading…
Cancel
Save