/*
 * Ouroboros - Copyright (C) 2016 - 2026
 *
 * Ouroboros library configuration
 *
 *    Dimitri Staessens <dimitri@ouroboros.rocks>
 *    Sander Vrijders   <sander@ouroboros.rocks>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., http://www.fsf.org/about/contact/.
 */

#ifndef MILLION
#define MILLION  1000000LL
#endif

#ifndef BILLION
#define BILLION  1000000000LL
#endif

#cmakedefine HAVE_SYS_RANDOM
#cmakedefine HAVE_EXPLICIT_BZERO
#cmakedefine HAVE_LIBGCRYPT
#cmakedefine HAVE_OPENSSL
#ifdef HAVE_OPENSSL
#cmakedefine HAVE_OPENSSL_ML_KEM
#cmakedefine HAVE_OPENSSL_ML_DSA
#cmakedefine HAVE_OPENSSL_SLH_DSA
#define HAVE_ENCRYPTION
#define SECMEM_MINSIZE           @SECMEM_MINSIZE@
#endif
#define PROC_SECMEM_MAX          @PROC_SECMEM_MAX@

#define SYS_MAX_FLOWS            @SYS_MAX_FLOWS@

#cmakedefine                     QOS_DISABLE_CRC
#cmakedefine                     HAVE_OPENSSL_RNG
#cmakedefine                     HAVE_PCLMUL
#cmakedefine                     HAVE_PMULL

#define SHM_LOCKFILE_NAME        "@SHM_LOCKFILE_NAME@"
#define FLOW_ALLOC_TIMEOUT        @FLOW_ALLOC_TIMEOUT@

#define TPM_DEBUG_REPORT_INTERVAL @TPM_DEBUG_REPORT_INTERVAL@
#define TPM_DEBUG_ABORT_TIMEOUT   @TPM_DEBUG_ABORT_TIMEOUT@

#if defined(__linux__) || (defined(__MACH__) && !defined(__APPLE__))
/* Avoid a bug in robust mutex implementation of glibc 2.25 */
    #include <features.h>
    #if !defined(__GLIBC__) || !(__GLIBC__ == 2 && __GLIBC_MINOR__ == 25)
    #cmakedefine HAVE_ROBUST_MUTEX
    #endif
#else
#cmakedefine HAVE_ROBUST_MUTEX
#endif

#cmakedefine HAVE_FUSE
#ifdef HAVE_FUSE
#define FUSE_PREFIX         "@FUSE_PREFIX@"
#cmakedefine PROC_FLOW_STATS
#endif

#cmakedefine HAVE_LIBURCU

#cmakedefine FRCT_DEBUG_STDOUT

#define PTHREAD_COND_CLOCK  @PTHREAD_COND_CLOCK@

#define PROC_MAX_FLOWS      @PROC_MAX_FLOWS@
#define PROC_RES_FDS        @PROC_RES_FDS@
#define PROC_MAX_FQUEUES    @PROC_MAX_FQUEUES@

/* Default Delta-t parameters */
#cmakedefine                FRCT_LINUX_RTT_ESTIMATOR
#define DELT_A              (@DELTA_T_ACK@)                  /* ms */
#define DELT_R              (@DELTA_T_RTX@)                  /* ms */

#define RQ_SIZE             (@FRCT_REORDER_QUEUE_SIZE@)
#define START_WINDOW        (@FRCT_START_WINDOW@)
#define RTO_MIN             (@FRCT_RTO_MIN@ * 1000)
#define RTO_DIV             (@FRCT_RTO_INC_FACTOR@)
#define MDEV_MUL            (@FRCT_RTO_MDEV_MULTIPLIER@)

#define TICTIME             (@FRCT_TICK_TIME@ * 1000)        /* ns */

/* Retransmission tuning */
#define RXMQ_RES            (@RXM_MIN_RESOLUTION@)           /* 2^N ns */
#define RXMQ_BUMP           (@RXM_WHEEL_MULTIPLIER@)
#define RXMQ_LVLS           (@RXM_WHEEL_LEVELS@)
#define RXMQ_SLOTS          (@RXM_WHEEL_SLOTS_PER_LEVEL@)

#define ACKQ_SLOTS          (@ACK_WHEEL_SLOTS@)
#define ACKQ_RES            (@ACK_WHEEL_RESOLUTION@)         /* 2^N ns */

#define KEY_LEAF_BITS       (@KEY_LEAF_BITS@)       /* pkts/leaf-key = 2^n */
#define KEY_NODE_BITS       (@KEY_NODE_BITS@)       /* leaf-keys/node = 2^n */
#define KEY_NODE_COUNT      (@KEY_NODE_COUNT@)      /* node keys/batch N */
#define KEY_REKEY_WATERMARK (@KEY_REKEY_WATERMARK@) /* node-keys-left trig */
#define KEY_REPLAY_WINDOW   (@KEY_REPLAY_WINDOW@)   /* rx replay win pkts */
