-
Notifications
You must be signed in to change notification settings - Fork 1
/
dp5_clib.h
200 lines (146 loc) · 4.75 KB
/
dp5_clib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#include <vector>
#include <set>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include "dp5params.h"
#include "dp5regclient.h"
#include "dp5combregclient.h"
#include "dp5regserver.h"
#include "dp5lookupserver.h"
#include "dp5lookupclient.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
using namespace std;
using namespace dp5;
using namespace dp5::internal;
extern "C" {
// Native buffer interface
typedef struct {
size_t len;
char * buf;
} nativebuffer;
void nativebuffer_purge(nativebuffer buf);
/* Init functions */
void Init_init();
/* DH functions */
typedef struct _DHKey DHKey;
DHKey * DHKey_alloc();
void DHKey_free(DHKey * vkeys);
void DHKey_keygen(DHKey * vkeys);
size_t DHKey_size();
size_t DHKey_pubsize();
/* BLH functions */
typedef struct _BLSKey BLSKey;
BLSKey * BLSKey_alloc();
void BLSKey_free(BLSKey * keys);
void BLSKey_keygen(BLSKey * keys);
size_t BLSKey_size();
size_t BLSKey_pubsize();
/* DP5 Config functions */
struct DP5Config * Config_alloc(
unsigned int epoch_len,
unsigned int dataenc_bytes,
bool combined);
unsigned int Config_dataplain_bytes(struct DP5Config * config);
dp5::Epoch Config_current_epoch(struct DP5Config * config);
void Config_delete(struct DP5Config * config);
/* Registration client */
struct DP5RegClient * RegClient_alloc(
struct DP5Config * config,
DHKey * keys);
void RegClient_delete(struct DP5RegClient * p);
int RegClient_start(
struct DP5RegClient * reg,
struct DP5Config * config,
unsigned int epoch,
unsigned int friends_num,
char * data,
nativebuffer * msg);
int RegClient_complete(
DP5RegClient * reg,
unsigned int epoch,
nativebuffer buf);
/* Combined registration client */
DP5CombinedRegClient * RegClientCB_alloc(BLSKey * keys);
void RegClientCB_delete(struct DP5CombinedRegClient * p);
int RegClientCB_start(
DP5CombinedRegClient * reg,
unsigned int epoch,
nativebuffer data,
void processbuf(size_t, const void*));
int RegClientCB_complete(
DP5CombinedRegClient * reg,
unsigned int epoch,
nativebuffer buffer);
/* Registration Server */
DP5RegServer * RegServer_alloc(
DP5Config * config,
unsigned int epoch,
char* regdir,
char* datadir);
void RegServer_delete(DP5RegServer * p);
void RegServer_register(
DP5RegServer * reg,
nativebuffer data,
void processbuf(size_t, const void*));
unsigned int RegServer_epoch_change(
DP5RegServer * reg,
char * metadata,
char * data);
/* Lookup server */
DP5LookupServer * LookupServer_alloc(char* meta, char* data);
void LookupServer_delete(DP5LookupServer * p);
void LookupServer_process(
DP5LookupServer * ser,
nativebuffer data,
void processbuf(size_t, const void*));
/* Combined lookup Client */
DP5CombinedLookupClient * LookupClientCB_alloc();
void LookupClientCB_delete(DP5CombinedLookupClient * p);
void LookupClientCB_metadata_req(
DP5CombinedLookupClient * cli,
unsigned int epoch,
void processbuf(size_t, const void*));
int LookupClientCB_metadata_rep(
DP5CombinedLookupClient * cli,
nativebuffer data);
DP5CombinedLookupClient::Request * LookupRequestCB_lookup(
DP5CombinedLookupClient * cli,
unsigned int buds_len,
void * buds,
unsigned int num_servers,
void processbuf(size_t, const void*) );
int LookupRequestCB_reply(
DP5CombinedLookupClient::Request * req,
unsigned int num_servers,
nativebuffer * replies,
void processprez(char*, bool, size_t, const void*)
);
void LookupRequestCB_delete(DP5CombinedLookupClient::Request * p);
/* Lookup client */
DP5LookupClient * LookupClient_alloc(DHKey * keys);
void LookupClient_delete(DP5LookupClient * p);
void LookupClient_metadata_req(
DP5LookupClient * cli,
unsigned int epoch,
nativebuffer * msg);
int LookupClient_metadata_rep(
DP5LookupClient * cli,
nativebuffer data);
DP5LookupClient::Request * LookupRequest_lookup(
DP5LookupClient * cli,
unsigned int buds_len,
void * buds,
unsigned int num_servers,
nativebuffer * msg);
int LookupRequest_reply(
DP5LookupClient::Request * req,
unsigned int num_servers,
nativebuffer * replies,
nativebuffer * msg);
void LookupRequest_delete(DP5LookupClient::Request * p);
}