]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
tun_device: add a getter for the underlying file descriptor
authorMartin Willi <martin@revosec.ch>
Fri, 12 Apr 2013 10:42:14 +0000 (12:42 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 6 May 2013 14:10:11 +0000 (16:10 +0200)
src/libstrongswan/networking/tun_device.c
src/libstrongswan/networking/tun_device.h

index 691d96c8e0ed7b37293f8968aecd87e6dae63a56..b0be8688e628de564959ff33a9281eb2d0c222f6 100644 (file)
@@ -192,6 +192,12 @@ METHOD(tun_device_t, get_name, char*,
        return this->if_name;
 }
 
+METHOD(tun_device_t, get_fd, int,
+       private_tun_device_t *this)
+{
+       return this->tunfd;
+}
+
 METHOD(tun_device_t, write_packet, bool,
        private_tun_device_t *this, chunk_t packet)
 {
@@ -398,6 +404,7 @@ tun_device_t *tun_device_create(const char *name_tmpl)
                        .get_mtu = _get_mtu,
                        .set_mtu = _set_mtu,
                        .get_name = _get_name,
+                       .get_fd = _get_fd,
                        .set_address = _set_address,
                        .up = _up,
                        .destroy = _destroy,
index b22a5d170e7bf60c7ac166e30bc3e3bd4f599c94..3bdb02a5d3facf12f6f69b2d18ab8cd50fcd9c56 100644 (file)
@@ -94,6 +94,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
         */