From 3d74722cc77309f626887f8e16cd2e47585ed004 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 22 Aug 2016 01:56:00 +0200 Subject: routingtable: hyphen was ugly --- src/routingtable.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/routingtable.h (limited to 'src/routingtable.h') diff --git a/src/routingtable.h b/src/routingtable.h new file mode 100644 index 0000000..c4fd05d --- /dev/null +++ b/src/routingtable.h @@ -0,0 +1,41 @@ +/* Copyright 2015-2016 Jason A. Donenfeld . All Rights Reserved. */ + +#ifndef ROUTINGTABLE_H +#define ROUTINGTABLE_H + +#include "wireguard.h" +#include +#include +#include + +struct wireguard_peer; +struct routing_table_node; + +struct routing_table { + struct routing_table_node __rcu *root4; + struct routing_table_node __rcu *root6; + struct mutex table_update_lock; +}; + +void routing_table_init(struct routing_table *table); +void routing_table_free(struct routing_table *table); +int routing_table_insert_v4(struct routing_table *table, const struct in_addr *ip, uint8_t cidr, struct wireguard_peer *peer); +int routing_table_insert_v6(struct routing_table *table, const struct in6_addr *ip, uint8_t cidr, struct wireguard_peer *peer); +int routing_table_remove_v4(struct routing_table *table, const struct in_addr *ip, uint8_t cidr); +int routing_table_remove_v6(struct routing_table *table, const struct in6_addr *ip, uint8_t cidr); +int routing_table_remove_by_peer(struct routing_table *table, struct wireguard_peer *peer); +int routing_table_walk_ips(struct routing_table *table, void *ctx, int (*func)(void *ctx, struct wireguard_peer *peer, union nf_inet_addr ip, uint8_t cidr, int family)); +int routing_table_walk_ips_by_peer(struct routing_table *table, void *ctx, struct wireguard_peer *peer, int (*func)(void *ctx, union nf_inet_addr ip, uint8_t cidr, int family)); +int routing_table_walk_ips_by_peer_sleepable(struct routing_table *table, void *ctx, struct wireguard_peer *peer, int (*func)(void *ctx, union nf_inet_addr ip, uint8_t cidr, int family)); + +/* These return a strong reference to a peer: */ +struct wireguard_peer *routing_table_lookup_v4(struct routing_table *table, const struct in_addr *ip); +struct wireguard_peer *routing_table_lookup_v6(struct routing_table *table, const struct in6_addr *ip); +struct wireguard_peer *routing_table_lookup_dst(struct routing_table *table, struct sk_buff *skb); +struct wireguard_peer *routing_table_lookup_src(struct routing_table *table, struct sk_buff *skb); + +#ifdef DEBUG +bool routing_table_selftest(void); +#endif + +#endif -- cgit v1.2.3-59-g8ed1b