summaryrefslogtreecommitdiff
path: root/src/auction/gnunet-service-auction.c
blob: c20f0bdbeff59a3fe0bbc0567179f6d620b8625b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
   This file is part of GNUnet.
   Copyright (C) 2009 GNUnet e.V.

   GNUnet is free software: you can redistribute it and/or modify it
   under the terms of the GNU Affero General Public License as published
   by the Free Software Foundation, either version 3 of the License,
   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
   Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

     SPDX-License-Identifier: AGPL3.0-or-later
 */

/**
 * @file auction/gnunet-service-auction.c
 * @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.
 *
 * @param cls unused
 */
static void
cleanup_task (void *cls)
{
  /* FIXME: do clean up here */
}


/**
 * Callback called when a client connects to the service.
 *
 * @param cls closure for the service
 * @param c the new client that connected to the service
 * @param mq the message queue used to send messages to the client
 * @return @a c
 */
static void *
client_connect_cb (void *cls,
                   struct GNUNET_SERVICE_Client *c,
                   struct GNUNET_MQ_Handle *mq)
{
  return c;
}


/**
 * Callback called when a client disconnected from the service
 *
 * @param cls closure for the service
 * @param c the client that disconnected
 * @param internal_cls should be equal to @a c
 */
static void
client_disconnect_cb (void *cls,
                      struct GNUNET_SERVICE_Client *c,
                      void *internal_cls)
{
  GNUNET_assert (c == internal_cls);
}


/**
 * Process auction requests.
 *
 * @param cls closure
 * @param cfg configuration to use
 * @param service the initialized service
 */
static void
run (void *cls,
     const struct GNUNET_CONFIGURATION_Handle *cfg,
     struct GNUNET_SERVICE_Handle *service)
{
  /* FIXME: do setup here */
  GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
}


/**
 * Define "main" method using service macro.
 */
GNUNET_SERVICE_MAIN
  ("auction",
  GNUNET_SERVICE_OPTION_NONE,
  &run,
  &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 ())


/* end of gnunet-service-auction.c */