Skip to content

Commit 57d79c2

Browse files
committed
remove dead code for Windows pre-Vista
Signed-off-by: Heiko Hund <[email protected]>
1 parent 1483c12 commit 57d79c2

File tree

1 file changed

+0
-162
lines changed

1 file changed

+0
-162
lines changed

openvpn/tun/win/client/tunsetup.hpp

Lines changed: 0 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ class Setup : public SetupBase
368368
}
369369
}
370370

371-
#if _WIN32_WINNT >= 0x0600
372371
// Configure TAP adapter on Vista and higher
373372
void adapter_config(HANDLE th,
374373
const std::wstring &openvpn_app_path,
@@ -807,167 +806,6 @@ class Setup : public SetupBase
807806
if (pull.proxy_auto_config_url.defined())
808807
ProxySettings::add_actions<WinProxySettings>(pull, create, destroy);
809808
}
810-
#else
811-
// Configure TAP adapter for pre-Vista
812-
// Currently we don't support IPv6 on pre-Vista
813-
void adapter_config(HANDLE th,
814-
const std::wstring &openvpn_app_path,
815-
const Util::TapNameGuidPair &tap,
816-
const TunBuilderCapture &pull,
817-
const bool l2_post,
818-
ActionList &create,
819-
ActionList &destroy,
820-
std::ostream &os)
821-
{
822-
// Windows interface index
823-
const std::string tap_index_name = tap.index_or_name();
824-
825-
// get default gateway
826-
const Util::DefaultGateway gw;
827-
828-
// set local4 to point to IPv4 route configurations
829-
const TunBuilderCapture::RouteAddress *local4 = pull.vpn_ipv4();
830-
831-
// This section skipped on layer 2 post-config
832-
if (!l2_post)
833-
{
834-
// Make sure the TAP adapter is set for DHCP
835-
{
836-
const Util::IPAdaptersInfo ai;
837-
if (!ai.is_dhcp_enabled(tap.index))
838-
{
839-
os << "TAP: DHCP is disabled, attempting to enable" << std::endl;
840-
ActionList::Ptr cmds(new ActionList());
841-
cmds->add(new Util::ActionEnableDHCP(tap));
842-
cmds->execute(os);
843-
}
844-
}
845-
846-
// Set IPv4 Interface
847-
if (local4)
848-
{
849-
// Process ifconfig and topology
850-
const std::string netmask = IPv4::Addr::netmask_from_prefix_len(local4->prefix_length).to_string();
851-
const IP::Addr localaddr = IP::Addr::from_string(local4->address);
852-
if (local4->net30)
853-
Util::tap_configure_topology_net30(th, localaddr, local4->prefix_length);
854-
else
855-
Util::tap_configure_topology_subnet(th, localaddr, local4->prefix_length);
856-
}
857-
858-
// On pre-Vista, set up TAP adapter DHCP masquerade for
859-
// configuring adapter properties.
860-
{
861-
os << "TAP: configure DHCP masquerade" << std::endl;
862-
Util::TAPDHCPMasquerade dhmasq;
863-
dhmasq.init_from_capture(pull);
864-
dhmasq.ioctl(th);
865-
}
866-
867-
// set TAP media status to CONNECTED
868-
if (tun_type_ == TapWindows6)
869-
Util::tap_set_media_status(th, true);
870-
871-
// ARP
872-
Util::flush_arp(tap.index, os);
873-
874-
// DHCP release/renew
875-
{
876-
const Util::InterfaceInfoList ii;
877-
Util::dhcp_release(ii, tap.index, os);
878-
Util::dhcp_renew(ii, tap.index, os);
879-
}
880-
881-
// Wait for TAP adapter to come up
882-
{
883-
bool succeed = false;
884-
const Util::IPNetmask4 vpn_addr(pull, "VPN IP");
885-
for (int i = 1; i <= 30; ++i)
886-
{
887-
os << '[' << i << "] waiting for TAP adapter to receive DHCP settings..." << std::endl;
888-
const Util::IPAdaptersInfo ai;
889-
if (ai.is_up(tap.index, vpn_addr))
890-
{
891-
succeed = true;
892-
break;
893-
}
894-
::Sleep(1000);
895-
}
896-
if (!succeed)
897-
throw tun_win_setup("TAP adapter DHCP handshake failed");
898-
}
899-
900-
// Pre route-add sleep
901-
os << "Sleeping 5 seconds prior to adding routes..." << std::endl;
902-
::Sleep(5000);
903-
}
904-
905-
// Process routes
906-
for (auto &route : pull.add_routes)
907-
{
908-
const std::string metric = route_metric_opt(pull, route, MT_ROUTE);
909-
if (!route.ipv6)
910-
{
911-
if (local4)
912-
{
913-
const std::string netmask = IPv4::Addr::netmask_from_prefix_len(route.prefix_length).to_string();
914-
create.add(new WinCmd("route ADD " + route.address + " MASK " + netmask + ' ' + local4->gateway + metric));
915-
destroy.add(new WinCmd("route DELETE " + route.address + " MASK " + netmask + ' ' + local4->gateway));
916-
}
917-
else
918-
throw tun_win_setup("IPv4 routes pushed without IPv4 ifconfig");
919-
}
920-
}
921-
922-
// Process exclude routes
923-
if (!pull.exclude_routes.empty())
924-
{
925-
if (gw.defined())
926-
{
927-
for (auto &route : pull.exclude_routes)
928-
{
929-
const std::string metric = route_metric_opt(pull, route, MT_ROUTE);
930-
if (!route.ipv6)
931-
{
932-
const std::string netmask = IPv4::Addr::netmask_from_prefix_len(route.prefix_length).to_string();
933-
create.add(new WinCmd("route ADD " + route.address + " MASK " + netmask + ' ' + gw.gateway_address() + metric));
934-
destroy.add(new WinCmd("route DELETE " + route.address + " MASK " + netmask + ' ' + gw.gateway_address()));
935-
}
936-
}
937-
}
938-
else
939-
os << "NOTE: exclude routes error: cannot detect default gateway" << std::endl;
940-
}
941-
942-
// Process IPv4 redirect-gateway
943-
if (pull.reroute_gw.ipv4)
944-
{
945-
// add server bypass route
946-
if (gw.defined())
947-
{
948-
if (!pull.remote_address.ipv6)
949-
{
950-
create.add(new WinCmd("route ADD " + pull.remote_address.address + " MASK 255.255.255.255 " + gw.gateway_address()));
951-
destroy.add(new WinCmd("route DELETE " + pull.remote_address.address + " MASK 255.255.255.255 " + gw.gateway_address()));
952-
}
953-
}
954-
else
955-
throw tun_win_setup("redirect-gateway error: cannot detect default gateway");
956-
957-
create.add(new WinCmd("route ADD 0.0.0.0 MASK 128.0.0.0 " + local4->gateway));
958-
create.add(new WinCmd("route ADD 128.0.0.0 MASK 128.0.0.0 " + local4->gateway));
959-
destroy.add(new WinCmd("route DELETE 0.0.0.0 MASK 128.0.0.0 " + local4->gateway));
960-
destroy.add(new WinCmd("route DELETE 128.0.0.0 MASK 128.0.0.0 " + local4->gateway));
961-
}
962-
963-
// flush DNS cache
964-
// create.add(new WinCmd("net stop dnscache"));
965-
// create.add(new WinCmd("net start dnscache"));
966-
create.add(new WinCmd("ipconfig /flushdns"));
967-
// create.add(new WinCmd("ipconfig /registerdns"));
968-
destroy.add(new WinCmd("ipconfig /flushdns"));
969-
}
970-
#endif
971809

972810
void adapter_config_l2(HANDLE th,
973811
const std::wstring &openvpn_app_path,

0 commit comments

Comments
 (0)