summaryrefslogtreecommitdiff
path: root/src/libhydra/kernel/kernel_net.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libhydra/kernel/kernel_net.h')
-rw-r--r--src/libhydra/kernel/kernel_net.h74
1 files changed, 54 insertions, 20 deletions
diff --git a/src/libhydra/kernel/kernel_net.h b/src/libhydra/kernel/kernel_net.h
index a89e76804..8c448ddbc 100644
--- a/src/libhydra/kernel/kernel_net.h
+++ b/src/libhydra/kernel/kernel_net.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Tobias Brunner
+ * Copyright (C) 2008-2012 Tobias Brunner
* Copyright (C) 2007 Martin Willi
* Hochschule fuer Technik Rapperswil
*
@@ -23,10 +23,30 @@
#define KERNEL_NET_H_
typedef struct kernel_net_t kernel_net_t;
+typedef enum kernel_address_type_t kernel_address_type_t;
-#include <utils/enumerator.h>
-#include <utils/host.h>
+#include <collections/enumerator.h>
+#include <networking/host.h>
#include <plugins/plugin.h>
+#include <kernel/kernel_interface.h>
+
+/**
+ * Type of addresses (e.g. when enumerating them)
+ */
+enum kernel_address_type_t {
+ /** normal addresses (on regular, up, non-ignored) interfaces */
+ ADDR_TYPE_REGULAR = (1 << 0),
+ /** addresses on down interfaces */
+ ADDR_TYPE_DOWN = (1 << 1),
+ /** addresses on ignored interfaces */
+ ADDR_TYPE_IGNORED = (1 << 2),
+ /** addresses on loopback interfaces */
+ ADDR_TYPE_LOOPBACK = (1 << 3),
+ /** virtual IP addresses */
+ ADDR_TYPE_VIRTUAL = (1 << 4),
+ /** to enumerate all available addresses */
+ ADDR_TYPE_ALL = (1 << 5) - 1,
+};
/**
* Interface to the network subsystem of the kernel.
@@ -37,12 +57,19 @@ typedef struct kernel_net_t kernel_net_t;
struct kernel_net_t {
/**
+ * Get the feature set supported by this kernel backend.
+ *
+ * @return ORed feature-set of backend
+ */
+ kernel_feature_t (*get_features)(kernel_net_t *this);
+
+ /**
* Get our outgoing source address for a destination.
*
* Does a route lookup to get the source address used to reach dest.
* The returned host is allocated and must be destroyed.
* An optional src address can be used to check if a route is available
- * for given source to dest.
+ * for the given source to dest.
*
* @param dest target destination address
* @param src source address to check, or NULL
@@ -55,19 +82,24 @@ struct kernel_net_t {
*
* Does a route lookup to get the next hop used to reach dest.
* The returned host is allocated and must be destroyed.
+ * An optional src address can be used to check if a route is available
+ * for the given source to dest.
*
* @param dest target destination address
+ * @param src source address to check, or NULL
* @return next hop address, NULL if unreachable
*/
- host_t* (*get_nexthop)(kernel_net_t *this, host_t *dest);
+ host_t* (*get_nexthop)(kernel_net_t *this, host_t *dest, host_t *src);
/**
- * Get the interface name of a local address.
+ * Get the interface name of a local address. Interfaces that are down or
+ * ignored by config are not considered.
*
* @param host address to get interface name from
- * @return allocated interface name, or NULL if not found
+ * @param name allocated interface name (optional)
+ * @return TRUE if interface found and usable
*/
- char* (*get_interface) (kernel_net_t *this, host_t *host);
+ bool (*get_interface) (kernel_net_t *this, host_t *host, char **name);
/**
* Creates an enumerator over all local addresses.
@@ -76,12 +108,11 @@ struct kernel_net_t {
* enumerator gets destroyed.
* The hosts are read-only, do not modify of free.
*
- * @param include_down_ifaces TRUE to enumerate addresses from down interfaces
- * @param include_virtual_ips TRUE to enumerate virtual ip addresses
- * @return enumerator over host_t's
+ * @param which a combination of address types to enumerate
+ * @return enumerator over host_t's
*/
enumerator_t *(*create_address_enumerator) (kernel_net_t *this,
- bool include_down_ifaces, bool include_virtual_ips);
+ kernel_address_type_t which);
/**
* Add a virtual IP to an interface.
@@ -89,24 +120,27 @@ struct kernel_net_t {
* Virtual IPs are attached to an interface. If an IP is added multiple
* times, the IP is refcounted and not removed until del_ip() was called
* as many times as add_ip().
- * The virtual IP is attached to the interface where the iface_ip is found.
*
* @param virtual_ip virtual ip address to assign
- * @param iface_ip IP of an interface to attach virtual IP
+ * @param prefix prefix length to install with IP address, -1 for auto
+ * @param iface interface to install virtual IP on
* @return SUCCESS if operation completed
*/
- status_t (*add_ip) (kernel_net_t *this, host_t *virtual_ip,
- host_t *iface_ip);
+ status_t (*add_ip) (kernel_net_t *this, host_t *virtual_ip, int prefix,
+ char *iface);
/**
* Remove a virtual IP from an interface.
*
* The kernel interface uses refcounting, see add_ip().
*
- * @param virtual_ip virtual ip address to assign
+ * @param virtual_ip virtual ip address to remove
+ * @param prefix prefix length of the IP to uninstall, -1 for auto
+ * @param wait TRUE to wait until IP is gone
* @return SUCCESS if operation completed
*/
- status_t (*del_ip) (kernel_net_t *this, host_t *virtual_ip);
+ status_t (*del_ip) (kernel_net_t *this, host_t *virtual_ip, int prefix,
+ bool wait);
/**
* Add a route.
@@ -114,7 +148,7 @@ struct kernel_net_t {
* @param dst_net destination net
* @param prefixlen destination net prefix length
* @param gateway gateway for this route
- * @param src_ip sourc ip of the route
+ * @param src_ip source ip of the route
* @param if_name name of the interface the route is bound to
* @return SUCCESS if operation completed
* ALREADY_DONE if the route already exists
@@ -129,7 +163,7 @@ struct kernel_net_t {
* @param dst_net destination net
* @param prefixlen destination net prefix length
* @param gateway gateway for this route
- * @param src_ip sourc ip of the route
+ * @param src_ip source ip of the route
* @param if_name name of the interface the route is bound to
* @return SUCCESS if operation completed
*/