Skip to content

Commit e87bb3f

Browse files
committed
Moved transport_dns to transport_dns_winsock
1 parent f12b0d3 commit e87bb3f

File tree

6 files changed

+101
-80
lines changed

6 files changed

+101
-80
lines changed

game/game.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ copy /b $(ProjectDir)source\config\version.cpp +,, $(ProjectDir)source\config\ve
338338
<ClCompile Include="source\networking\session\network_session_parameter_types.cpp" />
339339
<ClCompile Include="source\networking\tools\telnet_console.cpp" />
340340
<ClCompile Include="source\networking\tools\xbox_connection_manager.cpp" />
341+
<ClCompile Include="source\networking\transport\transport_dns_winsock.cpp" />
341342
<ClCompile Include="source\networking\transport\transport_qos.cpp" />
342343
<ClCompile Include="source\objects\crates.cpp" />
343344
<ClCompile Include="source\objects\damage_owner.cpp" />
@@ -1250,6 +1251,7 @@ copy /b $(ProjectDir)source\config\version.cpp +,, $(ProjectDir)source\config\ve
12501251
<ClInclude Include="source\networking\tools\network_web_events.hpp" />
12511252
<ClInclude Include="source\networking\tools\telnet_console.hpp" />
12521253
<ClInclude Include="source\networking\tools\xbox_connection_manager.hpp" />
1254+
<ClInclude Include="source\networking\transport\transport_dns_winsock.hpp" />
12531255
<ClInclude Include="source\objects\crates.hpp" />
12541256
<ClInclude Include="source\objects\reference_lists.hpp" />
12551257
<ClInclude Include="source\objects\scenery.hpp" />

game/game.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,9 @@
18931893
<ClCompile Include="source\render\render_mesh.cpp">
18941894
<Filter>Source Files</Filter>
18951895
</ClCompile>
1896+
<ClCompile Include="source\networking\transport\transport_dns_winsock.cpp">
1897+
<Filter>Source Files</Filter>
1898+
</ClCompile>
18961899
</ItemGroup>
18971900
<ItemGroup>
18981901
<ClInclude Include="source\camera\camera.hpp">
@@ -4289,6 +4292,9 @@
42894292
<ClInclude Include="source\_force_includes\_force_included_macros.hpp">
42904293
<Filter>Header Files</Filter>
42914294
</ClInclude>
4295+
<ClInclude Include="source\networking\transport\transport_dns_winsock.hpp">
4296+
<Filter>Header Files</Filter>
4297+
</ClInclude>
42924298
</ItemGroup>
42934299
<ItemGroup>
42944300
<ResourceCompile Include="resource\resource.rc">

game/source/networking/transport/transport_address.cpp

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
#include "cseries/cseries_events.hpp"
44
#include "game/players.hpp"
5-
#include "memory/byte_swapping.hpp"
65
#include "memory/module.hpp"
7-
#include "networking/transport/transport.hpp"
6+
#include "networking/transport/transport_dns_winsock.hpp"
87
#include "networking/transport/transport_security.hpp"
98

10-
#include <string.h>
11-
//#include <WinSock2.h>
12-
139
HOOK_DECLARE(0x0043F660, transport_address_equivalent);
1410
HOOK_DECLARE(0x0043F6F0, transport_address_get_string);
1511
HOOK_DECLARE(0x0043F720, transport_address_ipv4_extract);
@@ -47,74 +43,6 @@ transport_address::transport_address(s_player_identifier const* player_identifie
4743
address_length = sizeof(uint32);
4844
}
4945

50-
bool __cdecl transport_dns_address_to_name(dns_result* result)
51-
{
52-
return INVOKE(0x0043B330, transport_dns_address_to_name, result);
53-
54-
//if (!transport_available())
55-
// return false;
56-
//
57-
//ASSERT(result != NULL);
58-
//
59-
//transport_address* address = &result->address[0];
60-
//
61-
//union
62-
//{
63-
// uint32 ipv4_address;
64-
// uint16 ipv6_address[8];
65-
//} ip_address;
66-
//
67-
//int32 type = 0;
68-
//int32 address_length = 0;
69-
//switch (address->address_length)
70-
//{
71-
//case 4:
72-
//{
73-
// type = AF_INET;
74-
// address_length = 4;
75-
//
76-
// ip_address.ipv4_address = bswap_uint32(result->address[0].ipv4_address);
77-
//}
78-
//break;
79-
//case 16:
80-
//{
81-
// type = AF_INET6;
82-
// address_length = 16;
83-
//
84-
// ip_address.ipv6_address[0] = bswap_uint16(address->ina6.words[0]);
85-
// ip_address.ipv6_address[1] = bswap_uint16(address->ina6.words[1]);
86-
// ip_address.ipv6_address[2] = bswap_uint16(address->ina6.words[2]);
87-
// ip_address.ipv6_address[3] = bswap_uint16(address->ina6.words[3]);
88-
// ip_address.ipv6_address[4] = bswap_uint16(address->ina6.words[4]);
89-
// ip_address.ipv6_address[5] = bswap_uint16(address->ina6.words[5]);
90-
// ip_address.ipv6_address[6] = bswap_uint16(address->ina6.words[6]);
91-
// ip_address.ipv6_address[7] = bswap_uint16(address->ina6.words[7]);
92-
//}
93-
//break;
94-
//default:
95-
//{
96-
// event(_event_error, "networking:transport:dns: reverse dns failed: bad address type");
97-
// return false;
98-
//}
99-
//break;
100-
//}
101-
//
102-
//hostent* host = gethostbyaddr((const char*)&ip_address, address_length, type);
103-
//if (!host || !*host->h_aliases)
104-
//{
105-
// return false;
106-
//}
107-
//
108-
//csstrnzcpy(result->name, *host->h_aliases, sizeof(result->name));
109-
//result->name[255] = 0;
110-
//return true;
111-
}
112-
113-
bool __cdecl transport_dns_name_to_address(dns_result* result)
114-
{
115-
return INVOKE(0x0043B460, transport_dns_name_to_address, result);
116-
}
117-
11846
bool __cdecl transport_address_equivalent(transport_address const* a, transport_address const* b)
11947
{
12048
//return INVOKE(0x0043F660, transport_address_equivalent, a, b);

game/source/networking/transport/transport_address.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ struct transport_address
4040
};
4141
static_assert(sizeof(transport_address) == 0x14);
4242

