aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_scheduling.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/gnunet-service-ats_scheduling.c')
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c154
1 files changed, 154 insertions, 0 deletions
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
new file mode 100644
index 000000000..9400e12ff
--- /dev/null
+++ b/src/ats/gnunet-service-ats_scheduling.c
@@ -0,0 +1,154 @@
1/*
2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file ats/gnunet-service-ats_scheduling.c
23 * @brief ats service, interaction with 'scheduling' API
24 * @author Matthias Wachs
25 */
26#include "platform.h"
27#include "gnunet-service-ats_scheduling.h"
28#include "ats.h"
29
30
31struct SchedulingClient
32{
33 struct SchedulingClient * next;
34
35 struct SchedulingClient * prev;
36
37 struct GNUNET_SERVER_Client *client;
38
39};
40
41
42/**
43 * Head of linked list of all clients to this service.
44 */
45static struct SchedulingClient *ac_head;
46
47/**
48 * Tail of linked list of all clients to this service.
49 */
50static struct SchedulingClient *ac_tail;
51
52
53void
54GAS_add_scheduling_client (struct GNUNET_SERVER_Client *client)
55{
56 struct SchedulingClient *ac;
57
58 ac = GNUNET_malloc (sizeof (struct SchedulingClient));
59 ac->client = client;
60 GNUNET_SERVER_client_keep (client);
61 GNUNET_CONTAINER_DLL_insert(ac_head, ac_tail, ac);
62}
63
64
65void
66GAS_remove_scheduling_client (struct GNUNET_SERVER_Client *client)
67{
68}
69
70
71void
72GAS_handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
73 const struct GNUNET_MessageHeader *message)
74
75{
76 // struct RequestAddressMessage * msg = (struct RequestAddressMessage *) message;
77 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "REQUEST_ADDRESS");
78
79}
80
81
82void
83GAS_handle_address_update (void *cls, struct GNUNET_SERVER_Client *client,
84 const struct GNUNET_MessageHeader *message)
85
86{
87#if 0
88 struct AddressUpdateMessage * msg = (struct AddressUpdateMessage *) message;
89 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "ADDRESS_UPDATE");
90
91 struct GNUNET_TRANSPORT_ATS_Information *am;
92 char *pm;
93
94 size_t size = ntohs (msg->header.size);
95 if ((size <= sizeof (struct AddressUpdateMessage)) || (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE))
96 {
97 GNUNET_break (0);
98 return;
99 }
100
101 size_t ats_count = ntohs (msg->ats_count);
102 size_t addr_len = ntohs (msg->address_length);
103 size_t plugin_len = ntohs (msg->plugin_name_length) + 1 ;
104
105 if (
106 (plugin_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
107 (addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
108 (addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_TRANSPORT_ATS_Information)) )
109 {
110 GNUNET_break (0);
111 return;
112 }
113
114 struct ATS_Address * aa = GNUNET_malloc (sizeof (struct ATS_Address) +
115 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information) +
116 addr_len +
117 plugin_len);
118
119
120
121 memcpy (&aa->peer, &msg->peer, sizeof (struct GNUNET_PeerIdentity));
122 aa->addr_len = addr_len;
123 aa->ats_count = ats_count;
124 aa->ats = (struct GNUNET_TRANSPORT_ATS_Information *) &aa[1];
125
126 am = (struct GNUNET_TRANSPORT_ATS_Information*) &msg[1];
127 memcpy (&aa->ats, am, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
128 pm = (char *) &am[ats_count];
129 memcpy (aa->addr, pm, addr_len);
130 memcpy (aa->plugin, &pm[plugin_len], plugin_len);
131 aa->session_id = ntohl(msg->session_id);
132
133 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put(addresses, &aa->peer.hashPubKey, aa, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
134#endif
135}
136
137
138void
139GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client,
140 const struct GNUNET_MessageHeader *message)
141
142{
143#if 0
144 // struct AddressDestroyedMessage * msg = (struct AddressDestroyedMessage *) message;
145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "ADDRESS_DESTROYED");
146/*
147 struct GNUNET_PeerIdentity *peer = &msg->peer;
148 struct ATS_Address * aa = find_address_by_addr (peer);
149 GNUNET_CONTAINER_multihashmap_remove(addresses, peer, aa);
150 GNUNET_free (aa);*/
151#endif
152}
153
154/* end of gnunet-service-ats_scheduling.c */