From ac32a52c1fa71735c4f12cdc831458304763bde8 Mon Sep 17 00:00:00 2001 From: Omar Tarabai Date: Sun, 24 Aug 2014 22:44:35 +0000 Subject: peerstore java port --- .../java/org/gnunet/peerstore/IterateRequest.java | 72 +++++++ src/main/java/org/gnunet/peerstore/Peerstore.java | 220 +++++++++++++++++++++ .../org/gnunet/peerstore/PeerstoreReceiver.java | 43 ++++ .../org/gnunet/peerstore/PeerstoreWatcher.java | 10 + .../java/org/gnunet/peerstore/StoreOption.java | 43 ++++ .../java/org/gnunet/peerstore/WatchRequest.java | 77 ++++++++ .../peerstore/messages/IterateEndMessage.java | 29 +++ .../gnunet/peerstore/messages/IterateMessage.java | 57 ++++++ .../peerstore/messages/IterateRecordMessage.java | 57 ++++++ .../gnunet/peerstore/messages/StoreMessage.java | 57 ++++++ .../gnunet/peerstore/messages/WatchMessage.java | 12 ++ .../peerstore/messages/WatchRecordMessage.java | 37 ++++ src/main/resources/org/gnunet/construct/MsgMap.txt | 12 +- 13 files changed, 723 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/gnunet/peerstore/IterateRequest.java create mode 100644 src/main/java/org/gnunet/peerstore/Peerstore.java create mode 100644 src/main/java/org/gnunet/peerstore/PeerstoreReceiver.java create mode 100644 src/main/java/org/gnunet/peerstore/PeerstoreWatcher.java create mode 100644 src/main/java/org/gnunet/peerstore/StoreOption.java create mode 100644 src/main/java/org/gnunet/peerstore/WatchRequest.java create mode 100644 src/main/java/org/gnunet/peerstore/messages/IterateEndMessage.java create mode 100644 src/main/java/org/gnunet/peerstore/messages/IterateMessage.java create mode 100644 src/main/java/org/gnunet/peerstore/messages/IterateRecordMessage.java create mode 100644 src/main/java/org/gnunet/peerstore/messages/StoreMessage.java create mode 100644 src/main/java/org/gnunet/peerstore/messages/WatchMessage.java create mode 100644 src/main/java/org/gnunet/peerstore/messages/WatchRecordMessage.java 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 @@ +/* + This file is part of GNUnet. + (C) 2011, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.peerstore; + +import org.gnunet.mq.Envelope; +import org.gnunet.peerstore.messages.IterateMessage; +import org.gnunet.requests.Request; +import org.gnunet.util.AbsoluteTimeMessage; +import org.gnunet.util.PeerIdentity; + +class IterateRequest extends Request { + private final String sub_system; + private final PeerIdentity peer; + private final String key; + public final PeerstoreReceiver receiver; + + public IterateRequest(String sub_system, PeerIdentity peer, String key, + PeerstoreReceiver receiver) { + this.sub_system = sub_system; + this.peer = peer; + this.key = key; + this.receiver = receiver; + } + + @Override + public Envelope assembleRequest() { + IterateMessage im = new IterateMessage(); + im.sub_system_size = this.sub_system.length() + 1; + im.sub_system = this.sub_system; + if (null == this.peer) { + im.peer_set = 0; + im.peer = new PeerIdentity(); + } else { + im.peer_set = 1; + im.peer = peer; + } + if (null == this.key) { + im.key = null; + im.key_size = 0; + } else { + im.key_size = this.key.length() + 1; + im.key = this.key; + } + im.value_size = 0; + im.value = new byte[0]; + im.expiry = new AbsoluteTimeMessage(); + im.options = 0; + return new Envelope(im); + } + + public void cancel() { + } + +} 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 @@ +/* + This file is part of GNUnet. + (C) 2011, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.peerstore; + +import org.gnunet.peerstore.messages.IterateEndMessage; +import org.gnunet.peerstore.messages.IterateRecordMessage; +import org.gnunet.peerstore.messages.StoreMessage; +import org.gnunet.peerstore.messages.WatchRecordMessage; +import org.gnunet.requests.MatchingRequestContainer; +import org.gnunet.requests.RequestIdentifier; +import org.gnunet.requests.SequentialRequestContainer; +import org.gnunet.requests.TimeoutHandler; +import org.gnunet.util.*; + +/** + * API for the GNUnet peerstore service. + */ +public class Peerstore { + + /** + * Client connecting us to the statistics service. + */ + private Client client; + + /** + * All request to the service for iterating records. + */ + private final SequentialRequestContainer iterateRequests; + + /** + * All requests to the service for watching a value. + */ + private final MatchingRequestContainer watchRequests; + + /** + * Are we currently destroying the client? + */ + private boolean destroyRequested; + + /** + * Messages from the statistics service are dispatched to an instance of + * this class. + */ + public class PeerstoreMessageReceiver extends RunaboutMessageReceiver { + + public void visit(IterateRecordMessage m) { + RequestIdentifier req = iterateRequests + .getRequestIdentifier(); + if (null != req) + req.getRequest().receiver.onReceive(m.sub_system, m.peer, + m.key, m.value, new AbsoluteTime(m.expiry.value)); + } + + public void visit(IterateEndMessage m) { + RequestIdentifier req = iterateRequests + .getRequestIdentifier(); + if (null != req) { + req.retire(); + req.getRequest().receiver.onDone(); + } + } + + public void visit(WatchRecordMessage m) { + RequestIdentifier ri = watchRequests + .getRequestIdentifier(WatchRequest.getHash(m.sub_system, + m.peer, m.key)); + WatchRequest r = ri.getRequest(); + if (null != r) { + r.watcher.onReceive(m.sub_system, m.peer, m.key, m.value, + new AbsoluteTime(m.expiry.value)); + } + } + + @Override + public void handleError() { + if (null == client) + throw new AssertionError(); + if (!destroyRequested) { + client.reconnect(); + iterateRequests.restart(); + watchRequests.restart(); + } + } + + } + + /** + * Create a connection to the peerstore service. + * + * @param cfg + * configuration to use + */ + public Peerstore(Configuration cfg) { + client = new Client("peerstore", cfg); + client.installReceiver(new PeerstoreMessageReceiver()); + iterateRequests = new SequentialRequestContainer(client); + watchRequests = new MatchingRequestContainer( + client); + } + + /** + * Store a new entry in the PEERSTORE. Note that stored entries can be lost + * in some cases such as power failure. + * + * @param sub_system + * name of the sub system + * @param peer + * Peer Identity + * @param key + * entry key + * @param value + * entry value BLOB + * @param expiry + * absolute time after which the entry is (possibly) deleted + * @param options + * options specific to the storage operation + */ + public void store(final String sub_system, final PeerIdentity peer, + final String key, final byte[] value, AbsoluteTime expiry, + StoreOption options) { + if (destroyRequested || client == null) + throw new AssertionError("already destroyed"); + StoreMessage sm = new StoreMessage(); + sm.peer_set = 1; + sm.peer = peer; + sm.sub_system_size = sub_system.length() + 1; + sm.key_size = key.length() + 1; + sm.value_size = value.length; + sm.expiry = new AbsoluteTimeMessage(expiry); + sm.options = options.val; + sm.sub_system = sub_system; + sm.key = key; + sm.value = value; + client.send(sm); + } + + /** + * Iterate over records matching supplied key information + * + * @param sub_system + * name of sub system + * @param peer + * Peer identity (can be NULL) + * @param key + * entry key string (can be NULL) + * @param timeout + * time after which the iterate request is canceled + * @param receiver + * Object that will receive request results + * @return Handle to iteration request + */ + public Cancelable iterate(final String sub_system, final PeerIdentity peer, + final String key, final RelativeTime timeout, + final PeerstoreReceiver receiver) { + if (destroyRequested || client == null) + throw new AssertionError("already destroyed"); + RequestIdentifier identifier = iterateRequests + .addRequest(new IterateRequest(sub_system, peer, key, receiver)); + identifier.setTimeout(timeout, new TimeoutHandler() { + + @Override + public void onTimeout() { + receiver.onTimeout(); + + } + }); + return identifier; + } + + /** + * Request watching a given key User will be notified with any new values + * added to key + * + * @param sub_system + * name of sub system + * @param peer + * Peer identity + * @param key + * entry key string + * @param watcher + * Receiver for watch records + * @return Handle to watch request + */ + public Cancelable watch(final String sub_system, final PeerIdentity peer, + final String key, PeerstoreWatcher watcher) { + if (destroyRequested || null == client) + throw new AssertionError("already destroyed"); + WatchRequest r = new WatchRequest(sub_system, peer, key, watcher); + return watchRequests.addRequest(r.hash, r); + } + + /** + * Destroy handle to the peerstore service. + */ + public void destroy() { // TODO: imeplement syncfirst + if (destroyRequested) + throw new AssertionError("already destroyed"); + destroyRequested = true; + client.disconnect(); + client = null; + } +} 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 @@ +/* + This file is part of GNUnet. + (C) 2011, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.peerstore; + +import org.gnunet.util.AbsoluteTime; +import org.gnunet.util.PeerIdentity; + +public interface PeerstoreReceiver { + /** + * Called when having received a peerstore record from the service. + */ + public void onReceive(String sub_system, PeerIdentity peer, String key, + byte[] value, AbsoluteTime expiry); + + /** + * Called when peerstore request times out. Never called for watchers. + */ + public void onTimeout(); + + /** + * Called when all values for the request have been received. Never called + * for watchers. + */ + public void onDone(); +} 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 @@ +package org.gnunet.peerstore; + +import org.gnunet.util.AbsoluteTime; +import org.gnunet.util.PeerIdentity; + +public interface PeerstoreWatcher { + + public void onReceive(String sub_system, PeerIdentity peer, String key, + byte[] value, AbsoluteTime expiry); +} 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 @@ +/* + This file is part of GNUnet. + (C) 2011, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.peerstore; + +/** + * Options for storing values in PEERSTORE + */ +public enum StoreOption { + /** + * Possibly store multiple values under given key. + */ + MULTIPLE(0), + + /** + * Delete any previous values for the given key before storing the given + * value. + */ + REPLACE(1); + + int val; + + StoreOption(int val) { + this.val = val; + } +} 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 @@ +/* + This file is part of GNUnet. + (C) 2011, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.peerstore; + +import java.nio.ByteBuffer; + +import org.gnunet.mq.Envelope; +import org.gnunet.peerstore.messages.WatchMessage; +import org.gnunet.requests.Request; +import org.gnunet.util.HashCode; +import org.gnunet.util.PeerIdentity; + +class WatchRequest extends Request { + public final String sub_system; + public final PeerIdentity peer; + public final String key; + public final PeerstoreWatcher watcher; + public final HashCode hash; + + public static HashCode getHash(String sub_system, PeerIdentity peer, + String key) { + int block_size = 0; + block_size += sub_system.length() + 1; + block_size += peer.data.length; + block_size += key.length() + 1; + + byte[] block = new byte[block_size]; + ByteBuffer target = ByteBuffer.wrap(block); + target.put(sub_system.getBytes()); + target.put((byte)'\0'); + target.put(peer.data); + target.put(key.getBytes()); + target.put((byte)'\0'); + + return HashCode.hash(block); + } + + public WatchRequest(String sub_system, PeerIdentity peer, String key, + PeerstoreWatcher watcher) { + this.sub_system = sub_system; + this.peer = peer; + this.key = key; + this.watcher = watcher; + this.hash = WatchRequest.getHash(sub_system, peer, key); + } + + @Override + public Envelope assembleRequest() { + WatchMessage wm = new WatchMessage(); + wm.keyhash = this.hash; + return new Envelope(wm); + } + + @Override + public void cancel() { + // TODO: send a watch cancel request + } + +} 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 @@ +/* + This file is part of GNUnet. + (C) 2011, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.peerstore.messages; + +import org.gnunet.construct.UnionCase; +import org.gnunet.util.GnunetMessage; + +@UnionCase(823) +public class IterateEndMessage implements GnunetMessage.Body { + +} 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 @@ +/* + This file is part of GNUnet. + (C) 2011, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.peerstore.messages; + +import org.gnunet.construct.FillWith; +import org.gnunet.construct.NestedMessage; +import org.gnunet.construct.UInt16; +import org.gnunet.construct.UInt32; +import org.gnunet.construct.UInt8; +import org.gnunet.construct.UnionCase; +import org.gnunet.construct.ZeroTerminatedString; +import org.gnunet.util.AbsoluteTimeMessage; +import org.gnunet.util.GnunetMessage; +import org.gnunet.util.PeerIdentity; + +@UnionCase(821) +public class IterateMessage implements GnunetMessage.Body { + @UInt16 + public int peer_set; + @NestedMessage + public PeerIdentity peer; + @UInt16 + public int sub_system_size; + @UInt16 + public int key_size; + @UInt16 + public int value_size; + @NestedMessage + public AbsoluteTimeMessage expiry; + @UInt32 + public int options; + @ZeroTerminatedString + public String sub_system; + @ZeroTerminatedString(optional = true) + public String key; + @FillWith + @UInt8 + public byte[] value; +} 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 @@ +/* + This file is part of GNUnet. + (C) 2011, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.peerstore.messages; + +import org.gnunet.construct.FillWith; +import org.gnunet.construct.NestedMessage; +import org.gnunet.construct.UInt16; +import org.gnunet.construct.UInt32; +import org.gnunet.construct.UInt8; +import org.gnunet.construct.UnionCase; +import org.gnunet.construct.ZeroTerminatedString; +import org.gnunet.util.AbsoluteTimeMessage; +import org.gnunet.util.GnunetMessage; +import org.gnunet.util.PeerIdentity; + +@UnionCase(822) +public class IterateRecordMessage implements GnunetMessage.Body { + @UInt16 + public int peer_set; + @NestedMessage + public PeerIdentity peer; + @UInt16 + public int sub_system_size; + @UInt16 + public int key_size; + @UInt16 + public int value_size; + @NestedMessage + public AbsoluteTimeMessage expiry; + @UInt32 + public int options; + @ZeroTerminatedString + public String sub_system; + @ZeroTerminatedString + public String key; + @FillWith + @UInt8 + public byte[] value; +} 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 @@ +/* + This file is part of GNUnet. + (C) 2011, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.peerstore.messages; + +import org.gnunet.construct.FillWith; +import org.gnunet.construct.NestedMessage; +import org.gnunet.construct.UInt16; +import org.gnunet.construct.UInt32; +import org.gnunet.construct.UInt8; +import org.gnunet.construct.UnionCase; +import org.gnunet.construct.ZeroTerminatedString; +import org.gnunet.util.AbsoluteTimeMessage; +import org.gnunet.util.GnunetMessage; +import org.gnunet.util.PeerIdentity; + +@UnionCase(820) +public class StoreMessage implements GnunetMessage.Body { + @UInt16 + public int peer_set; + @NestedMessage + public PeerIdentity peer; + @UInt16 + public int sub_system_size; + @UInt16 + public int key_size; + @UInt16 + public int value_size; + @NestedMessage + public AbsoluteTimeMessage expiry; + @UInt32 + public int options; + @ZeroTerminatedString + public String sub_system; + @ZeroTerminatedString + public String key; + @FillWith + @UInt8 + public byte[] value; +} 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 @@ +package org.gnunet.peerstore.messages; + +import org.gnunet.construct.NestedMessage; +import org.gnunet.construct.UnionCase; +import org.gnunet.util.GnunetMessage; +import org.gnunet.util.HashCode; + +@UnionCase(824) +public class WatchMessage implements GnunetMessage.Body { + @NestedMessage + public HashCode keyhash; +} 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 @@ +package org.gnunet.peerstore.messages; + +import org.gnunet.construct.FillWith; +import org.gnunet.construct.NestedMessage; +import org.gnunet.construct.UInt16; +import org.gnunet.construct.UInt32; +import org.gnunet.construct.UInt8; +import org.gnunet.construct.UnionCase; +import org.gnunet.construct.ZeroTerminatedString; +import org.gnunet.util.AbsoluteTimeMessage; +import org.gnunet.util.GnunetMessage; +import org.gnunet.util.PeerIdentity; + +@UnionCase(825) +public class WatchRecordMessage implements GnunetMessage.Body { + @UInt16 + public int peer_set; + @NestedMessage + public PeerIdentity peer; + @UInt16 + public int sub_system_size; + @UInt16 + public int key_size; + @UInt16 + public int value_size; + @NestedMessage + public AbsoluteTimeMessage expiry; + @UInt32 + public int options; + @ZeroTerminatedString + public String sub_system; + @ZeroTerminatedString + public String key; + @FillWith + @UInt8 + public byte[] value; +} 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 @@ org.gnunet.util.Resolver$Address|0=org.gnunet.util.Resolver$TextualAddress org.gnunet.util.Resolver$Address|1=org.gnunet.util.Resolver$NumericAddress +org.gnunet.util.GnunetMessage$Body|821=org.gnunet.peerstore.messages.IterateMessage org.gnunet.util.GnunetMessage$Body|274=org.gnunet.cadet.messages.TunnelDestroyMessage +org.gnunet.util.GnunetMessage$Body|820=org.gnunet.peerstore.messages.StoreMessage org.gnunet.util.GnunetMessage$Body|1=org.gnunet.util.TestMessage org.gnunet.util.GnunetMessage$Body|273=org.gnunet.cadet.messages.TunnelCreateMessage +org.gnunet.util.GnunetMessage$Body|823=org.gnunet.peerstore.messages.IterateEndMessage org.gnunet.util.GnunetMessage$Body|272=org.gnunet.cadet.messages.ClientConnectMessage +org.gnunet.util.GnunetMessage$Body|822=org.gnunet.peerstore.messages.IterateRecordMessage org.gnunet.util.GnunetMessage$Body|4=org.gnunet.util.Resolver$GetMessage org.gnunet.util.GnunetMessage$Body|5=org.gnunet.util.Resolver$ResolverResponse org.gnunet.util.GnunetMessage$Body|276=org.gnunet.cadet.RejectMessage org.gnunet.util.GnunetMessage$Body|10=org.gnunet.arm.messages.ResultMessage org.gnunet.util.GnunetMessage$Body|11=org.gnunet.arm.messages.StatusMessage +org.gnunet.util.GnunetMessage$Body|825=org.gnunet.peerstore.messages.WatchRecordMessage org.gnunet.util.GnunetMessage$Body|286=org.gnunet.cadet.messages.LocalAckMessage +org.gnunet.util.GnunetMessage$Body|824=org.gnunet.peerstore.messages.WatchMessage org.gnunet.util.GnunetMessage$Body|13=org.gnunet.arm.messages.ListResultMessage org.gnunet.util.GnunetMessage$Body|285=org.gnunet.cadet.DataMessage 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 org.gnunet.util.GnunetMessage$Body|625=org.gnunet.identity.messages.ResultCodeMessage org.gnunet.util.GnunetMessage$Body|624=org.gnunet.identity.messages.StartMessage org.gnunet.util.GnunetMessage$Body|631=org.gnunet.identity.messages.DeleteMessage -org.gnunet.util.GnunetMessage$Body|323=org.gnunet.nse.UpdateMessage org.gnunet.util.GnunetMessage$Body|630=org.gnunet.identity.messages.RenameMessage +org.gnunet.util.GnunetMessage$Body|323=org.gnunet.nse.UpdateMessage org.gnunet.util.GnunetMessage$Body|629=org.gnunet.identity.messages.CreateRequestMessage -org.gnunet.util.GnunetMessage$Body|321=org.gnunet.nse.StartMessage org.gnunet.util.GnunetMessage$Body|628=org.gnunet.identity.messages.SetDefaultMessage +org.gnunet.util.GnunetMessage$Body|321=org.gnunet.nse.StartMessage org.gnunet.util.GnunetMessage$Body|332=org.gnunet.peerinfo.messages.InfoMessage org.gnunet.util.GnunetMessage$Body|333=org.gnunet.peerinfo.messages.InfoEnd 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 org.gnunet.util.GnunetMessage$Body|483=org.gnunet.testbed.messages.ManagePeerServiceMessage org.gnunet.gns.records.RecordData|1=org.gnunet.gns.records.ARecordData org.gnunet.gns.records.RecordData|65536=org.gnunet.gns.records.PkeyRecordData -# generated 2014/08/04 20:04:04 +# generated 2014/08/25 00:32:19 -- cgit v1.2.3