gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] 68/171: - merge; service API change


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 68/171: - merge; service API change
Date: Thu, 04 Jan 2018 16:09:36 +0100

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

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit 3cb90c74c5f591fd2541d154a8e7b05a1c2f4539
Merge: 7122f35e2 aedd5919e
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Fri Jan 20 07:00:54 2017 +0100

    - merge; service API change

 AUTHORS                                            |    4 +-
 ChangeLog                                          |    3 +
 README                                             |   15 +-
 configure.ac                                       |   11 +
 contrib/.gitignore                                 |    2 +
 contrib/no_forcestart.conf                         |    3 +
 contrib/ssh-config                                 |   33 +
 contrib/ssh-keys                                   |    1 +
 doc/man/Makefile.am                                |    1 +
 doc/man/gnunet-nat-auto.1                          |   69 +
 doc/man/gnunet-nat.1                               |   29 +-
 doc/man/gnunet-transport.1                         |    3 -
 doc/structure.dot                                  |    5 +-
 po/POTFILES.in                                     |   25 +-
 po/de.po                                           |  710 +++---
 po/es.po                                           |  800 +++----
 po/fr.po                                           |  693 +++---
 po/sv.po                                           |  743 ++++---
 po/vi.po                                           |  740 ++++---
 po/zh_CN.po                                        |  721 ++++---
 src/Makefile.am                                    |   10 +-
 src/arm/.gitignore                                 |    4 +
 src/arm/arm_api.c                                  |    2 +-
 src/arm/arm_monitor_api.c                          |    2 +-
 src/arm/gnunet-arm.c                               |   37 +-
 src/arm/test_exponential_backoff.c                 |    2 +-
 src/ats-tests/.gitignore                           |    6 +
 src/ats-tests/ats-testing.c                        |   25 +-
 src/ats-tests/ats-testing.h                        |   15 +-
 src/ats/.gitignore                                 |    2 +
 src/ats/ats_api_connectivity.c                     |    2 +-
 src/ats/ats_api_performance.c                      |    2 +-
 src/ats/ats_api_scheduling.c                       |    2 +-
 src/auction/.gitignore                             |    5 +
 src/auction/Makefile.am                            |   74 +
 src/auction/auction.conf                           |    4 +
 src/auction/auction.h                              |   77 +
 src/auction/gnunet-auction-create.c                |  197 ++
 src/auction/gnunet-auction-info.c                  |   84 +
 src/auction/gnunet-auction-join.c                  |   84 +
 src/auction/gnunet-service-auction.c               |  155 ++
 src/auction/test_auction_api.c                     |   42 +
 src/auction/test_auction_create.sh                 |   80 +
 src/cadet/Makefile.am                              |   37 +-
 src/cadet/cadet.h                                  |   92 +-
 src/cadet/cadet_api.c                              |  420 ++--
 src/cadet/cadet_common.c                           |   61 +-
 src/cadet/cadet_protocol.h                         |  253 ++-
 src/cadet/gnunet-cadet.c                           |   13 +-
 src/cadet/gnunet-service-cadet-new.c               | 1350 ++++++++++++
 src/cadet/gnunet-service-cadet-new.h               |  264 +++
 src/cadet/gnunet-service-cadet-new_channel.c       | 1077 ++++++++++
 src/cadet/gnunet-service-cadet-new_channel.h       |  191 ++
 src/cadet/gnunet-service-cadet-new_connection.c    |  665 ++++++
 src/cadet/gnunet-service-cadet-new_connection.h    |  196 ++
 src/cadet/gnunet-service-cadet-new_core.c          |  903 ++++++++
 ...det_hello.h => gnunet-service-cadet-new_core.h} |   35 +-
 src/cadet/gnunet-service-cadet-new_dht.c           |  315 +++
 ...adet_hello.h => gnunet-service-cadet-new_dht.h} |   53 +-
 src/cadet/gnunet-service-cadet-new_hello.c         |  142 ++
 ...et_hello.h => gnunet-service-cadet-new_hello.h} |   10 +-
 src/cadet/gnunet-service-cadet-new_paths.c         |  557 +++++
 src/cadet/gnunet-service-cadet-new_paths.h         |  182 ++
 src/cadet/gnunet-service-cadet-new_peer.c          | 1056 +++++++++
 src/cadet/gnunet-service-cadet-new_peer.h          |  368 ++++
 src/cadet/gnunet-service-cadet-new_tunnels.c       | 2249 ++++++++++++++++++++
 src/cadet/gnunet-service-cadet-new_tunnels.h       |  357 ++++
 src/cadet/gnunet-service-cadet_channel.c           |  237 ++-
 src/cadet/gnunet-service-cadet_channel.h           |   16 +-
 src/cadet/gnunet-service-cadet_connection.c        |  518 +++--
 src/cadet/gnunet-service-cadet_connection.h        |   37 +-
 src/cadet/gnunet-service-cadet_dht.c               |   90 +-
 src/cadet/gnunet-service-cadet_hello.h             |    5 +-
 src/cadet/gnunet-service-cadet_local.c             |  207 +-
 src/cadet/gnunet-service-cadet_local.h             |   32 +-
 src/cadet/gnunet-service-cadet_peer.c              |  194 +-
 src/cadet/gnunet-service-cadet_peer.h              |   15 +-
 src/cadet/gnunet-service-cadet_tunnel.c            |  255 +--
 src/cadet/gnunet-service-cadet_tunnel.h            |    8 +-
 src/cadet/test_cadet.conf                          |    5 -
 src/cadet/test_cadet_local.c                       |    5 +-
 src/consensus/consensus_api.c                      |    2 +-
 src/conversation/conversation_api.c                |    2 +-
 src/conversation/conversation_api_call.c           |    2 +-
 src/core/.gitignore                                |    7 +
 src/core/Makefile.am                               |    1 -
 src/core/core_api.c                                |  761 +++----
 src/core/core_api_2.c                              |  865 --------
 src/core/core_api_monitor_peers.c                  |    2 +-
 src/core/core_api_mq.c                             |  191 --
 src/core/test_core_api.c                           |    6 +-
 src/core/test_core_api_reliability.c               |    6 +-
 src/core/test_core_api_send_to_self.c              |    4 +-
 src/core/test_core_api_start_only.c                |   12 +-
 src/core/test_core_defaults.conf                   |    6 -
 src/core/test_core_quota_compliance.c              |    6 +-
 src/credential/credential_api.c                    |    2 +-
 src/datacache/.gitignore                           |    6 +
 src/datacache/plugin_datacache_heap.c              |    3 +-
 src/datastore/.gitignore                           |   14 +
 src/datastore/datastore_api.c                      |    4 +-
 src/datastore/plugin_datastore_heap.c              |    8 +-
 src/dht/.gitignore                                 |    7 +
 src/dht/Makefile.am                                |    6 +-
 src/dht/dht_api.c                                  |    2 +-
 src/dht/gnunet-service-dht_hello.c                 |   20 +-
 src/dht/gnunet-service-dht_neighbours.c            |   16 +-
 src/dht/gnunet-service-dht_routing.c               |   44 +-
 src/dht/gnunet-service-wdht_neighbours.c           |    4 +-
 src/dht/gnunet-service-xdht_neighbours.c           |    4 +-
 src/dht/plugin_block_dht.c                         |   15 +-
 src/dns/.gitignore                                 |    1 +
 src/dns/dns_api.c                                  |    2 +-
 src/dv/dv_api.c                                    |    2 +-
 src/dv/gnunet-service-dv.c                         |    6 +-
 src/exit/gnunet-daemon-exit.c                      |    5 +-
 src/fragmentation/.gitignore                       |    2 +
 src/fs/fs_download.c                               |    2 +-
 src/fs/fs_list_indexed.c                           |    2 +-
 src/fs/fs_publish.c                                |    4 +-
 src/fs/fs_search.c                                 |    2 +-
 src/fs/fs_unindex.c                                |    2 +-
 src/fs/gnunet-service-fs.c                         |    6 +-
 src/gns/gns.conf.in                                |    4 -
 src/gns/gns_api.c                                  |    2 +-
 src/gns/gnunet-service-gns.c                       |  644 +-----
 src/gns/gnunet-service-gns_reverser.c              |    5 +
 src/gnsrecord/.gitignore                           |    4 +
 src/hello/.gitignore                               |    2 +
 src/hostlist/.gitignore                            |    3 +
 src/hostlist/gnunet-daemon-hostlist.c              |   10 +-
 src/hostlist/gnunet-daemon-hostlist_client.c       |    4 +-
 src/hostlist/gnunet-daemon-hostlist_client.h       |    4 +-
 src/hostlist/gnunet-daemon-hostlist_server.c       |    2 +-
 src/hostlist/gnunet-daemon-hostlist_server.h       |    2 +-
 .../test_gnunet_daemon_hostlist_learning.c         |   13 +-
 src/identity-provider/identity_provider_api.c      |    2 +-
 src/identity/.gitignore                            |    2 +
 src/identity/identity_api.c                        |    2 +-
 src/include/Makefile.am                            |    2 +-
 src/include/gnunet_cadet_service.h                 |   55 +-
 src/include/gnunet_client_lib.h                    |    2 +-
 src/include/gnunet_common.h                        |   17 +-
 src/include/gnunet_constants.h                     |    6 +-
 src/include/gnunet_container_lib.h                 |  277 ++-
 src/include/gnunet_core_service.h                  |  142 +-
 src/include/gnunet_crypto_lib.h                    |   28 +-
 src/include/gnunet_mq_lib.h                        |   13 +-
 src/include/gnunet_nat_auto_service.h              |  135 ++
 src/include/gnunet_nat_lib.h                       |  591 -----
 src/include/gnunet_nat_service.h                   |  407 ++--
 src/include/gnunet_peerinfo_service.h              |    2 +-
 src/include/gnunet_protocols.h                     |   66 +-
 src/include/gnunet_signatures.h                    |    5 -
 src/json/.gitignore                                |    1 +
 src/jsonapi/.gitignore                             |    1 +
 src/multicast/gnunet-service-multicast.c           |   54 +-
 src/multicast/multicast_api.c                      |    6 +-
 src/my/.gitignore                                  |    1 +
 src/namecache/.gitignore                           |    4 +
 src/namecache/namecache_api.c                      |    2 +-
 src/namestore/.gitignore                           |   17 +
 src/namestore/namestore_api.c                      |    2 +-
 src/namestore/namestore_api_monitor.c              |    2 +-
 src/nat-auto/.gitignore                            |    3 +
 src/nat-auto/Makefile.am                           |   58 +
 src/nat-auto/gnunet-nat-auto.c                     |  381 ++++
 .../gnunet-nat-auto_legacy.c}                      |    2 +-
 src/{nat => nat-auto}/gnunet-nat-server.c          |   47 +-
 src/nat-auto/gnunet-service-nat-auto.c             |  482 +++++
 .../gnunet-service-nat-auto_legacy.c}              |    2 +-
 src/nat-auto/nat-auto.conf.in                      |   15 +
 src/nat-auto/nat-auto.h                            |  110 +
 src/nat-auto/nat_auto_api.c                        |  273 +++
 .../nat_auto_api_test.c}                           |  164 +-
 src/nat/Makefile.am                                |   81 +-
 src/nat/gnunet-nat.c                               |  301 +--
 src/nat/gnunet-service-nat.c                       | 1186 +++++------
 src/nat/gnunet-service-nat.h                       |   35 +
 src/nat/gnunet-service-nat_externalip.c            |  314 +++
 src/nat/gnunet-service-nat_externalip.h            |   92 +
 src/nat/gnunet-service-nat_helper.c                |   26 +-
 src/nat/gnunet-service-nat_mini.h                  |    2 +-
 src/nat/nat.c                                      | 2054 ------------------
 src/nat/nat.conf.in                                |   38 +-
 src/nat/nat.h                                      |   48 +-
 src/nat/nat_api.c                                  |  271 +--
 src/nat/nat_api_stun.c                             |    8 +-
 src/nat/nat_mini.c                                 |  712 -------
 src/nat/nat_stun.c                                 |  439 ----
 src/nse/.gitignore                                 |    2 +
 src/nse/gnunet-service-nse.c                       |    4 +-
 src/nse/nse_api.c                                  |    2 +-
 src/peerinfo-tool/.gitignore                       |    1 +
 src/peerinfo-tool/Makefile.am                      |    1 -
 src/peerinfo/.gitignore                            |    4 +
 src/peerinfo/peerinfo_api.c                        |    4 +-
 src/peerinfo/peerinfo_api_notify.c                 |    2 +-
 src/peerstore/.gitignore                           |    6 +
 src/peerstore/peerstore_api.c                      |    2 +-
 src/pq/.gitignore                                  |    1 +
 src/psyc/psyc_api.c                                |    6 +-
 src/psycstore/gnunet-service-psycstore.c           |    4 +-
 src/psycstore/psycstore_api.c                      |    2 +-
 src/regex/.gitignore                               |    7 +
 src/regex/regex_api_announce.c                     |    2 +-
 src/regex/regex_api_search.c                       |    2 +-
 src/revocation/gnunet-service-revocation.c         |    4 +-
 src/revocation/revocation_api.c                    |    4 +-
 src/revocation/test_revocation.c                   |    4 +-
 src/rps/rps_api.c                                  |    2 +-
 src/scalarproduct/scalarproduct_api.c              |    4 +-
 src/secretsharing/secretsharing_api.c              |    4 +-
 src/set/Makefile.am                                |    2 +
 src/set/set_api.c                                  |    4 +-
 src/social/gnunet-social.c                         |    2 +-
 src/social/social_api.c                            |   12 +-
 src/statistics/.gitignore                          |    5 +
 src/statistics/statistics_api.c                    |    2 +-
 src/template/.gitignore                            |    1 +
 src/testbed-logger/.gitignore                      |    1 +
 src/testbed-logger/testbed_logger_api.c            |    2 +-
 src/testbed/.gitignore                             |   30 +
 .../gnunet-service-testbed_connectionpool.c        |    8 +-
 src/testbed/testbed_api.c                          |    2 +-
 src/testbed/testbed_api_barriers.c                 |    2 +-
 src/testing/.gitignore                             |    5 +
 src/topology/.gitignore                            |    1 +
 src/topology/gnunet-daemon-topology.c              |    6 +-
 src/transport/.gitignore                           |   76 +
 src/transport/Makefile.am                          |   14 +-
 .../gnunet-service-transport_neighbours.c          |    8 +
 src/transport/gnunet-transport.c                   |  246 +--
 src/transport/plugin_transport_http_server.c       |   25 +-
 src/transport/plugin_transport_tcp.c               |  138 +-
 src/transport/plugin_transport_udp.c               |   71 +-
 src/transport/plugin_transport_udp.h               |    1 -
 src/transport/plugin_transport_udp_broadcasting.c  |    1 -
 src/transport/transport.conf.in                    |   49 +
 src/transport/transport_api_address_to_string.c    |    2 +-
 src/transport/transport_api_blacklist.c            |    2 +-
 src/transport/transport_api_core.c                 |    2 +-
 src/transport/transport_api_hello_get.c            |    2 +-
 src/transport/transport_api_manipulation.c         |    2 +-
 src/transport/transport_api_monitor_peers.c        |    2 +-
 src/transport/transport_api_monitor_plugins.c      |    2 +-
 src/transport/transport_api_offer_hello.c          |    2 +-
 src/tun/.gitignore                                 |    2 +
 src/util/.gitignore                                |   55 +
 src/util/Makefile.am                               |    3 +-
 src/util/{client_new.c => client.c}                |   16 +-
 src/util/common_logging.c                          |   23 +
 src/util/container_heap.c                          |   27 +-
 src/util/container_multishortmap.c                 |  965 +++++++++
 src/util/mq.c                                      |   22 +-
 src/util/resolver_api.c                            |    2 +-
 src/util/test_client.c                             |    4 +-
 src/util/test_container_heap.c                     |   13 +-
 src/util/test_server.c                             |    2 +-
 src/util/test_server_disconnect.c                  |    2 +-
 src/util/test_server_with_client.c                 |    2 +-
 src/util/test_server_with_client_unix.c            |    2 +-
 src/util/test_service.c                            |    2 +-
 src/util/test_socks.c                              |    2 +-
 src/vpn/gnunet-service-vpn.c                       |   12 +-
 src/vpn/vpn.conf.in                                |    2 +-
 src/vpn/vpn_api.c                                  |    2 +-
 src/zonemaster/.gitignore                          |    1 +
 src/zonemaster/Makefile.am                         |   35 +
 .../gnunet-service-zonemaster.c}                   |  579 +----
 .../gns.conf.in => zonemaster/zonemaster.conf.in}  |   30 +-
 271 files changed, 20080 insertions(+), 12274 deletions(-)

