adding session handles
authorVolker Birk <vb@pep-project.org>
Sun, 15 May 2016 21:23:36 +0200
changeset 627ef1fdfde8ced
parent 626 64a89bd12469
child 628 7a1615476a52
adding session handles
src/sync_actions.c
src/sync_driver.c
src/sync_fsm.c
src/sync_fsm.h
sync/gen_actions_skeleton.ysl2
sync/gen_statemachine.ysl2
     1.1 --- a/src/sync_actions.c	Sun May 15 16:23:31 2016 +0200
     1.2 +++ b/src/sync_actions.c	Sun May 15 21:23:36 2016 +0200
     1.3 @@ -7,12 +7,13 @@
     1.4  // sendBeacon() - 
     1.5  //
     1.6  //  params:
     1.7 +//      session (in)        session handle
     1.8  //      partner (in)        (must be NULL)
     1.9  //
    1.10  //  returns:
    1.11  //      PEP_STATUS_OK or any other value on error
    1.12  
    1.13 -PEP_STATUS sendBeacon(const Identity partner)
    1.14 +PEP_STATUS sendBeacon(PEP_SESSION session, const Identity partner)
    1.15  {
    1.16      PEP_STATUS status = PEP_STATUS_OK;
    1.17  
    1.18 @@ -29,12 +30,13 @@
    1.19  // sendHandshakeRequest() - 
    1.20  //
    1.21  //  params:
    1.22 +//      session (in)        session handle
    1.23  //      partner (in)        partner in sync
    1.24  //
    1.25  //  returns:
    1.26  //      PEP_STATUS_OK or any other value on error
    1.27  
    1.28 -PEP_STATUS sendHandshakeRequest(const Identity partner)
    1.29 +PEP_STATUS sendHandshakeRequest(PEP_SESSION session, const Identity partner)
    1.30  {
    1.31      PEP_STATUS status = PEP_STATUS_OK;
    1.32  
    1.33 @@ -51,12 +53,13 @@
    1.34  // showHandshake() - 
    1.35  //
    1.36  //  params:
    1.37 +//      session (in)        session handle
    1.38  //      partner (in)        partner in sync
    1.39  //
    1.40  //  returns:
    1.41  //      PEP_STATUS_OK or any other value on error
    1.42  
    1.43 -PEP_STATUS showHandshake(const Identity partner)
    1.44 +PEP_STATUS showHandshake(PEP_SESSION session, const Identity partner)
    1.45  {
    1.46      PEP_STATUS status = PEP_STATUS_OK;
    1.47  
    1.48 @@ -73,12 +76,13 @@
    1.49  // reject() - 
    1.50  //
    1.51  //  params:
    1.52 +//      session (in)        session handle
    1.53  //      partner (in)        partner in sync
    1.54  //
    1.55  //  returns:
    1.56  //      PEP_STATUS_OK or any other value on error
    1.57  
    1.58 -PEP_STATUS reject(const Identity partner)
    1.59 +PEP_STATUS reject(PEP_SESSION session, const Identity partner)
    1.60  {
    1.61      PEP_STATUS status = PEP_STATUS_OK;
    1.62  
    1.63 @@ -95,12 +99,13 @@
    1.64  // storeGroupKeys() - 
    1.65  //
    1.66  //  params:
    1.67 +//      session (in)        session handle
    1.68  //      partner (in)        partner in sync
    1.69  //
    1.70  //  returns:
    1.71  //      PEP_STATUS_OK or any other value on error
    1.72  
    1.73 -PEP_STATUS storeGroupKeys(const Identity partner)
    1.74 +PEP_STATUS storeGroupKeys(PEP_SESSION session, const Identity partner)
    1.75  {
    1.76      PEP_STATUS status = PEP_STATUS_OK;
    1.77  
    1.78 @@ -117,12 +122,13 @@
    1.79  // sendOwnKeys() - 
    1.80  //
    1.81  //  params:
    1.82 +//      session (in)        session handle
    1.83  //      partner (in)        (must be NULL)
    1.84  //
    1.85  //  returns:
    1.86  //      PEP_STATUS_OK or any other value on error
    1.87  
    1.88 -PEP_STATUS sendOwnKeys(const Identity partner)
    1.89 +PEP_STATUS sendOwnKeys(PEP_SESSION session, const Identity partner)
    1.90  {
    1.91      PEP_STATUS status = PEP_STATUS_OK;
    1.92  
    1.93 @@ -139,12 +145,13 @@
    1.94  // transmitGroupKeys() - 
    1.95  //
    1.96  //  params:
    1.97 +//      session (in)        session handle
    1.98  //      partner (in)        partner in sync
    1.99  //
   1.100  //  returns:
   1.101  //      PEP_STATUS_OK or any other value on error
   1.102  
   1.103 -PEP_STATUS transmitGroupKeys(const Identity partner)
   1.104 +PEP_STATUS transmitGroupKeys(PEP_SESSION session, const Identity partner)
   1.105  {
   1.106      PEP_STATUS status = PEP_STATUS_OK;
   1.107  
     2.1 --- a/src/sync_driver.c	Sun May 15 16:23:31 2016 +0200
     2.2 +++ b/src/sync_driver.c	Sun May 15 21:23:36 2016 +0200
     2.3 @@ -11,7 +11,7 @@
     2.4      static DeviceState_state state = InitState;
     2.5      static Identity partner = NULL;
     2.6  
     2.7 -    state = fsm_DeviceState(state, event, partner);
     2.8 +    state = fsm_DeviceState(session, state, event, partner);
     2.9      return status;
    2.10  }
    2.11  
     3.1 --- a/src/sync_fsm.c	Sun May 15 16:23:31 2016 +0200
     3.2 +++ b/src/sync_fsm.c	Sun May 15 21:23:36 2016 +0200
     3.3 @@ -3,6 +3,7 @@
     3.4  // state machine for DeviceState
     3.5  
     3.6  DeviceState_state fsm_DeviceState(
     3.7 +        PEP_SESSION session,
     3.8          DeviceState_state state,
     3.9          DeviceState_event event,
    3.10          const Identity partner
    3.11 @@ -21,16 +22,16 @@
    3.12      case Sole:
    3.13          switch (event) {
    3.14              case KeyGen:
    3.15 -                sendBeacon(NULL);
    3.16 +                sendBeacon(session, NULL);
    3.17                  break;
    3.18              case CannotDecrypt:
    3.19 -                sendBeacon(NULL);
    3.20 +                sendBeacon(session, NULL);
    3.21                  break;
    3.22              case Beacon:
    3.23 -                sendHandshakeRequest(partner);
    3.24 +                sendHandshakeRequest(session, partner);
    3.25                  break;
    3.26              case HandshakeRequest:
    3.27 -                sendHandshakeRequest(partner);
    3.28 +                sendHandshakeRequest(session, partner);
    3.29                  return HandshakingSole;
    3.30          default:
    3.31              return invalid_event;
    3.32 @@ -40,10 +41,10 @@
    3.33      case HandshakingSole:
    3.34          switch (event) {
    3.35              case Init:
    3.36 -                showHandshake(partner);
    3.37 +                showHandshake(session, partner);
    3.38                  break;
    3.39              case HandshakeRejected:
    3.40 -                reject(partner);
    3.41 +                reject(session, partner);
    3.42                  return Sole;
    3.43              case HandshakeAccepted:
    3.44                  return WaitForGroupKeys;
    3.45 @@ -55,12 +56,12 @@
    3.46      case WaitForGroupKeys:
    3.47          switch (event) {
    3.48              case ReceiveGroupKeys:
    3.49 -                storeGroupKeys(partner);
    3.50 +                storeGroupKeys(session, partner);
    3.51                  return Grouped;
    3.52              case Cancel:
    3.53                  return Sole;
    3.54              case Reject:
    3.55 -                reject(partner);
    3.56 +                reject(session, partner);
    3.57                  return Sole;
    3.58          default:
    3.59              return invalid_event;
    3.60 @@ -70,20 +71,20 @@
    3.61      case Grouped:
    3.62          switch (event) {
    3.63              case KeyGen:
    3.64 -                sendOwnKeys(NULL);
    3.65 +                sendOwnKeys(session, NULL);
    3.66                  break;
    3.67              case HandshakeRequest:
    3.68 -                sendHandshakeRequest(partner);
    3.69 -                showHandshake(partner);
    3.70 +                sendHandshakeRequest(session, partner);
    3.71 +                showHandshake(session, partner);
    3.72                  break;
    3.73              case HandshakeRejected:
    3.74 -                reject(partner);
    3.75 +                reject(session, partner);
    3.76                  break;
    3.77              case HandshakeAccepted:
    3.78 -                transmitGroupKeys(partner);
    3.79 +                transmitGroupKeys(session, partner);
    3.80                  break;
    3.81              case Reject:
    3.82 -                reject(NULL);
    3.83 +                reject(session, NULL);
    3.84                  break;
    3.85          default:
    3.86              return invalid_event;
     4.1 --- a/src/sync_fsm.h	Sun May 15 16:23:31 2016 +0200
     4.2 +++ b/src/sync_fsm.h	Sun May 15 21:23:36 2016 +0200
     4.3 @@ -43,17 +43,18 @@
     4.4  
     4.5  // actions
     4.6  
     4.7 -PEP_STATUS sendBeacon(const Identity partner);
     4.8 -PEP_STATUS sendHandshakeRequest(const Identity partner);
     4.9 -PEP_STATUS showHandshake(const Identity partner);
    4.10 -PEP_STATUS reject(const Identity partner);
    4.11 -PEP_STATUS storeGroupKeys(const Identity partner);
    4.12 -PEP_STATUS sendOwnKeys(const Identity partner);
    4.13 -PEP_STATUS transmitGroupKeys(const Identity partner);
    4.14 +PEP_STATUS sendBeacon(PEP_SESSION session, const Identity partner);
    4.15 +PEP_STATUS sendHandshakeRequest(PEP_SESSION session, const Identity partner);
    4.16 +PEP_STATUS showHandshake(PEP_SESSION session, const Identity partner);
    4.17 +PEP_STATUS reject(PEP_SESSION session, const Identity partner);
    4.18 +PEP_STATUS storeGroupKeys(PEP_SESSION session, const Identity partner);
    4.19 +PEP_STATUS sendOwnKeys(PEP_SESSION session, const Identity partner);
    4.20 +PEP_STATUS transmitGroupKeys(PEP_SESSION session, const Identity partner);
    4.21  
    4.22  // state machine
    4.23  
    4.24  DeviceState_state fsm_DeviceState(
    4.25 +        PEP_SESSION session,
    4.26          DeviceState_state state,
    4.27          DeviceState_event event,
    4.28          const Identity partner
     5.1 --- a/sync/gen_actions_skeleton.ysl2	Sun May 15 16:23:31 2016 +0200
     5.2 +++ b/sync/gen_actions_skeleton.ysl2	Sun May 15 21:23:36 2016 +0200
     5.3 @@ -25,7 +25,7 @@
     5.4          static «@name»_state state = InitState;
     5.5          static Identity partner = NULL;
     5.6  
     5.7 -        state = fsm_«@name»(state, event, partner);
     5.8 +        state = fsm_«@name»(session, state, event, partner);
     5.9          return status;
    5.10      }
    5.11  
    5.12 @@ -49,13 +49,14 @@
    5.13          // «$action/@name»() - 
    5.14          //
    5.15          //  params:
    5.16 +        //      session (in)        session handle
    5.17          `` if "parm"        | //      partner (in)        partner in sync
    5.18          `` if "not(parm)"   | //      partner (in)        (must be NULL)
    5.19          //
    5.20          //  returns:
    5.21          //      PEP_STATUS_OK or any other value on error
    5.22  
    5.23 -        PEP_STATUS «$action/@name»(const Identity partner)
    5.24 +        PEP_STATUS «$action/@name»(PEP_SESSION session, const Identity partner)
    5.25          {
    5.26              PEP_STATUS status = PEP_STATUS_OK;
    5.27  
     6.1 --- a/sync/gen_statemachine.ysl2	Sun May 15 16:23:31 2016 +0200
     6.2 +++ b/sync/gen_statemachine.ysl2	Sun May 15 21:23:36 2016 +0200
     6.3 @@ -44,11 +44,12 @@
     6.4  
     6.5          // actions
     6.6  
     6.7 -        `` for "func:distinctName(//action)" | PEP_STATUS «@name»(const Identity partner);
     6.8 +        `` for "func:distinctName(//action)" | PEP_STATUS «@name»(PEP_SESSION session, const Identity partner);
     6.9  
    6.10          // state machine
    6.11  
    6.12          «@name»_state fsm_«@name»(
    6.13 +                PEP_SESSION session,
    6.14                  «@name»_state state,
    6.15                  «@name»_event event,
    6.16                  const Identity partner
    6.17 @@ -65,6 +66,7 @@
    6.18          // state machine for «@name»
    6.19  
    6.20          «@name»_state fsm_«@name»(
    6.21 +                PEP_SESSION session,
    6.22                  «@name»_state state,
    6.23                  «@name»_event event,
    6.24                  const Identity partner
    6.25 @@ -103,7 +105,7 @@
    6.26  
    6.27      template "action" {
    6.28          indent(0);
    6.29 -        > «@name»(
    6.30 +        > «@name»(session, 
    6.31          choose {
    6.32              when "parm" > «name(parm/*)»
    6.33              otherwise > NULL