KeySync : added composit state payload to hold multiple state parameters KeySyncWaitForAccept
authorEdouard Tisserant <edouard@pep-project.org>
Mon, 20 Feb 2017 10:29:45 +0100
branchKeySyncWaitForAccept
changeset 15906e007351ccde
parent 1589 c6dbfcea6e5a
child 1595 ddf2993d75fe
KeySync : added composit state payload to hold multiple state parameters
sync/devicegroup.fsm
sync/gen_statemachine.ysl2
sync/generated/sync_fsm.c
     1.1 --- a/sync/devicegroup.fsm	Mon Feb 20 09:31:58 2017 +0100
     1.2 +++ b/sync/devicegroup.fsm	Mon Feb 20 10:29:45 2017 +0100
     1.3 @@ -95,6 +95,11 @@
     1.4                  go Sole;
     1.5              }
     1.6              on Cancel go Sole;
     1.7 +//            on GroupKeys(Identity partner, identity_list keys) {
     1.8 +//                if sameIdentities(partner, expected) {
     1.9 +//                    go WaitForAcceptSole(partner, keys);
    1.10 +//                }
    1.11 +//            }
    1.12              on Timeout {
    1.13                  do notifyTimeout(expected);
    1.14                  do sendBeacon;
    1.15 @@ -117,6 +122,28 @@
    1.16              }
    1.17          }
    1.18  
    1.19 +//        state WaitForAcceptSole timeout=600 (Identity expected, identity_list keys) {
    1.20 +//            on HandshakeRejected(Identity partner) {
    1.21 +//                do rejectHandshake(partner);
    1.22 +//                go Sole;
    1.23 +//            }
    1.24 +//            on HandshakeAccepted(Identity partner) {
    1.25 +//                if sameIdentities(partner, expected) {
    1.26 +//                    do acceptHandshake(partner); 
    1.27 +//                    do storeGroupKeys(partner, keys);
    1.28 +//                    do sendGroupUpdate;
    1.29 +//                    do notifyAcceptedDeviceAdded(partner);
    1.30 +//                    go Grouped;
    1.31 +//                }
    1.32 +//                go Sole;
    1.33 +//            }
    1.34 +//            on Cancel go Sole;
    1.35 +//            on Timeout {
    1.36 +//                do notifyTimeout(expected);
    1.37 +//                go Sole;
    1.38 +//            }
    1.39 +//        }
    1.40 +//
    1.41          state Grouped end=1 {
    1.42              on KeyGen
    1.43                  do sendGroupUpdate;
    1.44 @@ -187,6 +214,11 @@
    1.45                  go WaitForGroupKeysGrouped(partner);
    1.46              }
    1.47              on Cancel go Grouped;
    1.48 +//            on GroupKeys(Identity partner, identity_list keys) {
    1.49 +//                if sameIdentities(partner, expected) {
    1.50 +//                    go WaitForAcceptGrouped(partner, keys);
    1.51 +//                }
    1.52 +//            }
    1.53              on Timeout {
    1.54                  do notifyTimeout(expected);
    1.55                  go Grouped;
    1.56 @@ -208,6 +240,25 @@
    1.57              }
    1.58          }
    1.59  
    1.60 +//        state WaitForAcceptGrouped timeout=600 (Identity expected, identity_list keys) {
    1.61 +//            on HandshakeRejected(Identity partner) {
    1.62 +//                do rejectHandshake(partner);
    1.63 +//                go Grouped;
    1.64 +//            }
    1.65 +//            on HandshakeAccepted(Identity partner) {
    1.66 +//                do acceptHandshake(partner); 
    1.67 +//                do storeGroupKeys(partner, keys);
    1.68 +//                do sendGroupUpdate;
    1.69 +//                do notifyAcceptedDeviceMoved(partner);
    1.70 +//                go Grouped;
    1.71 +//            }
    1.72 +//            on Cancel go Grouped;
    1.73 +//            on Timeout {
    1.74 +//                do notifyTimeout(expected);
    1.75 +//                go Grouped;
    1.76 +//            }
    1.77 +//        }
    1.78 +//
    1.79          tag Init 1;
    1.80          tag Beacon 2;
    1.81          tag HandshakeRequest 3;
     2.1 --- a/sync/gen_statemachine.ysl2	Mon Feb 20 09:31:58 2017 +0100
     2.2 +++ b/sync/gen_statemachine.ysl2	Mon Feb 20 10:29:45 2017 +0100
     2.3 @@ -186,6 +186,10 @@
     2.4          #include "pEp_internal.h"
     2.5          #include "«@filename»_fsm.h"
     2.6  
     2.7 +        // local definitions for «@name»'s state machine 
     2.8 +
     2.9 +        `` apply "state", 2 mode="declStatePayload"
    2.10 +
    2.11          // state machine for «@name»
    2.12  
    2.13          «@name»_state fsm_«@name»(
    2.14 @@ -212,28 +216,59 @@
    2.15          ||
    2.16      }
    2.17  
    2.18 -    template "state"
    2.19 +    template "state" {
    2.20 +        ||
    2.21 +        case «@name»:
    2.22 +        {
    2.23 +            DEBUG_LOG("Entering FSM state", "«../@filename»_fsm.c", "state=«@name»")
    2.24 +        ||
    2.25 +
    2.26 +        if "count(parm) > 0" 
    2.27 +        || 
    2.28 +            assert(session->sync_state_payload);
    2.29 +            if(!session->sync_state_payload) return («../@name»_state) invalid_state;
    2.30 +            `` apply "parm", 1 mode="unpackStatePayloadParm" with "stateName", "@name"
    2.31 +        ||
    2.32 +
    2.33 +        ||
    2.34 +            *timeout = «@timeout»;
    2.35 +            switch (event) {
    2.36 +        ||
    2.37 +
    2.38 +        if "not(event[@name='Init'])" 
    2.39 +        ||
    2.40 +                case Init: 
    2.41 +                    DEBUG_LOG("FSM event", "«../@filename»_fsm.c, state=«@name»", "event=Init") 
    2.42 +                    break;
    2.43 +        ||
    2.44 +
    2.45 +        apply "event", 2;
    2.46 +
    2.47 +        ||
    2.48 +                default:
    2.49 +                    return («../@name»_state) invalid_event;
    2.50 +            }
    2.51 +            break;
    2.52 +        }
    2.53 +        ||
    2.54 +    }
    2.55 +
    2.56 +    template "parm" mode="unpackStatePayloadParm" 
    2.57 +    {
    2.58 +        param "stateName";
    2.59 +        | «name(*[1])» «name(*[2])» = ((«$stateName»_state_payload_t*)session->sync_state_payload)->«name(*[2])»;
    2.60 +    }
    2.61 +
    2.62 +    template "state" mode="declStatePayload" if "count(parm) > 0"
    2.63      ||
    2.64 -    case «@name»:
    2.65 -    {
    2.66 -        `` if "count(parm) > 1" error | # TODO composite state payload 
    2.67 -        `` apply "parm", 1 mode="stateParm"
    2.68 -        *timeout = «@timeout»;
    2.69 -        DEBUG_LOG("Entering FSM state", "«../@filename»_fsm.c", "state=«@name»")
    2.70 -        switch (event) {
    2.71 -        `` if "not(event[@name='Init'])" |>> case Init: DEBUG_LOG("FSM event", "«../@filename»_fsm.c, state=«@name»", "event=Init") break;
    2.72 -        `` apply "event", 2
    2.73 -            default:
    2.74 -                return («../@name»_state) invalid_event;
    2.75 -        }
    2.76 -        break;
    2.77 -    }
    2.78 +    typedef struct _«@name»_state_payload {
    2.79 +        `` apply "parm", 1 mode="declStatePayloadParm"
    2.80 +    } «@name»_state_payload_t;
    2.81 +
    2.82      ||
    2.83  
    2.84 -    template "parm" mode="stateParm" 
    2.85 -    {
    2.86 -        | «name(*[1])» «name(*[2])» = («name(*[1])»)session->sync_state_payload;
    2.87 -    }
    2.88 +    template "parm" mode="declStatePayloadParm" 
    2.89 +    | «name(*[1])» «name(*[2])»;
    2.90  
    2.91      template "event"
    2.92      ||
    2.93 @@ -293,19 +328,46 @@
    2.94  
    2.95      template "transition"{
    2.96          const "stateparm", "ancestor::state/child::parm";
    2.97 -        if "$stateparm" {
    2.98 -            | if(session->sync_state_payload){
    2.99 -            |     free_«yml:lcase(name($stateparm[1]/*))»((«name($stateparm[1]/*)»)session->sync_state_payload);
   2.100 -            |     session->sync_state_payload = NULL;
   2.101 -            | }
   2.102 +        if "count($stateparm) > 0" {
   2.103 +            ||
   2.104 +            assert(session->sync_state_payload);
   2.105 +            if(!session->sync_state_payload) return («ancestor::fsm/@name»_state) invalid_state;
   2.106 +            `` apply "$stateparm", 0 mode="freeStatePayloadParm" with "stateName", "ancestor::state/@name"
   2.107 +            free(session->sync_state_payload);
   2.108 +            session->sync_state_payload = NULL;
   2.109 +            ||
   2.110          }
   2.111 -        if "parm" {
   2.112 +        if "count(parm) > 0" {
   2.113              const "nextstatename", "@target";
   2.114              const "nextstateparm", "ancestor::fsm/child::state[@name = $nextstatename]/child::parm";
   2.115 -            | session->sync_state_payload = «yml:lcase(name($nextstateparm/*))»_dup(«name(parm/*)»);
   2.116 +            if "count(parm) != count($nextstateparm)" 
   2.117 +                error > different state parameters and transition parameters count state=«ancestor::state/@name», event=«ancestor::event/@name» target=«@target»
   2.118 +            ||
   2.119 +            session->sync_state_payload = malloc(sizeof(«$nextstatename»_state_payload_t));
   2.120 +            assert(session->sync_state_payload);
   2.121 +            if(!session->sync_state_payload) return («ancestor::fsm/@name»_state) invalid_out_of_memory;
   2.122 +            ||
   2.123 +            apply "$nextstateparm", 0 mode="dupStatePayloadParm" {
   2.124 +                with "stateName", "$nextstatename";
   2.125 +                with "transitionParms", "parm";
   2.126 +            }
   2.127          }
   2.128          | DEBUG_LOG("FSM transition", "«ancestor::fsm/@filename»_fsm.c, state=«ancestor::state/@name», event=«ancestor::event/@name»", "target=«@target»")
   2.129          | return «@target»;
   2.130      }
   2.131 +
   2.132 +    template "parm" mode="freeStatePayloadParm" 
   2.133 +    {
   2.134 +        param "stateName";
   2.135 +        | free_«yml:lcase(name(*[1]))»(((«$stateName»_state_payload_t*)session->sync_state_payload)->«name(*[2])»);
   2.136 +    }
   2.137 +
   2.138 +    template "parm" mode="dupStatePayloadParm" 
   2.139 +    {
   2.140 +        param "stateName";
   2.141 +        param "transitionParms";
   2.142 +        | ((«$stateName»_state_payload_t*)session->sync_state_payload)->«name(*[2])» =
   2.143 +        |     «yml:lcase(name(*[1]))»_dup(«name($transitionParms[position()]/*)»);
   2.144 +    }
   2.145  }
   2.146  
     3.1 --- a/sync/generated/sync_fsm.c	Mon Feb 20 09:31:58 2017 +0100
     3.2 +++ b/sync/generated/sync_fsm.c	Mon Feb 20 10:29:45 2017 +0100
     3.3 @@ -1,6 +1,33 @@
     3.4  #include "pEp_internal.h"
     3.5  #include "sync_fsm.h"
     3.6  
     3.7 +// local definitions for DeviceState's state machine 
     3.8 +
     3.9 +        typedef struct _SoleBeaconed_state_payload {
    3.10 +            Identity expected;
    3.11 +        } SoleBeaconed_state_payload_t;
    3.12 +        
    3.13 +        typedef struct _HandshakingSole_state_payload {
    3.14 +            Identity expected;
    3.15 +        } HandshakingSole_state_payload_t;
    3.16 +        
    3.17 +        typedef struct _WaitForGroupKeysSole_state_payload {
    3.18 +            Identity expected;
    3.19 +        } WaitForGroupKeysSole_state_payload_t;
    3.20 +        
    3.21 +        typedef struct _GroupedBeaconed_state_payload {
    3.22 +            Identity expected;
    3.23 +        } GroupedBeaconed_state_payload_t;
    3.24 +        
    3.25 +        typedef struct _HandshakingGrouped_state_payload {
    3.26 +            Identity expected;
    3.27 +        } HandshakingGrouped_state_payload_t;
    3.28 +        
    3.29 +        typedef struct _WaitForGroupKeysGrouped_state_payload {
    3.30 +            Identity expected;
    3.31 +        } WaitForGroupKeysGrouped_state_payload_t;
    3.32 +        
    3.33 +
    3.34  // state machine for DeviceState
    3.35  
    3.36  DeviceState_state fsm_DeviceState(
    3.37 @@ -18,8 +45,8 @@
    3.38      switch (state) {
    3.39          case InitState:
    3.40          {
    3.41 +            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=InitState")
    3.42              *timeout = 0;
    3.43 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=InitState")
    3.44              switch (event) {
    3.45                  case Init:
    3.46                  {
    3.47 @@ -46,10 +73,12 @@
    3.48          }
    3.49          case Sole:
    3.50          {
    3.51 +            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=Sole")
    3.52              *timeout = 0;
    3.53 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=Sole")
    3.54              switch (event) {
    3.55 -                case Init: DEBUG_LOG("FSM event", "sync_fsm.c, state=Sole", "event=Init") break;
    3.56 +                case Init: 
    3.57 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=Sole", "event=Init") 
    3.58 +                    break;
    3.59                  case KeyGen:
    3.60                  {
    3.61                      DEBUG_LOG("FSM event", "sync_fsm.c, state=Sole", "event=KeyGen")
    3.62 @@ -81,7 +110,11 @@
    3.63                          return (int) invalid_out_of_memory;
    3.64                      if (status != PEP_STATUS_OK)
    3.65                          return (int) invalid_action;
    3.66 -                    session->sync_state_payload = identity_dup(partner);
    3.67 +                    session->sync_state_payload = malloc(sizeof(SoleBeaconed_state_payload_t));
    3.68 +                    assert(session->sync_state_payload);
    3.69 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
    3.70 +                    ((SoleBeaconed_state_payload_t*)session->sync_state_payload)->expected =
    3.71 +                        identity_dup(partner);
    3.72                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=Sole, event=Beacon", "target=SoleBeaconed")
    3.73                      return SoleBeaconed;
    3.74                  }
    3.75 @@ -94,7 +127,11 @@
    3.76                          return (int) invalid_out_of_memory;
    3.77                      if (status != PEP_STATUS_OK)
    3.78                          return (int) invalid_action;
    3.79 -                    session->sync_state_payload = identity_dup(partner);
    3.80 +                    session->sync_state_payload = malloc(sizeof(HandshakingSole_state_payload_t));
    3.81 +                    assert(session->sync_state_payload);
    3.82 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
    3.83 +                    ((HandshakingSole_state_payload_t*)session->sync_state_payload)->expected =
    3.84 +                        identity_dup(partner);
    3.85                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=Sole, event=HandshakeRequest", "target=HandshakingSole")
    3.86                      return HandshakingSole;
    3.87                  }
    3.88 @@ -105,11 +142,15 @@
    3.89          }
    3.90          case SoleBeaconed:
    3.91          {
    3.92 -            Identity expected = (Identity)session->sync_state_payload;
    3.93 +            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=SoleBeaconed")
    3.94 +            assert(session->sync_state_payload);
    3.95 +            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
    3.96 +            Identity expected = ((SoleBeaconed_state_payload_t*)session->sync_state_payload)->expected;
    3.97              *timeout = 600;
    3.98 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=SoleBeaconed")
    3.99              switch (event) {
   3.100 -                case Init: DEBUG_LOG("FSM event", "sync_fsm.c, state=SoleBeaconed", "event=Init") break;
   3.101 +                case Init: 
   3.102 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=SoleBeaconed", "event=Init") 
   3.103 +                    break;
   3.104                  case KeyGen:
   3.105                  {
   3.106                      DEBUG_LOG("FSM event", "sync_fsm.c, state=SoleBeaconed", "event=KeyGen")
   3.107 @@ -119,10 +160,11 @@
   3.108                          return (int) invalid_out_of_memory;
   3.109                      if (status != PEP_STATUS_OK)
   3.110                          return (int) invalid_action;
   3.111 -                    if(session->sync_state_payload){
   3.112 -                        free_identity((Identity)session->sync_state_payload);
   3.113 -                        session->sync_state_payload = NULL;
   3.114 -                    }
   3.115 +                    assert(session->sync_state_payload);
   3.116 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.117 +                    free_identity(((SoleBeaconed_state_payload_t*)session->sync_state_payload)->expected);
   3.118 +                    free(session->sync_state_payload);
   3.119 +                    session->sync_state_payload = NULL;
   3.120                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=SoleBeaconed, event=KeyGen", "target=Sole")
   3.121                      return Sole;
   3.122                  }
   3.123 @@ -135,10 +177,11 @@
   3.124                          return (int) invalid_out_of_memory;
   3.125                      if (status != PEP_STATUS_OK)
   3.126                          return (int) invalid_action;
   3.127 -                    if(session->sync_state_payload){
   3.128 -                        free_identity((Identity)session->sync_state_payload);
   3.129 -                        session->sync_state_payload = NULL;
   3.130 -                    }
   3.131 +                    assert(session->sync_state_payload);
   3.132 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.133 +                    free_identity(((SoleBeaconed_state_payload_t*)session->sync_state_payload)->expected);
   3.134 +                    free(session->sync_state_payload);
   3.135 +                    session->sync_state_payload = NULL;
   3.136                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=SoleBeaconed, event=CannotDecrypt", "target=Sole")
   3.137                      return Sole;
   3.138                  }
   3.139 @@ -151,11 +194,16 @@
   3.140                          return (int) invalid_out_of_memory;
   3.141                      if (status != PEP_STATUS_OK)
   3.142                          return (int) invalid_action;
   3.143 -                    if(session->sync_state_payload){
   3.144 -                        free_identity((Identity)session->sync_state_payload);
   3.145 -                        session->sync_state_payload = NULL;
   3.146 -                    }
   3.147 -                    session->sync_state_payload = identity_dup(partner);
   3.148 +                    assert(session->sync_state_payload);
   3.149 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.150 +                    free_identity(((SoleBeaconed_state_payload_t*)session->sync_state_payload)->expected);
   3.151 +                    free(session->sync_state_payload);
   3.152 +                    session->sync_state_payload = NULL;
   3.153 +                    session->sync_state_payload = malloc(sizeof(SoleBeaconed_state_payload_t));
   3.154 +                    assert(session->sync_state_payload);
   3.155 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   3.156 +                    ((SoleBeaconed_state_payload_t*)session->sync_state_payload)->expected =
   3.157 +                        identity_dup(partner);
   3.158                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=SoleBeaconed, event=Beacon", "target=SoleBeaconed")
   3.159                      return SoleBeaconed;
   3.160                  }
   3.161 @@ -180,21 +228,27 @@
   3.162                          if (status != PEP_STATUS_OK)
   3.163                              return (int) invalid_action;
   3.164                      }
   3.165 -                    if(session->sync_state_payload){
   3.166 -                        free_identity((Identity)session->sync_state_payload);
   3.167 -                        session->sync_state_payload = NULL;
   3.168 -                    }
   3.169 -                    session->sync_state_payload = identity_dup(partner);
   3.170 +                    assert(session->sync_state_payload);
   3.171 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.172 +                    free_identity(((SoleBeaconed_state_payload_t*)session->sync_state_payload)->expected);
   3.173 +                    free(session->sync_state_payload);
   3.174 +                    session->sync_state_payload = NULL;
   3.175 +                    session->sync_state_payload = malloc(sizeof(HandshakingSole_state_payload_t));
   3.176 +                    assert(session->sync_state_payload);
   3.177 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   3.178 +                    ((HandshakingSole_state_payload_t*)session->sync_state_payload)->expected =
   3.179 +                        identity_dup(partner);
   3.180                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=SoleBeaconed, event=HandshakeRequest", "target=HandshakingSole")
   3.181                      return HandshakingSole;
   3.182                  }
   3.183                  case Timeout:
   3.184                  {
   3.185                      DEBUG_LOG("FSM event", "sync_fsm.c, state=SoleBeaconed", "event=Timeout")
   3.186 -                    if(session->sync_state_payload){
   3.187 -                        free_identity((Identity)session->sync_state_payload);
   3.188 -                        session->sync_state_payload = NULL;
   3.189 -                    }
   3.190 +                    assert(session->sync_state_payload);
   3.191 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.192 +                    free_identity(((SoleBeaconed_state_payload_t*)session->sync_state_payload)->expected);
   3.193 +                    free(session->sync_state_payload);
   3.194 +                    session->sync_state_payload = NULL;
   3.195                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=SoleBeaconed, event=Timeout", "target=Sole")
   3.196                      return Sole;
   3.197                  }
   3.198 @@ -205,9 +259,11 @@
   3.199          }
   3.200          case HandshakingSole:
   3.201          {
   3.202 -            Identity expected = (Identity)session->sync_state_payload;
   3.203 +            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=HandshakingSole")
   3.204 +            assert(session->sync_state_payload);
   3.205 +            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.206 +            Identity expected = ((HandshakingSole_state_payload_t*)session->sync_state_payload)->expected;
   3.207              *timeout = 600;
   3.208 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=HandshakingSole")
   3.209              switch (event) {
   3.210                  case Init:
   3.211                  {
   3.212 @@ -247,10 +303,11 @@
   3.213                          return (int) invalid_out_of_memory;
   3.214                      if (status != PEP_STATUS_OK)
   3.215                          return (int) invalid_action;
   3.216 -                    if(session->sync_state_payload){
   3.217 -                        free_identity((Identity)session->sync_state_payload);
   3.218 -                        session->sync_state_payload = NULL;
   3.219 -                    }
   3.220 +                    assert(session->sync_state_payload);
   3.221 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.222 +                    free_identity(((HandshakingSole_state_payload_t*)session->sync_state_payload)->expected);
   3.223 +                    free(session->sync_state_payload);
   3.224 +                    session->sync_state_payload = NULL;
   3.225                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingSole, event=HandshakeRejected", "target=Sole")
   3.226                      return Sole;
   3.227                  }
   3.228 @@ -299,35 +356,43 @@
   3.229                                  return (int) invalid_out_of_memory;
   3.230                              if (status != PEP_STATUS_OK)
   3.231                                  return (int) invalid_action;
   3.232 -                            if(session->sync_state_payload){
   3.233 -                                free_identity((Identity)session->sync_state_payload);
   3.234 -                                session->sync_state_payload = NULL;
   3.235 -                            }
   3.236 +                            assert(session->sync_state_payload);
   3.237 +                            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.238 +                            free_identity(((HandshakingSole_state_payload_t*)session->sync_state_payload)->expected);
   3.239 +                            free(session->sync_state_payload);
   3.240 +                            session->sync_state_payload = NULL;
   3.241                              DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingSole, event=HandshakeAccepted", "target=Grouped")
   3.242                              return Grouped;
   3.243                          }
   3.244 -                        if(session->sync_state_payload){
   3.245 -                            free_identity((Identity)session->sync_state_payload);
   3.246 -                            session->sync_state_payload = NULL;
   3.247 -                        }
   3.248 -                        session->sync_state_payload = identity_dup(partner);
   3.249 +                        assert(session->sync_state_payload);
   3.250 +                        if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.251 +                        free_identity(((HandshakingSole_state_payload_t*)session->sync_state_payload)->expected);
   3.252 +                        free(session->sync_state_payload);
   3.253 +                        session->sync_state_payload = NULL;
   3.254 +                        session->sync_state_payload = malloc(sizeof(WaitForGroupKeysSole_state_payload_t));
   3.255 +                        assert(session->sync_state_payload);
   3.256 +                        if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   3.257 +                        ((WaitForGroupKeysSole_state_payload_t*)session->sync_state_payload)->expected =
   3.258 +                            identity_dup(partner);
   3.259                          DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingSole, event=HandshakeAccepted", "target=WaitForGroupKeysSole")
   3.260                          return WaitForGroupKeysSole;
   3.261                      }
   3.262 -                    if(session->sync_state_payload){
   3.263 -                        free_identity((Identity)session->sync_state_payload);
   3.264 -                        session->sync_state_payload = NULL;
   3.265 -                    }
   3.266 +                    assert(session->sync_state_payload);
   3.267 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.268 +                    free_identity(((HandshakingSole_state_payload_t*)session->sync_state_payload)->expected);
   3.269 +                    free(session->sync_state_payload);
   3.270 +                    session->sync_state_payload = NULL;
   3.271                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingSole, event=HandshakeAccepted", "target=Sole")
   3.272                      return Sole;
   3.273                  }
   3.274                  case Cancel:
   3.275                  {
   3.276                      DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingSole", "event=Cancel")
   3.277 -                    if(session->sync_state_payload){
   3.278 -                        free_identity((Identity)session->sync_state_payload);
   3.279 -                        session->sync_state_payload = NULL;
   3.280 -                    }
   3.281 +                    assert(session->sync_state_payload);
   3.282 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.283 +                    free_identity(((HandshakingSole_state_payload_t*)session->sync_state_payload)->expected);
   3.284 +                    free(session->sync_state_payload);
   3.285 +                    session->sync_state_payload = NULL;
   3.286                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingSole, event=Cancel", "target=Sole")
   3.287                      return Sole;
   3.288                  }
   3.289 @@ -346,10 +411,11 @@
   3.290                          return (int) invalid_out_of_memory;
   3.291                      if (status != PEP_STATUS_OK)
   3.292                          return (int) invalid_action;
   3.293 -                    if(session->sync_state_payload){
   3.294 -                        free_identity((Identity)session->sync_state_payload);
   3.295 -                        session->sync_state_payload = NULL;
   3.296 -                    }
   3.297 +                    assert(session->sync_state_payload);
   3.298 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.299 +                    free_identity(((HandshakingSole_state_payload_t*)session->sync_state_payload)->expected);
   3.300 +                    free(session->sync_state_payload);
   3.301 +                    session->sync_state_payload = NULL;
   3.302                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingSole, event=Timeout", "target=Sole")
   3.303                      return Sole;
   3.304                  }
   3.305 @@ -360,11 +426,15 @@
   3.306          }
   3.307          case WaitForGroupKeysSole:
   3.308          {
   3.309 -            Identity expected = (Identity)session->sync_state_payload;
   3.310 +            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=WaitForGroupKeysSole")
   3.311 +            assert(session->sync_state_payload);
   3.312 +            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.313 +            Identity expected = ((WaitForGroupKeysSole_state_payload_t*)session->sync_state_payload)->expected;
   3.314              *timeout = 600;
   3.315 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=WaitForGroupKeysSole")
   3.316              switch (event) {
   3.317 -                case Init: DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysSole", "event=Init") break;
   3.318 +                case Init: 
   3.319 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysSole", "event=Init") 
   3.320 +                    break;
   3.321                  case GroupKeys:
   3.322                  {
   3.323                      DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysSole", "event=GroupKeys")
   3.324 @@ -395,10 +465,11 @@
   3.325                              return (int) invalid_out_of_memory;
   3.326                          if (status != PEP_STATUS_OK)
   3.327                              return (int) invalid_action;
   3.328 -                        if(session->sync_state_payload){
   3.329 -                            free_identity((Identity)session->sync_state_payload);
   3.330 -                            session->sync_state_payload = NULL;
   3.331 -                        }
   3.332 +                        assert(session->sync_state_payload);
   3.333 +                        if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.334 +                        free_identity(((WaitForGroupKeysSole_state_payload_t*)session->sync_state_payload)->expected);
   3.335 +                        free(session->sync_state_payload);
   3.336 +                        session->sync_state_payload = NULL;
   3.337                          DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForGroupKeysSole, event=GroupKeys", "target=Grouped")
   3.338                          return Grouped;
   3.339                      }
   3.340 @@ -413,10 +484,11 @@
   3.341                          return (int) invalid_out_of_memory;
   3.342                      if (status != PEP_STATUS_OK)
   3.343                          return (int) invalid_action;
   3.344 -                    if(session->sync_state_payload){
   3.345 -                        free_identity((Identity)session->sync_state_payload);
   3.346 -                        session->sync_state_payload = NULL;
   3.347 -                    }
   3.348 +                    assert(session->sync_state_payload);
   3.349 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.350 +                    free_identity(((WaitForGroupKeysSole_state_payload_t*)session->sync_state_payload)->expected);
   3.351 +                    free(session->sync_state_payload);
   3.352 +                    session->sync_state_payload = NULL;
   3.353                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForGroupKeysSole, event=Timeout", "target=Sole")
   3.354                      return Sole;
   3.355                  }
   3.356 @@ -427,10 +499,12 @@
   3.357          }
   3.358          case Grouped:
   3.359          {
   3.360 +            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=Grouped")
   3.361              *timeout = 0;
   3.362 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=Grouped")
   3.363              switch (event) {
   3.364 -                case Init: DEBUG_LOG("FSM event", "sync_fsm.c, state=Grouped", "event=Init") break;
   3.365 +                case Init: 
   3.366 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=Grouped", "event=Init") 
   3.367 +                    break;
   3.368                  case KeyGen:
   3.369                  {
   3.370                      DEBUG_LOG("FSM event", "sync_fsm.c, state=Grouped", "event=KeyGen")
   3.371 @@ -479,7 +553,11 @@
   3.372                          return (int) invalid_out_of_memory;
   3.373                      if (status != PEP_STATUS_OK)
   3.374                          return (int) invalid_action;
   3.375 -                    session->sync_state_payload = identity_dup(partner);
   3.376 +                    session->sync_state_payload = malloc(sizeof(GroupedBeaconed_state_payload_t));
   3.377 +                    assert(session->sync_state_payload);
   3.378 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   3.379 +                    ((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected =
   3.380 +                        identity_dup(partner);
   3.381                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=Grouped, event=Beacon", "target=GroupedBeaconed")
   3.382                      return GroupedBeaconed;
   3.383                  }
   3.384 @@ -492,7 +570,11 @@
   3.385                          return (int) invalid_out_of_memory;
   3.386                      if (status != PEP_STATUS_OK)
   3.387                          return (int) invalid_action;
   3.388 -                    session->sync_state_payload = identity_dup(partner);
   3.389 +                    session->sync_state_payload = malloc(sizeof(HandshakingGrouped_state_payload_t));
   3.390 +                    assert(session->sync_state_payload);
   3.391 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   3.392 +                    ((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected =
   3.393 +                        identity_dup(partner);
   3.394                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=Grouped, event=HandshakeRequest", "target=HandshakingGrouped")
   3.395                      return HandshakingGrouped;
   3.396                  }
   3.397 @@ -514,11 +596,15 @@
   3.398          }
   3.399          case GroupedBeaconed:
   3.400          {
   3.401 -            Identity expected = (Identity)session->sync_state_payload;
   3.402 +            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=GroupedBeaconed")
   3.403 +            assert(session->sync_state_payload);
   3.404 +            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.405 +            Identity expected = ((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected;
   3.406              *timeout = 600;
   3.407 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=GroupedBeaconed")
   3.408              switch (event) {
   3.409 -                case Init: DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=Init") break;
   3.410 +                case Init: 
   3.411 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=Init") 
   3.412 +                    break;
   3.413                  case KeyGen:
   3.414                  {
   3.415                      DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=KeyGen")
   3.416 @@ -567,11 +653,16 @@
   3.417                          return (int) invalid_out_of_memory;
   3.418                      if (status != PEP_STATUS_OK)
   3.419                          return (int) invalid_action;
   3.420 -                    if(session->sync_state_payload){
   3.421 -                        free_identity((Identity)session->sync_state_payload);
   3.422 -                        session->sync_state_payload = NULL;
   3.423 -                    }
   3.424 -                    session->sync_state_payload = identity_dup(partner);
   3.425 +                    assert(session->sync_state_payload);
   3.426 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.427 +                    free_identity(((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected);
   3.428 +                    free(session->sync_state_payload);
   3.429 +                    session->sync_state_payload = NULL;
   3.430 +                    session->sync_state_payload = malloc(sizeof(GroupedBeaconed_state_payload_t));
   3.431 +                    assert(session->sync_state_payload);
   3.432 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   3.433 +                    ((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected =
   3.434 +                        identity_dup(partner);
   3.435                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=GroupedBeaconed, event=Beacon", "target=GroupedBeaconed")
   3.436                      return GroupedBeaconed;
   3.437                  }
   3.438 @@ -596,11 +687,16 @@
   3.439                          if (status != PEP_STATUS_OK)
   3.440                              return (int) invalid_action;
   3.441                      }
   3.442 -                    if(session->sync_state_payload){
   3.443 -                        free_identity((Identity)session->sync_state_payload);
   3.444 -                        session->sync_state_payload = NULL;
   3.445 -                    }
   3.446 -                    session->sync_state_payload = identity_dup(partner);
   3.447 +                    assert(session->sync_state_payload);
   3.448 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.449 +                    free_identity(((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected);
   3.450 +                    free(session->sync_state_payload);
   3.451 +                    session->sync_state_payload = NULL;
   3.452 +                    session->sync_state_payload = malloc(sizeof(HandshakingGrouped_state_payload_t));
   3.453 +                    assert(session->sync_state_payload);
   3.454 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   3.455 +                    ((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected =
   3.456 +                        identity_dup(partner);
   3.457                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=GroupedBeaconed, event=HandshakeRequest", "target=HandshakingGrouped")
   3.458                      return HandshakingGrouped;
   3.459                  }
   3.460 @@ -618,10 +714,11 @@
   3.461                  case Timeout:
   3.462                  {
   3.463                      DEBUG_LOG("FSM event", "sync_fsm.c, state=GroupedBeaconed", "event=Timeout")
   3.464 -                    if(session->sync_state_payload){
   3.465 -                        free_identity((Identity)session->sync_state_payload);
   3.466 -                        session->sync_state_payload = NULL;
   3.467 -                    }
   3.468 +                    assert(session->sync_state_payload);
   3.469 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.470 +                    free_identity(((GroupedBeaconed_state_payload_t*)session->sync_state_payload)->expected);
   3.471 +                    free(session->sync_state_payload);
   3.472 +                    session->sync_state_payload = NULL;
   3.473                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=GroupedBeaconed, event=Timeout", "target=Grouped")
   3.474                      return Grouped;
   3.475                  }
   3.476 @@ -632,9 +729,11 @@
   3.477          }
   3.478          case HandshakingGrouped:
   3.479          {
   3.480 -            Identity expected = (Identity)session->sync_state_payload;
   3.481 +            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=HandshakingGrouped")
   3.482 +            assert(session->sync_state_payload);
   3.483 +            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.484 +            Identity expected = ((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected;
   3.485              *timeout = 600;
   3.486 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=HandshakingGrouped")
   3.487              switch (event) {
   3.488                  case Init:
   3.489                  {
   3.490 @@ -674,10 +773,11 @@
   3.491                          return (int) invalid_out_of_memory;
   3.492                      if (status != PEP_STATUS_OK)
   3.493                          return (int) invalid_action;
   3.494 -                    if(session->sync_state_payload){
   3.495 -                        free_identity((Identity)session->sync_state_payload);
   3.496 -                        session->sync_state_payload = NULL;
   3.497 -                    }
   3.498 +                    assert(session->sync_state_payload);
   3.499 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.500 +                    free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   3.501 +                    free(session->sync_state_payload);
   3.502 +                    session->sync_state_payload = NULL;
   3.503                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeRejected", "target=Grouped")
   3.504                      return Grouped;
   3.505                  }
   3.506 @@ -711,28 +811,35 @@
   3.507                              return (int) invalid_out_of_memory;
   3.508                          if (status != PEP_STATUS_OK)
   3.509                              return (int) invalid_action;
   3.510 -                        if(session->sync_state_payload){
   3.511 -                            free_identity((Identity)session->sync_state_payload);
   3.512 -                            session->sync_state_payload = NULL;
   3.513 -                        }
   3.514 +                        assert(session->sync_state_payload);
   3.515 +                        if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.516 +                        free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   3.517 +                        free(session->sync_state_payload);
   3.518 +                        session->sync_state_payload = NULL;
   3.519                          DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeAccepted", "target=Grouped")
   3.520                          return Grouped;
   3.521                      }
   3.522 -                    if(session->sync_state_payload){
   3.523 -                        free_identity((Identity)session->sync_state_payload);
   3.524 -                        session->sync_state_payload = NULL;
   3.525 -                    }
   3.526 -                    session->sync_state_payload = identity_dup(partner);
   3.527 +                    assert(session->sync_state_payload);
   3.528 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.529 +                    free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   3.530 +                    free(session->sync_state_payload);
   3.531 +                    session->sync_state_payload = NULL;
   3.532 +                    session->sync_state_payload = malloc(sizeof(WaitForGroupKeysGrouped_state_payload_t));
   3.533 +                    assert(session->sync_state_payload);
   3.534 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_out_of_memory;
   3.535 +                    ((WaitForGroupKeysGrouped_state_payload_t*)session->sync_state_payload)->expected =
   3.536 +                        identity_dup(partner);
   3.537                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=HandshakeAccepted", "target=WaitForGroupKeysGrouped")
   3.538                      return WaitForGroupKeysGrouped;
   3.539                  }
   3.540                  case Cancel:
   3.541                  {
   3.542                      DEBUG_LOG("FSM event", "sync_fsm.c, state=HandshakingGrouped", "event=Cancel")
   3.543 -                    if(session->sync_state_payload){
   3.544 -                        free_identity((Identity)session->sync_state_payload);
   3.545 -                        session->sync_state_payload = NULL;
   3.546 -                    }
   3.547 +                    assert(session->sync_state_payload);
   3.548 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.549 +                    free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   3.550 +                    free(session->sync_state_payload);
   3.551 +                    session->sync_state_payload = NULL;
   3.552                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=Cancel", "target=Grouped")
   3.553                      return Grouped;
   3.554                  }
   3.555 @@ -745,10 +852,11 @@
   3.556                          return (int) invalid_out_of_memory;
   3.557                      if (status != PEP_STATUS_OK)
   3.558                          return (int) invalid_action;
   3.559 -                    if(session->sync_state_payload){
   3.560 -                        free_identity((Identity)session->sync_state_payload);
   3.561 -                        session->sync_state_payload = NULL;
   3.562 -                    }
   3.563 +                    assert(session->sync_state_payload);
   3.564 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.565 +                    free_identity(((HandshakingGrouped_state_payload_t*)session->sync_state_payload)->expected);
   3.566 +                    free(session->sync_state_payload);
   3.567 +                    session->sync_state_payload = NULL;
   3.568                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=HandshakingGrouped, event=Timeout", "target=Grouped")
   3.569                      return Grouped;
   3.570                  }
   3.571 @@ -759,11 +867,15 @@
   3.572          }
   3.573          case WaitForGroupKeysGrouped:
   3.574          {
   3.575 -            Identity expected = (Identity)session->sync_state_payload;
   3.576 +            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=WaitForGroupKeysGrouped")
   3.577 +            assert(session->sync_state_payload);
   3.578 +            if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.579 +            Identity expected = ((WaitForGroupKeysGrouped_state_payload_t*)session->sync_state_payload)->expected;
   3.580              *timeout = 600;
   3.581 -            DEBUG_LOG("Entering FSM state", "sync_fsm.c", "state=WaitForGroupKeysGrouped")
   3.582              switch (event) {
   3.583 -                case Init: DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysGrouped", "event=Init") break;
   3.584 +                case Init: 
   3.585 +                    DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysGrouped", "event=Init") 
   3.586 +                    break;
   3.587                  case GroupKeys:
   3.588                  {
   3.589                      DEBUG_LOG("FSM event", "sync_fsm.c, state=WaitForGroupKeysGrouped", "event=GroupKeys")
   3.590 @@ -794,10 +906,11 @@
   3.591                              return (int) invalid_out_of_memory;
   3.592                          if (status != PEP_STATUS_OK)
   3.593                              return (int) invalid_action;
   3.594 -                        if(session->sync_state_payload){
   3.595 -                            free_identity((Identity)session->sync_state_payload);
   3.596 -                            session->sync_state_payload = NULL;
   3.597 -                        }
   3.598 +                        assert(session->sync_state_payload);
   3.599 +                        if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.600 +                        free_identity(((WaitForGroupKeysGrouped_state_payload_t*)session->sync_state_payload)->expected);
   3.601 +                        free(session->sync_state_payload);
   3.602 +                        session->sync_state_payload = NULL;
   3.603                          DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=GroupKeys", "target=Grouped")
   3.604                          return Grouped;
   3.605                      }
   3.606 @@ -812,10 +925,11 @@
   3.607                          return (int) invalid_out_of_memory;
   3.608                      if (status != PEP_STATUS_OK)
   3.609                          return (int) invalid_action;
   3.610 -                    if(session->sync_state_payload){
   3.611 -                        free_identity((Identity)session->sync_state_payload);
   3.612 -                        session->sync_state_payload = NULL;
   3.613 -                    }
   3.614 +                    assert(session->sync_state_payload);
   3.615 +                    if(!session->sync_state_payload) return (DeviceState_state) invalid_state;
   3.616 +                    free_identity(((WaitForGroupKeysGrouped_state_payload_t*)session->sync_state_payload)->expected);
   3.617 +                    free(session->sync_state_payload);
   3.618 +                    session->sync_state_payload = NULL;
   3.619                      DEBUG_LOG("FSM transition", "sync_fsm.c, state=WaitForGroupKeysGrouped, event=Timeout", "target=Grouped")
   3.620                      return Grouped;
   3.621                  }