aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-09-02 13:53:29 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-09-02 13:53:29 +0000
commit24a5d2fbc4f6fd9be36a59f0e53ddf9f511d3826 (patch)
treec574e47cef32284e74a81de9931343cf30122130
parent5635cdd2e7644ca44e94c767b42831d891f35df7 (diff)
downloadgnunet-24a5d2fbc4f6fd9be36a59f0e53ddf9f511d3826.tar.gz
gnunet-24a5d2fbc4f6fd9be36a59f0e53ddf9f511d3826.zip
updated includes of api and service to include the new headerfiles
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct.c147
-rw-r--r--src/scalarproduct/scalarproduct_api.c1
2 files changed, 147 insertions, 1 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c
index 80fe35758..9d0a8a2e7 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct.c
@@ -32,7 +32,7 @@
32#include "gnunet_protocols.h" 32#include "gnunet_protocols.h"
33#include "gnunet_scalarproduct_service.h" 33#include "gnunet_scalarproduct_service.h"
34#include "gnunet_scalarproduct.h" 34#include "gnunet_scalarproduct.h"
35 35#include "scalarproduct.h"
36 36
37#define LOG(kind,...) GNUNET_log_from (kind, "scalarproduct", __VA_ARGS__) 37#define LOG(kind,...) GNUNET_log_from (kind, "scalarproduct", __VA_ARGS__)
38 38
@@ -44,6 +44,151 @@
44#define LOG_GCRY(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0) 44#define LOG_GCRY(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0)
45 45
46/////////////////////////////////////////////////////////////////////////////// 46///////////////////////////////////////////////////////////////////////////////
47// Service Structure Definitions
48///////////////////////////////////////////////////////////////////////////////
49
50/**
51 * state a session can be in
52 */
53enum SessionState
54{
55 WAITING_FOR_BOBS_CONNECT,
56 MESSAGE_FROM_RESPONDING_CLIENT_RECEIVED,
57 WAITING_FOR_RESPONSE_FROM_SERVICE,
58 REQUEST_FROM_SERVICE_RECEIVED,
59 FINALIZED
60};
61
62/**
63 * role a peer in a session can assume
64 */
65enum PeerRole
66{
67 ALICE,
68 BOB
69};
70
71
72/**
73 * A scalarproduct session which tracks:
74 *
75 * a request form the client to our final response.
76 * or
77 * a request from a service to us(service).
78 */
79struct ServiceSession
80{
81 /**
82 * the role this peer has
83 */
84 enum PeerRole role;
85
86 /**
87 * session information is kept in a DLL
88 */
89 struct ServiceSession *next;
90
91 /**
92 * session information is kept in a DLL
93 */
94 struct ServiceSession *prev;
95
96 /**
97 * (hopefully) unique transaction ID
98 */
99 struct GNUNET_HashCode key;
100
101 /**
102 * state of the session
103 */
104 enum SessionState state;
105
106 /**
107 * Alice or Bob's peerID
108 */
109 struct GNUNET_PeerIdentity peer;
110
111 /**
112 * the client this request is related to
113 */
114 struct GNUNET_SERVER_Client * client;
115
116 /**
117 * how many elements we were supplied with from the client
118 */
119 uint16_t element_count;
120
121 /**
122 * how many elements actually are used after applying the mask
123 */
124 uint16_t used_element_count;
125
126 /**
127 * how many bytes the mask is long.
128 * just for convenience so we don't have to re-re-re calculate it each time
129 */
130 uint16_t mask_length;
131
132 /**
133 * all the vector elements we received
134 */
135 int32_t * vector;
136
137 /**
138 * mask of which elements to check
139 */
140 unsigned char * mask;
141
142 /**
143 * Public key of the remote service, only used by bob
144 */
145 gcry_sexp_t remote_pubkey;
146
147 /**
148 * E(ai)(Bob) or ai(Alice) after applying the mask
149 */
150 gcry_mpi_t * a;
151
152 /**
153 * The computed scalar
154 */
155 gcry_mpi_t product;
156
157 /**
158 * My transmit handle for the current message to a alice/bob
159 */
160 struct GNUNET_MESH_TransmitHandle * service_transmit_handle;
161
162 /**
163 * My transmit handle for the current message to the client
164 */
165 struct GNUNET_SERVER_TransmitHandle * client_transmit_handle;
166
167 /**
168 * tunnel-handle associated with our mesh handle
169 */
170 struct GNUNET_MESH_Tunnel * tunnel;
171
172};
173
174/**
175 * We need to do a minimum of bookkeeping to maintain track of our transmit handles.
176 * each msg is associated with a session and handle. using this information we can determine which msg was sent.
177 */
178struct MessageObject
179{
180 /**
181 * The handle used to transmit with this request
182 */
183 void ** transmit_handle;
184
185 /**
186 * The message to send
187 */
188 struct GNUNET_MessageHeader * msg;
189};
190
191///////////////////////////////////////////////////////////////////////////////
47// Global Variables 192// Global Variables
48/////////////////////////////////////////////////////////////////////////////// 193///////////////////////////////////////////////////////////////////////////////
49 194
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c
index 3eae200c3..b77c30925 100644
--- a/src/scalarproduct/scalarproduct_api.c
+++ b/src/scalarproduct/scalarproduct_api.c
@@ -30,6 +30,7 @@
30#include "gnunet_statistics_service.h" 30#include "gnunet_statistics_service.h"
31#include "gnunet_scalarproduct_service.h" 31#include "gnunet_scalarproduct_service.h"
32#include "gnunet_protocols.h" 32#include "gnunet_protocols.h"
33#include "scalarproduct.h"
33 34
34#define LOG(kind,...) GNUNET_log_from (kind, "scalarproduct-api",__VA_ARGS__) 35#define LOG(kind,...) GNUNET_log_from (kind, "scalarproduct-api",__VA_ARGS__)
35 36