mirror of
https://github.com/Cesarus85/ringfall-mjolnir-vr.git
synced 2026-10-24 16:00:48 +02:00
Complete transport address object
This commit is contained in:
1 parent
50e22f0959
commit
b287bb949b
3 files changed
+139
-2
No files matched your search
+1
-1
@@ -746,7 +746,7 @@
|
||||
{ "name": "source/bungie_net/network/transport_endpoint_winsock.c", "index": 372, "status": "NonMatching" },
|
||||
{ "name": "source/bungie_net/network/transport_endpoint_set_winsock.c", "index": 373, "status": "NonMatching" },
|
||||
{ "name": "source/bungie_net/network/transport_dns_winsock.c", "index": 374, "status": "Matching" },
|
||||
{ "name": "source/bungie_net/network/transport_address.c", "index": 375, "status": "NonMatching" },
|
||||
{ "name": "source/bungie_net/network/transport_address.c", "index": 375, "status": "Matching" },
|
||||
{ "name": "source/bungie_net/common/thread_win32.c", "index": 376, "status": "NonMatching" },
|
||||
{ "name": "source/bungie_net/common/random_numbers.c", "index": 377, "status": "Matching" },
|
||||
{ "name": "source/bungie_net/common/public_key_crypt.c", "index": 378, "status": "NonMatching" },
|
||||
|
||||
@@ -13,16 +13,50 @@ header included in hcex build.
|
||||
enum
|
||||
{
|
||||
IPV4_ADDRESS_LENGTH = 4,
|
||||
IPV6_ADDRESS_LENGTH = 16,
|
||||
MAXIMUM_TRANSPORT_ADDRESS_LENGTH = 16,
|
||||
};
|
||||
|
||||
enum transport_error
|
||||
{
|
||||
_transport_result_connect_in_progress = -23,
|
||||
_transport_result_dns_lookup_in_progress,
|
||||
_transport_error_poll_error,
|
||||
_transport_error_endpoint_set_full,
|
||||
_transport_error_endpoint_not_in_set,
|
||||
_transport_error_options_failed,
|
||||
_transport_error_listen_failed,
|
||||
_transport_error_connect_failed,
|
||||
_transport_error_address_unknown,
|
||||
_transport_error_bind_endpoint,
|
||||
_transport_result_poll_timeout,
|
||||
_transport_error_bad_endpoint,
|
||||
_transport_error_buffers_full,
|
||||
_transport_error_seg_fault,
|
||||
_transport_error_out_of_memory,
|
||||
_transport_error_dns_lookup_failure,
|
||||
_transport_error_bad_input_parameters,
|
||||
_transport_result_already_initialized,
|
||||
_transport_error_not_initialized,
|
||||
_transport_result_operation_would_block,
|
||||
_transport_error_connection_lost,
|
||||
_transport_error_endpoint_io,
|
||||
_transport_error_unknown,
|
||||
_transport_error_none,
|
||||
};
|
||||
|
||||
/* ---------- macros */
|
||||
|
||||
/* ---------- structures */
|
||||
|
||||
struct transport_address_data
|
||||
{
|
||||
unsigned long words[MAXIMUM_TRANSPORT_ADDRESS_LENGTH / sizeof(unsigned long)];
|
||||
union
|
||||
{
|
||||
byte bytes[MAXIMUM_TRANSPORT_ADDRESS_LENGTH];
|
||||
word words[MAXIMUM_TRANSPORT_ADDRESS_LENGTH / sizeof(word)];
|
||||
unsigned long long_words[MAXIMUM_TRANSPORT_ADDRESS_LENGTH / sizeof(unsigned long)];
|
||||
};
|
||||
};
|
||||
|
||||
struct transport_address
|
||||
@@ -44,6 +78,10 @@ void delete_transport_address(
|
||||
long transport_address_equivalent(
|
||||
struct transport_address const *a,
|
||||
struct transport_address const *b);
|
||||
char const *transport_address_to_string(
|
||||
struct transport_address const *addr);
|
||||
char const *transport_error_to_string(
|
||||
short error);
|
||||
|
||||
/* ---------- globals */
|
||||
|
||||
|
||||
@@ -104,6 +104,8 @@ symbols in this file:
|
||||
|
||||
/* ---------- globals */
|
||||
|
||||
char transport_address_string[256];
|
||||
|
||||
/* ---------- public code */
|
||||
|
||||
struct transport_address *create_transport_address(
|
||||
@@ -160,4 +162,101 @@ long transport_address_equivalent(
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char const *transport_address_to_string(
|
||||
struct transport_address const *addr)
|
||||
{
|
||||
match_assert("c:\\halo\\SOURCE\\bungie_net\\network\\transport_address.c", 74, addr);
|
||||
match_assert("c:\\halo\\SOURCE\\bungie_net\\network\\transport_address.c", 75, IPV4_ADDRESS_LENGTH == addr->address_length);
|
||||
|
||||
transport_address_string[0] = 0;
|
||||
if (addr->address_length == IPV4_ADDRESS_LENGTH)
|
||||
{
|
||||
_snprintf(
|
||||
transport_address_string,
|
||||
NUMBEROF(transport_address_string),
|
||||
"%hd.%hd.%hd.%hd:%hd",
|
||||
addr->address.bytes[3],
|
||||
addr->address.bytes[2],
|
||||
addr->address.bytes[1],
|
||||
addr->address.bytes[0],
|
||||
addr->port);
|
||||
}
|
||||
else if (addr->address_length == IPV6_ADDRESS_LENGTH)
|
||||
{
|
||||
_snprintf(
|
||||
transport_address_string,
|
||||
NUMBEROF(transport_address_string),
|
||||
"%4X.%4X.%4X.%4X.%4X.%4X.%4X.%4X:%hd",
|
||||
addr->address.words[0],
|
||||
addr->address.words[1],
|
||||
addr->address.words[2],
|
||||
addr->address.words[3],
|
||||
addr->address.words[4],
|
||||
addr->address.words[5],
|
||||
addr->address.words[6],
|
||||
addr->address.words[7],
|
||||
addr->port);
|
||||
}
|
||||
|
||||
return transport_address_string;
|
||||
}
|
||||
|
||||
char const *transport_error_to_string(
|
||||
short error)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
case _transport_error_none:
|
||||
return "_transport_error_none";
|
||||
case _transport_error_unknown:
|
||||
return "_transport_error_unknown";
|
||||
case _transport_error_endpoint_io:
|
||||
return "_transport_error_endpoint_io";
|
||||
case _transport_error_connection_lost:
|
||||
return "_transport_error_connection_lost";
|
||||
case _transport_result_operation_would_block:
|
||||
return "_transport_result_operation_would_block";
|
||||
case _transport_error_not_initialized:
|
||||
return "_transport_error_not_initialized";
|
||||
case _transport_result_already_initialized:
|
||||
return "_transport_result_already_initialized";
|
||||
case _transport_error_bad_input_parameters:
|
||||
return "_transport_error_bad_input_parameters";
|
||||
case _transport_error_dns_lookup_failure:
|
||||
return "_transport_error_dns_lookup_failure";
|
||||
case _transport_error_out_of_memory:
|
||||
return "_transport_error_out_of_memory";
|
||||
case _transport_error_seg_fault:
|
||||
return "_transport_error_seg_fault";
|
||||
case _transport_error_buffers_full:
|
||||
return "_transport_error_buffers_full";
|
||||
case _transport_error_bad_endpoint:
|
||||
return "_transport_error_bad_endpoint";
|
||||
case _transport_result_poll_timeout:
|
||||
return "_transport_result_poll_timeout";
|
||||
case _transport_error_bind_endpoint:
|
||||
return "_transport_error_bind_endpoint";
|
||||
case _transport_error_address_unknown:
|
||||
return "_transport_error_address_unknown";
|
||||
case _transport_error_connect_failed:
|
||||
return "_transport_error_connect_failed";
|
||||
case _transport_error_listen_failed:
|
||||
return "_transport_error_listen_failed";
|
||||
case _transport_error_options_failed:
|
||||
return "_transport_error_options_failed";
|
||||
case _transport_error_endpoint_not_in_set:
|
||||
return "_transport_error_endpoint_not_in_set";
|
||||
case _transport_error_endpoint_set_full:
|
||||
return "_transport_error_endpoint_set_full";
|
||||
case _transport_error_poll_error:
|
||||
return "_transport_error_poll_error";
|
||||
case _transport_result_dns_lookup_in_progress:
|
||||
return "_transport_result_dns_lookup_in_progress";
|
||||
case _transport_result_connect_in_progress:
|
||||
return "_transport_result_connect_in_progress";
|
||||
default:
|
||||
return "<unknown transport error>";
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- private code */
|
||||
Reference in new issue
Block a user