aboutsummaryrefslogtreecommitdiff
path: root/src/auction/gnunet-service-auction.c
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/gnunet-service-auction.c
parente66a9b07d76995c00dab4c62ef22c73d2a3d7aaf (diff)
downloadgnunet-a760ff52c2ec00f46a9a384a1d63e637ba6b3271.tar.gz
gnunet-a760ff52c2ec00f46a9a384a1d63e637ba6b3271.zip
auction: basic service template
Diffstat (limited to 'src/auction/gnunet-service-auction.c')
-rw-r--r--src/auction/gnunet-service-auction.c69
1 files changed, 59 insertions, 10 deletions
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