Browse Source

infrastructure changes for multiple protocols

IOSAD-201_from_Release_3.0
Volker Birk 10 months ago
parent
commit
df8f9734bc
5 changed files with 163 additions and 104 deletions
  1. +2
    -0
      .gitignore
  2. +3
    -3
      asn.1/Makefile
  3. +2
    -0
      codegen/cond_act_sync.yml2
  4. +135
    -101
      codegen/gen_statemachine.ysl2
  5. +21
    -0
      codegen/sync.fsm

+ 2
- 0
.gitignore View File

@ -66,11 +66,13 @@ test/src/engine_test/LocalPlayground.cc
*/*/.tags
asn.1/.generated
src/KeySync_*
src/TrustSync_*
src/Sync_*
src/sync_codec.*
src/distribution_codec.*
src/storage_codec.*
asn.1/keysync.asn1
asn.1/trustsync.asn1
asn.1/keyreset.asn1
asn.1/sync.asn1
asn.1/distribution.asn1


+ 3
- 3
asn.1/Makefile View File

@ -19,8 +19,8 @@ libasn1.a: $(ALL_OBJECTS)
%.o: %.c %.h
$(CC) $(CFLAGS) $(CPPFLAGS) $(OPTIMIZE) $(ASN1C_INC) -c $< -o $@
Sync.c: sync.asn1 keysync.asn1 pEp.asn1
$(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=auto pEp.asn1 keysync.asn1 $<
Sync.c: sync.asn1 keysync.asn1 trustsync.asn1 pEp.asn1
$(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=auto pEp.asn1 keysync.asn1 trustsync.asn1 $<
rm -f converter-sample.c
touch Sync.c
@ -35,7 +35,7 @@ Storage.c: storage.asn1 messagestorage.asn1 pEp.asn1
touch Storage.c
clean:
rm -f *.a *.o *.c *.h *.sample sync.asn1 keysync.asn1 distribution.asn1 keyreset.asn1 managedgroup.asn1 storage.asn1 messagestorage.asn1
rm -f *.a *.o *.c *.h *.sample sync.asn1 keysync.asn1 trustsync.asn1 distribution.asn1 keyreset.asn1 managedgroup.asn1 storage.asn1 messagestorage.asn1
install:


+ 2
- 0
codegen/cond_act_sync.yml2 View File

@ -368,6 +368,8 @@ action showBeingInGroup
timeout KeySync
call "show_handshake" with "type" > SYNC_NOTIFY_TIMEOUT
timeout TrustSync;
action prepareOwnKeys
||
stringlist_t *own_keys;


+ 135
- 101
codegen/gen_statemachine.ysl2 View File

@ -536,50 +536,13 @@ tstylesheet {
assert(session && fsm > None && message_type > None);
if (!(session && fsm > None && message_type > None))
return PEP_ILLEGAL_VALUE;
||
if "fsm/message[@security='ignore']" {
|
|> // ignore
|> switch (message_type) {
for "fsm/message[@security='ignore']" {
|>> case «../@name»_PR_«yml:mixedCase(@name)»:
|>>> return PEP_STATUS_OK;
}
|> }
}
if "fsm/message[@ratelimit>0]" {
||
// test if a message with a rate limit was just sent; in case drop
time_t now = time(NULL);
switch (fsm) {
||
for "fsm[message/@ratelimit>0]" {
||
case Sync_PR_«yml:lcase(@name)»:
switch (message_type) {
||
for "message[@ratelimit>0]"
||
case «../@name»_PR_«yml:mixedCase(@name)»:
if (now < session->«yml:lcase(../../@name)»_state.own.last_«../@name»_«@name» + «@ratelimit»)
return PEP_STATUS_OK;
break;
||
||
default:
break;
}
break;
||
}
apply "fsm", 2, mode=send;
||
default:
break;
}
||
}
||
«@name»_t *msg = new_«@name»_message(fsm, message_type);
if (!msg)
@ -621,70 +584,12 @@ tstylesheet {
}
}
switch (message_type) {
// these messages are being broadcasted
`` for "fsm/message[@type='broadcast']" |>> case «../@name»_PR_«yml:mixedCase(@name)»:
status = _own_identities_retrieve(session, &channels, PEP_idf_not_for_«yml:lcase(@name)»);
if (status)
goto the_end;
if (!(channels && channels->ident)) {
// status = PEP_«yml:ucase(@name)»_NO_CHANNEL;
// we don't check for having a channel, because if
// this is initial setup before having an own
// identity we're fine
goto the_end;
}
break;
// these go anycast; previously used address is sticky (unicast)
`` for "fsm/message[@type='anycast' and @security!='ignore']" |>> case «../@name»_PR_«yml:mixedCase(@name)»:
// if we have a comm_partner fixed send it there
if (session->«yml:lcase(@name)»_state.comm_partner.identity) {
pEp_identity *channel = identity_dup(session->«yml:lcase(@name)»_state.comm_partner.identity);
if (!channel) {
status = PEP_OUT_OF_MEMORY;
goto the_end;
}
channels = new_identity_list(channel);
if (!channels) {
status = PEP_OUT_OF_MEMORY;
goto the_end;
}
}
// if we can reply just do
else if (session->«yml:lcase(@name)»_state.transport.from) {
pEp_identity *channel = identity_dup(session->«yml:lcase(@name)»_state.transport.from);
if (!channel) {
status = PEP_OUT_OF_MEMORY;
goto the_end;
}
channels = new_identity_list(channel);
if (!channels) {
status = PEP_OUT_OF_MEMORY;
goto the_end;
}
}
// real anycast, send it to the first matching
else {
status = _own_identities_retrieve(session, &channels, PEP_idf_not_for_«yml:lcase(@name)»);
if (status)
goto the_end;
if (!channels)
goto the_end;
if (channels->next) {
free_identity_list(channels->next);
channels->next = NULL;
}
}
break;
switch (fsm) {
||
apply "fsm", 2, mode=send2;
||
default:
status = PEP_«yml:ucase(@name)»_ILLEGAL_MESSAGE;
goto the_end;
break;
}
for (identity_list *li = channels; li && li->ident ; li = li->next) {
@ -1113,6 +1018,7 @@ tstylesheet {
break;
}
break;
||
}
||
@ -1224,6 +1130,134 @@ tstylesheet {
apply "fsm", 0, mode=gen;
}
template "fsm", mode=send2 {
||
case Sync_PR_«yml:lcase(@name)»: {
switch (message_type) {
||
if "message[@type='broadcast']"
||
// these messages are being broadcasted
`` for "message[@type='broadcast']" |>> case «../@name»_PR_«yml:mixedCase(@name)»:
status = _own_identities_retrieve(session, &channels, PEP_idf_not_for_«yml:lcase(../@name)»);
if (status)
goto the_end;
if (!(channels && channels->ident)) {
// status = PEP_«yml:ucase(../@name)»_NO_CHANNEL;
// we don't check for having a channel, because if
// this is initial setup before having an own
// identity we're fine
goto the_end;
}
break;
||
||
// these go anycast; previously used address is sticky (unicast)
`` for "message[@type='anycast' and @security!='ignore']" |>> case «../@name»_PR_«yml:mixedCase(@name)»:
// if we have a comm_partner fixed send it there
if (session->«yml:lcase(../@name)»_state.comm_partner.identity) {
pEp_identity *channel = identity_dup(session->«yml:lcase(../@name)»_state.comm_partner.identity);
if (!channel) {
status = PEP_OUT_OF_MEMORY;
goto the_end;
}
channels = new_identity_list(channel);
if (!channels) {
status = PEP_OUT_OF_MEMORY;
goto the_end;
}
}
// if we can reply just do
else if (session->«yml:lcase(../@name)»_state.transport.from) {
pEp_identity *channel = identity_dup(session->«yml:lcase(../@name)»_state.transport.from);
if (!channel) {
status = PEP_OUT_OF_MEMORY;
goto the_end;
}
channels = new_identity_list(channel);
if (!channels) {
status = PEP_OUT_OF_MEMORY;
goto the_end;
}
}
// real anycast, send it to the first matching
else {
status = _own_identities_retrieve(session, &channels, PEP_idf_not_for_«yml:lcase(../@name)»);
if (status)
goto the_end;
if (!channels)
goto the_end;
if (channels->next) {
free_identity_list(channels->next);
channels->next = NULL;
}
}
break;
default:
status = PEP_«yml:ucase(../@name)»_ILLEGAL_MESSAGE;
goto the_end;
}
}
break;
||
}
template "fsm[message/@security='ignore' or message/@ratelimit>0]", mode=send {
||
case Sync_PR_«yml:lcase(@name)»: {
||
if "message[@security='ignore']" {
||
// ignore
switch (message_type) {
||
for "message[@security='ignore']" {
|>> case «../@name»_PR_«yml:mixedCase(@name)»:
|>>> return PEP_STATUS_OK;
}
||
default:
break;
}
||
}
if "message[@ratelimit>0]" {
||
// test if a message with a rate limit was just sent; in case drop
switch (message_type) {
||
for "message[@ratelimit>0]"
||
case «../@name»_PR_«yml:mixedCase(@name)»:
if (now < session->«yml:lcase(../../@name)»_state.own.last_«../@name»_«@name» + «@ratelimit»)
return PEP_STATUS_OK;
break;
||
if "message[@ratelimit>0]"
||
default:
break;
}
break;
||
||
default:
break;
}
||
}
}
template "fsm", mode=timeout
||
/**


+ 21
- 0
codegen/sync.fsm View File

@ -689,4 +689,25 @@ protocol Sync 1 {
field Rating rating;
}
}
fsm TrustSync 2, threshold=300 {
version 1, 0;
state InitState {
on Init {
go WaitForTrustUpdate;
}
}
state WaitForTrustUpdate {
on TrustUpdate {
}
}
message TrustUpdate 2 {
auto Version version;
field IdentityList trust;
}
}
}

Loading…
Cancel
Save