adding some parameter check to send*() functions keysync
authorVolker Birk <vb@pep.foundation>
Tue, 23 Aug 2016 11:48:50 +0200
branchkeysync
changeset 1060fcfc07caa0f6
parent 1059 b5e275717e44
child 1061 6406a8b521e7
adding some parameter check to send*() functions
src/sync_send_actions.c
sync/gen_actions_skeleton.ysl2
     1.1 --- a/src/sync_send_actions.c	Tue Aug 23 11:42:05 2016 +0200
     1.2 +++ b/src/sync_send_actions.c	Tue Aug 23 11:48:50 2016 +0200
     1.3 @@ -31,13 +31,17 @@
     1.4          void *extra
     1.5      )
     1.6  {
     1.7 +    assert(session && state);
     1.8 +    if (!(session && state))
     1.9 +        return PEP_ILLEGAL_VALUE;
    1.10 +
    1.11      PEP_STATUS status = PEP_STATUS_OK;
    1.12  
    1.13      DeviceGroup_Protocol_t *msg = new_DeviceGroup_Protocol_msg(DeviceGroup_Protocol__payload_PR_beacon);
    1.14      if (!msg)
    1.15          goto enomem;
    1.16  
    1.17 -    status = unicast_msg(session, partner, state, msg);
    1.18 +    status = multicast_self_msg(session, state, msg);
    1.19      if (status != PEP_STATUS_OK)
    1.20          goto error;
    1.21  
    1.22 @@ -68,6 +72,10 @@
    1.23          void *extra
    1.24      )
    1.25  {
    1.26 +    assert(session && state);
    1.27 +    if (!(session && state))
    1.28 +        return PEP_ILLEGAL_VALUE;
    1.29 +
    1.30      PEP_STATUS status = PEP_STATUS_OK;
    1.31  
    1.32      DeviceGroup_Protocol_t *msg = new_DeviceGroup_Protocol_msg(DeviceGroup_Protocol__payload_PR_handshakeRequest);
    1.33 @@ -105,6 +113,10 @@
    1.34          void *extra
    1.35      )
    1.36  {
    1.37 +    assert(session && state);
    1.38 +    if (!(session && state))
    1.39 +        return PEP_ILLEGAL_VALUE;
    1.40 +
    1.41      PEP_STATUS status = PEP_STATUS_OK;
    1.42      identity_list *kl = new_identity_list(NULL);
    1.43  
     2.1 --- a/sync/gen_actions_skeleton.ysl2	Tue Aug 23 11:42:05 2016 +0200
     2.2 +++ b/sync/gen_actions_skeleton.ysl2	Tue Aug 23 11:48:50 2016 +0200
     2.3 @@ -157,6 +157,10 @@
     2.4                  void *extra
     2.5              )
     2.6          {
     2.7 +            assert(session && state);
     2.8 +            if (!(session && state))
     2.9 +                return PEP_ILLEGAL_VALUE;
    2.10 +
    2.11              PEP_STATUS status = PEP_STATUS_OK;
    2.12              `` if "$name='GroupKeys'" |> identity_list *kl = new_identity_list(NULL);
    2.13  
    2.14 @@ -176,7 +180,14 @@
    2.15          }
    2.16          ||
    2.17  
    2.18 -            status = unicast_msg(session, partner, state, msg);
    2.19 +        ||
    2.20 +        choose {
    2.21 +            when "count(/protocol/broadcast/*[name()=$action/@name]) = 0"
    2.22 +                |> status = unicast_msg(session, partner, state, msg);
    2.23 +            otherwise
    2.24 +                |> status = multicast_self_msg(session, state, msg);
    2.25 +        }
    2.26 +        ||
    2.27              if (status != PEP_STATUS_OK)
    2.28                  goto error;
    2.29