gnunet-android

GNUnet for Android
Log | Files | Refs | README

gnunet_peerstore_plugin.h (4697B)


      1 /*
      2      This file is part of GNUnet
      3      Copyright (C) 2012, 2013 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 
     21 /**
     22  * @addtogroup Backbone
     23  * @{
     24  *
     25  * @author Omar Tarabai
     26  *
     27  * @file
     28  * Plugin API for the peerstore database backend
     29  *
     30  * @defgroup peerstore-plugin  Peer Store service plugin API
     31  * Plugin API for the peerstore database backend
     32  * @{
     33  */
     34 #ifndef GNUNET_PEERSTORE_PLUGIN_H
     35 #define GNUNET_PEERSTORE_PLUGIN_H
     36 
     37 
     38 #include "gnunet_util_lib.h"
     39 #include "gnunet_peerstore_service.h"
     40 
     41 #ifdef __cplusplus
     42 extern "C"
     43 {
     44 #if 0                           /* keep Emacsens' auto-indent happy */
     45 }
     46 #endif
     47 #endif
     48 
     49 /**
     50  * Function called by PEERSTORE for each matching record.
     51  *
     52  * @param cls closure
     53  * @param seq sequence in interation
     54  * @param record peerstore record information
     55  * @param emsg error message, or NULL if no errors
     56  */
     57 typedef void (*GNUNET_PEERSTORE_PluginProcessor) (
     58   void *cls,
     59   uint64_t seq,
     60   const struct GNUNET_PEERSTORE_Record *record,
     61   const char *emsg);
     62 
     63 /**
     64  * @brief struct returned by the initialization function of the plugin
     65  */
     66 struct GNUNET_PEERSTORE_PluginFunctions
     67 {
     68   /**
     69    * Closure to pass to all plugin functions.
     70    */
     71   void *cls;
     72 
     73   /**
     74    * Store a record in the peerstore.
     75    * Key is the combination of sub system and peer identity.
     76    * One key can store multiple values.
     77    *
     78    * @param cls closure (internal context for the plugin)
     79    * @param sub_system name of the GNUnet sub system responsible
     80    * @param peer peer identity
     81    * @param value value to be stored
     82    * @param size size of value to be stored
     83    * @param expiry absolute time after which the record is (possibly) deleted
     84    * @param options options related to the store operation
     85    * @param cont continuation called when record is stored
     86    * @param cont_cls continuation closure
     87    * @return #GNUNET_OK on success, else #GNUNET_SYSERR and cont is not called
     88    */
     89   int
     90   (*store_record) (void *cls,
     91                    const char *sub_system,
     92                    const struct GNUNET_PeerIdentity *peer,
     93                    const char *key,
     94                    const void *value,
     95                    size_t size,
     96                    struct GNUNET_TIME_Absolute expiry,
     97                    enum GNUNET_PEERSTORE_StoreOption options,
     98                    GNUNET_PEERSTORE_Continuation cont,
     99                    void *cont_cls);
    100 
    101   /**
    102    * Iterate over the records given an optional peer id
    103    * and/or key.
    104    *
    105    * @param cls closure (internal context for the plugin)
    106    * @param sub_system name of sub system
    107    * @param peer Peer identity (can be NULL)
    108    * @param key entry key string (can be NULL)
    109    * @param limit max number of results to give
    110    * @param iter function to call asynchronously with the results, terminated
    111    * by a NULL result
    112    * @param iter_cls closure for @a iter
    113    * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and iter is not
    114    * called
    115    */
    116   int
    117   (*iterate_records) (void *cls,
    118                       const char *sub_system,
    119                       const struct GNUNET_PeerIdentity *peer,
    120                       const char *key,
    121                       uint64_t serial,
    122                       uint64_t limit,
    123                       GNUNET_PEERSTORE_PluginProcessor iter,
    124                       void *iter_cls);
    125 
    126   /**
    127    * Delete expired records (expiry < now)
    128    *
    129    * @param cls closure (internal context for the plugin)
    130    * @param now time to use as reference
    131    * @param cont continuation called with the number of records expired
    132    * @param cont_cls continuation closure
    133    * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and cont is not
    134    * called
    135    */
    136   int
    137   (*expire_records) (void *cls,
    138                      struct GNUNET_TIME_Absolute now,
    139                      GNUNET_PEERSTORE_Continuation cont,
    140                      void *cont_cls);
    141 };
    142 
    143 
    144 #if 0                           /* keep Emacsens' auto-indent happy */
    145 {
    146 #endif
    147 #ifdef __cplusplus
    148 }
    149 #endif
    150 
    151 #endif
    152 
    153 /** @} */  /* end of group */
    154 
    155 /** @} */ /* end of group addition */