Install virtual IPs via interface name, and use an interface lookup where required
[strongswan.git] / src / libhydra / kernel / kernel_interface.h
index 842b511..a5ee0b5 100644 (file)
@@ -48,7 +48,7 @@
 
 typedef struct kernel_interface_t kernel_interface_t;
 
-#include <utils/host.h>
+#include <networking/host.h>
 #include <crypto/prf_plus.h>
 
 #include <kernel/kernel_listener.h>
@@ -305,13 +305,14 @@ struct kernel_interface_t {
        host_t* (*get_nexthop)(kernel_interface_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
         * @param name                  allocated interface name (optional)
         * @return                              TRUE if interface found and usable
         */
-       bool (*get_interface) (kernel_interface_t *this, host_t *host, char **name);
+       bool (*get_interface)(kernel_interface_t *this, host_t *host, char **name);
 
        /**
         * Creates an enumerator over all local addresses.
@@ -320,14 +321,11 @@ struct kernel_interface_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
-        * @param include_loopback              TRUE to enumerate addresses on loopback interfaces
-        * @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_interface_t *this,
-                                                       bool include_down_ifaces, bool include_virtual_ips,
-                                                       bool include_loopback);
+                                                                                               kernel_address_type_t which);
 
        /**
         * Add a virtual IP to an interface.
@@ -335,14 +333,14 @@ struct kernel_interface_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 IP with, -1 for auto
+        * @param iface                 interface to install virtual IP on
         * @return                              SUCCESS if operation completed
         */
-       status_t (*add_ip) (kernel_interface_t *this, host_t *virtual_ip,
-                                               host_t *iface_ip);
+       status_t (*add_ip) (kernel_interface_t *this, host_t *virtual_ip, int prefix,
+                                               char *iface);
 
        /**
         * Remove a virtual IP from an interface.
@@ -350,9 +348,10 @@ struct kernel_interface_t {
         * The kernel interface uses refcounting, see add_ip().
         *
         * @param virtual_ip    virtual ip address to assign
+        * @param prefix                prefix length of the IP to uninstall, -1 for auto
         * @return                              SUCCESS if operation completed
         */
-       status_t (*del_ip) (kernel_interface_t *this, host_t *virtual_ip);
+       status_t (*del_ip) (kernel_interface_t *this, host_t *virtual_ip, int prefix);
 
        /**
         * Add a route.
@@ -418,6 +417,13 @@ struct kernel_interface_t {
        bool (*is_interface_usable)(kernel_interface_t *this, const char *iface);
 
        /**
+        * Check if interfaces are excluded by config.
+        *
+        * @return                              TRUE if no interfaces are exclued by config
+        */
+       bool (*all_interfaces_usable)(kernel_interface_t *this);
+
+       /**
         * Tries to find an IP address of a local interface that is included in the
         * supplied traffic selector.
         *