separating send actions from other actions
authorVolker Birk <vb@pep-project.org>
Thu, 14 Jul 2016 13:33:24 +0200
changeset 883096ff09932ad
parent 871 f0c1582416e3
child 884 d64d366512a0
separating send actions from other actions
src/sync_actions.c
src/sync_send_actions.c
sync/Makefile
sync/gen_actions_skeleton.ysl2
     1.1 --- a/src/sync_actions.c	Thu Jul 14 10:13:08 2016 +0200
     1.2 +++ b/src/sync_actions.c	Thu Jul 14 13:33:24 2016 +0200
     1.3 @@ -5,196 +5,6 @@
     1.4  #include "keymanagement.h"
     1.5  #include "message.h"
     1.6  #include "sync_fsm.h"
     1.7 -#include "baseprotocol.h"
     1.8 -#include "map_asn1.h"
     1.9 -#include "../asn.1/Beacon.h"
    1.10 -#include "../asn.1/HandshakeRequest.h"
    1.11 -#include "../asn.1/GroupKeys.h"
    1.12 -
    1.13 -
    1.14 -// sendBeacon() - send Beacon message
    1.15 -//
    1.16 -//  params:
    1.17 -//      session (in)        session handle
    1.18 -//      state (in)          state the state machine is in
    1.19 -//      partner (in)        (must be NULL)
    1.20 -//
    1.21 -//  returns:
    1.22 -//      PEP_STATUS_OK or any other value on error
    1.23 -
    1.24 -PEP_STATUS sendBeacon(
    1.25 -        PEP_SESSION session,
    1.26 -        DeviceState_state state,
    1.27 -        const Identity partner
    1.28 -    )
    1.29 -{
    1.30 -    PEP_STATUS status = PEP_STATUS_OK;
    1.31 -    Beacon_t *msg = NULL;
    1.32 -    char *payload = NULL;
    1.33 -    message *_message = NULL;
    1.34 -    pEp_identity *me = NULL;
    1.35 -
    1.36 -    assert(session);
    1.37 -    assert(!partner);
    1.38 -    if (!(session && !partner))
    1.39 -        return PEP_ILLEGAL_VALUE;
    1.40 -
    1.41 -    assert(session->messageToSend);
    1.42 -    if (!session->messageToSend)
    1.43 -        return PEP_SEND_FUNCTION_NOT_REGISTERED;
    1.44 -
    1.45 -    msg = (Beacon_t *) calloc(1, sizeof(Beacon_t));
    1.46 -    assert(msg);
    1.47 -    if (!msg)
    1.48 -        goto enomem;
    1.49 -
    1.50 -    int32_t seq;
    1.51 -    status = sequence_value(session, "DeviceGroup", &seq);
    1.52 -    if (status != PEP_STATUS_OK)
    1.53 -        goto error;
    1.54 -    msg->header.sequence = (long) seq;
    1.55 -
    1.56 -    msg->state = (long) state;
    1.57 -
    1.58 -    me = new_identity(NULL, NULL, NULL, NULL);
    1.59 -    if (!me)
    1.60 -        goto enomem;
    1.61 -    status = myself(session, me);
    1.62 -    if (status != PEP_STATUS_OK)
    1.63 -        goto error;
    1.64 -    if (Identity_from_Struct(me, &msg->me) == NULL)
    1.65 -        goto enomem;
    1.66 -
    1.67 -    if (asn_check_constraints(&asn_DEF_Beacon, msg, NULL, NULL)) {
    1.68 -        status = PEP_CONTRAINTS_VIOLATED;
    1.69 -        goto error;
    1.70 -    }
    1.71 -
    1.72 -    ssize_t size = uper_encode_to_new_buffer(&asn_DEF_Beacon,
    1.73 -            NULL, msg, (void **) &payload);
    1.74 -    if (size == -1) {
    1.75 -        status = PEP_CANNOT_ENCODE;
    1.76 -        goto error;
    1.77 -    }
    1.78 -
    1.79 -    status = prepare_message(me, partner, payload, size, &_message);
    1.80 -    if (status != PEP_STATUS_OK)
    1.81 -        goto error;
    1.82 -    payload = NULL;
    1.83 -
    1.84 -    free_identity(me);
    1.85 -    me = NULL;
    1.86 -
    1.87 -    status = session->messageToSend(session->sync_obj, _message);
    1.88 -
    1.89 -    free_message(_message);
    1.90 -    ASN_STRUCT_FREE(asn_DEF_Beacon, msg);
    1.91 -
    1.92 -    return status;
    1.93 -
    1.94 -enomem:
    1.95 -    status = PEP_OUT_OF_MEMORY;
    1.96 -error:
    1.97 -    ASN_STRUCT_FREE(asn_DEF_Beacon, msg);
    1.98 -    free(payload);
    1.99 -    free_message(_message);
   1.100 -    free_identity(me);
   1.101 -    return status;
   1.102 -}
   1.103 -
   1.104 -
   1.105 -// sendHandshakeRequest() - send HandshakeRequest message
   1.106 -//
   1.107 -//  params:
   1.108 -//      session (in)        session handle
   1.109 -//      state (in)          state the state machine is in
   1.110 -//      partner (in)        partner to communicate with
   1.111 -//
   1.112 -//  returns:
   1.113 -//      PEP_STATUS_OK or any other value on error
   1.114 -
   1.115 -PEP_STATUS sendHandshakeRequest(
   1.116 -        PEP_SESSION session,
   1.117 -        DeviceState_state state,
   1.118 -        const Identity partner
   1.119 -    )
   1.120 -{
   1.121 -    PEP_STATUS status = PEP_STATUS_OK;
   1.122 -    HandshakeRequest_t *msg = NULL;
   1.123 -    char *payload = NULL;
   1.124 -    message *_message = NULL;
   1.125 -    pEp_identity *me = NULL;
   1.126 -
   1.127 -    assert(session);
   1.128 -    assert(partner);
   1.129 -    if (!(session && partner))
   1.130 -        return PEP_ILLEGAL_VALUE;
   1.131 -
   1.132 -    assert(session->messageToSend);
   1.133 -    if (!session->messageToSend)
   1.134 -        return PEP_SEND_FUNCTION_NOT_REGISTERED;
   1.135 -
   1.136 -    msg = (HandshakeRequest_t *) calloc(1, sizeof(HandshakeRequest_t));
   1.137 -    assert(msg);
   1.138 -    if (!msg)
   1.139 -        goto enomem;
   1.140 -
   1.141 -    int32_t seq;
   1.142 -    status = sequence_value(session, "DeviceGroup", &seq);
   1.143 -    if (status != PEP_STATUS_OK)
   1.144 -        goto error;
   1.145 -    msg->header.sequence = (long) seq;
   1.146 -
   1.147 -    msg->state = (long) state;
   1.148 -
   1.149 -    me = new_identity(NULL, NULL, NULL, NULL);
   1.150 -    if (!me)
   1.151 -        goto enomem;
   1.152 -    status = myself(session, me);
   1.153 -    if (status != PEP_STATUS_OK)
   1.154 -        goto error;
   1.155 -    if (Identity_from_Struct(me, &msg->me) == NULL)
   1.156 -        goto enomem;
   1.157 -
   1.158 -    if (Identity_from_Struct(partner, &msg->partner) == NULL)
   1.159 -        goto enomem;
   1.160 -
   1.161 -    if (asn_check_constraints(&asn_DEF_HandshakeRequest, msg, NULL, NULL)) {
   1.162 -        status = PEP_CONTRAINTS_VIOLATED;
   1.163 -        goto error;
   1.164 -    }
   1.165 -
   1.166 -    ssize_t size = uper_encode_to_new_buffer(&asn_DEF_HandshakeRequest,
   1.167 -            NULL, msg, (void **) &payload);
   1.168 -    if (size == -1) {
   1.169 -        status = PEP_CANNOT_ENCODE;
   1.170 -        goto error;
   1.171 -    }
   1.172 -
   1.173 -    status = prepare_message(me, partner, payload, size, &_message);
   1.174 -    if (status != PEP_STATUS_OK)
   1.175 -        goto error;
   1.176 -    payload = NULL;
   1.177 -
   1.178 -    free_identity(me);
   1.179 -    me = NULL;
   1.180 -
   1.181 -    status = session->messageToSend(session->sync_obj, _message);
   1.182 -
   1.183 -    free_message(_message);
   1.184 -    ASN_STRUCT_FREE(asn_DEF_HandshakeRequest, msg);
   1.185 -
   1.186 -    return status;
   1.187 -
   1.188 -enomem:
   1.189 -    status = PEP_OUT_OF_MEMORY;
   1.190 -error:
   1.191 -    ASN_STRUCT_FREE(asn_DEF_HandshakeRequest, msg);
   1.192 -    free(payload);
   1.193 -    free_message(_message);
   1.194 -    free_identity(me);
   1.195 -    return status;
   1.196 -}
   1.197  
   1.198  
   1.199  // showHandshake() - 
   1.200 @@ -304,95 +114,3 @@
   1.201      return status;
   1.202  }
   1.203  
   1.204 -
   1.205 -// sendGroupKeys() - send GroupKeys message
   1.206 -//
   1.207 -//  params:
   1.208 -//      session (in)        session handle
   1.209 -//      state (in)          state the state machine is in
   1.210 -//      partner (in)        (must be NULL)
   1.211 -//
   1.212 -//  returns:
   1.213 -//      PEP_STATUS_OK or any other value on error
   1.214 -
   1.215 -PEP_STATUS sendGroupKeys(
   1.216 -        PEP_SESSION session,
   1.217 -        DeviceState_state state,
   1.218 -        const Identity partner
   1.219 -    )
   1.220 -{
   1.221 -    PEP_STATUS status = PEP_STATUS_OK;
   1.222 -    GroupKeys_t *msg = NULL;
   1.223 -    char *payload = NULL;
   1.224 -    message *_message = NULL;
   1.225 -    pEp_identity *me = NULL;
   1.226 -
   1.227 -    assert(session);
   1.228 -    assert(!partner);
   1.229 -    if (!(session && !partner))
   1.230 -        return PEP_ILLEGAL_VALUE;
   1.231 -
   1.232 -    assert(session->messageToSend);
   1.233 -    if (!session->messageToSend)
   1.234 -        return PEP_SEND_FUNCTION_NOT_REGISTERED;
   1.235 -
   1.236 -    msg = (GroupKeys_t *) calloc(1, sizeof(GroupKeys_t));
   1.237 -    assert(msg);
   1.238 -    if (!msg)
   1.239 -        goto enomem;
   1.240 -
   1.241 -    int32_t seq;
   1.242 -    status = sequence_value(session, "DeviceGroup", &seq);
   1.243 -    if (status != PEP_STATUS_OK)
   1.244 -        goto error;
   1.245 -    msg->header.sequence = (long) seq;
   1.246 -
   1.247 -    msg->state = (long) state;
   1.248 -
   1.249 -    me = new_identity(NULL, NULL, NULL, NULL);
   1.250 -    if (!me)
   1.251 -        goto enomem;
   1.252 -    status = myself(session, me);
   1.253 -    if (status != PEP_STATUS_OK)
   1.254 -        goto error;
   1.255 -    if (Identity_from_Struct(me, &msg->me) == NULL)
   1.256 -        goto enomem;
   1.257 -
   1.258 -    if (asn_check_constraints(&asn_DEF_GroupKeys, msg, NULL, NULL)) {
   1.259 -        status = PEP_CONTRAINTS_VIOLATED;
   1.260 -        goto error;
   1.261 -    }
   1.262 -
   1.263 -    ssize_t size = uper_encode_to_new_buffer(&asn_DEF_GroupKeys,
   1.264 -            NULL, msg, (void **) &payload);
   1.265 -    if (size == -1) {
   1.266 -        status = PEP_CANNOT_ENCODE;
   1.267 -        goto error;
   1.268 -    }
   1.269 -
   1.270 -    status = prepare_message(me, partner, payload, size, &_message);
   1.271 -    if (status != PEP_STATUS_OK)
   1.272 -        goto error;
   1.273 -    payload = NULL;
   1.274 -
   1.275 -    free_identity(me);
   1.276 -    me = NULL;
   1.277 -
   1.278 -    status = session->messageToSend(session->sync_obj, _message);
   1.279 -
   1.280 -    free_message(_message);
   1.281 -    ASN_STRUCT_FREE(asn_DEF_GroupKeys, msg);
   1.282 -
   1.283 -    return status;
   1.284 -
   1.285 -enomem:
   1.286 -    status = PEP_OUT_OF_MEMORY;
   1.287 -error:
   1.288 -    ASN_STRUCT_FREE(asn_DEF_GroupKeys, msg);
   1.289 -    free(payload);
   1.290 -    free_message(_message);
   1.291 -    free_identity(me);
   1.292 -    return status;
   1.293 -}
   1.294 -
   1.295 -
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/sync_send_actions.c	Thu Jul 14 13:33:24 2016 +0200
     2.3 @@ -0,0 +1,289 @@
     2.4 +// Send Actions for DeviceState state machine
     2.5 +
     2.6 +#include <assert.h>
     2.7 +#include "pEp_internal.h"
     2.8 +#include "keymanagement.h"
     2.9 +#include "message.h"
    2.10 +#include "sync_fsm.h"
    2.11 +#include "baseprotocol.h"
    2.12 +#include "map_asn1.h"
    2.13 +#include "../asn.1/Beacon.h"
    2.14 +#include "../asn.1/HandshakeRequest.h"
    2.15 +#include "../asn.1/GroupKeys.h"
    2.16 +
    2.17 +
    2.18 +// sendBeacon() - send Beacon message
    2.19 +//
    2.20 +//  params:
    2.21 +//      session (in)        session handle
    2.22 +//      state (in)          state the state machine is in
    2.23 +//      partner (in)        (must be NULL)
    2.24 +//
    2.25 +//  returns:
    2.26 +//      PEP_STATUS_OK or any other value on error
    2.27 +
    2.28 +PEP_STATUS sendBeacon(
    2.29 +        PEP_SESSION session,
    2.30 +        DeviceState_state state,
    2.31 +        const Identity partner
    2.32 +    )
    2.33 +{
    2.34 +    PEP_STATUS status = PEP_STATUS_OK;
    2.35 +    Beacon_t *msg = NULL;
    2.36 +    char *payload = NULL;
    2.37 +    message *_message = NULL;
    2.38 +    pEp_identity *me = NULL;
    2.39 +
    2.40 +    assert(session);
    2.41 +    assert(!partner);
    2.42 +    if (!(session && !partner))
    2.43 +        return PEP_ILLEGAL_VALUE;
    2.44 +
    2.45 +    assert(session->messageToSend);
    2.46 +    if (!session->messageToSend)
    2.47 +        return PEP_SEND_FUNCTION_NOT_REGISTERED;
    2.48 +
    2.49 +    msg = (Beacon_t *) calloc(1, sizeof(Beacon_t));
    2.50 +    assert(msg);
    2.51 +    if (!msg)
    2.52 +        goto enomem;
    2.53 +
    2.54 +    int32_t seq;
    2.55 +    status = sequence_value(session, "DeviceGroup", &seq);
    2.56 +    if (status != PEP_STATUS_OK)
    2.57 +        goto error;
    2.58 +    msg->header.sequence = (long) seq;
    2.59 +
    2.60 +    msg->state = (long) state;
    2.61 +
    2.62 +    me = new_identity(NULL, NULL, NULL, NULL);
    2.63 +    if (!me)
    2.64 +        goto enomem;
    2.65 +    status = myself(session, me);
    2.66 +    if (status != PEP_STATUS_OK)
    2.67 +        goto error;
    2.68 +    if (Identity_from_Struct(me, &msg->me) == NULL)
    2.69 +        goto enomem;
    2.70 +
    2.71 +    if (asn_check_constraints(&asn_DEF_Beacon, msg, NULL, NULL)) {
    2.72 +        status = PEP_CONTRAINTS_VIOLATED;
    2.73 +        goto error;
    2.74 +    }
    2.75 +
    2.76 +    ssize_t size = uper_encode_to_new_buffer(&asn_DEF_Beacon,
    2.77 +            NULL, msg, (void **) &payload);
    2.78 +    if (size == -1) {
    2.79 +        status = PEP_CANNOT_ENCODE;
    2.80 +        goto error;
    2.81 +    }
    2.82 +
    2.83 +    status = prepare_message(me, partner, payload, size, &_message);
    2.84 +    if (status != PEP_STATUS_OK)
    2.85 +        goto error;
    2.86 +    payload = NULL;
    2.87 +
    2.88 +    free_identity(me);
    2.89 +    me = NULL;
    2.90 +
    2.91 +    status = session->messageToSend(session->sync_obj, _message);
    2.92 +
    2.93 +    free_message(_message);
    2.94 +    ASN_STRUCT_FREE(asn_DEF_Beacon, msg);
    2.95 +
    2.96 +    return status;
    2.97 +
    2.98 +enomem:
    2.99 +    status = PEP_OUT_OF_MEMORY;
   2.100 +error:
   2.101 +    ASN_STRUCT_FREE(asn_DEF_Beacon, msg);
   2.102 +    free(payload);
   2.103 +    free_message(_message);
   2.104 +    free_identity(me);
   2.105 +    return status;
   2.106 +}
   2.107 +
   2.108 +
   2.109 +// sendHandshakeRequest() - send HandshakeRequest message
   2.110 +//
   2.111 +//  params:
   2.112 +//      session (in)        session handle
   2.113 +//      state (in)          state the state machine is in
   2.114 +//      partner (in)        partner to communicate with
   2.115 +//
   2.116 +//  returns:
   2.117 +//      PEP_STATUS_OK or any other value on error
   2.118 +
   2.119 +PEP_STATUS sendHandshakeRequest(
   2.120 +        PEP_SESSION session,
   2.121 +        DeviceState_state state,
   2.122 +        const Identity partner
   2.123 +    )
   2.124 +{
   2.125 +    PEP_STATUS status = PEP_STATUS_OK;
   2.126 +    HandshakeRequest_t *msg = NULL;
   2.127 +    char *payload = NULL;
   2.128 +    message *_message = NULL;
   2.129 +    pEp_identity *me = NULL;
   2.130 +
   2.131 +    assert(session);
   2.132 +    assert(partner);
   2.133 +    if (!(session && partner))
   2.134 +        return PEP_ILLEGAL_VALUE;
   2.135 +
   2.136 +    assert(session->messageToSend);
   2.137 +    if (!session->messageToSend)
   2.138 +        return PEP_SEND_FUNCTION_NOT_REGISTERED;
   2.139 +
   2.140 +    msg = (HandshakeRequest_t *) calloc(1, sizeof(HandshakeRequest_t));
   2.141 +    assert(msg);
   2.142 +    if (!msg)
   2.143 +        goto enomem;
   2.144 +
   2.145 +    int32_t seq;
   2.146 +    status = sequence_value(session, "DeviceGroup", &seq);
   2.147 +    if (status != PEP_STATUS_OK)
   2.148 +        goto error;
   2.149 +    msg->header.sequence = (long) seq;
   2.150 +
   2.151 +    msg->state = (long) state;
   2.152 +
   2.153 +    me = new_identity(NULL, NULL, NULL, NULL);
   2.154 +    if (!me)
   2.155 +        goto enomem;
   2.156 +    status = myself(session, me);
   2.157 +    if (status != PEP_STATUS_OK)
   2.158 +        goto error;
   2.159 +    if (Identity_from_Struct(me, &msg->me) == NULL)
   2.160 +        goto enomem;
   2.161 +
   2.162 +    if (Identity_from_Struct(partner, &msg->partner) == NULL)
   2.163 +        goto enomem;
   2.164 +
   2.165 +    if (asn_check_constraints(&asn_DEF_HandshakeRequest, msg, NULL, NULL)) {
   2.166 +        status = PEP_CONTRAINTS_VIOLATED;
   2.167 +        goto error;
   2.168 +    }
   2.169 +
   2.170 +    ssize_t size = uper_encode_to_new_buffer(&asn_DEF_HandshakeRequest,
   2.171 +            NULL, msg, (void **) &payload);
   2.172 +    if (size == -1) {
   2.173 +        status = PEP_CANNOT_ENCODE;
   2.174 +        goto error;
   2.175 +    }
   2.176 +
   2.177 +    status = prepare_message(me, partner, payload, size, &_message);
   2.178 +    if (status != PEP_STATUS_OK)
   2.179 +        goto error;
   2.180 +    payload = NULL;
   2.181 +
   2.182 +    free_identity(me);
   2.183 +    me = NULL;
   2.184 +
   2.185 +    status = session->messageToSend(session->sync_obj, _message);
   2.186 +
   2.187 +    free_message(_message);
   2.188 +    ASN_STRUCT_FREE(asn_DEF_HandshakeRequest, msg);
   2.189 +
   2.190 +    return status;
   2.191 +
   2.192 +enomem:
   2.193 +    status = PEP_OUT_OF_MEMORY;
   2.194 +error:
   2.195 +    ASN_STRUCT_FREE(asn_DEF_HandshakeRequest, msg);
   2.196 +    free(payload);
   2.197 +    free_message(_message);
   2.198 +    free_identity(me);
   2.199 +    return status;
   2.200 +}
   2.201 +
   2.202 +
   2.203 +// sendGroupKeys() - send GroupKeys message
   2.204 +//
   2.205 +//  params:
   2.206 +//      session (in)        session handle
   2.207 +//      state (in)          state the state machine is in
   2.208 +//      partner (in)        (must be NULL)
   2.209 +//
   2.210 +//  returns:
   2.211 +//      PEP_STATUS_OK or any other value on error
   2.212 +
   2.213 +PEP_STATUS sendGroupKeys(
   2.214 +        PEP_SESSION session,
   2.215 +        DeviceState_state state,
   2.216 +        const Identity partner
   2.217 +    )
   2.218 +{
   2.219 +    PEP_STATUS status = PEP_STATUS_OK;
   2.220 +    GroupKeys_t *msg = NULL;
   2.221 +    char *payload = NULL;
   2.222 +    message *_message = NULL;
   2.223 +    pEp_identity *me = NULL;
   2.224 +
   2.225 +    assert(session);
   2.226 +    assert(!partner);
   2.227 +    if (!(session && !partner))
   2.228 +        return PEP_ILLEGAL_VALUE;
   2.229 +
   2.230 +    assert(session->messageToSend);
   2.231 +    if (!session->messageToSend)
   2.232 +        return PEP_SEND_FUNCTION_NOT_REGISTERED;
   2.233 +
   2.234 +    msg = (GroupKeys_t *) calloc(1, sizeof(GroupKeys_t));
   2.235 +    assert(msg);
   2.236 +    if (!msg)
   2.237 +        goto enomem;
   2.238 +
   2.239 +    int32_t seq;
   2.240 +    status = sequence_value(session, "DeviceGroup", &seq);
   2.241 +    if (status != PEP_STATUS_OK)
   2.242 +        goto error;
   2.243 +    msg->header.sequence = (long) seq;
   2.244 +
   2.245 +    msg->state = (long) state;
   2.246 +
   2.247 +    me = new_identity(NULL, NULL, NULL, NULL);
   2.248 +    if (!me)
   2.249 +        goto enomem;
   2.250 +    status = myself(session, me);
   2.251 +    if (status != PEP_STATUS_OK)
   2.252 +        goto error;
   2.253 +    if (Identity_from_Struct(me, &msg->me) == NULL)
   2.254 +        goto enomem;
   2.255 +
   2.256 +    if (asn_check_constraints(&asn_DEF_GroupKeys, msg, NULL, NULL)) {
   2.257 +        status = PEP_CONTRAINTS_VIOLATED;
   2.258 +        goto error;
   2.259 +    }
   2.260 +
   2.261 +    ssize_t size = uper_encode_to_new_buffer(&asn_DEF_GroupKeys,
   2.262 +            NULL, msg, (void **) &payload);
   2.263 +    if (size == -1) {
   2.264 +        status = PEP_CANNOT_ENCODE;
   2.265 +        goto error;
   2.266 +    }
   2.267 +
   2.268 +    status = prepare_message(me, partner, payload, size, &_message);
   2.269 +    if (status != PEP_STATUS_OK)
   2.270 +        goto error;
   2.271 +    payload = NULL;
   2.272 +
   2.273 +    free_identity(me);
   2.274 +    me = NULL;
   2.275 +
   2.276 +    status = session->messageToSend(session->sync_obj, _message);
   2.277 +
   2.278 +    free_message(_message);
   2.279 +    ASN_STRUCT_FREE(asn_DEF_GroupKeys, msg);
   2.280 +
   2.281 +    return status;
   2.282 +
   2.283 +enomem:
   2.284 +    status = PEP_OUT_OF_MEMORY;
   2.285 +error:
   2.286 +    ASN_STRUCT_FREE(asn_DEF_GroupKeys, msg);
   2.287 +    free(payload);
   2.288 +    free_message(_message);
   2.289 +    free_identity(me);
   2.290 +    return status;
   2.291 +}
   2.292 +
     3.1 --- a/sync/Makefile	Thu Jul 14 10:13:08 2016 +0200
     3.2 +++ b/sync/Makefile	Thu Jul 14 13:33:24 2016 +0200
     3.3 @@ -1,6 +1,6 @@
     3.4  include ../Makefile.conf
     3.5  
     3.6 -all: .statemachines
     3.7 +all: .statemachines .skeletons
     3.8  
     3.9  skeleton: .skeletons
    3.10  
     4.1 --- a/sync/gen_actions_skeleton.ysl2	Thu Jul 14 10:13:08 2016 +0200
     4.2 +++ b/sync/gen_actions_skeleton.ysl2	Thu Jul 14 13:33:24 2016 +0200
     4.3 @@ -9,11 +9,16 @@
     4.4  tstylesheet {
     4.5      include ./functions.ysl2
     4.6  
     4.7 -    template "/protocol/fsm" document "../src/{@filename}_actions.c.skeleton", "text" {
     4.8 +    template "/protocol" {
     4.9 +        apply "fsm", mode=send, 0;
    4.10 +        apply "fsm", mode=other, 0;
    4.11 +    }
    4.12 +
    4.13 +    template "fsm", mode=send document "../src/{@filename}_send_actions.c", "text" {
    4.14          const "name", "@name";
    4.15          const "filename", "@filename";
    4.16          ||
    4.17 -        // Actions for «@name» state machine
    4.18 +        // Send Actions for «@name» state machine
    4.19  
    4.20          #include <assert.h>
    4.21          #include "pEp_internal.h"
    4.22 @@ -28,29 +33,32 @@
    4.23                  | #include "../asn.1/«substring(@name, 5, 255)».h"
    4.24          |
    4.25          for "func:distinctName(//action)"
    4.26 -            call "action"
    4.27 -                with "action", ".",
    4.28 -                with "fsm", "$name",
    4.29 -                with "filename", "$filename";
    4.30 -        |
    4.31 +            if "substring(@name, 1, 4) = 'send'"
    4.32 +                call "send_action"
    4.33 +                    with "action", ".",
    4.34 +                    with "fsm", "$name",
    4.35 +                    with "filename", "$filename";
    4.36      }
    4.37  
    4.38 -    function "action" {
    4.39 -        param "action";
    4.40 -        param "fsm";
    4.41 -        param "filename", "'###'";
    4.42 -        choose {
    4.43 -            when "substring($action/@name, 1, 4) = 'send'"
    4.44 -                call "send_action"
    4.45 -                    with "action", "$action",
    4.46 -                    with "fsm", "$fsm",
    4.47 +    template "fsm", mode=other document "../src/{@filename}_actions.c.skeleton", "text" {
    4.48 +        const "name", "@name";
    4.49 +        const "filename", "@filename";
    4.50 +        ||
    4.51 +        // Actions for «@name» state machine
    4.52 +
    4.53 +        #include <assert.h>
    4.54 +        #include "pEp_internal.h"
    4.55 +        #include "keymanagement.h"
    4.56 +        #include "message.h"
    4.57 +        #include "«@filename»_fsm.h"
    4.58 +
    4.59 +        ||
    4.60 +        for "func:distinctName(//action)"
    4.61 +            if "substring(@name, 1, 4) != 'send'"
    4.62 +                call "other_action"
    4.63 +                    with "action", ".",
    4.64 +                    with "fsm", "$name",
    4.65                      with "filename", "$filename";
    4.66 -            otherwise
    4.67 -                call "other_action"
    4.68 -                    with "action", "$action",
    4.69 -                    with "fsm", "$fsm",
    4.70 -                    with "filename", "$filename";
    4.71 -        }
    4.72      }
    4.73  
    4.74      function "paramcheck" {