gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: implement notfiy_client_dk_add


From: gnunet
Subject: [taler-exchange] branch master updated: implement notfiy_client_dk_add
Date: Sun, 15 Nov 2020 12:27:28 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new bf7a660e implement notfiy_client_dk_add
bf7a660e is described below

commit bf7a660ec0278e56eea0bce413c61a2ba0daeca2
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Nov 15 12:27:26 2020 +0100

    implement notfiy_client_dk_add
---
 src/util/Makefile.am               |  1 +
 src/util/taler-helper-crypto-rsa.c | 58 +++++++++++++++++++++++++++++++++-----
 src/util/taler-helper-crypto-rsa.h |  2 +-
 3 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 991f0a95..e8ad9c4d 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -38,6 +38,7 @@ taler_helper_crypto_rsa_SOURCES = \
 taler_helper_crypto_rsa_LDADD = \
   libtalerutil.la \
   -lgnunetutil \
+  -lpthread \
   $(LIBGCRYPT_LIBS) \
   $(XLIB)
 
diff --git a/src/util/taler-helper-crypto-rsa.c 
b/src/util/taler-helper-crypto-rsa.c
index a4e08221..a26ac3f4 100644
--- a/src/util/taler-helper-crypto-rsa.c
+++ b/src/util/taler-helper-crypto-rsa.c
@@ -290,25 +290,69 @@ read_job (void *cls)
 /**
  * Notify @a client about @a dk becoming available.
  *
- * @param client the client to notify
+ * @param[in,out] client the client to notify; possible freed if transmission 
fails
  * @param dk the key to notify @a client about
  * @return #GNUNET_OK on success
  */
 static int
-notify_client_dk_add (const struct Client *client,
+notify_client_dk_add (struct Client *client,
                       const struct DenominationKey *dk)
 {
   struct TALER_CRYPTO_RsaKeyAvailableNotification *an;
-
-  // FIXME: send msg!
-  return GNUNET_SYSERR;
+  struct Denomination *denom = dk->denom;
+  size_t nlen = strlen (denom->section) + 1;
+  size_t buf_len;
+  void *buf;
+  void *p;
+  ssize_t ret;
+  size_t tlen;
+
+  buf_len = GNUNET_CRYPTO_rsa_public_key_encode (dk->denom_pub.rsa_public_key,
+                                                 &buf);
+  GNUNET_assert (buf_len < UINT16_MAX);
+  GNUNET_assert (nlen < UINT16_MAX);
+  tlen = buf_len + nlen + sizeof (*an);
+  GNUNET_assert (tlen < UINT16_MAX);
+  an = GNUNET_malloc (tlen);
+  an->header.size = htons ((uint16_t) tlen);
+  an->header.type = htons (TALER_HELPER_RSA_MT_AVAIL);
+  an->pub_size = htons ((uint16_t) buf_len);
+  an->section_name_len = htons ((uint16_t) nlen);
+  an->anchor_time = GNUNET_TIME_absolute_hton (dk->anchor);
+  an->duration_withdraw = GNUNET_TIME_relative_hton (denom->duration_withdraw);
+  p = (void *) &an[1];
+  memcpy (p,
+          buf,
+          buf_len);
+  GNUNET_free (buf);
+  memcpy (p + buf_len,
+          denom->section,
+          nlen);
+  ret = send (GNUNET_NETWORK_get_fd (client->sock),
+              an,
+              tlen,
+              0);
+  if (tlen != ret)
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
+                         "send");
+    GNUNET_free (an);
+    GNUNET_NETWORK_socket_close (client->sock);
+    GNUNET_CONTAINER_DLL_remove (clients_head,
+                                 clients_tail,
+                                 client);
+    GNUNET_free (client);
+    return GNUNET_SYSERR;
+  }
+  GNUNET_free (an);
+  return GNUNET_OK;
 }
 
 
 /**
  * Notify @a client about @a dk being purged.
  *
- * @param client the client to notify
+ * @param[in,out] client the client to notify; possible freed if transmission 
fails
  * @param dk the key to notify @a client about
  * @return #GNUNET_OK on success
  */
@@ -1246,7 +1290,7 @@ main (int argc,
   };
   int ret;
 
-  umask (S_IWGRP | S_IROTH | S_IWOTH | S_IXOTH);
+  (void) umask (S_IWGRP | S_IROTH | S_IWOTH | S_IXOTH);
   /* force linker to link against libtalerutil; if we do
    not do this, the linker may "optimize" libtalerutil
    away and skip #TALER_OS_init(), which we do need */
diff --git a/src/util/taler-helper-crypto-rsa.h 
b/src/util/taler-helper-crypto-rsa.h
index 6dbf26af..3715c17c 100644
--- a/src/util/taler-helper-crypto-rsa.h
+++ b/src/util/taler-helper-crypto-rsa.h
@@ -44,7 +44,7 @@ struct TALER_CRYPTO_RsaKeyAvailableNotification
   /**
    * Number of bytes of the section name.
    */
-  uint16_t section_name;
+  uint16_t section_name_len;
 
   /**
    * When does the key become available?

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]