diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/anastasis.h | 1 | ||||
-rw-r--r-- | src/include/anastasis_crypto_lib.h | 2 | ||||
-rw-r--r-- | src/include/anastasis_service.h | 188 | ||||
-rw-r--r-- | src/include/anastasis_testing_lib.h | 10 | ||||
-rw-r--r-- | src/include/platform.h | 214 |
5 files changed, 349 insertions, 66 deletions
diff --git a/src/include/anastasis.h b/src/include/anastasis.h index fd1275c..ea49ee7 100644 --- a/src/include/anastasis.h +++ b/src/include/anastasis.h @@ -1071,7 +1071,6 @@ struct ANASTASIS_ShareResult */ enum ANASTASIS_UploadStatus ec; - } provider_failure; } details; diff --git a/src/include/anastasis_crypto_lib.h b/src/include/anastasis_crypto_lib.h index 648a8eb..8cbc954 100644 --- a/src/include/anastasis_crypto_lib.h +++ b/src/include/anastasis_crypto_lib.h @@ -21,7 +21,7 @@ * @author Dennis Neufeld */ #include <jansson.h> -#include <gnunet/gnunet_crypto_lib.h> +#include <gnunet/gnunet_util_lib.h> /** diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h index ba55314..2f30a8b 100644 --- a/src/include/anastasis_service.h +++ b/src/include/anastasis_service.h @@ -51,51 +51,82 @@ struct ANASTASIS_AuthorizationMethodConfig */ struct ANASTASIS_Config { - /** - * Protocol version supported by the server. - */ - const char *version; /** - * Business name of the anastasis provider. + * HTTP status returned. */ - const char *business_name; + unsigned int http_status; /** - * Array of authorization methods supported by the server. + * Taler-specific error code, #TALER_EC_NONE on success. */ - const struct ANASTASIS_AuthorizationMethodConfig *methods; + enum TALER_ErrorCode ec; /** - * Length of the @e methods array. + * Full response in JSON, if provided. */ - unsigned int methods_length; + const json_t *response; /** - * Maximum size of an upload in megabytes. + * Details depending on @e http_status. */ - uint32_t storage_limit_in_megabytes; + union + { - /** - * Annual fee for an account / policy upload. - */ - struct TALER_Amount annual_fee; + /** + * Details on #MHD_HTTP_OK. + */ + struct + { - /** - * Fee for a truth upload. - */ - struct TALER_Amount truth_upload_fee; + /** + * Protocol version supported by the server. + */ + const char *version; - /** - * Maximum legal liability for data loss covered by the - * provider. - */ - struct TALER_Amount liability_limit; + /** + * Business name of the anastasis provider. + */ + const char *business_name; - /** - * Provider salt. - */ - struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt; + /** + * Array of authorization methods supported by the server. + */ + const struct ANASTASIS_AuthorizationMethodConfig *methods; + + /** + * Length of the @e methods array. + */ + unsigned int methods_length; + + /** + * Maximum size of an upload in megabytes. + */ + uint32_t storage_limit_in_megabytes; + + /** + * Annual fee for an account / policy upload. + */ + struct TALER_Amount annual_fee; + + /** + * Fee for a truth upload. + */ + struct TALER_Amount truth_upload_fee; + + /** + * Maximum legal liability for data loss covered by the + * provider. + */ + struct TALER_Amount liability_limit; + + /** + * Provider salt. + */ + struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt; + } ok; + + } details; }; @@ -107,12 +138,10 @@ struct ANASTASIS_Config * the server provided an acceptable response. * * @param cls closure - * @param http_status the HTTP status * @param acfg configuration obtained, NULL if we could not parse it */ typedef void (*ANASTASIS_ConfigCallback)(void *cls, - unsigned int http_status, const struct ANASTASIS_Config *acfg); @@ -185,15 +214,45 @@ struct ANASTASIS_MetaDownloadDetails { /** - * Version-sorted array of meta data we downloaded. + * HTTP status returned. + */ + unsigned int http_status; + + /** + * Taler-specific error code, #TALER_EC_NONE on success. + */ + enum TALER_ErrorCode ec; + + /** + * Full response in JSON, if provided. */ - const struct ANASTASIS_MetaDataEntry *metas; + const json_t *response; /** - * Number of entries in @e metas. + * Details depending on @e http_status. */ - size_t metas_length; + union + { + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Version-sorted array of meta data we downloaded. + */ + const struct ANASTASIS_MetaDataEntry *metas; + + /** + * Number of entries in @e metas. + */ + size_t metas_length; + + } ok; + + } details; }; @@ -201,13 +260,11 @@ struct ANASTASIS_MetaDownloadDetails * Callback to process a GET /policy/$POL/meta request * * @param cls closure - * @param http_status HTTP status code for this request * @param dd the response details */ typedef void (*ANASTASIS_PolicyMetaLookupCallback) ( void *cls, - unsigned int http_status, const struct ANASTASIS_MetaDownloadDetails *dd); @@ -247,30 +304,57 @@ ANASTASIS_policy_meta_lookup_cancel ( */ struct ANASTASIS_DownloadDetails { - /** - * Signature (already verified). - */ - struct ANASTASIS_AccountSignatureP sig; /** - * Hash over @e policy and @e policy_size. + * HTTP status returned. */ - struct GNUNET_HashCode curr_policy_hash; + unsigned int http_status; /** - * The backup we downloaded. + * Taler-specific error code, #TALER_EC_NONE on success. */ - const void *policy; + enum TALER_ErrorCode ec; /** - * Number of bytes in @e backup. + * Details depending on @e http_status. */ - size_t policy_size; + union + { + + /** + * Details on #MHD_HTTP_OK. + */ + struct + { + + /** + * Signature (already verified). + */ + struct ANASTASIS_AccountSignatureP sig; + + /** + * Hash over @e policy and @e policy_size. + */ + struct GNUNET_HashCode curr_policy_hash; + + /** + * The backup we downloaded. + */ + const void *policy; + + /** + * Number of bytes in @e backup. + */ + size_t policy_size; + + /** + * Policy version returned by the service. + */ + uint32_t version; + } ok; + + } details; - /** - * Policy version returned by the service. - */ - uint32_t version; }; @@ -284,12 +368,10 @@ struct ANASTASIS_PolicyLookupOperation; * Callback to process a GET /policy request * * @param cls closure - * @param http_status HTTP status code for this request * @param dd the response details */ typedef void (*ANASTASIS_PolicyLookupCallback) (void *cls, - unsigned int http_status, const struct ANASTASIS_DownloadDetails *dd); diff --git a/src/include/anastasis_testing_lib.h b/src/include/anastasis_testing_lib.h index b5036ff..62cde06 100644 --- a/src/include/anastasis_testing_lib.h +++ b/src/include/anastasis_testing_lib.h @@ -130,15 +130,15 @@ op (truth, const struct ANASTASIS_Truth *) \ op (policy, const struct ANASTASIS_Policy *) \ op (provider_salt, const struct ANASTASIS_CRYPTO_ProviderSaltP) \ - op (core_secret, const void *) \ + op (core_secret, const void) \ op (truth_key, const struct ANASTASIS_CRYPTO_TruthKeyP) \ op (account_pub, const struct ANASTASIS_CRYPTO_AccountPublicKeyP) \ op (account_priv, const struct ANASTASIS_CRYPTO_AccountPrivateKeyP) \ op (payment_secret, const struct ANASTASIS_PaymentSecretP) \ op (truth_uuid, const struct ANASTASIS_CRYPTO_TruthUUIDP) \ op (eks, const struct ANASTASIS_CRYPTO_EncryptedKeyShareP) \ - op (code, const char *) \ - op (filename, const char *) + op (code, const char) \ + op (filename, const char) /** @@ -552,7 +552,7 @@ enum ANASTASIS_TESTING_SecretShareOption * @param id_data ID data to generate user identifier * @param core_secret core secret to backup/recover * @param core_secret_size size of @a core_secret - * @param http_status expected HTTP status. + * @param want_status expected status. * @param sso secret share options * @param ... NULL-terminated list of policy create commands * @return the command @@ -566,7 +566,7 @@ ANASTASIS_TESTING_cmd_secret_share ( const json_t *id_data, const void *core_secret, size_t core_secret_size, - unsigned int http_status, + enum ANASTASIS_ShareStatus want_status, enum ANASTASIS_TESTING_SecretShareOption sso, ...); diff --git a/src/include/platform.h b/src/include/platform.h index 7667460..0fd6672 100644 --- a/src/include/platform.h +++ b/src/include/platform.h @@ -26,10 +26,10 @@ /* Include our configuration header */ #ifndef HAVE_USED_CONFIG_H -# define HAVE_USED_CONFIG_H -# ifdef HAVE_CONFIG_H -# include "anastasis_config.h" -# endif +#define HAVE_USED_CONFIG_H +#ifdef HAVE_CONFIG_H +#include "anastasis_config.h" +#endif #endif @@ -69,8 +69,210 @@ /* Include the features available for GNU source */ #define _GNU_SOURCE -/* Include GNUnet's platform file */ -#include <gnunet/platform.h> + +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + +#ifdef __clang__ +#undef HAVE_STATIC_ASSERT +#endif + +/** + * These may be expensive, but good for debugging... + */ +#define ALLOW_EXTRA_CHECKS GNUNET_YES + +/** + * For strptime (glibc2 needs this). + */ +#ifndef _XOPEN_SOURCE +#define _XOPEN_SOURCE 499 +#endif + +#ifndef _REENTRANT +#define _REENTRANT +#endif + +/* configuration options */ + +#define VERBOSE_STATS 0 + +#include <netdb.h> +#include <sys/socket.h> +#include <sys/un.h> +#if HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif +#if HAVE_NETINET_IN_SYSTM_H +#include <netinet/in_systm.h> +#endif +#if HAVE_NETINET_IP_H +#include <netinet/ip.h> /* superset of previous */ +#endif +#include <arpa/inet.h> +#include <netinet/tcp.h> +#include <pwd.h> +#include <sys/ioctl.h> +#include <sys/wait.h> +#include <grp.h> + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdarg.h> +#include <stdbool.h> +#include <errno.h> +#include <signal.h> +#include <libgen.h> +#ifdef HAVE_MALLOC_H +#include <malloc.h> /* for mallinfo on GNU */ +#endif +#include <unistd.h> /* KLB_FIX */ +#include <sys/stat.h> +#include <sys/types.h> +#include <dirent.h> /* KLB_FIX */ +#include <fcntl.h> +#include <math.h> +#if HAVE_SYS_PARAM_H +#include <sys/param.h> +#endif +#if HAVE_SYS_TIME_H +#include <sys/time.h> +#endif +#include <time.h> +#ifdef BSD +#include <net/if.h> +#endif +#if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__) +#include <semaphore.h> +#endif +#ifdef DARWIN +#include <dlfcn.h> +#include <semaphore.h> +#include <net/if.h> +#endif +#if defined(__linux__) || defined(GNU) +#include <net/if.h> +#endif +#ifdef SOLARIS +#include <sys/sockio.h> +#include <sys/filio.h> +#include <sys/loadavg.h> +#include <semaphore.h> +#endif +#if HAVE_UCRED_H +#include <ucred.h> +#endif +#if HAVE_SYS_UCRED_H +#include <sys/ucred.h> +#endif +#if HAVE_IFADDRS_H +#include <ifaddrs.h> +#endif +#include <errno.h> +#include <limits.h> + +#if HAVE_VFORK_H +#include <vfork.h> +#endif + +#include <ctype.h> +#if HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif + +#if HAVE_ENDIAN_H +#include <endian.h> +#endif +#if HAVE_SYS_ENDIAN_H +#include <sys/endian.h> +#endif + +#define DIR_SEPARATOR '/' +#define DIR_SEPARATOR_STR "/" +#define PATH_SEPARATOR ':' +#define PATH_SEPARATOR_STR ":" +#define NEWLINE "\n" + +#include <locale.h> +#include "gettext.h" +/** + * GNU gettext support macro. + */ +#define _(String) dgettext (PACKAGE, String) +#define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor" + +#include <sys/mman.h> + +/* FreeBSD_kernel is not defined on the now discontinued kFreeBSD */ +#if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__) +#define __BYTE_ORDER BYTE_ORDER +#define __BIG_ENDIAN BIG_ENDIAN +#endif + +#ifdef DARWIN +#define __BYTE_ORDER BYTE_ORDER +#define __BIG_ENDIAN BIG_ENDIAN +/* not available on darwin, override configure */ +#undef HAVE_STAT64 +#undef HAVE_MREMAP +#endif + +#if ! HAVE_ATOLL +long long +atoll (const char *nptr); + +#endif + +#if ENABLE_NLS +#include "langinfo.h" +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX ((size_t) (-1)) +#endif + +#ifndef O_LARGEFILE +#define O_LARGEFILE 0 +#endif + +/** + * AI_NUMERICSERV not defined in windows. Then we just do without. + */ +#ifndef AI_NUMERICSERV +#define AI_NUMERICSERV 0 +#endif + + +#if defined(__sparc__) +#define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove (&__tmp, &(val), \ + sizeof((val))); \ + __tmp; }) +#else +#define MAKE_UNALIGNED(val) val +#endif + +/** + * The termination signal + */ +#define GNUNET_TERM_SIG SIGTERM + + +#ifndef PATH_MAX +/** + * Assumed maximum path length. + */ +#define PATH_MAX 4096 +#endif + +#if HAVE_THREAD_LOCAL_GCC +#define ANASTASIS_THREAD_LOCAL __thread +#else +#define ANASTASIS_THREAD_LOCAL +#endif + /* Do not use shortcuts for gcrypt mpi */ #define GCRYPT_NO_MPI_MACROS 1 |