#ifndef USER_SETTINGS_H
#define USER_SETTINGS_H

#include <stdint.h>
#include <string.h>
#include <wolfssl/ssl.h>
#include <wolfssl/wolfcrypt/types.h>

/* Configuration */
#define WOLFSSL_USER_IO
#define WOLFSSL_GENERAL_ALIGNMENT 4
#define WOLFSSL_SMALL_STACK
#define WOLFSSL_BASE64_ENCODE
#define WOLFSSL_SHA512

#define HAVE_AESGCM
#define HAVE_CURVE25519
#define HAVE_HKDF
#define HAVE_HASHDRBG
#define HAVE_CHACHA
#define HAVE_POLY1305
#define HAVE_ONE_TIME_AUTH
#define HAVE_TLS_EXTENSIONS
#define HAVE_SUPPORTED_CURVES
#define HAVE_ERRNO_H
#define HAVE_LWIP_NATIVE

#define FP_LUT                   4
#define FP_MAX_BITS              2048 /* 4096 */
#define FP_MAX_BITS_ECC          512
#define ALT_ECC_SIZE
#define USE_FAST_MATH
#define SMALL_SESSION_CACHE
#define CURVED25519_SMALL
#define RSA_LOW_MEM
#define GCM_SMALL
#define ECC_SHAMIR
#define USE_SLOW_SHA2
#define MP_LOW_MEM
#define TFM_TIMING_RESISTANT
//#define TFM_ARM


/* Remove Features */
#define NO_DEV_RANDOM
#define NO_WRITEV
#define NO_MAIN_DRIVER
#define NO_DEV_RANDOM
#define NO_MD4
#define NO_RABBIT
#define NO_HC128
#define NO_DSA
#define NO_PWDBASED
#define NO_PSK
#define NO_64BIT
#define NO_OLD_TLS
#define ECC_USER_CURVES /* Disables P-112, P-128, P-160, P-192, P-224, P-384, P-521 but leaves P-256 enabled */
#define NO_MD5
#define NO_RC4


/* Benchmark / Testing */
#define BENCH_EMBEDDED
#define USE_CERT_BUFFERS_1024


#define SOCKET_T int
/*
#define inet_addr wolfSSL_inet_addr
#include <string.h>
static unsigned long wolfSSL_inet_addr(const char *cp)
{
    unsigned int a[4] ; unsigned long ret ;
    sscanf(cp, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]) ;
    ret = ((a[3]<<24) + (a[2]<<16) + (a[1]<<8) + a[0]) ;
    return(ret) ;
}
*/

/* Custom functions */
//extern uint32_t rand_gen(void);
//#define CUSTOM_RAND_GENERATE rand_gen
//#define CUSTOM_RAND_TYPE     uint32_t

extern double current_time(int reset);
#define WOLFSSL_USER_CURRTIME

enum {
    WS_SELECT_FAIL,
    WS_SELECT_TIMEOUT,
    WS_SELECT_RECV_READY,
    WS_SELECT_ERROR_READY
};

#define WMEMCPY memcpy

#include <lwip/sockets.h>
#define WFIONREAD FIONREAD
static inline void ws_Ioctl(int fd, int flag, int* ret)
{
    (void)flag;
    int status;
    uint32_t bytesSz;

    bytesSz = sizeof(*ret);
    status = getsockopt(fd, SOL_SOCKET, WFIONREAD, ret, &bytesSz);
    if (status != 0) {
        /*
        WLOG(WS_LOG_ERROR, "Error calling getsockopt()");
        *ret = 0;
        */
    }
}
#define WIOCTL ws_Ioctl

#include "wolfssl_test.h"

#endif