linux/drivers/net/wireguard/selftest/allowedips.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2015-2019 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
 *
 * This contains some basic static unit tests for the allowedips data structure.
 * It also has two additional modes that are disabled and meant to be used by
 * folks directly playing with this file. If you define the macro
 * DEBUG_PRINT_TRIE_GRAPHVIZ to be 1, then every time there's a full tree in
 * memory, it will be printed out as KERN_DEBUG in a format that can be passed
 * to graphviz (the dot command) to visualize it. If you define the macro
 * DEBUG_RANDOM_TRIE to be 1, then there will be an extremely costly set of
 * randomized tests done against a trivial implementation, which may take
 * upwards of a half-hour to complete. There's no set of users who should be
 * enabling these, and the only developers that should go anywhere near these
 * nobs are the ones who are reading this comment.
 */

#ifdef DEBUG

#include <linux/siphash.h>

static __init void print_node(struct allowedips_node *node, u8 bits)
{}

static __init void print_tree(struct allowedips_node __rcu *top, u8 bits)
{}

enum {};

struct horrible_allowedips {};

struct horrible_allowedips_node {};

static __init void horrible_allowedips_init(struct horrible_allowedips *table)
{}

static __init void horrible_allowedips_free(struct horrible_allowedips *table)
{}

static __init inline union nf_inet_addr horrible_cidr_to_mask(u8 cidr)
{}

static __init inline u8 horrible_mask_to_cidr(union nf_inet_addr subnet)
{}

static __init inline void
horrible_mask_self(struct horrible_allowedips_node *node)
{}

static __init inline bool
horrible_match_v4(const struct horrible_allowedips_node *node, struct in_addr *ip)
{}

static __init inline bool
horrible_match_v6(const struct horrible_allowedips_node *node, struct in6_addr *ip)
{}

static __init void
horrible_insert_ordered(struct horrible_allowedips *table, struct horrible_allowedips_node *node)
{}

static __init int
horrible_allowedips_insert_v4(struct horrible_allowedips *table,
			      struct in_addr *ip, u8 cidr, void *value)
{}

static __init int
horrible_allowedips_insert_v6(struct horrible_allowedips *table,
			      struct in6_addr *ip, u8 cidr, void *value)
{}

static __init void *
horrible_allowedips_lookup_v4(struct horrible_allowedips *table, struct in_addr *ip)
{}

static __init void *
horrible_allowedips_lookup_v6(struct horrible_allowedips *table, struct in6_addr *ip)
{}


static __init void
horrible_allowedips_remove_by_value(struct horrible_allowedips *table, void *value)
{}

static __init bool randomized_test(void)
{}

static __init inline struct in_addr *ip4(u8 a, u8 b, u8 c, u8 d)
{}

static __init inline struct in6_addr *ip6(u32 a, u32 b, u32 c, u32 d)
{}

static __init struct wg_peer *init_peer(void)
{}

#define insert

#define maybe_fail()

#define test

#define test_negative

#define test_boolean(cond)

bool __init wg_allowedips_selftest(void)
{}

#undef test_negative
#undef test
#undef remove
#undef insert
#undef init_peer

#endif