kernel-netlink: Extract shared route handling code in net/ipsec

This commit is contained in:
Tobias Brunner
2020-03-10 10:30:39 +01:00
parent e23708bdf3
commit dfd261d2de
4 changed files with 108 additions and 135 deletions
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008-2019 Tobias Brunner
* Copyright (C) 2008-2020 Tobias Brunner
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -130,4 +130,50 @@ void* netlink_reserve(struct nlmsghdr *hdr, int buflen, int type, int len);
*/
u_int netlink_get_buflen();
/**
* Information about an installed route.
*/
struct route_entry_t {
/** Destination net */
chunk_t dst_net;
/** Destination net prefix length */
uint8_t prefixlen;
/** Name of the interface the route is bound to (optional) */
char *if_name;
/** Source IP of the route (virtual IP or %any) */
host_t *src_ip;
/** Gateway for this route (optional) */
host_t *gateway;
/** Whether the route was installed for a passthrough policy */
bool pass;
};
typedef struct route_entry_t route_entry_t;
/**
* Destroy a route entry.
*/
void route_entry_destroy(route_entry_t *this);
/**
* Clone a route entry.
*/
route_entry_t *route_entry_clone(const route_entry_t *this);
/**
* Hash a route entry (note that this only hashes the destination).
*/
u_int route_entry_hash(const route_entry_t *this);
/**
* Compare two route entries.
*/
bool route_entry_equals(const route_entry_t *a, const route_entry_t *b);
#endif /* KERNEL_NETLINK_SHARED_H_ */