adding keyreset to base protocol sync
authorVolker Birk <vb@pep-project.org>
Sat, 14 Dec 2019 12:40:12 +0100
branchsync
changeset 42807ee3366b3743
parent 4279 1f9a55b8a012
child 4281 342ba676caef
adding keyreset to base protocol
src/baseprotocol.c
src/baseprotocol.h
src/message_api.c
sync/gen_statemachine.ysl2
     1.1 --- a/src/baseprotocol.c	Sat Dec 14 12:10:01 2019 +0100
     1.2 +++ b/src/baseprotocol.c	Sat Dec 14 12:40:12 2019 +0100
     1.3 @@ -3,10 +3,12 @@
     1.4  
     1.5  #include "pEp_internal.h"
     1.6  #include "message_api.h"
     1.7 +#include "baseprotocol.h"
     1.8  
     1.9  PEP_STATUS base_decorate_message(
    1.10          PEP_SESSION session,
    1.11          message *msg,
    1.12 +        base_protocol_type type,
    1.13          char *payload,
    1.14          size_t size,
    1.15          const char *fpr
    1.16 @@ -57,6 +59,7 @@
    1.17          PEP_SESSION session,
    1.18          const pEp_identity *me,
    1.19          const pEp_identity *partner,
    1.20 +        base_protocol_type type,
    1.21          char *payload,
    1.22          size_t size,
    1.23          const char *fpr,
    1.24 @@ -102,7 +105,7 @@
    1.25      if (!msg->longmsg)
    1.26          goto enomem;
    1.27  
    1.28 -    status = base_decorate_message(session, msg, payload, size, fpr);
    1.29 +    status = base_decorate_message(session, msg, type, payload, size, fpr);
    1.30      if (status == PEP_STATUS_OK)
    1.31          *result = msg;
    1.32      return status;
    1.33 @@ -115,6 +118,7 @@
    1.34  PEP_STATUS base_extract_message(
    1.35          PEP_SESSION session,
    1.36          message *msg,
    1.37 +        base_protocol_type type,
    1.38          size_t *size,
    1.39          const char **payload,
    1.40          char **fpr
     2.1 --- a/src/baseprotocol.h	Sat Dec 14 12:10:01 2019 +0100
     2.2 +++ b/src/baseprotocol.h	Sat Dec 14 12:40:12 2019 +0100
     2.3 @@ -10,11 +10,20 @@
     2.4  #endif
     2.5  
     2.6  
     2.7 +typedef enum _base_protocol_type {
     2.8 +    BASE_UNKNOWN = 0,
     2.9 +
    2.10 +    BASE_SYNC = 1,
    2.11 +    BASE_KEYRESET = 2
    2.12 +} base_protocol_type;
    2.13 +
    2.14 +
    2.15  // base_decorate_message() - decorate a message with payload
    2.16  //
    2.17  //  parameters:
    2.18  //      session (in)    session handle
    2.19  //      msg (inout)     message to decorate
    2.20 +//      type (in)       base protocol type
    2.21  //      payload (in)    payload to send
    2.22  //      size (in)       size of payload
    2.23  //      fpr (in)        optional key to sign or NULL
    2.24 @@ -29,6 +38,7 @@
    2.25  PEP_STATUS base_decorate_message(
    2.26          PEP_SESSION session,
    2.27          message *msg,
    2.28 +        base_protocol_type type,
    2.29          char *payload,
    2.30          size_t size,
    2.31          const char *fpr
    2.32 @@ -41,6 +51,7 @@
    2.33  //      session (in)    session handle
    2.34  //      me (in)         identity to use for the sender
    2.35  //      partner (in)    identity to use for the receiver
    2.36 +//      type (in)       base protocol type
    2.37  //      payload (in)    payload to send
    2.38  //      size (in)       size of payload
    2.39  //      fpr (in)        optional key to sign or NULL
    2.40 @@ -57,6 +68,7 @@
    2.41          PEP_SESSION session,
    2.42          const pEp_identity *me,
    2.43          const pEp_identity *partner,
    2.44 +        base_protocol_type type,
    2.45          char *payload,
    2.46          size_t size,
    2.47          const char *fpr,
    2.48 @@ -69,6 +81,7 @@
    2.49  //  parameters:
    2.50  //      session (in)    session handle
    2.51  //      msg (in)        message to analyze
    2.52 +//      type (in)       base protocol type to extract
    2.53  //      size (out)      size of extracted payload or 0 if not found
    2.54  //      payload (out)   extraced payload
    2.55  //      fpr (out)       if message was correctly signed then fpr of signature's
    2.56 @@ -86,6 +99,7 @@
    2.57  PEP_STATUS base_extract_message(
    2.58          PEP_SESSION session,
    2.59          message *msg,
    2.60 +        base_protocol_type type,
    2.61          size_t *size,
    2.62          const char **payload,
    2.63          char **fpr
     3.1 --- a/src/message_api.c	Sat Dec 14 12:10:01 2019 +0100
     3.2 +++ b/src/message_api.c	Sat Dec 14 12:40:12 2019 +0100
     3.3 @@ -4090,7 +4090,7 @@
     3.4          size_t size;
     3.5          const char *data;
     3.6          char *sender_fpr = NULL;
     3.7 -        PEP_STATUS tmpstatus = base_extract_message(session, msg, &size, &data, &sender_fpr);
     3.8 +        PEP_STATUS tmpstatus = base_extract_message(session, msg, BASE_SYNC, &size, &data, &sender_fpr);
     3.9          if (!tmpstatus && size && data) {
    3.10              if (sender_fpr)
    3.11                  signal_Sync_message(session, *rating, data, size, msg->from, sender_fpr);
     4.1 --- a/sync/gen_statemachine.ysl2	Sat Dec 14 12:10:01 2019 +0100
     4.2 +++ b/sync/gen_statemachine.ysl2	Sat Dec 14 12:40:12 2019 +0100
     4.3 @@ -510,6 +510,7 @@
     4.4                                      session,
     4.5                                      li->ident,
     4.6                                      li->ident,
     4.7 +                                    BASE_SYNC,
     4.8                                      _data,
     4.9                                      size,
    4.10                                      li->ident->fpr,
    4.11 @@ -543,6 +544,7 @@
    4.12                                      session,
    4.13                                      li->ident,
    4.14                                      li->ident,
    4.15 +                                    BASE_SYNC,
    4.16                                      _data,
    4.17                                      size,
    4.18                                      NULL,
    4.19 @@ -644,6 +646,7 @@
    4.20                                      session,
    4.21                                      li->ident,
    4.22                                      li->ident,
    4.23 +                                    BASE_SYNC,
    4.24                                      _data,
    4.25                                      size,
    4.26                                      NULL,
    4.27 @@ -747,6 +750,7 @@
    4.28                                      session,
    4.29                                      li->ident,
    4.30                                      li->ident,
    4.31 +                                    BASE_SYNC,
    4.32                                      _data,
    4.33                                      size,
    4.34                                      NULL,
    4.35 @@ -850,6 +854,7 @@
    4.36                                      session,
    4.37                                      li->ident,
    4.38                                      li->ident,
    4.39 +                                    BASE_SYNC,
    4.40                                      _data,
    4.41                                      size,
    4.42                                      NULL,