diff --git a/bindings/cpp/tuntap++.cc b/bindings/cpp/tuntap++.cc index 21e9b5c..d0c3a70 100644 --- a/bindings/cpp/tuntap++.cc +++ b/bindings/cpp/tuntap++.cc @@ -7,7 +7,7 @@ namespace tuntap { tuntap::tuntap(int mode, int id) - : _dev{tuntap_init()}, _started{true} + : _dev{::tuntap_init()}, _started{true} { if (mode != TUNTAP_MODE_ETHERNET && mode != TUNTAP_MODE_TUNNEL) { throw std::invalid_argument("Unknown tuntap mode"); @@ -15,7 +15,7 @@ tuntap::tuntap(int mode, int id) if (id < 0 || id > TUNTAP_ID_MAX) { throw std::invalid_argument("Tunnel ID is invalid"); } - if (tuntap_start(_dev, mode, id)) { + if (::tuntap_start(_dev, mode, id)) { throw std::runtime_error("tuntap_start failed"); } } @@ -23,7 +23,7 @@ tuntap::tuntap(int mode, int id) tuntap::~tuntap() { if (_started) { - tuntap_destroy(_dev); + ::tuntap_destroy(_dev); } } @@ -36,20 +36,20 @@ tuntap::tuntap(tuntap &&t) noexcept void tuntap::release() noexcept { - tuntap_release(_dev); + ::tuntap_release(_dev); _started = false; } std::string tuntap::name() const noexcept { - return std::string(tuntap_get_ifname(_dev)); + return std::string(::tuntap_get_ifname(_dev)); } void tuntap::name(std::string const &s) { - if (tuntap_set_ifname(_dev, s.c_str())) { + if (::tuntap_set_ifname(_dev, s.c_str())) { throw std::runtime_error("Failed to set ifname"); } } @@ -57,13 +57,13 @@ tuntap::name(std::string const &s) t_tun tuntap::native_handle() const noexcept { - return tuntap_get_fd(this->_dev); + return ::tuntap_get_fd(this->_dev); } void tuntap::up() { - if (tuntap_up(_dev)) { + if (::tuntap_up(_dev)) { throw std::runtime_error("Failed to bring up tuntap device"); } } @@ -71,7 +71,7 @@ tuntap::up() void tuntap::down() { - if (tuntap_down(_dev)) { + if (::tuntap_down(_dev)) { throw std::runtime_error("Failed to bring down tuntap device"); } } @@ -79,7 +79,7 @@ tuntap::down() int tuntap::mtu() const noexcept { - return tuntap_get_mtu(_dev); + return ::tuntap_get_mtu(_dev); } void @@ -88,7 +88,7 @@ tuntap::mtu(int m) if (m < 1 || m > 65535) { throw std::invalid_argument("Invalid mtu"); } - if (tuntap_set_mtu(_dev, m)) { + if (::tuntap_set_mtu(_dev, m)) { throw std::runtime_error("Failed to set mtu for tuntap device"); } } @@ -99,7 +99,7 @@ tuntap::ip(std::string const &s, int netmask) if (netmask > 128) { throw std::invalid_argument("Invalid netmask"); } - if (tuntap_set_ip(_dev, s.c_str(), netmask)) { + if (::tuntap_set_ip(_dev, s.c_str(), netmask)) { throw std::runtime_error("Failed to set ip for tuntap device"); } } @@ -107,19 +107,19 @@ tuntap::ip(std::string const &s, int netmask) int tuntap::read(void *buf, size_t len) noexcept { - return tuntap_read(_dev, buf, len); + return ::tuntap_read(_dev, buf, len); } int tuntap::write(void *buf, size_t len) noexcept { - return tuntap_write(_dev, buf, len); + return ::tuntap_write(_dev, buf, len); } void tuntap::nonblocking(bool b) { - if (tuntap_set_nonblocking(_dev, int(b))) { + if (::tuntap_set_nonblocking(_dev, int(b))) { throw std::runtime_error("Failed to change non-blocking state for tuntap device"); } }