GNUnet  0.10.x
plugin_datacache_template.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2006, 2009, 2015 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19 */
20 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
29 
30 
34 struct Plugin
35 {
40 };
41 
42 
57 static ssize_t
59  const struct GNUNET_HashCode *key,
60  uint32_t xor_distance,
61  size_t size,
62  const char *data,
64  struct GNUNET_TIME_Absolute discard_time,
65  unsigned int path_info_len,
66  const struct GNUNET_PeerIdentity *path_info)
67 {
68  GNUNET_break (0);
69  return -1;
70 }
71 
72 
84 static unsigned int
86  const struct GNUNET_HashCode *key,
89  void *iter_cls)
90 {
91  GNUNET_break (0);
92  return 0;
93 }
94 
95 
103 static int
105 {
106  GNUNET_break (0);
107  return GNUNET_SYSERR;
108 }
109 
110 
119 static unsigned int
122  void *iter_cls)
123 {
124  GNUNET_break (0);
125  return 0;
126 }
127 
128 
129 
143 static unsigned int
145  const struct GNUNET_HashCode *key,
146  unsigned int num_results,
148  void *iter_cls)
149 {
150  GNUNET_break (0);
151  return 0;
152 }
153 
154 
161 void *
163 {
166  struct Plugin *plugin;
167 
168  plugin = GNUNET_new (struct Plugin);
169  plugin->env = env;
171  api->cls = plugin;
172  api->get = &template_plugin_get;
173  api->put = &template_plugin_put;
174  api->del = &template_plugin_del;
178  "template",
179  "Template datacache running\n");
180  return api;
181 }
182 
183 
190 void *
192 {
194  struct Plugin *plugin = api->cls;
195 
196  GNUNET_free (plugin);
197  GNUNET_free (api);
198  return NULL;
199 }
200 
201 
202 /* end of plugin_datacache_template.c */
static unsigned int template_plugin_get_closest(void *cls, const struct GNUNET_HashCode *key, unsigned int num_results, GNUNET_DATACACHE_Iterator iter, void *iter_cls)
Iterate over the results that are "close" to a particular key in the datacache.
void * cls
Closure to pass to all plugin functions.
ssize_t(* put)(void *cls, const struct GNUNET_HashCode *key, uint32_t xor_distance, size_t size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time, unsigned int path_info_len, const struct GNUNET_PeerIdentity *path_info)
Store an item in the datastore.
int(* del)(void *cls)
Delete the entry with the lowest expiration value from the datacache right now.
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
char * key
TLS key.
void * libgnunet_plugin_datacache_template_done(void *cls)
Exit point from the plugin.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void * libgnunet_plugin_datacache_template_init(void *cls)
Entry point for the plugin.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static ssize_t template_plugin_put(void *cls, const struct GNUNET_HashCode *key, uint32_t xor_distance, size_t size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time, unsigned int path_info_len, const struct GNUNET_PeerIdentity *path_info)
Store an item in the datastore.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
unsigned int(* get_closest)(void *cls, const struct GNUNET_HashCode *key, unsigned int num_results, GNUNET_DATACACHE_Iterator iter, void *iter_cls)
Iterate over the results that are "close" to a particular key in the datacache.
struct returned by the initialization function of the plugin
A 512-bit hashcode.
static unsigned int template_plugin_get(void *cls, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, void *iter_cls)
Iterate over the results for a particular key in the datastore.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
void * iter_cls
Iterator cls.
The identity of the host (wraps the signing key of the peer).
static int template_plugin_del(void *cls)
Delete the entry with the lowest expiration value from the datacache right now.
unsigned long long size
Size of all values we&#39;re storing.
Handle for a plugin.
Definition: block.c:37
int(* GNUNET_DATACACHE_Iterator)(void *cls, const struct GNUNET_HashCode *key, size_t data_size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute exp, unsigned int path_info_len, const struct GNUNET_PeerIdentity *path_info)
An iterator over a set of items stored in the datacache.
void * cls
Closure to use for callbacks.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
unsigned int(* get_random)(void *cls, GNUNET_DATACACHE_Iterator iter, void *iter_cls)
Return a random value from the datastore.
#define GNUNET_log_from(kind, comp,...)
uint32_t data
The data value.
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
GNUNET_PEERSTORE_Processor iter
Iterator.
unsigned int(* get)(void *cls, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, void *iter_cls)
Iterate over the results for a particular key in the datastore.
#define GNUNET_free(ptr)
Wrapper around free.
static unsigned int template_plugin_get_random(void *cls, GNUNET_DATACACHE_Iterator iter, void *iter_cls)
Return a random value from the datastore.