# Proportional specific settings
# How proportional to preferences is bandwidth distribution in a network
# 1.0: Fair with respect to addresses without preferences
-# > 1.0: The bigger, the more respect is payed to preferences
+# > 1.0: The bigger, the more respect is payed to preferences
PROP_PROPORTIONALITY_FACTOR = 2.00
# Should we stick to existing connections are prefer to switch?
# [1.0...2.0], lower value prefers to switch, bigger value is more tolerant
# Maximum duration for a solution process (both LP and MILP)
# MLP_MAX_DURATION = 3 s
# Maximum numbero of iterations for a solution process (only LP)
-# MLP_MAX_ITERATIONS =
+# MLP_MAX_ITERATIONS =
# Tolerated MIP Gap [0.0 .. 1.0], default 0.025
MLP_MAX_MIP_GAP = 0.025
# Tolerated LP/MIP Gap [0.0 .. 1.0], default 0.025
/**
* How namy messages to send
*/
-#define TOTAL_PACKETS 20000
+#define TOTAL_PACKETS 40000
/**
* How long until we give up on connecting the peers?
*/
static int
peer_respect_cb (void *cls,
- struct GNUNET_PEERSTORE_Record *record,
- char *emsg)
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
struct GSF_ConnectedPeer *cp = cls;
else if (0 == strcmp(proxytype_str, "SOCKS4A"))
proxy_type = CURLPROXY_SOCKS4A;
else if (0 == strcmp(proxytype_str, "SOCKS5_HOSTNAME"))
- proxy_type = CURLPROXY_SOCKS5_HOSTNAME ;
+ proxy_type = CURLPROXY_SOCKS5_HOSTNAME;
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Invalid proxy type: `%s', disabling proxy! Check configuration!\n"),
- proxytype_str);
+ if (0 != strcasecmp (proxytype_str, "NONE"))
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Invalid proxy type: `%s', disabling proxy! Check configuration!\n"),
+ proxytype_str);
GNUNET_free (proxytype_str);
GNUNET_free (proxy);
/*
This file is part of GNUnet
- (C)
+ (C)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
* Delete any previous values for the given key before
* storing the given value.
*/
- GNUNET_PEERSTORE_STOREOPTION_REPLACE = 1,
+ GNUNET_PEERSTORE_STOREOPTION_REPLACE = 1
};
void *value;
/**
- * Size of 'value' BLOB
+ * Size of @e value BLOB
*/
size_t value_size;
struct GNUNET_SERVER_Client *client;
};
+
/**
* Continuation called with a status result.
*
* @param cls closure
* @param success #GNUNET_OK or #GNUNET_SYSERR
*/
-typedef void (*GNUNET_PEERSTORE_Continuation)(void *cls, int success);
+typedef void
+(*GNUNET_PEERSTORE_Continuation)(void *cls, int success);
/**
* Function called by PEERSTORE for each matching record.
* @param emsg error message, or NULL if no errors
* @return #GNUNET_YES to continue iterating, #GNUNET_NO to stop
*/
-typedef int (*GNUNET_PEERSTORE_Processor) (void *cls,
- struct GNUNET_PEERSTORE_Record *record,
- char *emsg);
+typedef int
+(*GNUNET_PEERSTORE_Processor) (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg);
/**
* Connect to the PEERSTORE service.
struct GNUNET_PEERSTORE_Handle *
GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
+
/**
* Disconnect from the PEERSTORE service. Any pending ITERATE and WATCH requests
* will be canceled.
* @param sync_first send any pending STORE requests before disconnecting
*/
void
-GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first);
+GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h,
+ int sync_first);
+
/**
* Store a new entry in the PEERSTORE.
* @param expiry absolute time after which the entry is (possibly) deleted
* @param options options specific to the storage operation
* @param cont Continuation function after the store request is sent
- * @param cont_cls Closure for 'cont'
+ * @param cont_cls Closure for @a cont
*/
struct GNUNET_PEERSTORE_StoreContext *
GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h,
GNUNET_PEERSTORE_Continuation cont,
void *cont_cls);
+
/**
* Cancel a store request
*
void
GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc);
+
/**
* Iterate over records matching supplied key information
*
*/
struct GNUNET_PEERSTORE_IterateContext *
GNUNET_PEERSTORE_iterate (struct GNUNET_PEERSTORE_Handle *h,
- const char *sub_system,
- const struct GNUNET_PeerIdentity *peer,
- const char *key,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_PEERSTORE_Processor callback, void *callback_cls);
+ const char *sub_system,
+ const struct GNUNET_PeerIdentity *peer,
+ const char *key,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_PEERSTORE_Processor callback,
+ void *callback_cls);
+
/**
* Cancel an iterate request
void
GNUNET_PEERSTORE_iterate_cancel (struct GNUNET_PEERSTORE_IterateContext *ic);
+
/**
* Request watching a given key
- * User will be notified with any new values added to key
+ * User will be notified with any new values added to key.
*
* @param h handle to the PEERSTORE service
* @param sub_system name of sub system
*/
struct GNUNET_PEERSTORE_WatchContext *
GNUNET_PEERSTORE_watch (struct GNUNET_PEERSTORE_Handle *h,
- const char *sub_system,
- const struct GNUNET_PeerIdentity *peer,
- const char *key,
- GNUNET_PEERSTORE_Processor callback, void *callback_cls);
+ const char *sub_system,
+ const struct GNUNET_PeerIdentity *peer,
+ const char *key,
+ GNUNET_PEERSTORE_Processor callback,
+ void *callback_cls);
+
/**
* Cancel a watch request
* @param wc handle to the watch request
*/
void
-GNUNET_PEERSTORE_watch_cancel(struct GNUNET_PEERSTORE_WatchContext *wc);
+GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc);
#if 0 /* keep Emacsens' auto-indent happy */
{
* @return #GNUNET_YES to continue iteration
*/
static int
-record_iterator (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+record_iterator (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
struct GNUNET_PEERSTORE_Record *cls_record = cls;
struct StoreRecordMessage *srm;
/**
- * Continuation of store_record called by the peerstore plugin
+ * Continuation of store_record called by the peerstore plugin
*
* @param cls closure
* @param success result
GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Message carrying a PEERSTORE record message
*/
- struct StoreRecordMessage
+struct StoreRecordMessage
{
/**
*/
uint16_t peer_set GNUNET_PACKED;
+ /**
+ * Size of the sub_system string
+ * Allocated at position 0 after this struct
+ */
+ uint16_t sub_system_size GNUNET_PACKED;
+
/**
* Peer Identity
*/
struct GNUNET_PeerIdentity peer;
/**
- * Size of the sub_system string
- * Allocated at position 0 after this struct
+ * Expiry time of entry
*/
- uint16_t sub_system_size GNUNET_PACKED;
+ struct GNUNET_TIME_Absolute expiry GNUNET_PACKED;
/**
* Size of the key string
*/
uint16_t value_size GNUNET_PACKED;
- /**
- * Expiry time of entry
- */
- struct GNUNET_TIME_Absolute expiry GNUNET_PACKED;
-
/**
* Options, needed only in case of a
* store operation
*/
- enum GNUNET_PEERSTORE_StoreOption options GNUNET_PACKED;
+ uint32_t /* enum GNUNET_PEERSTORE_StoreOption */ options GNUNET_PACKED;
};
+
/**
* Message carrying record key hash
*/
*/
struct GNUNET_MessageHeader header;
+ /**
+ * Always 0, for alignment.
+ */
+ uint32_t reserved GNUNET_PACKED;
+
/**
* Hash of a record key
*/
/*
This file is part of GNUnet.
- (C)
+ (C) 2013-2014 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
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-
/**
* @file peerstore/peerstore_api.c
* @brief API for peerstore
* @author Omar Tarabai
+ * @author Christian Grothoff
*/
#include "platform.h"
#include "gnunet_util_lib.h"
* @param cls a 'struct GNUNET_PEERSTORE_WatchContext *'
*/
static void
-watch_request_sent (void *cls);
+watch_request_sent (void *cls)
+{
+ struct GNUNET_PEERSTORE_WatchContext *wc = cls;
+
+ wc->request_sent = GNUNET_YES;
+ wc->ev = NULL;
+}
+
/**
* Callback after MQ envelope is sent
*
- * @param cls a 'struct GNUNET_PEERSTORE_IterateContext *'
+ * @param cls a `struct GNUNET_PEERSTORE_IterateContext *`
*/
static void
-iterate_request_sent (void *cls);
+iterate_request_sent (void *cls)
+{
+ struct GNUNET_PEERSTORE_IterateContext *ic = cls;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Iterate request sent to service.\n");
+ ic->iterating = GNUNET_YES;
+ ic->ev = NULL;
+}
/**
callback_cls = ic->callback_cls;
if (NULL == msg) /* Connection error */
{
-
if (NULL != callback)
callback (callback_cls, NULL,
_("Error communicating with `PEERSTORE' service."));
}
-/**
- * Callback after MQ envelope is sent
- *
- * @param cls a `struct GNUNET_PEERSTORE_IterateContext *`
- */
-static void
-iterate_request_sent (void *cls)
-{
- struct GNUNET_PEERSTORE_IterateContext *ic = cls;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Iterate request sent to service.\n");
- ic->iterating = GNUNET_YES;
- ic->ev = NULL;
-}
-
-
/**
* Called when the iterate request is timedout
*
}
-/**
- * Callback after MQ envelope is sent
- *
- * @param cls a `struct GNUNET_PEERSTORE_WatchContext *`
- */
-static void
-watch_request_sent (void *cls)
-{
- struct GNUNET_PEERSTORE_WatchContext *wc = cls;
-
- wc->request_sent = GNUNET_YES;
- wc->ev = NULL;
-}
-
-
/**
* Cancel a watch request
*
static char *k = "test_peerstore_stress_key";
static char *v = "test_peerstore_stress_val";
-int count = 0;
+static int count = 0;
-void
+static void
disconnect ()
{
if (NULL != h)
}
-void
+static void
store ()
{
GNUNET_PEERSTORE_store (h, ss, &p, k, v, strlen (v) + 1,
static int
-watch_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+watch_cb (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
GNUNET_assert (NULL == emsg);
if (STORES == count)
static char *val = "test_peerstore_api_iterate_val";
static int count = 0;
+
static int
-iter3_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+iter3_cb (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
if (NULL != emsg)
return GNUNET_NO;
static int
-iter2_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+iter2_cb (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
if (NULL != emsg)
return GNUNET_NO;
static int
-iter1_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+iter1_cb (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
if (NULL != emsg)
return GNUNET_NO;
static char *val2 = "test_peerstore_api_store_val2-";
static char *val3 = "test_peerstore_api_store_val3--";
-int count = 0;
+static int count = 0;
-int
-test3_cont2 (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+static int
+test3_cont2 (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
if (NULL != emsg)
return GNUNET_NO;
}
-int
-test2_cont2 (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+static int
+test2_cont2 (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
if (NULL != emsg)
return GNUNET_NO;
}
-int
-test1_cont2 (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+static int
+test1_cont2 (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
if (NULL != emsg)
return GNUNET_NO;
static void
-run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
{
h = GNUNET_PEERSTORE_connect (cfg);
#include "gnunet_testing_lib.h"
#include "gnunet_peerstore_service.h"
-int ok = 1;
+static int ok = 1;
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
static struct GNUNET_PEERSTORE_Handle *h;
static char *key = "test_peerstore_api_store_key";
static char *val = "test_peerstore_api_store_val";
-int
-iterate_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+static int
+iterate_cb (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
const char *rec_val;
* @return #GNUNET_YES to continue iterating, #GNUNET_NO to stop
*/
static int
-peerstore_watch_cb (void *cls, struct GNUNET_PEERSTORE_Record *record,
- char *emsg)
+peerstore_watch_cb (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
struct PeerInfo *peer = cls;
struct GNUNET_SENSOR_DashboardAnomalyEntry *anomaly;
* @return #GNUNET_YES
*/
static int
-sensor_watcher (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+sensor_watcher (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
struct SensorModel *model = cls;
double *val;
* @param cls Closure, ValueInfo struct related to the sensor we are watching
* @param record PEERSTORE new record, NULL if error
* @param emsg Error message, NULL if no error
- * @return GNUNET_YES to continue watching
+ * @return #GNUNET_YES to continue watching
*/
static int
-value_watch_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+value_watch_cb (void *cls,
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
struct ValueInfo *vi = cls;
saddr = NULL;
sock_addr = NULL;
- if ((addrlen < sizeof(struct HttpAddress))
- || (addrlen != http_common_address_get_size (address)))
+ if ( (addrlen < sizeof(struct HttpAddress)) ||
+ (addrlen != http_common_address_get_size (address)) )
{
GNUNET_break(0);
goto handle_error;