summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-09-20 09:00:16 +0200
committert3sserakt <t3ss@posteo.de>2021-09-20 11:10:54 +0200
commitb97b260a0461401b317958002b472ff7ed29fb68 (patch)
tree0681d8e7e91626cdcd22f5724557e39153b45306 /src
parentd5df403e64bbde52c5436165eee5231a1b2f876b (diff)
parent48896731e966376ec6f256e175e0d12cd17afa42 (diff)
Merge branch 'master' of ssh://git.gnunet.org/gnunet
Diffstat (limited to 'src')
-rw-r--r--src/dhtu/Makefile.am12
-rw-r--r--src/dhtu/plugin_dhtu_gnunet.c163
-rw-r--r--src/dhtu/plugin_dhtu_ip.c4
-rw-r--r--src/include/gnunet_common.h8
-rw-r--r--src/include/gnunet_dhtu_plugin.h54
-rw-r--r--src/include/gnunet_hello_lib.h7
-rw-r--r--src/include/gnunet_mq_lib.h21
-rw-r--r--src/include/gnunet_transport_service.h21
-rw-r--r--src/transport/test_transport_port_forward.c2
-rw-r--r--src/util/gnunet-config.c59
10 files changed, 266 insertions, 85 deletions
diff --git a/src/dhtu/Makefile.am b/src/dhtu/Makefile.am
index 72b422812..f4b968526 100644
--- a/src/dhtu/Makefile.am
+++ b/src/dhtu/Makefile.am
@@ -11,6 +11,7 @@ if USE_COVERAGE
endif
plugin_LTLIBRARIES = \
+ libgnunet_plugin_dhtu_gnunet.la \
libgnunet_plugin_dhtu_ip.la
libgnunet_plugin_dhtu_ip_la_SOURCES = \
@@ -22,3 +23,14 @@ libgnunet_plugin_dhtu_ip_la_LIBADD = \
libgnunet_plugin_dhtu_ip_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
+
+
+libgnunet_plugin_dhtu_gnunet_la_SOURCES = \
+ plugin_dhtu_gnunet.c
+libgnunet_plugin_dhtu_gnunet_la_LIBADD = \
+ $(top_builddir)/src/core/libgnunetcore.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(XLIBS) \
+ $(LTLIBINTL)
+libgnunet_plugin_dhtu_gnunet_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
index d6cd75242..ccd329e8e 100644
--- a/src/dhtu/plugin_dhtu_gnunet.c
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -21,11 +21,44 @@
/**
* @author Christian Grothoff
*
- * @file plugin_dhtu_ip.c
+ * @file plugin_dhtu_gnunet.c
* @brief plain IP based DHT network underlay
*/
#include "platform.h"
-#incluce "gnunet_dhtu_plugin.h"
+#include "gnunet_dhtu_plugin.h"
+#include "gnunet_core_service.h"
+
+/**
+ * Handle for a private key used by this underlay.
+ */
+struct GNUNET_DHTU_PrivateKey
+{
+ /**
+ * GNUnet uses eddsa for peers.
+ */
+ struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
+
+};
+
+
+/**
+ * Handle for a public key used by this underlay.
+ */
+struct PublicKey
+{
+
+ /**
+ * Header.
+ */
+ struct GNUNET_DHTU_PublicKey header;
+
+ /**
+ * GNUnet uses eddsa for peers.
+ */
+ struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
+
+};
+
/**
* Opaque handle that the underlay offers for our address to be used when
@@ -47,7 +80,7 @@ struct GNUNET_DHTU_Source
*/
struct GNUNET_DHTU_Target
{
-
+
/**
* Application context for this target.
*/
@@ -94,23 +127,20 @@ struct GNUNET_DHTU_PreferenceHandle
/**
- * Opaque handle for a private key used by this underlay.
- */
-struct GNUNET_DHTU_PrivateKey
-{
- /* we are IP, we do not do crypto */
-};
-
-
-/**
* Closure for all plugin functions.
*/
struct Plugin
{
- /**
+ /**
* Callbacks into the DHT.
*/
struct GNUNET_DHTU_PluginEnvironment *env;
+
+ /**
+ * Handle to the CORE service.
+ */
+ struct GNUNET_CORE_Handle *core;
+
};
@@ -126,10 +156,17 @@ struct Plugin
static ssize_t
ip_sign (void *cls,
const struct GNUNET_DHTU_PrivateKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
void **sig)
{
- return 0;
+ struct GNUNET_CRYPTO_EddsaSignature *es;
+
+ es = GNUNET_new (struct GNUNET_CRYPTO_EddsaSignature);
+ GNUNET_CRYPTO_eddsa_sign_ (&pk->eddsa_priv,
+ purpose,
+ es);
+ *sig = es;
+ return sizeof (*es);
}
@@ -148,11 +185,31 @@ ip_sign (void *cls,
static enum GNUNET_GenericReturnValue
ip_verify (void *cls,
const struct GNUNET_DHTU_PublicKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
const void *sig,
size_t sig_size)
{
- return GNUNET_NO;
+ const struct GNUNET_CRYPTO_EddsaSignature *es = sig;
+ const struct PublicKey *pub;
+
+ GNUNET_assert (sizeof (struct PublicKey) ==
+ ntohs (pk->size));
+ pub = (const struct PublicKey *) pk;
+ if (sizeof (*es) != sig_size)
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_verify_ (ntohl (purpose->purpose),
+ purpose,
+ es,
+ &pub->eddsa_pub))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
}
@@ -174,7 +231,7 @@ ip_try_connect (void *cls,
* Request underlay to keep the connection to @a target alive if possible.
* Hold may be called multiple times to express a strong preference to
* keep a connection, say because a @a target is in multiple tables.
- *
+ *
* @param cls closure
* @param target connection to keep alive
*/
@@ -196,7 +253,7 @@ ip_hold (void *cls,
/**
* Do no long request underlay to keep the connection alive.
- *
+ *
* @param cls closure
* @param target connection to keep alive
*/
@@ -204,7 +261,7 @@ static void
ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
{
struct GNUNET_DHTU_Target *target = ph->target;
-
+
GNUNET_CONTAINER_DLL_remove (target->ph_head,
target->ph_tail,
ph);
@@ -225,7 +282,7 @@ ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
* @param msg_size number of bytes in @a msg
* @param finished_cb function called once transmission is done
* (not called if @a target disconnects, then only the
- * disconnect_cb is called).
+ * disconnect_cb is called).
* @param finished_cb_cls closure for @a finished_cb
*/
static void
@@ -240,6 +297,60 @@ ip_send (void *cls,
}
+
+/**
+ * Method called whenever a given peer connects.
+ *
+ * @param cls closure
+ * @param peer peer identity this notification is about
+ * @return closure associated with @a peer. given to mq callbacks and
+ * #GNUNET_CORE_DisconnectEventHandler
+ */
+static void *
+core_connect_cb (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct GNUNET_MQ_Handle *mq)
+{
+ return NULL;
+}
+
+
+/**
+ * Method called whenever a peer disconnects.
+ *
+ * @param cls closure
+ * @param peer peer identity this notification is about
+ * @param peer_cls closure associated with peer. given in
+ * #GNUNET_CORE_ConnectEventHandler
+ */
+static void
+core_disconnect_cb (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ void *peer_cls)
+{
+}
+
+
+/**
+ * Function called after #GNUNET_CORE_connect has succeeded (or failed
+ * for good). Note that the private key of the peer is intentionally
+ * not exposed here; if you need it, your process should try to read
+ * the private key file directly (which should work if you are
+ * authorized...). Implementations of this function must not call
+ * #GNUNET_CORE_disconnect (other than by scheduling a new task to
+ * do this later).
+ *
+ * @param cls closure
+ * @param my_identity ID of this peer, NULL if we failed
+ */
+static void
+core_init_cb (void *cls,
+ const struct GNUNET_PeerIdentity *my_identity)
+{
+ struct Plugin *plugin = cls;
+}
+
+
/**
* Entry point for the plugin.
*
@@ -252,6 +363,9 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
struct GNUNET_DHTU_PluginEnvironment *env = cls;
struct GNUNET_DHTU_PluginFunctions *api;
struct Plugin *plugin;
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_handler_end ()
+ };
plugin = GNUNET_new (struct Plugin);
plugin->env = env;
@@ -263,6 +377,12 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
api->hold = &ip_hold;
api->drop = &ip_drop;
api->send = &ip_send;
+ plugin->core = GNUNET_CORE_connect (env->cfg,
+ plugin,
+ &core_init_cb,
+ &core_connect_cb,
+ &core_disconnect_cb,
+ handlers);
return api;
}
@@ -279,6 +399,7 @@ libgnunet_plugin_dhtu_gnunet_done (void *cls)
struct GNUNET_DHTU_PluginFunctions *api = cls;
struct Plugin *plugin = api->cls;
+ GNUNET_CORE_disconnect (plugin->core);
GNUNET_free (plugin);
GNUNET_free (api);
return NULL;
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c
index 8593a69ef..ae35adb37 100644
--- a/src/dhtu/plugin_dhtu_ip.c
+++ b/src/dhtu/plugin_dhtu_ip.c
@@ -240,7 +240,7 @@ struct Plugin
static ssize_t
ip_sign (void *cls,
const struct GNUNET_DHTU_PrivateKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
void **sig)
{
return 0;
@@ -262,7 +262,7 @@ ip_sign (void *cls,
static enum GNUNET_GenericReturnValue
ip_verify (void *cls,
const struct GNUNET_DHTU_PublicKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
const void *sig,
size_t sig_size)
{
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index ca3ddceaa..4472d3ee8 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -151,10 +151,10 @@ enum GNUNET_GenericReturnValue
*/
#if __BYTE_ORDER == __LITTLE_ENDIAN
-#if defined(__linux__)
-#define BYTE_SWAP_16(x) __bswap_16 (x)
-#define BYTE_SWAP_32(x) __bswap_32 (x)
-#define BYTE_SWAP_64(x) __bswap_64 (x)
+#ifdef HAVE_BYTESWAP_H
+#define BYTE_SWAP_16(x) bswap_16 (x)
+#define BYTE_SWAP_32(x) bswap_32 (x)
+#define BYTE_SWAP_64(x) bswap_64 (x)
#else
#define BYTE_SWAP_16(x) ((((x) & 0x00ff) << 8) | (((x) & 0xff00) >> 8))
diff --git a/src/include/gnunet_dhtu_plugin.h b/src/include/gnunet_dhtu_plugin.h
index df9729a23..e65318fb5 100644
--- a/src/include/gnunet_dhtu_plugin.h
+++ b/src/include/gnunet_dhtu_plugin.h
@@ -75,42 +75,18 @@ struct GNUNET_DHTU_PublicKey
/* followed by size-2 bytes of the actual public key */
};
-
+
/**
* Hash used by the DHT for keys and peers.
*/
struct GNUNET_DHTU_Hash
{
-
- /**
- * For now, use a 512 bit hash. (To be discussed).
- */
- struct GNUNET_HashCode hc;
-};
-
-/**
- * @brief header of what an DHTU signature signs
- * this must be followed by "size - 8" bytes of
- * the actual signed data
- */
-struct GNUNET_DHTU_SignaturePurpose
-{
/**
- * How many bytes does this signature sign?
- * (including this purpose header); in network
- * byte order (!).
- */
- uint32_t size GNUNET_PACKED;
-
- /**
- * What does this signature vouch for? This
- * must contain a GNUNET_SIGNATURE_PURPOSE_XXX
- * constant (from gnunet_signatures.h). In
- * network byte order!
+ * For now, use a 512 bit hash. (To be discussed).
*/
- uint32_t purpose GNUNET_PACKED;
+ struct GNUNET_HashCode hc;
};
@@ -131,7 +107,7 @@ struct GNUNET_DHTU_PluginEnvironment
*/
void *cls;
- /**
+ /**
* Function to call with new addresses of this peer.
*
* @param cls the closure
@@ -151,7 +127,7 @@ struct GNUNET_DHTU_PluginEnvironment
struct GNUNET_DHTU_Source *source,
void **ctx);
- /**
+ /**
* Function to call with expired addresses of this peer.
*
* @param[in] ctx storage space used by the DHT in association with this address
@@ -160,7 +136,7 @@ struct GNUNET_DHTU_PluginEnvironment
(*address_del_cb)(void *ctx);
/**
- * We have a new estimate on the size of the underlay.
+ * We have a new estimate on the size of the underlay.
*
* @param cls closure
* @param timestamp time when the estimate was received from the server (or created by the server)
@@ -172,7 +148,7 @@ struct GNUNET_DHTU_PluginEnvironment
struct GNUNET_TIME_Absolute timestamp,
double logestimate,
double std_dev);
-
+
/**
* Function to call when we connect to a peer and can henceforth transmit to
* that peer.
@@ -208,7 +184,7 @@ struct GNUNET_DHTU_PluginEnvironment
* @param cls the closure
* @param origin where the message originated from
* @param[in,out] tctx ctx of target address where we received the message from
- * @param[in,out] sctx ctx of our own source address at which we received the message
+ * @param[in,out] sctx ctx of our own source address at which we received the message
* @param message the message we received @param message_size number of
* bytes in @a message
*/
@@ -244,7 +220,7 @@ struct GNUNET_DHTU_PluginFunctions
ssize_t
(*sign)(void *cls,
const struct GNUNET_DHTU_PrivateKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
void **sig);
/**
@@ -262,7 +238,7 @@ struct GNUNET_DHTU_PluginFunctions
enum GNUNET_GenericReturnValue
(*verify)(void *cls,
const struct GNUNET_DHTU_PublicKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
const void *sig,
size_t sig_size);
@@ -281,7 +257,7 @@ struct GNUNET_DHTU_PluginFunctions
* Request underlay to keep the connection to @a target alive if possible.
* Hold may be called multiple times to express a strong preference to
* keep a connection, say because a @a target is in multiple tables.
- *
+ *
* @param cls closure
* @param target connection to keep alive
*/
@@ -291,13 +267,13 @@ struct GNUNET_DHTU_PluginFunctions
/**
* Do no long request underlay to keep the connection alive.
- *
+ *
* @param cls closure
* @param target connection to keep alive
*/
void
(*drop)(struct GNUNET_DHTU_PreferenceHandle *ph);
-
+
/**
* Send message to some other participant over the network. Note that
* sending is not guaranteeing that the other peer actually received the
@@ -310,7 +286,7 @@ struct GNUNET_DHTU_PluginFunctions
* @param msg_size number of bytes in @a msg
* @param finished_cb function called once transmission is done
* (not called if @a target disconnects, then only the
- * disconnect_cb is called).
+ * disconnect_cb is called).
* @param finished_cb_cls closure for @a finished_cb
*/
void
@@ -320,7 +296,7 @@ struct GNUNET_DHTU_PluginFunctions
size_t msg_size,
GNUNET_SCHEDULER_TaskCallback finished_cb,
void *finished_cb_cls);
-
+
};
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h
index fff0045aa..74eca999d 100644
--- a/src/include/gnunet_hello_lib.h
+++ b/src/include/gnunet_hello_lib.h
@@ -268,9 +268,10 @@ GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address,
* @return number of bytes written or 0, #GNUNET_SYSERR to signal the
* end of the iteration.
*/
-typedef ssize_t (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls,
- size_t max,
- void *buf);
+typedef ssize_t
+(*GNUNET_HELLO_GenerateAddressListCallback) (void *cls,
+ size_t max,
+ void *buf);
/**
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h
index 37bba8c1b..765647a98 100644
--- a/src/include/gnunet_mq_lib.h
+++ b/src/include/gnunet_mq_lib.h
@@ -331,9 +331,10 @@ typedef int (*GNUNET_MQ_MessageValidationCallback) (
* @param msg the message to send
* @param impl_state state of the implementation
*/
-typedef void (*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq,
- const struct GNUNET_MessageHeader *msg,
- void *impl_state);
+typedef void
+(*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq,
+ const struct GNUNET_MessageHeader *msg,
+ void *impl_state);
/**
@@ -345,8 +346,9 @@ typedef void (*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq,
* @param mq the message queue to destroy
* @param impl_state state of the implementation
*/
-typedef void (*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq,
- void *impl_state);
+typedef void
+(*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq,
+ void *impl_state);
/**
@@ -355,8 +357,9 @@ typedef void (*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq,
* @param mq message queue
* @param impl_state state specific to the implementation
*/
-typedef void (*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq,
- void *impl_state);
+typedef void
+(*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq,
+ void *impl_state);
/**
@@ -368,7 +371,9 @@ typedef void (*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq,
* @param cls closure
* @param error error code
*/
-typedef void (*GNUNET_MQ_ErrorHandler) (void *cls, enum GNUNET_MQ_Error error);
+typedef void
+(*GNUNET_MQ_ErrorHandler) (void *cls,
+ enum GNUNET_MQ_Error error);
/**
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index d190eff92..545bb28d2 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -115,7 +115,8 @@ struct GNUNET_TRANSPORT_AddressToStringContext;
* if #GNUNET_NO: address was invalid (or not supported)
* if #GNUNET_SYSERR: communication error (IPC error)
*/
-typedef void (*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls,
+typedef void
+(*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls,
const char *address,
int res);
@@ -326,7 +327,8 @@ struct GNUNET_TRANSPORT_PeerMonitoringContext;
* @param state current state this peer is in
* @param state_timeout timeout for the current state of the peer
*/
-typedef void (*GNUNET_TRANSPORT_PeerIterateCallback) (
+typedef void
+(*GNUNET_TRANSPORT_PeerIterateCallback) (
void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
@@ -394,7 +396,8 @@ struct GNUNET_TRANSPORT_Blacklist;
* @param pid peer to approve or disapproave
* @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not
*/
-typedef int (*GNUNET_TRANSPORT_BlacklistCallback) (
+typedef int
+(*GNUNET_TRANSPORT_BlacklistCallback) (
void *cls,
const struct GNUNET_PeerIdentity *pid);
@@ -541,7 +544,8 @@ struct GNUNET_TRANSPORT_SessionInfo
* NULL with @a session being non-NULL if the monitor
* was being cancelled while sessions were active
*/
-typedef void (*GNUNET_TRANSPORT_SessionMonitorCallback) (
+typedef void
+(*GNUNET_TRANSPORT_SessionMonitorCallback) (
void *cls,
struct GNUNET_TRANSPORT_PluginSession *session,
void **session_ctx,
@@ -593,7 +597,8 @@ struct GNUNET_TRANSPORT_CoreHandle;
* @param mq message queue to use to transmit to @a peer
* @return closure to use in MQ handlers
*/
-typedef void *(*GNUNET_TRANSPORT_NotifyConnect) (
+typedef void *
+(*GNUNET_TRANSPORT_NotifyConnect) (
void *cls,
const struct GNUNET_PeerIdentity *peer,
struct GNUNET_MQ_Handle *mq);
@@ -610,7 +615,8 @@ typedef void *(*GNUNET_TRANSPORT_NotifyConnect) (
* @param handlers_cls closure of the handlers, was returned from the
* connect notification callback
*/
-typedef void (*GNUNET_TRANSPORT_NotifyDisconnect) (
+typedef void
+(*GNUNET_TRANSPORT_NotifyDisconnect) (
void *cls,
const struct GNUNET_PeerIdentity *peer,
void *handler_cls);
@@ -632,7 +638,8 @@ typedef void (*GNUNET_TRANSPORT_NotifyDisconnect) (
* @param handlers_cls closure of the handlers, was returned from the
* connect notification callback
*/
-typedef void (*GNUNET_TRANSPORT_NotifyExcessBandwidth) (
+typedef void
+(*GNUNET_TRANSPORT_NotifyExcessBandwidth) (
void *cls,
const struct GNUNET_PeerIdentity *neighbour,
void *handlers_cls);
diff --git a/src/transport/test_transport_port_forward.c b/src/transport/test_transport_port_forward.c
index b0f0b113e..d3233c2da 100644
--- a/src/transport/test_transport_port_forward.c
+++ b/src/transport/test_transport_port_forward.c
@@ -21,7 +21,7 @@
/**
* @file transport/test_transport_port_forward.c
* @brief Test case executing a script which sends a test UDP message from a nated peer
- * to a gloabl known peer. There is a tcp port forwarding in place towards the
+ * to a global known peer. There is a tcp port forwarding in place towards the
* natted peer to test the backchannel functionality of the TNG service.
* @author t3sserakt
*/
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
index 797de0b0d..2ca78577e 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -36,6 +36,25 @@ static char *backend_check;
/**
+ * If printing the value of CFLAGS has been requested.
+ */
+static int cflags;
+
+
+/**
+ * If printing the value of LIBS has been requested.
+ */
+static int libs;
+
+
+/**
+ * If printing the value of PREFIX has been requested.
+ */
+static int prefix;
+
+
+/**
+ * Print each option in a given section.
* Main task to run to perform operations typical for
* gnunet-config as per the configuration settings
* given in @a cls.
@@ -54,6 +73,28 @@ run (void *cls,
{
struct GNUNET_CONFIGURATION_ConfigSettings *cs = cls;
+ if (1 == cflags || 1 == libs || 1 == prefix)
+ {
+ char *prefixdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_PREFIX);
+ char *libdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR);
+
+ if (1 == cflags)
+ {
+ fprintf (stdout, "-I%sinclude\n", prefixdir);
+ }
+ if (1 == libs)
+ {
+ fprintf (stdout, "-L%s -lgnunetutil\n", libdir);
+ }
+ if (1 == prefix)
+ {
+ fprintf (stdout, "%s\n", prefixdir);
+ }
+ cs->global_ret = 0;
+ GNUNET_free (prefixdir);
+ GNUNET_free (libdir);
+ return;
+ }
if (NULL != backend_check)
{
char *name;
@@ -97,6 +138,24 @@ main (int argc,
gettext_noop (
"test if the current installation supports the specified BACKEND"),
&backend_check)),
+ GNUNET_GETOPT_option_flag (
+ 'C',
+ "cflags",
+ gettext_noop (
+ "Provide an appropriate value for CFLAGS to applications building on top of GNUnet"),
+ &cflags),
+ GNUNET_GETOPT_option_flag (
+ 'j',
+ "libs",
+ gettext_noop (
+ "Provide an appropriate value for LIBS to applications building on top of GNUnet"),
+ &libs),
+ GNUNET_GETOPT_option_flag (
+ 'p',
+ "prefix",
+ gettext_noop (
+ "Provide the path under which GNUnet was installed"),
+ &prefix),
GNUNET_CONFIGURATION_CONFIG_OPTIONS (&cs),
GNUNET_GETOPT_OPTION_END
};