diff --git a/cpp/devices/tap_driver.cpp b/cpp/devices/tap_driver.cpp index 8f29634a..fa315f84 100644 --- a/cpp/devices/tap_driver.cpp +++ b/cpp/devices/tap_driver.cpp @@ -197,7 +197,7 @@ string TapDriver::CreateBridge(int bridge_fd, int ip_fd) string TapDriver::SetAddressAndNetMask(int fd, const string &interface) const { - const auto [address, netmask] = ExtractAddressAndMask(inet); + const auto [address, netmask] = ExtractAddressAndMask(); if (address.empty() || netmask.empty()) { return "Error extracting inet address and netmask"; } @@ -227,11 +227,11 @@ string TapDriver::SetAddressAndNetMask(int fd, const string &interface) const return ""; } -pair TapDriver::ExtractAddressAndMask(const string &addr) +pair TapDriver::ExtractAddressAndMask() const { - string address = addr; + string address = inet; string netmask = DEFAULT_NETMASK; - if (const auto &components = Split(addr, '/', 2); components.size() == 2) { + if (const auto &components = Split(inet, '/', 2); components.size() == 2) { address = components[0]; int m; diff --git a/cpp/devices/tap_driver.h b/cpp/devices/tap_driver.h index 5b4028e1..16cacfc7 100644 --- a/cpp/devices/tap_driver.h +++ b/cpp/devices/tap_driver.h @@ -60,7 +60,7 @@ class TapDriver static string IpLink(int, const string&, bool); static string BrSetIf(int fd, const string&, const string&, bool); string CreateBridge(int, int); - static pair ExtractAddressAndMask(const string&); + pair ExtractAddressAndMask() const; string SetAddressAndNetMask(int, const string&) const; string EnablePromiscuousMode() const;