diff options
13 files changed, 723 insertions, 3 deletions
diff --git a/src/main/java/org/gnunet/peerstore/IterateRequest.java b/src/main/java/org/gnunet/peerstore/IterateRequest.java new file mode 100644 index 0000000..ec7f7df --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/IterateRequest.java | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | package org.gnunet.peerstore; | ||
22 | |||
23 | import org.gnunet.mq.Envelope; | ||
24 | import org.gnunet.peerstore.messages.IterateMessage; | ||
25 | import org.gnunet.requests.Request; | ||
26 | import org.gnunet.util.AbsoluteTimeMessage; | ||
27 | import org.gnunet.util.PeerIdentity; | ||
28 | |||
29 | class IterateRequest extends Request { | ||
30 | private final String sub_system; | ||
31 | private final PeerIdentity peer; | ||
32 | private final String key; | ||
33 | public final PeerstoreReceiver receiver; | ||
34 | |||
35 | public IterateRequest(String sub_system, PeerIdentity peer, String key, | ||
36 | PeerstoreReceiver receiver) { | ||
37 | this.sub_system = sub_system; | ||
38 | this.peer = peer; | ||
39 | this.key = key; | ||
40 | this.receiver = receiver; | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public Envelope assembleRequest() { | ||
45 | IterateMessage im = new IterateMessage(); | ||
46 | im.sub_system_size = this.sub_system.length() + 1; | ||
47 | im.sub_system = this.sub_system; | ||
48 | if (null == this.peer) { | ||
49 | im.peer_set = 0; | ||
50 | im.peer = new PeerIdentity(); | ||
51 | } else { | ||
52 | im.peer_set = 1; | ||
53 | im.peer = peer; | ||
54 | } | ||
55 | if (null == this.key) { | ||
56 | im.key = null; | ||
57 | im.key_size = 0; | ||
58 | } else { | ||
59 | im.key_size = this.key.length() + 1; | ||
60 | im.key = this.key; | ||
61 | } | ||
62 | im.value_size = 0; | ||
63 | im.value = new byte[0]; | ||
64 | im.expiry = new AbsoluteTimeMessage(); | ||
65 | im.options = 0; | ||
66 | return new Envelope(im); | ||
67 | } | ||
68 | |||
69 | public void cancel() { | ||
70 | } | ||
71 | |||
72 | } | ||
diff --git a/src/main/java/org/gnunet/peerstore/Peerstore.java b/src/main/java/org/gnunet/peerstore/Peerstore.java new file mode 100644 index 0000000..6af904d --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/Peerstore.java | |||
@@ -0,0 +1,220 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | package org.gnunet.peerstore; | ||
22 | |||
23 | import org.gnunet.peerstore.messages.IterateEndMessage; | ||
24 | import org.gnunet.peerstore.messages.IterateRecordMessage; | ||
25 | import org.gnunet.peerstore.messages.StoreMessage; | ||
26 | import org.gnunet.peerstore.messages.WatchRecordMessage; | ||
27 | import org.gnunet.requests.MatchingRequestContainer; | ||
28 | import org.gnunet.requests.RequestIdentifier; | ||
29 | import org.gnunet.requests.SequentialRequestContainer; | ||
30 | import org.gnunet.requests.TimeoutHandler; | ||
31 | import org.gnunet.util.*; | ||
32 | |||
33 | /** | ||
34 | * API for the GNUnet peerstore service. | ||
35 | */ | ||
36 | public class Peerstore { | ||
37 | |||
38 | /** | ||
39 | * Client connecting us to the statistics service. | ||
40 | */ | ||
41 | private Client client; | ||
42 | |||
43 | /** | ||
44 | * All request to the service for iterating records. | ||
45 | */ | ||
46 | private final SequentialRequestContainer<IterateRequest> iterateRequests; | ||
47 | |||
48 | /** | ||
49 | * All requests to the service for watching a value. | ||
50 | */ | ||
51 | private final MatchingRequestContainer<HashCode, WatchRequest> watchRequests; | ||
52 | |||
53 | /** | ||
54 | * Are we currently destroying the client? | ||
55 | */ | ||
56 | private boolean destroyRequested; | ||
57 | |||
58 | /** | ||
59 | * Messages from the statistics service are dispatched to an instance of | ||
60 | * this class. | ||
61 | */ | ||
62 | public class PeerstoreMessageReceiver extends RunaboutMessageReceiver { | ||
63 | |||
64 | public void visit(IterateRecordMessage m) { | ||
65 | RequestIdentifier<IterateRequest> req = iterateRequests | ||
66 | .getRequestIdentifier(); | ||
67 | if (null != req) | ||
68 | req.getRequest().receiver.onReceive(m.sub_system, m.peer, | ||
69 | m.key, m.value, new AbsoluteTime(m.expiry.value)); | ||
70 | } | ||
71 | |||
72 | public void visit(IterateEndMessage m) { | ||
73 | RequestIdentifier<IterateRequest> req = iterateRequests | ||
74 | .getRequestIdentifier(); | ||
75 | if (null != req) { | ||
76 | req.retire(); | ||
77 | req.getRequest().receiver.onDone(); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | public void visit(WatchRecordMessage m) { | ||
82 | RequestIdentifier<WatchRequest> ri = watchRequests | ||
83 | .getRequestIdentifier(WatchRequest.getHash(m.sub_system, | ||
84 | m.peer, m.key)); | ||
85 | WatchRequest r = ri.getRequest(); | ||
86 | if (null != r) { | ||
87 | r.watcher.onReceive(m.sub_system, m.peer, m.key, m.value, | ||
88 | new AbsoluteTime(m.expiry.value)); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public void handleError() { | ||
94 | if (null == client) | ||
95 | throw new AssertionError(); | ||
96 | if (!destroyRequested) { | ||
97 | client.reconnect(); | ||
98 | iterateRequests.restart(); | ||
99 | watchRequests.restart(); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | } | ||
104 | |||
105 | /** | ||
106 | * Create a connection to the peerstore service. | ||
107 | * | ||
108 | * @param cfg | ||
109 | * configuration to use | ||
110 | */ | ||
111 | public Peerstore(Configuration cfg) { | ||
112 | client = new Client("peerstore", cfg); | ||
113 | client.installReceiver(new PeerstoreMessageReceiver()); | ||
114 | iterateRequests = new SequentialRequestContainer<IterateRequest>(client); | ||
115 | watchRequests = new MatchingRequestContainer<HashCode, WatchRequest>( | ||
116 | client); | ||
117 | } | ||
118 | |||
119 | /** | ||
120 | * Store a new entry in the PEERSTORE. Note that stored entries can be lost | ||
121 | * in some cases such as power failure. | ||
122 | * | ||
123 | * @param sub_system | ||
124 | * name of the sub system | ||
125 | * @param peer | ||
126 | * Peer Identity | ||
127 | * @param key | ||
128 | * entry key | ||
129 | * @param value | ||
130 | * entry value BLOB | ||
131 | * @param expiry | ||
132 | * absolute time after which the entry is (possibly) deleted | ||
133 | * @param options | ||
134 | * options specific to the storage operation | ||
135 | */ | ||
136 | public void store(final String sub_system, final PeerIdentity peer, | ||
137 | final String key, final byte[] value, AbsoluteTime expiry, | ||
138 | StoreOption options) { | ||
139 | if (destroyRequested || client == null) | ||
140 | throw new AssertionError("already destroyed"); | ||
141 | StoreMessage sm = new StoreMessage(); | ||
142 | sm.peer_set = 1; | ||
143 | sm.peer = peer; | ||
144 | sm.sub_system_size = sub_system.length() + 1; | ||
145 | sm.key_size = key.length() + 1; | ||
146 | sm.value_size = value.length; | ||
147 | sm.expiry = new AbsoluteTimeMessage(expiry); | ||
148 | sm.options = options.val; | ||
149 | sm.sub_system = sub_system; | ||
150 | sm.key = key; | ||
151 | sm.value = value; | ||
152 | client.send(sm); | ||
153 | } | ||
154 | |||
155 | /** | ||
156 | * Iterate over records matching supplied key information | ||
157 | * | ||
158 | * @param sub_system | ||
159 | * name of sub system | ||
160 | * @param peer | ||
161 | * Peer identity (can be NULL) | ||
162 | * @param key | ||
163 | * entry key string (can be NULL) | ||
164 | * @param timeout | ||
165 | * time after which the iterate request is canceled | ||
166 | * @param receiver | ||
167 | * Object that will receive request results | ||
168 | * @return Handle to iteration request | ||
169 | */ | ||
170 | public Cancelable iterate(final String sub_system, final PeerIdentity peer, | ||
171 | final String key, final RelativeTime timeout, | ||
172 | final PeerstoreReceiver receiver) { | ||
173 | if (destroyRequested || client == null) | ||
174 | throw new AssertionError("already destroyed"); | ||
175 | RequestIdentifier<IterateRequest> identifier = iterateRequests | ||
176 | .addRequest(new IterateRequest(sub_system, peer, key, receiver)); | ||
177 | identifier.setTimeout(timeout, new TimeoutHandler() { | ||
178 | |||
179 | @Override | ||
180 | public void onTimeout() { | ||
181 | receiver.onTimeout(); | ||
182 | |||
183 | } | ||
184 | }); | ||
185 | return identifier; | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * Request watching a given key User will be notified with any new values | ||
190 | * added to key | ||
191 | * | ||
192 | * @param sub_system | ||
193 | * name of sub system | ||
194 | * @param peer | ||
195 | * Peer identity | ||
196 | * @param key | ||
197 | * entry key string | ||
198 | * @param watcher | ||
199 | * Receiver for watch records | ||
200 | * @return Handle to watch request | ||
201 | */ | ||
202 | public Cancelable watch(final String sub_system, final PeerIdentity peer, | ||
203 | final String key, PeerstoreWatcher watcher) { | ||
204 | if (destroyRequested || null == client) | ||
205 | throw new AssertionError("already destroyed"); | ||
206 | WatchRequest r = new WatchRequest(sub_system, peer, key, watcher); | ||
207 | return watchRequests.addRequest(r.hash, r); | ||
208 | } | ||
209 | |||
210 | /** | ||
211 | * Destroy handle to the peerstore service. | ||
212 | */ | ||
213 | public void destroy() { // TODO: imeplement syncfirst | ||
214 | if (destroyRequested) | ||
215 | throw new AssertionError("already destroyed"); | ||
216 | destroyRequested = true; | ||
217 | client.disconnect(); | ||
218 | client = null; | ||
219 | } | ||
220 | } | ||
diff --git a/src/main/java/org/gnunet/peerstore/PeerstoreReceiver.java b/src/main/java/org/gnunet/peerstore/PeerstoreReceiver.java new file mode 100644 index 0000000..867cb51 --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/PeerstoreReceiver.java | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | package org.gnunet.peerstore; | ||
22 | |||
23 | import org.gnunet.util.AbsoluteTime; | ||
24 | import org.gnunet.util.PeerIdentity; | ||
25 | |||
26 | public interface PeerstoreReceiver { | ||
27 | /** | ||
28 | * Called when having received a peerstore record from the service. | ||
29 | */ | ||
30 | public void onReceive(String sub_system, PeerIdentity peer, String key, | ||
31 | byte[] value, AbsoluteTime expiry); | ||
32 | |||
33 | /** | ||
34 | * Called when peerstore request times out. Never called for watchers. | ||
35 | */ | ||
36 | public void onTimeout(); | ||
37 | |||
38 | /** | ||
39 | * Called when all values for the request have been received. Never called | ||
40 | * for watchers. | ||
41 | */ | ||
42 | public void onDone(); | ||
43 | } | ||
diff --git a/src/main/java/org/gnunet/peerstore/PeerstoreWatcher.java b/src/main/java/org/gnunet/peerstore/PeerstoreWatcher.java new file mode 100644 index 0000000..64dd493 --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/PeerstoreWatcher.java | |||
@@ -0,0 +1,10 @@ | |||
1 | package org.gnunet.peerstore; | ||
2 | |||
3 | import org.gnunet.util.AbsoluteTime; | ||
4 | import org.gnunet.util.PeerIdentity; | ||
5 | |||
6 | public interface PeerstoreWatcher { | ||
7 | |||
8 | public void onReceive(String sub_system, PeerIdentity peer, String key, | ||
9 | byte[] value, AbsoluteTime expiry); | ||
10 | } | ||
diff --git a/src/main/java/org/gnunet/peerstore/StoreOption.java b/src/main/java/org/gnunet/peerstore/StoreOption.java new file mode 100644 index 0000000..f03aff9 --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/StoreOption.java | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | package org.gnunet.peerstore; | ||
22 | |||
23 | /** | ||
24 | * Options for storing values in PEERSTORE | ||
25 | */ | ||
26 | public enum StoreOption { | ||
27 | /** | ||
28 | * Possibly store multiple values under given key. | ||
29 | */ | ||
30 | MULTIPLE(0), | ||
31 | |||
32 | /** | ||
33 | * Delete any previous values for the given key before storing the given | ||
34 | * value. | ||
35 | */ | ||
36 | REPLACE(1); | ||
37 | |||
38 | int val; | ||
39 | |||
40 | StoreOption(int val) { | ||
41 | this.val = val; | ||
42 | } | ||
43 | } | ||
diff --git a/src/main/java/org/gnunet/peerstore/WatchRequest.java b/src/main/java/org/gnunet/peerstore/WatchRequest.java new file mode 100644 index 0000000..4460c1c --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/WatchRequest.java | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | package org.gnunet.peerstore; | ||
22 | |||
23 | import java.nio.ByteBuffer; | ||
24 | |||
25 | import org.gnunet.mq.Envelope; | ||
26 | import org.gnunet.peerstore.messages.WatchMessage; | ||
27 | import org.gnunet.requests.Request; | ||
28 | import org.gnunet.util.HashCode; | ||
29 | import org.gnunet.util.PeerIdentity; | ||
30 | |||
31 | class WatchRequest extends Request { | ||
32 | public final String sub_system; | ||
33 | public final PeerIdentity peer; | ||
34 | public final String key; | ||
35 | public final PeerstoreWatcher watcher; | ||
36 | public final HashCode hash; | ||
37 | |||
38 | public static HashCode getHash(String sub_system, PeerIdentity peer, | ||
39 | String key) { | ||
40 | int block_size = 0; | ||
41 | block_size += sub_system.length() + 1; | ||
42 | block_size += peer.data.length; | ||
43 | block_size += key.length() + 1; | ||
44 | |||
45 | byte[] block = new byte[block_size]; | ||
46 | ByteBuffer target = ByteBuffer.wrap(block); | ||
47 | target.put(sub_system.getBytes()); | ||
48 | target.put((byte)'\0'); | ||
49 | target.put(peer.data); | ||
50 | target.put(key.getBytes()); | ||
51 | target.put((byte)'\0'); | ||
52 | |||
53 | return HashCode.hash(block); | ||
54 | } | ||
55 | |||
56 | public WatchRequest(String sub_system, PeerIdentity peer, String key, | ||
57 | PeerstoreWatcher watcher) { | ||
58 | this.sub_system = sub_system; | ||
59 | this.peer = peer; | ||
60 | this.key = key; | ||
61 | this.watcher = watcher; | ||
62 | this.hash = WatchRequest.getHash(sub_system, peer, key); | ||
63 | } | ||
64 | |||
65 | @Override | ||
66 | public Envelope assembleRequest() { | ||
67 | WatchMessage wm = new WatchMessage(); | ||
68 | wm.keyhash = this.hash; | ||
69 | return new Envelope(wm); | ||
70 | } | ||
71 | |||
72 | @Override | ||
73 | public void cancel() { | ||
74 | // TODO: send a watch cancel request | ||
75 | } | ||
76 | |||
77 | } | ||
diff --git a/src/main/java/org/gnunet/peerstore/messages/IterateEndMessage.java b/src/main/java/org/gnunet/peerstore/messages/IterateEndMessage.java new file mode 100644 index 0000000..494555d --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/messages/IterateEndMessage.java | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | package org.gnunet.peerstore.messages; | ||
22 | |||
23 | import org.gnunet.construct.UnionCase; | ||
24 | import org.gnunet.util.GnunetMessage; | ||
25 | |||
26 | @UnionCase(823) | ||
27 | public class IterateEndMessage implements GnunetMessage.Body { | ||
28 | |||
29 | } | ||
diff --git a/src/main/java/org/gnunet/peerstore/messages/IterateMessage.java b/src/main/java/org/gnunet/peerstore/messages/IterateMessage.java new file mode 100644 index 0000000..8eb2be2 --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/messages/IterateMessage.java | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | package org.gnunet.peerstore.messages; | ||
22 | |||
23 | import org.gnunet.construct.FillWith; | ||
24 | import org.gnunet.construct.NestedMessage; | ||
25 | import org.gnunet.construct.UInt16; | ||
26 | import org.gnunet.construct.UInt32; | ||
27 | import org.gnunet.construct.UInt8; | ||
28 | import org.gnunet.construct.UnionCase; | ||
29 | import org.gnunet.construct.ZeroTerminatedString; | ||
30 | import org.gnunet.util.AbsoluteTimeMessage; | ||
31 | import org.gnunet.util.GnunetMessage; | ||
32 | import org.gnunet.util.PeerIdentity; | ||
33 | |||
34 | @UnionCase(821) | ||
35 | public class IterateMessage implements GnunetMessage.Body { | ||
36 | @UInt16 | ||
37 | public int peer_set; | ||
38 | @NestedMessage | ||
39 | public PeerIdentity peer; | ||
40 | @UInt16 | ||
41 | public int sub_system_size; | ||
42 | @UInt16 | ||
43 | public int key_size; | ||
44 | @UInt16 | ||
45 | public int value_size; | ||
46 | @NestedMessage | ||
47 | public AbsoluteTimeMessage expiry; | ||
48 | @UInt32 | ||
49 | public int options; | ||
50 | @ZeroTerminatedString | ||
51 | public String sub_system; | ||
52 | @ZeroTerminatedString(optional = true) | ||
53 | public String key; | ||
54 | @FillWith | ||
55 | @UInt8 | ||
56 | public byte[] value; | ||
57 | } | ||
diff --git a/src/main/java/org/gnunet/peerstore/messages/IterateRecordMessage.java b/src/main/java/org/gnunet/peerstore/messages/IterateRecordMessage.java new file mode 100644 index 0000000..b595b88 --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/messages/IterateRecordMessage.java | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | package org.gnunet.peerstore.messages; | ||
22 | |||
23 | import org.gnunet.construct.FillWith; | ||
24 | import org.gnunet.construct.NestedMessage; | ||
25 | import org.gnunet.construct.UInt16; | ||
26 | import org.gnunet.construct.UInt32; | ||
27 | import org.gnunet.construct.UInt8; | ||
28 | import org.gnunet.construct.UnionCase; | ||
29 | import org.gnunet.construct.ZeroTerminatedString; | ||
30 | import org.gnunet.util.AbsoluteTimeMessage; | ||
31 | import org.gnunet.util.GnunetMessage; | ||
32 | import org.gnunet.util.PeerIdentity; | ||
33 | |||
34 | @UnionCase(822) | ||
35 | public class IterateRecordMessage implements GnunetMessage.Body { | ||
36 | @UInt16 | ||
37 | public int peer_set; | ||
38 | @NestedMessage | ||
39 | public PeerIdentity peer; | ||
40 | @UInt16 | ||
41 | public int sub_system_size; | ||
42 | @UInt16 | ||
43 | public int key_size; | ||
44 | @UInt16 | ||
45 | public int value_size; | ||
46 | @NestedMessage | ||
47 | public AbsoluteTimeMessage expiry; | ||
48 | @UInt32 | ||
49 | public int options; | ||
50 | @ZeroTerminatedString | ||
51 | public String sub_system; | ||
52 | @ZeroTerminatedString | ||
53 | public String key; | ||
54 | @FillWith | ||
55 | @UInt8 | ||
56 | public byte[] value; | ||
57 | } | ||
diff --git a/src/main/java/org/gnunet/peerstore/messages/StoreMessage.java b/src/main/java/org/gnunet/peerstore/messages/StoreMessage.java new file mode 100644 index 0000000..632d562 --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/messages/StoreMessage.java | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | package org.gnunet.peerstore.messages; | ||
22 | |||
23 | import org.gnunet.construct.FillWith; | ||
24 | import org.gnunet.construct.NestedMessage; | ||
25 | import org.gnunet.construct.UInt16; | ||
26 | import org.gnunet.construct.UInt32; | ||
27 | import org.gnunet.construct.UInt8; | ||
28 | import org.gnunet.construct.UnionCase; | ||
29 | import org.gnunet.construct.ZeroTerminatedString; | ||
30 | import org.gnunet.util.AbsoluteTimeMessage; | ||
31 | import org.gnunet.util.GnunetMessage; | ||
32 | import org.gnunet.util.PeerIdentity; | ||
33 | |||
34 | @UnionCase(820) | ||
35 | public class StoreMessage implements GnunetMessage.Body { | ||
36 | @UInt16 | ||
37 | public int peer_set; | ||
38 | @NestedMessage | ||
39 | public PeerIdentity peer; | ||
40 | @UInt16 | ||
41 | public int sub_system_size; | ||
42 | @UInt16 | ||
43 | public int key_size; | ||
44 | @UInt16 | ||
45 | public int value_size; | ||
46 | @NestedMessage | ||
47 | public AbsoluteTimeMessage expiry; | ||
48 | @UInt32 | ||
49 | public int options; | ||
50 | @ZeroTerminatedString | ||
51 | public String sub_system; | ||
52 | @ZeroTerminatedString | ||
53 | public String key; | ||
54 | @FillWith | ||
55 | @UInt8 | ||
56 | public byte[] value; | ||
57 | } | ||
diff --git a/src/main/java/org/gnunet/peerstore/messages/WatchMessage.java b/src/main/java/org/gnunet/peerstore/messages/WatchMessage.java new file mode 100644 index 0000000..34261a7 --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/messages/WatchMessage.java | |||
@@ -0,0 +1,12 @@ | |||
1 | package org.gnunet.peerstore.messages; | ||
2 | |||
3 | import org.gnunet.construct.NestedMessage; | ||
4 | import org.gnunet.construct.UnionCase; | ||
5 | import org.gnunet.util.GnunetMessage; | ||
6 | import org.gnunet.util.HashCode; | ||
7 | |||
8 | @UnionCase(824) | ||
9 | public class WatchMessage implements GnunetMessage.Body { | ||
10 | @NestedMessage | ||
11 | public HashCode keyhash; | ||
12 | } | ||
diff --git a/src/main/java/org/gnunet/peerstore/messages/WatchRecordMessage.java b/src/main/java/org/gnunet/peerstore/messages/WatchRecordMessage.java new file mode 100644 index 0000000..4ed6422 --- /dev/null +++ b/src/main/java/org/gnunet/peerstore/messages/WatchRecordMessage.java | |||
@@ -0,0 +1,37 @@ | |||
1 | package org.gnunet.peerstore.messages; | ||
2 | |||
3 | import org.gnunet.construct.FillWith; | ||
4 | import org.gnunet.construct.NestedMessage; | ||
5 | import org.gnunet.construct.UInt16; | ||
6 | import org.gnunet.construct.UInt32; | ||
7 | import org.gnunet.construct.UInt8; | ||
8 | import org.gnunet.construct.UnionCase; | ||
9 | import org.gnunet.construct.ZeroTerminatedString; | ||
10 | import org.gnunet.util.AbsoluteTimeMessage; | ||
11 | import org.gnunet.util.GnunetMessage; | ||
12 | import org.gnunet.util.PeerIdentity; | ||
13 | |||
14 | @UnionCase(825) | ||
15 | public class WatchRecordMessage implements GnunetMessage.Body { | ||
16 | @UInt16 | ||
17 | public int peer_set; | ||
18 | @NestedMessage | ||
19 | public PeerIdentity peer; | ||
20 | @UInt16 | ||
21 | public int sub_system_size; | ||
22 | @UInt16 | ||
23 | public int key_size; | ||
24 | @UInt16 | ||
25 | public int value_size; | ||
26 | @NestedMessage | ||
27 | public AbsoluteTimeMessage expiry; | ||
28 | @UInt32 | ||
29 | public int options; | ||
30 | @ZeroTerminatedString | ||
31 | public String sub_system; | ||
32 | @ZeroTerminatedString | ||
33 | public String key; | ||
34 | @FillWith | ||
35 | @UInt8 | ||
36 | public byte[] value; | ||
37 | } | ||
diff --git a/src/main/resources/org/gnunet/construct/MsgMap.txt b/src/main/resources/org/gnunet/construct/MsgMap.txt index 6e1aacf..1515f50 100644 --- a/src/main/resources/org/gnunet/construct/MsgMap.txt +++ b/src/main/resources/org/gnunet/construct/MsgMap.txt | |||
@@ -1,15 +1,21 @@ | |||
1 | org.gnunet.util.Resolver$Address|0=org.gnunet.util.Resolver$TextualAddress | 1 | org.gnunet.util.Resolver$Address|0=org.gnunet.util.Resolver$TextualAddress |
2 | org.gnunet.util.Resolver$Address|1=org.gnunet.util.Resolver$NumericAddress | 2 | org.gnunet.util.Resolver$Address|1=org.gnunet.util.Resolver$NumericAddress |
3 | org.gnunet.util.GnunetMessage$Body|821=org.gnunet.peerstore.messages.IterateMessage | ||
3 | org.gnunet.util.GnunetMessage$Body|274=org.gnunet.cadet.messages.TunnelDestroyMessage | 4 | org.gnunet.util.GnunetMessage$Body|274=org.gnunet.cadet.messages.TunnelDestroyMessage |
5 | org.gnunet.util.GnunetMessage$Body|820=org.gnunet.peerstore.messages.StoreMessage | ||
4 | org.gnunet.util.GnunetMessage$Body|1=org.gnunet.util.TestMessage | 6 | org.gnunet.util.GnunetMessage$Body|1=org.gnunet.util.TestMessage |
5 | org.gnunet.util.GnunetMessage$Body|273=org.gnunet.cadet.messages.TunnelCreateMessage | 7 | org.gnunet.util.GnunetMessage$Body|273=org.gnunet.cadet.messages.TunnelCreateMessage |
8 | org.gnunet.util.GnunetMessage$Body|823=org.gnunet.peerstore.messages.IterateEndMessage | ||
6 | org.gnunet.util.GnunetMessage$Body|272=org.gnunet.cadet.messages.ClientConnectMessage | 9 | org.gnunet.util.GnunetMessage$Body|272=org.gnunet.cadet.messages.ClientConnectMessage |
10 | org.gnunet.util.GnunetMessage$Body|822=org.gnunet.peerstore.messages.IterateRecordMessage | ||
7 | org.gnunet.util.GnunetMessage$Body|4=org.gnunet.util.Resolver$GetMessage | 11 | org.gnunet.util.GnunetMessage$Body|4=org.gnunet.util.Resolver$GetMessage |
8 | org.gnunet.util.GnunetMessage$Body|5=org.gnunet.util.Resolver$ResolverResponse | 12 | org.gnunet.util.GnunetMessage$Body|5=org.gnunet.util.Resolver$ResolverResponse |
9 | org.gnunet.util.GnunetMessage$Body|276=org.gnunet.cadet.RejectMessage | 13 | org.gnunet.util.GnunetMessage$Body|276=org.gnunet.cadet.RejectMessage |
10 | org.gnunet.util.GnunetMessage$Body|10=org.gnunet.arm.messages.ResultMessage | 14 | org.gnunet.util.GnunetMessage$Body|10=org.gnunet.arm.messages.ResultMessage |
11 | org.gnunet.util.GnunetMessage$Body|11=org.gnunet.arm.messages.StatusMessage | 15 | org.gnunet.util.GnunetMessage$Body|11=org.gnunet.arm.messages.StatusMessage |
16 | org.gnunet.util.GnunetMessage$Body|825=org.gnunet.peerstore.messages.WatchRecordMessage | ||
12 | org.gnunet.util.GnunetMessage$Body|286=org.gnunet.cadet.messages.LocalAckMessage | 17 | org.gnunet.util.GnunetMessage$Body|286=org.gnunet.cadet.messages.LocalAckMessage |
18 | org.gnunet.util.GnunetMessage$Body|824=org.gnunet.peerstore.messages.WatchMessage | ||
13 | org.gnunet.util.GnunetMessage$Body|13=org.gnunet.arm.messages.ListResultMessage | 19 | org.gnunet.util.GnunetMessage$Body|13=org.gnunet.arm.messages.ListResultMessage |
14 | org.gnunet.util.GnunetMessage$Body|285=org.gnunet.cadet.DataMessage | 20 | org.gnunet.util.GnunetMessage$Body|285=org.gnunet.cadet.DataMessage |
15 | org.gnunet.util.GnunetMessage$Body|17=org.gnunet.hello.HelloMessage | 21 | org.gnunet.util.GnunetMessage$Body|17=org.gnunet.hello.HelloMessage |
@@ -48,11 +54,11 @@ org.gnunet.util.GnunetMessage$Body|626=org.gnunet.identity.messages.UpdateListMe | |||
48 | org.gnunet.util.GnunetMessage$Body|625=org.gnunet.identity.messages.ResultCodeMessage | 54 | org.gnunet.util.GnunetMessage$Body|625=org.gnunet.identity.messages.ResultCodeMessage |
49 | org.gnunet.util.GnunetMessage$Body|624=org.gnunet.identity.messages.StartMessage | 55 | org.gnunet.util.GnunetMessage$Body|624=org.gnunet.identity.messages.StartMessage |
50 | org.gnunet.util.GnunetMessage$Body|631=org.gnunet.identity.messages.DeleteMessage | 56 | org.gnunet.util.GnunetMessage$Body|631=org.gnunet.identity.messages.DeleteMessage |
51 | org.gnunet.util.GnunetMessage$Body|323=org.gnunet.nse.UpdateMessage | ||
52 | org.gnunet.util.GnunetMessage$Body|630=org.gnunet.identity.messages.RenameMessage | 57 | org.gnunet.util.GnunetMessage$Body|630=org.gnunet.identity.messages.RenameMessage |
58 | org.gnunet.util.GnunetMessage$Body|323=org.gnunet.nse.UpdateMessage | ||
53 | org.gnunet.util.GnunetMessage$Body|629=org.gnunet.identity.messages.CreateRequestMessage | 59 | org.gnunet.util.GnunetMessage$Body|629=org.gnunet.identity.messages.CreateRequestMessage |
54 | org.gnunet.util.GnunetMessage$Body|321=org.gnunet.nse.StartMessage | ||
55 | org.gnunet.util.GnunetMessage$Body|628=org.gnunet.identity.messages.SetDefaultMessage | 60 | org.gnunet.util.GnunetMessage$Body|628=org.gnunet.identity.messages.SetDefaultMessage |
61 | org.gnunet.util.GnunetMessage$Body|321=org.gnunet.nse.StartMessage | ||
56 | org.gnunet.util.GnunetMessage$Body|332=org.gnunet.peerinfo.messages.InfoMessage | 62 | org.gnunet.util.GnunetMessage$Body|332=org.gnunet.peerinfo.messages.InfoMessage |
57 | org.gnunet.util.GnunetMessage$Body|333=org.gnunet.peerinfo.messages.InfoEnd | 63 | org.gnunet.util.GnunetMessage$Body|333=org.gnunet.peerinfo.messages.InfoEnd |
58 | org.gnunet.util.GnunetMessage$Body|331=org.gnunet.peerinfo.messages.ListAllPeersMessage | 64 | org.gnunet.util.GnunetMessage$Body|331=org.gnunet.peerinfo.messages.ListAllPeersMessage |
@@ -103,4 +109,4 @@ org.gnunet.util.GnunetMessage$Body|495=org.gnunet.testbed.messages.HelperInitMes | |||
103 | org.gnunet.util.GnunetMessage$Body|483=org.gnunet.testbed.messages.ManagePeerServiceMessage | 109 | org.gnunet.util.GnunetMessage$Body|483=org.gnunet.testbed.messages.ManagePeerServiceMessage |
104 | org.gnunet.gns.records.RecordData|1=org.gnunet.gns.records.ARecordData | 110 | org.gnunet.gns.records.RecordData|1=org.gnunet.gns.records.ARecordData |
105 | org.gnunet.gns.records.RecordData|65536=org.gnunet.gns.records.PkeyRecordData | 111 | org.gnunet.gns.records.RecordData|65536=org.gnunet.gns.records.PkeyRecordData |
106 | # generated 2014/08/04 20:04:04 | 112 | # generated 2014/08/25 00:32:19 |