... sync
authorVolker Birk <vb@pep.foundation>
Thu, 16 Aug 2018 23:17:34 +0200
branchsync
changeset 2854f4728cd6a9b8
parent 2853 f5f2abf9adcf
child 2855 4db88ce549ee
...
src/sync_impl.c
sync/gen_message_func.ysl2
sync/gen_statemachine.ysl2
sync/sync.fsm
     1.1 --- a/src/sync_impl.c	Thu Aug 16 17:13:19 2018 +0200
     1.2 +++ b/src/sync_impl.c	Thu Aug 16 23:17:34 2018 +0200
     1.3 @@ -69,7 +69,7 @@
     1.4              goto error;
     1.5          }
     1.6  
     1.7 -        status = update_Sync_message(session, fsm, event, msg);
     1.8 +        status = update_Sync_message(session, msg);
     1.9          if (status)
    1.10              goto error;
    1.11      }
    1.12 @@ -120,7 +120,7 @@
    1.13          goto error;
    1.14      }
    1.15  
    1.16 -    status = update_Sync_message(session, fsm, message_type, msg);
    1.17 +    status = update_Sync_message(session, msg);
    1.18      if (status)
    1.19          goto error;
    1.20  
    1.21 @@ -145,14 +145,14 @@
    1.22      if (!(session && fsm > None && message_type > None))
    1.23          return PEP_ILLEGAL_VALUE;
    1.24      
    1.25 -    Sync_t *msg = new_Sync_message(None, None);
    1.26 +    Sync_t *msg = new_Sync_message(fsm, message_type);
    1.27      if (!msg)
    1.28          return PEP_OUT_OF_MEMORY;
    1.29  
    1.30      char *data = NULL;
    1.31      message *m = NULL;
    1.32  
    1.33 -    status = update_Sync_message(session, fsm, message_type, msg);
    1.34 +    status = update_Sync_message(session, msg);
    1.35      if (status)
    1.36          goto the_end;
    1.37  
     2.1 --- a/sync/gen_message_func.ysl2	Thu Aug 16 17:13:19 2018 +0200
     2.2 +++ b/sync/gen_message_func.ysl2	Thu Aug 16 23:17:34 2018 +0200
     2.3 @@ -60,8 +60,7 @@
     2.4  PEP_STATUS update_«@name»_state(PEP_SESSION session, «@name»_t *msg,
     2.5          «@name»_PR *fsm, int *message_type);
     2.6  
     2.7 -PEP_STATUS update_«@name»_message(PEP_SESSION session, «@name»_PR fsm,
     2.8 -        int message_type, «@name»_t *msg);
     2.9 +PEP_STATUS update_«@name»_message(PEP_SESSION session, «@name»_t *msg);
    2.10  
    2.11  #ifdef __cplusplus
    2.12  }
    2.13 @@ -160,8 +159,7 @@
    2.14      return PEP_STATUS_OK;
    2.15  }
    2.16  
    2.17 -PEP_STATUS update_«@name»_message(PEP_SESSION session, «@name»_PR fsm,
    2.18 -        int message_type, «@name»_t *msg)
    2.19 +PEP_STATUS update_«@name»_message(PEP_SESSION session, «@name»_t *msg)
    2.20  {
    2.21      int result = 0;
    2.22  
    2.23 @@ -169,6 +167,7 @@
    2.24      if (!(session && msg))
    2.25          return PEP_ILLEGAL_VALUE;
    2.26  
    2.27 +    int fsm = msg->present;
    2.28      switch (fsm) {
    2.29          case «@name»_PR_NOTHING:
    2.30              return PEP_ILLEGAL_VALUE;
    2.31 @@ -187,16 +186,18 @@
    2.32  template "fsm", mode=update_message
    2.33  ||
    2.34  case «../@name»_PR_«yml:lcase(@name)»:
    2.35 -    switch (message_type) {
    2.36 -        case «@name»__payload_PR_NOTHING:
    2.37 -            return PEP_ILLEGAL_VALUE;
    2.38 +    {
    2.39 +        int message_type = msg->choice.«yml:lcase(@name)».payload.present;
    2.40 +        switch (message_type) {
    2.41 +            case «@name»__payload_PR_NOTHING:
    2.42 +                return PEP_ILLEGAL_VALUE;
    2.43  
    2.44 -        `` apply "message", 2, mode=update_message
    2.45 -        default:
    2.46 -            return PEP_ILLEGAL_VALUE;
    2.47 +            `` apply "message", 2, mode=update_message
    2.48 +            default:
    2.49 +                return PEP_ILLEGAL_VALUE;
    2.50 +        }
    2.51 +        break;
    2.52      }
    2.53 -    break;
    2.54 -
    2.55  ||
    2.56  
    2.57  template "message", mode=update_message {
     3.1 --- a/sync/gen_statemachine.ysl2	Thu Aug 16 17:13:19 2018 +0200
     3.2 +++ b/sync/gen_statemachine.ysl2	Thu Aug 16 23:17:34 2018 +0200
     3.3 @@ -254,7 +254,7 @@
     3.4                      goto error;
     3.5                  }
     3.6  
     3.7 -                status = update_«@name»_message(session, fsm, event, msg);
     3.8 +                status = update_«@name»_message(session, msg);
     3.9                  if (status)
    3.10                      goto error;
    3.11              }
    3.12 @@ -305,7 +305,7 @@
    3.13                  goto error;
    3.14              }
    3.15  
    3.16 -            status = update_«@name»_message(session, fsm, message_type, msg);
    3.17 +            status = update_«@name»_message(session, msg);
    3.18              if (status)
    3.19                  goto error;
    3.20  
    3.21 @@ -330,14 +330,14 @@
    3.22              if (!(session && fsm > None && message_type > None))
    3.23                  return PEP_ILLEGAL_VALUE;
    3.24              
    3.25 -            «@name»_t *msg = new_«@name»_message(None, None);
    3.26 +            «@name»_t *msg = new_«@name»_message(fsm, message_type);
    3.27              if (!msg)
    3.28                  return PEP_OUT_OF_MEMORY;
    3.29  
    3.30              char *data = NULL;
    3.31              message *m = NULL;
    3.32  
    3.33 -            status = update_«@name»_message(session, fsm, message_type, msg);
    3.34 +            status = update_«@name»_message(session, msg);
    3.35              if (status)
    3.36                  goto the_end;
    3.37  
    3.38 @@ -688,7 +688,7 @@
    3.39                  ||
    3.40  
    3.41                  «$fsm/@name»_SERVICE_LOG("send message", "«$name»");
    3.42 -                status = send_«$protocol/@name»_message(session, «$fsm/@id», «$name»);
    3.43 +                status = send_«$protocol/@name»_message(session, «$fsm/@id», «$fsm/@name»__payload_PR_«yml:mixedCase($name)»);
    3.44                  ||
    3.45              }
    3.46              otherwise
     4.1 --- a/sync/sync.fsm	Thu Aug 16 17:13:19 2018 +0200
     4.2 +++ b/sync/sync.fsm	Thu Aug 16 23:17:34 2018 +0200
     4.3 @@ -23,7 +23,6 @@
     4.4              on Init {
     4.5                  if deviceGrouped
     4.6                      go Grouped;
     4.7 -                do sendBeacon;
     4.8                  go Sole;
     4.9              }
    4.10          }
    4.11 @@ -32,6 +31,7 @@
    4.12              on Init {
    4.13                  do closeHandshakeDialog;
    4.14                  do openChallenge; // own challenge
    4.15 +                do sendBeacon;
    4.16              }
    4.17  
    4.18              on KeyGen