gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: auction: basic service temp


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: auction: basic service template
Date: Mon, 16 Jan 2017 21:08:53 +0100

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

mteich pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new a760ff52c auction: basic service template
a760ff52c is described below

commit a760ff52c2ec00f46a9a384a1d63e637ba6b3271
Author: Markus Teich <address@hidden>
AuthorDate: Mon Jan 16 21:08:20 2017 +0100

    auction: basic service template
---
 src/auction/Makefile.am              |  2 +-
 src/auction/auction.conf             |  6 ++-
 src/auction/auction.h                | 77 ++++++++++++++++++++++++++++++++++++
 src/auction/gnunet-service-auction.c | 69 +++++++++++++++++++++++++++-----
 4 files changed, 141 insertions(+), 13 deletions(-)

diff --git a/src/auction/Makefile.am b/src/auction/Makefile.am
index 0c250a0b4..87f917283 100644
--- a/src/auction/Makefile.am
+++ b/src/auction/Makefile.am
@@ -6,7 +6,7 @@ pkgcfgdir= $(pkgdatadir)/config.d/
 libexecdir= $(pkglibdir)/libexec/
 
 
-dist_pkgcfg_DATA = \
+pkgcfg_DATA = \
   auction.conf
 
 if MINGW
diff --git a/src/auction/auction.conf b/src/auction/auction.conf
index 139597f9c..6ca35896b 100644
--- a/src/auction/auction.conf
+++ b/src/auction/auction.conf
@@ -1,2 +1,4 @@
-
-
+[auction]
+AUTOSTART = NO
+BINARY = gnunet-service-auction
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-auction.sock
diff --git a/src/auction/auction.h b/src/auction/auction.h
new file mode 100644
index 000000000..758307aeb
--- /dev/null
+++ b/src/auction/auction.h
@@ -0,0 +1,77 @@
+/*
+     This file is part of GNUnet.
+     Copyright (C) 2001-2011 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.
+*/
+
+/**
+ * @author Markus Teich
+ * @file auction/auction.h
+ *
+ * @brief Common type definitions for the auction service and API.
+ */
+#ifndef AUCTION_H
+#define AUCTION_H
+
+#include "gnunet_common.h"
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * Auction creation request sent from the client to the service
+ */
+struct GNUNET_AUCTION_ClientCreateMessage
+{
+  /**
+   * Type: GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * When should the auction start
+   */
+  struct GNUNET_TIME_AbsoluteNBO time_start;
+
+  /**
+   * How long is each round allowed to be maximally
+   */
+  struct GNUNET_TIME_RelativeNBO time_round;
+
+  /**
+   * Auction parameter m.
+   * 0 for first price auctions.
+   * >0 for M+1st price auctions.
+   */
+  uint16_t m GNUNET_PACKED;
+
+  /**
+   * Should the auction outcome be public?
+   * 0 for private outcome auctions.
+   * 1 for public outcome auctions.
+   */
+  uint16_t outcome_public GNUNET_PACKED;
+
+  /**
+   * TODO: Price mapping.
+   */
+
+  /* DESCRIPTION text copied to end of this message */
+};
+
+GNUNET_NETWORK_STRUCT_END
+
+#endif
diff --git a/src/auction/gnunet-service-auction.c 
b/src/auction/gnunet-service-auction.c
index b2587bfd7..dac38914d 100644
--- a/src/auction/gnunet-service-auction.c
+++ b/src/auction/gnunet-service-auction.c
@@ -20,12 +20,58 @@
 
 /**
  * @file auction/gnunet-service-auction.c
- * @brief program that does auction
- * @author Christian Grothoff
+ * @brief service for executing auctions
+ * @author Markus Teich
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
 
+#include "auction.h"
+
+/**
+ * Check AUCTION CREATE messages from the client.
+ *
+ * @param cls the client we received this message from
+ * @param msg the actual message received
+ * @return #GNUNET_OK (always)
+ */
+static int
+check_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
+{
+       /* always well-formed due to arbitrary length description */
+       return GNUNET_OK;
+}
+
+
+/**
+ * Handler for CREATE messages.
+ *
+ * @param cls the client we received this message from
+ * @param msg the actual message received
+ */
+static void
+handle_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
+{
+       struct GNUNET_SERVICE_Client *client = cls;
+//     struct GNUNET_MQ_Handle *mq;
+//     struct GNUNET_MQ_Envelope *env;
+//     struct GNUNET_AUCTION_blabla em;
+       uint16_t size;
+
+       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                   "Received CREATE message from client\n");
+
+       size = ntohs (msg->header.size);
+
+       /**TODO: create auction and return auction object */
+//     mq = GNUNET_SERVICE_client_get_mq (client);
+//     setup_info_message (&em);
+//     env = GNUNET_MQ_msg_copy (&em.header);
+//     GNUNET_MQ_send (mq, env);
+
+       GNUNET_SERVICE_client_continue (client);
+}
+
 
 /**
  * Task run during shutdown.
@@ -49,8 +95,8 @@ cleanup_task (void *cls)
  */
 static void *
 client_connect_cb (void *cls,
-                                  struct GNUNET_SERVICE_Client *c,
-                                  struct GNUNET_MQ_Handle *mq)
+                   struct GNUNET_SERVICE_Client *c,
+                   struct GNUNET_MQ_Handle *mq)
 {
        return c;
 }
@@ -65,8 +111,8 @@ client_connect_cb (void *cls,
  */
 static void
 client_disconnect_cb (void *cls,
-                                         struct GNUNET_SERVICE_Client *c,
-                                         void *internal_cls)
+                      struct GNUNET_SERVICE_Client *c,
+                      void *internal_cls)
 {
        GNUNET_assert (c == internal_cls);
 }
@@ -81,12 +127,11 @@ client_disconnect_cb (void *cls,
  */
 static void
 run (void *cls,
-        const struct GNUNET_CONFIGURATION_Handle *cfg,
-        struct GNUNET_SERVICE_Handle *service)
+     const struct GNUNET_CONFIGURATION_Handle *cfg,
+     struct GNUNET_SERVICE_Handle *service)
 {
        /* FIXME: do setup here */
-       GNUNET_SCHEDULER_add_shutdown (&cleanup_task,
-                                                                  NULL);
+       GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
 }
 
 
@@ -100,6 +145,10 @@ GNUNET_SERVICE_MAIN
  &client_connect_cb,
  &client_disconnect_cb,
  NULL,
+ GNUNET_MQ_hd_var_size (create,
+                        GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE,
+                        struct GNUNET_AUCTION_ClientCreateMessage,
+                        NULL),
  GNUNET_MQ_handler_end ())
 
 

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



reply via email to

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