Preliminary code for distributed hash table. Defines some basic udp message structure...
[IRC.git] / Robust / src / Runtime / DSTM / interface / dht.h
1 #ifndef _DHT_H
2 #define _DHT_H
3
4 #define INIT_NUM_BLOCKS 16
5
6 //messages
7 #define DHT_INSERT 1
8 #define DHT_REMOVE 2
9 #define DHT_SEARCH 3
10 #define DHT_ACK 4
11 #define DHT_JOIN 5
12 #define DHT_LEAVE 6
13 #define DHT_REBUILD 7
14 //etc...
15
16 struct hostData {
17         unsigned int ipAddr;
18         unsigned int maxKeyCapacity;
19         struct hostData *next;
20 };
21
22 struct dhtInsertMsg {
23         unsigned char msgType;
24         unsigned int unused:12;
25         unsigned int key;
26         unsigned int val;
27 };
28
29 struct dhtRemoveMsg {
30         unsigned char msgType;
31         unsigned int unused:12;
32         unsigned int key;
33 };
34
35 struct dhtSearchMsg {
36         unsigned char msgType;
37         unsigned int unused:12;
38         unsigned int key;
39 };
40
41 struct dhtJoinMsg {
42         unsigned char msgType;
43         unsigned int unused:12;
44         struct hostData newHost;
45 };
46
47 //called by host which joins (or starts) the system
48 void dhtInit();
49 //exit system, cleanup
50 void dhtExit();
51
52 //called by whoever performs the creation, move, deletion
53 int dhtInsert(unsigned int key, unsigned int val);
54 int dhtRemove(unsigned int key);
55 int dhtSearch(unsigned int key);
56
57 #endif
58