void upgradevlan(UINT num, char **arg) { bool ok; KAKUSHI *k = NULL; MS_DRIVER_VER ver; if (num < 1) { return; } InitWinUi(L"VPN", _SS("DEFAULT_FONT"), _II("DEFAULT_FONT_SIZE")); if (MsIsNt()) { k = InitKakushi(); } CiInitDriverVerStruct(&ver); ok = MsUpgradeVLan(VLAN_ADAPTER_NAME_TAG, VLAN_CONNECTION_NAME, arg[0], &ver); FreeKakushi(k); FreeWinUi(); if (ok == false) { _exit(1); } else { _exit(0); } }
// Show the folder selection dialog wchar_t *FolderDlgW(HWND hWnd, wchar_t *title, wchar_t *default_dir) { wchar_t *ret; if (MsIsNt() == false) { char *default_dir_a = CopyUniToStr(default_dir); char *ret_a = FolderDlgA(hWnd, title, default_dir_a); ret = CopyStrToUni(ret_a); Free(ret_a); Free(default_dir_a); return ret; } ret = FolderDlgInnerW(hWnd, title, default_dir); return ret; }
// End the tracking of the routing table void RouteTrackingStop(SESSION *s, ROUTE_TRACKING *t) { ROUTE_ENTRY *e; ROUTE_TABLE *table; IP dns_ip; bool network_has_changed = false; bool do_not_delete_routing_entry = false; // Validate arguments if (s == NULL || t == NULL) { return; } Zero(&dns_ip, sizeof(dns_ip)); // Remove the default gateway added by the virtual LAN card if (MsIsVista() == false) { if (t->DefaultGatewayByVLan != NULL) { Debug("Default Gateway by VLAN was deleted.\n"); DeleteRouteEntry(t->DefaultGatewayByVLan); } if (t->VistaOldDefaultGatewayByVLan != NULL) { FreeRouteEntry(t->VistaOldDefaultGatewayByVLan); } } if (t->DefaultGatewayByVLan != NULL) { FreeRouteEntry(t->DefaultGatewayByVLan); t->DefaultGatewayByVLan = NULL; } if (t->VistaDefaultGateway1 != NULL) { Debug("Vista PPP Fix Route Table Deleted.\n"); DeleteRouteEntry(t->VistaDefaultGateway1); FreeRouteEntry(t->VistaDefaultGateway1); DeleteRouteEntry(t->VistaDefaultGateway2); FreeRouteEntry(t->VistaDefaultGateway2); } if (MsIsNt() == false) { // Only in the case of Windows 9x, release the DHCP address of the virtual LAN card Win32ReleaseDhcp9x(t->VLanInterfaceId, false); } // Clear the DNS cache Win32FlushDnsCache(); if (s->Cedar->Client != NULL && s->Account != NULL) { UINT i; ACCOUNT *a; for (i = 0;i < LIST_NUM(s->Cedar->Client->AccountList);i++) { a = LIST_DATA(s->Cedar->Client->AccountList, i); Lock(a->lock); { SESSION *sess = a->ClientSession; if (sess != NULL && sess != s) { VLAN *v = sess->PacketAdapter->Param; if (v != NULL) { ROUTE_TRACKING *tr = v->RouteState; if (tr != NULL) { if (Cmp(tr->RouteToServer, t->RouteToServer, sizeof(ROUTE_ENTRY)) == 0) { do_not_delete_routing_entry = true; } } } } } Unlock(a->lock); } Lock(s->Account->lock); } if (do_not_delete_routing_entry == false) { // Delete the route that is added firstly if (t->RouteToServerAlreadyExists == false) { DeleteRouteEntry(t->RouteToServer); } DeleteRouteEntry(t->RouteToDefaultDns); DeleteRouteEntry(t->RouteToNatTServer); DeleteRouteEntry(t->RouteToRealServerGlobal); } FreeRouteEntry(t->RouteToDefaultDns); FreeRouteEntry(t->RouteToServer); FreeRouteEntry(t->RouteToEight); FreeRouteEntry(t->RouteToNatTServer); FreeRouteEntry(t->RouteToRealServerGlobal); t->RouteToDefaultDns = t->RouteToServer = t->RouteToEight = t->RouteToNatTServer = t->RouteToRealServerGlobal = NULL; if (s->Cedar->Client != NULL && s->Account != NULL) { Unlock(s->Account->lock); } #if 0 // Get the current DNS server if (GetDefaultDns(&dns_ip)) { if (IPToUINT(&t->OldDnsServer) != 0) { if (IPToUINT(&t->OldDnsServer) != IPToUINT(&dns_ip)) { char s1[MAX_SIZE], s2[MAX_SIZE]; network_has_changed = true; IPToStr(s1, sizeof(s1), &t->OldDnsServer); IPToStr(s2, sizeof(s2), &dns_ip); Debug("Old Dns: %s, New Dns: %s\n", s1, s2); } } } if (network_has_changed == false) { Debug("Network: not changed.\n"); } else { Debug("Network: Changed.\n"); } #endif // Get the current routing table table = GetRouteTable(); // Restore the routing table which has been removed so far while (e = GetNext(t->DeletedDefaultGateway)) { bool restore = true; UINT i; // If the restoring routing entry is a default gateway and // the existing routing table contains another default gateway // on the interface, give up restoring the entry if (IPToUINT(&e->DestIP) == 0 && IPToUINT(&e->DestMask) == 0) { for (i = 0;i < table->NumEntry;i++) { ROUTE_ENTRY *r = table->Entry[i]; if (IPToUINT(&r->DestIP) == 0 && IPToUINT(&r->DestMask) == 0) { if (r->InterfaceID == e->InterfaceID) { restore = false; } } } if (network_has_changed) { restore = false; } } if (restore) { // Routing table restoration AddRouteEntry(e); } // Memory release FreeRouteEntry(e); } // Release FreeRouteTable(table); ReleaseQueue(t->DeletedDefaultGateway); FreeRouteChange(t->RouteChange); Free(t); }