aboutsummaryrefslogtreecommitdiff
path: root/src/auction
diff options
context:
space:
mode:
authorMarkus Teich <teichm@fs.tum.de>2017-01-16 21:08:20 +0100
committerMarkus Teich <teichm@fs.tum.de>2017-01-16 21:08:47 +0100
commita760ff52c2ec00f46a9a384a1d63e637ba6b3271 (patch)
tree8ee6e9b0bad17d6c677729ce669d365de67e91b5 /src/auction
parente66a9b07d76995c00dab4c62ef22c73d2a3d7aaf (diff)
downloadgnunet-a760ff52c2ec00f46a9a384a1d63e637ba6b3271.tar.gz
gnunet-a760ff52c2ec00f46a9a384a1d63e637ba6b3271.zip
auction: basic service template
Diffstat (limited to 'src/auction')
-rw-r--r--src/auction/Makefile.am2
-rw-r--r--src/auction/auction.conf6
-rw-r--r--src/auction/auction.h77
-rw-r--r--src/auction/gnunet-service-auction.c69
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/
6libexecdir= $(pkglibdir)/libexec/ 6libexecdir= $(pkglibdir)/libexec/
7 7
8 8
9dist_pkgcfg_DATA = \ 9pkgcfg_DATA = \
10 auction.conf 10 auction.conf
11 11
12if MINGW 12if 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 @@
1 1[auction]
2 2AUTOSTART = NO
3BINARY = gnunet-service-auction
4UNIXPATH = $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 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2001-2011 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @author Markus Teich
23 * @file auction/auction.h
24 *
25 * @brief Common type definitions for the auction service and API.
26 */
27#ifndef AUCTION_H
28#define AUCTION_H
29
30#include "gnunet_common.h"
31
32GNUNET_NETWORK_STRUCT_BEGIN
33
34/**
35 * Auction creation request sent from the client to the service
36 */
37struct GNUNET_AUCTION_ClientCreateMessage
38{
39 /**
40 * Type: GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE
41 */
42 struct GNUNET_MessageHeader header;
43
44 /**
45 * When should the auction start
46 */
47 struct GNUNET_TIME_AbsoluteNBO time_start;
48
49 /**
50 * How long is each round allowed to be maximally
51 */
52 struct GNUNET_TIME_RelativeNBO time_round;
53
54 /**
55 * Auction parameter m.
56 * 0 for first price auctions.
57 * >0 for M+1st price auctions.
58 */
59 uint16_t m GNUNET_PACKED;
60
61 /**
62 * Should the auction outcome be public?
63 * 0 for private outcome auctions.
64 * 1 for public outcome auctions.
65 */
66 uint16_t outcome_public GNUNET_PACKED;
67
68 /**
69 * TODO: Price mapping.
70 */
71
72 /* DESCRIPTION text copied to end of this message */
73};
74
75GNUNET_NETWORK_STRUCT_END
76
77#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 @@
20 20
21/** 21/**
22 * @file auction/gnunet-service-auction.c 22 * @file auction/gnunet-service-auction.c
23 * @brief program that does auction 23 * @brief service for executing auctions
24 * @author Christian Grothoff 24 * @author Markus Teich
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28 28
29#include "auction.h"
30
31/**
32 * Check AUCTION CREATE messages from the client.
33 *
34 * @param cls the client we received this message from
35 * @param msg the actual message received
36 * @return #GNUNET_OK (always)
37 */
38static int
39check_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
40{
41 /* always well-formed due to arbitrary length description */
42 return GNUNET_OK;
43}
44
45
46/**
47 * Handler for CREATE messages.
48 *
49 * @param cls the client we received this message from
50 * @param msg the actual message received
51 */
52static void
53handle_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
54{
55 struct GNUNET_SERVICE_Client *client = cls;
56// struct GNUNET_MQ_Handle *mq;
57// struct GNUNET_MQ_Envelope *env;
58// struct GNUNET_AUCTION_blabla em;
59 uint16_t size;
60
61 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
62 "Received CREATE message from client\n");
63
64 size = ntohs (msg->header.size);
65
66 /**TODO: create auction and return auction object */
67// mq = GNUNET_SERVICE_client_get_mq (client);
68// setup_info_message (&em);
69// env = GNUNET_MQ_msg_copy (&em.header);
70// GNUNET_MQ_send (mq, env);
71
72 GNUNET_SERVICE_client_continue (client);
73}
74
29 75
30/** 76/**
31 * Task run during shutdown. 77 * Task run during shutdown.
@@ -49,8 +95,8 @@ cleanup_task (void *cls)
49 */ 95 */
50static void * 96static void *
51client_connect_cb (void *cls, 97client_connect_cb (void *cls,
52 struct GNUNET_SERVICE_Client *c, 98 struct GNUNET_SERVICE_Client *c,
53 struct GNUNET_MQ_Handle *mq) 99 struct GNUNET_MQ_Handle *mq)
54{ 100{
55 return c; 101 return c;
56} 102}
@@ -65,8 +111,8 @@ client_connect_cb (void *cls,
65 */ 111 */
66static void 112static void
67client_disconnect_cb (void *cls, 113client_disconnect_cb (void *cls,
68 struct GNUNET_SERVICE_Client *c, 114 struct GNUNET_SERVICE_Client *c,
69 void *internal_cls) 115 void *internal_cls)
70{ 116{
71 GNUNET_assert (c == internal_cls); 117 GNUNET_assert (c == internal_cls);
72} 118}
@@ -81,12 +127,11 @@ client_disconnect_cb (void *cls,
81 */ 127 */
82static void 128static void
83run (void *cls, 129run (void *cls,
84 const struct GNUNET_CONFIGURATION_Handle *cfg, 130 const struct GNUNET_CONFIGURATION_Handle *cfg,
85 struct GNUNET_SERVICE_Handle *service) 131 struct GNUNET_SERVICE_Handle *service)
86{ 132{
87 /* FIXME: do setup here */ 133 /* FIXME: do setup here */
88 GNUNET_SCHEDULER_add_shutdown (&cleanup_task, 134 GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
89 NULL);
90} 135}
91 136
92 137
@@ -100,6 +145,10 @@ GNUNET_SERVICE_MAIN
100 &client_connect_cb, 145 &client_connect_cb,
101 &client_disconnect_cb, 146 &client_disconnect_cb,
102 NULL, 147 NULL,
148 GNUNET_MQ_hd_var_size (create,
149 GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE,
150 struct GNUNET_AUCTION_ClientCreateMessage,
151 NULL),
103 GNUNET_MQ_handler_end ()) 152 GNUNET_MQ_handler_end ())
104 153
105 154