diff --cc src/Makefile.am
index 2877cab0b,56f301ac0..120d80a3f
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@@ -109,7 -115,7 +115,8 @@@ SUBDIRS = 
    revocation \
    vpn \
    gns \
 +      credential \
+   zonemaster \
    $(CONVERSATION_DIR) \
    fs \
    exit \
diff --cc src/credential/credential_api.c
index b201d4d9c,000000000..f90bf9630
mode 100644,000000..100644
--- a/src/credential/credential_api.c
+++ b/src/credential/credential_api.c
@@@ -1,513 -1,0 +1,513 @@@
 +/*
 +     This file is part of GNUnet.
 +     Copyright (C) 2009-2013, 2016 GNUnet e.V.
 +
 +     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., 51 Franklin Street, Fifth Floor,
 +     Boston, MA 02110-1301, USA.
 +*/
 +/**
 + * @file credential/credential_api.c
 + * @brief library to access the CREDENTIAL service
 + * @author Adnan Husain
 + */
 +#include "platform.h"
 +#include "gnunet_util_lib.h"
 +#include "gnunet_constants.h"
 +#include "gnunet_arm_service.h"
 +#include "gnunet_hello_lib.h"
 +#include "gnunet_protocols.h"
 +#include "gnunet_signatures.h"
 +#include "credential.h"
 +#include "credential_serialization.h"
 +#include "gnunet_credential_service.h"
 +#include "gnunet_identity_service.h"
 +
 +
 +#define LOG(kind,...) GNUNET_log_from (kind, "credential-api",__VA_ARGS__)
 +
 +/**
 + * Handle to a verify request
 + */
 +struct GNUNET_CREDENTIAL_Request
 +{
 +
 +  /**
 +   * DLL
 +   */
 +  struct GNUNET_CREDENTIAL_Request *next;
 +
 +  /**
 +   * DLL
 +   */
 +  struct GNUNET_CREDENTIAL_Request *prev;
 +
 +  /**
 +   * handle to credential service
 +   */
 +  struct GNUNET_CREDENTIAL_Handle *credential_handle;
 +
 +  /**
 +   * processor to call on verify result
 +   */
 +  GNUNET_CREDENTIAL_CredentialResultProcessor verify_proc;
 +
 +  /**
 +   * @e verify_proc closure
 +   */
 +  void *proc_cls;
 +
 +  /**
 +   * Envelope with the message for this queue entry.
 +   */
 +  struct GNUNET_MQ_Envelope *env;
 +
 +  /**
 +   * request id
 +   */
 +  uint32_t r_id;
 +
 +};
 +
 +
 +/**
 + * Connection to the CREDENTIAL service.
 + */
 +struct GNUNET_CREDENTIAL_Handle
 +{
 +
 +  /**
 +   * Configuration to use.
 +   */
 +  const struct GNUNET_CONFIGURATION_Handle *cfg;
 +
 +  /**
 +   * Connection to service (if available).
 +   */
 +  struct GNUNET_MQ_Handle *mq;
 +
 +  /**
 +   * Head of linked list of active verify requests.
 +   */
 +  struct GNUNET_CREDENTIAL_Request *request_head;
 +
 +  /**
 +   * Tail of linked list of active verify requests.
 +   */
 +  struct GNUNET_CREDENTIAL_Request *request_tail;
 +
 +  /**
 +   * Reconnect task
 +   */
 +  struct GNUNET_SCHEDULER_Task *reconnect_task;
 +
 +  /**
 +   * How long do we wait until we try to reconnect?
 +   */
 +  struct GNUNET_TIME_Relative reconnect_backoff;
 +
 +  /**
 +   * Request Id generator.  Incremented by one for each request.
 +   */
 +  uint32_t r_id_gen;
 +
 +};
 +
 +
 +/**
 + * Reconnect to CREDENTIAL service.
 + *
 + * @param handle the handle to the CREDENTIAL service
 + */
 +static void
 +reconnect (struct GNUNET_CREDENTIAL_Handle *handle);
 +
 +
 +/**
 + * Reconnect to CREDENTIAL
 + *
 + * @param cls the handle
 + */
 +static void
 +reconnect_task (void *cls)
 +{
 +  struct GNUNET_CREDENTIAL_Handle *handle = cls;
 +
 +  handle->reconnect_task = NULL;
 +  reconnect (handle);
 +}
 +
 +
 +/**
 + * Disconnect from service and then reconnect.
 + *
 + * @param handle our handle
 + */
 +static void
 +force_reconnect (struct GNUNET_CREDENTIAL_Handle *handle)
 +{
 +  GNUNET_MQ_destroy (handle->mq);
 +  handle->mq = NULL;
 +  handle->reconnect_backoff
 +    = GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff);
 +  handle->reconnect_task
 +    = GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff,
 +                        &reconnect_task,
 +                        handle);
 +}
 +
 +
 +/**
 + * Generic error handler, called with the appropriate error code and
 + * the same closure specified at the creation of the message queue.
 + * Not every message queue implementation supports an error handler.
 + *
 + * @param cls closure with the `struct GNUNET_CREDENTIAL_Handle *`
 + * @param error error code
 + */
 +static void
 +mq_error_handler (void *cls,
 +                  enum GNUNET_MQ_Error error)
 +{
 +  struct GNUNET_CREDENTIAL_Handle *handle = cls;
 +
 +  force_reconnect (handle);
 +}
 +
 +/**
 + * Check validity of message received from the CREDENTIAL service
 + *
 + * @param cls the `struct GNUNET_CREDENTIAL_Handle *`
 + * @param loookup_msg the incoming message
 + */
 +static int
 +check_result (void *cls,
 +              const struct DelegationChainResultMessage *vr_msg)
 +{
 +  //TODO
 +  return GNUNET_OK;
 +}
 +
 +
 +/**
 + * Handler for messages received from the CREDENTIAL service
 + *
 + * @param cls the `struct GNUNET_CREDENTIAL_Handle *`
 + * @param loookup_msg the incoming message
 + */
 +static void
 +handle_result (void *cls,
 +               const struct DelegationChainResultMessage *vr_msg)
 +{
 +  struct GNUNET_CREDENTIAL_Handle *handle = cls;
 +  uint32_t r_id = ntohl (vr_msg->id);
 +  struct GNUNET_CREDENTIAL_Request *vr;
 +  size_t mlen = ntohs (vr_msg->header.size) - sizeof (*vr_msg);
 +  uint32_t d_count = ntohl (vr_msg->d_count);
 +  uint32_t c_count = ntohl (vr_msg->c_count);
 +  struct GNUNET_CREDENTIAL_Delegation d_chain[d_count];
 +  struct GNUNET_CREDENTIAL_Credential creds[c_count];
 +  GNUNET_CREDENTIAL_CredentialResultProcessor proc;
 +  void *proc_cls;
 +
 +  LOG (GNUNET_ERROR_TYPE_DEBUG,
 +       "Received verify reply from CREDENTIAL service\n");
 +  for (vr = handle->request_head; NULL != vr; vr = vr->next)
 +    if (vr->r_id == r_id)
 +      break;
 +  if (NULL == vr)
 +    return;
 +  proc = vr->verify_proc;
 +  proc_cls = vr->proc_cls;
 +  GNUNET_CONTAINER_DLL_remove (handle->request_head,
 +                               handle->request_tail,
 +                               vr);
 +  GNUNET_MQ_discard (vr->env);
 +  GNUNET_free (vr);
 +  GNUNET_assert (GNUNET_OK ==
 +                 GNUNET_CREDENTIAL_delegation_chain_deserialize (mlen,
 +                                                                 (const 
char*) &vr_msg[1],
 +                                                                 d_count,
 +                                                                 d_chain,
 +                                                                 c_count,
 +                                                                 creds));
 +  if (GNUNET_NO == ntohl (vr_msg->cred_found))
 +  {
 +    proc (proc_cls,
 +          0,
 +          NULL,
 +          0,
 +          NULL); // TODO
 +  } else {
 +    proc (proc_cls,
 +          d_count,
 +          d_chain,
 +          c_count,
 +          creds);
 +  }
 +}
 +
 +
 +/**
 + * Reconnect to CREDENTIAL service.
 + *
 + * @param handle the handle to the CREDENTIAL service
 + */
 +static void
 +reconnect (struct GNUNET_CREDENTIAL_Handle *handle)
 +{
 +  struct GNUNET_MQ_MessageHandler handlers[] = {
 +    GNUNET_MQ_hd_var_size (result,
 +                           GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT,
 +                           struct DelegationChainResultMessage,
 +                           handle),
 +    GNUNET_MQ_hd_var_size (result,
 +                           GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT_RESULT,
 +                           struct DelegationChainResultMessage,
 +                           handle),
 +    GNUNET_MQ_handler_end ()
 +  };
 +  struct GNUNET_CREDENTIAL_Request *vr;
 +
 +  GNUNET_assert (NULL == handle->mq);
 +  LOG (GNUNET_ERROR_TYPE_DEBUG,
 +       "Trying to connect to CREDENTIAL\n");
-   handle->mq = GNUNET_CLIENT_connecT (handle->cfg,
++  handle->mq = GNUNET_CLIENT_connect (handle->cfg,
 +                                      "credential",
 +                                      handlers,
 +                                      &mq_error_handler,
 +                                      handle);
 +  if (NULL == handle->mq)
 +    return;
 +  for (vr = handle->request_head; NULL != vr; vr = vr->next)
 +    GNUNET_MQ_send_copy (handle->mq,
 +                         vr->env);
 +}
 +
 +
 +/**
 + * Initialize the connection with the CREDENTIAL service.
 + *
 + * @param cfg configuration to use
 + * @return handle to the CREDENTIAL service, or NULL on error
 + */
 +struct GNUNET_CREDENTIAL_Handle *
 +GNUNET_CREDENTIAL_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 +{
 +  struct GNUNET_CREDENTIAL_Handle *handle;
 +
 +  handle = GNUNET_new (struct GNUNET_CREDENTIAL_Handle);
 +  handle->cfg = cfg;
 +  reconnect (handle);
 +  if (NULL == handle->mq)
 +  {
 +    GNUNET_free (handle);
 +    return NULL;
 +  }
 +  return handle;
 +}
 +
 +
 +/**
 + * Shutdown connection with the CREDENTIAL service.
 + *
 + * @param handle handle of the CREDENTIAL connection to stop
 + */
 +void
 +GNUNET_CREDENTIAL_disconnect (struct GNUNET_CREDENTIAL_Handle *handle)
 +{
 +  if (NULL != handle->mq)
 +  {
 +    GNUNET_MQ_destroy (handle->mq);
 +    handle->mq = NULL;
 +  }
 +  if (NULL != handle->reconnect_task)
 +  {
 +    GNUNET_SCHEDULER_cancel (handle->reconnect_task);
 +    handle->reconnect_task = NULL;
 +  }
 +  GNUNET_assert (NULL == handle->request_head);
 +  GNUNET_free (handle);
 +}
 +
 +
 +/**
 + * Cancel pending verify request
 + *
 + * @param lr the verify request to cancel
 + */
 +void
 +GNUNET_CREDENTIAL_verify_cancel (struct GNUNET_CREDENTIAL_Request *vr)
 +{
 +  struct GNUNET_CREDENTIAL_Handle *handle = vr->credential_handle;
 +
 +  GNUNET_CONTAINER_DLL_remove (handle->request_head,
 +                               handle->request_tail,
 +                               vr);
 +  GNUNET_MQ_discard (vr->env);
 +  GNUNET_free (vr);
 +}
 +
 +
 +/**
 + * Performs attribute collection.
 + * Collects all credentials of subject to fulfill the 
 + * attribute, if possible
 + *
 + * @param handle handle to the Credential service
 + * @param issuer_key the issuer public key
 + * @param issuer_attribute the issuer attribute
 + * @param subject_key the subject public key
 + * @param credential_count number of credentials provided
 + * @param credentials subject credentials
 + * @param proc function to call on result
 + * @param proc_cls closure for processor
 + * @return handle to the queued request
 + */
 +struct GNUNET_CREDENTIAL_Request*
 +GNUNET_CREDENTIAL_collect (struct GNUNET_CREDENTIAL_Handle *handle,
 +                           const struct GNUNET_CRYPTO_EcdsaPublicKey 
*issuer_key,
 +                           const char *issuer_attribute,
 +                           const struct GNUNET_CRYPTO_EcdsaPrivateKey 
*subject_key,
 +                           GNUNET_CREDENTIAL_CredentialResultProcessor proc,
 +                           void *proc_cls)
 +{
 +  /* IPC to shorten credential names, return shorten_handle */
 +  struct CollectMessage *c_msg;
 +  struct GNUNET_CREDENTIAL_Request *vr;
 +  size_t nlen;
 +
 +  if (NULL == issuer_attribute)
 +  {
 +    GNUNET_break (0);
 +    return NULL;
 +  }
 +
 +  //DEBUG LOG
 +  LOG (GNUNET_ERROR_TYPE_DEBUG,
 +       "Trying to collect `%s' in CREDENTIAL\n",
 +       issuer_attribute);
 +  nlen = strlen (issuer_attribute) + 1;
 +  if (nlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*vr))
 +  {
 +    GNUNET_break (0);
 +    return NULL;
 +  }
 +  vr = GNUNET_new (struct GNUNET_CREDENTIAL_Request);
 +  vr->credential_handle = handle;
 +  vr->verify_proc = proc;
 +  vr->proc_cls = proc_cls;
 +  vr->r_id = handle->r_id_gen++;
 +  vr->env = GNUNET_MQ_msg_extra (c_msg,
 +                                 nlen,
 +                                 GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT);
 +  c_msg->id = htonl (vr->r_id);
 +  c_msg->subject_key = *subject_key;
 +  c_msg->issuer_key =  *issuer_key;
 +  c_msg->issuer_attribute_len = htons(strlen(issuer_attribute));
 +  GNUNET_memcpy (&c_msg[1],
 +                 issuer_attribute,
 +                 strlen (issuer_attribute));
 +  GNUNET_CONTAINER_DLL_insert (handle->request_head,
 +                               handle->request_tail,
 +                               vr);
 +  if (NULL != handle->mq)
 +    GNUNET_MQ_send_copy (handle->mq,
 +                         vr->env);
 +  return vr;
 +}
 +/**
 + * Performs attribute verification.
 + * Checks if there is a delegation chain from
 + * attribute ``issuer_attribute'' issued by the issuer
 + * with public key ``issuer_key'' maps to the attribute
 + * ``subject_attribute'' claimed by the subject with key
 + * ``subject_key''
 + *
 + * @param handle handle to the Credential service
 + * @param issuer_key the issuer public key
 + * @param issuer_attribute the issuer attribute
 + * @param subject_key the subject public key
 + * @param credential_count number of credentials provided
 + * @param credentials subject credentials
 + * @param proc function to call on result
 + * @param proc_cls closure for processor
 + * @return handle to the queued request
 + */
 +struct GNUNET_CREDENTIAL_Request*
 +GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
 +                          const struct GNUNET_CRYPTO_EcdsaPublicKey 
