* The current MTU
*/
int mtu;
+
+ /**
+ * Associated address
+ */
+ host_t *address;
+
+ /**
+ * Netmask for address
+ */
+ u_int8_t netmask;
};
METHOD(tun_device_t, set_address, bool,
this->if_name, strerror(errno));
return FALSE;
}
+ this->address = addr->clone(addr);
+ this->netmask = netmask;
return TRUE;
}
+METHOD(tun_device_t, get_address, host_t*,
+ private_tun_device_t *this, u_int8_t *netmask)
+{
+ if (netmask && this->address)
+ {
+ *netmask = this->netmask;
+ }
+ return this->address;
+}
+
METHOD(tun_device_t, up, bool,
private_tun_device_t *this)
{
{
close(this->sock);
}
+ DESTROY_IF(this->address);
free(this);
}
.get_name = _get_name,
.get_fd = _get_fd,
.set_address = _set_address,
+ .get_address = _get_address,
.up = _up,
.destroy = _destroy,
},
*/
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
*