tun-device: Remove the superfluous use of select() before read()
[strongswan.git] / src / libstrongswan / networking / tun_device.h
index b22a5d1..880369b 100644 (file)
@@ -23,7 +23,6 @@
 #ifndef TUN_DEVICE_H_
 #define TUN_DEVICE_H_
 
-#include <library.h>
 #include <networking/host.h>
 
 typedef struct tun_device_t tun_device_t;
@@ -32,8 +31,6 @@ typedef struct tun_device_t tun_device_t;
  * Class to create TUN devices
  *
  * Creating such a device requires the CAP_NET_ADMIN capability.
- *
- * @note The implementation is currently very Linux specific
  */
 struct tun_device_t {
 
@@ -43,7 +40,7 @@ struct tun_device_t {
         * @note This call blocks until a packet is available. It is a thread
         * cancellation point.
         *
-        * @param packet                the packet read from the device
+        * @param packet                the packet read from the device, allocated
         * @return                              TRUE if successful
         */
        bool (*read_packet)(tun_device_t *this, chunk_t *packet);
@@ -66,6 +63,14 @@ struct tun_device_t {
        bool (*set_address)(tun_device_t *this, host_t *addr, u_int8_t netmask);
 
        /**
+        * Get the IP address previously assigned to using set_address().
+        *
+        * @param netmask               pointer receiving the configured netmask, or NULL
+        * @return                              address previously set, NULL if none
+        */
+       host_t* (*get_address)(tun_device_t *this, u_int8_t *netmask);
+
+       /**
         * Bring the TUN device up
         *
         * @return                              TRUE if operation successful
@@ -95,6 +100,13 @@ struct tun_device_t {
        char *(*get_name)(tun_device_t *this);
 
        /**
+        * Get the underlying tun file descriptor.
+        *
+        * @return                              file descriptor of this tun device
+        */
+       int (*get_fd)(tun_device_t *this);
+
+       /**
         * Destroy a tun_device_t
         */
        void (*destroy)(tun_device_t *this);