gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

gnunet_reclaim_plugin.h (11220B)


      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 reclaim_suite  RECLAIM services and libraries
     23  * @{
     24  *
     25  * @author Martin Schanzenbach
     26  *
     27  * @file
     28  * Plugin API for reclaim attribute types
     29  *
     30  * @defgroup reclaim-attribute-plugin  reclaim plugin API for attributes/claims
     31  * @{
     32  */
     33 #ifndef GNUNET_RECLAIM_PLUGIN_H
     34 #define GNUNET_RECLAIM_PLUGIN_H
     35 
     36 
     37 #include "gnunet_util_lib.h"
     38 #include "gnunet_reclaim_lib.h"
     39 
     40 #ifdef __cplusplus
     41 extern "C" {
     42 #if 0 /* keep Emacsens' auto-indent happy */
     43 }
     44 #endif
     45 #endif
     46 
     47 
     48 /**
     49  * Function called to convert the binary value @a data of an attribute of
     50  * type @a type to a human-readable string.
     51  *
     52  * @param cls closure
     53  * @param type type of the attribute
     54  * @param data value in binary encoding
     55  * @param data_size number of bytes in @a data
     56  * @return NULL on error, otherwise human-readable representation of the value
     57  */
     58 typedef char *(*GNUNET_RECLAIM_AttributeValueToStringFunction) (
     59   void *cls,
     60   uint32_t type,
     61   const void *data,
     62   size_t data_size);
     63 
     64 
     65 /**
     66  * Function called to convert human-readable version of the value @a s
     67  * of an attribute of type @a type to the respective binary
     68  * representation.
     69  *
     70  * @param cls closure
     71  * @param type type of the attribute
     72  * @param s human-readable string
     73  * @param data set to value in binary encoding (will be allocated)
     74  * @param data_size set to number of bytes in @a data
     75  * @return #GNUNET_OK on success
     76  */
     77 typedef int (*GNUNET_RECLAIM_AttributeStringToValueFunction) (
     78   void *cls,
     79   uint32_t type,
     80   const char *s,
     81   void **data,
     82   size_t *data_size);
     83 
     84 
     85 /**
     86  * Function called to convert a type name to the
     87  * corresponding number.
     88  *
     89  * @param cls closure
     90  * @param typename name to convert
     91  * @return corresponding number, UINT32_MAX on error
     92  */
     93 typedef uint32_t (*GNUNET_RECLAIM_AttributeTypenameToNumberFunction) (
     94   void *cls,
     95   const char *typename);
     96 
     97 
     98 /**
     99  * Function called to convert a type number to the
    100  * corresponding type string (e.g. 1 to "A")
    101  *
    102  * @param cls closure
    103  * @param type number of a type to convert
    104  * @return corresponding typestring, NULL on error
    105  */
    106 typedef const char *(*GNUNET_RECLAIM_AttributeNumberToTypenameFunction) (
    107   void *cls,
    108   uint32_t type);
    109 
    110 /**
    111  * Function called to convert the binary value @a data of an attribute of
    112  * type @a type to a human-readable string.
    113  *
    114  * @param cls closure
    115  * @param type type of the attribute
    116  * @param data value in binary encoding
    117  * @param data_size number of bytes in @a data
    118  * @return NULL on error, otherwise human-readable representation of the value
    119  */
    120 typedef char *(*GNUNET_RECLAIM_CredentialValueToStringFunction) (
    121   void *cls,
    122   uint32_t type,
    123   const void *data,
    124   size_t data_size);
    125 
    126 
    127 /**
    128  * Function called to convert human-readable version of the value @a s
    129  * of an attribute of type @a type to the respective binary
    130  * representation.
    131  *
    132  * @param cls closure
    133  * @param type type of the attribute
    134  * @param s human-readable string
    135  * @param data set to value in binary encoding (will be allocated)
    136  * @param data_size set to number of bytes in @a data
    137  * @return #GNUNET_OK on success
    138  */
    139 typedef int (*GNUNET_RECLAIM_CredentialStringToValueFunction) (
    140   void *cls,
    141   uint32_t type,
    142   const char *s,
    143   void **data,
    144   size_t *data_size);
    145 
    146 
    147 /**
    148  * Function called to convert a type name to the
    149  * corresponding number.
    150  *
    151  * @param cls closure
    152  * @param typename name to convert
    153  * @return corresponding number, UINT32_MAX on error
    154  */
    155 typedef uint32_t (*GNUNET_RECLAIM_CredentialTypenameToNumberFunction) (
    156   void *cls,
    157   const char *typename);
    158 
    159 
    160 /**
    161  * Function called to convert a type number to the
    162  * corresponding type string (e.g. 1 to "A")
    163  *
    164  * @param cls closure
    165  * @param type number of a type to convert
    166  * @return corresponding typestring, NULL on error
    167  */
    168 typedef const char *(*GNUNET_RECLAIM_CredentialNumberToTypenameFunction) (
    169   void *cls,
    170   uint32_t type);
    171 
    172 /**
    173  * Function called to extract attributes from a credential
    174  *
    175  * @param cls closure
    176  * @param cred the credential object
    177  * @return an attribute list
    178  */
    179 typedef struct
    180   GNUNET_RECLAIM_AttributeList *(*
    181 GNUNET_RECLAIM_CredentialGetAttributesFunction) (
    182   void *cls,
    183   const struct GNUNET_RECLAIM_Credential *cred);
    184 
    185 /**
    186  * Function called to get the issuer of the credential (as string)
    187  *
    188  * @param cls closure
    189  * @param cred the credential object
    190  * @return corresponding issuer string
    191  */
    192 typedef char *(*GNUNET_RECLAIM_CredentialGetIssuerFunction) (
    193   void *cls,
    194   const struct GNUNET_RECLAIM_Credential *cred);
    195 
    196 /**
    197  * Function called to get the expiration of the credential
    198  *
    199  * @param cls closure
    200  * @param cred the credential object
    201  * @param where to write the value
    202  * @return GNUNET_OK if successful
    203  */
    204 typedef int (*GNUNET_RECLAIM_CredentialGetExpirationFunction) (
    205   void *cls,
    206   const struct GNUNET_RECLAIM_Credential *cred,
    207   struct GNUNET_TIME_Absolute *expiration);
    208 
    209 /**
    210  * Function called to convert the binary value @a data of an attribute of
    211  * type @a type to a human-readable string.
    212  *
    213  * @param cls closure
    214  * @param type type of the attribute
    215  * @param data value in binary encoding
    216  * @param data_size number of bytes in @a data
    217  * @return NULL on error, otherwise human-readable representation of the value
    218  */
    219 typedef char *(*GNUNET_RECLAIM_PresentationValueToStringFunction) (
    220   void *cls,
    221   uint32_t type,
    222   const void *data,
    223   size_t data_size);
    224 
    225 
    226 /**
    227  * Function called to convert human-readable version of the value @a s
    228  * of an attribute of type @a type to the respective binary
    229  * representation.
    230  *
    231  * @param cls closure
    232  * @param type type of the attribute
    233  * @param s human-readable string
    234  * @param data set to value in binary encoding (will be allocated)
    235  * @param data_size set to number of bytes in @a data
    236  * @return #GNUNET_OK on success
    237  */
    238 typedef int (*GNUNET_RECLAIM_PresentationStringToValueFunction) (
    239   void *cls,
    240   uint32_t type,
    241   const char *s,
    242   void **data,
    243   size_t *data_size);
    244 
    245 
    246 /**
    247  * Function called to convert a type name to the
    248  * corresponding number.
    249  *
    250  * @param cls closure
    251  * @param typename name to convert
    252  * @return corresponding number, UINT32_MAX on error
    253  */
    254 typedef uint32_t (*GNUNET_RECLAIM_PresentationTypenameToNumberFunction) (
    255   void *cls,
    256   const char *typename);
    257 
    258 
    259 /**
    260  * Function called to convert a type number to the
    261  * corresponding type string (e.g. 1 to "A")
    262  *
    263  * @param cls closure
    264  * @param type number of a type to convert
    265  * @return corresponding typestring, NULL on error
    266  */
    267 typedef const char *(*GNUNET_RECLAIM_PresentationNumberToTypenameFunction) (
    268   void *cls,
    269   uint32_t type);
    270 
    271 /**
    272  * Function called to extract attributes from a credential
    273  *
    274  * @param cls closure
    275  * @param cred the credential object
    276  * @return an attribute list
    277  */
    278 typedef struct
    279   GNUNET_RECLAIM_AttributeList *(*
    280 GNUNET_RECLAIM_PresentationGetAttributesFunction) (
    281   void *cls,
    282   const struct GNUNET_RECLAIM_Presentation *cred);
    283 
    284 /**
    285  * Function called to get the issuer of the credential (as string)
    286  *
    287  * @param cls closure
    288  * @param cred the credential object
    289  * @return corresponding issuer string
    290  */
    291 typedef char *(*GNUNET_RECLAIM_PresentationGetIssuerFunction) (
    292   void *cls,
    293   const struct GNUNET_RECLAIM_Presentation *cred);
    294 
    295 /**
    296  * Function called to get the expiration of the credential
    297  *
    298  * @param cls closure
    299  * @param cred the credential object
    300  * @param where to write the value
    301  * @return GNUNET_OK if successful
    302  */
    303 typedef int (*GNUNET_RECLAIM_PresentationGetExpirationFunction) (
    304   void *cls,
    305   const struct GNUNET_RECLAIM_Presentation *cred,
    306   struct GNUNET_TIME_Absolute *expiration);
    307 
    308 typedef int (*GNUNET_RECLAIM_CredentialToPresentation) (
    309   void *cls,
    310   const struct GNUNET_RECLAIM_Credential *cred,
    311   const struct GNUNET_RECLAIM_AttributeList *attrs,
    312   struct GNUNET_RECLAIM_Presentation **presentation);
    313 
    314 /**
    315  * Each plugin is required to return a pointer to a struct of this
    316  * type as the return value from its entry point.
    317  */
    318 struct GNUNET_RECLAIM_AttributePluginFunctions
    319 {
    320   /**
    321    * Closure for all of the callbacks.
    322    */
    323   void *cls;
    324 
    325   /**
    326    * Conversion to string.
    327    */
    328   GNUNET_RECLAIM_AttributeValueToStringFunction value_to_string;
    329 
    330   /**
    331    * Conversion to binary.
    332    */
    333   GNUNET_RECLAIM_AttributeStringToValueFunction string_to_value;
    334 
    335   /**
    336    * Typename to number.
    337    */
    338   GNUNET_RECLAIM_AttributeTypenameToNumberFunction typename_to_number;
    339 
    340   /**
    341    * Number to typename.
    342    */
    343   GNUNET_RECLAIM_AttributeNumberToTypenameFunction number_to_typename;
    344 
    345 };
    346 
    347 /**
    348  * Each plugin is required to return a pointer to a struct of this
    349  * type as the return value from its entry point.
    350  */
    351 struct GNUNET_RECLAIM_CredentialPluginFunctions
    352 {
    353   /**
    354    * Closure for all of the callbacks.
    355    */
    356   void *cls;
    357 
    358   /**
    359    * Conversion to string.
    360    */
    361   GNUNET_RECLAIM_CredentialValueToStringFunction value_to_string;
    362 
    363   /**
    364    * Conversion to binary.
    365    */
    366   GNUNET_RECLAIM_CredentialStringToValueFunction string_to_value;
    367 
    368   /**
    369    * Typename to number.
    370    */
    371   GNUNET_RECLAIM_CredentialTypenameToNumberFunction typename_to_number;
    372 
    373   /**
    374    * Number to typename.
    375    */
    376   GNUNET_RECLAIM_CredentialNumberToTypenameFunction number_to_typename;
    377 
    378   /**
    379    * Attesation attributes.
    380    */
    381   GNUNET_RECLAIM_CredentialGetAttributesFunction get_attributes;
    382 
    383   /**
    384    * Attesation issuer.
    385    */
    386   GNUNET_RECLAIM_CredentialGetIssuerFunction get_issuer;
    387 
    388   /**
    389    * Expiration.
    390    */
    391   GNUNET_RECLAIM_CredentialGetExpirationFunction get_expiration;
    392 
    393   /**
    394    * Conversion to string.
    395    */
    396   GNUNET_RECLAIM_PresentationValueToStringFunction value_to_string_p;
    397 
    398   /**
    399    * Conversion to binary.
    400    */
    401   GNUNET_RECLAIM_PresentationStringToValueFunction string_to_value_p;
    402 
    403   /**
    404    * Typename to number.
    405    */
    406   GNUNET_RECLAIM_PresentationTypenameToNumberFunction typename_to_number_p;
    407 
    408   /**
    409    * Number to typename.
    410    */
    411   GNUNET_RECLAIM_PresentationNumberToTypenameFunction number_to_typename_p;
    412 
    413   /**
    414    * Attesation attributes.
    415    */
    416   GNUNET_RECLAIM_PresentationGetAttributesFunction get_attributes_p;
    417 
    418   /**
    419    * Attesation issuer.
    420    */
    421   GNUNET_RECLAIM_PresentationGetIssuerFunction get_issuer_p;
    422 
    423   /**
    424    * Expiration.
    425    */
    426   GNUNET_RECLAIM_PresentationGetExpirationFunction get_expiration_p;
    427 
    428   /**
    429    * Get presentation
    430    */
    431   GNUNET_RECLAIM_CredentialToPresentation create_presentation;
    432 
    433 };
    434 
    435 
    436 #if 0 /* keep Emacsens' auto-indent happy */
    437 {
    438 #endif
    439 #ifdef __cplusplus
    440 }
    441 #endif
    442 
    443 #endif
    444 
    445 /** @} */ /* end of group */
    446 
    447 /** @} */ /* end of group addition */