*issuer_key,
 +                          const char *issuer_attribute,
 +                          const struct GNUNET_CRYPTO_EcdsaPublicKey 
*subject_key,
 +                          uint32_t credential_count,
 +                          const struct GNUNET_CREDENTIAL_Credential 
*credentials,
 +                          GNUNET_CREDENTIAL_CredentialResultProcessor proc,
 +                          void *proc_cls)
 +{
 +  /* IPC to shorten credential names, return shorten_handle */
 +  struct VerifyMessage *v_msg;
 +  struct GNUNET_CREDENTIAL_Request *vr;
 +  size_t nlen;
 +  size_t clen;
 +
 +  if (NULL == issuer_attribute || NULL == credentials)
 +  {
 +    GNUNET_break (0);
 +    return NULL;
 +  }
 +
 +  clen = GNUNET_CREDENTIAL_credentials_get_size (credential_count,
 +                                                 credentials);
 +
 +  //DEBUG LOG
 +  LOG (GNUNET_ERROR_TYPE_DEBUG,
 +       "Trying to verify `%s' in CREDENTIAL\n",
 +       issuer_attribute);
 +  nlen = strlen (issuer_attribute) + 1 + clen;
 +  if (nlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*vr))
 +  {
 +    GNUNET_break (0);
 +    return NULL;
 +  }
 +  vr = GNUNET_new (struct GNUNET_CREDENTIAL_Request);
 +  vr->credential_handle = handle;
 +  vr->verify_proc = proc;
 +  vr->proc_cls = proc_cls;
 +  vr->r_id = handle->r_id_gen++;
 +  vr->env = GNUNET_MQ_msg_extra (v_msg,
 +                                 nlen,
 +                                 GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY);
 +  v_msg->id = htonl (vr->r_id);
 +  v_msg->subject_key = *subject_key;
 +  v_msg->c_count = htonl(credential_count);
 +  v_msg->issuer_key =  *issuer_key;
 +  v_msg->issuer_attribute_len = htons(strlen(issuer_attribute));
 +  GNUNET_memcpy (&v_msg[1],
 +                 issuer_attribute,
 +                 strlen (issuer_attribute));
 +  GNUNET_CREDENTIAL_credentials_serialize (credential_count,
 +                                           credentials,
 +                                           clen,
 +                                           ((char*)&v_msg[1])
 +                                           + strlen (issuer_attribute) + 1);
 +  GNUNET_CONTAINER_DLL_insert (handle->request_head,
 +                               handle->request_tail,
 +                               vr);
 +  if (NULL != handle->mq)
 +    GNUNET_MQ_send_copy (handle->mq,
 +                         vr->env);
 +  return vr;
 +}
 +
 +/* end of credential_api.c */

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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