merged in sync krista_temp
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 17 Apr 2019 17:16:41 +0200
branchkrista_temp
changeset 3536ebd964291c30
parent 3535 3beb2f01130e
parent 3534 aeeca2b084fc
child 3537 06ed5ddd9363
merged in sync
     1.1 --- a/sync/gen_statemachine.ysl2	Tue Apr 16 17:42:57 2019 +0200
     1.2 +++ b/sync/gen_statemachine.ysl2	Wed Apr 17 17:16:41 2019 +0200
     1.3 @@ -21,7 +21,7 @@
     1.4  
     1.5          #pragma once
     1.6  
     1.7 -        #include "dynamic_api.h"
     1.8 +        #include "pEpEngine.h"
     1.9  
    1.10          #ifdef __cplusplus
    1.11          extern "C" {
    1.12 @@ -31,9 +31,14 @@
    1.13          typedef int «yml:ucase(@name)»_PR;
    1.14  
    1.15          typedef struct «@name»_event {
    1.16 +            // state machine data
    1.17              «yml:ucase(@name)»_PR fsm;
    1.18              int event;
    1.19              «yml:ucase(@name)» *msg;
    1.20 +
    1.21 +            // transport data
    1.22 +            pEp_identity *from;
    1.23 +            char *signature_fpr;
    1.24          } «@name»_event_t;
    1.25  
    1.26   
    1.27 @@ -110,6 +115,8 @@
    1.28          {
    1.29              if (ev) {
    1.30                  free_«@name»_message(ev->msg);
    1.31 +                free_identity(ev->from);
    1.32 +                free(ev->signature_fpr);
    1.33                  free(ev);
    1.34              }
    1.35          }
    1.36 @@ -326,24 +333,6 @@
    1.37                  PEP_STATUS status = PEP_STATUS_OK;
    1.38                  «@name»_event_t *ev = NULL;
    1.39  
    1.40 -                if (from) {
    1.41 -                    free_identity(session->«yml:lcase(@name)»_state.common.from);
    1.42 -                    session->«yml:lcase(@name)»_state.common.from = identity_dup(from);
    1.43 -                    if (!session->«yml:lcase(@name)»_state.common.from) {
    1.44 -                        status = PEP_OUT_OF_MEMORY;
    1.45 -                        goto the_end;
    1.46 -                    }
    1.47 -                }
    1.48 -
    1.49 -                if (signature_fpr) {
    1.50 -                    free(session->«yml:lcase(@name)»_state.common.signature_fpr);
    1.51 -                    session->«yml:lcase(@name)»_state.common.signature_fpr = strdup(signature_fpr);
    1.52 -                    if (!session->«yml:lcase(@name)»_state.common.signature_fpr) {
    1.53 -                        status = PEP_OUT_OF_MEMORY;
    1.54 -                        goto the_end;
    1.55 -                    }
    1.56 -                }
    1.57 -
    1.58                  «@name»_t *msg = NULL;
    1.59                  status = decode_«@name»_message(data, size, &msg);
    1.60                  if (status)
    1.61 @@ -365,6 +354,25 @@
    1.62                      goto the_end;
    1.63                  }
    1.64  
    1.65 +                // add transport data
    1.66 +
    1.67 +                if (from) {
    1.68 +                    ev->from = identity_dup(from);
    1.69 +                    if (!ev->from) {
    1.70 +                        status = PEP_OUT_OF_MEMORY;
    1.71 +                        goto the_end;
    1.72 +                    }
    1.73 +                }
    1.74 +
    1.75 +                if (signature_fpr) {
    1.76 +                    ev->signature_fpr = strdup(signature_fpr);
    1.77 +                    assert(ev->signature_fpr);
    1.78 +                    if (!ev->signature_fpr) {
    1.79 +                        status = PEP_OUT_OF_MEMORY;
    1.80 +                        goto the_end;
    1.81 +                    }
    1.82 +                }
    1.83 +
    1.84                  int result = session->inject_«yml:lcase(@name)»_event(ev,
    1.85                          session->«yml:lcase(@name)»_management);
    1.86                  if (result) {
    1.87 @@ -650,6 +658,27 @@
    1.88                      event = ev->event;
    1.89                  }
    1.90  
    1.91 +                // update transport data
    1.92 +
    1.93 +                if (ev->from) {
    1.94 +                    free_identity(session->sync_state.common.from);
    1.95 +                    session->sync_state.common.from = identity_dup(ev->from);
    1.96 +                    if (!session->sync_state.common.from) {
    1.97 +                        status = PEP_OUT_OF_MEMORY;
    1.98 +                        goto the_end;
    1.99 +                    }
   1.100 +                }
   1.101 +
   1.102 +                if (ev->signature_fpr) {
   1.103 +                    free(session->sync_state.common.signature_fpr);
   1.104 +                    session->sync_state.common.signature_fpr = strdup(ev->signature_fpr);
   1.105 +                    assert(session->sync_state.common.signature_fpr);
   1.106 +                    if (!session->sync_state.common.signature_fpr) {
   1.107 +                        status = PEP_OUT_OF_MEMORY;
   1.108 +                        goto the_end;
   1.109 +                    }
   1.110 +                }
   1.111 +
   1.112                  status = «@name»_driver(session, fsm, event);
   1.113  
   1.114              the_end: