From 6a1876ad060b859a7dadf819a7d266a818b8fa20 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 10 Jun 2018 23:16:53 +0500 Subject: [PATCH] src/Mayaqua/Network: remove unused functions [src/Mayaqua/Network.c:7831]: (style) The function 'CheckSubnetLength6' is never used. [src/Mayaqua/Network.c:14663]: (style) The function 'CheckTCPPortThread' is never used. [src/Mayaqua/Network.c:6876]: (style) The function 'CheckUnicastAddress' is never used. [src/Mayaqua/Network.c:8220]: (style) The function 'CompareTcpTable' is never used. [src/Mayaqua/Network.c:7825]: (style) The function 'CopyIP' is never used. [src/Mayaqua/Network.c:18436]: (style) The function 'DelSockList' is never used. [src/Mayaqua/Network.c:549]: (style) The function 'DisableRUDPRegisterGlobally' is never used. [src/Mayaqua/Network.c:12161]: (style) The function 'DisableUDPChecksum' is never used. [src/Mayaqua/Network.c:6679]: (style) The function 'GenerateEui64GlobalAddress' is never used. [src/Mayaqua/Network.c:6953]: (style) The function 'GenerateMulticastMacAddress6' is never used. [src/Mayaqua/Network.c:7055]: (style) The function 'GetAllFilledAddress6' is never used. [src/Mayaqua/Network.c:11415]: (style) The function 'GetBestRouteEntryFromRouteTable' is never used. [src/Mayaqua/Network.c:16738]: (style) The function 'GetIP46Any4' is never used. [src/Mayaqua/Network.c:16771]: (style) The function 'GetIP46Any6' is never used. [src/Mayaqua/Network.c:16250]: (style) The function 'GetMachineIp' is never used. [src/Mayaqua/Network.c:12192]: (style) The function 'GetNewAvailableUdpPortRand' is never used. [src/Mayaqua/Network.c:11073]: (style) The function 'GetNumWaitThread' is never used. [src/Mayaqua/Network.c:561]: (style) The function 'GetSimpleHostname' is never used. [src/Mayaqua/Network.c:22688]: (style) The function 'GetSniNameFromPreSslConnection' is never used. [src/Mayaqua/Network.c:15761]: (style) The function 'GetSocketBufferSize' is never used. [src/Mayaqua/Network.c:6924]: (style) The function 'GetSoliciationMulticastAddr6' is never used. [src/Mayaqua/Network.c:7842]: (style) The function 'GetTcpProcessIdFromSocket' is never used. [src/Mayaqua/Network.c:7871]: (style) The function 'GetTcpProcessIdFromSocketReverse' is never used. [src/Mayaqua/Network.c:20709]: (style) The function 'GetUdpListenerPortList' is never used. [src/Mayaqua/Network.c:21971]: (style) The function 'HttpSendServerError' is never used. [src/Mayaqua/Network.c:7119]: (style) The function 'IPNot4' is never used. [src/Mayaqua/Network.c:7134]: (style) The function 'IPOr4' is never used. [src/Mayaqua/Network.c:17392]: (style) The function 'IPToStr128' is never used. [src/Mayaqua/Network.c:12182]: (style) The function 'InitAsyncSocket' is never used. [src/Mayaqua/Network.c:18091]: (style) The function 'IsIPLocalOrPrivate' is never used. [src/Mayaqua/Network.c:6813]: (style) The function 'IsInSameLocalNetworkToMe4' is never used. [src/Mayaqua/Network.c:467]: (style) The function 'IsInStrByStrList' is never used. [src/Mayaqua/Network.c:504]: (style) The function 'IsIpInStrList' is never used. [src/Mayaqua/Network.c:18793]: (style) The function 'IsIpStr46' is never used. [src/Mayaqua/Network.c:738]: (style) The function 'IsMacAddressLocal' is never used. [src/Mayaqua/Network.c:8495]: (style) The function 'IsNetworkAddress' is never used. [src/Mayaqua/Network.c:7803]: (style) The function 'IsSameIPVer' is never used. [src/Mayaqua/Network.c:14140]: (style) The function 'Listen6' is never used. [src/Mayaqua/Network.c:5792]: (style) The function 'ListenAnyPortEx' is never used. [src/Mayaqua/Network.c:11938]: (style) The function 'LockOpenSSL' is never used. [src/Mayaqua/Network.c:12266]: (style) The function 'NewRandPortByMachineAndExePath' is never used. [src/Mayaqua/Network.c:8191]: (style) The function 'PrintTcpTableList' is never used. [src/Mayaqua/Network.c:4773]: (style) The function 'RUDPGetRandPortNumber' is never used. [src/Mayaqua/Network.c:1637]: (style) The function 'RUDPSetSourceIpValidationForceDisable' is never used. [src/Mayaqua/Network.c:11157]: (style) The function 'RenewDhcp' is never used. [src/Mayaqua/Network.c:12057]: (style) The function 'SendTo6' is never used. [src/Mayaqua/Network.c:8691]: (style) The function 'SetNetworkReleaseMode' is never used. [src/Mayaqua/Network.c:18903]: (style) The function 'StrToMask46' is never used. [src/Mayaqua/Network.c:20013]: (style) The function 'UdpListenerGetPublicPortList' is never used. [src/Mayaqua/Network.c:20608]: (style) The function 'UdpListenerSendPacket' is never used. [src/Mayaqua/Network.c:17545]: (style) The function 'UniStrToIP' is never used. [src/Mayaqua/Network.c:8746]: (style) The function 'UnixCompareRouteEntryByMetric' is never used. [src/Mayaqua/Network.c:8736]: (style) The function 'UnixIpForwardRowToRouteEntry' is never used. [src/Mayaqua/Network.c:8741]: (style) The function 'UnixRouteEntryToIpForwardRow' is never used. [src/Mayaqua/Network.c:11944]: (style) The function 'UnlockOpenSSL' is never used. [src/Mayaqua/Network.c:7787]: (style) The function 'FreeTcpTableList' is never used. [src/Mayaqua/Network.c:16024]: (style) The function 'GetIP46' is never used. [src/Mayaqua/Network.c:7488]: (style) The function 'GetTcpTableFromEndPoint' is never used. [src/Mayaqua/Network.c:7777]: (style) The function 'GetTcpTableList' is never used. [src/Mayaqua/Network.c:6865]: (style) The function 'IPOr6' is never used. [src/Mayaqua/Network.c:6642]: (style) The function 'IsNetworkAddress6' is never used. [src/Mayaqua/Network.c:17942]: (style) The function 'StrToMask4' is never used. [src/Mayaqua/Network.c:8296]: (style) The function 'UnixRenewDhcp' is never used. [src/Mayaqua/Network.c:9337]: (style) The function 'Win32RenewDhcp' is never used. --- src/Mayaqua/Network.c | 1203 ----------------------------------------- src/Mayaqua/Network.h | 66 --- 2 files changed, 1269 deletions(-) diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c index 2be14462..7cc1beac 100644 --- a/src/Mayaqua/Network.c +++ b/src/Mayaqua/Network.c @@ -463,121 +463,18 @@ void FreeDynList() g_dyn_value_list = NULL; } -// Check whether the string in the string list appears in the specified string -bool IsInStrByStrList(char *str, char *str_list) -{ - TOKEN_LIST *t; - bool ret = false; - // Validate arguments - if (str == NULL || str_list == NULL) - { - return false; - } - - t = ParseTokenWithoutNullStr(str_list, ", \t\r\n"); - if (t != NULL) - { - UINT i; - - for (i = 0;i < t->NumTokens;i++) - { - char *s = t->Token[i]; - - if (StrLen(s) >= 1) - { - if (InStrEx(str, s, true)) - { - ret = true; - break; - } - } - } - } - - FreeToken(t); - - return ret; -} - - -// Search whether the IP address exists on the IP address list string -bool IsIpInStrList(IP *ip, char *ip_list) -{ - char ip_str[128]; - TOKEN_LIST *t; - bool ret = false; - // Validate arguments - if (ip == NULL || ip_list == NULL) - { - return false; - } - - Zero(ip_str, sizeof(ip_str)); - IPToStr(ip_str, sizeof(ip_str), ip); - - t = ParseTokenWithoutNullStr(ip_list, ", \t\r\n"); - - if (t != NULL) - { - UINT i; - - for (i = 0;i < t->NumTokens;i++) - { - char *s = t->Token[i]; - - if (StrCmpi(s, ip_str) == 0) - { - ret = true; - break; - } - } - } - - FreeToken(t); - - return ret; -} - - // Disable NAT-T function globally void DisableRDUPServerGlobally() { g_no_rudp_server = true; } -// Disable NAT-T registration globally -void DisableRUDPRegisterGlobally() -{ - g_no_rudp_register = true; -} - // Lower the priority of the host at NAT-T void SetNatTLowPriority() { g_natt_low_priority = true; } -// Extract only the host name part from FQDN -void GetSimpleHostname(char *hostname, UINT hostname_size, char *fqdn) -{ - UINT i; - ClearStr(hostname, hostname_size); - // Validate arguments - if (hostname == NULL || fqdn == NULL) - { - return; - } - - StrCpy(hostname, hostname_size, fqdn); - Trim(hostname); - - i = SearchStrEx(hostname, ".", 0, true); - if (i != INFINITE) - { - hostname[i] = 0; - } -} - // Get the current time zone int GetCurrentTimezone() { @@ -735,24 +632,6 @@ void RefreshLocalMacAddressList() } // Check whether the specified MAC address exists on the local host -bool IsMacAddressLocal(void *addr) -{ - LIST *o; - bool ret; - // Validate arguments - if (addr == NULL) - { - return false; - } - - o = GetNicList(); - - ret = IsMacAddressLocalInner(o, addr); - - FreeNicList(o); - - return ret; -} bool IsMacAddressLocalInner(LIST *o, void *addr) { bool ret = false; @@ -1633,12 +1512,6 @@ void RUDPProcess_NatT_Recv(RUDP_STACK *r, UDPPACKET *udp) FreeBuf(b); } -// Set the flag of the source IP address validation function -void RUDPSetSourceIpValidationForceDisable(bool b) -{ - g_source_ip_validation_force_disable = b; -} - // Process such as packet transmission for NAT-T server void RUDPDo_NatT_Interrupt(RUDP_STACK *r) { @@ -4769,22 +4642,6 @@ bool IsIPLocalHostOrMySelf(IP *ip) return ret; } -// Get the results of the port number that is determined at random -UINT RUDPGetRandPortNumber(UCHAR rand_port_id) -{ - UINT ret; - // Validate arguments - if (rand_port_id == 0) - { - return 0; - } - - ret = rand_port_numbers[rand_port_id]; - - Debug("rand_port_id[%u] = %u\n", rand_port_id, ret); - return ret; -} - // Obtain the hash value of combining all of the IP address assigned to the host UINT GetHostIPAddressHash32() { @@ -5789,10 +5646,6 @@ bool NewTcpPair(SOCK **s1, SOCK **s2) } // Listen in any available port -SOCK *ListenAnyPortEx(bool local_only) -{ - return ListenAnyPortEx2(local_only, false); -} SOCK *ListenAnyPortEx2(bool local_only, bool disable_ca) { UINT i; @@ -6675,32 +6528,6 @@ bool IsSubnetMask6(IP *a) return false; } -// Generate a global address from the MAC address -void GenerateEui64GlobalAddress(IP *ip, IP *prefix, IP *subnet, UCHAR *mac) -{ - UCHAR tmp[8]; - IP a; - IP subnet_not; - IP or1, or2; - // Validate arguments - if (ip == NULL || prefix == NULL || subnet == NULL || mac == NULL) - { - return; - } - - GenerateEui64Address6(tmp, mac); - - ZeroIP6(&a); - - Copy(&a.ipv6_addr[8], tmp, 8); - - IPNot6(&subnet_not, subnet); - IPAnd6(&or1, &a, &subnet_not); - IPAnd6(&or2, prefix, subnet); - - IPOr6(ip, &or1, &or2); -} - // Generate a local address from the MAC address void GenerateEui64LocalAddress(IP *a, UCHAR *mac) { @@ -6810,44 +6637,8 @@ bool IsInSameNetwork4Standard(IP *a1, IP *a2) return IsInSameNetwork4(a1, a2, &subnet); } -bool IsInSameLocalNetworkToMe4(IP *a) -{ - IP g1, g2; - - Zero(&g1, sizeof(g1)); - Zero(&g2, sizeof(g2)); - - GetCurrentGlobalIPGuess(&g1, false); - - if (IsZeroIp(&g1) == false) - { - if (IsInSameNetwork4Standard(&g1, a)) - { - return true; - } - } - - if (GetCurrentGlobalIP(&g2, false)) - { - if (IsInSameNetwork4Standard(&g2, a)) - { - return true; - } - } - - if (IsIPAddressInSameLocalNetwork(a)) - { - return true; - } - - return false; -} // Check whether it is a network address prefix -bool IsNetworkAddress6(IP *ip, IP *subnet) -{ - return IsNetworkPrefixAddress6(ip, subnet); -} bool IsNetworkPrefixAddress6(IP *ip, IP *subnet) { IP host; @@ -6872,23 +6663,6 @@ bool IsNetworkPrefixAddress6(IP *ip, IP *subnet) return false; } -// Check whether the unicast address is available -bool CheckUnicastAddress(IP *ip) -{ - // Validate arguments - if (ip == NULL) - { - return false; - } - - if ((GetIPAddrType6(ip) & IPV6_ADDR_UNICAST) == 0) - { - return false; - } - - return true; -} - // Get the host address void GetHostAddress6(IP *dst, IP *ip, IP *subnet) { @@ -6920,52 +6694,6 @@ void GetPrefixAddress6(IP *dst, IP *ip, IP *subnet) dst->ipv6_scope_id = ip->ipv6_scope_id; } -// Get the solicited-node multicast address -void GetSoliciationMulticastAddr6(IP *dst, IP *src) -{ - IP prefix; - IP mask104; - IP or1, or2; - - // Validate arguments - if (dst == NULL || src == NULL) - { - return; - } - - ZeroIP6(&prefix); - prefix.ipv6_addr[0] = 0xff; - prefix.ipv6_addr[1] = 0x02; - prefix.ipv6_addr[11] = 0x01; - prefix.ipv6_addr[12] = 0xff; - - IntToSubnetMask6(&mask104, 104); - - IPAnd6(&or1, &prefix, &mask104); - IPAnd6(&or2, src, &mask104); - - IPOr6(dst, &or1, &or2); - - dst->ipv6_scope_id = src->ipv6_scope_id; -} - -// Generate a MAC address corresponding to the multicast address -void GenerateMulticastMacAddress6(UCHAR *mac, IP *ip) -{ - // Validate arguments - if (mac == NULL) - { - return; - } - - mac[0] = 0x33; - mac[1] = 0x33; - mac[2] = ip->ipv6_addr[12]; - mac[3] = ip->ipv6_addr[13]; - mac[4] = ip->ipv6_addr[14]; - mac[5] = ip->ipv6_addr[15]; -} - // Get the type of the IPv6 address UINT GetIPv6AddrType(IPV6_ADDR *addr) { @@ -7051,24 +6779,6 @@ UINT GetIPAddrType6(IP *ip) return ret; } -// Address that all of the bits are set -void GetAllFilledAddress6(IP *ip) -{ - UINT i; - // Validate arguments - if (ip == NULL) - { - return; - } - - ZeroIP6(ip); - - for (i = 0;i < 15;i++) - { - ip->ipv6_addr[i] = 0xff; - } -} - // Loopback address void GetLoopbackAddress6(IP *ip) { @@ -7116,35 +6826,6 @@ void GetAllRouterMulticastAddress6(IP *ip) } // Logical operation of the IPv4 address -void IPNot4(IP *dst, IP *a) -{ - UINT i; - // Validate arguments - if (dst == NULL || a == NULL || IsIP4(a) == false) - { - Zero(dst, sizeof(IP)); - return; - } - - i = IPToUINT(a); - i = ~i; - - UINTToIP(dst, i); -} -void IPOr4(IP *dst, IP *a, IP *b) -{ - UINT i; - // Validate arguments - if (dst == NULL || a == NULL || b == NULL || IsIP4(a) == false || IsIP4(b) == false) - { - Zero(dst, sizeof(IP)); - return; - } - - i = IPToUINT(a) | IPToUINT(b); - - UINTToIP(dst, i); -} void IPAnd4(IP *dst, IP *a, IP *b) { UINT i; @@ -7177,22 +6858,6 @@ void IPAnd6(IP *dst, IP *a, IP *b) dst->ipv6_addr[i] = a->ipv6_addr[i] & b->ipv6_addr[i]; } } -void IPOr6(IP *dst, IP *a, IP *b) -{ - UINT i; - // Validate arguments - if (dst == NULL || IsIP6(a) == false || IsIP6(b) == false) - { - ZeroIP6(dst); - return; - } - - ZeroIP6(dst); - for (i = 0;i < 16;i++) - { - dst->ipv6_addr[i] = a->ipv6_addr[i] | b->ipv6_addr[i]; - } -} void IPNot6(IP *dst, IP *a) { UINT i; @@ -7799,154 +7464,6 @@ bool IsIP4(IP *ip) return (IsIP6(ip) ? false : true); } -// Examine whether the version of the two IP addresses are same -bool IsSameIPVer(IP *ip1, IP *ip2) -{ - // Validate arguments - if (ip1 == NULL || ip2 == NULL) - { - return false; - } - - if (IsIP4(ip1) && IsIP4(ip2)) - { - return true; - } - - if (IsIP6(ip1) && IsIP6(ip2)) - { - return true; - } - - return false; -} - -// Copy the IP address -void CopyIP(IP *dst, IP *src) -{ - Copy(dst, src, sizeof(IP)); -} - -// Check the length of the IPv6 subnet -bool CheckSubnetLength6(UINT i) -{ - if (i >= 1 && i <= 127) - { - return true; - } - - return false; -} - -// Get the process ID of the corresponding TCP connection by the socket -UINT GetTcpProcessIdFromSocket(SOCK *s) -{ - LIST *o; - TCPTABLE *t; - UINT pid = 0; - // Validate arguments - if (s == NULL) - { - return 0; - } - - o = GetTcpTableList(); - if (o == NULL) - { - return 0; - } - - t = GetTcpTableFromEndPoint(o, &s->LocalIP, s->LocalPort, - &s->RemoteIP, s->RemotePort); - - if (t != NULL) - { - pid = t->ProcessId; - } - - FreeTcpTableList(o); - - return pid; -} -UINT GetTcpProcessIdFromSocketReverse(SOCK *s) -{ - LIST *o; - TCPTABLE *t; - UINT pid = 0; - // Validate arguments - if (s == NULL) - { - return 0; - } - - o = GetTcpTableList(); - if (o == NULL) - { - return 0; - } - - t = GetTcpTableFromEndPoint(o, &s->RemoteIP, s->RemotePort, - &s->LocalIP, s->LocalPort); - - if (t != NULL) - { - pid = t->ProcessId; - } - - FreeTcpTableList(o); - - return pid; -} - -// Search in the TCP table by the end point -TCPTABLE *GetTcpTableFromEndPoint(LIST *o, IP *local_ip, UINT local_port, IP *remote_ip, UINT remote_port) -{ - IP local; - UINT i; - // Validate arguments - if (o == NULL) - { - return NULL; - } - - SetIP(&local, 127, 0, 0, 1); - - if (local_ip == NULL) - { - local_ip = &local; - } - - if (remote_ip == NULL) - { - remote_ip = &local; - } - - for (i = 0;i < LIST_NUM(o);i++) - { - TCPTABLE *t = LIST_DATA(o, i); - - if (t->Status == TCP_STATE_SYN_SENT || t->Status == TCP_STATE_SYN_RCVD || - t->Status == TCP_STATE_ESTAB) - { - if (CmpIpAddr(&t->LocalIP, local_ip) == 0) - { - if (CmpIpAddr(&t->RemoteIP, remote_ip) == 0) - { - if (t->LocalPort == local_port) - { - if (t->RemotePort == remote_port) - { - return t; - } - } - } - } - } - } - - return NULL; -} - // Get the TCP table list (Win32) #ifdef OS_WIN32 LIST *Win32GetTcpTableList() @@ -8187,83 +7704,6 @@ LIST *Win32GetTcpTableListByGetTcpTable() #endif // OS_WIN32 -// Display the TCP table -void PrintTcpTableList(LIST *o) -{ - UINT i; - // Validate arguments - if (o == NULL) - { - Print("o == NULL\n\n"); - return; - } - - Print("--- TCPTABLE: %u Entries ---\n", LIST_NUM(o)); - for (i = 0;i < LIST_NUM(o);i++) - { - char tmp1[MAX_PATH], tmp2[MAX_PATH]; - TCPTABLE *t = LIST_DATA(o, i); - - IPToStr(tmp1, sizeof(tmp1), &t->LocalIP); - IPToStr(tmp2, sizeof(tmp2), &t->RemoteIP); - - Print("%s:%u <--> %s:%u state=%u pid=%u\n", - tmp1, t->LocalPort, - tmp2, t->RemotePort, - t->Status, - t->ProcessId); - } - Print("------\n\n"); -} - -// Comparison of TCP table items -int CompareTcpTable(void *p1, void *p2) -{ - TCPTABLE *t1, *t2; - if (p1 == NULL || p2 == NULL) - { - return 0; - } - t1 = *(TCPTABLE **)p1; - t2 = *(TCPTABLE **)p2; - if (t1 == NULL || t2 == NULL) - { - return 0; - } - - return Cmp(t1, t2, sizeof(TCPTABLE)); -} - -// Get the TCP table list -LIST *GetTcpTableList() -{ -#ifdef OS_WIN32 - return Win32GetTcpTableList(); -#else // OS_WIN32 - return NULL; -#endif // OS_WIN32 -} - -// Release the TCP table list -void FreeTcpTableList(LIST *o) -{ - UINT i; - // Validate arguments - if (o == NULL) - { - return; - } - - for (i = 0;i < LIST_NUM(o);i++) - { - TCPTABLE *t = LIST_DATA(o, i); - - Free(t); - } - - ReleaseList(o); -} - // Get the number of clients connected from the specified IP address UINT GetNumIpClient(IP *ip) { @@ -8492,17 +7932,6 @@ bool IsHostIPAddress32(UINT ip) } // Check whether the specified IP address and subnet mask indicates a network correctly -bool IsNetworkAddress(IP *ip, IP *mask) -{ - if (IsIP4(ip)) - { - return IsNetworkAddress4(ip, mask); - } - else - { - return IsNetworkAddress6(ip, mask); - } -} bool IsNetworkAddress4(IP *ip, IP *mask) { UINT a, b; @@ -8687,12 +8116,6 @@ bool IsSubnetMask32(UINT ip) return IsSubnetMask4(&p); } -// Network release mode -void SetNetworkReleaseMode() -{ - NetworkReleaseMode = true; -} - #ifdef OS_UNIX // Code for UNIX // Turn on and off the non-blocking mode of the socket @@ -8732,22 +8155,6 @@ void UnixSetSocketNonBlockingMode(int fd, bool nonblock) #endif // FIONBIO } -// Do Nothing -void UnixIpForwardRowToRouteEntry(ROUTE_ENTRY *entry, void *ip_forward_row) -{ -} - -// Do Nothing -void UnixRouteEntryToIpForwardRow(void *ip_forward_row, ROUTE_ENTRY *entry) -{ -} - -// Do Nothing -int UnixCompareRouteEntryByMetric(void *p1, void *p2) -{ - return 1; -} - // Do Nothing ROUTE_TABLE *UnixGetRouteTable() { @@ -8786,11 +8193,6 @@ char **UnixEnumVLan(char *tag_name) return list; } -// Do Nothing -void UnixRenewDhcp() -{ -} - // Get the IP address of the default DNS server bool UnixGetDefaultDns(IP *ip) { @@ -9931,27 +9333,6 @@ void Win32ReleaseDhcp9x(UINT if_id, bool wait) Free(info); } -// Re-obtain an IP address from a DHCP server -void Win32RenewDhcp() -{ - if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType)) - { - Run("ipconfig.exe", "/renew", true, false); - if (MsIsVista()) - { - Run("ipconfig.exe", "/renew6", true, false); - } - else - { - Run("netsh.exe", "int ipv6 renew", true, false); - } - } - else - { - Run("ipconfig.exe", "/renew_all", true, false); - } -} - // Enumerate a list of virtual LAN cards that contains the specified string char **Win32EnumVLan(char *tag_name) { @@ -11069,20 +10450,6 @@ void InitHostCache() HostCacheList = NewList(CompareHostCache); } -// Get the number of wait threads -UINT GetNumWaitThread() -{ - UINT ret = 0; - - LockList(WaitThreadList); - { - ret = LIST_NUM(WaitThreadList); - } - UnlockList(WaitThreadList); - - return ret; -} - // Add the thread to the thread waiting list void AddWaitThread(THREAD *t) { @@ -11153,16 +10520,6 @@ void FreeWaitThread() WaitThreadList = NULL; } -// Renewing the IP address of the DHCP server -void RenewDhcp() -{ -#ifdef OS_WIN32 - Win32RenewDhcp(); -#else - UnixRenewDhcp(); -#endif -} - // Get a domain name for UNIX bool UnixGetDomainName(char *name, UINT size) { @@ -11412,10 +10769,6 @@ void Cancel(CANCEL *c) } // Calculate the optimal route from the specified routing table -ROUTE_ENTRY *GetBestRouteEntryFromRouteTable(ROUTE_TABLE *table, IP *ip) -{ - return GetBestRouteEntryFromRouteTableEx(table, ip, 0); -} ROUTE_ENTRY *GetBestRouteEntryFromRouteTableEx(ROUTE_TABLE *table, IP *ip, UINT exclude_if_id) { UINT i; @@ -11934,18 +11287,6 @@ UINT RecvFrom6(SOCK *sock, IP *src_addr, UINT *src_port, void *data, UINT size) } } -// Lock the OpenSSL -void LockOpenSSL() -{ - Lock(openssl_lock); -} - -// Unlock the OpenSSL -void UnlockOpenSSL() -{ - Unlock(openssl_lock); -} - // UDP transmission UINT SendTo(SOCK *sock, IP *dest_addr, UINT dest_port, void *data, UINT size) { @@ -12054,10 +11395,6 @@ UINT SendToEx(SOCK *sock, IP *dest_addr, UINT dest_port, void *data, UINT size, return ret; } -UINT SendTo6(SOCK *sock, IP *dest_addr, UINT dest_port, void *data, UINT size) -{ - return SendTo6Ex(sock, dest_addr, dest_port, data, size, false); -} UINT SendTo6Ex(SOCK *sock, IP *dest_addr, UINT dest_port, void *data, UINT size, bool broadcast) { SOCKET s; @@ -12157,68 +11494,6 @@ UINT SendTo6Ex(SOCK *sock, IP *dest_addr, UINT dest_port, void *data, UINT size, return ret; } -// Disable the UDP checksum -void DisableUDPChecksum(SOCK *s) -{ - bool true_flag = true; - // Validate arguments - if (s == NULL || s->Type != SOCK_UDP) - { - return; - } - - if (s->socket != INVALID_SOCKET) - { - if (s->IPv6 == false) - { -#ifdef UDP_NOCHECKSUM - setsockopt(s->socket, IPPROTO_UDP, UDP_NOCHECKSUM, (char *)&true_flag, sizeof(bool)); -#endif // UDP_NOCHECKSUM - } - } -} - -// Set the socket to asynchronous mode -void InitAsyncSocket(SOCK *sock) -{ -#ifdef OS_WIN32 - Win32InitAsyncSocket(sock); -#else // OS_WIN32 - UnixInitAsyncSocket(sock); -#endif // OS_WIN32 -} - -// Get a new available UDP port number -UINT GetNewAvailableUdpPortRand() -{ - UINT num_retry = 8; - UINT i; - UINT ret = 0; - UCHAR seed[SHA1_SIZE]; - - Rand(seed, sizeof(seed)); - - for (i = 0;i < num_retry;i++) - { - SOCK *s = NewUDPEx2Rand(false, NULL, seed, sizeof(seed), RAND_UDP_PORT_DEFAULT_NUM_RETRY); - - if (s != NULL) - { - ret = s->LocalPort; - - Disconnect(s); - ReleaseSock(s); - } - - if (ret != 0) - { - break; - } - } - - return ret; -} - // Open a UDP port (port number is random, but determine the randomness in the seed) SOCK *NewUDPEx2Rand(bool ipv6, IP *ip, void *rand_seed, UINT rand_seed_size, UINT num_retry) { @@ -12262,47 +11537,6 @@ SOCK *NewUDPEx2Rand(bool ipv6, IP *ip, void *rand_seed, UINT rand_seed_size, UIN return NewUDPEx2(0, ipv6, ip); } -// Generate a random port number (based on the EXE path and machine key) -UINT NewRandPortByMachineAndExePath(UINT start_port, UINT end_port, UINT additional_int) -{ - BUF *b; - char machine_name[MAX_SIZE]; - wchar_t exe_path[MAX_PATH]; - char *product_id = NULL; - UCHAR hash[SHA1_SIZE]; - -#ifdef OS_WIN32 - product_id = MsRegReadStr(REG_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "ProductId"); - if (product_id == NULL) - { - product_id = MsRegReadStr(REG_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion", "ProductId"); - } -#endif // OS_WIN32 - - b = NewBuf(); - - GetMachineHostName(machine_name, sizeof(machine_name)); - Trim(machine_name); - StrUpper(machine_name); - - GetExeNameW(exe_path, sizeof(exe_path)); - UniTrim(exe_path); - UniStrUpper(exe_path); - - WriteBuf(b, machine_name, StrSize(machine_name)); - WriteBuf(b, exe_path, UniStrSize(exe_path)); - WriteBuf(b, product_id, StrSize(product_id)); - WriteBufInt(b, additional_int); - - HashSha1(hash, b->Buf, b->Size); - - FreeBuf(b); - - Free(product_id); - - return (READ_UINT(hash) % (end_port - start_port)) + start_port; -} - // Open the UDP port (based on the EXE path and machine key) SOCK *NewUDPEx2RandMachineAndExePath(bool ipv6, IP *ip, UINT num_retry, UCHAR rand_port_id) { @@ -14137,10 +13371,6 @@ SOCK *Accept6(SOCK *sock) } // Standby for TCP (IPv6) -SOCK *Listen6(UINT port) -{ - return ListenEx6(port, false); -} SOCK *ListenEx6(UINT port, bool local_only) { return ListenEx62(port, local_only, false); @@ -14659,39 +13889,6 @@ typedef struct TCP_PORT_CHECK bool ok; } TCP_PORT_CHECK; -// The thread to check the TCP port -void CheckTCPPortThread(THREAD *thread, void *param) -{ - TCP_PORT_CHECK *c; - SOCK *s; - // Validate arguments - if (thread == NULL || param == NULL) - { - return; - } - - c = (TCP_PORT_CHECK *)param; - AddRef(c->ref); - NoticeThreadInit(thread); - - AddWaitThread(thread); - - s = Connect(c->hostname, c->port); - if (s != NULL) - { - c->ok = true; - Disconnect(s); - ReleaseSock(s); - } - - if (Release(c->ref) == 0) - { - Free(c); - } - - DelWaitThread(thread); -} - // Check whether the TCP port can be connected bool CheckTCPPortEx(char *hostname, UINT port, UINT timeout) { @@ -15757,25 +14954,6 @@ void SetSocketSendRecvBufferSize(SOCKET s, UINT size) setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&value, sizeof(int)); } -// Get the buffer size of the socket -UINT GetSocketBufferSize(SOCKET s, bool send) -{ - int value = 0; - int len = sizeof(int); - // Validate arguments - if (s == INVALID_SOCKET) - { - return 0; - } - - if (getsockopt(s, SOL_SOCKET, (send ? SO_SNDBUF : SO_RCVBUF), (char *)&value, &len) != 0) - { - return 0; - } - - return value; -} - // Setting the buffer size of the socket bool SetSocketBufferSize(SOCKET s, bool send, UINT size) { @@ -16246,23 +15424,6 @@ void GetMachineHostName(char *name, UINT size) ConvertSafeFileName(name, size, tmp); } -// Get the IP address of this computer -void GetMachineIp(IP *ip) -{ - char tmp[MAX_SIZE]; - // Validate arguments - if (ip == NULL) - { - return; - } - - Zero(ip, sizeof(IP)); - SetIP(ip, 127, 0, 0, 1); - - GetMachineName(tmp, sizeof(tmp)); - GetIP(ip, tmp); -} - // Get the computer name from 'hosts' bool GetMachineNameFromHosts(char *name, UINT size) { @@ -16734,77 +15895,7 @@ UINT SetIP32(UCHAR a1, UCHAR a2, UCHAR a3, UCHAR a4) return IPToUINT(&ip); } -// Get either of v4 and v6 results with a DNS forward lookup (The IPv4 precedes in the case of both results) -bool GetIP46Any4(IP *ip, char *hostname) -{ - IP ip4, ip6; - bool b = false; - // Validate arguments - if (ip == NULL || hostname == NULL) - { - return false; - } - - if (GetIP46(&ip4, &ip6, hostname) == false) - { - return false; - } - - if (IsZeroIp(&ip6) == false) - { - Copy(ip, &ip6, sizeof(IP)); - - b = true; - } - - if (IsZeroIp(&ip4) == false) - { - Copy(ip, &ip4, sizeof(IP)); - - b = true; - } - - return b; -} - -// Get either of v4 and v6 results with a DNS forward lookup (The IPv6 precedes in the case of both) -bool GetIP46Any6(IP *ip, char *hostname) -{ - IP ip4, ip6; - bool b = false; - // Validate arguments - if (ip == NULL || hostname == NULL) - { - return false; - } - - if (GetIP46(&ip4, &ip6, hostname) == false) - { - return false; - } - - if (IsZeroIp(&ip4) == false) - { - Copy(ip, &ip4, sizeof(IP)); - - b = true; - } - - if (IsZeroIp(&ip6) == false) - { - Copy(ip, &ip6, sizeof(IP)); - - b = true; - } - - return b; -} - // Obtain in both v4 and v6 results with a DNS forward lookup -bool GetIP46(IP *ip4, IP *ip6, char *hostname) -{ - return GetIP46Ex(ip4, ip6, hostname, 0, NULL); -} bool GetIP46Ex(IP *ip4, IP *ip6, char *hostname, UINT timeout, bool *cancel) { IP a, b; @@ -17388,20 +16479,6 @@ void IPToUniStr32(wchar_t *str, UINT size, UINT ip) StrToUni(str, size, tmp); } -// Convert the IP to a string (128bit byte array) -void IPToStr128(char *str, UINT size, UCHAR *ip_bytes) -{ - IP ip_st; - // Validate arguments - if (str == NULL) - { - return; - } - - SetIP6(&ip_st, ip_bytes); - IPToStr(str, size, &ip_st); -} - // Convert the IP to a string (32bit UINT) void IPToStr32(char *str, UINT size, UINT ip) { @@ -17542,17 +16619,6 @@ UINT StrToIP32(char *str) return IPToUINT(&ip); } -bool UniStrToIP(IP *ip, wchar_t *str) -{ - char *tmp; - bool ret; - - tmp = CopyUniToStr(str); - ret = StrToIP(ip, tmp); - Free(tmp); - - return ret; -} UINT UniStrToIP32(wchar_t *str) { UINT ret; @@ -18087,33 +17153,6 @@ bool IsIPPrivate(IP *ip) return false; } -// Is the IP address either local or private? -bool IsIPLocalOrPrivate(IP *ip) -{ - // Validate arguments - if (ip == NULL) - { - return false; - } - - if (IsIPPrivate(ip)) - { - return true; - } - - if (IsLocalHostIP(ip)) - { - return true; - } - - if (IsIPMyHost(ip)) - { - return true; - } - - return false; -} - // Read a private IP list file void LoadPrivateIPFile() { @@ -18432,25 +17471,6 @@ void FreeNetwork() } -// Remove the socket from socket list -void DelSockList(SOCKLIST *sl, SOCK *s) -{ - // Validate arguments - if (sl == NULL || s == NULL) - { - return; - } - - LockList(sl->SockList); - { - if (Delete(sl->SockList, s)) - { - ReleaseSock(s); - } - } - UnlockList(sl->SockList); -} - // Stop all the sockets in the list and delete it void StopSockList(SOCKLIST *sl) { @@ -18789,59 +17809,6 @@ bool IsIpStr6(char *str) return true; } -// Check whether the IP address specification is correct -bool IsIpStr46(char *str) -{ - if (IsIpStr4(str) || IsIpStr6(str)) - { - return true; - } - - return false; -} - - -// Convert the string to an IPv4 mask -bool StrToMask4(IP *mask, char *str) -{ - // Validate arguments - if (mask == NULL || str == NULL) - { - return false; - } - - if (str[0] == '/') - { - str++; - } - - if (IsNum(str)) - { - UINT n = ToInt(str); - - if (n <= 32) - { - IntToSubnetMask4(mask, n); - return true; - } - else - { - return false; - } - } - else - { - if (StrToIP(mask, str) == false) - { - return false; - } - else - { - return IsIP4(mask); - } - } -} - // Convert the string to an IPv6 mask bool StrToMask6(IP *mask, char *str) { @@ -18899,20 +17866,6 @@ bool StrToMask6Addr(IPV6_ADDR *mask, char *str) return true; } -// Convert the string to an IPv4 / IPv6 mask -bool StrToMask46(IP *mask, char *str, bool ipv6) -{ - if (ipv6) - { - return StrToMask6(mask, str); - } - else - { - return StrToMask4(mask, str); - } -} - - // Convert the IPv4 / IPv6 mask to a string void MaskToStr(char *str, UINT size, IP *mask) { @@ -20009,37 +18962,6 @@ void FreeQueryIpThread(QUERYIPTHREAD *t) Free(t); } -// Get a public port list which is known by UDP listener -void UdpListenerGetPublicPortList(UDPLISTENER *u, char *dst, UINT size) -{ - UINT k; - // Validate arguments - ClearStr(dst, size); - if (u == NULL || dst == NULL) - { - return; - } - - LockList(u->PortList); - { - for (k = 0;k < LIST_NUM(u->SockList);k++) - { - UDPLISTENER_SOCK *us = LIST_DATA(u->SockList, k); - - if (us->PublicPort != 0) - { - char tmp[64]; - ToStr(tmp, us->PublicPort); - StrCat(dst, size, tmp); - StrCat(dst, size, " "); - } - } - } - UnlockList(u->PortList); - - Trim(dst); -} - // UDP listener thread void UdpListenerThread(THREAD *thread, void *param) { @@ -20605,22 +19527,6 @@ void UdpListenerSendPackets(UDPLISTENER *u, LIST *packet_list) SetSockEvent(u->Event); } } -void UdpListenerSendPacket(UDPLISTENER *u, UDPPACKET *packet) -{ - LIST *o; - // Validate arguments - if (u == NULL || packet == NULL) - { - return; - } - - o = NewListFast(NULL); - Add(o, packet); - - UdpListenerSendPackets(u, o); - - ReleaseList(o); -} // Creating a UDP listener UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param, IP *listen_ip) @@ -20705,36 +19611,6 @@ void AddPortToUdpListener(UDPLISTENER *u, UINT port) SetSockEvent(u->Event); } -// Get the port list -UINT GetUdpListenerPortList(UDPLISTENER *u, UINT **port_list) -{ - UINT num_ports; - // Validate arguments - if (u == NULL || port_list == NULL) - { - return 0; - } - - LockList(u->PortList); - { - UINT *ports; - UINT i; - - num_ports = LIST_NUM(u->PortList); - ports = ZeroMalloc(sizeof(UINT) * num_ports); - - for (i = 0;i < num_ports;i++) - { - ports[i] = *((UINT *)(LIST_DATA(u->PortList, i))); - } - - *port_list = ports; - } - UnlockList(u->PortList); - - return num_ports; -} - // Delete all the UDP ports void DeleteAllPortFromUdpListener(UDPLISTENER *u) { @@ -21967,65 +20843,6 @@ bool HttpSendNotFound(SOCK *s, char *target) return ret; } -// Sending a 500 Server Error -bool HttpSendServerError(SOCK *s, char *target) -{ - HTTP_HEADER *h; - char date_str[MAX_SIZE]; - char *str; - UINT str_size; - char port_str[MAX_SIZE]; - bool ret; - char host[MAX_SIZE]; - UINT port; - // Validate arguments - if (s == NULL || target == NULL) - { - return false; - } - - // Get the host name - //GetMachineName(host, MAX_SIZE); - Zero(host, sizeof(host)); - IPToStr(host, sizeof(host), &s->LocalIP); - // Get the port number - port = s->LocalPort; - - // Creating a header - GetHttpDateStr(date_str, sizeof(date_str), SystemTime64()); - - h = NewHttpHeader("HTTP/1.1", "500", "Server Error"); - - AddHttpValue(h, NewHttpValue("Date", date_str)); - AddHttpValue(h, NewHttpValue("Keep-Alive", HTTP_KEEP_ALIVE)); - AddHttpValue(h, NewHttpValue("Connection", "Keep-Alive")); - AddHttpValue(h, NewHttpValue("Content-Type", HTTP_CONTENT_TYPE)); - - // Creating a Data - str_size = sizeof(http_500_str) * 2 + StrLen(target) + StrLen(host); - str = Malloc(str_size); - StrCpy(str, str_size, http_500_str); - - // TARGET - ReplaceUnsafeCharInTarget(target); - ReplaceStri(str, str_size, str, "$TARGET$", target); - - // HOST - ReplaceStri(str, str_size, str, "$HOST$", host); - - // PORT - ToStr(port_str, port); - ReplaceStri(str, str_size, str, "$PORT$", port_str); - - // Transmission - ret = PostHttp(s, h, str, StrLen(str)); - - FreeHttpHeader(h); - Free(str); - - return ret; -} - // Sending a 403 Forbidden error bool HttpSendForbidden(SOCK *s, char *target, char *server_id) { @@ -22684,26 +21501,6 @@ bool SendPackWithHash(SOCK *s, PACK *p) return SendNow(s, s->SecureMode); } -// Get SNI name from the data that has arrived to the TCP connection before accepting an SSL connection -bool GetSniNameFromPreSslConnection(SOCK *s, char *sni, UINT sni_size) -{ - UCHAR tmp[1500]; - UINT size; - // Validate arguments - if (s == NULL || sni == NULL) - { - return false; - } - - size = Peek(s, tmp, sizeof(tmp)); - if (size == 0) - { - return false; - } - - return GetSniNameFromSslPacket(tmp, size, sni, sni_size); -} - // Get SNI name from the SSL packet bool GetSniNameFromSslPacket(UCHAR *packet_buf, UINT packet_size, char *sni, UINT sni_size) { diff --git a/src/Mayaqua/Network.h b/src/Mayaqua/Network.h index d3a7d13a..b3a6cbfd 100644 --- a/src/Mayaqua/Network.h +++ b/src/Mayaqua/Network.h @@ -1019,7 +1019,6 @@ struct HTTP_HEADER int GetCurrentTimezone(); bool GetSniNameFromSslPacket(UCHAR *packet_buf, UINT packet_size, char *sni, UINT sni_size); -bool GetSniNameFromPreSslConnection(SOCK *s, char *sni, UINT sni_size); void SetDhParam(DH_CTX *dh); @@ -1065,8 +1064,6 @@ bool HttpClientSend(SOCK *s, PACK *p); PACK *HttpServerRecv(SOCK *s); PACK *HttpClientRecv(SOCK *s); -bool HttpSendServerError(SOCK *s, char *target); - bool GetIPViaDnsProxyForJapanFlets(IP *ip_ret, char *hostname, bool ipv6, UINT timeout, bool *cancel, char *dns_proxy_hostname); bool GetDnsProxyIPAddressForJapanBFlets(IP *ip_ret, UINT timeout, bool *cancel); BUF *QueryFileByUdpForJapanBFlets(UINT timeout, bool *cancel); @@ -1127,8 +1124,6 @@ void RUDPBulkSend(RUDP_STACK *r, RUDP_SESSION *se, void *data, UINT data_size); bool RUDPProcessBulkRecvPacket(RUDP_STACK *r, RUDP_SESSION *se, void *recv_data, UINT recv_size); UINT RUDPCalcBestMssForBulk(RUDP_STACK *r, RUDP_SESSION *se); bool IsIPLocalHostOrMySelf(IP *ip); -UINT RUDPGetRandPortNumber(UCHAR rand_port_id); -void RUDPSetSourceIpValidationForceDisable(bool b); bool RUDPIsIpInValidateList(RUDP_STACK *r, IP *ip); void RUDPAddIpToValidateList(RUDP_STACK *r, IP *ip); @@ -1163,7 +1158,6 @@ void Win32CleanupSockEvent(SOCK_EVENT *event); bool Win32WaitSockEvent(SOCK_EVENT *event, UINT timeout); bool Win32GetDefaultDns(IP *ip, char *domain, UINT size); bool Win32GetDnsSuffix(char *domain, UINT size); -void Win32RenewDhcp(); void Win32RenewDhcp9x(UINT if_id); void Win32ReleaseDhcp9x(UINT if_id, bool wait); void Win32FlushDnsCache(); @@ -1198,9 +1192,6 @@ void UnixSelect(SOCKSET *set, UINT timeout, CANCEL *c1, CANCEL *c2); void UnixInitAsyncSocket(SOCK *sock); void UnixJoinSockToSockEvent(SOCK *sock, SOCK_EVENT *event); void UnixFreeAsyncSocket(SOCK *sock); -void UnixIpForwardRowToRouteEntry(ROUTE_ENTRY *entry, void *ip_forward_row); -void UnixRouteEntryToIpForwardRow(void *ip_forward_row, ROUTE_ENTRY *entry); -int UnixCompareRouteEntryByMetric(void *p1, void *p2); ROUTE_TABLE *UnixGetRouteTable(); bool UnixAddRouteEntry(ROUTE_ENTRY *e, bool *already_exists); void UnixDeleteRouteEntry(ROUTE_ENTRY *e); @@ -1214,7 +1205,6 @@ void UnixSetSockEvent(SOCK_EVENT *event); void UnixCleanupSockEvent(SOCK_EVENT *event); bool UnixWaitSockEvent(SOCK_EVENT *event, UINT timeout); bool UnixGetDefaultDns(IP *ip); -void UnixRenewDhcp(); void UnixNewPipe(int *pipe_read, int *pipe_write); void UnixWritePipe(int pipe_write); void UnixDeletePipe(int p1, int p2); @@ -1244,20 +1234,15 @@ void IPToInAddr(struct in_addr *addr, IP *ip); void IPToInAddr6(struct in6_addr *addr, IP *ip); bool StrToIP(IP *ip, char *str); UINT StrToIP32(char *str); -bool UniStrToIP(IP *ip, wchar_t *str); UINT UniStrToIP32(wchar_t *str); void IPToStr(char *str, UINT size, IP *ip); void IPToStr4(char *str, UINT size, IP *ip); void IPToStr32(char *str, UINT size, UINT ip); -void IPToStr128(char *str, UINT size, UCHAR *ip_bytes); void IPToStr4or6(char *str, UINT size, UINT ip_4_uint, UCHAR *ip_6_bytes); void IPToUniStr(wchar_t *str, UINT size, IP *ip); void IPToUniStr32(wchar_t *str, UINT size, UINT ip); bool GetIPEx(IP *ip, char *hostname, bool ipv6); -bool GetIP46(IP *ip4, IP *ip6, char *hostname); bool GetIP46Ex(IP *ip4, IP *ip6, char *hostname, UINT timeout, bool *cancel); -bool GetIP46Any4(IP *ip, char *hostname); -bool GetIP46Any6(IP *ip, char *hostname); bool GetIP(IP *ip, char *hostname); bool GetIP4(IP *ip, char *hostname); bool GetIP6(IP *ip, char *hostname); @@ -1277,7 +1262,6 @@ void GetHostNameThread(THREAD *t, void *p); void GetMachineName(char *name, UINT size); void GetMachineNameEx(char *name, UINT size, bool no_load_hosts); bool GetMachineNameFromHosts(char *name, UINT size); -void GetMachineIp(IP *ip); void GetMachineHostName(char *name, UINT size); void UINTToIP(IP *ip, UINT value); UINT IPToUINT(IP *ip); @@ -1291,7 +1275,6 @@ SOCK *ConnectEx3(char *hostname, UINT port, UINT timeout, bool *cancel_flag, cha SOCK *ConnectEx4(char *hostname, UINT port, UINT timeout, bool *cancel_flag, char *nat_t_svc_name, UINT *nat_t_error_code, bool try_start_ssl, bool ssl_no_tls, bool no_get_hostname, IP *ret_ip); SOCKET ConnectTimeoutIPv4(IP *ip, UINT port, UINT timeout, bool *cancel_flag); void SetSocketSendRecvBufferSize(SOCKET s, UINT size); -UINT GetSocketBufferSize(SOCKET s, bool send); bool SetSocketBufferSize(SOCKET s, bool send, UINT size); UINT SetSocketBufferSizeWithBestEffort(SOCKET s, bool send, UINT size); void InitUdpSocketBufferSize(SOCKET s); @@ -1301,7 +1284,6 @@ void Disconnect(SOCK *sock); SOCK *Listen(UINT port); SOCK *ListenEx(UINT port, bool local_only); SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca, IP *listen_ip); -SOCK *Listen6(UINT port); SOCK *ListenEx6(UINT port, bool local_only); SOCK *ListenEx62(UINT port, bool local_only, bool enable_ca); SOCK *Accept(SOCK *sock); @@ -1330,7 +1312,6 @@ void CleanupCancel(CANCEL *c); void Cancel(CANCEL *c); void Select(SOCKSET *set, UINT timeout, CANCEL *c1, CANCEL *c2); void SetWantToUseCipher(SOCK *sock, char *name); -void InitAsyncSocket(SOCK *sock); SOCK *NewUDP(UINT port); SOCK *NewUDPEx(UINT port, bool ipv6); SOCK *NewUDPEx2(UINT port, bool ipv6, IP *ip); @@ -1341,12 +1322,8 @@ SOCK *NewUDPEx2Rand(bool ipv6, IP *ip, void *rand_seed, UINT rand_seed_size, UIN SOCK *NewUDPEx2RandMachineAndExePath(bool ipv6, IP *ip, UINT num_retry, UCHAR rand_port_id); void ClearSockDfBit(SOCK *s); void SetRawSockHeaderIncludeOption(SOCK *s, bool enable); -UINT GetNewAvailableUdpPortRand(); -UINT NewRandPortByMachineAndExePath(UINT start_port, UINT end_port, UINT additional_int); -void DisableUDPChecksum(SOCK *s); UINT SendTo(SOCK *sock, IP *dest_addr, UINT dest_port, void *data, UINT size); UINT SendToEx(SOCK *sock, IP *dest_addr, UINT dest_port, void *data, UINT size, bool broadcast); -UINT SendTo6(SOCK *sock, IP *dest_addr, UINT dest_port, void *data, UINT size); UINT SendTo6Ex(SOCK *sock, IP *dest_addr, UINT dest_port, void *data, UINT size, bool broadcast); UINT RecvFrom(SOCK *sock, IP *src_addr, UINT *src_port, void *data, UINT size); UINT RecvFrom6(SOCK *sock, IP *src_addr, UINT *src_port, void *data, UINT size); @@ -1354,7 +1331,6 @@ void SetTimeout(SOCK *sock, UINT timeout); UINT GetTimeout(SOCK *sock); bool CheckTCPPort(char *hostname, UINT port); bool CheckTCPPortEx(char *hostname, UINT port, UINT timeout); -void CheckTCPPortThread(THREAD *thread, void *param); ROUTE_TABLE *GetRouteTable(); void FreeRouteTable(ROUTE_TABLE *t); bool AddRouteEntryEx(ROUTE_ENTRY *e, bool *already_exists); @@ -1365,7 +1341,6 @@ void FreeEnumVLan(char **s); UINT GetVLanInterfaceID(char *tag_name); ROUTE_ENTRY *GetBestRouteEntry(IP *ip); ROUTE_ENTRY *GetBestRouteEntryEx(IP *ip, UINT exclude_if_id); -ROUTE_ENTRY *GetBestRouteEntryFromRouteTable(ROUTE_TABLE *table, IP *ip); ROUTE_ENTRY *GetBestRouteEntryFromRouteTableEx(ROUTE_TABLE *table, IP *ip, UINT exclude_if_id); void FreeRouteEntry(ROUTE_ENTRY *e); void JoinSockToSockEvent(SOCK *sock, SOCK_EVENT *event); @@ -1379,7 +1354,6 @@ UINT SetIP32(UCHAR a1, UCHAR a2, UCHAR a3, UCHAR a4); bool GetDefaultDns(IP *ip); bool GetDomainName(char *name, UINT size); bool UnixGetDomainName(char *name, UINT size); -void RenewDhcp(); void AcceptInit(SOCK *s); void AcceptInitEx(SOCK *s, bool no_lookup_hostname); void DisableGetHostNameWhenAcceptInit(); @@ -1397,7 +1371,6 @@ bool GetHostCache(char *hostname, UINT size, IP *ip); bool IsSubnetMask(IP *ip); bool IsSubnetMask4(IP *ip); bool IsSubnetMask32(UINT ip); -bool IsNetworkAddress(IP *ip, IP *mask); bool IsNetworkAddress4(IP *ip, IP *mask); bool IsNetworkAddress32(UINT ip, UINT mask); bool IsHostIPAddress4(IP *ip); @@ -1410,7 +1383,6 @@ void IntToSubnetMask4(IP *ip, UINT i); bool GetNetBiosName(char *name, UINT size, IP *ip); bool NormalizeMacAddress(char *dst, UINT size, char *src); SOCKLIST *NewSockList(); -void DelSockList(SOCKLIST *sl, SOCK *s); void StopSockList(SOCKLIST *sl); void FreeSockList(SOCKLIST *sl); bool IsIPv6Supported(); @@ -1424,13 +1396,6 @@ void DelIpClient(IP *ip); IP_CLIENT *SearchIpClient(IP *ip); UINT GetNumIpClient(IP *ip); void SetLinuxArpFilter(); -LIST *GetTcpTableList(); -void FreeTcpTableList(LIST *o); -int CompareTcpTable(void *p1, void *p2); -void PrintTcpTableList(LIST *o); -TCPTABLE *GetTcpTableFromEndPoint(LIST *o, IP *local_ip, UINT local_port, IP *remote_ip, UINT remote_port); -UINT GetTcpProcessIdFromSocket(SOCK *s); -UINT GetTcpProcessIdFromSocketReverse(SOCK *s); int connect_timeout(SOCKET s, struct sockaddr *addr, int size, int timeout, bool *cancel_flag); void EnableNetworkNameCache(); void DisableNetworkNameCache(); @@ -1442,7 +1407,6 @@ void RouteToStr(char *str, UINT str_size, ROUTE_ENTRY *e); void DebugPrintRoute(ROUTE_ENTRY *e); void DebugPrintRouteTable(ROUTE_TABLE *r); bool IsIPv6LocalNetworkAddress(IP *ip); -UINT GetNumWaitThread(); #ifdef ENABLE_SSL_LOGGING void SockEnableSslLogging(SOCK *s); @@ -1454,11 +1418,8 @@ void SocketTimeoutThread(THREAD *t, void *param); SOCKET_TIMEOUT_PARAM *NewSocketTimeout(SOCK *sock); void FreeSocketTimeout(SOCKET_TIMEOUT_PARAM *ttp); -void CopyIP(IP *dst, IP *src); -bool CheckSubnetLength6(UINT i); bool IsIP6(IP *ip); bool IsIP4(IP *ip); -bool IsSameIPVer(IP *ip1, IP *ip2); void IPv6AddrToIP(IP *ip, IPV6_ADDR *addr); bool IPToIPv6Addr(IPV6_ADDR *addr, IP *ip); void SetIP6(IP *ip, UCHAR *value); @@ -1479,19 +1440,13 @@ void IPToStr6Array(char *str, UINT size, UCHAR *bytes); void IPToStr6Inner(char *str, IP *ip); void IntToSubnetMask6(IP *ip, UINT i); void IPNot6(IP *dst, IP *a); -void IPOr6(IP *dst, IP *a, IP *b); void IPAnd6(IP *dst, IP *a, IP *b); void GetAllRouterMulticastAddress6(IP *ip); void GetAllNodeMulticaseAddress6(IP *ip); void GetLoopbackAddress6(IP *ip); -void GetAllFilledAddress6(IP *ip); UINT GetIPAddrType6(IP *ip); UINT GetIPv6AddrType(IPV6_ADDR *addr); -void GenerateMulticastMacAddress6(UCHAR *mac, IP *ip); -void GetSoliciationMulticastAddr6(IP *dst, IP *src); -bool CheckUnicastAddress(IP *ip); bool IsNetworkPrefixAddress6(IP *ip, IP *subnet); -bool IsNetworkAddress6(IP *ip, IP *subnet); void GetHostAddress6(IP *dst, IP *ip, IP *subnet); void GetPrefixAddress6(IP *dst, IP *ip, IP *subnet); bool IsNetworkPrefixAddress6(IP *ip, IP *subnet); @@ -1499,18 +1454,14 @@ bool IsInSameNetwork6(IP *a1, IP *a2, IP *subnet); bool IsInSameNetwork6ByStr(char *ip1, char *ip2, char *subnet); void GenerateEui64Address6(UCHAR *dst, UCHAR *mac); void GenerateEui64LocalAddress(IP *a, UCHAR *mac); -void GenerateEui64GlobalAddress(IP *ip, IP *prefix, IP *subnet, UCHAR *mac); bool IsSubnetMask6(IP *a); UINT SubnetMaskToInt(IP *a); UINT SubnetMaskToInt6(IP *a); UINT SubnetMaskToInt4(IP *a); bool IsStrIPv6Address(char *str); -void IPNot4(IP *dst, IP *a); -void IPOr4(IP *dst, IP *a, IP *b); void IPAnd4(IP *dst, IP *a, IP *b); bool IsInSameNetwork4(IP *a1, IP *a2, IP *subnet); bool IsInSameNetwork4Standard(IP *a1, IP *a2); -bool IsInSameLocalNetworkToMe4(IP *a); bool ParseIpAndSubnetMask4(char *src, UINT *ip, UINT *mask); bool ParseIpAndSubnetMask6(char *src, IP *ip, IP *mask); @@ -1521,11 +1472,8 @@ bool ParseIpAndMask46(char *src, IP *ip, IP *mask); bool IsIpStr4(char *str); bool IsIpStr6(char *str); bool IsIpMask6(char *str); -bool IsIpStr46(char *str); -bool StrToMask4(IP *mask, char *str); bool StrToMask6(IP *mask, char *str); bool StrToMask6Addr(IPV6_ADDR *mask, char *str); -bool StrToMask46(IP *mask, char *str, bool ipv6); void MaskToStr(char *str, UINT size, IP *mask); void Mask6AddrToStrEx(char *str, UINT size, IPV6_ADDR *mask, bool always_full_address); void Mask6AddrToStr(char *str, UINT size, IPV6_ADDR *mask); @@ -1570,14 +1518,11 @@ UINT64 GetHostIPAddressListHash(); UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param, IP *listen_ip); void UdpListenerThread(THREAD *thread, void *param); -void UdpListenerGetPublicPortList(UDPLISTENER *u, char *dst, UINT size); void FreeUdpListener(UDPLISTENER *u); void AddPortToUdpListener(UDPLISTENER *u, UINT port); void DeletePortFromUdpListener(UDPLISTENER *u, UINT port); void DeleteAllPortFromUdpListener(UDPLISTENER *u); -UINT GetUdpListenerPortList(UDPLISTENER *u, UINT **port_list); void UdpListenerSendPackets(UDPLISTENER *u, LIST *packet_list); -void UdpListenerSendPacket(UDPLISTENER *u, UDPPACKET *packet); UDPPACKET *NewUdpPacket(IP *src_ip, UINT src_port, IP *dst_ip, UINT dst_port, void *data, UINT size); void FreeUdpPacket(UDPPACKET *p); UDPLISTENER_SOCK *DetermineUdpSocketForSending(UDPLISTENER *u, UDPPACKET *p); @@ -1602,7 +1547,6 @@ SOCK *AcceptReverse(SOCK *s); void InjectNewReverseSocketToAccept(SOCK *listen_sock, SOCK *s, IP *client_ip, UINT client_port); bool NewTcpPair(SOCK **s1, SOCK **s2); -SOCK *ListenAnyPortEx(bool local_only); SOCK *ListenAnyPortEx2(bool local_only, bool disable_ca); bool IsIcmpApiSupported(); @@ -1639,7 +1583,6 @@ void GetCurrentGlobalIPGuess(IP *ip, bool ipv6); bool IsIPAddressInSameLocalNetwork(IP *a); bool IsIPPrivate(IP *ip); -bool IsIPLocalOrPrivate(IP *ip); bool IsIPMyHost(IP *ip); void LoadPrivateIPFile(); bool IsOnPrivateIPFile(UINT ip); @@ -1647,7 +1590,6 @@ void FreePrivateIPFile(); LIST *GetNicList(); void FreeNicList(LIST *o); -bool IsMacAddressLocal(void *addr); bool IsMacAddressLocalInner(LIST *o, void *addr); bool IsMacAddressLocalFast(void *addr); void RefreshLocalMacAddressList(); @@ -1659,10 +1601,7 @@ void SetCurrentDDnsFqdn(char *name); void GetCurrentDDnsFqdn(char *name, UINT size); UINT GetCurrentDDnsFqdnHash(); -void GetSimpleHostname(char *hostname, UINT hostname_size, char *fqdn); - void DisableRDUPServerGlobally(); -void DisableRUDPRegisterGlobally(); void SetNatTLowPriority(); void QueryIpThreadMain(THREAD *thread, void *param); @@ -1674,11 +1613,6 @@ void SetGetIpThreadMaxNum(UINT num); UINT GetGetIpThreadMaxNum(); UINT GetCurrentGetIpThreadNum(); - - -bool IsIpInStrList(IP *ip, char *ip_list); -bool IsInStrByStrList(char *str, char *str_list); - #ifdef OS_WIN32 LIST *Win32GetNicList(); #endif // OS_WIN32