aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_cadet_service.h2
-rw-r--r--src/include/gnunet_common.h26
-rw-r--r--src/include/gnunet_crypto_lib.h16
3 files changed, 28 insertions, 16 deletions
diff --git a/src/include/gnunet_cadet_service.h b/src/include/gnunet_cadet_service.h
index b8326657d..da914ac9e 100644
--- a/src/include/gnunet_cadet_service.h
+++ b/src/include/gnunet_cadet_service.h
@@ -89,7 +89,7 @@ struct GNUNET_CADET_ChannelTunnelNumber
89 * Given two peers, both may initiate channels over the same tunnel. 89 * Given two peers, both may initiate channels over the same tunnel.
90 * The @e cn must be greater or equal to 0x80000000 (high-bit set) 90 * The @e cn must be greater or equal to 0x80000000 (high-bit set)
91 * for tunnels initiated with the peer that has the larger peer 91 * for tunnels initiated with the peer that has the larger peer
92 * identity as compared using #GNUNET_CRYPTO_cmp_peer_identity(). 92 * identity as compared using #GNUNET_memcmp().
93 */ 93 */
94 uint32_t cn GNUNET_PACKED; 94 uint32_t cn GNUNET_PACKED;
95}; 95};
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index ca49d3109..773ff8f3e 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -913,6 +913,32 @@ GNUNET_ntoh_double (double d);
913 */ 913 */
914#define GNUNET_new(type) (type *) GNUNET_malloc (sizeof (type)) 914#define GNUNET_new(type) (type *) GNUNET_malloc (sizeof (type))
915 915
916
917/**
918 * Compare memory in @a a and @a b, where both must be of
919 * the same pointer type.
920 */
921#define GNUNET_memcmp(a,b) ({ \
922 typeof(b) _a = (a); \
923 typeof(a) _b = (b); \
924 memcmp(_a, \
925 _b, \
926 sizeof (*a)); })
927
928
929/**
930 * Check that memory in @a a is all zeros. @a a must be a pointer.
931 *
932 * @param a pointer to a struct which should be tested for the
933 * entire memory being zero'ed out.
934 */
935#define GNUNET_is_zero(a) ({ \
936 typeof(*a) _z = { 0 }; \
937 memcmp(a, \
938 &_z, \
939 sizeof (_z)); })
940
941
916/** 942/**
917 * Call memcpy() but check for @a n being 0 first. In the latter 943 * Call memcpy() but check for @a n being 0 first. In the latter
918 * case, it is now safe to pass NULL for @a src or @a dst. 944 * case, it is now safe to pass NULL for @a src or @a dst.
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 6a9eddd7c..c6ae943b9 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -1355,20 +1355,6 @@ GNUNET_CRYPTO_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *cfg,
1355 1355
1356 1356
1357/** 1357/**
1358 * Compare two Peer Identities.
1359 *
1360 * @param first first peer identity
1361 * @param second second peer identity
1362 * @return bigger than 0 if first > second,
1363 * 0 if they are the same
1364 * smaller than 0 if second > first
1365 */
1366int
1367GNUNET_CRYPTO_cmp_peer_identity (const struct GNUNET_PeerIdentity *first,
1368 const struct GNUNET_PeerIdentity *second);
1369
1370
1371/**
1372 * Internal structure used to cache pre-calculated values for DLOG calculation. 1358 * Internal structure used to cache pre-calculated values for DLOG calculation.
1373 */ 1359 */
1374struct GNUNET_CRYPTO_EccDlogContext; 1360struct GNUNET_CRYPTO_EccDlogContext;
@@ -1397,7 +1383,7 @@ struct GNUNET_CRYPTO_EccPoint
1397 */ 1383 */
1398struct GNUNET_CRYPTO_EccDlogContext * 1384struct GNUNET_CRYPTO_EccDlogContext *
1399GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, 1385GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max,
1400 unsigned int mem); 1386 unsigned int mem);
1401 1387
1402 1388
1403/** 1389/**