43-
struct dns_result
44-
{
45-
transport_address address[8];
46-
char name[256];
47-
};
48-
static_assert(sizeof(dns_result) == 0x1A0);
49-
5043
extern bool __cdecl transport_address_equivalent(transport_address const* a, transport_address const* b);
5144
extern char const* __cdecl transport_address_get_string(transport_address const* address);
5245
extern void __cdecl transport_address_ipv4_build(transport_address* address, uint32 ip_address, uint16 port);
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#include "networking/transport/transport_dns_winsock.hpp"
2+
3+
#include "cseries/cseries.hpp"
4+
#include "cseries/cseries_events.hpp"
5+
#include "memory/byte_swapping.hpp"
6+
#include "networking/transport/transport.hpp"
7+
8+
//#define _WINSOCK_DEPRECATED_NO_WARNINGS
9+
//#include <WinSock2.h>
10+
11+
bool __cdecl transport_dns_address_to_name(dns_result* result)
12+
{
13+
return INVOKE(0x0043B330, transport_dns_address_to_name, result);
14+
15+
//if (!transport_available())
16+
// return false;
17+
//
18+
//ASSERT(result != NULL);
19+
//
20+
//transport_address* address = &result->address[0];
21+
//
22+
//union
23+
//{
24+
// uint32 ipv4_address;
25+
// uint16 ipv6_address[8];
26+
//} ip_address;
27+
//
28+
//int32 type = 0;
29+
//int32 address_length = 0;
30+
//switch (address->address_length)
31+
//{
32+
//case 4:
33+
//{
34+
// type = AF_INET;
35+
// address_length = 4;
36+
//
37+
// ip_address.ipv4_address = bswap_uint32(result->address[0].ipv4_address);
38+
//}
39+
//break;
40+
//case 16:
41+
//{
42+
// type = AF_INET6;
43+
// address_length = 16;
44+
//
45+
// ip_address.ipv6_address[0] = bswap_uint16(address->ina6.words[0]);
46+
// ip_address.ipv6_address[1] = bswap_uint16(address->ina6.words[1]);
47+
// ip_address.ipv6_address[2] = bswap_uint16(address->ina6.words[2]);
48+
// ip_address.ipv6_address[3] = bswap_uint16(address->ina6.words[3]);
49+
// ip_address.ipv6_address[4] = bswap_uint16(address->ina6.words[4]);
50+
// ip_address.ipv6_address[5] = bswap_uint16(address->ina6.words[5]);
51+
// ip_address.ipv6_address[6] = bswap_uint16(address->ina6.words[6]);
52+
// ip_address.ipv6_address[7] = bswap_uint16(address->ina6.words[7]);
53+
//}
54+
//break;
55+
//default:
56+
//{
57+
// event(_event_error, "networking:transport:dns: reverse dns failed: bad address type");
58+
// return false;
59+
//}
60+
//break;
61+
//}
62+
//
63+
//hostent* host = gethostbyaddr((const char*)&ip_address, address_length, type);
64+
//if (!host || !*host->h_aliases)
65+
//{
66+
// return false;
67+
//}
68+
//
69+
//csstrnzcpy(result->name, *host->h_aliases, sizeof(result->name));
70+
//result->name[255] = 0;
71+
//return true;
72+
}
73+
74+
bool __cdecl transport_dns_name_to_address(dns_result* result)
75+
{
76+
return INVOKE(0x0043B460, transport_dns_name_to_address, result);
77+
}
78+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
#include "networking/transport/transport_address.hpp"
4+
5+
struct dns_result
6+
{
7+
transport_address address[8];
8+
char name[256];
9+
};
10+
static_assert(sizeof(dns_result) == 0x1A0);
11+
12+
extern bool __cdecl transport_dns_address_to_name(dns_result* result);
13+
extern bool __cdecl transport_dns_name_to_address(dns_result* result);
14+

0 commit comments

Comments
 (0)